Skip to content

Commit 8e8a3f7

Browse files
committed
Merge remote-tracking branch 'mainline/2.2-develop' into PANDA-PR-2.2
2 parents f36b92d + aa4b734 commit 8e8a3f7

File tree

72 files changed

+1721
-113
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+1721
-113
lines changed

app/code/Magento/AdvancedPricingImportExport/Model/Export/AdvancedPricing.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ class AdvancedPricing extends \Magento\CatalogImportExport\Model\Export\Product
103103
* @param \Magento\CatalogImportExport\Model\Export\RowCustomizerInterface $rowCustomizer
104104
* @param ImportProduct\StoreResolver $storeResolver
105105
* @param \Magento\Customer\Api\GroupRepositoryInterface $groupRepository
106-
* @throws \Magento\Framework\Exception\LocalizedException
107106
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
108107
*/
109108
public function __construct(
@@ -192,6 +191,7 @@ protected function initTypeModels()
192191
* Export process
193192
*
194193
* @return string
194+
* @throws \Magento\Framework\Exception\LocalizedException
195195
*/
196196
public function export()
197197
{
@@ -461,6 +461,7 @@ protected function getTierPrices(array $productLinksIds, $table)
461461
*
462462
* @param int $websiteId
463463
* @return string
464+
* @throws \Magento\Framework\Exception\LocalizedException
464465
*/
465466
protected function _getWebsiteCode(int $websiteId): string
466467
{
@@ -491,6 +492,8 @@ protected function _getWebsiteCode(int $websiteId): string
491492
* @param int $customerGroupId
492493
* @param int $allGroups
493494
* @return string
495+
* @throws \Magento\Framework\Exception\LocalizedException
496+
* @throws \Magento\Framework\Exception\NoSuchEntityException
494497
*/
495498
protected function _getCustomerGroupById(
496499
int $customerGroupId,

app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Magento\CatalogImportExport\Model\Import\Product as ImportProduct;
99
use Magento\CatalogImportExport\Model\Import\Product\RowValidatorInterface as ValidatorInterface;
1010
use Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface;
11-
use Magento\Framework\App\ResourceConnection;
1211

1312
/**
1413
* Class AdvancedPricing
@@ -619,6 +618,7 @@ protected function processCountNewPrices(array $tierPrices)
619618
* Get product entity link field
620619
*
621620
* @return string
621+
* @throws \Exception
622622
*/
623623
private function getProductEntityLinkField()
624624
{

app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing/Validator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public function __construct($validators = [])
2828
*
2929
* @param array $value
3030
* @return bool
31+
* @throws \Zend_Validate_Exception
3132
*/
3233
public function isValid($value)
3334
{

app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Export/AdvancedPricingTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ protected function tearDown()
347347
* @param $object
348348
* @param $property
349349
* @return mixed
350+
* @throws \ReflectionException
350351
*/
351352
protected function getPropertyValue($object, $property)
352353
{
@@ -362,6 +363,8 @@ protected function getPropertyValue($object, $property)
362363
* @param $object
363364
* @param $property
364365
* @param $value
366+
* @return mixed
367+
* @throws \ReflectionException
365368
*/
366369
protected function setPropertyValue(&$object, $property, $value)
367370
{

app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/TierPriceTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ public function isValidAddMessagesCallDataProvider()
346346
* @param object $object
347347
* @param string $property
348348
* @return mixed
349+
* @throws \ReflectionException
349350
*/
350351
protected function getPropertyValue($object, $property)
351352
{
@@ -363,6 +364,7 @@ protected function getPropertyValue($object, $property)
363364
* @param string $property
364365
* @param mixed $value
365366
* @return object
367+
* @throws \ReflectionException
366368
*/
367369
protected function setPropertyValue(&$object, $property, $value)
368370
{

app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricingTest.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,10 @@ public function testGetEntityTypeCode()
209209
* Test method validateRow against its result.
210210
*
211211
* @dataProvider validateRowResultDataProvider
212+
* @param array $rowData
213+
* @param string|null $behavior
214+
* @param bool $expectedResult
215+
* @throws \ReflectionException
212216
*/
213217
public function testValidateRowResult($rowData, $behavior, $expectedResult)
214218
{
@@ -234,6 +238,10 @@ public function testValidateRowResult($rowData, $behavior, $expectedResult)
234238
* Test method validateRow whether AddRowError is called.
235239
*
236240
* @dataProvider validateRowAddRowErrorCallDataProvider
241+
* @param array $rowData
242+
* @param string|null $behavior
243+
* @param string $error
244+
* @throws \ReflectionException
237245
*/
238246
public function testValidateRowAddRowErrorCall($rowData, $behavior, $error)
239247
{
@@ -324,6 +332,13 @@ public function testSaveAdvancedPricing()
324332
* Take into consideration different data and check relative internal calls.
325333
*
326334
* @dataProvider saveAndReplaceAdvancedPricesAppendBehaviourDataProvider
335+
* @param array $data
336+
* @param string $tierCustomerGroupId
337+
* @param string $groupCustomerGroupId
338+
* @param string $tierWebsiteId
339+
* @param string $groupWebsiteId
340+
* @param array $expectedTierPrices
341+
* @throws \ReflectionException
327342
*/
328343
public function testSaveAndReplaceAdvancedPricesAppendBehaviourDataAndCalls(
329344
$data,
@@ -956,6 +971,7 @@ public function processCountExistingPricesDataProvider()
956971
* @param $object
957972
* @param $property
958973
* @return mixed
974+
* @throws \ReflectionException
959975
*/
960976
protected function getPropertyValue($object, $property)
961977
{
@@ -972,6 +988,8 @@ protected function getPropertyValue($object, $property)
972988
* @param $object
973989
* @param $property
974990
* @param $value
991+
* @return mixed
992+
* @throws \ReflectionException
975993
*/
976994
protected function setPropertyValue(&$object, $property, $value)
977995
{
@@ -990,7 +1008,8 @@ protected function setPropertyValue(&$object, $property, $value)
9901008
* @param string $method
9911009
* @param array $args
9921010
*
993-
* @return mixed the method result.
1011+
* @return mixed
1012+
* @throws \ReflectionException
9941013
*/
9951014
private function invokeMethod($object, $method, $args = [])
9961015
{
@@ -1007,6 +1026,7 @@ private function invokeMethod($object, $method, $args = [])
10071026
* @param array $methods
10081027
*
10091028
* @return \PHPUnit_Framework_MockObject_MockObject
1029+
* @throws \ReflectionException
10101030
*/
10111031
private function getAdvancedPricingMock($methods = [])
10121032
{

app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Save.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ public function execute()
115115
{
116116
$data = $this->getRequest()->getPostValue();
117117
if ($data) {
118+
$this->preprocessOptionsData($data);
118119
$setId = $this->getRequest()->getParam('set');
119120

120121
$attributeSet = null;
@@ -210,7 +211,7 @@ public function execute()
210211

211212
$data['attribute_code'] = $model->getAttributeCode();
212213
$data['is_user_defined'] = $model->getIsUserDefined();
213-
$data['frontend_input'] = $model->getFrontendInput();
214+
$data['frontend_input'] = $data['frontend_input'] ?? $model->getFrontendInput();
214215
} else {
215216
/**
216217
* @todo add to helper and specify all relations for properties
@@ -311,6 +312,28 @@ public function execute()
311312
return $this->returnResult('catalog/*/', [], ['error' => true]);
312313
}
313314

315+
/**
316+
* Extract options data from serialized options field and append to data array.
317+
*
318+
* This logic is required to overcome max_input_vars php limit
319+
* that may vary and/or be inaccessible to change on different instances.
320+
*
321+
* @param array $data
322+
* @return void
323+
*/
324+
private function preprocessOptionsData(&$data)
325+
{
326+
if (isset($data['serialized_options'])) {
327+
$serializedOptions = json_decode($data['serialized_options'], JSON_OBJECT_AS_ARRAY);
328+
foreach ($serializedOptions as $serializedOption) {
329+
$option = [];
330+
parse_str($serializedOption, $option);
331+
$data = array_replace_recursive($data, $option);
332+
}
333+
}
334+
unset($data['serialized_options']);
335+
}
336+
314337
/**
315338
* @param string $path
316339
* @param array $params

app/code/Magento/Catalog/Model/ResourceModel/Category.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
*/
1212
namespace Magento\Catalog\Model\ResourceModel;
1313

14+
use Magento\Catalog\Model\Indexer\Category\Product\Processor;
15+
use Magento\Framework\DataObject;
1416
use Magento\Framework\EntityManager\EntityManager;
1517

1618
/**
@@ -82,6 +84,11 @@ class Category extends AbstractResource
8284
*/
8385
protected $aggregateCount;
8486

87+
/**
88+
* @var Processor
89+
*/
90+
private $indexerProcessor;
91+
8592
/**
8693
* Category constructor.
8794
* @param \Magento\Eav\Model\Entity\Context $context
@@ -92,6 +99,7 @@ class Category extends AbstractResource
9299
* @param Category\CollectionFactory $categoryCollectionFactory
93100
* @param array $data
94101
* @param \Magento\Framework\Serialize\Serializer\Json|null $serializer
102+
* @param Processor|null $indexerProcessor
95103
*/
96104
public function __construct(
97105
\Magento\Eav\Model\Entity\Context $context,
@@ -101,7 +109,8 @@ public function __construct(
101109
\Magento\Catalog\Model\ResourceModel\Category\TreeFactory $categoryTreeFactory,
102110
\Magento\Catalog\Model\ResourceModel\Category\CollectionFactory $categoryCollectionFactory,
103111
$data = [],
104-
\Magento\Framework\Serialize\Serializer\Json $serializer = null
112+
\Magento\Framework\Serialize\Serializer\Json $serializer = null,
113+
Processor $indexerProcessor = null
105114
) {
106115
parent::__construct(
107116
$context,
@@ -115,6 +124,8 @@ public function __construct(
115124
$this->connectionName = 'catalog';
116125
$this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance()
117126
->get(\Magento\Framework\Serialize\Serializer\Json::class);
127+
$this->indexerProcessor = $indexerProcessor ?: \Magento\Framework\App\ObjectManager::getInstance()
128+
->get(Processor::class);
118129
}
119130

120131
/**
@@ -197,6 +208,19 @@ protected function _beforeDelete(\Magento\Framework\DataObject $object)
197208
$this->deleteChildren($object);
198209
}
199210

211+
/**
212+
* Mark Category indexer as invalid to be picked up by cron.
213+
*
214+
* @param DataObject $object
215+
* @return $this
216+
*/
217+
protected function _afterDelete(DataObject $object): Category
218+
{
219+
$this->indexerProcessor->markIndexerAsInvalid();
220+
221+
return parent::_afterDelete($object);
222+
}
223+
200224
/**
201225
* Delete children categories of specific category
202226
*

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,14 +1079,15 @@ public function getAllAttributeValues($attribute)
10791079
$select = clone $this->getSelect();
10801080
$attribute = $this->getEntity()->getAttribute($attribute);
10811081

1082-
$aiField = $this->getConnection()->getAutoIncrementField($this->getMainTable());
1082+
$fieldMainTable = $this->getConnection()->getAutoIncrementField($this->getMainTable());
1083+
$fieldJoinTable = $attribute->getEntity()->getLinkField();
10831084
$select->reset()
10841085
->from(
10851086
['cpe' => $this->getMainTable()],
10861087
['entity_id']
10871088
)->join(
10881089
['cpa' => $attribute->getBackend()->getTable()],
1089-
'cpe.' . $aiField . ' = cpa.' . $aiField,
1090+
'cpe.' . $fieldMainTable . ' = cpa.' . $fieldJoinTable,
10901091
['store_id', 'value']
10911092
)->where('attribute_id = ?', (int)$attribute->getId());
10921093

app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/CategoryTest.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace Magento\Catalog\Test\Unit\Model\ResourceModel;
88

99
use Magento\Catalog\Model\Factory;
10+
use Magento\Catalog\Model\Indexer\Category\Product\Processor;
1011
use Magento\Catalog\Model\ResourceModel\Category;
1112
use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory;
1213
use Magento\Eav\Model\Config;
@@ -91,6 +92,11 @@ class CategoryTest extends \PHPUnit\Framework\TestCase
9192
*/
9293
private $serializerMock;
9394

95+
/**
96+
* @var Processor|\PHPUnit_Framework_MockObject_MockObject
97+
*/
98+
private $indexerProcessorMock;
99+
94100
/**
95101
* {@inheritDoc}
96102
*/
@@ -121,6 +127,9 @@ protected function setUp()
121127
$this->collectionFactoryMock = $this->getMockBuilder(CollectionFactory::class)
122128
->disableOriginalConstructor()
123129
->getMock();
130+
$this->indexerProcessorMock = $this->getMockBuilder(Processor::class)
131+
->disableOriginalConstructor()
132+
->getMock();
124133

125134
$this->serializerMock = $this->getMockBuilder(Json::class)->getMock();
126135

@@ -132,7 +141,8 @@ protected function setUp()
132141
$this->treeFactoryMock,
133142
$this->collectionFactoryMock,
134143
[],
135-
$this->serializerMock
144+
$this->serializerMock,
145+
$this->indexerProcessorMock
136146
);
137147
}
138148

0 commit comments

Comments
 (0)