Skip to content

Commit 0481475

Browse files
committed
Merge remote-tracking branch 'origin/2.3-develop' into MAGETWO-97237
2 parents e25e3dd + 4f23251 commit 0481475

File tree

39 files changed

+684
-306
lines changed

39 files changed

+684
-306
lines changed

app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
use Magento\Backend\Block\Template\Context;
1010
use Magento\Backend\Block\Widget\Accordion;
11-
use Magento\Backend\Block\Widget\Tabs as WigetTabs;
11+
use Magento\Backend\Block\Widget\Tabs as WidgetTabs;
1212
use Magento\Backend\Model\Auth\Session;
1313
use Magento\Catalog\Helper\Catalog;
1414
use Magento\Catalog\Helper\Data;
@@ -22,7 +22,7 @@
2222
* Admin product edit tabs
2323
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2424
*/
25-
class Tabs extends WigetTabs
25+
class Tabs extends WidgetTabs
2626
{
2727
const BASIC_TAB_GROUP_CODE = 'basic';
2828

@@ -109,7 +109,7 @@ public function __construct(
109109
}
110110

111111
/**
112-
* @return void
112+
* @inheritdoc
113113
*/
114114
protected function _construct()
115115
{
@@ -119,6 +119,8 @@ protected function _construct()
119119
}
120120

121121
/**
122+
* Get group collection.
123+
*
122124
* @param int $attributeSetId
123125
* @return \Magento\Eav\Model\ResourceModel\Entity\Attribute\Group\Collection
124126
*/
@@ -131,10 +133,11 @@ public function getGroupCollection($attributeSetId)
131133
}
132134

133135
/**
134-
* @return $this
136+
* @inheritdoc
135137
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
136-
* @SuppressWarnings(PHPMD.NPathComplexity)
137138
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
139+
* @SuppressWarnings(PHPMD.NPathComplexity)
140+
* @SuppressWarnings(PHPMD.RequestAwareBlockMethod)
138141
*/
139142
protected function _prepareLayout()
140143
{
@@ -315,6 +318,8 @@ public function getAttributeTabBlock()
315318
}
316319

317320
/**
321+
* Set attribute tab block.
322+
*
318323
* @param string $attributeTabBlock
319324
* @return $this
320325
*/
@@ -337,6 +342,8 @@ protected function _translateHtml($html)
337342
}
338343

339344
/**
345+
* Get accordion.
346+
*
340347
* @param string $parentTab
341348
* @return string
342349
*/

app/code/Magento/Catalog/Model/Product/Gallery/CreateHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ protected function duplicate($product)
318318

319319
$this->resourceModel->duplicate(
320320
$this->getAttribute()->getAttributeId(),
321-
isset($mediaGalleryData['duplicate']) ? $mediaGalleryData['duplicate'] : [],
321+
$mediaGalleryData['duplicate'] ?? [],
322322
$product->getOriginalLinkId(),
323323
$product->getData($this->metadata->getLinkField())
324324
);

app/code/Magento/Catalog/Model/ResourceModel/Product/Gallery.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
67
namespace Magento\Catalog\Model\ResourceModel\Product;
78

