Skip to content

Commit 0a4b7b8

Browse files
committed
Merge remote-tracking branch 'mainline/2.2-develop' into MAGETWO-87589
2 parents 6e2d32f + 0a52f88 commit 0a4b7b8

File tree

127 files changed

+3035
-403
lines changed

Some content is hidden

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

127 files changed

+3035
-403
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/Backend/Controller/Adminhtml/System/Store/DeleteStorePost.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ public function execute()
3737
try {
3838
$model->delete();
3939

40-
$this->_eventManager->dispatch('store_delete', ['store' => $model]);
41-
4240
$this->messageManager->addSuccess(__('You deleted the store view.'));
4341
return $redirectResult->setPath('adminhtml/*/');
4442
} catch (\Magento\Framework\Exception\LocalizedException $e) {

app/code/Magento/Backend/Controller/Adminhtml/System/Store/Save.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ private function processWebsiteSave($postData)
4646
*/
4747
private function processStoreSave($postData)
4848
{
49-
$eventName = 'store_edit';
5049
/** @var \Magento\Store\Model\Store $storeModel */
5150
$storeModel = $this->_objectManager->create(\Magento\Store\Model\Store::class);
5251
$postData['store']['name'] = $this->filterManager->removeTags($postData['store']['name']);
@@ -56,7 +55,6 @@ private function processStoreSave($postData)
5655
$storeModel->setData($postData['store']);
5756
if ($postData['store']['store_id'] == '') {
5857
$storeModel->setId(null);
59-
$eventName = 'store_add';
6058
}
6159
$groupModel = $this->_objectManager->create(
6260
\Magento\Store\Model\Group::class
@@ -70,8 +68,6 @@ private function processStoreSave($postData)
7068
);
7169
}
7270
$storeModel->save();
73-
$this->_objectManager->get(\Magento\Store\Model\StoreManager::class)->reinitStores();
74-
$this->_eventManager->dispatch($eventName, ['store' => $storeModel]);
7571
$this->messageManager->addSuccess(__('You saved the store view.'));
7672

7773
return $postData;
@@ -102,7 +98,6 @@ private function processGroupSave($postData)
10298
);
10399
}
104100
$groupModel->save();
105-
$this->_eventManager->dispatch('store_group_save', ['group' => $groupModel]);
106101
$this->messageManager->addSuccess(__('You saved the store.'));
107102

108103
return $postData;

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
*

0 commit comments

Comments
 (0)