89
use Magento\Store\Model\Store;
@@ -149,7 +150,7 @@ public function loadProductGalleryByAttributeId($product, $attributeId)
149150
*/
150151
protected function createBaseLoadSelect($entityId, $storeId, $attributeId)
151152
{
152-
$select = $this->createBatchBaseSelect($storeId, $attributeId);
153+
$select = $this->createBatchBaseSelect($storeId, $attributeId);
153154

154155
$select = $select->where(
155156
'entity.' . $this->metadata->getLinkField() . ' = ?',
@@ -378,9 +379,9 @@ public function deleteGalleryValueInStore($valueId, $entityId, $storeId)
378379
$conditions = implode(
379380
' AND ',
380381
[
381-
$this->getConnection()->quoteInto('value_id = ?', (int) $valueId),
382-
$this->getConnection()->quoteInto($this->metadata->getLinkField() . ' = ?', (int) $entityId),
383-
$this->getConnection()->quoteInto('store_id = ?', (int) $storeId)
382+
$this->getConnection()->quoteInto('value_id = ?', (int)$valueId),
383+
$this->getConnection()->quoteInto($this->metadata->getLinkField() . ' = ?', (int)$entityId),
384+
$this->getConnection()->quoteInto('store_id = ?', (int)$storeId)
384385
]
385386
);
386387

@@ -408,7 +409,7 @@ public function duplicate($attributeId, $newFiles, $originalProductId, $newProdu
408409

409410
$select = $this->getConnection()->select()->from(
410411
[$this->getMainTableAlias() => $this->getMainTable()],
411-
['value_id', 'value']
412+
['value_id', 'value', 'media_type', 'disabled']
412413
)->joinInner(
413414
['entity' => $this->getTable(self::GALLERY_VALUE_TO_ENTITY_TABLE)],
414415
$this->getMainTableAlias() . '.value_id = entity.value_id',
@@ -425,16 +426,16 @@ public function duplicate($attributeId, $newFiles, $originalProductId, $newProdu
425426

426427
// Duplicate main entries of gallery
427428
foreach ($this->getConnection()->fetchAll($select) as $row) {
428-
$data = [
429-
'attribute_id' => $attributeId,
430-
'value' => isset($newFiles[$row['value_id']]) ? $newFiles[$row['value_id']] : $row['value'],
431-
];
429+
$data = $row;
430+
$data['attribute_id'] = $attributeId;
431+
$data['value'] = $newFiles[$row['value_id']] ?? $row['value'];
432+
unset($data['value_id']);
432433

433434
$valueIdMap[$row['value_id']] = $this->insertGallery($data);
434435
$this->bindValueToEntity($valueIdMap[$row['value_id']], $newProductId);
435436
}
436437

437-
if (count($valueIdMap) == 0) {
438+
if (count($valueIdMap) === 0) {
438439
return [];
439440
}
440441

app/code/Magento/Catalog/Test/Mftf/ActionGroup/SearchForProductOnBackendActionGroup.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@
1919
<click selector="{{AdminProductFiltersSection.apply}}" stepKey="clickApplyFiltersButton"/>
2020
</actionGroup>
2121

22+
<actionGroup name="SearchForProductOnBackendByNameActionGroup" extends="SearchForProductOnBackendActionGroup">
23+
<arguments>
24+
<argument name="productName" type="string"/>
25+
</arguments>
26+
<remove keyForRemoval="fillSkuFieldOnFiltersSection"/>
27+
<fillField userInput="{{productName}}" selector="{{AdminProductFiltersSection.nameInput}}" after="cleanFiltersIfTheySet" stepKey="fillNameFieldOnFiltersSection"/>
28+
</actionGroup>
29+
2230
<actionGroup name="ClearProductsFilterActionGroup">
2331
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="navigateToProductIndex"/>
2432
<waitForPageLoad time="30" stepKey="waitForProductsPageToLoad"/>

app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88

99
use Magento\Catalog\Api\Data\ProductExtensionInterface;
1010
use Magento\Catalog\Model\Product;
11+
use Magento\Catalog\Model\Product\Attribute\Source\Status;
1112
use Magento\Framework\Api\Data\ImageContentInterface;
1213
use Magento\Framework\Api\ExtensibleDataInterface;
1314
use Magento\Framework\Api\ExtensionAttributesFactory;
1415
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
15-
use Magento\Catalog\Model\Product\Attribute\Source\Status;
1616

1717
/**
1818
* Product Test
@@ -180,7 +180,7 @@ class ProductTest extends \PHPUnit\Framework\TestCase
180180
/**
181181
* @var \PHPUnit_Framework_MockObject_MockObject
182182
*/
183-
private $extensionAttrbutes;
183+
private $extensionAttributes;
184184

185185
/**
186186
* @var \PHPUnit_Framework_MockObject_MockObject
@@ -200,7 +200,7 @@ class ProductTest extends \PHPUnit\Framework\TestCase
200200
/**
201201
* @var ProductExtensionInterface|\PHPUnit_Framework_MockObject_MockObject
202202
*/
203-
private $extensionAttributes;
203+
private $productExtAttributes;
204204

205205
/**
206206
* @var \Magento\Eav\Model\Config|\PHPUnit_Framework_MockObject_MockObject
@@ -218,7 +218,7 @@ protected function setUp()
218218
\Magento\Framework\Module\Manager::class,
219219
['isEnabled']
220220
);
221-
$this->extensionAttrbutes = $this->getMockBuilder(\Magento\Framework\Api\ExtensionAttributesInterface::class)
221+
$this->extensionAttributes = $this->getMockBuilder(\Magento\Framework\Api\ExtensionAttributesInterface::class)
222222
->setMethods(['getWebsiteIds', 'setWebsiteIds'])
223223
->disableOriginalConstructor()
224224
->getMock();
@@ -372,13 +372,13 @@ protected function setUp()
372372
$this->mediaConfig = $this->createMock(\Magento\Catalog\Model\Product\Media\Config::class);
373373
$this->eavConfig = $this->createMock(\Magento\Eav\Model\Config::class);
374374

375-
$this->extensionAttributes = $this->getMockBuilder(ProductExtensionInterface::class)
375+
$this->productExtAttributes = $this->getMockBuilder(ProductExtensionInterface::class)
376376
->setMethods(['getStockItem'])
377377
->getMockForAbstractClass();
378378
$this->extensionAttributesFactory
379379
->expects($this->any())
380380
->method('create')
381-
->willReturn($this->extensionAttributes);
381+
->willReturn($this->productExtAttributes);
382382

383383
$this->filterCustomAttribute = $this->createTestProxy(
384384
\Magento\Catalog\Model\FilterProductCustomAttribute::class
@@ -567,14 +567,6 @@ public function testGetCategoryId()
567567
$this->assertEquals(10, $this->model->getCategoryId());
568568
}
569569

570-
public function testGetCategoryIdWhenProductNotInCurrentCategory()
571-
{
572-
$this->model->setData('category_ids', [12]);
573-
$this->category->expects($this->once())->method('getId')->will($this->returnValue(10));
574-
$this->registry->expects($this->any())->method('registry')->will($this->returnValue($this->category));
575-
$this->assertFalse($this->model->getCategoryId());
576-
}
577-
578570
public function testGetIdBySku()
579571
{
580572
$this->resource->expects($this->once())->method('getIdBySku')->will($this->returnValue(5));

0 commit comments

Comments
 (0)