From 39b1ef3a5b5a4741a0c664135b13944c4e7c7b61 Mon Sep 17 00:00:00 2001 From: EugeneShab Date: Fri, 15 Dec 2017 18:28:57 +0200 Subject: [PATCH 001/206] magento/magento2#12695: Unable to change attribute type from swatch to dropdown - fixed the process of switching attribute input type --- .../Swatches/Model/Plugin/EavAttribute.php | 52 +++++++++++++++++++ .../Swatches/Model/ResourceModel/Swatch.php | 24 +++++++++ .../Swatches/Model/SwatchAttributeCodes.php | 2 +- .../Model/SwatchAttributesProvider.php | 18 +++++-- 4 files changed, 91 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/Swatches/Model/Plugin/EavAttribute.php b/app/code/Magento/Swatches/Model/Plugin/EavAttribute.php index 599406f455281..f83b28a7d51e2 100644 --- a/app/code/Magento/Swatches/Model/Plugin/EavAttribute.php +++ b/app/code/Magento/Swatches/Model/Plugin/EavAttribute.php @@ -10,6 +10,7 @@ use Magento\Framework\Exception\InputException; use Magento\Framework\Serialize\Serializer\Json; use Magento\Swatches\Model\Swatch; +use Magento\Swatches\Model\ResourceModel\Swatch as SwatchResource; /** * Plugin model for Catalog Resource Attribute @@ -18,6 +19,11 @@ class EavAttribute { const DEFAULT_STORE_ID = 0; + /** + * @var SwatchResource + */ + protected $swatchResource; + /** * Base option title used for string operations to detect is option already exists or new */ @@ -68,6 +74,7 @@ class EavAttribute public function __construct( \Magento\Swatches\Model\ResourceModel\Swatch\CollectionFactory $collectionFactory, \Magento\Swatches\Model\SwatchFactory $swatchFactory, + SwatchResource $swatchResource, \Magento\Swatches\Helper\Data $swatchHelper, Json $serializer = null ) { @@ -75,6 +82,7 @@ public function __construct( $this->swatchFactory = $swatchFactory; $this->swatchHelper = $swatchHelper; $this->serializer = $serializer ?: ObjectManager::getInstance()->create(Json::class); + $this->swatchResource = $swatchResource; } /** @@ -157,6 +165,9 @@ protected function convertSwatchToDropdown(Attribute $attribute) if (!empty($additionalData)) { $additionalData = $this->serializer->unserialize($additionalData); if (is_array($additionalData) && isset($additionalData[Swatch::SWATCH_INPUT_TYPE_KEY])) { + if ($additionalData[Swatch::SWATCH_INPUT_TYPE_KEY] == Swatch::SWATCH_INPUT_TYPE_VISUAL) { + $this->cleanEavAttributeOptionSwatchValues($attribute); + } unset($additionalData[Swatch::SWATCH_INPUT_TYPE_KEY]); $attribute->setData('additional_data', $this->serializer->serialize($additionalData)); } @@ -164,6 +175,25 @@ protected function convertSwatchToDropdown(Attribute $attribute) } } + /** + * Clean swatch option values after switching to the dropdown type. + * + * @param Attribute $attribute + * @throws \Magento\Framework\Exception\LocalizedException + */ + private function cleanEavAttributeOptionSwatchValues(Attribute $attribute) + { + $optionsIDs = []; + if (count($attribute->getOption())) { + $options = $attribute->getOption(); + foreach ($options['value'] as $id => $item) { + $optionsIDs[] = $id; + } + + $this->swatchResource->clearSwatchOptionByOptionId($optionsIDs); + } + } + /** * Creates array which link new option ids * @@ -235,6 +265,7 @@ protected function saveSwatchParams(Attribute $attribute) { if ($this->swatchHelper->isVisualSwatch($attribute)) { $this->processVisualSwatch($attribute); + $this->cleanTextSwatchValuesAfterSwitch($attribute); } elseif ($this->swatchHelper->isTextSwatch($attribute)) { $this->processTextualSwatch($attribute); } @@ -267,6 +298,27 @@ protected function processVisualSwatch(Attribute $attribute) } } + /** + * Cleaning the text type of swatch option values after switching. + * + * @param $attribute + */ + private function cleanTextSwatchValuesAfterSwitch( Attribute $attribute) + { + $optionsIDs = []; + if (count($attribute->getOptiontext())) { + $options = $attribute->getOptiontext(); + if (count($options)) { + foreach ($options['value'] as $id => $item) { + $optionsIDs[] = $id; + } + + $type = Swatch::SWATCH_TYPE_TEXTUAL; + $this->swatchResource->clearSwatchOptionTextByOptionId($optionsIDs, $type); + } + } + } + /** * @param string $value * @return int diff --git a/app/code/Magento/Swatches/Model/ResourceModel/Swatch.php b/app/code/Magento/Swatches/Model/ResourceModel/Swatch.php index 22eb1d4c7eef9..adc7467d2b06a 100644 --- a/app/code/Magento/Swatches/Model/ResourceModel/Swatch.php +++ b/app/code/Magento/Swatches/Model/ResourceModel/Swatch.php @@ -37,4 +37,28 @@ public function saveDefaultSwatchOption($id, $defaultValue) $this->getConnection()->update($this->getTable('eav_attribute'), $bind, $where); } } + + /** + * Cleaned swatch option values when switching to dropdown input type + * + * @param $optionIDs + * @throws \Magento\Framework\Exception\LocalizedException + */ + public function clearSwatchOptionByOptionId($optionIDs) + { + if (count($optionIDs)) { + foreach ($optionIDs as $optionId) { + $where = ['option_id' => $optionId]; + $this->getConnection()->delete($this->getMainTable(), $where); + } + } + } + + public function clearSwatchOptionTextByOptionId($optionIDs, $type) + { + foreach ($optionIDs as $optionId) { + $where = ['option_id = ?' => $optionId, 'type = ?' => $type]; + $this->getConnection()->delete($this->getMainTable(), $where); + } + } } diff --git a/app/code/Magento/Swatches/Model/SwatchAttributeCodes.php b/app/code/Magento/Swatches/Model/SwatchAttributeCodes.php index 4d2a40dae3aa6..a7ca162b2a1e0 100644 --- a/app/code/Magento/Swatches/Model/SwatchAttributeCodes.php +++ b/app/code/Magento/Swatches/Model/SwatchAttributeCodes.php @@ -67,7 +67,7 @@ public function __construct( * * @return array */ - public function getCodes() + public function getCodes() { if ($this->swatchAttributeCodes === null) { $swatchAttributeCodesCache = $this->cache->load($this->cacheKey); diff --git a/app/code/Magento/Swatches/Model/SwatchAttributesProvider.php b/app/code/Magento/Swatches/Model/SwatchAttributesProvider.php index d5a1b402c9fd3..566dd163d70d8 100644 --- a/app/code/Magento/Swatches/Model/SwatchAttributesProvider.php +++ b/app/code/Magento/Swatches/Model/SwatchAttributesProvider.php @@ -14,6 +14,10 @@ */ class SwatchAttributesProvider { + /** + * @var \Magento\Swatches\Helper\Data + */ + protected $swatchHelper; /** * @var Configurable */ @@ -36,10 +40,12 @@ class SwatchAttributesProvider */ public function __construct( Configurable $typeConfigurable, - SwatchAttributeCodes $swatchAttributeCodes + SwatchAttributeCodes $swatchAttributeCodes, + \Magento\Swatches\Helper\Data\Proxy $swatchHelper ) { $this->typeConfigurable = $typeConfigurable; $this->swatchAttributeCodes = $swatchAttributeCodes; + $this->swatchHelper = $swatchHelper; } /** @@ -60,9 +66,13 @@ public function provide(Product $product) $swatchAttributes = []; foreach ($configurableAttributes as $configurableAttribute) { - if (array_key_exists($configurableAttribute->getAttributeId(), $swatchAttributeCodeMap)) { - $swatchAttributes[$configurableAttribute->getAttributeId()] - = $configurableAttribute->getProductAttribute(); + // Due to $this->swatchAttributeCodes->getCodes() - return swatch data for every attribute. + if ($this->swatchHelper->isSwatchAttribute($configurableAttribute->getProductAttribute())) { + if (array_key_exists($configurableAttribute->getAttributeId(), $swatchAttributeCodeMap)) { + $swatchAttributes[$configurableAttribute->getAttributeId()] + = $configurableAttribute->getProductAttribute(); + } + } } $this->attributesPerProduct[$product->getId()] = $swatchAttributes; From 94539b755992f120927a4760c06c624a0ced07c7 Mon Sep 17 00:00:00 2001 From: EugeneShab Date: Thu, 21 Dec 2017 13:01:22 +0200 Subject: [PATCH 002/206] magento/magento2#12695: Unable to change attribute type from swatch to dropdown - fixes after code review. --- .../Swatches/Model/Plugin/EavAttribute.php | 25 +++++++--------- .../Swatches/Model/ResourceModel/Swatch.php | 5 ++++ .../Swatches/Model/SwatchAttributeCodes.php | 2 +- .../Model/SwatchAttributesProvider.php | 29 ++++++++++++++----- app/code/Magento/Swatches/etc/di.xml | 5 ++++ 5 files changed, 44 insertions(+), 22 deletions(-) diff --git a/app/code/Magento/Swatches/Model/Plugin/EavAttribute.php b/app/code/Magento/Swatches/Model/Plugin/EavAttribute.php index f83b28a7d51e2..107ffbbc2d35b 100644 --- a/app/code/Magento/Swatches/Model/Plugin/EavAttribute.php +++ b/app/code/Magento/Swatches/Model/Plugin/EavAttribute.php @@ -22,7 +22,7 @@ class EavAttribute /** * @var SwatchResource */ - protected $swatchResource; + private $swatchResource; /** * Base option title used for string operations to detect is option already exists or new @@ -70,19 +70,20 @@ class EavAttribute * @param \Magento\Swatches\Model\SwatchFactory $swatchFactory * @param \Magento\Swatches\Helper\Data $swatchHelper * @param Json|null $serializer + * @param SwatchResource|null $swatchResource */ public function __construct( \Magento\Swatches\Model\ResourceModel\Swatch\CollectionFactory $collectionFactory, \Magento\Swatches\Model\SwatchFactory $swatchFactory, - SwatchResource $swatchResource, \Magento\Swatches\Helper\Data $swatchHelper, - Json $serializer = null + Json $serializer = null, + SwatchResource $swatchResource = null ) { $this->swatchCollectionFactory = $collectionFactory; $this->swatchFactory = $swatchFactory; $this->swatchHelper = $swatchHelper; $this->serializer = $serializer ?: ObjectManager::getInstance()->create(Json::class); - $this->swatchResource = $swatchResource; + $this->swatchResource = $swatchResource ?: ObjectManager::getInstance()->create(SwatchResource::class); } /** @@ -183,12 +184,12 @@ protected function convertSwatchToDropdown(Attribute $attribute) */ private function cleanEavAttributeOptionSwatchValues(Attribute $attribute) { - $optionsIDs = []; if (count($attribute->getOption())) { $options = $attribute->getOption(); - foreach ($options['value'] as $id => $item) { - $optionsIDs[] = $id; - } +// foreach ($options['value'] as $id => $item) { +// $optionsIDs[] = $id; +// } + $optionsIDs = array_keys($options['value']); $this->swatchResource->clearSwatchOptionByOptionId($optionsIDs); } @@ -309,12 +310,8 @@ private function cleanTextSwatchValuesAfterSwitch( Attribute $attribute) if (count($attribute->getOptiontext())) { $options = $attribute->getOptiontext(); if (count($options)) { - foreach ($options['value'] as $id => $item) { - $optionsIDs[] = $id; - } - - $type = Swatch::SWATCH_TYPE_TEXTUAL; - $this->swatchResource->clearSwatchOptionTextByOptionId($optionsIDs, $type); + $optionsIDs[] = array_keys($options['value']); + $this->swatchResource->clearSwatchOptionTextByOptionId($optionsIDs, Swatch::SWATCH_TYPE_TEXTUAL); } } } diff --git a/app/code/Magento/Swatches/Model/ResourceModel/Swatch.php b/app/code/Magento/Swatches/Model/ResourceModel/Swatch.php index adc7467d2b06a..6c5cf1da05dbf 100644 --- a/app/code/Magento/Swatches/Model/ResourceModel/Swatch.php +++ b/app/code/Magento/Swatches/Model/ResourceModel/Swatch.php @@ -54,6 +54,11 @@ public function clearSwatchOptionByOptionId($optionIDs) } } + /** + * @param $optionIDs + * @param $type + * @throws \Magento\Framework\Exception\LocalizedException + */ public function clearSwatchOptionTextByOptionId($optionIDs, $type) { foreach ($optionIDs as $optionId) { diff --git a/app/code/Magento/Swatches/Model/SwatchAttributeCodes.php b/app/code/Magento/Swatches/Model/SwatchAttributeCodes.php index a7ca162b2a1e0..4d2a40dae3aa6 100644 --- a/app/code/Magento/Swatches/Model/SwatchAttributeCodes.php +++ b/app/code/Magento/Swatches/Model/SwatchAttributeCodes.php @@ -67,7 +67,7 @@ public function __construct( * * @return array */ - public function getCodes() + public function getCodes() { if ($this->swatchAttributeCodes === null) { $swatchAttributeCodesCache = $this->cache->load($this->cacheKey); diff --git a/app/code/Magento/Swatches/Model/SwatchAttributesProvider.php b/app/code/Magento/Swatches/Model/SwatchAttributesProvider.php index 566dd163d70d8..ddac043ca5b5d 100644 --- a/app/code/Magento/Swatches/Model/SwatchAttributesProvider.php +++ b/app/code/Magento/Swatches/Model/SwatchAttributesProvider.php @@ -8,6 +8,8 @@ use Magento\ConfigurableProduct\Model\Product\Type\Configurable; use Magento\Catalog\Model\Product; use Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute; +use \Magento\Swatches\Helper\Data as SwatchesHelper; +use Magento\Framework\App\ObjectManager; /** * Provide list of swatch attributes for product. @@ -17,7 +19,7 @@ class SwatchAttributesProvider /** * @var \Magento\Swatches\Helper\Data */ - protected $swatchHelper; + protected $swatchesHelper; /** * @var Configurable */ @@ -35,17 +37,20 @@ class SwatchAttributesProvider private $attributesPerProduct; /** - * @param Configurable $typeConfigurable + * SwatchAttributesProvider constructor. + * + * @param Configurable $typeConfigurable * @param SwatchAttributeCodes $swatchAttributeCodes + * @param SwatchesHelper|null $swatchHelper */ public function __construct( Configurable $typeConfigurable, SwatchAttributeCodes $swatchAttributeCodes, - \Magento\Swatches\Helper\Data\Proxy $swatchHelper + SwatchesHelper $swatchHelper = null ) { $this->typeConfigurable = $typeConfigurable; $this->swatchAttributeCodes = $swatchAttributeCodes; - $this->swatchHelper = $swatchHelper; + $this->swatchesHelper = $swatchHelper ?: ObjectManager::getInstance()->create(SwatchesHelper::class); } /** @@ -66,17 +71,27 @@ public function provide(Product $product) $swatchAttributes = []; foreach ($configurableAttributes as $configurableAttribute) { - // Due to $this->swatchAttributeCodes->getCodes() - return swatch data for every attribute. - if ($this->swatchHelper->isSwatchAttribute($configurableAttribute->getProductAttribute())) { + if ($this->getIsSwatchAttribute($configurableAttribute->getProductAttribute())) { if (array_key_exists($configurableAttribute->getAttributeId(), $swatchAttributeCodeMap)) { $swatchAttributes[$configurableAttribute->getAttributeId()] = $configurableAttribute->getProductAttribute(); } - } } $this->attributesPerProduct[$product->getId()] = $swatchAttributes; } return $this->attributesPerProduct[$product->getId()]; } + + /** + * This method introduced only for the case when customer already has converted attribute. + * + * @param \Magento\Catalog\Model\ResourceModel\Eav\Attribute $productAttribute + * @return bool + * @deprecated + */ + private function getIsSwatchAttribute($productAttribute) + { + return $this->swatchesHelper->isSwatchAttribute($productAttribute); + } } diff --git a/app/code/Magento/Swatches/etc/di.xml b/app/code/Magento/Swatches/etc/di.xml index 5292bfafb6a0f..2a8b437f55270 100644 --- a/app/code/Magento/Swatches/etc/di.xml +++ b/app/code/Magento/Swatches/etc/di.xml @@ -81,4 +81,9 @@ + + + \Magento\Swatches\Helper\Data\Proxy + + From 3d76096a752ff234843890d7a072cd1d64e8c1c2 Mon Sep 17 00:00:00 2001 From: EugeneShab Date: Thu, 21 Dec 2017 14:36:57 +0200 Subject: [PATCH 003/206] magento/magento2#12695: Unable to change attribute type from swatch to dropdown - fixes after code review --- app/code/Magento/Swatches/Model/Plugin/EavAttribute.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/Swatches/Model/Plugin/EavAttribute.php b/app/code/Magento/Swatches/Model/Plugin/EavAttribute.php index 107ffbbc2d35b..a473d86b5dbf7 100644 --- a/app/code/Magento/Swatches/Model/Plugin/EavAttribute.php +++ b/app/code/Magento/Swatches/Model/Plugin/EavAttribute.php @@ -186,9 +186,6 @@ private function cleanEavAttributeOptionSwatchValues(Attribute $attribute) { if (count($attribute->getOption())) { $options = $attribute->getOption(); -// foreach ($options['value'] as $id => $item) { -// $optionsIDs[] = $id; -// } $optionsIDs = array_keys($options['value']); $this->swatchResource->clearSwatchOptionByOptionId($optionsIDs); @@ -309,8 +306,8 @@ private function cleanTextSwatchValuesAfterSwitch( Attribute $attribute) $optionsIDs = []; if (count($attribute->getOptiontext())) { $options = $attribute->getOptiontext(); - if (count($options)) { - $optionsIDs[] = array_keys($options['value']); + if (count($options) && isset($options['value'])) { + $optionsIDs = array_keys($options['value']); $this->swatchResource->clearSwatchOptionTextByOptionId($optionsIDs, Swatch::SWATCH_TYPE_TEXTUAL); } } From 0b079e05ab2e12c004fb1e81bda57817e5f0f14f Mon Sep 17 00:00:00 2001 From: EugeneShab Date: Thu, 21 Dec 2017 15:11:59 +0200 Subject: [PATCH 004/206] magento/magento2#12695: Unable to change attribute type from swatch to dropdown - fixes after code review. --- .../Swatches/Model/Plugin/EavAttribute.php | 51 +++++++++---------- .../Swatches/Model/ResourceModel/Swatch.php | 19 ++----- 2 files changed, 28 insertions(+), 42 deletions(-) diff --git a/app/code/Magento/Swatches/Model/Plugin/EavAttribute.php b/app/code/Magento/Swatches/Model/Plugin/EavAttribute.php index a473d86b5dbf7..fcba995f50b70 100644 --- a/app/code/Magento/Swatches/Model/Plugin/EavAttribute.php +++ b/app/code/Magento/Swatches/Model/Plugin/EavAttribute.php @@ -167,7 +167,7 @@ protected function convertSwatchToDropdown(Attribute $attribute) $additionalData = $this->serializer->unserialize($additionalData); if (is_array($additionalData) && isset($additionalData[Swatch::SWATCH_INPUT_TYPE_KEY])) { if ($additionalData[Swatch::SWATCH_INPUT_TYPE_KEY] == Swatch::SWATCH_INPUT_TYPE_VISUAL) { - $this->cleanEavAttributeOptionSwatchValues($attribute); + $this->cleanEavAttributeOptionSwatchValues($attribute->getOption()); } unset($additionalData[Swatch::SWATCH_INPUT_TYPE_KEY]); $attribute->setData('additional_data', $this->serializer->serialize($additionalData)); @@ -176,22 +176,6 @@ protected function convertSwatchToDropdown(Attribute $attribute) } } - /** - * Clean swatch option values after switching to the dropdown type. - * - * @param Attribute $attribute - * @throws \Magento\Framework\Exception\LocalizedException - */ - private function cleanEavAttributeOptionSwatchValues(Attribute $attribute) - { - if (count($attribute->getOption())) { - $options = $attribute->getOption(); - $optionsIDs = array_keys($options['value']); - - $this->swatchResource->clearSwatchOptionByOptionId($optionsIDs); - } - } - /** * Creates array which link new option ids * @@ -263,7 +247,7 @@ protected function saveSwatchParams(Attribute $attribute) { if ($this->swatchHelper->isVisualSwatch($attribute)) { $this->processVisualSwatch($attribute); - $this->cleanTextSwatchValuesAfterSwitch($attribute); + $this->cleanTextSwatchValuesAfterSwitch($attribute->getOptiontext()); } elseif ($this->swatchHelper->isTextSwatch($attribute)) { $this->processTextualSwatch($attribute); } @@ -296,23 +280,34 @@ protected function processVisualSwatch(Attribute $attribute) } } + /** - * Cleaning the text type of swatch option values after switching. + * Clean swatch option values after switching to the dropdown type. * - * @param $attribute + * @param array $attributeOptions + * @param null $swatchType + * @throws \Magento\Framework\Exception\LocalizedException */ - private function cleanTextSwatchValuesAfterSwitch( Attribute $attribute) + private function cleanEavAttributeOptionSwatchValues($attributeOptions, $swatchType = null) { - $optionsIDs = []; - if (count($attribute->getOptiontext())) { - $options = $attribute->getOptiontext(); - if (count($options) && isset($options['value'])) { - $optionsIDs = array_keys($options['value']); - $this->swatchResource->clearSwatchOptionTextByOptionId($optionsIDs, Swatch::SWATCH_TYPE_TEXTUAL); - } + if (count($attributeOptions) && isset($attributeOptions['value'])) { + $optionsIDs = array_keys($attributeOptions['value']); + + $this->swatchResource->clearSwatchOptionByOptionIdAndType($optionsIDs, $swatchType); } } + /** + * Cleaning the text type of swatch option values after switching. + * + * @param array $attributeOptions + * @throws \Magento\Framework\Exception\LocalizedException + */ + private function cleanTextSwatchValuesAfterSwitch($attributeOptions) + { + $this->cleanEavAttributeOptionSwatchValues($attributeOptions, Swatch::SWATCH_TYPE_TEXTUAL); + } + /** * @param string $value * @return int diff --git a/app/code/Magento/Swatches/Model/ResourceModel/Swatch.php b/app/code/Magento/Swatches/Model/ResourceModel/Swatch.php index 6c5cf1da05dbf..8ca694725511d 100644 --- a/app/code/Magento/Swatches/Model/ResourceModel/Swatch.php +++ b/app/code/Magento/Swatches/Model/ResourceModel/Swatch.php @@ -42,28 +42,19 @@ public function saveDefaultSwatchOption($id, $defaultValue) * Cleaned swatch option values when switching to dropdown input type * * @param $optionIDs + * @param $type * @throws \Magento\Framework\Exception\LocalizedException */ - public function clearSwatchOptionByOptionId($optionIDs) + public function clearSwatchOptionByOptionIdAndType($optionIDs, $type = null) { if (count($optionIDs)) { foreach ($optionIDs as $optionId) { $where = ['option_id' => $optionId]; + if ($type !== null) { + $where['type = ?'] = $type; + } $this->getConnection()->delete($this->getMainTable(), $where); } } } - - /** - * @param $optionIDs - * @param $type - * @throws \Magento\Framework\Exception\LocalizedException - */ - public function clearSwatchOptionTextByOptionId($optionIDs, $type) - { - foreach ($optionIDs as $optionId) { - $where = ['option_id = ?' => $optionId, 'type = ?' => $type]; - $this->getConnection()->delete($this->getMainTable(), $where); - } - } } From 71d30b7c521fd5143a4cfd3252fa5c7c2c4fdd79 Mon Sep 17 00:00:00 2001 From: EugeneShab Date: Sat, 23 Dec 2017 23:50:54 +0200 Subject: [PATCH 005/206] magento/magento2#12695: Unable to change attribute type from swatch to dropdown - fixes after code review. --- app/code/Magento/Swatches/Model/SwatchAttributesProvider.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Swatches/Model/SwatchAttributesProvider.php b/app/code/Magento/Swatches/Model/SwatchAttributesProvider.php index ddac043ca5b5d..daae3515809ab 100644 --- a/app/code/Magento/Swatches/Model/SwatchAttributesProvider.php +++ b/app/code/Magento/Swatches/Model/SwatchAttributesProvider.php @@ -71,7 +71,7 @@ public function provide(Product $product) $swatchAttributes = []; foreach ($configurableAttributes as $configurableAttribute) { - if ($this->getIsSwatchAttribute($configurableAttribute->getProductAttribute())) { + if ($this->hasSwatchAttribute($configurableAttribute->getProductAttribute())) { if (array_key_exists($configurableAttribute->getAttributeId(), $swatchAttributeCodeMap)) { $swatchAttributes[$configurableAttribute->getAttributeId()] = $configurableAttribute->getProductAttribute(); @@ -90,7 +90,7 @@ public function provide(Product $product) * @return bool * @deprecated */ - private function getIsSwatchAttribute($productAttribute) + private function hasSwatchAttribute($productAttribute) { return $this->swatchesHelper->isSwatchAttribute($productAttribute); } From 47b2f4841ae27fa7bde0124e8860493e79c62a92 Mon Sep 17 00:00:00 2001 From: EugeneShab Date: Sun, 24 Dec 2017 00:14:46 +0200 Subject: [PATCH 006/206] magento/magento2#12695: Unable to change attribute type from swatch to dropdown - fixes after code review. --- app/code/Magento/Swatches/Model/SwatchAttributesProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Swatches/Model/SwatchAttributesProvider.php b/app/code/Magento/Swatches/Model/SwatchAttributesProvider.php index daae3515809ab..d7554bfea2907 100644 --- a/app/code/Magento/Swatches/Model/SwatchAttributesProvider.php +++ b/app/code/Magento/Swatches/Model/SwatchAttributesProvider.php @@ -86,7 +86,7 @@ public function provide(Product $product) /** * This method introduced only for the case when customer already has converted attribute. * - * @param \Magento\Catalog\Model\ResourceModel\Eav\Attribute $productAttribute + * @param $productAttribute * @return bool * @deprecated */ From 707f1cd34f0f4c905b07658849984d0eb825d6d7 Mon Sep 17 00:00:00 2001 From: EugeneShab Date: Tue, 26 Dec 2017 12:02:45 +0200 Subject: [PATCH 007/206] magento/magento2#12695: Unable to change attribute type from swatch to dropdown - fixes after code review. --- app/code/Magento/Swatches/Model/Plugin/EavAttribute.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Swatches/Model/Plugin/EavAttribute.php b/app/code/Magento/Swatches/Model/Plugin/EavAttribute.php index fcba995f50b70..b56d19ac5e05b 100644 --- a/app/code/Magento/Swatches/Model/Plugin/EavAttribute.php +++ b/app/code/Magento/Swatches/Model/Plugin/EavAttribute.php @@ -157,6 +157,7 @@ protected function setProperOptionsArray(Attribute $attribute) * Prepare attribute for conversion from any swatch type to dropdown * * @param Attribute $attribute + * @throws \Magento\Framework\Exception\LocalizedException * @return void */ protected function convertSwatchToDropdown(Attribute $attribute) @@ -166,9 +167,7 @@ protected function convertSwatchToDropdown(Attribute $attribute) if (!empty($additionalData)) { $additionalData = $this->serializer->unserialize($additionalData); if (is_array($additionalData) && isset($additionalData[Swatch::SWATCH_INPUT_TYPE_KEY])) { - if ($additionalData[Swatch::SWATCH_INPUT_TYPE_KEY] == Swatch::SWATCH_INPUT_TYPE_VISUAL) { - $this->cleanEavAttributeOptionSwatchValues($attribute->getOption()); - } + $this->cleanEavAttributeOptionSwatchValues($attribute->getOption()); unset($additionalData[Swatch::SWATCH_INPUT_TYPE_KEY]); $attribute->setData('additional_data', $this->serializer->serialize($additionalData)); } From 9153fe221d7ce9e65a3b082ab9d79c26245f1e0b Mon Sep 17 00:00:00 2001 From: EugeneShab Date: Mon, 19 Mar 2018 11:36:15 +0200 Subject: [PATCH 008/206] Added after merge. --- .../Model/SwatchAttributesProviderTest.php | 31 ++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Swatches/Test/Unit/Model/SwatchAttributesProviderTest.php b/app/code/Magento/Swatches/Test/Unit/Model/SwatchAttributesProviderTest.php index e00d46cfa1f3c..3beea4e368faa 100644 --- a/app/code/Magento/Swatches/Test/Unit/Model/SwatchAttributesProviderTest.php +++ b/app/code/Magento/Swatches/Test/Unit/Model/SwatchAttributesProviderTest.php @@ -27,6 +27,11 @@ class SwatchAttributesProviderTest extends \PHPUnit\Framework\TestCase */ private $swatchAttributeCodes; + /** + * @var \Magento\Swatches\Helper\Data|\PHPUnit_Framework_MockObject_MockObject + */ + private $swatchHelper; + /** * @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject */ @@ -36,16 +41,24 @@ protected function setUp() { $this->typeConfigurable = $this->createPartialMock( Configurable::class, - ['getConfigurableAttributes', 'getCodes'] + ['getConfigurableAttributes', 'getCodes', 'getProductAttribute'] ); $this->swatchAttributeCodes = $this->createMock(SwatchAttributeCodes::class); $this->productMock = $this->createPartialMock(\Magento\Catalog\Model\Product::class, ['getId', 'getTypeId']); +// $this->swatchHelper = (new ObjectManager($this)) +// ->getObject(\Magento\Swatches\Helper\Data::class); + $this->swatchHelper = $this->createPartialMock( + \Magento\Swatches\Helper\Data::class, + ['isSwatchAttribute'] + ); + $this->swatchAttributeProvider = (new ObjectManager($this))->getObject(SwatchAttributesProvider::class, [ - 'typeConfigurable' => $this->typeConfigurable, - 'swatchAttributeCodes' => $this->swatchAttributeCodes, + 'typeConfigurable' => $this->typeConfigurable, + 'swatchAttributeCodes' => $this->swatchAttributeCodes, + 'swatchesHelper' => $this->swatchHelper ]); } @@ -59,6 +72,11 @@ public function testProvide() \Magento\Framework\Interception\InterceptorInterface::class ); + $attributeMock = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class) + ->disableOriginalConstructor() + ->setMethods(['setStoreId', 'getData', 'setData', 'getSource', 'hasData']) + ->getMock(); + $configAttributeMock = $this->createPartialMock( Configurable\Attribute::class, ['getAttributeId', 'getProductAttribute'] @@ -69,7 +87,7 @@ public function testProvide() $configAttributeMock ->method('getProductAttribute') - ->willReturn($productAttributeMock); + ->willReturn($attributeMock); $this->typeConfigurable ->method('getConfigurableAttributes') @@ -81,6 +99,11 @@ public function testProvide() ->method('getCodes') ->willReturn($swatchAttributes); + $this->swatchHelper + ->method('isSwatchAttribute') + ->with($configAttributeMock) + ->willReturn(true); + $expected = [1 => $productAttributeMock]; $result = $this->swatchAttributeProvider->provide($this->productMock); From 8fa792a1444670e60fe6052c77e7b35684549906 Mon Sep 17 00:00:00 2001 From: EugeneShab Date: Thu, 3 May 2018 12:06:27 +0300 Subject: [PATCH 009/206] magento/magento2#12695: Unable to change attribute type from swatch to dropdown - fixes regarding comments @sidolov --- .../Swatches/Model/SwatchAttributesProvider.php | 12 ------------ .../Test/Unit/Model/SwatchAttributesProviderTest.php | 3 --- 2 files changed, 15 deletions(-) diff --git a/app/code/Magento/Swatches/Model/SwatchAttributesProvider.php b/app/code/Magento/Swatches/Model/SwatchAttributesProvider.php index 1b321e28987fc..3c11719b48400 100644 --- a/app/code/Magento/Swatches/Model/SwatchAttributesProvider.php +++ b/app/code/Magento/Swatches/Model/SwatchAttributesProvider.php @@ -96,16 +96,4 @@ public function provide(Product $product) } return $this->attributesPerProduct[$product->getId()]; } - - /** - * This method introduced only for the case when customer already has converted attribute. - * - * @param $productAttribute - * @return bool - * @deprecated - */ - private function hasSwatchAttribute($productAttribute) - { - return $this->swatchesHelper->isSwatchAttribute($productAttribute); - } } diff --git a/app/code/Magento/Swatches/Test/Unit/Model/SwatchAttributesProviderTest.php b/app/code/Magento/Swatches/Test/Unit/Model/SwatchAttributesProviderTest.php index e85afd6045673..1a7fbc17aeb21 100644 --- a/app/code/Magento/Swatches/Test/Unit/Model/SwatchAttributesProviderTest.php +++ b/app/code/Magento/Swatches/Test/Unit/Model/SwatchAttributesProviderTest.php @@ -56,9 +56,6 @@ protected function setUp() $this->productMock = $this->createPartialMock(\Magento\Catalog\Model\Product::class, ['getId', 'getTypeId']); $this->swatchTypeChecker = $this->createMock(SwatchAttributeType::class); - -// $this->swatchHelper = (new ObjectManager($this)) -// ->getObject(\Magento\Swatches\Helper\Data::class); $this->swatchHelper = $this->createPartialMock( \Magento\Swatches\Helper\Data::class, ['isSwatchAttribute'] From 7cd7adecf598dd6f9fe6ecd4369208869442387d Mon Sep 17 00:00:00 2001 From: EugeneShab Date: Thu, 3 May 2018 15:03:03 +0300 Subject: [PATCH 010/206] magento/magento2#12695: Unable to change attribute type from swatch to dropdown - fixed the unit test: testProvide(). --- .../Test/Unit/Model/SwatchAttributesProviderTest.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/code/Magento/Swatches/Test/Unit/Model/SwatchAttributesProviderTest.php b/app/code/Magento/Swatches/Test/Unit/Model/SwatchAttributesProviderTest.php index 1a7fbc17aeb21..532a51892d0e3 100644 --- a/app/code/Magento/Swatches/Test/Unit/Model/SwatchAttributesProviderTest.php +++ b/app/code/Magento/Swatches/Test/Unit/Model/SwatchAttributesProviderTest.php @@ -74,10 +74,6 @@ public function testProvide() $this->productMock->method('getTypeId') ->willReturn(Configurable::TYPE_CODE); - $productAttributeMock = $this->getMockBuilder(Attribute::class) - ->disableOriginalConstructor() - ->getMock(); - $attributeMock = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class) ->disableOriginalConstructor() ->setMethods(['setStoreId', 'getData', 'setData', 'getSource', 'hasData']) @@ -109,6 +105,6 @@ public function testProvide() $result = $this->swatchAttributeProvider->provide($this->productMock); - $this->assertEquals([1 => $productAttributeMock], $result); + $this->assertEquals([1 => $attributeMock], $result); } } From 54ad76c1f48eafbfe16a4e8e3c7669145a190627 Mon Sep 17 00:00:00 2001 From: EugeneShab Date: Thu, 3 May 2018 19:25:55 +0300 Subject: [PATCH 011/206] magento/magento2#12695: Unable to change attribute type from swatch to dropdown - remove empty line. --- app/code/Magento/Swatches/Model/Plugin/EavAttribute.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/code/Magento/Swatches/Model/Plugin/EavAttribute.php b/app/code/Magento/Swatches/Model/Plugin/EavAttribute.php index f299def061d0d..76bf5782d3922 100644 --- a/app/code/Magento/Swatches/Model/Plugin/EavAttribute.php +++ b/app/code/Magento/Swatches/Model/Plugin/EavAttribute.php @@ -279,7 +279,6 @@ protected function processVisualSwatch(Attribute $attribute) } } - /** * Clean swatch option values after switching to the dropdown type. * From bd126512cfe4f139a10ada9136495c1a617df158 Mon Sep 17 00:00:00 2001 From: EugeneShab Date: Fri, 4 May 2018 13:12:41 +0300 Subject: [PATCH 012/206] magento/magento2#12695: Unable to change attribute type from swatch to dropdown - fixes regarding comments @sidolov --- .../Magento/Swatches/Model/SwatchAttributesProvider.php | 7 ------- .../Test/Unit/Model/SwatchAttributesProviderTest.php | 9 --------- app/code/Magento/Swatches/etc/di.xml | 5 ----- 3 files changed, 21 deletions(-) diff --git a/app/code/Magento/Swatches/Model/SwatchAttributesProvider.php b/app/code/Magento/Swatches/Model/SwatchAttributesProvider.php index 3c11719b48400..66d4741c368d4 100644 --- a/app/code/Magento/Swatches/Model/SwatchAttributesProvider.php +++ b/app/code/Magento/Swatches/Model/SwatchAttributesProvider.php @@ -18,10 +18,6 @@ */ class SwatchAttributesProvider { - /** - * @var \Magento\Swatches\Helper\Data - */ - protected $swatchesHelper; /** * @var Configurable */ @@ -48,18 +44,15 @@ class SwatchAttributesProvider * * @param Configurable $typeConfigurable * @param SwatchAttributeCodes $swatchAttributeCodes - * @param SwatchesHelper|null $swatchHelper * @param SwatchAttributeType|null $swatchTypeChecker */ public function __construct( Configurable $typeConfigurable, SwatchAttributeCodes $swatchAttributeCodes, - SwatchesHelper $swatchHelper = null, SwatchAttributeType $swatchTypeChecker = null ) { $this->typeConfigurable = $typeConfigurable; $this->swatchAttributeCodes = $swatchAttributeCodes; - $this->swatchesHelper = $swatchHelper ?: ObjectManager::getInstance()->create(SwatchesHelper::class); $this->swatchTypeChecker = $swatchTypeChecker ?: ObjectManager::getInstance()->create(SwatchAttributeType::class); } diff --git a/app/code/Magento/Swatches/Test/Unit/Model/SwatchAttributesProviderTest.php b/app/code/Magento/Swatches/Test/Unit/Model/SwatchAttributesProviderTest.php index 532a51892d0e3..ec52d759ebafa 100644 --- a/app/code/Magento/Swatches/Test/Unit/Model/SwatchAttributesProviderTest.php +++ b/app/code/Magento/Swatches/Test/Unit/Model/SwatchAttributesProviderTest.php @@ -30,11 +30,6 @@ class SwatchAttributesProviderTest extends \PHPUnit\Framework\TestCase */ private $swatchAttributeCodes; - /** - * @var \Magento\Swatches\Helper\Data|\PHPUnit_Framework_MockObject_MockObject - */ - private $swatchHelper; - /** * @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject */ @@ -56,10 +51,6 @@ protected function setUp() $this->productMock = $this->createPartialMock(\Magento\Catalog\Model\Product::class, ['getId', 'getTypeId']); $this->swatchTypeChecker = $this->createMock(SwatchAttributeType::class); - $this->swatchHelper = $this->createPartialMock( - \Magento\Swatches\Helper\Data::class, - ['isSwatchAttribute'] - ); $this->swatchAttributeProvider = (new ObjectManager($this))->getObject(SwatchAttributesProvider::class, [ 'typeConfigurable' => $this->typeConfigurable, diff --git a/app/code/Magento/Swatches/etc/di.xml b/app/code/Magento/Swatches/etc/di.xml index 2a8b437f55270..5292bfafb6a0f 100644 --- a/app/code/Magento/Swatches/etc/di.xml +++ b/app/code/Magento/Swatches/etc/di.xml @@ -81,9 +81,4 @@ - - - \Magento\Swatches\Helper\Data\Proxy - - From cb6975c3f57739946cb65acebaf62300def1fa99 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Fri, 4 May 2018 15:41:43 +0300 Subject: [PATCH 013/206] Removed unused dependency --- app/code/Magento/Swatches/Model/SwatchAttributesProvider.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/code/Magento/Swatches/Model/SwatchAttributesProvider.php b/app/code/Magento/Swatches/Model/SwatchAttributesProvider.php index 66d4741c368d4..2dc00fcf9a428 100644 --- a/app/code/Magento/Swatches/Model/SwatchAttributesProvider.php +++ b/app/code/Magento/Swatches/Model/SwatchAttributesProvider.php @@ -9,7 +9,6 @@ use Magento\ConfigurableProduct\Model\Product\Type\Configurable; use Magento\Catalog\Model\Product; use Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute; -use Magento\Swatches\Helper\Data as SwatchesHelper; use Magento\Eav\Model\Entity\Attribute\AbstractAttribute; use Magento\Framework\App\ObjectManager; @@ -42,7 +41,7 @@ class SwatchAttributesProvider /** * SwatchAttributesProvider constructor. * - * @param Configurable $typeConfigurable + * @param Configurable $typeConfigurable * @param SwatchAttributeCodes $swatchAttributeCodes * @param SwatchAttributeType|null $swatchTypeChecker */ From 213e11d576d72a3d6bd2efd1a2f309f91d200d5d Mon Sep 17 00:00:00 2001 From: Diederick Bruin Date: Fri, 25 May 2018 16:07:53 +0200 Subject: [PATCH 014/206] Move breadcrumb json configuration to viewmodel --- .../Catalog/ViewModel/Product/Breadcrumbs.php | 27 ++++++++++++++++++- .../templates/product/breadcrumbs.phtml | 9 +------ 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/app/code/Magento/Catalog/ViewModel/Product/Breadcrumbs.php b/app/code/Magento/Catalog/ViewModel/Product/Breadcrumbs.php index 2f2048b2a3013..213f2fc34f621 100644 --- a/app/code/Magento/Catalog/ViewModel/Product/Breadcrumbs.php +++ b/app/code/Magento/Catalog/ViewModel/Product/Breadcrumbs.php @@ -8,6 +8,7 @@ use Magento\Catalog\Helper\Data; use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\DataObject; +use Magento\Framework\Serialize\Serializer\Json; use Magento\Framework\View\Element\Block\ArgumentInterface; /** @@ -27,18 +28,26 @@ class Breadcrumbs extends DataObject implements ArgumentInterface */ private $scopeConfig; + /** + * @var Json + */ + private $json; + /** * @param Data $catalogData * @param ScopeConfigInterface $scopeConfig + * @param Json $json */ public function __construct( Data $catalogData, - ScopeConfigInterface $scopeConfig + ScopeConfigInterface $scopeConfig, + Json $json ) { parent::__construct(); $this->catalogData = $catalogData; $this->scopeConfig = $scopeConfig; + $this->json = $json; } /** @@ -78,4 +87,20 @@ public function getProductName() ? $this->catalogData->getProduct()->getName() : ''; } + + /** + * Returns breadcrumb json. + * + * @return string + */ + public function getJsonConfiguration() + { + return $this->json->serialize([ + 'breadcrumbs' => [ + 'categoryUrlSuffix' => $this->getCategoryUrlSuffix(), + 'userCategoryPathInUrl' => (int)$this->isCategoryUsedInProductUrl(), + 'product' => $this->getProductName() + ] + ]); + } } diff --git a/app/code/Magento/Catalog/view/frontend/templates/product/breadcrumbs.phtml b/app/code/Magento/Catalog/view/frontend/templates/product/breadcrumbs.phtml index 063f8857329e5..d66aa5e5edb28 100644 --- a/app/code/Magento/Catalog/view/frontend/templates/product/breadcrumbs.phtml +++ b/app/code/Magento/Catalog/view/frontend/templates/product/breadcrumbs.phtml @@ -7,11 +7,4 @@ /** @var \Magento\Catalog\ViewModel\Product\Breadcrumbs $viewModel */ $viewModel = $block->getData('viewModel'); ?> - + From 0a38b845508577e38d79280288a4fc716f2d1108 Mon Sep 17 00:00:00 2001 From: Riccardo Tempesta Date: Sat, 26 May 2018 12:27:53 +0200 Subject: [PATCH 015/206] FIX for issue #15501 - M2.2.4 missing meta title tag and doesn't show product name if meta title is empty --- app/code/Magento/Catalog/Helper/Product/View.php | 7 +++---- lib/internal/Magento/Framework/View/Page/Config.php | 8 ++++++++ .../Magento/Framework/View/Page/Config/Renderer.php | 4 +++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/Catalog/Helper/Product/View.php b/app/code/Magento/Catalog/Helper/Product/View.php index 4ccea0436f2d8..90027ffb65a58 100644 --- a/app/code/Magento/Catalog/Helper/Product/View.php +++ b/app/code/Magento/Catalog/Helper/Product/View.php @@ -113,10 +113,9 @@ private function preparePageMetadata(ResultPage $resultPage, $product) { $pageConfig = $resultPage->getConfig(); - $title = $product->getMetaTitle(); - if ($title) { - $pageConfig->getTitle()->set($title); - } + $metaTitle = $product->getMetaTitle(); + $pageConfig->setMetaTitle($metaTitle); + $pageConfig->getTitle()->set($metaTitle ?: $product->getName()); $keyword = $product->getMetaKeyword(); $currentCategory = $this->_coreRegistry->registry('current_category'); diff --git a/lib/internal/Magento/Framework/View/Page/Config.php b/lib/internal/Magento/Framework/View/Page/Config.php index e3ea9a58661f2..6c9586e137640 100644 --- a/lib/internal/Magento/Framework/View/Page/Config.php +++ b/lib/internal/Magento/Framework/View/Page/Config.php @@ -339,6 +339,14 @@ public function getDescription() return $this->metadata['description']; } + /** + * @param string $title + */ + public function setMetaTitle($title) + { + $this->setMetadata('title', $title); + } + /** * @param string $keywords * @return void diff --git a/lib/internal/Magento/Framework/View/Page/Config/Renderer.php b/lib/internal/Magento/Framework/View/Page/Config/Renderer.php index 9563cbfbcc532..8a14286f8ef59 100644 --- a/lib/internal/Magento/Framework/View/Page/Config/Renderer.php +++ b/lib/internal/Magento/Framework/View/Page/Config/Renderer.php @@ -136,7 +136,9 @@ public function renderMetadata() protected function processMetadataContent($name, $content) { $method = 'get' . $this->string->upperCaseWords($name, '_', ''); - if (method_exists($this->pageConfig, $method)) { + + // We skip title, because PageConfig::getTitle() refers to the tag and not to meta title. + if (!in_array($name, ['title']) && method_exists($this->pageConfig, $method)) { $content = $this->pageConfig->$method(); } return $content; From 603de52d736e5a7e3e6473661823749ac3159961 Mon Sep 17 00:00:00 2001 From: Vishal Gelani <vishalgelani99@gmail.com> Date: Mon, 28 May 2018 12:18:09 +0530 Subject: [PATCH 016/206] Added escape text. --- .../Catalog/view/frontend/templates/product/breadcrumbs.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/view/frontend/templates/product/breadcrumbs.phtml b/app/code/Magento/Catalog/view/frontend/templates/product/breadcrumbs.phtml index d66aa5e5edb28..c54ce5340851c 100644 --- a/app/code/Magento/Catalog/view/frontend/templates/product/breadcrumbs.phtml +++ b/app/code/Magento/Catalog/view/frontend/templates/product/breadcrumbs.phtml @@ -7,4 +7,4 @@ /** @var \Magento\Catalog\ViewModel\Product\Breadcrumbs $viewModel */ $viewModel = $block->getData('viewModel'); ?> -<div class="breadcrumbs" data-mage-init='<?= $viewModel->getJsonConfiguration() ?>'></div> +<div class="breadcrumbs" data-mage-init='<?= /* @escapeNotVerified */ $viewModel->getJsonConfiguration() ?>'></div> From 8981225996e92af97671c67727be35af42591e94 Mon Sep 17 00:00:00 2001 From: Danny Verkade <danny@cream.nl> Date: Thu, 31 May 2018 16:12:13 +0200 Subject: [PATCH 017/206] This PR is a fix for issue #15627 where the default sorting behaviour of Magento was changed in Magento 2.2.4. --- app/code/Magento/Catalog/Block/Product/ProductList/Toolbar.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/Block/Product/ProductList/Toolbar.php b/app/code/Magento/Catalog/Block/Product/ProductList/Toolbar.php index dfbaf3a62420a..e9c383901b5ff 100644 --- a/app/code/Magento/Catalog/Block/Product/ProductList/Toolbar.php +++ b/app/code/Magento/Catalog/Block/Product/ProductList/Toolbar.php @@ -196,7 +196,7 @@ public function setCollection($collection) $this->_collection->addAttributeToSort( $this->getCurrentOrder(), $this->getCurrentDirection() - )->addAttributeToSort('entity_id', $this->getCurrentDirection()); + ); } else { $this->_collection->setOrder($this->getCurrentOrder(), $this->getCurrentDirection()); } From 8aea8ca5c5250c15e3b2379c66ac492f44737c69 Mon Sep 17 00:00:00 2001 From: Mark Shust <mark@shust.com> Date: Thu, 31 May 2018 17:20:24 -0400 Subject: [PATCH 018/206] Create ability to set is_visible_on_front to order status history comment --- app/code/Magento/Sales/Model/Order.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Sales/Model/Order.php b/app/code/Magento/Sales/Model/Order.php index 85443ee7f4f11..4693e0dd74df4 100644 --- a/app/code/Magento/Sales/Model/Order.php +++ b/app/code/Magento/Sales/Model/Order.php @@ -1009,7 +1009,7 @@ public function addStatusToHistory($status, $comment = '', $isCustomerNotified = * @param bool|string $status * @return OrderStatusHistoryInterface */ - public function addStatusHistoryComment($comment, $status = false) + public function addStatusHistoryComment($comment, $status = false, $isVisibleOnFront = false) { if (false === $status) { $status = $this->getStatus(); @@ -1024,6 +1024,8 @@ public function addStatusHistoryComment($comment, $status = false) $comment )->setEntityName( $this->entityType + )->setIsVisibleOnFront( + $isVisibleOnFront ); $this->addStatusHistory($history); return $history; From e95f3f7a1d790d661a024e12ad6bf34d33bb9485 Mon Sep 17 00:00:00 2001 From: Timon de Groot <tdegroot96@gmail.com> Date: Sat, 2 Jun 2018 14:20:43 +0200 Subject: [PATCH 019/206] Make new Json dependency backwards compatible --- app/code/Magento/Catalog/ViewModel/Product/Breadcrumbs.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Catalog/ViewModel/Product/Breadcrumbs.php b/app/code/Magento/Catalog/ViewModel/Product/Breadcrumbs.php index 213f2fc34f621..2b5665d20f304 100644 --- a/app/code/Magento/Catalog/ViewModel/Product/Breadcrumbs.php +++ b/app/code/Magento/Catalog/ViewModel/Product/Breadcrumbs.php @@ -7,6 +7,7 @@ use Magento\Catalog\Helper\Data; use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Framework\App\ObjectManager; use Magento\Framework\DataObject; use Magento\Framework\Serialize\Serializer\Json; use Magento\Framework\View\Element\Block\ArgumentInterface; @@ -41,13 +42,13 @@ class Breadcrumbs extends DataObject implements ArgumentInterface public function __construct( Data $catalogData, ScopeConfigInterface $scopeConfig, - Json $json + Json $json = null ) { parent::__construct(); $this->catalogData = $catalogData; $this->scopeConfig = $scopeConfig; - $this->json = $json; + $this->json = $json ?: ObjectManager::getInstance()->get(Json::class); } /** From b2cc966da3a6bcc925035e12a950e636847326f8 Mon Sep 17 00:00:00 2001 From: Riccardo Tempesta <info@riccardotempesta.com> Date: Sat, 28 Apr 2018 21:49:49 +0200 Subject: [PATCH 020/206] Fix issue #14895 - Change Password warning message appear two times The password change notice was a sticky message activated by admin_user_authenticate_after event. The password change page requires the current user password and thus triggering admin_user_authenticate_after while saving. One message was added every time the user was saved. --- app/code/Magento/User/Model/User.php | 2 ++ app/code/Magento/User/Observer/Backend/AuthObserver.php | 8 ++++++-- .../Observer/Backend/TrackAdminNewPasswordObserver.php | 3 ++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/User/Model/User.php b/app/code/Magento/User/Model/User.php index 2a7d43008f2ad..d711220441aaf 100644 --- a/app/code/Magento/User/Model/User.php +++ b/app/code/Magento/User/Model/User.php @@ -47,6 +47,8 @@ class User extends AbstractModel implements StorageInterface, UserInterface /** @deprecated */ const XML_PATH_RESET_PASSWORD_TEMPLATE = 'admin/emails/reset_password_template'; + const MESSAGE_ID_PASSWORD_EXPIRED = 'magento_user_password_expired'; + /** * Model event prefix * diff --git a/app/code/Magento/User/Observer/Backend/AuthObserver.php b/app/code/Magento/User/Observer/Backend/AuthObserver.php index bc5d6af615f13..70530c5be7263 100644 --- a/app/code/Magento/User/Observer/Backend/AuthObserver.php +++ b/app/code/Magento/User/Observer/Backend/AuthObserver.php @@ -149,7 +149,7 @@ public function execute(EventObserver $observer) /** * Update locking information for the user * - * @param \Magento\User\Model\User $user + * @param User $user * @return void */ private function _updateLockingInformation($user) @@ -195,10 +195,14 @@ private function _checkExpiredPassword($latestPassword) $myAccountUrl = $this->url->getUrl('adminhtml/system_account/'); $message = __('It\'s time to <a href="%1">change your password</a>.', $myAccountUrl); } + + // Avoid duplicating the message + $this->messageManager->getMessages()->deleteMessageByIdentifier(User::MESSAGE_ID_PASSWORD_EXPIRED); + $this->messageManager->addNoticeMessage($message); $message = $this->messageManager->getMessages()->getLastAddedMessage(); if ($message) { - $message->setIdentifier('magento_user_password_expired')->setIsSticky(true); + $message->setIdentifier(User::MESSAGE_ID_PASSWORD_EXPIRED)->setIsSticky(true); $this->authSession->setPciAdminUserIsPasswordExpired(true); } } diff --git a/app/code/Magento/User/Observer/Backend/TrackAdminNewPasswordObserver.php b/app/code/Magento/User/Observer/Backend/TrackAdminNewPasswordObserver.php index 09605372df181..059879ab9613f 100644 --- a/app/code/Magento/User/Observer/Backend/TrackAdminNewPasswordObserver.php +++ b/app/code/Magento/User/Observer/Backend/TrackAdminNewPasswordObserver.php @@ -8,6 +8,7 @@ use Magento\Framework\Event\Observer as EventObserver; use Magento\Framework\Event\ObserverInterface; +use Magento\User\Model\User; /** * User backend observer model for passwords @@ -74,7 +75,7 @@ public function execute(EventObserver $observer) $passwordHash = $user->getPassword(); if ($passwordHash && !$user->getForceNewPassword()) { $this->userResource->trackPassword($user, $passwordHash); - $this->messageManager->getMessages()->deleteMessageByIdentifier('magento_user_password_expired'); + $this->messageManager->getMessages()->deleteMessageByIdentifier(User::MESSAGE_ID_PASSWORD_EXPIRED); $this->authSession->unsPciAdminUserIsPasswordExpired(); } } From cfe58e16b5159f97fbf8b1246a6e5d75caaaf9e0 Mon Sep 17 00:00:00 2001 From: Riccardo Tempesta <info@riccardotempesta.com> Date: Sun, 29 Apr 2018 17:26:18 +0200 Subject: [PATCH 021/206] Single call for getMessages() app/code/Magento/User/Test/Unit/Observer/Backend/AuthObserverTest.php is checking for a single getMessages() call --- app/code/Magento/User/Observer/Backend/AuthObserver.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/User/Observer/Backend/AuthObserver.php b/app/code/Magento/User/Observer/Backend/AuthObserver.php index 70530c5be7263..c7a1a69f7ce84 100644 --- a/app/code/Magento/User/Observer/Backend/AuthObserver.php +++ b/app/code/Magento/User/Observer/Backend/AuthObserver.php @@ -196,11 +196,13 @@ private function _checkExpiredPassword($latestPassword) $message = __('It\'s time to <a href="%1">change your password</a>.', $myAccountUrl); } - // Avoid duplicating the message - $this->messageManager->getMessages()->deleteMessageByIdentifier(User::MESSAGE_ID_PASSWORD_EXPIRED); + $messages = $this->messageManager->getMessages(); + + // Remove existing messages with same ID to avoid duplication + $messages->deleteMessageByIdentifier(User::MESSAGE_ID_PASSWORD_EXPIRED); $this->messageManager->addNoticeMessage($message); - $message = $this->messageManager->getMessages()->getLastAddedMessage(); + $message = $messages->getLastAddedMessage(); if ($message) { $message->setIdentifier(User::MESSAGE_ID_PASSWORD_EXPIRED)->setIsSticky(true); $this->authSession->setPciAdminUserIsPasswordExpired(true); From 432cf007f79937437620f18ace00010b1a61a4ef Mon Sep 17 00:00:00 2001 From: Riccardo Tempesta <riccardo.tempesta@magespecialist.it> Date: Mon, 4 Jun 2018 19:06:11 +0200 Subject: [PATCH 022/206] Refactor to avoid method_exists call --- .../Magento/Framework/View/Page/Config.php | 52 +++++++++++++++++++ .../Framework/View/Page/Config/Renderer.php | 14 ++--- 2 files changed, 59 insertions(+), 7 deletions(-) diff --git a/lib/internal/Magento/Framework/View/Page/Config.php b/lib/internal/Magento/Framework/View/Page/Config.php index 6c9586e137640..3cc9edbb6f5e1 100644 --- a/lib/internal/Magento/Framework/View/Page/Config.php +++ b/lib/internal/Magento/Framework/View/Page/Config.php @@ -7,6 +7,7 @@ namespace Magento\Framework\View\Page; use Magento\Framework\App; +use Magento\Framework\Exception\LocalizedException; use Magento\Framework\View; /** @@ -34,6 +35,14 @@ class Config const ELEMENT_TYPE_HEAD = 'head'; /**#@-*/ + const META_DESCRIPTION = 'description'; + const META_CONTENT_TYPE = 'content_type'; + const META_MEDIA_TYPE = 'media_type'; + const META_CHARSET = 'charset'; + const META_TITLE = 'title'; + const META_KEYWORDS = 'keywords'; + const META_ROBOTS = 'robots'; + /** * Constant body attribute class */ @@ -339,6 +348,34 @@ public function getDescription() return $this->metadata['description']; } + /** + * Get rendered metadata + * @param string $fieldName + * @return string + * @throws LocalizedException + */ + public function getRenderedMetaTagValue(string $fieldName) + { + switch ($fieldName) { + case self::META_DESCRIPTION: + return $this->getDescription(); + case self::META_CONTENT_TYPE: + return $this->getContentType(); + case self::META_MEDIA_TYPE: + return $this->getMediaType(); + case self::META_CHARSET: + return $this->getCharset(); + case self::META_KEYWORDS: + return $this->getKeywords(); + case self::META_ROBOTS: + return $this->getRobots(); + case self::META_TITLE: + return $this->getMetaTitle(); + default: + throw new LocalizedException(__('No rendered meta function for %1', $fieldName)); + } + } + /** * @param string $title */ @@ -347,6 +384,21 @@ public function setMetaTitle($title) $this->setMetadata('title', $title); } + /** + * Retrieve meta title + * + * @return string + */ + public function getMetaTitle() + { + $this->build(); + if (empty($this->metadata['title'])) { + return ''; + } + + return $this->metadata['title']; + } + /** * @param string $keywords * @return void diff --git a/lib/internal/Magento/Framework/View/Page/Config/Renderer.php b/lib/internal/Magento/Framework/View/Page/Config/Renderer.php index 8a14286f8ef59..f251580441b2f 100644 --- a/lib/internal/Magento/Framework/View/Page/Config/Renderer.php +++ b/lib/internal/Magento/Framework/View/Page/Config/Renderer.php @@ -3,8 +3,10 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Framework\View\Page\Config; +use Magento\Framework\Exception\LocalizedException; use Magento\Framework\View\Asset\GroupedCollection; use Magento\Framework\View\Page\Config; @@ -131,17 +133,15 @@ public function renderMetadata() /** * @param string $name * @param string $content - * @return mixed + * @return string */ protected function processMetadataContent($name, $content) { - $method = 'get' . $this->string->upperCaseWords($name, '_', ''); - - // We skip title, because PageConfig::getTitle() refers to the tag <title> and not to meta title. - if (!in_array($name, ['title']) && method_exists($this->pageConfig, $method)) { - $content = $this->pageConfig->$method(); + try { + return $this->pageConfig->getRenderedMetaTagValue((string) $name); + } catch (LocalizedException $e) { + return (string) $content; } - return $content; } /** From 232dfa9bbbd4a62f93c14efb975826a0c308b9bf Mon Sep 17 00:00:00 2001 From: Victor Rad <vrad@magento.com> Date: Tue, 5 Jun 2018 08:54:38 +0300 Subject: [PATCH 023/206] MAGETWO-74021: "Catalog Products List" widget does not displays on frontend --- .../Rule/Model/Condition/Sql/Builder.php | 43 +----------- .../products_with_dropdown_attribute.php | 67 +++++++++++++++++++ .../Block/Product/ProductListTest.php | 29 ++++++++ 3 files changed, 97 insertions(+), 42 deletions(-) create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/_files/products_with_dropdown_attribute.php diff --git a/app/code/Magento/Rule/Model/Condition/Sql/Builder.php b/app/code/Magento/Rule/Model/Condition/Sql/Builder.php index 31592bf121d0f..11b960e73f636 100644 --- a/app/code/Magento/Rule/Model/Condition/Sql/Builder.php +++ b/app/code/Magento/Rule/Model/Condition/Sql/Builder.php @@ -147,12 +147,6 @@ protected function _getMappedSqlCondition(AbstractCondition $condition, $value = } $defaultValue = 0; - // Check if attribute has a table with default value and add it to the query - if ($this->canAttributeHaveDefaultValue($condition->getAttribute(), $isDefaultStoreUsed)) { - $defaultField = 'at_' . $condition->getAttribute() . '_default.value'; - $defaultValue = $this->_connection->quoteIdentifier($defaultField); - } - $sql = str_replace( ':field', $this->_connection->getIfNullSql($this->_connection->quoteIdentifier($argument), $defaultValue), @@ -204,45 +198,10 @@ public function attachConditionToCollection( ) { $this->_connection = $collection->getResource()->getConnection(); $this->_joinTablesToCollection($collection, $combine); - $isDefaultStoreUsed = $this->checkIsDefaultStoreUsed($collection); - $whereExpression = (string)$this->_getMappedSqlCombination($combine, '', $isDefaultStoreUsed); + $whereExpression = (string)$this->_getMappedSqlCombination($combine); if (!empty($whereExpression)) { // Select ::where method adds braces even on empty expression $collection->getSelect()->where($whereExpression); } } - - /** - * Check is default store used - * - * @param AbstractCollection $collection - * @return bool - */ - private function checkIsDefaultStoreUsed(AbstractCollection $collection): bool - { - return (int)$collection->getStoreId() === (int)$collection->getDefaultStoreId(); - } - - /** - * Check if attribute can have default value - * - * @param string $attributeCode - * @param bool $isDefaultStoreUsed - * @return bool - */ - private function canAttributeHaveDefaultValue(string $attributeCode, bool $isDefaultStoreUsed): bool - { - if ($isDefaultStoreUsed) { - return false; - } - - try { - $attribute = $this->attributeRepository->get(Product::ENTITY, $attributeCode); - } catch (NoSuchEntityException $e) { - // It's not exceptional case as we want to check if we have such attribute or not - return false; - } - - return !$attribute->isScopeGlobal(); - } } diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/products_with_dropdown_attribute.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/products_with_dropdown_attribute.php new file mode 100644 index 0000000000000..aaa3b9ec7503a --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/products_with_dropdown_attribute.php @@ -0,0 +1,67 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +/** + * Create multiselect attribute + */ +require __DIR__ . '/dropdown_attribute.php'; + +/** Create products with attribute option of dropdown type */ + +/** @var $installer \Magento\Catalog\Setup\CategorySetup */ +$installer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + \Magento\Catalog\Setup\CategorySetup::class +); + +/** @var $options \Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\Collection */ +$options = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + \Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\Collection::class +); +$options->setAttributeFilter($attribute->getId()); +$optionIds = $options->getAllIds(); + +/** @var $product \Magento\Catalog\Model\Product */ +$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Catalog\Model\Product::class); +$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE) + ->setId($optionIds[0] * 10) + ->setAttributeSetId($installer->getAttributeSetId('catalog_product', 'Default')) + ->setWebsiteIds([1]) + ->setName('With Option 1') + ->setSku('simple_op_1') + ->setPrice(10) + ->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH) + ->setDropdownAttribute($optionIds[0]) + ->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED) + ->setStockData(['use_config_manage_stock' => 1, 'qty' => 100, 'is_qty_decimal' => 0, 'is_in_stock' => 1]) + ->save(); + +$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Catalog\Model\Product::class); +$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE) + ->setId($optionIds[1] * 10) + ->setAttributeSetId($installer->getAttributeSetId('catalog_product', 'Default')) + ->setWebsiteIds([1]) + ->setName('With Option 2') + ->setSku('simple_op_2') + ->setPrice(10) + ->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH) + ->setDropdownAttribute($optionIds[1]) + ->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED) + ->setStockData(['use_config_manage_stock' => 1, 'qty' => 100, 'is_qty_decimal' => 0, 'is_in_stock' => 1]) + ->save(); + +$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Catalog\Model\Product::class); +$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE) + ->setId($optionIds[2] * 10) + ->setAttributeSetId($installer->getAttributeSetId('catalog_product', 'Default')) + ->setWebsiteIds([1]) + ->setName('With Option 3') + ->setSku('simple_op_3') + ->setPrice(10) + ->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH) + ->setDropdownAttribute($optionIds[2]) + ->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED) + ->setStockData(['use_config_manage_stock' => 1, 'qty' => 100, 'is_qty_decimal' => 0, 'is_in_stock' => 1]) + ->save(); diff --git a/dev/tests/integration/testsuite/Magento/CatalogWidget/Block/Product/ProductListTest.php b/dev/tests/integration/testsuite/Magento/CatalogWidget/Block/Product/ProductListTest.php index 151c21d9c2e21..62baa8f3d70d1 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogWidget/Block/Product/ProductListTest.php +++ b/dev/tests/integration/testsuite/Magento/CatalogWidget/Block/Product/ProductListTest.php @@ -88,6 +88,35 @@ public function testCreateCollectionWithMultipleSkuCondition() $this->performAssertions(2); } + /** + * Test product list widget can process condition with dropdown type of attribute which has Store Scope + * + * @magentoDbIsolation disabled + * @magentoDataFixture Magento/Catalog/_files/products_with_dropdown_attribute.php + */ + public function testCreateCollectionWithDropdownAttributeStoreScope() + { + /** @var $attribute \Magento\Catalog\Model\ResourceModel\Eav\Attribute */ + $attribute = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class + ); + $attribute->load('dropdown_attribute', 'attribute_code'); + $dropdownAttributeOptionIds = []; + foreach ($attribute->getOptions() as $option) { + if ($option->getValue()) { + $dropdownAttributeOptionIds[] = $option->getValue(); + } + } + $encodedConditions = '^[`1`:^[`type`:`Magento||CatalogWidget||Model||Rule||Condition||Combine`,' . + '`aggregator`:`any`,`value`:`1`,`new_child`:``^],`1--1`:^[`type`:`Magento||CatalogWidget||Model||Rule|' . + '|Condition||Product`,`attribute`:`dropdown_attribute`,`operator`:`==`,`value`:`' + . $dropdownAttributeOptionIds[0] . '`^],`1--2`:^[`type`:`Magento||CatalogWidget||Model||Rule|' . + '|Condition||Product`,`attribute`:`dropdown_attribute`,`operator`:`==`,`value`:`' + . $dropdownAttributeOptionIds[1] . '`^]^]'; + $this->block->setData('conditions_encoded', $encodedConditions); + $this->performAssertions(2); + } + /** * Check product collection includes correct amount of products. * From 8e6cae8e34391e1c3fbd1ddfaadc432f8f4742bf Mon Sep 17 00:00:00 2001 From: Victor Rad <vrad@magento.com> Date: Tue, 5 Jun 2018 09:54:01 +0300 Subject: [PATCH 024/206] MAGETWO-74021: "Catalog Products List" widget does not displays on frontend --- app/code/Magento/Rule/Model/Condition/Sql/Builder.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Rule/Model/Condition/Sql/Builder.php b/app/code/Magento/Rule/Model/Condition/Sql/Builder.php index 11b960e73f636..08940b5f0429b 100644 --- a/app/code/Magento/Rule/Model/Condition/Sql/Builder.php +++ b/app/code/Magento/Rule/Model/Condition/Sql/Builder.php @@ -130,6 +130,7 @@ protected function _joinTablesToCollection( * @param bool $isDefaultStoreUsed * @return string * @throws \Magento\Framework\Exception\LocalizedException + * @SuppressWarnings(PHPMD.UnusedLocalVariable) */ protected function _getMappedSqlCondition(AbstractCondition $condition, $value = '', $isDefaultStoreUsed = true) { From 4ff294b808760372fdcba6aea06f1d59466c718d Mon Sep 17 00:00:00 2001 From: Victor Rad <vrad@magento.com> Date: Tue, 5 Jun 2018 10:35:40 +0300 Subject: [PATCH 025/206] MAGETWO-74021: "Catalog Products List" widget does not displays on frontend --- app/code/Magento/Rule/Model/Condition/Sql/Builder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Rule/Model/Condition/Sql/Builder.php b/app/code/Magento/Rule/Model/Condition/Sql/Builder.php index 08940b5f0429b..efea70d041b34 100644 --- a/app/code/Magento/Rule/Model/Condition/Sql/Builder.php +++ b/app/code/Magento/Rule/Model/Condition/Sql/Builder.php @@ -130,7 +130,7 @@ protected function _joinTablesToCollection( * @param bool $isDefaultStoreUsed * @return string * @throws \Magento\Framework\Exception\LocalizedException - * @SuppressWarnings(PHPMD.UnusedLocalVariable) + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ protected function _getMappedSqlCondition(AbstractCondition $condition, $value = '', $isDefaultStoreUsed = true) { From ffdf57e5ea0938ea2da6bb0be91768d776458697 Mon Sep 17 00:00:00 2001 From: Victor Rad <vrad@magento.com> Date: Tue, 5 Jun 2018 12:56:47 +0300 Subject: [PATCH 026/206] MAGETWO-74021: "Catalog Products List" widget does not displays on frontend --- ...ducts_with_dropdown_attribute_rollback.php | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/_files/products_with_dropdown_attribute_rollback.php diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/products_with_dropdown_attribute_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/products_with_dropdown_attribute_rollback.php new file mode 100644 index 0000000000000..2fff69b40a61e --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/products_with_dropdown_attribute_rollback.php @@ -0,0 +1,24 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +/** + * Remove all products as strategy of isolation process + */ +$registry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Framework\Registry'); +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', true); + +/** @var $productCollection \Magento\Catalog\Model\ResourceModel\Product */ +$productCollection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Catalog\Model\Product') + ->getCollection(); + +foreach ($productCollection as $product) { + $product->delete(); +} + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', false); From fa51af4dcfbebc5aa6630276db5755525eadfbb7 Mon Sep 17 00:00:00 2001 From: Victor Rad <vrad@magento.com> Date: Tue, 5 Jun 2018 13:35:40 +0300 Subject: [PATCH 027/206] MAGETWO-74021: "Catalog Products List" widget does not displays on frontend --- .../Rule/Test/Unit/Model/Condition/Sql/BuilderTest.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/app/code/Magento/Rule/Test/Unit/Model/Condition/Sql/BuilderTest.php b/app/code/Magento/Rule/Test/Unit/Model/Condition/Sql/BuilderTest.php index daf7b1462c722..0a2767a94668a 100644 --- a/app/code/Magento/Rule/Test/Unit/Model/Condition/Sql/BuilderTest.php +++ b/app/code/Magento/Rule/Test/Unit/Model/Condition/Sql/BuilderTest.php @@ -61,12 +61,6 @@ public function testAttachConditionToCollection() $collection->expects($this->any()) ->method('getSelect') ->will($this->returnValue($select)); - $collection->expects($this->once()) - ->method('getStoreId') - ->willReturn(1); - $collection->expects($this->once()) - ->method('getDefaultStoreId') - ->willReturn(1); $resource->expects($this->once()) ->method('getConnection') From 54d494765224f7df07966bcbfdb7a8ed421680df Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov <slopukhov@magento.com> Date: Tue, 22 May 2018 13:22:39 +0300 Subject: [PATCH 028/206] MAGETWO-91886: Add ability to configure dimensions --- .../PriceIndexerDimensionsModeSetCommand.php | 179 ++++++++++++++++++ app/code/Magento/Catalog/etc/di.xml | 1 + 2 files changed, 180 insertions(+) create mode 100644 app/code/Magento/Catalog/Console/Command/PriceIndexerDimensionsModeSetCommand.php diff --git a/app/code/Magento/Catalog/Console/Command/PriceIndexerDimensionsModeSetCommand.php b/app/code/Magento/Catalog/Console/Command/PriceIndexerDimensionsModeSetCommand.php new file mode 100644 index 0000000000000..ceba8d078f045 --- /dev/null +++ b/app/code/Magento/Catalog/Console/Command/PriceIndexerDimensionsModeSetCommand.php @@ -0,0 +1,179 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Catalog\Console\Command; + +use Magento\Framework\Exception\LocalizedException; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Input\InputArgument; +use Magento\Indexer\Console\Command\AbstractIndexerCommand; +use Magento\Framework\App\ObjectManagerFactory; + +/** + * Command to change price indexer dimensions mode + */ +class PriceIndexerDimensionsModeSetCommand extends AbstractIndexerCommand +{ + const INPUT_KEY_MODE = 'mode'; + const INPUT_KEY_NONE = 'none'; + const INPUT_KEY_WEBSITE = 'website'; + const INPUT_KEY_CUSTOMER_GROUP = 'customer_group'; + const INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP = 'website_and_customer_group'; + const XML_PATH_PRICE_DIMENSIONS_MODE = 'indexer/catalog_product_price/dimensions_mode'; + + /** + * ScopeConfigInterface + * + * @var \Magento\Framework\App\Config\ScopeConfigInterface + */ + private $configReader; + + /** + * ConfigInterface + * + * @var \Magento\Framework\App\Config\ConfigResource\ConfigInterface + */ + private $configWriter; + + /** + * TypeListInterface + * + * @var \Magento\Framework\App\Cache\TypeListInterface + */ + private $cacheTypeList; + + /** + * @param ObjectManagerFactory $objectManagerFactory + * @param \Magento\Framework\App\Config\ScopeConfigInterface $configReader + * @param \Magento\Framework\App\Config\ConfigResource\ConfigInterface $configWriter + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList + */ + public function __construct( + ObjectManagerFactory $objectManagerFactory, + \Magento\Framework\App\Config\ScopeConfigInterface $configReader, + \Magento\Framework\App\Config\ConfigResource\ConfigInterface $configWriter, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList + ) { + $this->configReader = $configReader; + $this->configWriter = $configWriter; + $this->cacheTypeList = $cacheTypeList; + parent::__construct($objectManagerFactory); + } + + /** + * {@inheritdoc} + */ + protected function configure() + { + $this->setName('indexer:set-dimensions-mode:catalog_product_price') + ->setDescription('Set Indexer Dimensions Mode') + ->setDefinition($this->getInputList()); + + parent::configure(); + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $errors = $this->validate($input); + + if ($errors) { + throw new \InvalidArgumentException(implode("\n", $errors)); + } + + $returnValue = \Magento\Framework\Console\Cli::RETURN_SUCCESS; + + $indexer = $this->getObjectManager()->get(\Magento\Indexer\Model\Indexer::class); + $indexer->load(\Magento\Catalog\Model\Indexer\Product\Price\Processor::INDEXER_ID); + + try { + $currentMode = $input->getArgument(self::INPUT_KEY_MODE); + $previousMode = $this->configReader->getValue(self::XML_PATH_PRICE_DIMENSIONS_MODE) ?: self::INPUT_KEY_NONE; + + if ($previousMode !== $currentMode) { + $this->configWriter->saveConfig(self::XML_PATH_PRICE_DIMENSIONS_MODE, $currentMode); + //Create new tables and move data + $this->cacheTypeList->cleanType('config'); + //Delete old tables + } + + if ($previousMode !== $currentMode) { + $this->configWriter->saveConfig(self::XML_PATH_PRICE_DIMENSIONS_MODE, $currentMode); + $output->writeln( + 'Dimensions mode for indexer ' . $indexer->getTitle() . ' was changed from \'' + . $previousMode . '\' to \'' . $currentMode . '\'' + ); + $indexer->invalidate(); + } else { + $output->writeln('Dimensions mode for indexer ' . $indexer->getTitle() . ' has not been changed'); + } + } catch (LocalizedException $e) { + $output->writeln($e->getMessage() . PHP_EOL); + // we must have an exit code higher than zero to indicate something was wrong + $returnValue = \Magento\Framework\Console\Cli::RETURN_FAILURE; + } catch (\Exception $e) { + $output->writeln($indexer->getTitle() . " indexer process unknown error:" . PHP_EOL); + $output->writeln($e->getMessage() . PHP_EOL); + // we must have an exit code higher than zero to indicate something was wrong + $returnValue = \Magento\Framework\Console\Cli::RETURN_FAILURE; + } + + return $returnValue; + } + + /** + * Get list of arguments for the command + * + * @return InputOption[] + */ + public function getInputList() + { + $modeOptions[] = new InputArgument( + self::INPUT_KEY_MODE, + InputArgument::REQUIRED, + 'Indexer dimensions mode ['. self::INPUT_KEY_NONE . '|' . self::INPUT_KEY_WEBSITE + . '|' . self::INPUT_KEY_CUSTOMER_GROUP + . '|' . self::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP .']' + ); + return $modeOptions; + } + + /** + * Check if all admin options are provided + * + * @param InputInterface $input + * @return string[] + */ + public function validate(InputInterface $input) + { + $errors = []; + + $acceptedModeValues = ' Accepted values for ' . self::INPUT_KEY_MODE . ' are \'' + . self::INPUT_KEY_NONE . '\', \'' + . self::INPUT_KEY_WEBSITE . '\', \'' + . self::INPUT_KEY_CUSTOMER_GROUP . '\', \'' + . self::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP . '\''; + + $inputMode = $input->getArgument(self::INPUT_KEY_MODE); + if (!$inputMode) { + $errors[] = 'Missing argument \'' . self::INPUT_KEY_MODE .'\'.' . $acceptedModeValues; + } elseif (!in_array( + $inputMode, + [ + self::INPUT_KEY_NONE, + self::INPUT_KEY_WEBSITE, + self::INPUT_KEY_CUSTOMER_GROUP, + self::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP + ] + )) { + $errors[] = $acceptedModeValues; + } + return $errors; + } +} diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml index ae5f584920950..827637ad4d619 100644 --- a/app/code/Magento/Catalog/etc/di.xml +++ b/app/code/Magento/Catalog/etc/di.xml @@ -549,6 +549,7 @@ <argument name="commands" xsi:type="array"> <item name="imagesResizeCommand" xsi:type="object">Magento\Catalog\Console\Command\ImagesResizeCommand</item> <item name="productAttributesCleanUp" xsi:type="object">Magento\Catalog\Console\Command\ProductAttributesCleanUp</item> + <item name="setPriceDimensionsMode" xsi:type="object">Magento\Catalog\Console\Command\PriceIndexerDimensionsModeSetCommand</item> </argument> </arguments> </type> From 0c187041e4802583c6585ef2263027dcd956c926 Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov <slopukhov@magento.com> Date: Tue, 22 May 2018 14:34:33 +0300 Subject: [PATCH 029/206] MAGETWO-91886: Add ability to configure dimensions --- .../PriceIndexerDimensionsModeSetCommand.php | 77 +++--- .../Indexer/Product/Price/ModeSwitcher.php | 173 ++++++++++++ .../Indexer/Product/Price/TableMaintainer.php | 258 ++++++++++++++++++ 3 files changed, 476 insertions(+), 32 deletions(-) create mode 100644 app/code/Magento/Catalog/Model/Indexer/Product/Price/ModeSwitcher.php create mode 100644 app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php diff --git a/app/code/Magento/Catalog/Console/Command/PriceIndexerDimensionsModeSetCommand.php b/app/code/Magento/Catalog/Console/Command/PriceIndexerDimensionsModeSetCommand.php index ceba8d078f045..4c937ecb1179d 100644 --- a/app/code/Magento/Catalog/Console/Command/PriceIndexerDimensionsModeSetCommand.php +++ b/app/code/Magento/Catalog/Console/Command/PriceIndexerDimensionsModeSetCommand.php @@ -5,13 +5,17 @@ */ namespace Magento\Catalog\Console\Command; -use Magento\Framework\Exception\LocalizedException; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputArgument; +use Magento\Framework\Exception\LocalizedException; use Magento\Indexer\Console\Command\AbstractIndexerCommand; use Magento\Framework\App\ObjectManagerFactory; +use Magento\Catalog\Model\Indexer\Product\Price\ModeSwitcher; +use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Framework\App\Config\ConfigResource\ConfigInterface; +use Magento\Framework\App\Cache\TypeListInterface; /** * Command to change price indexer dimensions mode @@ -19,48 +23,53 @@ class PriceIndexerDimensionsModeSetCommand extends AbstractIndexerCommand { const INPUT_KEY_MODE = 'mode'; - const INPUT_KEY_NONE = 'none'; - const INPUT_KEY_WEBSITE = 'website'; - const INPUT_KEY_CUSTOMER_GROUP = 'customer_group'; - const INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP = 'website_and_customer_group'; - const XML_PATH_PRICE_DIMENSIONS_MODE = 'indexer/catalog_product_price/dimensions_mode'; /** * ScopeConfigInterface * - * @var \Magento\Framework\App\Config\ScopeConfigInterface + * @var ScopeConfigInterface */ private $configReader; /** * ConfigInterface * - * @var \Magento\Framework\App\Config\ConfigResource\ConfigInterface + * @var ConfigInterface */ private $configWriter; /** * TypeListInterface * - * @var \Magento\Framework\App\Cache\TypeListInterface + * @var TypeListInterface */ private $cacheTypeList; + /** + * ModeSwitcher + * + * @var ModeSwitcher + */ + private $modeSwitcher; + /** * @param ObjectManagerFactory $objectManagerFactory - * @param \Magento\Framework\App\Config\ScopeConfigInterface $configReader - * @param \Magento\Framework\App\Config\ConfigResource\ConfigInterface $configWriter - * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList + * @param ScopeConfigInterface $configReader + * @param ConfigInterface $configWriter + * @param TypeListInterface $cacheTypeList + * @param ModeSwitcher $modeSwitcher */ public function __construct( ObjectManagerFactory $objectManagerFactory, - \Magento\Framework\App\Config\ScopeConfigInterface $configReader, - \Magento\Framework\App\Config\ConfigResource\ConfigInterface $configWriter, - \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList + ScopeConfigInterface $configReader, + ConfigInterface $configWriter, + TypeListInterface $cacheTypeList, + ModeSwitcher $modeSwitcher ) { $this->configReader = $configReader; $this->configWriter = $configWriter; $this->cacheTypeList = $cacheTypeList; + $this->modeSwitcher = $modeSwitcher; parent::__construct($objectManagerFactory); } @@ -94,22 +103,26 @@ protected function execute(InputInterface $input, OutputInterface $output) try { $currentMode = $input->getArgument(self::INPUT_KEY_MODE); - $previousMode = $this->configReader->getValue(self::XML_PATH_PRICE_DIMENSIONS_MODE) ?: self::INPUT_KEY_NONE; + $previousMode = $this->configReader->getValue(ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE) ?: + ModeSwitcher::INPUT_KEY_NONE; if ($previousMode !== $currentMode) { - $this->configWriter->saveConfig(self::XML_PATH_PRICE_DIMENSIONS_MODE, $currentMode); + $this->configWriter->saveConfig(ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE, $currentMode); + //Create new tables and move data + $this->modeSwitcher->createTables($currentMode); + $this->modeSwitcher->moveData($currentMode, $previousMode); + $this->cacheTypeList->cleanType('config'); + $indexer->invalidate(); + //Delete old tables - } + $this->modeSwitcher->dropTables($previousMode); - if ($previousMode !== $currentMode) { - $this->configWriter->saveConfig(self::XML_PATH_PRICE_DIMENSIONS_MODE, $currentMode); $output->writeln( 'Dimensions mode for indexer ' . $indexer->getTitle() . ' was changed from \'' . $previousMode . '\' to \'' . $currentMode . '\'' ); - $indexer->invalidate(); } else { $output->writeln('Dimensions mode for indexer ' . $indexer->getTitle() . ' has not been changed'); } @@ -137,9 +150,9 @@ public function getInputList() $modeOptions[] = new InputArgument( self::INPUT_KEY_MODE, InputArgument::REQUIRED, - 'Indexer dimensions mode ['. self::INPUT_KEY_NONE . '|' . self::INPUT_KEY_WEBSITE - . '|' . self::INPUT_KEY_CUSTOMER_GROUP - . '|' . self::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP .']' + 'Indexer dimensions mode ['. ModeSwitcher::INPUT_KEY_NONE . '|' . ModeSwitcher::INPUT_KEY_WEBSITE + . '|' . ModeSwitcher::INPUT_KEY_CUSTOMER_GROUP + . '|' . ModeSwitcher::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP .']' ); return $modeOptions; } @@ -155,10 +168,10 @@ public function validate(InputInterface $input) $errors = []; $acceptedModeValues = ' Accepted values for ' . self::INPUT_KEY_MODE . ' are \'' - . self::INPUT_KEY_NONE . '\', \'' - . self::INPUT_KEY_WEBSITE . '\', \'' - . self::INPUT_KEY_CUSTOMER_GROUP . '\', \'' - . self::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP . '\''; + . ModeSwitcher::INPUT_KEY_NONE . '\', \'' + . ModeSwitcher::INPUT_KEY_WEBSITE . '\', \'' + . ModeSwitcher::INPUT_KEY_CUSTOMER_GROUP . '\', \'' + . ModeSwitcher::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP . '\''; $inputMode = $input->getArgument(self::INPUT_KEY_MODE); if (!$inputMode) { @@ -166,10 +179,10 @@ public function validate(InputInterface $input) } elseif (!in_array( $inputMode, [ - self::INPUT_KEY_NONE, - self::INPUT_KEY_WEBSITE, - self::INPUT_KEY_CUSTOMER_GROUP, - self::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP + ModeSwitcher::INPUT_KEY_NONE, + ModeSwitcher::INPUT_KEY_WEBSITE, + ModeSwitcher::INPUT_KEY_CUSTOMER_GROUP, + ModeSwitcher::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP ] )) { $errors[] = $acceptedModeValues; diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/ModeSwitcher.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/ModeSwitcher.php new file mode 100644 index 0000000000000..9faed8bf3a649 --- /dev/null +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/ModeSwitcher.php @@ -0,0 +1,173 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); +namespace Magento\Catalog\Model\Indexer\Product\Price; + +use Magento\Framework\Search\Request\Dimension; + +/** + * Class to prepare new tables for new indexer mode + */ +class ModeSwitcher +{ + const INPUT_KEY_NONE = 'none'; + const INPUT_KEY_WEBSITE = 'website'; + const INPUT_KEY_CUSTOMER_GROUP = 'customer_group'; + const INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP = 'website_and_customer_group'; + const XML_PATH_PRICE_DIMENSIONS_MODE = 'indexer/catalog_product_price/dimensions_mode'; + + /** + * ScopeConfigInterface + * + * @var \Magento\Framework\App\Config\ScopeConfigInterface + */ + private $configReader; + + /** + * ConfigInterface + * + * @var \Magento\Framework\App\Config\ConfigResource\ConfigInterface + */ + private $configWriter; + + /** + * TableMaintainer + * + * @var \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer + */ + private $tableMaintainer; + + /** + * @var \Magento\Store\Api\WebsiteRepositoryInterface + */ + private $websiteRepository; + + /** + * @var \Magento\Customer\Api\GroupRepositoryInterface + */ + private $customerGroupRepository; + + /** + * @var \Magento\Framework\Api\SearchCriteriaBuilder + */ + private $searchCriteriaBuilder; + + /** + * @var array|null + */ + private $dimensionsArray; + + /** + * @param \Magento\Framework\App\Config\ScopeConfigInterface $configReader + * @param \Magento\Framework\App\Config\ConfigResource\ConfigInterface $configWriter + * @param \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer $tableMaintainer + * @param \Magento\Store\Api\WebsiteRepositoryInterface $websiteRepository + * @param \Magento\Customer\Api\GroupRepositoryInterface $customerGroupRepository + * @param \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder + */ + public function __construct( + \Magento\Framework\App\Config\ScopeConfigInterface $configReader, + \Magento\Framework\App\Config\ConfigResource\ConfigInterface $configWriter, + \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer $tableMaintainer, + \Magento\Store\Api\WebsiteRepositoryInterface $websiteRepository, + \Magento\Customer\Api\GroupRepositoryInterface $customerGroupRepository, + \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder + ) { + $this->configReader = $configReader; + $this->configWriter = $configWriter; + $this->tableMaintainer = $tableMaintainer; + $this->websiteRepository = $websiteRepository; + $this->customerGroupRepository = $customerGroupRepository; + $this->searchCriteriaBuilder = $searchCriteriaBuilder; + } + + /** + * Create new tables + * + * @param string $currentMode + * + * @return void + */ + public function createTables($currentMode) + { + foreach ($this->getDimensionsArray($currentMode) as $dimensions) { + if (!empty($dimensions)) { + $this->tableMaintainer->createTablesForDimensions($dimensions); + } + } + } + + /** + * Move data from old tables to new + * + * @param string $currentMode + * @param string $previousMode + * + * @return void + */ + public function moveData($currentMode, $previousMode) + { + //move data + } + + /** + * Drop old tables + * + * @param string $previousMode + * + * @return void + */ + public function dropTables($previousMode) + { + foreach ($this->getDimensionsArray($previousMode) as $dimensions) { + if (empty($dimensions)) { + $this->tableMaintainer->truncateTablesForDimensions($dimensions); + } else { + $this->tableMaintainer->dropTablesForDimensions($dimensions); + } + } + } + + /** + * Get dimensions array + * + * @param string $previousMode + * + * @return array + */ + private function getDimensionsArray($mode) + { + if (isset($this->dimensionsArray[$mode])) { + return $this->dimensionsArray[$mode]; + } + + $searchCriteria = $this->searchCriteriaBuilder->create(); + $customerGroups = $this->customerGroupRepository->getList($searchCriteria)->getItems(); + + $dimensionsArray = []; + if ($mode !== self::INPUT_KEY_NONE) { + foreach ($this->websiteRepository->getList() as $website) { + foreach ($customerGroups as $customerGroup) { + $websiteDimension = new Dimension('website', $website->getId()); + $customerGroupDimension = new Dimension('group', $customerGroup->getId()); + if ($mode === self::INPUT_KEY_WEBSITE) { + $dimensionsArray[] = [$websiteDimension]; + } elseif ($mode === self::INPUT_KEY_CUSTOMER_GROUP) { + $dimensionsArray[] = [$customerGroupDimension]; + } else { + $dimensionsArray[] = [$websiteDimension, $customerGroupDimension]; + } + } + } + } else { + $dimensionsArray[] = []; + } + + $this->dimensionsArray[$mode] = $dimensionsArray; + return $this->dimensionsArray[$mode]; + } +} diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php new file mode 100644 index 0000000000000..6da978ee5663e --- /dev/null +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php @@ -0,0 +1,258 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); +namespace Magento\Catalog\Model\Indexer\Product\Price; + +use Magento\Framework\App\ResourceConnection; +use Magento\Framework\Search\Request\Dimension; +use Magento\Framework\DB\Adapter\AdapterInterface; +use Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver as TableResolver; + +class TableMaintainer +{ + /** + * Catalog product price index table name + */ + const MAIN_INDEX_TABLE = 'catalog_product_index_price'; + + /** + * @var ResourceConnection + */ + private $resource; + + /** + * @var TableResolver + */ + private $tableResolver; + + /** + * @var AdapterInterface + */ + private $connection; + + /** + * Catalog tmp category index table name + */ + private $tmpTableSuffix = '_tmp'; + + /** + * Catalog tmp category index table name + */ + private $additionalTableSuffix = '_replica'; + + /** + * @var string[] + */ + private $mainTmpTable; + + /** + * @param ResourceConnection $resource + * @param TableResolver $tableResolver + */ + public function __construct( + ResourceConnection $resource, + TableResolver $tableResolver + ) { + $this->resource = $resource; + $this->tableResolver = $tableResolver; + } + + /** + * Get connection + * + * @return AdapterInterface + */ + private function getConnection() + { + if (!isset($this->connection)) { + $this->connection = $this->resource->getConnection(); + } + return $this->connection; + } + + /** + * Return validated table name + * + * @param string|string[] $table + * @return string + */ + private function getTable($table) + { + return $this->resource->getTableName($table); + } + + /** + * Create table based on main table + * + * @param string $mainTableName + * @param string $newTableName + * + * @return void + */ + private function createTable($mainTableName, $newTableName) + { + if (!$this->getConnection()->isTableExists($newTableName)) { + $this->getConnection()->createTable( + $this->getConnection()->createTableByDdl($mainTableName, $newTableName) + ); + } + } + + /** + * Drop table + * + * @param string $tableName + * + * @return void + */ + private function dropTable($tableName) + { + if ($this->getConnection()->isTableExists($tableName)) { + $this->getConnection()->dropTable($tableName); + } + } + + /** + * Truncate table + * + * @param string $tableName + * + * @return void + */ + private function truncateTable($tableName) + { + if ($this->getConnection()->isTableExists($tableName)) { + $this->getConnection()->truncateTable($tableName); + } + } + + /** + * Get array key for tmp table + * + * @param Dimension[] $dimensions + * + * @return string + */ + private function getArrayKeyForTmpTable($dimensions) + { + $key = 'tmp'; + foreach ($dimensions as $dimension) { + $key .= $dimension->getName() . '_' . $dimension->getValue(); + } + return $key; + } + + /** + * Return main index table name + * + * @param Dimension[] $dimensions + * + * @return string + */ + public function getMainTable($dimensions) + { + return $this->tableResolver->resolve(self::MAIN_INDEX_TABLE, $dimensions); + } + + /** + * Create main and replica index tables for dimensions + * + * @param Dimension[] $dimensions + * + * @return void + */ + public function createTablesForDimensions($dimensions) + { + $mainTableName = $this->getMainTable($dimensions); + //Create index table for dimensions based on on main replica table + //Using main replica table is necessary for backward capability and TableResolver plugin work + $this->createTable( + $this->getTable(self::MAIN_INDEX_TABLE . $this->additionalTableSuffix), + $mainTableName + ); + + $mainReplicaTableName = $this->getMainTable($dimensions) . $this->additionalTableSuffix; + //Create replica table for dimensions based on main replica table + $this->createTable( + $this->getTable(self::MAIN_INDEX_TABLE . $this->additionalTableSuffix), + $mainReplicaTableName + ); + } + + /** + * Drop main and replica index tables for dimensions + * + * @param Dimension[] $dimensions + * + * @return void + */ + public function dropTablesForDimensions($dimensions) + { + $mainTableName = $this->getMainTable($dimensions); + $this->dropTable($mainTableName); + + $mainReplicaTableName = $this->getMainTable($dimensions) . $this->additionalTableSuffix; + $this->dropTable($mainReplicaTableName); + } + + /** + * Truncate main and replica index tables for dimensions + * + * @param Dimension[] $dimensions + * + * @return void + */ + public function truncateTablesForDimensions($dimensions) + { + $mainTableName = $this->getMainTable($dimensions); + $this->truncateTable($mainTableName); + + $mainReplicaTableName = $this->getMainTable($dimensions) . $this->additionalTableSuffix; + $this->truncateTable($mainReplicaTableName); + } + + /** + * Return replica index table name + * + * @param Dimension[] $dimensions + * + * @return string + */ + public function getMainReplicaTable($dimensions) + { + return $this->getMainTable($dimensions) . $this->additionalTableSuffix; + } + + /** + * Create temporary index table for dimensions + * + * @param Dimension[] $dimensions + * + * @return void + */ + public function createMainTmpTable($dimensions) + { + if (!isset($this->mainTmpTable[$this->getArrayKeyForTmpTable($dimensions)])) { + $originTableName = $this->getMainTable($dimensions); + $temporaryTableName = $this->getMainTable($dimensions) . $this->tmpTableSuffix; + $this->getConnection()->createTemporaryTableLike($temporaryTableName, $originTableName, true); + $this->mainTmpTable[$this->getArrayKeyForTmpTable($dimensions)] = $temporaryTableName; + } + } + + /** + * Return temporary index table name + * + * @param Dimension[] $dimensions + * + * @return string + */ + public function getMainTmpTable($dimensions) + { + return $this->mainTmpTable[$this->getArrayKeyForTmpTable($dimensions)]; + } +} From 461f3a2a0f4d4519aa47cb1e567727c83d833489 Mon Sep 17 00:00:00 2001 From: Andrii Voskoboinikov <avoskoboinikov@magento.com> Date: Wed, 23 May 2018 12:20:59 +0300 Subject: [PATCH 030/206] MAGETWO-91874: Adapt Full Action to use dimension --- .../Indexer/Product/Price/Action/Full.php | 246 ++++++++++++++---- .../Price/DimensionCollectionFactory.php | 107 ++++++++ .../MultiDimensionalIndexerInterface.php | 13 + .../CustomerGroupDataProvider.php | 56 ++++ .../CustomerGroupDimensionInterface.php | 16 ++ .../MultiDimensional/WebsiteDataProvider.php | 60 +++++ .../WebsiteDimensionInterface.php | 16 ++ .../Indexer/MultiDimensional/Dimension.php | 54 ++++ .../MultiDimensional/DimensionCollection.php | 84 ++++++ .../DimensionDataProviderInterface.php | 12 + .../MultiDimensional/DimensionFactory.php | 45 ++++ .../DimensionalIndexerInterface.php | 23 ++ 12 files changed, 676 insertions(+), 56 deletions(-) create mode 100644 app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionCollectionFactory.php create mode 100644 app/code/Magento/Catalog/Model/Indexer/Product/Price/MultiDimensionalIndexerInterface.php create mode 100644 app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php create mode 100644 app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDimensionInterface.php create mode 100644 app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php create mode 100644 app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDimensionInterface.php create mode 100644 lib/internal/Magento/Framework/Indexer/MultiDimensional/Dimension.php create mode 100644 lib/internal/Magento/Framework/Indexer/MultiDimensional/DimensionCollection.php create mode 100644 lib/internal/Magento/Framework/Indexer/MultiDimensional/DimensionDataProviderInterface.php create mode 100644 lib/internal/Magento/Framework/Indexer/MultiDimensional/DimensionFactory.php create mode 100644 lib/internal/Magento/Framework/Indexer/MultiDimensional/DimensionalIndexerInterface.php diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php index ba04af8ec1f41..c01690eb49fa1 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php @@ -6,12 +6,19 @@ namespace Magento\Catalog\Model\Indexer\Product\Price\Action; use Magento\Framework\App\ObjectManager; +use Magento\Framework\Indexer\MultiDimensional\Dimension; +use Magento\Framework\Indexer\MultiDimensional\DimensionalIndexerInterface; +use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\PriceInterface; +use Magento\Framework\EntityManager\EntityMetadataInterface; +use Magento\Catalog\Api\Data\ProductInterface; +use \Magento\Framework\Exception\LocalizedException; +use Magento\Catalog\Model\Indexer\Product\Price\MultiDimensionalIndexerInterface; /** * Class Full reindex action * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class Full extends \Magento\Catalog\Model\Indexer\Product\Price\AbstractAction +class Full extends \Magento\Catalog\Model\Indexer\Product\Price\AbstractAction implements DimensionalIndexerInterface { /** * @var \Magento\Framework\EntityManager\MetadataPool @@ -33,6 +40,21 @@ class Full extends \Magento\Catalog\Model\Indexer\Product\Price\AbstractAction */ private $activeTableSwitcher; + /** + * @var EntityMetadataInterface + */ + private $productMetaDataCached; + + /** + * @var \Magento\Framework\Indexer\MultiDimensional\DimensionCollection + */ + private $allDimensionCollection; + + /** + * @var \Magento\Framework\Indexer\MultiDimensional\DimensionCollection + */ + private $modeDimensionCollection; + /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $config * @param \Magento\Store\Model\StoreManagerInterface $storeManager @@ -61,7 +83,8 @@ public function __construct( \Magento\Framework\EntityManager\MetadataPool $metadataPool = null, \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\BatchSizeCalculator $batchSizeCalculator = null, \Magento\Framework\Indexer\BatchProviderInterface $batchProvider = null, - \Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher $activeTableSwitcher = null + \Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher $activeTableSwitcher = null, + \Magento\Catalog\Model\Indexer\Product\Price\DimensionCollectionFactory $dimensionCollectionFactory = null ) { parent::__construct( $config, @@ -85,6 +108,12 @@ public function __construct( $this->activeTableSwitcher = $activeTableSwitcher ?: ObjectManager::getInstance()->get( \Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher::class ); + $dimensionCollectionFactory = $dimensionCollectionFactory ?: ObjectManager::getInstance()->get( + \Magento\Catalog\Model\Indexer\Product\Price\DimensionCollectionFactory::class + ); + + $this->allDimensionCollection = $dimensionCollectionFactory->createWithAllDimensions(); + $this->modeDimensionCollection = $dimensionCollectionFactory->create(); } /** @@ -98,68 +127,173 @@ public function __construct( public function execute($ids = null) { try { - $this->_defaultIndexerResource->getTableStrategy()->setUseIdxTable(false); - $this->_prepareWebsiteDateTable(); - - $entityMetadata = $this->metadataPool->getMetadata(\Magento\Catalog\Api\Data\ProductInterface::class); - $replicaTable = $this->activeTableSwitcher->getAdditionalTableName( - $this->_defaultIndexerResource->getMainTable() - ); - - // Prepare replica table for indexation. - $this->_defaultIndexerResource->getConnection()->truncateTable($replicaTable); + $this->prepareTables(); /** @var \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\DefaultPrice $indexer */ - foreach ($this->getTypeIndexers() as $indexer) { - $indexer->getTableStrategy()->setUseIdxTable(false); - $connection = $indexer->getConnection(); - - $batches = $this->batchProvider->getBatches( - $connection, - $entityMetadata->getEntityTable(), - $entityMetadata->getIdentifierField(), - $this->batchSizeCalculator->estimateBatchSize($connection, $indexer->getTypeId()) - ); - - foreach ($batches as $batch) { - // Get entity ids from batch - $select = $connection->select(); - $select->distinct(true); - $select->from(['e' => $entityMetadata->getEntityTable()], $entityMetadata->getIdentifierField()); - $select->where('type_id = ?', $indexer->getTypeId()); - - $entityIds = $this->batchProvider->getBatchIds($connection, $select, $batch); - - if (!empty($entityIds)) { - // Temporary table will created if not exists - $idxTableName = $this->_defaultIndexerResource->getIdxTable(); - $this->_emptyTable($idxTableName); - - if ($indexer->getIsComposite()) { - $this->_copyRelationIndexData($entityIds); - } - $this->_prepareTierPriceIndex($entityIds); - - // Reindex entities by id - $indexer->reindexEntity($entityIds); - - // Sync data from temp table to index table - $this->_insertFromTable($idxTableName, $replicaTable); - - // Drop temporary index table - $connection->dropTable($idxTableName); - } + foreach ($this->getTypeIndexers() as $priceIndexer) { + $priceIndexer->getTableStrategy()->setUseIdxTable(false); + + if ($priceIndexer instanceof MultiDimensionalIndexerInterface) { + $this->reindexProductTypeWithDimensions($priceIndexer); + continue; } + + $this->reindexProductType($priceIndexer); } - $this->activeTableSwitcher->switchTable( - $this->_defaultIndexerResource->getConnection(), - [$this->_defaultIndexerResource->getMainTable()] - ); + + $this->switchTables(); } catch (\Exception $e) { - throw new \Magento\Framework\Exception\LocalizedException(__($e->getMessage()), $e); + throw new LocalizedException(__($e->getMessage()), $e); } } + private function prepareTables() + { + $this->_defaultIndexerResource->getTableStrategy()->setUseIdxTable(false); + + $this->_prepareWebsiteDateTable(); + + // Prepare replica table for indexation. + $this->_defaultIndexerResource->getConnection()->truncateTable($this->getReplicaTable()); + + // Prepare tables for dimensions. + foreach ($this->modeDimensionCollection as $dimension) { +// $this->dimensionTableMaintainer->createTableForDimension($dimension); +// $replicaTableName = $this->dimensionTableMaintainer->getMainReplicaTable($dimension); +// $this->_emptyTable($replicaTableName); + } + } + + private function switchTables() + { + // Switch default table + $this->activeTableSwitcher->switchTable( + $this->_defaultIndexerResource->getConnection(), + [$this->_defaultIndexerResource->getMainTable()] + ); + + // Switch dimension tables + $dimensionTables = []; + + foreach ($this->modeDimensionCollection as $dimension) { + $dimensionTables[] = $this->dimensionTableMaintainer->getMainReplicaTable($dimension); + } + + if (count($dimensionTables) > 0) { + $this->activeTableSwitcher->switchTable($this->_defaultIndexerResource->getConnection(), $dimensionTables); + } + } + + private function reindexProductType(PriceInterface $priceIndexer) + { + foreach ($this->getBatchesForIndexer($priceIndexer) as $batch) { + $this->reindexBatch($priceIndexer, $batch); + } + } + + private function reindexProductTypeWithDimensions(PriceInterface $priceIndexer) + { + foreach ($this->allDimensionCollection as $dimension) { + $this->reindexDimensions($priceIndexer, $dimension); + } + } + + private function reindexDimensions(PriceInterface $priceIndexer, array $dimension) + { + foreach ($this->getBatchesForIndexer($priceIndexer) as $batch) { + $this->reindexBatch($priceIndexer, $batch, $dimension); + } + } + + private function reindexBatch(PriceInterface $priceIndexer, array $batch, array $dimensions = null) + { + $entityIds = $this->getEntityIdsFromBatch($priceIndexer, $batch); + + if (!empty($entityIds)) { + // Temporary table will created if not exists + if ($dimensions === null) { + // Reindex entities by id + $idxTableName = $this->_defaultIndexerResource->getIdxTable(); + } + + if ($dimensions !== null) { + $idxTableName = $this->_defaultIndexerResource->getIdxTableWithinDimension(); + } + + $this->_emptyTable($idxTableName); + + if ($priceIndexer->getIsComposite()) { + $this->_copyRelationIndexData($entityIds); + } + $this->_prepareTierPriceIndex($entityIds); + + if ($dimensions === null) { + // Reindex entities by id + $priceIndexer->reindexEntity($entityIds); + } + + if ($dimensions !== null) { + $priceIndexer->reindexEntityWithinDimension($entityIds, $dimensions); + } + + // Sync data from temp table to index table + $this->_insertFromTable($idxTableName, $this->getReplicaTable()); + + // Drop temporary index table + $priceIndexer->getConnection()->dropTable($idxTableName); + } + } + + private function getEntityIdsFromBatch(PriceInterface $priceIndexer, array $batch) + { + // Get entity ids from batch + $select = $priceIndexer->getConnection() + ->select() + ->distinct(true) + ->from( + ['e' => $this->getProductMetaData()->getEntityTable()], + $this->getProductMetaData()->getIdentifierField() + ) + ->where('type_id = ?', $priceIndexer->getTypeId()); + + return $this->batchProvider->getBatchIds($priceIndexer->getConnection(), $select, $batch); + } + + private function getProductMetaData() + { + if ($this->productMetaDataCached === null) { + $this->productMetaDataCached = $this->metadataPool->getMetadata(ProductInterface::class); + } + + return $this->productMetaDataCached; + } + + private function getReplicaTable() + { + return $this->activeTableSwitcher->getAdditionalTableName( + $this->_defaultIndexerResource->getMainTable() + ); + } + + private function getBatchesForIndexer(PriceInterface $priceIndexer) + { + return $this->batchProvider->getBatches( + $priceIndexer->getConnection(), + $this->getProductMetaData()->getEntityTable(), + $this->getProductMetaData()->getIdentifierField(), + $this->batchSizeCalculator->estimateBatchSize( + $priceIndexer->getConnection(), + $priceIndexer->getTypeId() + ) + ); + } + + // Maybe we don`t need this at all + public function executeWithinDimensions(array $ids = [], array $dimensions = []) + { + $a = 1; + } + /** * @inheritdoc */ diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionCollectionFactory.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionCollectionFactory.php new file mode 100644 index 0000000000000..aa5c1c1100e05 --- /dev/null +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionCollectionFactory.php @@ -0,0 +1,107 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Catalog\Model\Indexer\Product\Price; + +use Magento\Framework\Indexer\MultiDimensional\Dimension; + +class DimensionCollectionFactory +{ + /** + * @var \Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProviderFactory + */ + private $websiteDataProviderFactory; + + /** + * @var \Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProviderFactory + */ + private $customerGroupDataProviderFactory; + + /** + * @var \Magento\Framework\Indexer\MultiDimensional\DimensionCollectionFactory + */ + private $generalDimensionCollectionFactory; + + /** + * @var \Magento\Framework\App\Config\ScopeConfigInterface + */ + private $configReader; + + /** + * @param \Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProviderFactory $websiteDataProviderFactory + * @param \Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProviderFactory $customerGroupDataProviderFactory + * @param \Magento\Framework\Indexer\MultiDimensional\DimensionCollectionFactory $generalDimensionCollectionFactory + * @param \Magento\Framework\App\Config\ScopeConfigInterface $configReader + */ + public function __construct( + \Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProviderFactory $websiteDataProviderFactory, + \Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProviderFactory $customerGroupDataProviderFactory, + \Magento\Framework\Indexer\MultiDimensional\DimensionCollectionFactory $generalDimensionCollectionFactory, + \Magento\Framework\App\Config\ScopeConfigInterface $configReader + ) + { + $this->websiteDataProviderFactory = $websiteDataProviderFactory; + $this->customerGroupDataProviderFactory = $customerGroupDataProviderFactory; + $this->generalDimensionCollectionFactory = $generalDimensionCollectionFactory; + $this->configReader = $configReader; + } + + /** + * @return Dimension[] + */ + public function create() + { + return $this->generalDimensionCollectionFactory->create( + [ + 'dimensionDataProviders' => $this->getDataProviders() + ] + ); + } + + public function createWithAllDimensions() + { + return $this->generalDimensionCollectionFactory->create( + [ + 'dimensionDataProviders' => [ + $this->websiteDataProviderFactory->create(), + $this->customerGroupDataProviderFactory->create() + ] + ] + ); + } + + private function getDataProviders() + { +// $dimensionsMode = $this->configReader->read('price_dimensions'); + $dimensionsMode = 'none'; + $providers = []; + + // TODO: change strings to const + switch ($dimensionsMode) { + case 'none': + break; + + case 'website': + $providers[] = $this->websiteDataProviderFactory->create(); + break; + + case 'customer_group': + $providers[] = $this->customerGroupDataProviderFactory->create(); + break; + + case 'website_and_customer_group': + $providers[] = $this->websiteDataProviderFactory->create(); + $providers[] = $this->customerGroupDataProviderFactory->create(); + break; + + default: + throw new \InvalidArgumentException( + sprintf('Undefined dimension name "%s".', $dimensionsMode) + ); + } + + return $providers; + } +} diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/MultiDimensionalIndexerInterface.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/MultiDimensionalIndexerInterface.php new file mode 100644 index 0000000000000..233984cd75595 --- /dev/null +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/MultiDimensionalIndexerInterface.php @@ -0,0 +1,13 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Catalog\Model\Indexer\Product\Price; + +interface MultiDimensionalIndexerInterface +{ + public function reindexAllWithinDimensions(array $dimensions); + public function reindexEntityWithinDimensions(array $entityIds, array $dimensions); +} diff --git a/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php b/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php new file mode 100644 index 0000000000000..302739d447151 --- /dev/null +++ b/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php @@ -0,0 +1,56 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Customer\Model\Indexer\MultiDimensional; + +use Magento\Customer\Model\ResourceModel\Group\CollectionFactory as CustomerGroupCollectionFactory; +use Magento\Framework\Indexer\MultiDimensional\DimensionFactory; +use Magento\Framework\Indexer\MultiDimensional\DimensionDataProviderInterface; + +class CustomerGroupDataProvider implements DimensionDataProviderInterface, CustomerGroupDimensionInterface +{ + /** + * @var \SplFixedArray + */ + private $customerGroupsDataIterator; + + /** + * @var DimensionFactory + */ + private $dimensionFactory; + + public function __construct(CustomerGroupCollectionFactory $collectionFactory, DimensionFactory $dimensionFactory) { + $this->dimensionFactory = $dimensionFactory; + $this->customerGroupsDataIterator = \SplFixedArray::fromArray( + $collectionFactory->create()->load()->getAllIds() + ); + } + + public function current() + { + return $this->dimensionFactory->create(self::DIMENSION_NAME, $this->customerGroupsDataIterator->current()); + } + + public function next() + { + $this->customerGroupsDataIterator->next(); + } + + public function key() + { + return $this->customerGroupsDataIterator->key(); + } + + public function valid() + { + return $this->customerGroupsDataIterator->valid(); + } + + public function rewind() + { + $this->customerGroupsDataIterator->rewind(); + } +} \ No newline at end of file diff --git a/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDimensionInterface.php b/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDimensionInterface.php new file mode 100644 index 0000000000000..1572f594dd083 --- /dev/null +++ b/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDimensionInterface.php @@ -0,0 +1,16 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Customer\Model\Indexer\MultiDimensional; + +interface CustomerGroupDimensionInterface +{ + /** + * Name for customer group dimension for multidimensional indexer + * 'cg' - stands for 'customer_group' + */ + const DIMENSION_NAME = 'cg'; +} \ No newline at end of file diff --git a/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php b/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php new file mode 100644 index 0000000000000..8fae8e019b30f --- /dev/null +++ b/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php @@ -0,0 +1,60 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Store\Model\Indexer\MultiDimensional; + +use Magento\Store\Model\ResourceModel\Website\CollectionFactory as WebsiteCollectionFactory; +use Magento\Framework\Indexer\MultiDimensional\DimensionFactory; +use Magento\Framework\Indexer\MultiDimensional\DimensionDataProviderInterface; + +class WebsiteDataProvider implements DimensionDataProviderInterface, WebsiteDimensionInterface +{ + /** + * @var \SplFixedArray + */ + private $websitesDataIterator; + + /** + * @var DimensionFactory + */ + private $dimensionFactory; + + /** + * @param WebsiteCollectionFactory $collectionFactory + * @param DimensionFactory $dimensionFactory + */ + public function __construct(WebsiteCollectionFactory $collectionFactory, DimensionFactory $dimensionFactory){ + $this->dimensionFactory = $dimensionFactory; + $this->websitesDataIterator = \SplFixedArray::fromArray( + $collectionFactory->create()->load()->getAllIds() + ); + } + + public function current() + { + return $this->dimensionFactory->create(self::DIMENSION_NAME, $this->websitesDataIterator->current()); + } + + public function next() + { + $this->websitesDataIterator->next(); + } + + public function key() + { + return $this->websitesDataIterator->key(); + } + + public function valid() + { + return $this->websitesDataIterator->valid(); + } + + public function rewind() + { + $this->websitesDataIterator->rewind(); + } +} diff --git a/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDimensionInterface.php b/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDimensionInterface.php new file mode 100644 index 0000000000000..a8b2131dc5ab7 --- /dev/null +++ b/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDimensionInterface.php @@ -0,0 +1,16 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Store\Model\Indexer\MultiDimensional; + +interface WebsiteDimensionInterface +{ + /** + * Name for website dimension for multidimensional indexer + * 'ws' - stands for 'website_store' + */ + const DIMENSION_NAME = 'ws'; +} \ No newline at end of file diff --git a/lib/internal/Magento/Framework/Indexer/MultiDimensional/Dimension.php b/lib/internal/Magento/Framework/Indexer/MultiDimensional/Dimension.php new file mode 100644 index 0000000000000..f7bb95788dd3f --- /dev/null +++ b/lib/internal/Magento/Framework/Indexer/MultiDimensional/Dimension.php @@ -0,0 +1,54 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Framework\Indexer\MultiDimensional; + +/** + * Index Dimension object + */ +class Dimension +{ + /** + * @var string + */ + private $name; + + /** + * @var string + */ + private $value; + + /** + * @param string $name + * @param string $value + */ + public function __construct(string $name, string $value) + { + $this->name = $name; + $this->value = $value; + } + + /** + * Get dimension name + * + * @return string + */ + public function getName(): string + { + return $this->name; + } + + /** + * Get dimension value + * + * @return string + */ + public function getValue(): string + { + return $this->value; + } +} diff --git a/lib/internal/Magento/Framework/Indexer/MultiDimensional/DimensionCollection.php b/lib/internal/Magento/Framework/Indexer/MultiDimensional/DimensionCollection.php new file mode 100644 index 0000000000000..7e7f11cf9b2d4 --- /dev/null +++ b/lib/internal/Magento/Framework/Indexer/MultiDimensional/DimensionCollection.php @@ -0,0 +1,84 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Framework\Indexer\MultiDimensional; + +class DimensionCollection implements \Iterator +{ + /** + * @var array + */ + private $dimensionsIterators = []; + + /** + * @var int + */ + private $dimensionsCount; + + /** + * @param array $dimensionDataProviders + */ + public function __construct(array $dimensionDataProviders = []) { + foreach ($dimensionDataProviders as $dimensionDataProvider) { + $this->addDimensionDataProvider($dimensionDataProvider); + } + + $this->dimensionsCount = count($this->dimensionsIterators); + } + + public function current() + { + $dimensions = []; + + foreach ($this->dimensionsIterators as $dimensionIterator) { + /** @var Dimension $dimension */ + $dimension = $dimensionIterator->current(); + $dimensions[$dimension->getName()] = $dimension; + } + + return $dimensions; + } + + public function next() + { + $this->dimensionsIterators[$this->dimensionsCount - 1]->next(); + + for ($i = ($this->dimensionsCount - 1); $i > 0; $i--) { + if (!$this->dimensionsIterators[$i]->valid()) { + $this->dimensionsIterators[$i]->rewind(); + $this->dimensionsIterators[$i-1]->next(); + } + } + } + + public function key() + { + $keys = []; + + foreach ($this->dimensionsIterators as $dimensionIterator) { + $keys[] = $dimensionIterator->key(); + } + + return implode(':', $keys); + } + + public function valid() + { + return $this->dimensionsCount > 0 && $this->dimensionsIterators[0]->valid(); + } + + public function rewind() + { + foreach ($this->dimensionsIterators as $dimensionIterator) { + $dimensionIterator->rewind(); + } + } + + private function addDimensionDataProvider(DimensionDataProviderInterface $dimensionDataProvider) + { + $this->dimensionsIterators[] = $dimensionDataProvider; + } +} diff --git a/lib/internal/Magento/Framework/Indexer/MultiDimensional/DimensionDataProviderInterface.php b/lib/internal/Magento/Framework/Indexer/MultiDimensional/DimensionDataProviderInterface.php new file mode 100644 index 0000000000000..78cd435361c99 --- /dev/null +++ b/lib/internal/Magento/Framework/Indexer/MultiDimensional/DimensionDataProviderInterface.php @@ -0,0 +1,12 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Framework\Indexer\MultiDimensional; + +interface DimensionDataProviderInterface extends \Iterator +{ +} diff --git a/lib/internal/Magento/Framework/Indexer/MultiDimensional/DimensionFactory.php b/lib/internal/Magento/Framework/Indexer/MultiDimensional/DimensionFactory.php new file mode 100644 index 0000000000000..77da6c8f270b7 --- /dev/null +++ b/lib/internal/Magento/Framework/Indexer/MultiDimensional/DimensionFactory.php @@ -0,0 +1,45 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Framework\Indexer\MultiDimensional; + +use Magento\Framework\ObjectManagerInterface; + +/** + * Dimension Factory + */ +class DimensionFactory +{ + /** + * @var ObjectManagerInterface + */ + private $objectManager; + + /** + * @param ObjectManagerInterface $objectManager + */ + public function __construct(ObjectManagerInterface $objectManager) + { + $this->objectManager = $objectManager; + } + + /** + * @param string $name + * @param string $value + * @return Dimension + */ + public function create(string $name, string $value): Dimension + { + return $this->objectManager->create( + Dimension::class, + [ + 'name' => $name, + 'value' => $value, + ] + ); + } +} diff --git a/lib/internal/Magento/Framework/Indexer/MultiDimensional/DimensionalIndexerInterface.php b/lib/internal/Magento/Framework/Indexer/MultiDimensional/DimensionalIndexerInterface.php new file mode 100644 index 0000000000000..8b7d32c77b373 --- /dev/null +++ b/lib/internal/Magento/Framework/Indexer/MultiDimensional/DimensionalIndexerInterface.php @@ -0,0 +1,23 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types = 1); + +namespace Magento\Framework\Indexer\MultiDimensional; + +/** + * Run indexer by specific dimension + */ +interface DimensionalIndexerInterface +{ + /** + * Execute indexer by specified dimension + * + * @param int[] $ids + * @param Dimension[] $dimensions + * @return mixed + */ + public function executeWithinDimensions(array $ids = [], array $dimensions = []); +} \ No newline at end of file From f30a813452aac1e6f04ed54d688bb2dec747c145 Mon Sep 17 00:00:00 2001 From: Andrii Voskoboinikov <avoskoboinikov@magento.com> Date: Wed, 23 May 2018 15:30:32 +0300 Subject: [PATCH 031/206] MAGETWO-91874: Adapt Full Action to use dimension --- .../Indexer/Product/Price/Action/Full.php | 14 +++-------- .../Price/DimensionCollectionFactory.php | 8 +++---- .../CustomerGroupDataProvider.php | 12 +++++++--- .../CustomerGroupDimensionInterface.php | 16 ------------- .../MultiDimensional/WebsiteDataProvider.php | 12 +++++++--- .../WebsiteDimensionInterface.php | 16 ------------- .../{MultiDimensional => }/Dimension.php | 2 +- .../DimensionCollection.php | 2 +- .../DimensionDataProviderInterface.php | 2 +- .../DimensionFactory.php | 2 +- .../DimensionalIndexerInterface.php | 23 ------------------- 11 files changed, 29 insertions(+), 80 deletions(-) delete mode 100644 app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDimensionInterface.php delete mode 100644 app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDimensionInterface.php rename lib/internal/Magento/Framework/Indexer/{MultiDimensional => }/Dimension.php (93%) rename lib/internal/Magento/Framework/Indexer/{MultiDimensional => }/DimensionCollection.php (97%) rename lib/internal/Magento/Framework/Indexer/{MultiDimensional => }/DimensionDataProviderInterface.php (78%) rename lib/internal/Magento/Framework/Indexer/{MultiDimensional => }/DimensionFactory.php (94%) delete mode 100644 lib/internal/Magento/Framework/Indexer/MultiDimensional/DimensionalIndexerInterface.php diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php index c01690eb49fa1..51f91dc346568 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php @@ -6,8 +6,6 @@ namespace Magento\Catalog\Model\Indexer\Product\Price\Action; use Magento\Framework\App\ObjectManager; -use Magento\Framework\Indexer\MultiDimensional\Dimension; -use Magento\Framework\Indexer\MultiDimensional\DimensionalIndexerInterface; use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\PriceInterface; use Magento\Framework\EntityManager\EntityMetadataInterface; use Magento\Catalog\Api\Data\ProductInterface; @@ -18,7 +16,7 @@ * Class Full reindex action * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class Full extends \Magento\Catalog\Model\Indexer\Product\Price\AbstractAction implements DimensionalIndexerInterface +class Full extends \Magento\Catalog\Model\Indexer\Product\Price\AbstractAction { /** * @var \Magento\Framework\EntityManager\MetadataPool @@ -46,12 +44,12 @@ class Full extends \Magento\Catalog\Model\Indexer\Product\Price\AbstractAction i private $productMetaDataCached; /** - * @var \Magento\Framework\Indexer\MultiDimensional\DimensionCollection + * @var \Magento\Framework\Indexer\DimensionCollection */ private $allDimensionCollection; /** - * @var \Magento\Framework\Indexer\MultiDimensional\DimensionCollection + * @var \Magento\Framework\Indexer\DimensionCollection */ private $modeDimensionCollection; @@ -288,12 +286,6 @@ private function getBatchesForIndexer(PriceInterface $priceIndexer) ); } - // Maybe we don`t need this at all - public function executeWithinDimensions(array $ids = [], array $dimensions = []) - { - $a = 1; - } - /** * @inheritdoc */ diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionCollectionFactory.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionCollectionFactory.php index aa5c1c1100e05..9c4f34a252a3a 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionCollectionFactory.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionCollectionFactory.php @@ -5,7 +5,7 @@ */ namespace Magento\Catalog\Model\Indexer\Product\Price; -use Magento\Framework\Indexer\MultiDimensional\Dimension; +use Magento\Framework\Indexer\Dimension; class DimensionCollectionFactory { @@ -20,7 +20,7 @@ class DimensionCollectionFactory private $customerGroupDataProviderFactory; /** - * @var \Magento\Framework\Indexer\MultiDimensional\DimensionCollectionFactory + * @var \Magento\Framework\Indexer\DimensionCollectionFactory */ private $generalDimensionCollectionFactory; @@ -32,13 +32,13 @@ class DimensionCollectionFactory /** * @param \Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProviderFactory $websiteDataProviderFactory * @param \Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProviderFactory $customerGroupDataProviderFactory - * @param \Magento\Framework\Indexer\MultiDimensional\DimensionCollectionFactory $generalDimensionCollectionFactory + * @param \Magento\Framework\Indexer\DimensionCollectionFactory $generalDimensionCollectionFactory * @param \Magento\Framework\App\Config\ScopeConfigInterface $configReader */ public function __construct( \Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProviderFactory $websiteDataProviderFactory, \Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProviderFactory $customerGroupDataProviderFactory, - \Magento\Framework\Indexer\MultiDimensional\DimensionCollectionFactory $generalDimensionCollectionFactory, + \Magento\Framework\Indexer\DimensionCollectionFactory $generalDimensionCollectionFactory, \Magento\Framework\App\Config\ScopeConfigInterface $configReader ) { diff --git a/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php b/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php index 302739d447151..b5ad64e0db16a 100644 --- a/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php +++ b/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php @@ -7,11 +7,17 @@ namespace Magento\Customer\Model\Indexer\MultiDimensional; use Magento\Customer\Model\ResourceModel\Group\CollectionFactory as CustomerGroupCollectionFactory; -use Magento\Framework\Indexer\MultiDimensional\DimensionFactory; -use Magento\Framework\Indexer\MultiDimensional\DimensionDataProviderInterface; +use Magento\Framework\Indexer\DimensionFactory; +use Magento\Framework\Indexer\DimensionDataProviderInterface; -class CustomerGroupDataProvider implements DimensionDataProviderInterface, CustomerGroupDimensionInterface +class CustomerGroupDataProvider implements DimensionDataProviderInterface { + /** + * Name for customer group dimension for multidimensional indexer + * 'cg' - stands for 'customer_group' + */ + const DIMENSION_NAME = 'cg'; + /** * @var \SplFixedArray */ diff --git a/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDimensionInterface.php b/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDimensionInterface.php deleted file mode 100644 index 1572f594dd083..0000000000000 --- a/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDimensionInterface.php +++ /dev/null @@ -1,16 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Customer\Model\Indexer\MultiDimensional; - -interface CustomerGroupDimensionInterface -{ - /** - * Name for customer group dimension for multidimensional indexer - * 'cg' - stands for 'customer_group' - */ - const DIMENSION_NAME = 'cg'; -} \ No newline at end of file diff --git a/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php b/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php index 8fae8e019b30f..e8f1b710ca24a 100644 --- a/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php +++ b/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php @@ -7,11 +7,17 @@ namespace Magento\Store\Model\Indexer\MultiDimensional; use Magento\Store\Model\ResourceModel\Website\CollectionFactory as WebsiteCollectionFactory; -use Magento\Framework\Indexer\MultiDimensional\DimensionFactory; -use Magento\Framework\Indexer\MultiDimensional\DimensionDataProviderInterface; +use Magento\Framework\Indexer\DimensionFactory; +use Magento\Framework\Indexer\DimensionDataProviderInterface; -class WebsiteDataProvider implements DimensionDataProviderInterface, WebsiteDimensionInterface +class WebsiteDataProvider implements DimensionDataProviderInterface { + /** + * Name for website dimension for multidimensional indexer + * 'ws' - stands for 'website_store' + */ + const DIMENSION_NAME = 'ws'; + /** * @var \SplFixedArray */ diff --git a/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDimensionInterface.php b/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDimensionInterface.php deleted file mode 100644 index a8b2131dc5ab7..0000000000000 --- a/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDimensionInterface.php +++ /dev/null @@ -1,16 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Store\Model\Indexer\MultiDimensional; - -interface WebsiteDimensionInterface -{ - /** - * Name for website dimension for multidimensional indexer - * 'ws' - stands for 'website_store' - */ - const DIMENSION_NAME = 'ws'; -} \ No newline at end of file diff --git a/lib/internal/Magento/Framework/Indexer/MultiDimensional/Dimension.php b/lib/internal/Magento/Framework/Indexer/Dimension.php similarity index 93% rename from lib/internal/Magento/Framework/Indexer/MultiDimensional/Dimension.php rename to lib/internal/Magento/Framework/Indexer/Dimension.php index f7bb95788dd3f..66a52afd70fae 100644 --- a/lib/internal/Magento/Framework/Indexer/MultiDimensional/Dimension.php +++ b/lib/internal/Magento/Framework/Indexer/Dimension.php @@ -5,7 +5,7 @@ */ declare(strict_types=1); -namespace Magento\Framework\Indexer\MultiDimensional; +namespace Magento\Framework\Indexer; /** * Index Dimension object diff --git a/lib/internal/Magento/Framework/Indexer/MultiDimensional/DimensionCollection.php b/lib/internal/Magento/Framework/Indexer/DimensionCollection.php similarity index 97% rename from lib/internal/Magento/Framework/Indexer/MultiDimensional/DimensionCollection.php rename to lib/internal/Magento/Framework/Indexer/DimensionCollection.php index 7e7f11cf9b2d4..aadfa12fcb981 100644 --- a/lib/internal/Magento/Framework/Indexer/MultiDimensional/DimensionCollection.php +++ b/lib/internal/Magento/Framework/Indexer/DimensionCollection.php @@ -4,7 +4,7 @@ * See COPYING.txt for license details. */ -namespace Magento\Framework\Indexer\MultiDimensional; +namespace Magento\Framework\Indexer; class DimensionCollection implements \Iterator { diff --git a/lib/internal/Magento/Framework/Indexer/MultiDimensional/DimensionDataProviderInterface.php b/lib/internal/Magento/Framework/Indexer/DimensionDataProviderInterface.php similarity index 78% rename from lib/internal/Magento/Framework/Indexer/MultiDimensional/DimensionDataProviderInterface.php rename to lib/internal/Magento/Framework/Indexer/DimensionDataProviderInterface.php index 78cd435361c99..1587113e060db 100644 --- a/lib/internal/Magento/Framework/Indexer/MultiDimensional/DimensionDataProviderInterface.php +++ b/lib/internal/Magento/Framework/Indexer/DimensionDataProviderInterface.php @@ -5,7 +5,7 @@ */ declare(strict_types=1); -namespace Magento\Framework\Indexer\MultiDimensional; +namespace Magento\Framework\Indexer; interface DimensionDataProviderInterface extends \Iterator { diff --git a/lib/internal/Magento/Framework/Indexer/MultiDimensional/DimensionFactory.php b/lib/internal/Magento/Framework/Indexer/DimensionFactory.php similarity index 94% rename from lib/internal/Magento/Framework/Indexer/MultiDimensional/DimensionFactory.php rename to lib/internal/Magento/Framework/Indexer/DimensionFactory.php index 77da6c8f270b7..e82218fed2655 100644 --- a/lib/internal/Magento/Framework/Indexer/MultiDimensional/DimensionFactory.php +++ b/lib/internal/Magento/Framework/Indexer/DimensionFactory.php @@ -5,7 +5,7 @@ */ declare(strict_types=1); -namespace Magento\Framework\Indexer\MultiDimensional; +namespace Magento\Framework\Indexer; use Magento\Framework\ObjectManagerInterface; diff --git a/lib/internal/Magento/Framework/Indexer/MultiDimensional/DimensionalIndexerInterface.php b/lib/internal/Magento/Framework/Indexer/MultiDimensional/DimensionalIndexerInterface.php deleted file mode 100644 index 8b7d32c77b373..0000000000000 --- a/lib/internal/Magento/Framework/Indexer/MultiDimensional/DimensionalIndexerInterface.php +++ /dev/null @@ -1,23 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -declare(strict_types = 1); - -namespace Magento\Framework\Indexer\MultiDimensional; - -/** - * Run indexer by specific dimension - */ -interface DimensionalIndexerInterface -{ - /** - * Execute indexer by specified dimension - * - * @param int[] $ids - * @param Dimension[] $dimensions - * @return mixed - */ - public function executeWithinDimensions(array $ids = [], array $dimensions = []); -} \ No newline at end of file From 4332f8b6ad15b4f3e78f810c78213883175e905a Mon Sep 17 00:00:00 2001 From: Andrii Voskoboinikov <avoskoboinikov@magento.com> Date: Wed, 23 May 2018 15:58:33 +0300 Subject: [PATCH 032/206] MAGETWO-91874: Adapt Full Action to use dimension --- .../Indexer/Product/Price/Action/Full.php | 18 ++++++++++++++---- .../Price/DimensionCollectionFactory.php | 17 +++++++++-------- .../CustomerGroupDataProvider.php | 2 +- .../MultiDimensional/WebsiteDataProvider.php | 2 +- 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php index 51f91dc346568..d05dfb6610e56 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php @@ -53,6 +53,11 @@ class Full extends \Magento\Catalog\Model\Indexer\Product\Price\AbstractAction */ private $modeDimensionCollection; + /** + * @var \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer + */ + private $dimensionTableMaintainer; + /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $config * @param \Magento\Store\Model\StoreManagerInterface $storeManager @@ -66,6 +71,7 @@ class Full extends \Magento\Catalog\Model\Indexer\Product\Price\AbstractAction * @param \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\BatchSizeCalculator|null $batchSizeCalculator * @param \Magento\Framework\Indexer\BatchProviderInterface|null $batchProvider * @param \Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher|null $activeTableSwitcher + * @param \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer|null $dimensionTableMaintainer * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -82,7 +88,8 @@ public function __construct( \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\BatchSizeCalculator $batchSizeCalculator = null, \Magento\Framework\Indexer\BatchProviderInterface $batchProvider = null, \Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher $activeTableSwitcher = null, - \Magento\Catalog\Model\Indexer\Product\Price\DimensionCollectionFactory $dimensionCollectionFactory = null + \Magento\Catalog\Model\Indexer\Product\Price\DimensionCollectionFactory $dimensionCollectionFactory = null, + \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer $dimensionTableMaintainer = null ) { parent::__construct( $config, @@ -109,6 +116,9 @@ public function __construct( $dimensionCollectionFactory = $dimensionCollectionFactory ?: ObjectManager::getInstance()->get( \Magento\Catalog\Model\Indexer\Product\Price\DimensionCollectionFactory::class ); + $this->dimensionTableMaintainer = $dimensionTableMaintainer ?: ObjectManager::getInstance()->get( + \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer::class + ); $this->allDimensionCollection = $dimensionCollectionFactory->createWithAllDimensions(); $this->modeDimensionCollection = $dimensionCollectionFactory->create(); @@ -156,9 +166,9 @@ private function prepareTables() // Prepare tables for dimensions. foreach ($this->modeDimensionCollection as $dimension) { -// $this->dimensionTableMaintainer->createTableForDimension($dimension); -// $replicaTableName = $this->dimensionTableMaintainer->getMainReplicaTable($dimension); -// $this->_emptyTable($replicaTableName); + $this->dimensionTableMaintainer->createTablesForDimensions($dimension); + $replicaTableName = $this->dimensionTableMaintainer->getMainReplicaTable($dimension); + $this->_emptyTable($replicaTableName); } } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionCollectionFactory.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionCollectionFactory.php index 9c4f34a252a3a..6556be2cdf39c 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionCollectionFactory.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionCollectionFactory.php @@ -60,6 +60,9 @@ public function create() ); } + /** + * @return Dimension[] + */ public function createWithAllDimensions() { return $this->generalDimensionCollectionFactory->create( @@ -74,24 +77,22 @@ public function createWithAllDimensions() private function getDataProviders() { -// $dimensionsMode = $this->configReader->read('price_dimensions'); - $dimensionsMode = 'none'; $providers = []; - // TODO: change strings to const - switch ($dimensionsMode) { - case 'none': + switch ($this->configReader->getValue(ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE)) { + case null: + case ModeSwitcher::INPUT_KEY_NONE: break; - case 'website': + case ModeSwitcher::INPUT_KEY_WEBSITE: $providers[] = $this->websiteDataProviderFactory->create(); break; - case 'customer_group': + case ModeSwitcher::INPUT_KEY_CUSTOMER_GROUP: $providers[] = $this->customerGroupDataProviderFactory->create(); break; - case 'website_and_customer_group': + case ModeSwitcher::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP: $providers[] = $this->websiteDataProviderFactory->create(); $providers[] = $this->customerGroupDataProviderFactory->create(); break; diff --git a/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php b/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php index b5ad64e0db16a..33495131f21a0 100644 --- a/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php +++ b/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php @@ -31,7 +31,7 @@ class CustomerGroupDataProvider implements DimensionDataProviderInterface public function __construct(CustomerGroupCollectionFactory $collectionFactory, DimensionFactory $dimensionFactory) { $this->dimensionFactory = $dimensionFactory; $this->customerGroupsDataIterator = \SplFixedArray::fromArray( - $collectionFactory->create()->load()->getAllIds() + $collectionFactory->create()->getAllIds() ); } diff --git a/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php b/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php index e8f1b710ca24a..bfe32aaed519c 100644 --- a/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php +++ b/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php @@ -35,7 +35,7 @@ class WebsiteDataProvider implements DimensionDataProviderInterface public function __construct(WebsiteCollectionFactory $collectionFactory, DimensionFactory $dimensionFactory){ $this->dimensionFactory = $dimensionFactory; $this->websitesDataIterator = \SplFixedArray::fromArray( - $collectionFactory->create()->load()->getAllIds() + $collectionFactory->create()->getAllIds() ); } From 543aad8cb2991e62482977121ca6b2afd15a5d32 Mon Sep 17 00:00:00 2001 From: Andrii Voskoboinikov <avoskoboinikov@magento.com> Date: Wed, 23 May 2018 15:59:42 +0300 Subject: [PATCH 033/206] MAGETWO-91874: Adapt Full Action to use dimension --- .../Model/Indexer/Product/Price/DimensionCollectionFactory.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionCollectionFactory.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionCollectionFactory.php index 6556be2cdf39c..1981688f8a3f1 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionCollectionFactory.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionCollectionFactory.php @@ -78,8 +78,9 @@ public function createWithAllDimensions() private function getDataProviders() { $providers = []; + $dimensionsMode = $this->configReader->getValue(ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE); - switch ($this->configReader->getValue(ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE)) { + switch ($dimensionsMode) { case null: case ModeSwitcher::INPUT_KEY_NONE: break; From 077381d00a71c8b9bec22b2d47bcd1b55af50544 Mon Sep 17 00:00:00 2001 From: Andrii Voskoboinikov <avoskoboinikov@magento.com> Date: Wed, 23 May 2018 16:02:29 +0300 Subject: [PATCH 034/206] MAGETWO-91874: Adapt Full Action to use dimension --- .../Catalog/Model/Indexer/Product/Price/Action/Full.php | 3 +-- .../Model/Indexer/Product/Price/DimensionCollectionFactory.php | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php index d05dfb6610e56..d0c03910afe38 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php @@ -167,8 +167,7 @@ private function prepareTables() // Prepare tables for dimensions. foreach ($this->modeDimensionCollection as $dimension) { $this->dimensionTableMaintainer->createTablesForDimensions($dimension); - $replicaTableName = $this->dimensionTableMaintainer->getMainReplicaTable($dimension); - $this->_emptyTable($replicaTableName); + $this->_emptyTable($this->dimensionTableMaintainer->getMainReplicaTable($dimension)); } } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionCollectionFactory.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionCollectionFactory.php index 1981688f8a3f1..556e6348a5097 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionCollectionFactory.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionCollectionFactory.php @@ -100,7 +100,7 @@ private function getDataProviders() default: throw new \InvalidArgumentException( - sprintf('Undefined dimension name "%s".', $dimensionsMode) + sprintf('Undefined dimension mode "%s".', $dimensionsMode) ); } From 3e4eb00301444940fbe1730ad8920603184608f3 Mon Sep 17 00:00:00 2001 From: Andrii Voskoboinikov <avoskoboinikov@magento.com> Date: Wed, 23 May 2018 16:41:39 +0300 Subject: [PATCH 035/206] MAGETWO-91874: Adapt Full Action to use dimension --- .../CustomerGroupDataProvider.php | 32 ++++--------------- .../MultiDimensional/WebsiteDataProvider.php | 30 ++++------------- .../Framework/Indexer/DimensionCollection.php | 17 +++++++--- .../DimensionDataProviderInterface.php | 12 ------- .../Indexer/DimensionProviderInterface.php | 17 ++++++++++ 5 files changed, 42 insertions(+), 66 deletions(-) delete mode 100644 lib/internal/Magento/Framework/Indexer/DimensionDataProviderInterface.php create mode 100644 lib/internal/Magento/Framework/Indexer/DimensionProviderInterface.php diff --git a/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php b/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php index 33495131f21a0..cca653f33136a 100644 --- a/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php +++ b/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php @@ -8,9 +8,9 @@ use Magento\Customer\Model\ResourceModel\Group\CollectionFactory as CustomerGroupCollectionFactory; use Magento\Framework\Indexer\DimensionFactory; -use Magento\Framework\Indexer\DimensionDataProviderInterface; +use Magento\Framework\Indexer\DimensionProviderInterface; -class CustomerGroupDataProvider implements DimensionDataProviderInterface +class CustomerGroupDataProvider implements DimensionProviderInterface { /** * Name for customer group dimension for multidimensional indexer @@ -35,28 +35,10 @@ public function __construct(CustomerGroupCollectionFactory $collectionFactory, D ); } - public function current() + public function getIterator(): \Traversable { - return $this->dimensionFactory->create(self::DIMENSION_NAME, $this->customerGroupsDataIterator->current()); + foreach ($this->customerGroupsDataIterator as $customerGroup) { + yield $this->dimensionFactory->create(self::DIMENSION_NAME, $customerGroup); + } } - - public function next() - { - $this->customerGroupsDataIterator->next(); - } - - public function key() - { - return $this->customerGroupsDataIterator->key(); - } - - public function valid() - { - return $this->customerGroupsDataIterator->valid(); - } - - public function rewind() - { - $this->customerGroupsDataIterator->rewind(); - } -} \ No newline at end of file +} diff --git a/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php b/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php index bfe32aaed519c..74be6206748bb 100644 --- a/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php +++ b/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php @@ -8,9 +8,9 @@ use Magento\Store\Model\ResourceModel\Website\CollectionFactory as WebsiteCollectionFactory; use Magento\Framework\Indexer\DimensionFactory; -use Magento\Framework\Indexer\DimensionDataProviderInterface; +use Magento\Framework\Indexer\DimensionProviderInterface; -class WebsiteDataProvider implements DimensionDataProviderInterface +class WebsiteDataProvider implements DimensionProviderInterface { /** * Name for website dimension for multidimensional indexer @@ -39,28 +39,10 @@ public function __construct(WebsiteCollectionFactory $collectionFactory, Dimensi ); } - public function current() + public function getIterator(): \Traversable { - return $this->dimensionFactory->create(self::DIMENSION_NAME, $this->websitesDataIterator->current()); - } - - public function next() - { - $this->websitesDataIterator->next(); - } - - public function key() - { - return $this->websitesDataIterator->key(); - } - - public function valid() - { - return $this->websitesDataIterator->valid(); - } - - public function rewind() - { - $this->websitesDataIterator->rewind(); + foreach ($this->websitesDataIterator as $website) { + yield $this->dimensionFactory->create(self::DIMENSION_NAME, $website); + } } } diff --git a/lib/internal/Magento/Framework/Indexer/DimensionCollection.php b/lib/internal/Magento/Framework/Indexer/DimensionCollection.php index aadfa12fcb981..a39257dd5a61d 100644 --- a/lib/internal/Magento/Framework/Indexer/DimensionCollection.php +++ b/lib/internal/Magento/Framework/Indexer/DimensionCollection.php @@ -13,6 +13,11 @@ class DimensionCollection implements \Iterator */ private $dimensionsIterators = []; + /** + * @var array + */ + private $dimensionsDataProviders = []; + /** * @var int */ @@ -48,7 +53,7 @@ public function next() for ($i = ($this->dimensionsCount - 1); $i > 0; $i--) { if (!$this->dimensionsIterators[$i]->valid()) { - $this->dimensionsIterators[$i]->rewind(); + $this->dimensionsIterators[$i] = $this->dimensionsDataProviders[$i]->getIterator(); $this->dimensionsIterators[$i-1]->next(); } } @@ -72,13 +77,15 @@ public function valid() public function rewind() { - foreach ($this->dimensionsIterators as $dimensionIterator) { - $dimensionIterator->rewind(); + $this->dimensionsIterators = []; + foreach ($this->dimensionsDataProviders as $dimensionsDataProvider) { + $this->dimensionsIterators[] = $dimensionsDataProvider->getIterator(); } } - private function addDimensionDataProvider(DimensionDataProviderInterface $dimensionDataProvider) + private function addDimensionDataProvider(DimensionProviderInterface $dimensionDataProvider) { - $this->dimensionsIterators[] = $dimensionDataProvider; + $this->dimensionsDataProviders[] = $dimensionDataProvider; + $this->dimensionsIterators[] = $dimensionDataProvider->getIterator(); } } diff --git a/lib/internal/Magento/Framework/Indexer/DimensionDataProviderInterface.php b/lib/internal/Magento/Framework/Indexer/DimensionDataProviderInterface.php deleted file mode 100644 index 1587113e060db..0000000000000 --- a/lib/internal/Magento/Framework/Indexer/DimensionDataProviderInterface.php +++ /dev/null @@ -1,12 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -declare(strict_types=1); - -namespace Magento\Framework\Indexer; - -interface DimensionDataProviderInterface extends \Iterator -{ -} diff --git a/lib/internal/Magento/Framework/Indexer/DimensionProviderInterface.php b/lib/internal/Magento/Framework/Indexer/DimensionProviderInterface.php new file mode 100644 index 0000000000000..ed3615e0e14d3 --- /dev/null +++ b/lib/internal/Magento/Framework/Indexer/DimensionProviderInterface.php @@ -0,0 +1,17 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Framework\Indexer; + +interface DimensionProviderInterface extends \IteratorAggregate +{ + /** + * Get Dimension Iterator. Returns yielded value of \Magento\Framework\Indexer\Dimension + * @return \Traversable|\Magento\Framework\Indexer\Dimension[] + */ + public function getIterator(): \Traversable; +} From c71a207d4229783e6d167b4cbb6a4a76e1ec5cde Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov <slopukhov@magento.com> Date: Wed, 23 May 2018 16:56:37 +0300 Subject: [PATCH 036/206] MAGETWO-91886: Add ability to configure dimensions --- .../Indexer/Product/Price/ModeSwitcher.php | 54 +++++++++++++++++-- .../Indexer/Product/Price/TableMaintainer.php | 2 +- 2 files changed, 51 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/ModeSwitcher.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/ModeSwitcher.php index 9faed8bf3a649..e7108732859e2 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/ModeSwitcher.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/ModeSwitcher.php @@ -111,7 +111,24 @@ public function createTables($currentMode) */ public function moveData($currentMode, $previousMode) { - //move data + $dimensionsArrayForCurrentMode = $this->getDimensionsArray($currentMode); + $dimensionsArrayForPreviousMode = $this->getDimensionsArray($previousMode); + + foreach ($dimensionsArrayForCurrentMode as $dimensionsForCurrentMode) { + $newTable = $this->tableMaintainer->getMainTable($dimensionsForCurrentMode); + if (empty($dimensionsForCurrentMode)) { + // new mode none + foreach ($dimensionsArrayForPreviousMode as $dimensionsForPreviousMode) { + $oldTable = $this->tableMaintainer->getMainTable($dimensionsForPreviousMode); + $this->insertFromOldTablesToNew($newTable, $oldTable); + } + } else { + foreach ($dimensionsArrayForPreviousMode as $dimensionsForPreviousMode) { + $oldTable = $this->tableMaintainer->getMainTable($dimensionsForPreviousMode); + $this->insertFromOldTablesToNew($newTable, $oldTable, $dimensionsForCurrentMode); + } + } + } } /** @@ -155,11 +172,14 @@ private function getDimensionsArray($mode) $websiteDimension = new Dimension('website', $website->getId()); $customerGroupDimension = new Dimension('group', $customerGroup->getId()); if ($mode === self::INPUT_KEY_WEBSITE) { - $dimensionsArray[] = [$websiteDimension]; + $key = $websiteDimension->getValue(); + $dimensionsArray[$key] = [$websiteDimension]; } elseif ($mode === self::INPUT_KEY_CUSTOMER_GROUP) { - $dimensionsArray[] = [$customerGroupDimension]; + $key = $customerGroupDimension->getValue(); + $dimensionsArray[$key] = [$customerGroupDimension]; } else { - $dimensionsArray[] = [$websiteDimension, $customerGroupDimension]; + $key = $websiteDimension->getValue() . '-' . $customerGroupDimension->getValue(); + $dimensionsArray[$key] = [$websiteDimension, $customerGroupDimension]; } } } @@ -170,4 +190,30 @@ private function getDimensionsArray($mode) $this->dimensionsArray[$mode] = $dimensionsArray; return $this->dimensionsArray[$mode]; } + + /** + * Insert from old tables data to new + * + * @param string $newTable + * @param string $oldTable + * @param Dimension[] $dimensions + * + * @return void + */ + private function insertFromOldTablesToNew($newTable, $oldTable, $dimensions = []) + { + $select = $this->tableMaintainer->getConnection()->select()->from($oldTable); + + foreach ($dimensions as $dimension) { + if ($dimension->getName() === 'website') { + $select->where('website_id = ?', $dimension->getValue()); + } + if ($dimension->getName() === 'group') { + $select->where('customer_group_id = ?', $dimension->getValue()); + } + } + $this->tableMaintainer->getConnection()->query( + $this->tableMaintainer->getConnection()->insertFromSelect($select, $newTable) + ); + } } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php index 6da978ee5663e..cc3c72edab66f 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php @@ -66,7 +66,7 @@ public function __construct( * * @return AdapterInterface */ - private function getConnection() + public function getConnection() { if (!isset($this->connection)) { $this->connection = $this->resource->getConnection(); From f8570ac36e37819c5b0987ddae29b3ce3b7e0c78 Mon Sep 17 00:00:00 2001 From: Andrii Voskoboinikov <avoskoboinikov@magento.com> Date: Wed, 23 May 2018 17:11:00 +0300 Subject: [PATCH 037/206] MAGETWO-91874: Adapt Full Action to use dimension --- .../Indexer/Product/Price/Action/Full.php | 44 ++++++++++++------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php index d0c03910afe38..54487f32d7e75 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php @@ -208,25 +208,42 @@ private function reindexProductTypeWithDimensions(PriceInterface $priceIndexer) private function reindexDimensions(PriceInterface $priceIndexer, array $dimension) { foreach ($this->getBatchesForIndexer($priceIndexer) as $batch) { - $this->reindexBatch($priceIndexer, $batch, $dimension); + $this->reindexBatchWithinDimension($priceIndexer, $batch, $dimension); } } - private function reindexBatch(PriceInterface $priceIndexer, array $batch, array $dimensions = null) + private function reindexBatch(PriceInterface $priceIndexer, array $batch) { $entityIds = $this->getEntityIdsFromBatch($priceIndexer, $batch); if (!empty($entityIds)) { // Temporary table will created if not exists - if ($dimensions === null) { - // Reindex entities by id - $idxTableName = $this->_defaultIndexerResource->getIdxTable(); - } + $idxTableName = $this->_defaultIndexerResource->getIdxTable(); + $this->_emptyTable($idxTableName); - if ($dimensions !== null) { - $idxTableName = $this->_defaultIndexerResource->getIdxTableWithinDimension(); + if ($priceIndexer->getIsComposite()) { + $this->_copyRelationIndexData($entityIds); } + $this->_prepareTierPriceIndex($entityIds); + + // Reindex entities by id + $priceIndexer->reindexEntity($entityIds); + // Sync data from temp table to index table + $this->_insertFromTable($idxTableName, $this->getReplicaTable()); + + // Drop temporary index table + $priceIndexer->getConnection()->dropTable($idxTableName); + } + } + + private function reindexBatchWithinDimension(PriceInterface $priceIndexer, array $batch, array $dimensions) + { + $entityIds = $this->getEntityIdsFromBatch($priceIndexer, $batch); + + if (!empty($entityIds)) { + // Temporary table will created if not exists + $idxTableName = $this->_defaultIndexerResource->getIdxTableWithinDimension(); $this->_emptyTable($idxTableName); if ($priceIndexer->getIsComposite()) { @@ -234,17 +251,10 @@ private function reindexBatch(PriceInterface $priceIndexer, array $batch, array } $this->_prepareTierPriceIndex($entityIds); - if ($dimensions === null) { - // Reindex entities by id - $priceIndexer->reindexEntity($entityIds); - } - - if ($dimensions !== null) { - $priceIndexer->reindexEntityWithinDimension($entityIds, $dimensions); - } + $priceIndexer->reindexEntityWithinDimension($entityIds, $dimensions); // Sync data from temp table to index table - $this->_insertFromTable($idxTableName, $this->getReplicaTable()); + $this->_insertFromTable($idxTableName, $this->dimensionTableMaintainer->getMainReplicaTable($dimensions)); // Drop temporary index table $priceIndexer->getConnection()->dropTable($idxTableName); From 6c81af0cc34055a5a196f09f953fb2f9aef78a4e Mon Sep 17 00:00:00 2001 From: Michail Slabko <mslabko@magento.com> Date: Wed, 23 May 2018 18:32:40 +0300 Subject: [PATCH 038/206] MAGETWO-91876: Adapt base select to use dimensions --- .../Product/Indexer/Price/DefaultPrice.php | 153 +++--------------- .../Indexer/Price/Query/BaseFinalPrice.php | 141 ++++++++++++++++ .../Price/Query/JoinAttributeProcessor.php | 128 +++++++++++++++ .../Product/Indexer/Price/Query/AddTaxId.php | 48 ++++++ app/code/Magento/Tax/etc/di.xml | 3 + 5 files changed, 339 insertions(+), 134 deletions(-) create mode 100644 app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php create mode 100644 app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/JoinAttributeProcessor.php create mode 100644 app/code/Magento/Tax/Plugin/Product/Indexer/Price/Query/AddTaxId.php diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php index 1de0a480c9fbc..9c1578205152d 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php @@ -6,6 +6,9 @@ namespace Magento\Catalog\Model\ResourceModel\Product\Indexer\Price; use Magento\Catalog\Model\ResourceModel\Product\Indexer\AbstractIndexer; +use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\Query\BaseFinalPrice; +use Magento\Framework\App\ObjectManager; +use Magento\Framework\Backup\BackupException; /** * Default Product Type Price Indexer Resource model @@ -63,8 +66,11 @@ class DefaultPrice extends AbstractIndexer implements PriceInterface private $priceModifiers = []; /** - * DefaultPrice constructor. - * + * @var BaseFinalPrice + */ + private $baseFinalPrice; + + /** * @param \Magento\Framework\Model\ResourceModel\Db\Context $context * @param \Magento\Framework\Indexer\Table\StrategyInterface $tableStrategy * @param \Magento\Eav\Model\Config $eavConfig @@ -82,6 +88,7 @@ public function __construct( \Magento\Framework\Module\Manager $moduleManager, $connectionName = null, IndexTableStructureFactory $indexTableStructureFactory = null, + BaseFinalPrice $baseFinalPrice = null, array $priceModifiers = [] ) { $this->_eventManager = $eventManager; @@ -89,7 +96,7 @@ public function __construct( parent::__construct($context, $tableStrategy, $eavConfig, $connectionName); $this->indexTableStructureFactory = $indexTableStructureFactory ?: - \Magento\Framework\App\ObjectManager::getInstance()->get(IndexTableStructureFactory::class); + ObjectManager::getInstance()->get(IndexTableStructureFactory::class); foreach ($priceModifiers as $priceModifier) { if (!($priceModifier instanceof PriceModifierInterface)) { throw new \InvalidArgumentException( @@ -99,6 +106,7 @@ public function __construct( $this->priceModifiers[] = $priceModifier; } + $this->baseFinalPrice = $baseFinalPrice ?? ObjectManager::getInstance()->get(BackupException::class); } /** @@ -303,7 +311,8 @@ protected function prepareFinalPriceDataForType($entityIds, $type) { $finalPriceTable = $this->prepareFinalPriceTable(); - $select = $this->getSelect($entityIds, $type); + //TODO: use DimensionProvider foreach instead hard-coded values + $select = $this->getSelect($entityIds, $type, 1, 1); $query = $select->insertFromSelect($finalPriceTable->getTableName(), [], false); $this->getConnection()->query($query); @@ -324,135 +333,9 @@ protected function prepareFinalPriceDataForType($entityIds, $type) * @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @since 101.0.8 */ - protected function getSelect($entityIds = null, $type = null) + protected function getSelect($entityIds = null, $type = null, int $websiteId = null, int $customerGroupId = null) { - $metadata = $this->getMetadataPool()->getMetadata(\Magento\Catalog\Api\Data\ProductInterface::class); - $connection = $this->getConnection(); - $select = $connection->select()->from( - ['e' => $this->getTable('catalog_product_entity')], - ['entity_id'] - )->join( - ['cg' => $this->getTable('customer_group')], - '', - ['customer_group_id'] - )->join( - ['cw' => $this->getTable('store_website')], - '', - ['website_id'] - )->join( - ['cwd' => $this->_getWebsiteDateTable()], - 'cw.website_id = cwd.website_id', - [] - )->join( - ['csg' => $this->getTable('store_group')], - 'csg.website_id = cw.website_id AND cw.default_group_id = csg.group_id', - [] - )->join( - ['cs' => $this->getTable('store')], - 'csg.default_store_id = cs.store_id AND cs.store_id != 0', - [] - )->join( - ['pw' => $this->getTable('catalog_product_website')], - 'pw.product_id = e.entity_id AND pw.website_id = cw.website_id', - [] - )->joinLeft( - ['tp' => $this->_getTierPriceIndexTable()], - 'tp.entity_id = e.entity_id AND tp.website_id = cw.website_id' . - ' AND tp.customer_group_id = cg.customer_group_id', - [] - ); - - if ($type !== null) { - $select->where('e.type_id = ?', $type); - } - - // add enable products limitation - $statusCond = $connection->quoteInto( - '=?', - \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED - ); - $this->_addAttributeToSelect( - $select, - 'status', - 'e.' . $metadata->getLinkField(), - 'cs.store_id', - $statusCond, - true - ); - if ($this->moduleManager->isEnabled('Magento_Tax')) { - $taxClassId = $this->_addAttributeToSelect( - $select, - 'tax_class_id', - 'e.' . $metadata->getLinkField(), - 'cs.store_id' - ); - } else { - $taxClassId = new \Zend_Db_Expr('0'); - } - $select->columns(['tax_class_id' => $taxClassId]); - - $price = $this->_addAttributeToSelect( - $select, - 'price', - 'e.' . $metadata->getLinkField(), - 'cs.store_id' - ); - $specialPrice = $this->_addAttributeToSelect( - $select, - 'special_price', - 'e.' . $metadata->getLinkField(), - 'cs.store_id' - ); - $specialFrom = $this->_addAttributeToSelect( - $select, - 'special_from_date', - 'e.' . $metadata->getLinkField(), - 'cs.store_id' - ); - $specialTo = $this->_addAttributeToSelect( - $select, - 'special_to_date', - 'e.' . $metadata->getLinkField(), - 'cs.store_id' - ); - $currentDate = 'cwd.website_date'; - - $maxUnsignedBigint = '~0'; - $specialFromDate = $connection->getDatePartSql($specialFrom); - $specialToDate = $connection->getDatePartSql($specialTo); - $specialFromExpr = "{$specialFrom} IS NULL OR {$specialFromDate} <= {$currentDate}"; - $specialToExpr = "{$specialTo} IS NULL OR {$specialToDate} >= {$currentDate}"; - $specialPriceExpr = $connection->getCheckSql( - "{$specialPrice} IS NOT NULL AND {$specialFromExpr} AND {$specialToExpr}", - $specialPrice, - $maxUnsignedBigint - ); - $tierPrice = new \Zend_Db_Expr('tp.min_price'); - $tierPriceExpr = $connection->getIfNullSql( - $tierPrice, - $maxUnsignedBigint - ); - $finalPrice = $connection->getLeastSql([ - $price, - $specialPriceExpr, - $tierPriceExpr, - ]); - - $select->columns( - [ - 'orig_price' => $connection->getIfNullSql($price, 0), - 'price' => $connection->getIfNullSql($finalPrice, 0), - 'min_price' => $connection->getIfNullSql($finalPrice, 0), - 'max_price' => $connection->getIfNullSql($finalPrice, 0), - 'tier_price' => $tierPrice, - 'base_tier' => $tierPrice, - ] - ); - - if ($entityIds !== null) { - $select->where('e.entity_id IN(?)', $entityIds); - } - + $select = $this->baseFinalPrice->getQuery($websiteId, $customerGroupId, $type, $entityIds); /** * Add additional external limitation */ @@ -461,8 +344,10 @@ protected function getSelect($entityIds = null, $type = null) [ 'select' => $select, 'entity_field' => new \Zend_Db_Expr('e.entity_id'), - 'website_field' => new \Zend_Db_Expr('cw.website_id'), - 'store_field' => new \Zend_Db_Expr('cs.store_id'), + 'website_field' => new \Zend_Db_Expr('pw.website_id'), + 'store_field' => new \Zend_Db_Expr('cs.store_id'), //TODO: use catalog_product_index_website + 'website_id' => $websiteId, + 'customer_group_id' => $customerGroupId, ] ); diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php new file mode 100644 index 0000000000000..3d8a822d5e094 --- /dev/null +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php @@ -0,0 +1,141 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\Query; + +use Magento\Catalog\Model\Product\Attribute\Source\Status; +use Magento\Framework\DB\Select; + +/** + * Prepare base select for Product Price index limited by specified dimensions: website and customer group + */ +class BaseFinalPrice +{ + /** + * @var \Magento\Framework\App\ResourceConnection + */ + private $resource; + + /** + * @var string + */ + private $connectionName; + + /** + * @var JoinAttributeProcessor + */ + private $joinAttributeProcessor; + + /** + * BaseFinalPrice constructor. + * @param \Magento\Framework\App\ResourceConnection $resource + * @param JoinAttributeProcessor $joinAttributeProcessor + * @param string $connectionName + */ + public function __construct( + \Magento\Framework\App\ResourceConnection $resource, + JoinAttributeProcessor $joinAttributeProcessor, + $connectionName = 'indexer' + ) { + $this->resource = $resource; + $this->connectionName = $connectionName; + $this->joinAttributeProcessor = $joinAttributeProcessor; + } + + /** + * @param int $websiteId + * @param int $customerGroupId + * @param string $productType + * @param array $entityIds + * @return Select + * @throws \Magento\Framework\Exception\LocalizedException + * @throws \Zend_Db_Select_Exception + */ + public function getQuery(int $websiteId, int $customerGroupId, string $productType, array $entityIds = []): Select + { + $connection = $this->resource->getConnection($this->connectionName); + + $select = $connection->select()->from( + ['e' => $this->getTable('catalog_product_entity')], + ['entity_id'] + )->joinInner( + ['pw' => $this->getTable('catalog_product_website')], + sprintf('pw.product_id = e.entity_id AND pw.website_id = %s', $websiteId), + [] + )->joinInner( + ['cg' => $this->getTable('customer_group')], + sprintf('cg.customer_group_id = %s', $customerGroupId), + ['customer_group_id'] + )->joinInner( + ['cwd' => $this->getTable('catalog_product_index_website')], //website currency rates + 'pw.website_id = cwd.website_id', + [] + )->joinLeft( + ['tp' => $this->getTable('catalog_product_index_tier_price')], //TODO: alligig with tier price + 'tp.entity_id = e.entity_id AND tp.website_id = pw.website_id' . + ' AND tp.customer_group_id = cg.customer_group_id', + [] + ); + + $this->joinAttributeProcessor->process($select, 'status', Status::STATUS_ENABLED); + + $price = $this->joinAttributeProcessor->process($select, $websiteId, 'price'); + $specialPrice = $this->joinAttributeProcessor->process($select, $websiteId, 'special_price'); + $specialFrom = $this->joinAttributeProcessor->process($select, $websiteId, 'special_from_date'); + $specialTo = $this->joinAttributeProcessor->process($select, $websiteId, 'special_to_date'); + $currentDate = 'cwd.website_date'; + + $maxUnsignedBigint = '~0'; + $specialFromDate = $connection->getDatePartSql($specialFrom); + $specialToDate = $connection->getDatePartSql($specialTo); + $specialFromExpr = "{$specialFrom} IS NULL OR {$specialFromDate} <= {$currentDate}"; + $specialToExpr = "{$specialTo} IS NULL OR {$specialToDate} >= {$currentDate}"; + $specialPriceExpr = $connection->getCheckSql( + "{$specialPrice} IS NOT NULL AND {$specialFromExpr} AND {$specialToExpr}", + $specialPrice, + $maxUnsignedBigint + ); + $tierPrice = new \Zend_Db_Expr('tp.min_price'); + $tierPriceExpr = $connection->getIfNullSql( + $tierPrice, + $maxUnsignedBigint + ); + $finalPrice = $connection->getLeastSql([ + $price, + $specialPriceExpr, + $tierPriceExpr, + ]); + + $select->columns( + [ + 'orig_price' => $connection->getIfNullSql($price, 0), + 'price' => $connection->getIfNullSql($finalPrice, 0), + 'min_price' => $connection->getIfNullSql($finalPrice, 0), + 'max_price' => $connection->getIfNullSql($finalPrice, 0), + 'tier_price' => $tierPrice, + 'base_tier' => $tierPrice, + ] + ); + + $select->where(sprintf("e.type_id = '%s'", $productType)); + + if ($entityIds !== null) { + $select->where(sprintf('e.entity_id BETWEEN %s AND %s', min($entityIds), max($entityIds))); + } + + return $select; + } + + /** + * @param string $tableName + * @return string + */ + private function getTable($tableName) + { + return $this->resource->getTableName($tableName, $this->connectionName); + } +} diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/JoinAttributeProcessor.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/JoinAttributeProcessor.php new file mode 100644 index 0000000000000..7e3d7032002a0 --- /dev/null +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/JoinAttributeProcessor.php @@ -0,0 +1,128 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\Query; + +use Magento\Framework\DB\Select; + +/** + * Allows to join product attribute to Select. Used for build price index for specified dimension, w + */ +class JoinAttributeProcessor +{ + private $defaultStoreId; + + /** + * @var \Magento\Eav\Model\Config + */ + private $eavConfig; + + /** + * @var \Magento\Framework\EntityManager\MetadataPool + */ + private $metadataPool; + + /** + * @var \Magento\Store\Model\StoreManagerInterface + */ + private $storeManager; + + /** + * JoinProcessor constructor. + * @param \Magento\Framework\App\ResourceConnection $resource + * @param \Magento\Eav\Model\Config $eavConfig + * @param \Magento\Framework\Module\Manager $moduleManager + * @param \Magento\Catalog\Helper\Data $dataHelper + * @param \Magento\Framework\EntityManager\MetadataPool $metadataPool + * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param string $connectionName + */ + public function __construct( + \Magento\Eav\Model\Config $eavConfig, + \Magento\Framework\EntityManager\MetadataPool $metadataPool, + \Magento\Store\Model\StoreManagerInterface $storeManager + ) { + $this->eavConfig = $eavConfig; + $this->metadataPool = $metadataPool; + $this->storeManager = $storeManager; + } + + /** + * @param Select $select + * @param int $websiteId + * @param string $attributeCode + * @param string|null $attributeValue + * @return \Zend_Db_Expr + * @throws \Magento\Framework\Exception\LocalizedException + * @throws \Zend_Db_Select_Exception + */ + public function process(Select $select, $websiteId, $attributeCode, $attributeValue = null) + { + $attribute = $this->eavConfig->getAttribute(\Magento\Catalog\Model\Product::ENTITY, $attributeCode); + $attributeId = $attribute->getAttributeId(); + $attributeTable = $attribute->getBackend()->getTable(); + $connection = $this->getConnection(); + $joinType = $attributeValue !== null ? 'join' : 'joinLeft'; + $productIdField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField(); + + if ($attribute->isScopeGlobal()) { + //TODO: refactor global join - move outside if statement + $alias = 'ta_' . $attributeCode; + $select->{$joinType}( + [$alias => $attributeTable], + "{$alias}.{$productIdField} = e.{$productIdField} AND {$alias}.attribute_id = {$attributeId}" . + " AND {$alias}.store_id = 0", + [] + ); + $whereExpression = new \Zend_Db_Expr("{$alias}.value"); + } else { + $storeId = $this->getDefaultStoreForWebsite($websiteId); + $dAlias = 'tad_' . $attributeCode; + $sAlias = 'tas_' . $attributeCode; + + $select->{$joinType}( + [$dAlias => $attributeTable], + "{$dAlias}.{$productIdField} = e.{$productIdField} AND {$dAlias}.attribute_id = {$attributeId}" . + " AND {$dAlias}.store_id = 0", + [] + ); + $select->joinLeft( + [$sAlias => $attributeTable], + "{$sAlias}.{$productIdField} = e.{$productIdField} AND {$sAlias}.attribute_id = {$attributeId}" . + " AND {$sAlias}.store_id = {$storeId}", + [] + ); + $whereExpression = $connection->getCheckSql( + $connection->getIfNullSql("{$sAlias}.value_id", -1) . ' > 0', + "{$sAlias}.value", + "{$dAlias}.value" + ); + } + + if ($attributeValue !== null) { + $select->where("{$whereExpression} = ?", $attributeValue); + } + + return $whereExpression; + } + + /** + * @param $websiteId + * @return int + * @throws \Magento\Framework\Exception\LocalizedException + */ + private function getDefaultStoreForWebsite($websiteId): int + { + if (!isset($this->defaultStoreId[$websiteId])) { + $website = $this->storeManager->getWebsite($websiteId); + $defaultGroup = $website->getDefaultGroup(); + $this->defaultStoreId[$websiteId] = (int) $defaultGroup->getDefaultStoreId(); + } + + return $this->defaultStoreId[$websiteId]; + } +} diff --git a/app/code/Magento/Tax/Plugin/Product/Indexer/Price/Query/AddTaxId.php b/app/code/Magento/Tax/Plugin/Product/Indexer/Price/Query/AddTaxId.php new file mode 100644 index 0000000000000..9d5efefd67a34 --- /dev/null +++ b/app/code/Magento/Tax/Plugin/Product/Indexer/Price/Query/AddTaxId.php @@ -0,0 +1,48 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Tax\Plugin\Product\Indexer\Price\Query; + +use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\Query\BaseFinalPrice; +use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\Query\JoinAttributeProcessor; +use Magento\Framework\DB\Select; + +/** + * Add tax_class_id column to price index select + */ +class AddTaxId +{ + /** + * @var JoinAttributeProcessor + */ + private $joinAttributeProcessor; + + /** + * @param JoinAttributeProcessor $joinAttributeProcessor + */ + public function __construct(JoinAttributeProcessor $joinAttributeProcessor) + { + $this->joinAttributeProcessor = $joinAttributeProcessor; + } + + /** + * @param BaseFinalPrice $subject + * @param Select $select + * @param int $websiteId + * @return Select + * @throws \Magento\Framework\Exception\LocalizedException + * @throws \Zend_Db_Select_Exception + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function afterGetQuery(BaseFinalPrice $subject, Select $select, int $websiteId): Select + { + $taxClassId = $this->joinAttributeProcessor->process($select, $websiteId, 'tax_class_id'); + $select->columns(['tax_class_id' => $taxClassId]); + + return $select; + } +} diff --git a/app/code/Magento/Tax/etc/di.xml b/app/code/Magento/Tax/etc/di.xml index 096f8359fadd3..3e29f7981bc50 100644 --- a/app/code/Magento/Tax/etc/di.xml +++ b/app/code/Magento/Tax/etc/di.xml @@ -181,4 +181,7 @@ <type name="Magento\Catalog\Ui\DataProvider\Product\Listing\DataProvider"> <plugin name="taxSettingsProvider" type="Magento\Tax\Plugin\Ui\DataProvider\TaxSettings"/> </type> + <type name="Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\Query\BaseFinalPrice"> + <plugin name="add_tax_id_to_price_index_select" type="Magento\Tax\Plugin\Product\Indexer\Price\Query\AddTaxId"/> + </type> </config> From 74cf7d8be9bcc78ea2f3a809560bd65c56f67ab4 Mon Sep 17 00:00:00 2001 From: Andrii Voskoboinikov <avoskoboinikov@magento.com> Date: Thu, 24 May 2018 16:16:06 +0300 Subject: [PATCH 039/206] MAGETWO-91874: Adapt Full Action to use dimension --- .../Indexer/Product/Price/Action/Full.php | 4 +-- .../Price/DimensionCollectionFactory.php | 30 ++++++++++++------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php index 54487f32d7e75..8294897760dbe 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php @@ -120,8 +120,8 @@ public function __construct( \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer::class ); - $this->allDimensionCollection = $dimensionCollectionFactory->createWithAllDimensions(); - $this->modeDimensionCollection = $dimensionCollectionFactory->create(); + $this->allDimensionCollection = $dimensionCollectionFactory->createByAllDimensions(); + $this->modeDimensionCollection = $dimensionCollectionFactory->createByCurrentMode(); } /** diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionCollectionFactory.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionCollectionFactory.php index 556e6348a5097..d646bef55159d 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionCollectionFactory.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionCollectionFactory.php @@ -40,8 +40,7 @@ public function __construct( \Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProviderFactory $customerGroupDataProviderFactory, \Magento\Framework\Indexer\DimensionCollectionFactory $generalDimensionCollectionFactory, \Magento\Framework\App\Config\ScopeConfigInterface $configReader - ) - { + ) { $this->websiteDataProviderFactory = $websiteDataProviderFactory; $this->customerGroupDataProviderFactory = $customerGroupDataProviderFactory; $this->generalDimensionCollectionFactory = $generalDimensionCollectionFactory; @@ -51,11 +50,22 @@ public function __construct( /** * @return Dimension[] */ - public function create() + public function createByCurrentMode() + { + $dbMode = $this->configReader->getValue(ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE); + + return $this->generalDimensionCollectionFactory->create( + [ + 'dimensionDataProviders' => $this->getDataProviders($dbMode) + ] + ); + } + + public function createByMode(string $mode) { return $this->generalDimensionCollectionFactory->create( [ - 'dimensionDataProviders' => $this->getDataProviders() + 'dimensionDataProviders' => $this->getDataProviders($mode) ] ); } @@ -63,22 +73,20 @@ public function create() /** * @return Dimension[] */ - public function createWithAllDimensions() + public function createByAllDimensions() { return $this->generalDimensionCollectionFactory->create( [ - 'dimensionDataProviders' => [ - $this->websiteDataProviderFactory->create(), - $this->customerGroupDataProviderFactory->create() - ] + 'dimensionDataProviders' => $this->getDataProviders( + ModeSwitcher::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP + ) ] ); } - private function getDataProviders() + private function getDataProviders($dimensionsMode) { $providers = []; - $dimensionsMode = $this->configReader->getValue(ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE); switch ($dimensionsMode) { case null: From dfb4ad3fccc18247d631e5d33c10daaccdb394a2 Mon Sep 17 00:00:00 2001 From: Andrii Voskoboinikov <avoskoboinikov@magento.com> Date: Thu, 24 May 2018 18:25:15 +0300 Subject: [PATCH 040/206] MAGETWO-91874: Adapt Full Action to use dimension --- .../MultiDimensional/CustomerGroupDataProvider.php | 5 +++++ .../MultiDimensional/WebsiteDataProvider.php | 5 +++++ .../Framework/Indexer/DimensionCollection.php | 13 ++++++++++++- .../Indexer/DimensionProviderInterface.php | 2 +- 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php b/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php index cca653f33136a..44c7cdaafbe7a 100644 --- a/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php +++ b/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php @@ -41,4 +41,9 @@ public function getIterator(): \Traversable yield $this->dimensionFactory->create(self::DIMENSION_NAME, $customerGroup); } } + + public function count(): int + { + return $this->customerGroupsDataIterator->count(); + } } diff --git a/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php b/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php index 74be6206748bb..6fdc3132be957 100644 --- a/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php +++ b/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php @@ -45,4 +45,9 @@ public function getIterator(): \Traversable yield $this->dimensionFactory->create(self::DIMENSION_NAME, $website); } } + + public function count(): int + { + return $this->websitesDataIterator->count(); + } } diff --git a/lib/internal/Magento/Framework/Indexer/DimensionCollection.php b/lib/internal/Magento/Framework/Indexer/DimensionCollection.php index a39257dd5a61d..3c5c519da267a 100644 --- a/lib/internal/Magento/Framework/Indexer/DimensionCollection.php +++ b/lib/internal/Magento/Framework/Indexer/DimensionCollection.php @@ -6,7 +6,7 @@ namespace Magento\Framework\Indexer; -class DimensionCollection implements \Iterator +class DimensionCollection implements \Iterator, \Countable { /** * @var array @@ -83,6 +83,17 @@ public function rewind() } } + public function count() + { + $counts = []; + + foreach ($this->dimensionsDataProviders as $dimensionsDataProvider) { + $counts[] = count($dimensionsDataProvider); + } + + return array_product($counts); + } + private function addDimensionDataProvider(DimensionProviderInterface $dimensionDataProvider) { $this->dimensionsDataProviders[] = $dimensionDataProvider; diff --git a/lib/internal/Magento/Framework/Indexer/DimensionProviderInterface.php b/lib/internal/Magento/Framework/Indexer/DimensionProviderInterface.php index ed3615e0e14d3..7797009905161 100644 --- a/lib/internal/Magento/Framework/Indexer/DimensionProviderInterface.php +++ b/lib/internal/Magento/Framework/Indexer/DimensionProviderInterface.php @@ -7,7 +7,7 @@ namespace Magento\Framework\Indexer; -interface DimensionProviderInterface extends \IteratorAggregate +interface DimensionProviderInterface extends \IteratorAggregate, \Countable { /** * Get Dimension Iterator. Returns yielded value of \Magento\Framework\Indexer\Dimension From 6fc724b7d88d83c211dfa1e9aa07947571e2d473 Mon Sep 17 00:00:00 2001 From: Andrii Voskoboinikov <avoskoboinikov@magento.com> Date: Thu, 24 May 2018 18:27:25 +0300 Subject: [PATCH 041/206] MAGETWO-91874: Adapt Full Action to use dimension --- .../Indexer/DimensionalIndexerInterface.php | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 lib/internal/Magento/Framework/Indexer/DimensionalIndexerInterface.php diff --git a/lib/internal/Magento/Framework/Indexer/DimensionalIndexerInterface.php b/lib/internal/Magento/Framework/Indexer/DimensionalIndexerInterface.php new file mode 100644 index 0000000000000..b8a345c2d6cf9 --- /dev/null +++ b/lib/internal/Magento/Framework/Indexer/DimensionalIndexerInterface.php @@ -0,0 +1,25 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Framework\Indexer\Dimension; + +/** + * @api + * Run indexer by specific dimension + */ +interface DimensionalIndexerInterface +{ + /** + * Execute indexer by specified dimension. + * Accept array of dimensions DTO that represent indexer dimension + * + * @param \Magento\Framework\Indexer\Dimension[] $dimension + * @param array|null $entityIds + * @return void + */ + public function executeByDimension(array $dimension, array $entityIds = null); +} \ No newline at end of file From d2aa2314b07dffdfa194ac14d29de1cd0266f346 Mon Sep 17 00:00:00 2001 From: Andrii Voskoboinikov <avoskoboinikov@magento.com> Date: Thu, 24 May 2018 18:30:33 +0300 Subject: [PATCH 042/206] MAGETWO-91874: Adapt Full Action to use dimension --- .../Model/Indexer/Product/Price/Action/Full.php | 6 +++--- .../Price/MultiDimensionalIndexerInterface.php | 13 ------------- 2 files changed, 3 insertions(+), 16 deletions(-) delete mode 100644 app/code/Magento/Catalog/Model/Indexer/Product/Price/MultiDimensionalIndexerInterface.php diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php index 8294897760dbe..ae37fdddac2b8 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php @@ -9,8 +9,8 @@ use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\PriceInterface; use Magento\Framework\EntityManager\EntityMetadataInterface; use Magento\Catalog\Api\Data\ProductInterface; -use \Magento\Framework\Exception\LocalizedException; -use Magento\Catalog\Model\Indexer\Product\Price\MultiDimensionalIndexerInterface; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Indexer\Dimension\DimensionalIndexerInterface; /** * Class Full reindex action @@ -141,7 +141,7 @@ public function execute($ids = null) foreach ($this->getTypeIndexers() as $priceIndexer) { $priceIndexer->getTableStrategy()->setUseIdxTable(false); - if ($priceIndexer instanceof MultiDimensionalIndexerInterface) { + if ($priceIndexer instanceof DimensionalIndexerInterface) { $this->reindexProductTypeWithDimensions($priceIndexer); continue; } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/MultiDimensionalIndexerInterface.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/MultiDimensionalIndexerInterface.php deleted file mode 100644 index 233984cd75595..0000000000000 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/MultiDimensionalIndexerInterface.php +++ /dev/null @@ -1,13 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Catalog\Model\Indexer\Product\Price; - -interface MultiDimensionalIndexerInterface -{ - public function reindexAllWithinDimensions(array $dimensions); - public function reindexEntityWithinDimensions(array $entityIds, array $dimensions); -} From be24b4e3fb8b4ee3b480f6c8175106d2de2e22b8 Mon Sep 17 00:00:00 2001 From: Andrii Voskoboinikov <avoskoboinikov@magento.com> Date: Thu, 24 May 2018 19:27:30 +0300 Subject: [PATCH 043/206] MAGETWO-91874: Adapt Full Action to use dimension --- .../Framework/Indexer/DimensionalIndexerInterface.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/internal/Magento/Framework/Indexer/DimensionalIndexerInterface.php b/lib/internal/Magento/Framework/Indexer/DimensionalIndexerInterface.php index b8a345c2d6cf9..73c48773d978a 100644 --- a/lib/internal/Magento/Framework/Indexer/DimensionalIndexerInterface.php +++ b/lib/internal/Magento/Framework/Indexer/DimensionalIndexerInterface.php @@ -9,7 +9,7 @@ /** * @api - * Run indexer by specific dimension + * Run indexer by dimensions */ interface DimensionalIndexerInterface { @@ -17,9 +17,9 @@ interface DimensionalIndexerInterface * Execute indexer by specified dimension. * Accept array of dimensions DTO that represent indexer dimension * - * @param \Magento\Framework\Indexer\Dimension[] $dimension + * @param \Magento\Framework\Indexer\Dimension[] $dimensions * @param array|null $entityIds * @return void */ - public function executeByDimension(array $dimension, array $entityIds = null); + public function reindexByDimensions(array $dimensions, array $entityIds = null); } \ No newline at end of file From 7b4bd0a1e92f908699f4bd5a4181ebd06a7d0701 Mon Sep 17 00:00:00 2001 From: Michail Slabko <mslabko@magento.com> Date: Thu, 24 May 2018 20:46:13 +0300 Subject: [PATCH 044/206] MAGETWO-91876: Adapt base select to use dimensions --- .../Product/Indexer/Price/DefaultPrice.php | 30 +++++++++--- .../Indexer/Price/Query/BaseFinalPrice.php | 27 ++++++++--- .../Price/Query/JoinAttributeProcessor.php | 19 +++++++- .../MultiDimensional/WebsiteDataProvider.php | 20 ++++---- .../Product/Indexer/Price/Query/AddTaxId.php | 48 ------------------- app/code/Magento/Tax/etc/di.xml | 3 -- 6 files changed, 70 insertions(+), 77 deletions(-) delete mode 100644 app/code/Magento/Tax/Plugin/Product/Indexer/Price/Query/AddTaxId.php diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php index 9c1578205152d..15f26b279c349 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php @@ -5,10 +5,12 @@ */ namespace Magento\Catalog\Model\ResourceModel\Product\Indexer\Price; +use Magento\Catalog\Model\Indexer\Product\Price\DimensionCollectionFactory; use Magento\Catalog\Model\ResourceModel\Product\Indexer\AbstractIndexer; use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\Query\BaseFinalPrice; +use Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProvider; use Magento\Framework\App\ObjectManager; -use Magento\Framework\Backup\BackupException; +use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; /** * Default Product Type Price Indexer Resource model @@ -70,6 +72,11 @@ class DefaultPrice extends AbstractIndexer implements PriceInterface */ private $baseFinalPrice; + /** + * @var DimensionCollectionFactory + */ + private $dimensionCollectionFactory; + /** * @param \Magento\Framework\Model\ResourceModel\Db\Context $context * @param \Magento\Framework\Indexer\Table\StrategyInterface $tableStrategy @@ -89,6 +96,7 @@ public function __construct( $connectionName = null, IndexTableStructureFactory $indexTableStructureFactory = null, BaseFinalPrice $baseFinalPrice = null, + DimensionCollectionFactory $dimensionCollectionFactory = null, array $priceModifiers = [] ) { $this->_eventManager = $eventManager; @@ -106,7 +114,9 @@ public function __construct( $this->priceModifiers[] = $priceModifier; } - $this->baseFinalPrice = $baseFinalPrice ?? ObjectManager::getInstance()->get(BackupException::class); + $this->baseFinalPrice = $baseFinalPrice ?? ObjectManager::getInstance()->get(BaseFinalPrice::class); + $this->dimensionCollectionFactory = $dimensionCollectionFactory + ?? ObjectManager::getInstance()->get(DimensionCollectionFactory::class); } /** @@ -311,11 +321,17 @@ protected function prepareFinalPriceDataForType($entityIds, $type) { $finalPriceTable = $this->prepareFinalPriceTable(); - //TODO: use DimensionProvider foreach instead hard-coded values - $select = $this->getSelect($entityIds, $type, 1, 1); - $query = $select->insertFromSelect($finalPriceTable->getTableName(), [], false); - $this->getConnection()->query($query); - + $dimensions = $this->dimensionCollectionFactory->createWithAllDimensions(); + foreach ($dimensions as $dimension) { + $select = $this->getSelect( + $entityIds, + $type, + $dimension[WebsiteDataProvider::DIMENSION_NAME]->getValue(), + $dimension[CustomerGroupDataProvider::DIMENSION_NAME]->getValue() + ); + $query = $select->insertFromSelect($finalPriceTable->getTableName(), [], false); + $this->getConnection()->query($query); + } $this->applyDiscountPrices($finalPriceTable); return $this; diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php index 3d8a822d5e094..e495afc5eeccf 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php @@ -30,20 +30,28 @@ class BaseFinalPrice */ private $joinAttributeProcessor; + /** + * @var \Magento\Framework\Module\Manager + */ + private $moduleManager; + /** * BaseFinalPrice constructor. * @param \Magento\Framework\App\ResourceConnection $resource * @param JoinAttributeProcessor $joinAttributeProcessor + * @param \Magento\Framework\Module\Manager $moduleManager * @param string $connectionName */ public function __construct( \Magento\Framework\App\ResourceConnection $resource, JoinAttributeProcessor $joinAttributeProcessor, + \Magento\Framework\Module\Manager $moduleManager, $connectionName = 'indexer' ) { $this->resource = $resource; $this->connectionName = $connectionName; $this->joinAttributeProcessor = $joinAttributeProcessor; + $this->moduleManager = $moduleManager; } /** @@ -62,16 +70,16 @@ public function getQuery(int $websiteId, int $customerGroupId, string $productTy $select = $connection->select()->from( ['e' => $this->getTable('catalog_product_entity')], ['entity_id'] - )->joinInner( - ['pw' => $this->getTable('catalog_product_website')], - sprintf('pw.product_id = e.entity_id AND pw.website_id = %s', $websiteId), - [] )->joinInner( ['cg' => $this->getTable('customer_group')], sprintf('cg.customer_group_id = %s', $customerGroupId), ['customer_group_id'] )->joinInner( - ['cwd' => $this->getTable('catalog_product_index_website')], //website currency rates + ['pw' => $this->getTable('catalog_product_website')], + sprintf('pw.product_id = e.entity_id AND pw.website_id = %s', $websiteId), + ['pw.website_id'] + )->joinInner( + ['cwd' => $this->getTable('catalog_product_index_website')], // website currency rates 'pw.website_id = cwd.website_id', [] )->joinLeft( @@ -81,7 +89,14 @@ public function getQuery(int $websiteId, int $customerGroupId, string $productTy [] ); - $this->joinAttributeProcessor->process($select, 'status', Status::STATUS_ENABLED); + if ($this->moduleManager->isEnabled('Magento_Tax')) { + $taxClassId = $this->joinAttributeProcessor->process($select, $websiteId,'tax_class_id'); + } else { + $taxClassId = new \Zend_Db_Expr(0); + } + $select->columns(['tax_class_id' => $taxClassId]); + + $this->joinAttributeProcessor->process($select, $websiteId, 'status', Status::STATUS_ENABLED); $price = $this->joinAttributeProcessor->process($select, $websiteId, 'price'); $specialPrice = $this->joinAttributeProcessor->process($select, $websiteId, 'special_price'); diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/JoinAttributeProcessor.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/JoinAttributeProcessor.php index 7e3d7032002a0..e42a4f8a84dbb 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/JoinAttributeProcessor.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/JoinAttributeProcessor.php @@ -7,6 +7,7 @@ namespace Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\Query; +use Magento\Catalog\Api\Data\ProductInterface; use Magento\Framework\DB\Select; /** @@ -31,6 +32,16 @@ class JoinAttributeProcessor */ private $storeManager; + /** + * @var \Magento\Framework\App\ResourceConnection + */ + private $resource; + + /** + * @var string + */ + private $connectionName; + /** * JoinProcessor constructor. * @param \Magento\Framework\App\ResourceConnection $resource @@ -44,11 +55,15 @@ class JoinAttributeProcessor public function __construct( \Magento\Eav\Model\Config $eavConfig, \Magento\Framework\EntityManager\MetadataPool $metadataPool, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\App\ResourceConnection $resource, + $connectionName = 'indexer' ) { $this->eavConfig = $eavConfig; $this->metadataPool = $metadataPool; $this->storeManager = $storeManager; + $this->resource = $resource; + $this->connectionName = $connectionName; } /** @@ -65,7 +80,7 @@ public function process(Select $select, $websiteId, $attributeCode, $attributeVa $attribute = $this->eavConfig->getAttribute(\Magento\Catalog\Model\Product::ENTITY, $attributeCode); $attributeId = $attribute->getAttributeId(); $attributeTable = $attribute->getBackend()->getTable(); - $connection = $this->getConnection(); + $connection = $this->resource->getConnection($this->connectionName); $joinType = $attributeValue !== null ? 'join' : 'joinLeft'; $productIdField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField(); diff --git a/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php b/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php index 6fdc3132be957..6344be3a19542 100644 --- a/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php +++ b/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php @@ -19,30 +19,28 @@ class WebsiteDataProvider implements DimensionProviderInterface const DIMENSION_NAME = 'ws'; /** - * @var \SplFixedArray + * @var DimensionFactory */ - private $websitesDataIterator; + private $dimensionFactory; /** - * @var DimensionFactory + * @var \Magento\Store\Model\StoreManagerInterface */ - private $dimensionFactory; + private $storeManager; /** - * @param WebsiteCollectionFactory $collectionFactory + * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param DimensionFactory $dimensionFactory */ - public function __construct(WebsiteCollectionFactory $collectionFactory, DimensionFactory $dimensionFactory){ + public function __construct(\Magento\Store\Model\StoreManagerInterface $storeManager, DimensionFactory $dimensionFactory){ $this->dimensionFactory = $dimensionFactory; - $this->websitesDataIterator = \SplFixedArray::fromArray( - $collectionFactory->create()->getAllIds() - ); + $this->storeManager = $storeManager; } public function getIterator(): \Traversable { - foreach ($this->websitesDataIterator as $website) { - yield $this->dimensionFactory->create(self::DIMENSION_NAME, $website); + foreach ($this->storeManager->getWebsites(false) as $website) { + yield $this->dimensionFactory->create(self::DIMENSION_NAME, $website->getId()); } } diff --git a/app/code/Magento/Tax/Plugin/Product/Indexer/Price/Query/AddTaxId.php b/app/code/Magento/Tax/Plugin/Product/Indexer/Price/Query/AddTaxId.php deleted file mode 100644 index 9d5efefd67a34..0000000000000 --- a/app/code/Magento/Tax/Plugin/Product/Indexer/Price/Query/AddTaxId.php +++ /dev/null @@ -1,48 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -declare(strict_types=1); - -namespace Magento\Tax\Plugin\Product\Indexer\Price\Query; - -use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\Query\BaseFinalPrice; -use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\Query\JoinAttributeProcessor; -use Magento\Framework\DB\Select; - -/** - * Add tax_class_id column to price index select - */ -class AddTaxId -{ - /** - * @var JoinAttributeProcessor - */ - private $joinAttributeProcessor; - - /** - * @param JoinAttributeProcessor $joinAttributeProcessor - */ - public function __construct(JoinAttributeProcessor $joinAttributeProcessor) - { - $this->joinAttributeProcessor = $joinAttributeProcessor; - } - - /** - * @param BaseFinalPrice $subject - * @param Select $select - * @param int $websiteId - * @return Select - * @throws \Magento\Framework\Exception\LocalizedException - * @throws \Zend_Db_Select_Exception - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - public function afterGetQuery(BaseFinalPrice $subject, Select $select, int $websiteId): Select - { - $taxClassId = $this->joinAttributeProcessor->process($select, $websiteId, 'tax_class_id'); - $select->columns(['tax_class_id' => $taxClassId]); - - return $select; - } -} diff --git a/app/code/Magento/Tax/etc/di.xml b/app/code/Magento/Tax/etc/di.xml index 3e29f7981bc50..096f8359fadd3 100644 --- a/app/code/Magento/Tax/etc/di.xml +++ b/app/code/Magento/Tax/etc/di.xml @@ -181,7 +181,4 @@ <type name="Magento\Catalog\Ui\DataProvider\Product\Listing\DataProvider"> <plugin name="taxSettingsProvider" type="Magento\Tax\Plugin\Ui\DataProvider\TaxSettings"/> </type> - <type name="Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\Query\BaseFinalPrice"> - <plugin name="add_tax_id_to_price_index_select" type="Magento\Tax\Plugin\Product\Indexer\Price\Query\AddTaxId"/> - </type> </config> From abdb38eae8e9f4f1fdeb23c284a386fe8b8288b1 Mon Sep 17 00:00:00 2001 From: Andrii Voskoboinikov <avoskoboinikov@magento.com> Date: Fri, 25 May 2018 10:16:21 +0300 Subject: [PATCH 045/206] MAGETWO-91874: Adapt Full Action to use dimension --- .../Magento/Framework/Indexer/DimensionalIndexerInterface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/Indexer/DimensionalIndexerInterface.php b/lib/internal/Magento/Framework/Indexer/DimensionalIndexerInterface.php index 73c48773d978a..7a0ad1e8143d3 100644 --- a/lib/internal/Magento/Framework/Indexer/DimensionalIndexerInterface.php +++ b/lib/internal/Magento/Framework/Indexer/DimensionalIndexerInterface.php @@ -5,7 +5,7 @@ */ declare(strict_types=1); -namespace Magento\Framework\Indexer\Dimension; +namespace Magento\Framework\Indexer; /** * @api From 7a1a506ae436d2729e79d6b5e633b65a7189005a Mon Sep 17 00:00:00 2001 From: Andrii Voskoboinikov <avoskoboinikov@magento.com> Date: Fri, 25 May 2018 10:35:01 +0300 Subject: [PATCH 046/206] MAGETWO-91874: Adapt Full Action to use dimension --- .../Catalog/Model/Indexer/Product/Price/Action/Full.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php index ae37fdddac2b8..c709431c1fd91 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php @@ -10,7 +10,7 @@ use Magento\Framework\EntityManager\EntityMetadataInterface; use Magento\Catalog\Api\Data\ProductInterface; use Magento\Framework\Exception\LocalizedException; -use Magento\Framework\Indexer\Dimension\DimensionalIndexerInterface; +use Magento\Framework\Indexer\DimensionalIndexerInterface; /** * Class Full reindex action @@ -237,13 +237,14 @@ private function reindexBatch(PriceInterface $priceIndexer, array $batch) } } - private function reindexBatchWithinDimension(PriceInterface $priceIndexer, array $batch, array $dimensions) + private function reindexBatchWithinDimension(DimensionalIndexerInterface $priceIndexer, array $batch, array $dimensions) { $entityIds = $this->getEntityIdsFromBatch($priceIndexer, $batch); if (!empty($entityIds)) { // Temporary table will created if not exists - $idxTableName = $this->_defaultIndexerResource->getIdxTableWithinDimension(); +// $idxTableName = $this->_defaultIndexerResource->getIdxTableWithinDimension($dimensions); + $idxTableName = $this->_defaultIndexerResource->getIdxTable(); # TODO: replace with appropriate method according to dimension $this->_emptyTable($idxTableName); if ($priceIndexer->getIsComposite()) { @@ -251,7 +252,7 @@ private function reindexBatchWithinDimension(PriceInterface $priceIndexer, array } $this->_prepareTierPriceIndex($entityIds); - $priceIndexer->reindexEntityWithinDimension($entityIds, $dimensions); + $priceIndexer->reindexByDimensions($entityIds, $dimensions); // Sync data from temp table to index table $this->_insertFromTable($idxTableName, $this->dimensionTableMaintainer->getMainReplicaTable($dimensions)); From 52a36fa00469911310a9f5ccc1823e69c2bbe4c4 Mon Sep 17 00:00:00 2001 From: Michail Slabko <mslabko@magento.com> Date: Fri, 25 May 2018 11:26:48 +0300 Subject: [PATCH 047/206] MAGETWO-91876: Adapt base select to use dimensions --- .../Indexer/Product/Price/AbstractAction.php | 1 + .../Product/Indexer/Price/DefaultPrice.php | 4 +-- .../Indexer/Price/Query/BaseFinalPrice.php | 14 +++++------ .../Price/Query/JoinAttributeProcessor.php | 25 +++---------------- .../Magento/Catalog/Setup/UpgradeSchema.php | 20 +++++++++++++++ app/code/Magento/Catalog/etc/module.xml | 2 +- 6 files changed, 34 insertions(+), 32 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php index 7aed842713f5d..4ff611aae9829 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php @@ -199,6 +199,7 @@ protected function _prepareWebsiteDateTable() 'website_id' => $website->getId(), 'website_date' => $this->_dateTime->formatDate($timestamp, false), 'rate' => $rate, + 'default_store_id' => $store->getId() ]; } } diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php index 15f26b279c349..cf0b237f8a0ed 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php @@ -321,7 +321,7 @@ protected function prepareFinalPriceDataForType($entityIds, $type) { $finalPriceTable = $this->prepareFinalPriceTable(); - $dimensions = $this->dimensionCollectionFactory->createWithAllDimensions(); + $dimensions = $this->dimensionCollectionFactory->createByAllDimensions(); foreach ($dimensions as $dimension) { $select = $this->getSelect( $entityIds, @@ -361,7 +361,7 @@ protected function getSelect($entityIds = null, $type = null, int $websiteId = n 'select' => $select, 'entity_field' => new \Zend_Db_Expr('e.entity_id'), 'website_field' => new \Zend_Db_Expr('pw.website_id'), - 'store_field' => new \Zend_Db_Expr('cs.store_id'), //TODO: use catalog_product_index_website + 'store_field' => new \Zend_Db_Expr('cwd.default_store_id'), 'website_id' => $websiteId, 'customer_group_id' => $customerGroupId, ] diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php index e495afc5eeccf..8bd77c644fa4b 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php @@ -79,7 +79,7 @@ public function getQuery(int $websiteId, int $customerGroupId, string $productTy sprintf('pw.product_id = e.entity_id AND pw.website_id = %s', $websiteId), ['pw.website_id'] )->joinInner( - ['cwd' => $this->getTable('catalog_product_index_website')], // website currency rates + ['cwd' => $this->getTable('catalog_product_index_website')], 'pw.website_id = cwd.website_id', [] )->joinLeft( @@ -90,18 +90,18 @@ public function getQuery(int $websiteId, int $customerGroupId, string $productTy ); if ($this->moduleManager->isEnabled('Magento_Tax')) { - $taxClassId = $this->joinAttributeProcessor->process($select, $websiteId,'tax_class_id'); + $taxClassId = $this->joinAttributeProcessor->process($select,'tax_class_id'); } else { $taxClassId = new \Zend_Db_Expr(0); } $select->columns(['tax_class_id' => $taxClassId]); - $this->joinAttributeProcessor->process($select, $websiteId, 'status', Status::STATUS_ENABLED); + $this->joinAttributeProcessor->process($select, 'status', Status::STATUS_ENABLED); - $price = $this->joinAttributeProcessor->process($select, $websiteId, 'price'); - $specialPrice = $this->joinAttributeProcessor->process($select, $websiteId, 'special_price'); - $specialFrom = $this->joinAttributeProcessor->process($select, $websiteId, 'special_from_date'); - $specialTo = $this->joinAttributeProcessor->process($select, $websiteId, 'special_to_date'); + $price = $this->joinAttributeProcessor->process($select, 'price'); + $specialPrice = $this->joinAttributeProcessor->process($select, 'special_price'); + $specialFrom = $this->joinAttributeProcessor->process($select, 'special_from_date'); + $specialTo = $this->joinAttributeProcessor->process($select, 'special_to_date'); $currentDate = 'cwd.website_date'; $maxUnsignedBigint = '~0'; diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/JoinAttributeProcessor.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/JoinAttributeProcessor.php index e42a4f8a84dbb..0caf13281cacb 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/JoinAttributeProcessor.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/JoinAttributeProcessor.php @@ -11,12 +11,10 @@ use Magento\Framework\DB\Select; /** - * Allows to join product attribute to Select. Used for build price index for specified dimension, w + * Allows to join product attribute to Select. Used for build price index for specified dimension */ class JoinAttributeProcessor { - private $defaultStoreId; - /** * @var \Magento\Eav\Model\Config */ @@ -75,7 +73,7 @@ public function __construct( * @throws \Magento\Framework\Exception\LocalizedException * @throws \Zend_Db_Select_Exception */ - public function process(Select $select, $websiteId, $attributeCode, $attributeValue = null) + public function process(Select $select, $attributeCode, $attributeValue = null) { $attribute = $this->eavConfig->getAttribute(\Magento\Catalog\Model\Product::ENTITY, $attributeCode); $attributeId = $attribute->getAttributeId(); @@ -95,7 +93,6 @@ public function process(Select $select, $websiteId, $attributeCode, $attributeVa ); $whereExpression = new \Zend_Db_Expr("{$alias}.value"); } else { - $storeId = $this->getDefaultStoreForWebsite($websiteId); $dAlias = 'tad_' . $attributeCode; $sAlias = 'tas_' . $attributeCode; @@ -108,7 +105,7 @@ public function process(Select $select, $websiteId, $attributeCode, $attributeVa $select->joinLeft( [$sAlias => $attributeTable], "{$sAlias}.{$productIdField} = e.{$productIdField} AND {$sAlias}.attribute_id = {$attributeId}" . - " AND {$sAlias}.store_id = {$storeId}", + " AND {$sAlias}.store_id = cwd.default_store_id", [] ); $whereExpression = $connection->getCheckSql( @@ -124,20 +121,4 @@ public function process(Select $select, $websiteId, $attributeCode, $attributeVa return $whereExpression; } - - /** - * @param $websiteId - * @return int - * @throws \Magento\Framework\Exception\LocalizedException - */ - private function getDefaultStoreForWebsite($websiteId): int - { - if (!isset($this->defaultStoreId[$websiteId])) { - $website = $this->storeManager->getWebsite($websiteId); - $defaultGroup = $website->getDefaultGroup(); - $this->defaultStoreId[$websiteId] = (int) $defaultGroup->getDefaultStoreId(); - } - - return $this->defaultStoreId[$websiteId]; - } } diff --git a/app/code/Magento/Catalog/Setup/UpgradeSchema.php b/app/code/Magento/Catalog/Setup/UpgradeSchema.php index 1ccfd7c243320..7776cf24995ce 100755 --- a/app/code/Magento/Catalog/Setup/UpgradeSchema.php +++ b/app/code/Magento/Catalog/Setup/UpgradeSchema.php @@ -142,6 +142,10 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con $this->enableSegmentation($setup); } + if (version_compare($context->getVersion(), '2.2.6', '<')) { + $this->addStoreIdFieldForWebsiteIndexTable($setup); + } + $setup->endSetup(); } @@ -799,4 +803,20 @@ private function enableSegmentation(SchemaSetupInterface $setup) ); } } + + /** + * @param SchemaSetupInterface $setup + */ + private function addStoreIdFieldForWebsiteIndexTable(SchemaSetupInterface $setup) + { + $setup->getConnection()->addColumn( + $setup->getTable('catalog_product_index_website'), + 'default_store_id', + [ + 'type' => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, + 'nullable' => false, + 'comment' => 'Default store id for website ' + ] + ); + } } diff --git a/app/code/Magento/Catalog/etc/module.xml b/app/code/Magento/Catalog/etc/module.xml index cb27a54c2b58b..23e130aa8a991 100644 --- a/app/code/Magento/Catalog/etc/module.xml +++ b/app/code/Magento/Catalog/etc/module.xml @@ -6,7 +6,7 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> - <module name="Magento_Catalog" setup_version="2.2.5"> + <module name="Magento_Catalog" setup_version="2.2.6"> <sequence> <module name="Magento_Eav"/> <module name="Magento_Cms"/> From a6124b72c29e3a48e56c605d9968aa43763a4d3d Mon Sep 17 00:00:00 2001 From: Andrii Voskoboinikov <avoskoboinikov@magento.com> Date: Fri, 25 May 2018 12:36:48 +0300 Subject: [PATCH 048/206] MAGETWO-91874: Adapt Full Action to use dimension --- .../CustomerGroupDataProvider.php | 27 +++++++++--- .../MultiDimensional/WebsiteDataProvider.php | 42 ++++++++++++++----- .../Framework/Indexer/DimensionCollection.php | 25 +++++++---- 3 files changed, 71 insertions(+), 23 deletions(-) diff --git a/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php b/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php index 44c7cdaafbe7a..24f7c9c17bea5 100644 --- a/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php +++ b/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php @@ -18,6 +18,11 @@ class CustomerGroupDataProvider implements DimensionProviderInterface */ const DIMENSION_NAME = 'cg'; + /** + * @var CustomerGroupCollectionFactory + */ + private $collectionFactory; + /** * @var \SplFixedArray */ @@ -30,20 +35,32 @@ class CustomerGroupDataProvider implements DimensionProviderInterface public function __construct(CustomerGroupCollectionFactory $collectionFactory, DimensionFactory $dimensionFactory) { $this->dimensionFactory = $dimensionFactory; - $this->customerGroupsDataIterator = \SplFixedArray::fromArray( - $collectionFactory->create()->getAllIds() - ); + $this->collectionFactory = $collectionFactory; } public function getIterator(): \Traversable { - foreach ($this->customerGroupsDataIterator as $customerGroup) { + foreach ($this->getCustomerGroups() as $customerGroup) { yield $this->dimensionFactory->create(self::DIMENSION_NAME, $customerGroup); } } public function count(): int { - return $this->customerGroupsDataIterator->count(); + return $this->getCustomerGroups()->count(); + } + + /** + * @return \SplFixedArray + */ + private function getCustomerGroups() + { + if ($this->customerGroupsDataIterator === null) { + $this->customerGroupsDataIterator = \SplFixedArray::fromArray( + $this->collectionFactory->create()->getAllIds() + ); + } + + return $this->customerGroupsDataIterator; } } diff --git a/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php b/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php index 6344be3a19542..1e83e1333c27f 100644 --- a/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php +++ b/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php @@ -9,6 +9,7 @@ use Magento\Store\Model\ResourceModel\Website\CollectionFactory as WebsiteCollectionFactory; use Magento\Framework\Indexer\DimensionFactory; use Magento\Framework\Indexer\DimensionProviderInterface; +use Magento\Store\Model\Store; class WebsiteDataProvider implements DimensionProviderInterface { @@ -19,33 +20,54 @@ class WebsiteDataProvider implements DimensionProviderInterface const DIMENSION_NAME = 'ws'; /** - * @var DimensionFactory + * @var WebsiteCollectionFactory */ - private $dimensionFactory; + private $collectionFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \SplFixedArray */ - private $storeManager; + private $websitesDataIterator; + + /** + * @var DimensionFactory + */ + private $dimensionFactory; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param WebsiteCollectionFactory $collectionFactory * @param DimensionFactory $dimensionFactory */ - public function __construct(\Magento\Store\Model\StoreManagerInterface $storeManager, DimensionFactory $dimensionFactory){ + public function __construct(WebsiteCollectionFactory $collectionFactory, DimensionFactory $dimensionFactory){ $this->dimensionFactory = $dimensionFactory; - $this->storeManager = $storeManager; + $this->collectionFactory = $collectionFactory; } public function getIterator(): \Traversable { - foreach ($this->storeManager->getWebsites(false) as $website) { - yield $this->dimensionFactory->create(self::DIMENSION_NAME, $website->getId()); + foreach ($this->getWebsites() as $website) { + yield $this->dimensionFactory->create(self::DIMENSION_NAME, $website); } } public function count(): int { - return $this->websitesDataIterator->count(); + return $this->getWebsites()->count(); + } + + /** + * @return \SplFixedArray + */ + private function getWebsites() + { + if ($this->websitesDataIterator === null) { + $this->websitesDataIterator = \SplFixedArray::fromArray( + $this->collectionFactory->create() + ->addFieldToFilter('code', ['neq' => Store::ADMIN_CODE]) + ->getAllIds() + ); + } + + return $this->websitesDataIterator; } } diff --git a/lib/internal/Magento/Framework/Indexer/DimensionCollection.php b/lib/internal/Magento/Framework/Indexer/DimensionCollection.php index 3c5c519da267a..299456be15bca 100644 --- a/lib/internal/Magento/Framework/Indexer/DimensionCollection.php +++ b/lib/internal/Magento/Framework/Indexer/DimensionCollection.php @@ -18,6 +18,11 @@ class DimensionCollection implements \Iterator, \Countable */ private $dimensionsDataProviders = []; + /** + * @var int + */ + private $dimensionsProvidersCount; + /** * @var int */ @@ -31,7 +36,7 @@ public function __construct(array $dimensionDataProviders = []) { $this->addDimensionDataProvider($dimensionDataProvider); } - $this->dimensionsCount = count($this->dimensionsIterators); + $this->dimensionsProvidersCount = count($this->dimensionsIterators); } public function current() @@ -49,9 +54,9 @@ public function current() public function next() { - $this->dimensionsIterators[$this->dimensionsCount - 1]->next(); + $this->dimensionsIterators[$this->dimensionsProvidersCount - 1]->next(); - for ($i = ($this->dimensionsCount - 1); $i > 0; $i--) { + for ($i = ($this->dimensionsProvidersCount - 1); $i > 0; $i--) { if (!$this->dimensionsIterators[$i]->valid()) { $this->dimensionsIterators[$i] = $this->dimensionsDataProviders[$i]->getIterator(); $this->dimensionsIterators[$i-1]->next(); @@ -72,7 +77,7 @@ public function key() public function valid() { - return $this->dimensionsCount > 0 && $this->dimensionsIterators[0]->valid(); + return $this->dimensionsProvidersCount > 0 && $this->dimensionsIterators[0]->valid(); } public function rewind() @@ -85,13 +90,17 @@ public function rewind() public function count() { - $counts = []; + if ($this->dimensionsCount === null) { + $counts = []; - foreach ($this->dimensionsDataProviders as $dimensionsDataProvider) { - $counts[] = count($dimensionsDataProvider); + foreach ($this->dimensionsDataProviders as $dimensionsDataProvider) { + $counts[] = count($dimensionsDataProvider); + } + + $this->dimensionsCount = array_product($counts); } - return array_product($counts); + return $this->dimensionsCount; } private function addDimensionDataProvider(DimensionProviderInterface $dimensionDataProvider) From 534eaf67c9f26f5e6a5f78f15d7a3c3e5b2dbde9 Mon Sep 17 00:00:00 2001 From: Andrii Voskoboinikov <avoskoboinikov@magento.com> Date: Fri, 25 May 2018 12:51:38 +0300 Subject: [PATCH 049/206] MAGETWO-91874: Adapt Full Action to use dimension --- lib/internal/Magento/Framework/Indexer/DimensionCollection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/Indexer/DimensionCollection.php b/lib/internal/Magento/Framework/Indexer/DimensionCollection.php index 299456be15bca..41a6b22c2dd13 100644 --- a/lib/internal/Magento/Framework/Indexer/DimensionCollection.php +++ b/lib/internal/Magento/Framework/Indexer/DimensionCollection.php @@ -97,7 +97,7 @@ public function count() $counts[] = count($dimensionsDataProvider); } - $this->dimensionsCount = array_product($counts); + $this->dimensionsCount = count($counts) === 0 ? 0 : array_product($counts); } return $this->dimensionsCount; From bba7b906d0b458de62b5f9b980a35d9e5a236fcc Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov <slopukhov@magento.com> Date: Fri, 25 May 2018 13:08:13 +0300 Subject: [PATCH 050/206] MAGETWO-91886: Add ability to configure dimensions --- .../Indexer/Product/Price/ModeSwitcher.php | 58 +++++++++---------- .../Magento/Catalog/Setup/UpgradeData.php | 21 +++++++ 2 files changed, 50 insertions(+), 29 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/ModeSwitcher.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/ModeSwitcher.php index e7108732859e2..9819f34d0faf8 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/ModeSwitcher.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/ModeSwitcher.php @@ -8,6 +8,8 @@ namespace Magento\Catalog\Model\Indexer\Product\Price; use Magento\Framework\Search\Request\Dimension; +use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; +use Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProvider; /** * Class to prepare new tables for new indexer mode @@ -42,20 +44,33 @@ class ModeSwitcher private $tableMaintainer; /** + * WebsiteRepositoryInterface + * * @var \Magento\Store\Api\WebsiteRepositoryInterface */ private $websiteRepository; /** + * GroupRepositoryInterface + * * @var \Magento\Customer\Api\GroupRepositoryInterface */ private $customerGroupRepository; /** + * SearchCriteriaBuilder + * * @var \Magento\Framework\Api\SearchCriteriaBuilder */ private $searchCriteriaBuilder; + /** + * DimensionCollectionFactory + * + * @var \Magento\Catalog\Model\Indexer\Product\Price\DimensionCollectionFactory + */ + private $dimensionCollectionFactory; + /** * @var array|null */ @@ -68,6 +83,7 @@ class ModeSwitcher * @param \Magento\Store\Api\WebsiteRepositoryInterface $websiteRepository * @param \Magento\Customer\Api\GroupRepositoryInterface $customerGroupRepository * @param \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder + * @param \Magento\Catalog\Model\Indexer\Product\Price\DimensionCollectionFactory $dimensionCollectionFactory */ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $configReader, @@ -75,7 +91,8 @@ public function __construct( \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer $tableMaintainer, \Magento\Store\Api\WebsiteRepositoryInterface $websiteRepository, \Magento\Customer\Api\GroupRepositoryInterface $customerGroupRepository, - \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder + \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder, + \Magento\Catalog\Model\Indexer\Product\Price\DimensionCollectionFactory $dimensionCollectionFactory ) { $this->configReader = $configReader; $this->configWriter = $configWriter; @@ -83,6 +100,7 @@ public function __construct( $this->websiteRepository = $websiteRepository; $this->customerGroupRepository = $customerGroupRepository; $this->searchCriteriaBuilder = $searchCriteriaBuilder; + $this->dimensionCollectionFactory = $dimensionCollectionFactory; } /** @@ -117,12 +135,13 @@ public function moveData($currentMode, $previousMode) foreach ($dimensionsArrayForCurrentMode as $dimensionsForCurrentMode) { $newTable = $this->tableMaintainer->getMainTable($dimensionsForCurrentMode); if (empty($dimensionsForCurrentMode)) { - // new mode none + // new mode is 'none' foreach ($dimensionsArrayForPreviousMode as $dimensionsForPreviousMode) { $oldTable = $this->tableMaintainer->getMainTable($dimensionsForPreviousMode); $this->insertFromOldTablesToNew($newTable, $oldTable); } } else { + // new mode is not 'none' foreach ($dimensionsArrayForPreviousMode as $dimensionsForPreviousMode) { $oldTable = $this->tableMaintainer->getMainTable($dimensionsForPreviousMode); $this->insertFromOldTablesToNew($newTable, $oldTable, $dimensionsForCurrentMode); @@ -152,7 +171,7 @@ public function dropTables($previousMode) /** * Get dimensions array * - * @param string $previousMode + * @param string $mode * * @return array */ @@ -162,32 +181,13 @@ private function getDimensionsArray($mode) return $this->dimensionsArray[$mode]; } - $searchCriteria = $this->searchCriteriaBuilder->create(); - $customerGroups = $this->customerGroupRepository->getList($searchCriteria)->getItems(); - - $dimensionsArray = []; - if ($mode !== self::INPUT_KEY_NONE) { - foreach ($this->websiteRepository->getList() as $website) { - foreach ($customerGroups as $customerGroup) { - $websiteDimension = new Dimension('website', $website->getId()); - $customerGroupDimension = new Dimension('group', $customerGroup->getId()); - if ($mode === self::INPUT_KEY_WEBSITE) { - $key = $websiteDimension->getValue(); - $dimensionsArray[$key] = [$websiteDimension]; - } elseif ($mode === self::INPUT_KEY_CUSTOMER_GROUP) { - $key = $customerGroupDimension->getValue(); - $dimensionsArray[$key] = [$customerGroupDimension]; - } else { - $key = $websiteDimension->getValue() . '-' . $customerGroupDimension->getValue(); - $dimensionsArray[$key] = [$websiteDimension, $customerGroupDimension]; - } - } - } - } else { - $dimensionsArray[] = []; + $this->dimensionsArray[$mode] = $this->dimensionCollectionFactory->createByMode($mode); + + //Array structure for 'none' mode + if (count($this->dimensionsArray[$mode]) === 0) { + $this->dimensionsArray[$mode] = [[]]; } - $this->dimensionsArray[$mode] = $dimensionsArray; return $this->dimensionsArray[$mode]; } @@ -205,10 +205,10 @@ private function insertFromOldTablesToNew($newTable, $oldTable, $dimensions = [] $select = $this->tableMaintainer->getConnection()->select()->from($oldTable); foreach ($dimensions as $dimension) { - if ($dimension->getName() === 'website') { + if ($dimension->getName() === WebsiteDataProvider::DIMENSION_NAME) { $select->where('website_id = ?', $dimension->getValue()); } - if ($dimension->getName() === 'group') { + if ($dimension->getName() === CustomerGroupDataProvider::DIMENSION_NAME) { $select->where('customer_group_id = ?', $dimension->getValue()); } } diff --git a/app/code/Magento/Catalog/Setup/UpgradeData.php b/app/code/Magento/Catalog/Setup/UpgradeData.php index 4e0be7396a166..123daf45de312 100644 --- a/app/code/Magento/Catalog/Setup/UpgradeData.php +++ b/app/code/Magento/Catalog/Setup/UpgradeData.php @@ -396,6 +396,10 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $this->enableSegmentation($setup); } + if (version_compare($context->getVersion(), '2.2.6') < 0) { + $this->savePriceIndexerDimensionsMode($setup); + } + $setup->endSetup(); } @@ -480,4 +484,21 @@ private function enableSegmentation(ModuleDataSetupInterface $setup) $setup->getConnection()->truncateTable($setup->getTable('catalog_category_product_index_replica')); $setup->getConnection()->truncateTable($setup->getTable('catalog_category_product_index_tmp')); } + + /** + * @param ModuleDataSetupInterface $setup + * @return void + */ + private function savePriceIndexerDimensionsMode(ModuleDataSetupInterface $setup) + { + $setup->getConnection()->insert( + $setup->getTable('core_config_data'), + [ + 'scope' => 'default', + 'scope_id' => 0, + 'path' => \Magento\Catalog\Model\Indexer\Product\Price\ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE, + 'value' => 'none' + ] + ); + } } From f5788130d7248a27a8deff75be6670f381bb271b Mon Sep 17 00:00:00 2001 From: Andrii Voskoboinikov <avoskoboinikov@magento.com> Date: Fri, 25 May 2018 16:14:46 +0300 Subject: [PATCH 051/206] MAGETWO-91874: Adapt Full Action to use dimension --- .../Indexer/Product/Price/Action/Full.php | 16 ++- .../Price/DimensionCollectionFactory.php | 117 ------------------ .../Price/DimensionProviderFactory.php | 93 ++++++++++++++ app/code/Magento/Catalog/etc/di.xml | 27 ++++ .../CustomerGroupDataProvider.php | 2 +- .../MultiDimensional/WebsiteDataProvider.php | 2 +- ...onCollection.php => DimensionProvider.php} | 83 ++++++------- 7 files changed, 173 insertions(+), 167 deletions(-) delete mode 100644 app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionCollectionFactory.php create mode 100644 app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionProviderFactory.php rename lib/internal/Magento/Framework/Indexer/{DimensionCollection.php => DimensionProvider.php} (69%) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php index c709431c1fd91..2666959c4ce5b 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php @@ -11,6 +11,8 @@ use Magento\Catalog\Api\Data\ProductInterface; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Indexer\DimensionalIndexerInterface; +use Magento\Catalog\Model\Indexer\Product\Price\ModeSwitcher; +use Magento\Framework\Indexer\DimensionProviderInterface; /** * Class Full reindex action @@ -88,7 +90,7 @@ public function __construct( \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\BatchSizeCalculator $batchSizeCalculator = null, \Magento\Framework\Indexer\BatchProviderInterface $batchProvider = null, \Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher $activeTableSwitcher = null, - \Magento\Catalog\Model\Indexer\Product\Price\DimensionCollectionFactory $dimensionCollectionFactory = null, + \Magento\Catalog\Model\Indexer\Product\Price\DimensionProviderFactory $dimensionCollectionFactory = null, \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer $dimensionTableMaintainer = null ) { parent::__construct( @@ -114,14 +116,11 @@ public function __construct( \Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher::class ); $dimensionCollectionFactory = $dimensionCollectionFactory ?: ObjectManager::getInstance()->get( - \Magento\Catalog\Model\Indexer\Product\Price\DimensionCollectionFactory::class + \Magento\Catalog\Model\Indexer\Product\Price\DimensionProvider::class ); $this->dimensionTableMaintainer = $dimensionTableMaintainer ?: ObjectManager::getInstance()->get( \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer::class ); - - $this->allDimensionCollection = $dimensionCollectionFactory->createByAllDimensions(); - $this->modeDimensionCollection = $dimensionCollectionFactory->createByCurrentMode(); } /** @@ -200,7 +199,12 @@ private function reindexProductType(PriceInterface $priceIndexer) private function reindexProductTypeWithDimensions(PriceInterface $priceIndexer) { - foreach ($this->allDimensionCollection as $dimension) { + /** @var DimensionProviderInterface $dimensionsProviders */ + $dimensionsProviders = $this->dimensionTableMaintainer->createByMode( + ModeSwitcher::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP + ); + + foreach ($dimensionsProviders->getIterator() as $dimension) { $this->reindexDimensions($priceIndexer, $dimension); } } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionCollectionFactory.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionCollectionFactory.php deleted file mode 100644 index d646bef55159d..0000000000000 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionCollectionFactory.php +++ /dev/null @@ -1,117 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Catalog\Model\Indexer\Product\Price; - -use Magento\Framework\Indexer\Dimension; - -class DimensionCollectionFactory -{ - /** - * @var \Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProviderFactory - */ - private $websiteDataProviderFactory; - - /** - * @var \Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProviderFactory - */ - private $customerGroupDataProviderFactory; - - /** - * @var \Magento\Framework\Indexer\DimensionCollectionFactory - */ - private $generalDimensionCollectionFactory; - - /** - * @var \Magento\Framework\App\Config\ScopeConfigInterface - */ - private $configReader; - - /** - * @param \Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProviderFactory $websiteDataProviderFactory - * @param \Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProviderFactory $customerGroupDataProviderFactory - * @param \Magento\Framework\Indexer\DimensionCollectionFactory $generalDimensionCollectionFactory - * @param \Magento\Framework\App\Config\ScopeConfigInterface $configReader - */ - public function __construct( - \Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProviderFactory $websiteDataProviderFactory, - \Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProviderFactory $customerGroupDataProviderFactory, - \Magento\Framework\Indexer\DimensionCollectionFactory $generalDimensionCollectionFactory, - \Magento\Framework\App\Config\ScopeConfigInterface $configReader - ) { - $this->websiteDataProviderFactory = $websiteDataProviderFactory; - $this->customerGroupDataProviderFactory = $customerGroupDataProviderFactory; - $this->generalDimensionCollectionFactory = $generalDimensionCollectionFactory; - $this->configReader = $configReader; - } - - /** - * @return Dimension[] - */ - public function createByCurrentMode() - { - $dbMode = $this->configReader->getValue(ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE); - - return $this->generalDimensionCollectionFactory->create( - [ - 'dimensionDataProviders' => $this->getDataProviders($dbMode) - ] - ); - } - - public function createByMode(string $mode) - { - return $this->generalDimensionCollectionFactory->create( - [ - 'dimensionDataProviders' => $this->getDataProviders($mode) - ] - ); - } - - /** - * @return Dimension[] - */ - public function createByAllDimensions() - { - return $this->generalDimensionCollectionFactory->create( - [ - 'dimensionDataProviders' => $this->getDataProviders( - ModeSwitcher::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP - ) - ] - ); - } - - private function getDataProviders($dimensionsMode) - { - $providers = []; - - switch ($dimensionsMode) { - case null: - case ModeSwitcher::INPUT_KEY_NONE: - break; - - case ModeSwitcher::INPUT_KEY_WEBSITE: - $providers[] = $this->websiteDataProviderFactory->create(); - break; - - case ModeSwitcher::INPUT_KEY_CUSTOMER_GROUP: - $providers[] = $this->customerGroupDataProviderFactory->create(); - break; - - case ModeSwitcher::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP: - $providers[] = $this->websiteDataProviderFactory->create(); - $providers[] = $this->customerGroupDataProviderFactory->create(); - break; - - default: - throw new \InvalidArgumentException( - sprintf('Undefined dimension mode "%s".', $dimensionsMode) - ); - } - - return $providers; - } -} diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionProviderFactory.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionProviderFactory.php new file mode 100644 index 0000000000000..4b8b9fb9bb20a --- /dev/null +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionProviderFactory.php @@ -0,0 +1,93 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Catalog\Model\Indexer\Product\Price; + +use Magento\Framework\Indexer\Dimension; +use Magento\Framework\Indexer\DimensionProviderInterface; + +class DimensionProviderFactory +{ + /** + * + */ + const EMPTY_CONFIGURATION = '-'; + + /** + * @var \Magento\Framework\Indexer\DimensionCollectionFactory + */ + private $dimensionProviderFactory; + + /** + * @var array + */ + private $dataProviders; + + /** + * @var array + */ + private $modes; + + /** + * @var array + */ + private $modesConfiguration; + + public function __construct( + \Magento\Framework\Indexer\DimensionProviderFactory $dimensionProviderFactory, + array $dataProviders, + array $modes, + array $modesConfiguration + ) { + $this->dimensionProviderFactory = $dimensionProviderFactory; + $this->dataProviders = $dataProviders; + $this->modes = $modes; + $this->modesConfiguration = $modesConfiguration; + } + + public function createByMode($dimensionsMode): DimensionProviderInterface + { + if (!in_array($dimensionsMode, $this->modes)) { + throw new \InvalidArgumentException( + sprintf('Undefined dimension mode "%s".', $dimensionsMode) + ); + } + + $modeConfigurationKey = array_search($dimensionsMode, $this->modes, true); + if (!array_key_exists($modeConfigurationKey, $this->modesConfiguration)) { + throw new \InvalidArgumentException( + sprintf('Missing configuration for mode "%s".', $dimensionsMode) + ); + } + + return $this->dimensionProviderFactory->create( + [ + 'dimensionDataProviders' => $this->getDataProviders($modeConfigurationKey) + ] + ); + } + + private function getDataProviders($modeConfigurationKey): array + { + $modeConfiguration = $this->modesConfiguration[$modeConfigurationKey]; + $providers = []; + + if ($modeConfiguration === self::EMPTY_CONFIGURATION) { + return $providers; + } + + foreach ($modeConfiguration as $modeDataProviderName) { + if (!array_key_exists($modeDataProviderName, $this->dataProviders)) { + throw new \InvalidArgumentException( + sprintf('Missing data provider "%s".', $modeDataProviderName) + ); + } + + $providers[] = $this->dataProviders[$modeDataProviderName]->create(); + } + + return $providers; + } +} diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml index 827637ad4d619..c1273ae530013 100644 --- a/app/code/Magento/Catalog/etc/di.xml +++ b/app/code/Magento/Catalog/etc/di.xml @@ -1074,4 +1074,31 @@ <argument name="nativeAttributeConditionBuilder" xsi:type="object">Magento\Catalog\Model\Api\SearchCriteria\CollectionProcessor\ConditionProcessor\ConditionBuilder\NativeAttributeCondition</argument> </arguments> </type> + <type name="Magento\Catalog\Model\Indexer\Product\Price\DimensionProviderFactory"> + <arguments> + <argument name="dataProviders" xsi:type="array"> + <item name="websites" xsi:type="object">Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProviderFactory</item> + <item name="customer_groups" xsi:type="object">Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProviderFactory</item> + </argument> + <argument name="modes" xsi:type="array"> + <item name="mode-1" xsi:type="const">Magento\Catalog\Model\Indexer\Product\Price\ModeSwitcher::INPUT_KEY_NONE</item> + <item name="mode-2" xsi:type="const">Magento\Catalog\Model\Indexer\Product\Price\ModeSwitcher::INPUT_KEY_WEBSITE</item> + <item name="mode-3" xsi:type="const">Magento\Catalog\Model\Indexer\Product\Price\ModeSwitcher::INPUT_KEY_CUSTOMER_GROUP</item> + <item name="mode-4" xsi:type="const">Magento\Catalog\Model\Indexer\Product\Price\ModeSwitcher::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP</item> + </argument> + <argument name="modesConfiguration" xsi:type="array"> + <item name="mode-1" xsi:type="const">Magento\Catalog\Model\Indexer\Product\Price\DimensionProvider::EMPTY_CONFIGURATION</item> + <item name="mode-2" xsi:type="array"> + <item name="websites" xsi:type="string">websites</item> + </item> + <item name="mode-3" xsi:type="array"> + <item name="customer_groups" xsi:type="string">customer_groups</item> + </item> + <item name="mode-4" xsi:type="array"> + <item name="websites" xsi:type="string">websites</item> + <item name="customer_groups" xsi:type="string">customer_groups</item> + </item> + </argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php b/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php index 24f7c9c17bea5..4215ded9ce213 100644 --- a/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php +++ b/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php @@ -41,7 +41,7 @@ public function __construct(CustomerGroupCollectionFactory $collectionFactory, D public function getIterator(): \Traversable { foreach ($this->getCustomerGroups() as $customerGroup) { - yield $this->dimensionFactory->create(self::DIMENSION_NAME, $customerGroup); + yield [self::DIMENSION_NAME => $this->dimensionFactory->create(self::DIMENSION_NAME, $customerGroup)]; } } diff --git a/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php b/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php index 1e83e1333c27f..56062ec2bc762 100644 --- a/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php +++ b/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php @@ -46,7 +46,7 @@ public function __construct(WebsiteCollectionFactory $collectionFactory, Dimensi public function getIterator(): \Traversable { foreach ($this->getWebsites() as $website) { - yield $this->dimensionFactory->create(self::DIMENSION_NAME, $website); + yield [self::DIMENSION_NAME => $this->dimensionFactory->create(self::DIMENSION_NAME, $website)]; } } diff --git a/lib/internal/Magento/Framework/Indexer/DimensionCollection.php b/lib/internal/Magento/Framework/Indexer/DimensionProvider.php similarity index 69% rename from lib/internal/Magento/Framework/Indexer/DimensionCollection.php rename to lib/internal/Magento/Framework/Indexer/DimensionProvider.php index 41a6b22c2dd13..c47471b8a1503 100644 --- a/lib/internal/Magento/Framework/Indexer/DimensionCollection.php +++ b/lib/internal/Magento/Framework/Indexer/DimensionProvider.php @@ -6,7 +6,7 @@ namespace Magento\Framework\Indexer; -class DimensionCollection implements \Iterator, \Countable +class DimensionProvider implements DimensionProviderInterface { /** * @var array @@ -21,7 +21,7 @@ class DimensionCollection implements \Iterator, \Countable /** * @var int */ - private $dimensionsProvidersCount; + private $dimensionsProvidersCount = 0; /** * @var int @@ -35,24 +35,54 @@ public function __construct(array $dimensionDataProviders = []) { foreach ($dimensionDataProviders as $dimensionDataProvider) { $this->addDimensionDataProvider($dimensionDataProvider); } + } + + public function getIterator(): \Traversable + { + $this->initDataIterators(); + $dimensionsCount = $this->count(); + + for ($i = 0; $i < $dimensionsCount; $i++) { + yield $this->getCurrentDimension(); + $this->setNextDimension(); + } - $this->dimensionsProvidersCount = count($this->dimensionsIterators); } - public function current() + public function count(): int + { + if ($this->dimensionsCount === null) { + $counts = []; + + foreach ($this->dimensionsDataProviders as $dimensionsDataProvider) { + $counts[] = count($dimensionsDataProvider); + } + + $this->dimensionsCount = count($counts) === 0 ? 0 : array_product($counts); + } + + return $this->dimensionsCount; + } + + private function getCurrentDimension(): array { $dimensions = []; foreach ($this->dimensionsIterators as $dimensionIterator) { /** @var Dimension $dimension */ $dimension = $dimensionIterator->current(); + + if (is_array($dimension)) { + $dimension = $dimension[0]; + } + $dimensions[$dimension->getName()] = $dimension; } return $dimensions; } - public function next() + private function setNextDimension() { $this->dimensionsIterators[$this->dimensionsProvidersCount - 1]->next(); @@ -64,48 +94,17 @@ public function next() } } - public function key() - { - $keys = []; - - foreach ($this->dimensionsIterators as $dimensionIterator) { - $keys[] = $dimensionIterator->key(); - } - - return implode(':', $keys); - } - - public function valid() + private function addDimensionDataProvider(DimensionProviderInterface $dimensionDataProvider) { - return $this->dimensionsProvidersCount > 0 && $this->dimensionsIterators[0]->valid(); - } + $this->dimensionsDataProviders[] = $dimensionDataProvider; + $this->dimensionsProvidersCount++; - public function rewind() - { - $this->dimensionsIterators = []; - foreach ($this->dimensionsDataProviders as $dimensionsDataProvider) { - $this->dimensionsIterators[] = $dimensionsDataProvider->getIterator(); - } } - public function count() + private function initDataIterators() { - if ($this->dimensionsCount === null) { - $counts = []; - - foreach ($this->dimensionsDataProviders as $dimensionsDataProvider) { - $counts[] = count($dimensionsDataProvider); - } - - $this->dimensionsCount = count($counts) === 0 ? 0 : array_product($counts); + foreach ($this->dimensionsDataProviders as $dimensionDataProvider) { + $this->dimensionsIterators[] = $dimensionDataProvider->getIterator(); } - - return $this->dimensionsCount; - } - - private function addDimensionDataProvider(DimensionProviderInterface $dimensionDataProvider) - { - $this->dimensionsDataProviders[] = $dimensionDataProvider; - $this->dimensionsIterators[] = $dimensionDataProvider->getIterator(); } } From 155070f2e4c2af5cad4f7af8a83377623ba28f15 Mon Sep 17 00:00:00 2001 From: Andrii Voskoboinikov <avoskoboinikov@magento.com> Date: Fri, 25 May 2018 16:17:11 +0300 Subject: [PATCH 052/206] MAGETWO-91874: Adapt Full Action to use dimension --- app/code/Magento/Catalog/etc/di.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml index c1273ae530013..c0a8fec1eda40 100644 --- a/app/code/Magento/Catalog/etc/di.xml +++ b/app/code/Magento/Catalog/etc/di.xml @@ -1087,7 +1087,7 @@ <item name="mode-4" xsi:type="const">Magento\Catalog\Model\Indexer\Product\Price\ModeSwitcher::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP</item> </argument> <argument name="modesConfiguration" xsi:type="array"> - <item name="mode-1" xsi:type="const">Magento\Catalog\Model\Indexer\Product\Price\DimensionProvider::EMPTY_CONFIGURATION</item> + <item name="mode-1" xsi:type="const">Magento\Catalog\Model\Indexer\Product\Price\DimensionProviderFactory::EMPTY_CONFIGURATION</item> <item name="mode-2" xsi:type="array"> <item name="websites" xsi:type="string">websites</item> </item> From b7f047e630f853ae113c97f2a9b23e6fc43e4224 Mon Sep 17 00:00:00 2001 From: Andrii Voskoboinikov <avoskoboinikov@magento.com> Date: Fri, 25 May 2018 16:25:51 +0300 Subject: [PATCH 053/206] MAGETWO-91874: Adapt Full Action to use dimension --- .../Indexer/Product/Price/Action/Full.php | 20 +++++++------------ .../Indexer/Product/Price/ModeSwitcher.php | 4 ++-- .../Product/Indexer/Price/DefaultPrice.php | 14 ++++++++----- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php index 2666959c4ce5b..baac8c82140fb 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php @@ -162,12 +162,6 @@ private function prepareTables() // Prepare replica table for indexation. $this->_defaultIndexerResource->getConnection()->truncateTable($this->getReplicaTable()); - - // Prepare tables for dimensions. - foreach ($this->modeDimensionCollection as $dimension) { - $this->dimensionTableMaintainer->createTablesForDimensions($dimension); - $this->_emptyTable($this->dimensionTableMaintainer->getMainReplicaTable($dimension)); - } } private function switchTables() @@ -179,15 +173,15 @@ private function switchTables() ); // Switch dimension tables - $dimensionTables = []; +// $dimensionTables = []; - foreach ($this->modeDimensionCollection as $dimension) { - $dimensionTables[] = $this->dimensionTableMaintainer->getMainReplicaTable($dimension); - } +// foreach ($this->modeDimensionCollection as $dimension) { +// $dimensionTables[] = $this->dimensionTableMaintainer->getMainReplicaTable($dimension); +// } - if (count($dimensionTables) > 0) { - $this->activeTableSwitcher->switchTable($this->_defaultIndexerResource->getConnection(), $dimensionTables); - } +// if (count($dimensionTables) > 0) { +// $this->activeTableSwitcher->switchTable($this->_defaultIndexerResource->getConnection(), $dimensionTables); +// } } private function reindexProductType(PriceInterface $priceIndexer) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/ModeSwitcher.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/ModeSwitcher.php index 9819f34d0faf8..5b2eb9678ac2e 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/ModeSwitcher.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/ModeSwitcher.php @@ -92,7 +92,7 @@ public function __construct( \Magento\Store\Api\WebsiteRepositoryInterface $websiteRepository, \Magento\Customer\Api\GroupRepositoryInterface $customerGroupRepository, \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder, - \Magento\Catalog\Model\Indexer\Product\Price\DimensionCollectionFactory $dimensionCollectionFactory + \Magento\Catalog\Model\Indexer\Product\Price\DimensionProviderFactory $dimensionCollectionFactory ) { $this->configReader = $configReader; $this->configWriter = $configWriter; @@ -181,7 +181,7 @@ private function getDimensionsArray($mode) return $this->dimensionsArray[$mode]; } - $this->dimensionsArray[$mode] = $this->dimensionCollectionFactory->createByMode($mode); + $this->dimensionsArray[$mode] = $this->dimensionCollectionFactory->createByMode($mode)->getIterator(); //Array structure for 'none' mode if (count($this->dimensionsArray[$mode]) === 0) { diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php index cf0b237f8a0ed..73188fb961e65 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php @@ -5,12 +5,13 @@ */ namespace Magento\Catalog\Model\ResourceModel\Product\Indexer\Price; -use Magento\Catalog\Model\Indexer\Product\Price\DimensionCollectionFactory; +use Magento\Catalog\Model\Indexer\Product\Price\DimensionProviderFactory; use Magento\Catalog\Model\ResourceModel\Product\Indexer\AbstractIndexer; use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\Query\BaseFinalPrice; use Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProvider; use Magento\Framework\App\ObjectManager; use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; +use Magento\Catalog\Model\Indexer\Product\Price\ModeSwitcher; /** * Default Product Type Price Indexer Resource model @@ -96,7 +97,7 @@ public function __construct( $connectionName = null, IndexTableStructureFactory $indexTableStructureFactory = null, BaseFinalPrice $baseFinalPrice = null, - DimensionCollectionFactory $dimensionCollectionFactory = null, + DimensionProviderFactory $dimensionCollectionFactory = null, array $priceModifiers = [] ) { $this->_eventManager = $eventManager; @@ -116,7 +117,7 @@ public function __construct( } $this->baseFinalPrice = $baseFinalPrice ?? ObjectManager::getInstance()->get(BaseFinalPrice::class); $this->dimensionCollectionFactory = $dimensionCollectionFactory - ?? ObjectManager::getInstance()->get(DimensionCollectionFactory::class); + ?? ObjectManager::getInstance()->get(DimensionProviderFactory::class); } /** @@ -321,8 +322,11 @@ protected function prepareFinalPriceDataForType($entityIds, $type) { $finalPriceTable = $this->prepareFinalPriceTable(); - $dimensions = $this->dimensionCollectionFactory->createByAllDimensions(); - foreach ($dimensions as $dimension) { + $dimensions = $this->dimensionCollectionFactory->createByMode( + ModeSwitcher::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP + ) + ; + foreach ($dimensions->getIterator() as $dimension) { $select = $this->getSelect( $entityIds, $type, From 80e204ebe030a085ecd7d24258b8e9d24c895dd2 Mon Sep 17 00:00:00 2001 From: Andrii Voskoboinikov <avoskoboinikov@magento.com> Date: Fri, 25 May 2018 18:52:47 +0300 Subject: [PATCH 054/206] MAGETWO-91874: Adapt Full Action to use dimension --- .../Indexer/Product/Price/Action/Full.php | 47 ++++++++++++------- .../Price/DimensionProviderFactory.php | 1 - .../Indexer/Product/Price/ModeSwitcher.php | 2 +- .../Product/Indexer/Price/DefaultPrice.php | 5 +- .../Framework/Indexer/DimensionProvider.php | 2 +- 5 files changed, 34 insertions(+), 23 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php index baac8c82140fb..1f7ff3794e2de 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php @@ -46,19 +46,19 @@ class Full extends \Magento\Catalog\Model\Indexer\Product\Price\AbstractAction private $productMetaDataCached; /** - * @var \Magento\Framework\Indexer\DimensionCollection + * @var \Magento\Catalog\Model\Indexer\Product\Price\DimensionProviderFactory */ - private $allDimensionCollection; + private $dimensionCollectionFactory; /** - * @var \Magento\Framework\Indexer\DimensionCollection + * @var \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer */ - private $modeDimensionCollection; + private $dimensionTableMaintainer; /** * @var \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer */ - private $dimensionTableMaintainer; + private $configReader; /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $config @@ -91,7 +91,8 @@ public function __construct( \Magento\Framework\Indexer\BatchProviderInterface $batchProvider = null, \Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher $activeTableSwitcher = null, \Magento\Catalog\Model\Indexer\Product\Price\DimensionProviderFactory $dimensionCollectionFactory = null, - \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer $dimensionTableMaintainer = null + \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer $dimensionTableMaintainer = null, + \Magento\Framework\App\Config\ScopeConfigInterface $configReader = null ) { parent::__construct( $config, @@ -115,12 +116,15 @@ public function __construct( $this->activeTableSwitcher = $activeTableSwitcher ?: ObjectManager::getInstance()->get( \Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher::class ); - $dimensionCollectionFactory = $dimensionCollectionFactory ?: ObjectManager::getInstance()->get( - \Magento\Catalog\Model\Indexer\Product\Price\DimensionProvider::class + $this->dimensionCollectionFactory = $dimensionCollectionFactory ?: ObjectManager::getInstance()->get( + \Magento\Catalog\Model\Indexer\Product\Price\DimensionProviderFactory::class ); $this->dimensionTableMaintainer = $dimensionTableMaintainer ?: ObjectManager::getInstance()->get( \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer::class ); + $this->configReader = $configReader ?: ObjectManager::getInstance()->get( + \Magento\Framework\App\Config\ScopeConfigInterface::class + ); } /** @@ -172,16 +176,25 @@ private function switchTables() [$this->_defaultIndexerResource->getMainTable()] ); + $currentMode = $this->configReader + ->getValue(ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE) ?: ModeSwitcher::INPUT_KEY_NONE; + + /** @var DimensionProviderInterface $dimensionsProviders */ + $dimensionsProviders = $this->dimensionCollectionFactory->createByMode($currentMode); + // Switch dimension tables -// $dimensionTables = []; + $dimensionTables = []; -// foreach ($this->modeDimensionCollection as $dimension) { -// $dimensionTables[] = $this->dimensionTableMaintainer->getMainReplicaTable($dimension); -// } + foreach ($dimensionsProviders as $dimension) { + $dimensionTables[] = $this->dimensionTableMaintainer->getMainReplicaTable($dimension); + } -// if (count($dimensionTables) > 0) { -// $this->activeTableSwitcher->switchTable($this->_defaultIndexerResource->getConnection(), $dimensionTables); -// } + if (count($dimensionTables) > 0) { + $this->activeTableSwitcher->switchTable( + $this->_defaultIndexerResource->getConnection(), + $dimensionTables + ); + } } private function reindexProductType(PriceInterface $priceIndexer) @@ -194,11 +207,11 @@ private function reindexProductType(PriceInterface $priceIndexer) private function reindexProductTypeWithDimensions(PriceInterface $priceIndexer) { /** @var DimensionProviderInterface $dimensionsProviders */ - $dimensionsProviders = $this->dimensionTableMaintainer->createByMode( + $dimensionsProviders = $this->dimensionCollectionFactory->createByMode( ModeSwitcher::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP ); - foreach ($dimensionsProviders->getIterator() as $dimension) { + foreach ($dimensionsProviders as $dimension) { $this->reindexDimensions($priceIndexer, $dimension); } } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionProviderFactory.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionProviderFactory.php index 4b8b9fb9bb20a..89eedb1c9d9a9 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionProviderFactory.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionProviderFactory.php @@ -5,7 +5,6 @@ */ namespace Magento\Catalog\Model\Indexer\Product\Price; -use Magento\Framework\Indexer\Dimension; use Magento\Framework\Indexer\DimensionProviderInterface; class DimensionProviderFactory diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/ModeSwitcher.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/ModeSwitcher.php index 5b2eb9678ac2e..18243c9104ee0 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/ModeSwitcher.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/ModeSwitcher.php @@ -181,7 +181,7 @@ private function getDimensionsArray($mode) return $this->dimensionsArray[$mode]; } - $this->dimensionsArray[$mode] = $this->dimensionCollectionFactory->createByMode($mode)->getIterator(); + $this->dimensionsArray[$mode] = $this->dimensionCollectionFactory->createByMode($mode); //Array structure for 'none' mode if (count($this->dimensionsArray[$mode]) === 0) { diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php index 73188fb961e65..9ff1a65eab707 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php @@ -324,9 +324,8 @@ protected function prepareFinalPriceDataForType($entityIds, $type) $dimensions = $this->dimensionCollectionFactory->createByMode( ModeSwitcher::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP - ) - ; - foreach ($dimensions->getIterator() as $dimension) { + ); + foreach ($dimensions as $dimension) { $select = $this->getSelect( $entityIds, $type, diff --git a/lib/internal/Magento/Framework/Indexer/DimensionProvider.php b/lib/internal/Magento/Framework/Indexer/DimensionProvider.php index c47471b8a1503..0e4ef20d2f37a 100644 --- a/lib/internal/Magento/Framework/Indexer/DimensionProvider.php +++ b/lib/internal/Magento/Framework/Indexer/DimensionProvider.php @@ -73,7 +73,7 @@ private function getCurrentDimension(): array $dimension = $dimensionIterator->current(); if (is_array($dimension)) { - $dimension = $dimension[0]; + $dimension = reset($dimension); } $dimensions[$dimension->getName()] = $dimension; From d49f9b3d058b68e2cd710577f62b2da3b872c8db Mon Sep 17 00:00:00 2001 From: Michail Slabko <mslabko@magento.com> Date: Fri, 25 May 2018 21:55:18 +0300 Subject: [PATCH 055/206] MAGETWO-91886: Add ability to configure dimensions - adapt interfaces --- .../Price/DimensionProviderFactory.php | 32 +++++++++++-------- .../Indexer/Product/Price/ModeSwitcher.php | 5 --- app/code/Magento/Catalog/etc/di.xml | 6 ++-- .../CustomerGroupDataProvider.php | 2 +- .../MultiDimensional/WebsiteDataProvider.php | 2 +- app/etc/di.xml | 1 + .../Indexer/DimensionProviderInterface.php | 3 ++ ...rovider.php => MultiDimensionProvider.php} | 17 +++++----- .../MultiDimensionProviderInterface.php | 21 ++++++++++++ 9 files changed, 57 insertions(+), 32 deletions(-) rename lib/internal/Magento/Framework/Indexer/{DimensionProvider.php => MultiDimensionProvider.php} (86%) create mode 100644 lib/internal/Magento/Framework/Indexer/MultiDimensionProviderInterface.php diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionProviderFactory.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionProviderFactory.php index 89eedb1c9d9a9..03d9aa354b9ab 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionProviderFactory.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionProviderFactory.php @@ -5,7 +5,7 @@ */ namespace Magento\Catalog\Model\Indexer\Product\Price; -use Magento\Framework\Indexer\DimensionProviderInterface; +use Magento\Framework\Indexer\MultiDimensionProviderInterface; class DimensionProviderFactory { @@ -15,14 +15,14 @@ class DimensionProviderFactory const EMPTY_CONFIGURATION = '-'; /** - * @var \Magento\Framework\Indexer\DimensionCollectionFactory + * @var \Magento\Framework\Indexer\MultiDimensionProviderFactory */ - private $dimensionProviderFactory; + private $multiDimensionProviderFactory; /** * @var array */ - private $dataProviders; + private $dimensionProviders; /** * @var array @@ -35,18 +35,24 @@ class DimensionProviderFactory private $modesConfiguration; public function __construct( - \Magento\Framework\Indexer\DimensionProviderFactory $dimensionProviderFactory, - array $dataProviders, + \Magento\Framework\Indexer\MultiDimensionProviderInterfaceFactory $multiDimensionProviderFactory, + array $dimensionProviders, array $modes, array $modesConfiguration ) { - $this->dimensionProviderFactory = $dimensionProviderFactory; - $this->dataProviders = $dataProviders; + $this->multiDimensionProviderFactory = $multiDimensionProviderFactory; + $this->dimensionProviders = $dimensionProviders; $this->modes = $modes; $this->modesConfiguration = $modesConfiguration; } - public function createByMode($dimensionsMode): DimensionProviderInterface + /** + * Create MultiDimensionProviderInterface for specified "dimension mode" - which dimensions indexer use for sharding + * + * @param string $dimensionsMode + * @return MultiDimensionProviderInterface + */ + public function createByMode(string $dimensionsMode): MultiDimensionProviderInterface { if (!in_array($dimensionsMode, $this->modes)) { throw new \InvalidArgumentException( @@ -61,9 +67,9 @@ public function createByMode($dimensionsMode): DimensionProviderInterface ); } - return $this->dimensionProviderFactory->create( + return $this->multiDimensionProviderFactory->create( [ - 'dimensionDataProviders' => $this->getDataProviders($modeConfigurationKey) + 'dimensionProviders' => $this->getDataProviders($modeConfigurationKey) ] ); } @@ -78,13 +84,13 @@ private function getDataProviders($modeConfigurationKey): array } foreach ($modeConfiguration as $modeDataProviderName) { - if (!array_key_exists($modeDataProviderName, $this->dataProviders)) { + if (!array_key_exists($modeDataProviderName, $this->dimensionProviders)) { throw new \InvalidArgumentException( sprintf('Missing data provider "%s".', $modeDataProviderName) ); } - $providers[] = $this->dataProviders[$modeDataProviderName]->create(); + $providers[] = $this->dimensionProviders[$modeDataProviderName]; } return $providers; diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/ModeSwitcher.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/ModeSwitcher.php index 18243c9104ee0..4326023293521 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/ModeSwitcher.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/ModeSwitcher.php @@ -183,11 +183,6 @@ private function getDimensionsArray($mode) $this->dimensionsArray[$mode] = $this->dimensionCollectionFactory->createByMode($mode); - //Array structure for 'none' mode - if (count($this->dimensionsArray[$mode]) === 0) { - $this->dimensionsArray[$mode] = [[]]; - } - return $this->dimensionsArray[$mode]; } diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml index c0a8fec1eda40..e426de94150ad 100644 --- a/app/code/Magento/Catalog/etc/di.xml +++ b/app/code/Magento/Catalog/etc/di.xml @@ -1076,9 +1076,9 @@ </type> <type name="Magento\Catalog\Model\Indexer\Product\Price\DimensionProviderFactory"> <arguments> - <argument name="dataProviders" xsi:type="array"> - <item name="websites" xsi:type="object">Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProviderFactory</item> - <item name="customer_groups" xsi:type="object">Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProviderFactory</item> + <argument name="dimensionProviders" xsi:type="array"> + <item name="websites" xsi:type="object">Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider</item> + <item name="customer_groups" xsi:type="object">Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProvider</item> </argument> <argument name="modes" xsi:type="array"> <item name="mode-1" xsi:type="const">Magento\Catalog\Model\Indexer\Product\Price\ModeSwitcher::INPUT_KEY_NONE</item> diff --git a/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php b/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php index 4215ded9ce213..24f7c9c17bea5 100644 --- a/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php +++ b/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php @@ -41,7 +41,7 @@ public function __construct(CustomerGroupCollectionFactory $collectionFactory, D public function getIterator(): \Traversable { foreach ($this->getCustomerGroups() as $customerGroup) { - yield [self::DIMENSION_NAME => $this->dimensionFactory->create(self::DIMENSION_NAME, $customerGroup)]; + yield $this->dimensionFactory->create(self::DIMENSION_NAME, $customerGroup); } } diff --git a/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php b/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php index 56062ec2bc762..1e83e1333c27f 100644 --- a/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php +++ b/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php @@ -46,7 +46,7 @@ public function __construct(WebsiteCollectionFactory $collectionFactory, Dimensi public function getIterator(): \Traversable { foreach ($this->getWebsites() as $website) { - yield [self::DIMENSION_NAME => $this->dimensionFactory->create(self::DIMENSION_NAME, $website)]; + yield $this->dimensionFactory->create(self::DIMENSION_NAME, $website); } } diff --git a/app/etc/di.xml b/app/etc/di.xml index 0a5c05cf1006d..295716acf2fe5 100755 --- a/app/etc/di.xml +++ b/app/etc/di.xml @@ -173,6 +173,7 @@ <preference for="Magento\Framework\View\Page\FaviconInterface" type="Magento\Theme\Model\Favicon\Favicon" /> <preference for="Magento\Framework\View\Element\Message\InterpretationStrategyInterface" type="Magento\Framework\View\Element\Message\InterpretationMediator" /> <preference for="Magento\Framework\Indexer\Config\DependencyInfoProviderInterface" type="Magento\Framework\Indexer\Config\DependencyInfoProvider" /> + <preference for="Magento\Framework\Indexer\MultiDimensionProviderInterface" type="\Magento\Framework\Indexer\MultiDimensionProvider" /> <type name="Magento\Framework\Model\ResourceModel\Db\TransactionManager" shared="false" /> <type name="Magento\Framework\Acl\Data\Cache"> <arguments> diff --git a/lib/internal/Magento/Framework/Indexer/DimensionProviderInterface.php b/lib/internal/Magento/Framework/Indexer/DimensionProviderInterface.php index 7797009905161..992388dd33bf4 100644 --- a/lib/internal/Magento/Framework/Indexer/DimensionProviderInterface.php +++ b/lib/internal/Magento/Framework/Indexer/DimensionProviderInterface.php @@ -7,6 +7,9 @@ namespace Magento\Framework\Indexer; +/** + * Provide a list of dimensions + */ interface DimensionProviderInterface extends \IteratorAggregate, \Countable { /** diff --git a/lib/internal/Magento/Framework/Indexer/DimensionProvider.php b/lib/internal/Magento/Framework/Indexer/MultiDimensionProvider.php similarity index 86% rename from lib/internal/Magento/Framework/Indexer/DimensionProvider.php rename to lib/internal/Magento/Framework/Indexer/MultiDimensionProvider.php index 0e4ef20d2f37a..3f01b87802e44 100644 --- a/lib/internal/Magento/Framework/Indexer/DimensionProvider.php +++ b/lib/internal/Magento/Framework/Indexer/MultiDimensionProvider.php @@ -6,7 +6,7 @@ namespace Magento\Framework\Indexer; -class DimensionProvider implements DimensionProviderInterface +class MultiDimensionProvider implements MultiDimensionProviderInterface { /** * @var array @@ -29,10 +29,10 @@ class DimensionProvider implements DimensionProviderInterface private $dimensionsCount; /** - * @param array $dimensionDataProviders + * @param DimensionProviderInterface[] $dimensionProviders */ - public function __construct(array $dimensionDataProviders = []) { - foreach ($dimensionDataProviders as $dimensionDataProvider) { + public function __construct(array $dimensionProviders = []) { + foreach ($dimensionProviders as $dimensionDataProvider) { $this->addDimensionDataProvider($dimensionDataProvider); } } @@ -46,7 +46,9 @@ public function getIterator(): \Traversable yield $this->getCurrentDimension(); $this->setNextDimension(); } - + if (!$dimensionsCount) { + yield [[]]; + } } public function count(): int @@ -72,10 +74,6 @@ private function getCurrentDimension(): array /** @var Dimension $dimension */ $dimension = $dimensionIterator->current(); - if (is_array($dimension)) { - $dimension = reset($dimension); - } - $dimensions[$dimension->getName()] = $dimension; } @@ -103,6 +101,7 @@ private function addDimensionDataProvider(DimensionProviderInterface $dimensionD private function initDataIterators() { + $this->dimensionsIterators = []; foreach ($this->dimensionsDataProviders as $dimensionDataProvider) { $this->dimensionsIterators[] = $dimensionDataProvider->getIterator(); } diff --git a/lib/internal/Magento/Framework/Indexer/MultiDimensionProviderInterface.php b/lib/internal/Magento/Framework/Indexer/MultiDimensionProviderInterface.php new file mode 100644 index 0000000000000..745bd4989a9b7 --- /dev/null +++ b/lib/internal/Magento/Framework/Indexer/MultiDimensionProviderInterface.php @@ -0,0 +1,21 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Framework\Indexer; + +/** + * Provide a list of multi dimensions. + * Used for multiply several dimension and return array of dimensions during iteration + */ +interface MultiDimensionProviderInterface extends \IteratorAggregate +{ + /** + * Returns [\Magento\Framework\Indexer\Dimension, ...] for each iteration + * @return \Traversable|[\Magento\Framework\Indexer\Dimension,] + */ + public function getIterator(): \Traversable; +} From 484eb85c7bfbb08e018d9a832aa826402d9bdcde Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov <slopukhov@magento.com> Date: Tue, 29 May 2018 15:39:53 +0300 Subject: [PATCH 056/206] MAGETWO-91874: Adapt Full Action to use dimension --- .../Magento/Framework/Indexer/MultiDimensionProvider.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/internal/Magento/Framework/Indexer/MultiDimensionProvider.php b/lib/internal/Magento/Framework/Indexer/MultiDimensionProvider.php index 3f01b87802e44..21274fe633075 100644 --- a/lib/internal/Magento/Framework/Indexer/MultiDimensionProvider.php +++ b/lib/internal/Magento/Framework/Indexer/MultiDimensionProvider.php @@ -31,7 +31,8 @@ class MultiDimensionProvider implements MultiDimensionProviderInterface /** * @param DimensionProviderInterface[] $dimensionProviders */ - public function __construct(array $dimensionProviders = []) { + public function __construct(array $dimensionProviders = []) + { foreach ($dimensionProviders as $dimensionDataProvider) { $this->addDimensionDataProvider($dimensionDataProvider); } @@ -47,7 +48,7 @@ public function getIterator(): \Traversable $this->setNextDimension(); } if (!$dimensionsCount) { - yield [[]]; + yield []; } } @@ -96,7 +97,6 @@ private function addDimensionDataProvider(DimensionProviderInterface $dimensionD { $this->dimensionsDataProviders[] = $dimensionDataProvider; $this->dimensionsProvidersCount++; - } private function initDataIterators() From c56b8777a98b92fcd24870f2c19325a8c6213216 Mon Sep 17 00:00:00 2001 From: Andrii Voskoboinikov <avoskoboinikov@magento.com> Date: Tue, 29 May 2018 16:01:02 +0300 Subject: [PATCH 057/206] MAGETWO-91877: Adapt custom options select to use dimensions --- .../Product/Indexer/Price/DefaultPrice.php | 174 ++---------- .../Price/Query/CustomOptionsPrice.php | 267 ++++++++++++++++++ 2 files changed, 283 insertions(+), 158 deletions(-) create mode 100644 app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/CustomOptionsPrice.php diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php index 9ff1a65eab707..52faccf745d12 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php @@ -8,6 +8,7 @@ use Magento\Catalog\Model\Indexer\Product\Price\DimensionProviderFactory; use Magento\Catalog\Model\ResourceModel\Product\Indexer\AbstractIndexer; use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\Query\BaseFinalPrice; +use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\Query\CustomOptionsPrice; use Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProvider; use Magento\Framework\App\ObjectManager; use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; @@ -73,6 +74,11 @@ class DefaultPrice extends AbstractIndexer implements PriceInterface */ private $baseFinalPrice; + /** + * @var CustomOptionsPrice + */ + private $customOptionsPrice; + /** * @var DimensionCollectionFactory */ @@ -97,6 +103,7 @@ public function __construct( $connectionName = null, IndexTableStructureFactory $indexTableStructureFactory = null, BaseFinalPrice $baseFinalPrice = null, + CustomOptionsPrice $customOptionsPrice = null, DimensionProviderFactory $dimensionCollectionFactory = null, array $priceModifiers = [] ) { @@ -116,6 +123,7 @@ public function __construct( $this->priceModifiers[] = $priceModifier; } $this->baseFinalPrice = $baseFinalPrice ?? ObjectManager::getInstance()->get(BaseFinalPrice::class); + $this->customOptionsPrice = $baseFinalPrice ?? ObjectManager::getInstance()->get(CustomOptionsPrice::class); $this->dimensionCollectionFactory = $dimensionCollectionFactory ?? ObjectManager::getInstance()->get(DimensionProviderFactory::class); } @@ -438,177 +446,27 @@ protected function _applyCustomOption() { $connection = $this->getConnection(); $finalPriceTable = $this->_getDefaultFinalPriceTable(); - $coaTable = $this->_getCustomOptionAggregateTable(); - $copTable = $this->_getCustomOptionPriceTable(); - $metadata = $this->getMetadataPool()->getMetadata(\Magento\Catalog\Api\Data\ProductInterface::class); + $coaTable = $this->_getCustomOptionAggregateTable(); $this->_prepareCustomOptionAggregateTable(); - $this->_prepareCustomOptionPriceTable(); - - $select = $connection->select()->from( - ['i' => $finalPriceTable], - ['entity_id', 'customer_group_id', 'website_id'] - )->join( - ['e' => $this->getTable('catalog_product_entity')], - 'e.entity_id = i.entity_id', - [] - )->join( - ['cw' => $this->getTable('store_website')], - 'cw.website_id = i.website_id', - [] - )->join( - ['csg' => $this->getTable('store_group')], - 'csg.group_id = cw.default_group_id', - [] - )->join( - ['cs' => $this->getTable('store')], - 'cs.store_id = csg.default_store_id', - [] - )->join( - ['o' => $this->getTable('catalog_product_option')], - 'o.product_id = e.' . $metadata->getLinkField(), - ['option_id'] - )->join( - ['ot' => $this->getTable('catalog_product_option_type_value')], - 'ot.option_id = o.option_id', - [] - )->join( - ['otpd' => $this->getTable('catalog_product_option_type_price')], - 'otpd.option_type_id = ot.option_type_id AND otpd.store_id = 0', - [] - )->joinLeft( - ['otps' => $this->getTable('catalog_product_option_type_price')], - 'otps.option_type_id = otpd.option_type_id AND otpd.store_id = cs.store_id', - [] - )->group( - ['i.entity_id', 'i.customer_group_id', 'i.website_id', 'o.option_id'] - ); - $optPriceType = $connection->getCheckSql('otps.option_type_price_id > 0', 'otps.price_type', 'otpd.price_type'); - $optPriceValue = $connection->getCheckSql('otps.option_type_price_id > 0', 'otps.price', 'otpd.price'); - $minPriceRound = new \Zend_Db_Expr("ROUND(i.price * ({$optPriceValue} / 100), 4)"); - $minPriceExpr = $connection->getCheckSql("{$optPriceType} = 'fixed'", $optPriceValue, $minPriceRound); - $minPriceMin = new \Zend_Db_Expr("MIN({$minPriceExpr})"); - $minPrice = $connection->getCheckSql("MIN(o.is_require) = 1", $minPriceMin, '0'); - - $tierPriceRound = new \Zend_Db_Expr("ROUND(i.base_tier * ({$optPriceValue} / 100), 4)"); - $tierPriceExpr = $connection->getCheckSql("{$optPriceType} = 'fixed'", $optPriceValue, $tierPriceRound); - $tierPriceMin = new \Zend_Db_Expr("MIN({$tierPriceExpr})"); - $tierPriceValue = $connection->getCheckSql("MIN(o.is_require) > 0", $tierPriceMin, 0); - $tierPrice = $connection->getCheckSql("MIN(i.base_tier) IS NOT NULL", $tierPriceValue, "NULL"); - - $maxPriceRound = new \Zend_Db_Expr("ROUND(i.price * ({$optPriceValue} / 100), 4)"); - $maxPriceExpr = $connection->getCheckSql("{$optPriceType} = 'fixed'", $optPriceValue, $maxPriceRound); - $maxPrice = $connection->getCheckSql( - "(MIN(o.type)='radio' OR MIN(o.type)='drop_down')", - "MAX({$maxPriceExpr})", - "SUM({$maxPriceExpr})" - ); - - $select->columns( - [ - 'min_price' => $minPrice, - 'max_price' => $maxPrice, - 'tier_price' => $tierPrice, - ] - ); + $copTable = $this->_getCustomOptionPriceTable(); + $this->_prepareCustomOptionPriceTable(); + $select = $this->customOptionsPrice->getSelectForOptionsWithMultipleValues($finalPriceTable); $query = $select->insertFromSelect($coaTable); $connection->query($query); - $select = $connection->select()->from( - ['i' => $finalPriceTable], - ['entity_id', 'customer_group_id', 'website_id'] - )->join( - ['e' => $this->getTable('catalog_product_entity')], - 'e.entity_id = i.entity_id', - [] - )->join( - ['cw' => $this->getTable('store_website')], - 'cw.website_id = i.website_id', - [] - )->join( - ['csg' => $this->getTable('store_group')], - 'csg.group_id = cw.default_group_id', - [] - )->join( - ['cs' => $this->getTable('store')], - 'cs.store_id = csg.default_store_id', - [] - )->join( - ['o' => $this->getTable('catalog_product_option')], - 'o.product_id = e.' . $metadata->getLinkField(), - ['option_id'] - )->join( - ['opd' => $this->getTable('catalog_product_option_price')], - 'opd.option_id = o.option_id AND opd.store_id = 0', - [] - )->joinLeft( - ['ops' => $this->getTable('catalog_product_option_price')], - 'ops.option_id = opd.option_id AND ops.store_id = cs.store_id', - [] - ); - - $optPriceType = $connection->getCheckSql('ops.option_price_id > 0', 'ops.price_type', 'opd.price_type'); - $optPriceValue = $connection->getCheckSql('ops.option_price_id > 0', 'ops.price', 'opd.price'); - - $minPriceRound = new \Zend_Db_Expr("ROUND(i.price * ({$optPriceValue} / 100), 4)"); - $priceExpr = $connection->getCheckSql("{$optPriceType} = 'fixed'", $optPriceValue, $minPriceRound); - $minPrice = $connection->getCheckSql("{$priceExpr} > 0 AND o.is_require = 1", $priceExpr, 0); - - $maxPrice = $priceExpr; - - $tierPriceRound = new \Zend_Db_Expr("ROUND(i.base_tier * ({$optPriceValue} / 100), 4)"); - $tierPriceExpr = $connection->getCheckSql("{$optPriceType} = 'fixed'", $optPriceValue, $tierPriceRound); - $tierPriceValue = $connection->getCheckSql("{$tierPriceExpr} > 0 AND o.is_require = 1", $tierPriceExpr, 0); - $tierPrice = $connection->getCheckSql("i.base_tier IS NOT NULL", $tierPriceValue, "NULL"); - - $select->columns( - [ - 'min_price' => $minPrice, - 'max_price' => $maxPrice, - 'tier_price' => $tierPrice, - ] - ); - + $select = $this->customOptionsPrice->getSelectForOptionsWithOneValue($finalPriceTable); $query = $select->insertFromSelect($coaTable); $connection->query($query); - $select = $connection->select()->from( - [$coaTable], - [ - 'entity_id', - 'customer_group_id', - 'website_id', - 'min_price' => 'SUM(min_price)', - 'max_price' => 'SUM(max_price)', - 'tier_price' => 'SUM(tier_price)', - ] - )->group( - ['entity_id', 'customer_group_id', 'website_id'] - ); + $select = $this->customOptionsPrice->getSelectAggregated($coaTable); $query = $select->insertFromSelect($copTable); $connection->query($query); - $table = ['i' => $finalPriceTable]; - $select = $connection->select()->join( - ['io' => $copTable], - 'i.entity_id = io.entity_id AND i.customer_group_id = io.customer_group_id' . - ' AND i.website_id = io.website_id', - [] - ); - $select->columns( - [ - 'min_price' => new \Zend_Db_Expr('i.min_price + io.min_price'), - 'max_price' => new \Zend_Db_Expr('i.max_price + io.max_price'), - 'tier_price' => $connection->getCheckSql( - 'i.tier_price IS NOT NULL', - 'i.tier_price + io.tier_price', - 'NULL' - ), - ] - ); - $query = $select->crossUpdateFromSelect($table); + $select = $this->customOptionsPrice->getSelectForUpdate($copTable); + $query = $select->crossUpdateFromSelect(['i' => $finalPriceTable]); $connection->query($query); $connection->delete($coaTable); diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/CustomOptionsPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/CustomOptionsPrice.php new file mode 100644 index 0000000000000..3122c418203d8 --- /dev/null +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/CustomOptionsPrice.php @@ -0,0 +1,267 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\Query; + +use \Magento\Catalog\Api\Data\ProductInterface; + +class CustomOptionsPrice +{ + /** + * @var \Magento\Framework\App\ResourceConnection + */ + private $resource; + + /** + * @var \Magento\Framework\EntityManager\MetadataPool + */ + private $metadataPool; + + /** + * @var \Magento\Framework\DB\Sql\ColumnValueExpression + */ + private $columnValueExpressionFactory; + + /** + * @var string + */ + private $connectionName; + + /** + * @param \Magento\Framework\App\ResourceConnection $resource + * @param \Magento\Framework\EntityManager\MetadataPool $metadataPool + * @param string $connectionName + */ + public function __construct( + \Magento\Framework\App\ResourceConnection $resource, + \Magento\Framework\EntityManager\MetadataPool $metadataPool, + \Magento\Framework\DB\Sql\ColumnValueExpressionFactory $columnValueExpressionFactory, + $connectionName = 'indexer' + ) { + $this->resource = $resource; + $this->metadataPool = $metadataPool; + $this->connectionName = $connectionName; + $this->columnValueExpressionFactory = $columnValueExpressionFactory; + } + + public function getSelectForOptionsWithMultipleValues($sourceTable) + { + $connection = $this->resource->getConnection($this->connectionName); + $metadata = $this->metadataPool->getMetadata(ProductInterface::class); + + $select = $connection->select() + ->from( + ['i' => $sourceTable], + ['entity_id', 'customer_group_id', 'website_id'] + )->join( + ['e' => $this->getTable('catalog_product_entity')], + 'e.entity_id = i.entity_id', + [] + )->join( + ['cw' => $this->getTable('store_website')], + 'cw.website_id = i.website_id', + [] + )->join( + ['csg' => $this->getTable('store_group')], + 'csg.group_id = cw.default_group_id', + [] + )->join( + ['cs' => $this->getTable('store')], + 'cs.store_id = csg.default_store_id', + [] + )->join( + ['o' => $this->getTable('catalog_product_option')], + 'o.product_id = e.' . $metadata->getLinkField(), + ['option_id'] + )->join( + ['ot' => $this->getTable('catalog_product_option_type_value')], + 'ot.option_id = o.option_id', + [] + )->join( + ['otpd' => $this->getTable('catalog_product_option_type_price')], + 'otpd.option_type_id = ot.option_type_id AND otpd.store_id = 0', + [] + )->joinLeft( + ['otps' => $this->getTable('catalog_product_option_type_price')], + 'otps.option_type_id = otpd.option_type_id AND otpd.store_id = cs.store_id', + [] + )->group( + ['i.entity_id', 'i.customer_group_id', 'i.website_id', 'o.option_id'] + ); + + $optPriceType = $connection->getCheckSql('otps.option_type_price_id > 0', 'otps.price_type', 'otpd.price_type'); + $optPriceValue = $connection->getCheckSql('otps.option_type_price_id > 0', 'otps.price', 'otpd.price'); + $minPriceRound = $this->columnValueExpressionFactory + ->create([ + 'expression' => "ROUND(i.price * ({$optPriceValue} / 100), 4)" + ]); + $minPriceExpr = $connection->getCheckSql("{$optPriceType} = 'fixed'", $optPriceValue, $minPriceRound); + $minPriceMin = $this->columnValueExpressionFactory + ->create([ + 'expression' => "MIN({$minPriceExpr})" + ]); + $minPrice = $connection->getCheckSql("MIN(o.is_require) = 1", $minPriceMin, '0'); + + $tierPriceRound = $this->columnValueExpressionFactory + ->create([ + 'expression' => "ROUND(i.base_tier * ({$optPriceValue} / 100), 4)" + ]); + $tierPriceExpr = $connection->getCheckSql("{$optPriceType} = 'fixed'", $optPriceValue, $tierPriceRound); + $tierPriceMin = $this->columnValueExpressionFactory + ->create([ + 'expression' => "MIN({$tierPriceExpr})" + ]); + $tierPriceValue = $connection->getCheckSql("MIN(o.is_require) > 0", $tierPriceMin, 0); + $tierPrice = $connection->getCheckSql("MIN(i.base_tier) IS NOT NULL", $tierPriceValue, "NULL"); + + $maxPriceRound = $this->columnValueExpressionFactory + ->create([ + 'expression' => "ROUND(i.price * ({$optPriceValue} / 100), 4)" + ]); + $maxPriceExpr = $connection->getCheckSql("{$optPriceType} = 'fixed'", $optPriceValue, $maxPriceRound); + $maxPrice = $connection->getCheckSql( + "(MIN(o.type)='radio' OR MIN(o.type)='drop_down')", + "MAX({$maxPriceExpr})", + "SUM({$maxPriceExpr})" + ); + + $select->columns( + [ + 'min_price' => $minPrice, + 'max_price' => $maxPrice, + 'tier_price' => $tierPrice, + ] + ); + + return $select; + } + + public function getSelectForOptionsWithOneValue($sourceTable) + { + $connection = $this->resource->getConnection($this->connectionName); + $metadata = $this->metadataPool->getMetadata(ProductInterface::class); + + $select = $connection->select() + ->from( + ['i' => $sourceTable], + ['entity_id', 'customer_group_id', 'website_id'] + )->join( + ['e' => $this->getTable('catalog_product_entity')], + 'e.entity_id = i.entity_id', + [] + )->join( + ['cw' => $this->getTable('store_website')], + 'cw.website_id = i.website_id', + [] + )->join( + ['csg' => $this->getTable('store_group')], + 'csg.group_id = cw.default_group_id', + [] + )->join( + ['cs' => $this->getTable('store')], + 'cs.store_id = csg.default_store_id', + [] + )->join( + ['o' => $this->getTable('catalog_product_option')], + 'o.product_id = e.' . $metadata->getLinkField(), + ['option_id'] + )->join( + ['opd' => $this->getTable('catalog_product_option_price')], + 'opd.option_id = o.option_id AND opd.store_id = 0', + [] + )->joinLeft( + ['ops' => $this->getTable('catalog_product_option_price')], + 'ops.option_id = opd.option_id AND ops.store_id = cs.store_id', + [] + ); + + $optPriceType = $connection->getCheckSql('ops.option_price_id > 0', 'ops.price_type', 'opd.price_type'); + $optPriceValue = $connection->getCheckSql('ops.option_price_id > 0', 'ops.price', 'opd.price'); + + $minPriceRound = $this->columnValueExpressionFactory + ->create([ + 'expression' => "ROUND(i.price * ({$optPriceValue} / 100), 4)" + ]); + $priceExpr = $connection->getCheckSql("{$optPriceType} = 'fixed'", $optPriceValue, $minPriceRound); + $minPrice = $connection->getCheckSql("{$priceExpr} > 0 AND o.is_require = 1", $priceExpr, 0); + + $maxPrice = $priceExpr; + + $tierPriceRound = $this->columnValueExpressionFactory + ->create([ + 'expression' => "ROUND(i.base_tier * ({$optPriceValue} / 100), 4)" + ]); + $tierPriceExpr = $connection->getCheckSql("{$optPriceType} = 'fixed'", $optPriceValue, $tierPriceRound); + $tierPriceValue = $connection->getCheckSql("{$tierPriceExpr} > 0 AND o.is_require = 1", $tierPriceExpr, 0); + $tierPrice = $connection->getCheckSql("i.base_tier IS NOT NULL", $tierPriceValue, "NULL"); + + $select->columns( + [ + 'min_price' => $minPrice, + 'max_price' => $maxPrice, + 'tier_price' => $tierPrice, + ] + ); + + return $select; + } + + public function getSelectAggregated($sourceTable) + { + $connection = $this->resource->getConnection($this->connectionName); + + $select = $connection->select() + ->from( + [$sourceTable], + [ + 'entity_id', + 'customer_group_id', + 'website_id', + 'min_price' => 'SUM(min_price)', + 'max_price' => 'SUM(max_price)', + 'tier_price' => 'SUM(tier_price)', + ] + )->group( + ['entity_id', 'customer_group_id', 'website_id'] + ); + + return $select; + } + + public function getSelectForUpdate($sourceTable) + { + $connection = $this->resource->getConnection($this->connectionName); + + $select = $connection->select()->join( + ['io' => $sourceTable], + 'i.entity_id = io.entity_id AND i.customer_group_id = io.customer_group_id' . + ' AND i.website_id = io.website_id', + [] + ); + $select->columns( + [ + 'min_price' => new \Zend_Db_Expr('i.min_price + io.min_price'), + 'max_price' => new \Zend_Db_Expr('i.max_price + io.max_price'), + 'tier_price' => $connection->getCheckSql( + 'i.tier_price IS NOT NULL', + 'i.tier_price + io.tier_price', + 'NULL' + ), + ] + ); + + return $select; + } + + /** + * @param string $tableName + * @return string + */ + private function getTable($tableName) + { + return $this->resource->getTableName($tableName, $this->connectionName); + } +} From 0fc30a985ae3a458df0731e0a4ef948874227b90 Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov <slopukhov@magento.com> Date: Tue, 29 May 2018 16:32:11 +0300 Subject: [PATCH 058/206] MAGETWO-91874: Adapt Full Action to use dimension --- .../Model/Indexer/Product/Price/DimensionProviderFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionProviderFactory.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionProviderFactory.php index 03d9aa354b9ab..733730ccadeab 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionProviderFactory.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionProviderFactory.php @@ -90,7 +90,7 @@ private function getDataProviders($modeConfigurationKey): array ); } - $providers[] = $this->dimensionProviders[$modeDataProviderName]; + $providers[] = clone $this->dimensionProviders[$modeDataProviderName]; } return $providers; From cb51aad2b069dd8cde01c4c9a209bc70750b7c20 Mon Sep 17 00:00:00 2001 From: Andrii Voskoboinikov <avoskoboinikov@magento.com> Date: Tue, 29 May 2018 16:32:31 +0300 Subject: [PATCH 059/206] MAGETWO-91877: Adapt custom options select to use dimensions --- .../Product/Indexer/Price/DefaultPrice.php | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php index 52faccf745d12..1c844a53c162a 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php @@ -444,6 +444,11 @@ private function applyDiscountPrices(IndexTableStructure $finalPriceTable) */ protected function _applyCustomOption() { + // no need to run all queries if current products have no custom options + if (!$this->checkIfCustomOptionsExist()) { + return $this; + } + $connection = $this->getConnection(); $finalPriceTable = $this->_getDefaultFinalPriceTable(); @@ -453,18 +458,22 @@ protected function _applyCustomOption() $copTable = $this->_getCustomOptionPriceTable(); $this->_prepareCustomOptionPriceTable(); + // prepare prices for products with custom options that has multiple values $select = $this->customOptionsPrice->getSelectForOptionsWithMultipleValues($finalPriceTable); $query = $select->insertFromSelect($coaTable); $connection->query($query); + // prepare prices for products with custom options that has single value $select = $this->customOptionsPrice->getSelectForOptionsWithOneValue($finalPriceTable); $query = $select->insertFromSelect($coaTable); $connection->query($query); + // aggregate prices from previous two cases into one table $select = $this->customOptionsPrice->getSelectAggregated($coaTable); $query = $select->insertFromSelect($copTable); $connection->query($query); + // update tmp price index with prices from custom options (from previous aggregated table) $select = $this->customOptionsPrice->getSelectForUpdate($copTable); $query = $select->crossUpdateFromSelect(['i' => $finalPriceTable]); $connection->query($query); @@ -475,6 +484,22 @@ protected function _applyCustomOption() return $this; } + private function checkIfCustomOptionsExist() + { + $select = $this->getConnection() + ->select() + ->from( + ['i' => $this->_getDefaultFinalPriceTable()], + ['entity_id'] + )->join( + ['o' => $this->getTable('catalog_product_option')], + 'o.product_id = i.entity_id', + [] + ); + + return !empty($this->getConnection()->fetchRow($select)); + } + /** * Mode Final Prices index to primary temporary index table * From 0bffe80056adcac42c7fbbe853e4a59842850494 Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov <slopukhov@magento.com> Date: Tue, 29 May 2018 16:38:39 +0300 Subject: [PATCH 060/206] MAGETWO-91886: Add ability to configure dimensions --- .../PriceIndexerDimensionsModeSetCommand.php | 8 +++--- .../Indexer/Product/Price/ModeSwitcher.php | 22 ++++++++-------- .../Indexer/Product/Price/TableMaintainer.php | 26 +++++++++---------- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/app/code/Magento/Catalog/Console/Command/PriceIndexerDimensionsModeSetCommand.php b/app/code/Magento/Catalog/Console/Command/PriceIndexerDimensionsModeSetCommand.php index 4c937ecb1179d..03be0eb8c6f82 100644 --- a/app/code/Magento/Catalog/Console/Command/PriceIndexerDimensionsModeSetCommand.php +++ b/app/code/Magento/Catalog/Console/Command/PriceIndexerDimensionsModeSetCommand.php @@ -107,12 +107,12 @@ protected function execute(InputInterface $input, OutputInterface $output) ModeSwitcher::INPUT_KEY_NONE; if ($previousMode !== $currentMode) { - $this->configWriter->saveConfig(ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE, $currentMode); - //Create new tables and move data $this->modeSwitcher->createTables($currentMode); $this->modeSwitcher->moveData($currentMode, $previousMode); + //Change config options + $this->configWriter->saveConfig(ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE, $currentMode); $this->cacheTypeList->cleanType('config'); $indexer->invalidate(); @@ -145,7 +145,7 @@ protected function execute(InputInterface $input, OutputInterface $output) * * @return InputOption[] */ - public function getInputList() + public function getInputList(): array { $modeOptions[] = new InputArgument( self::INPUT_KEY_MODE, @@ -163,7 +163,7 @@ public function getInputList() * @param InputInterface $input * @return string[] */ - public function validate(InputInterface $input) + public function validate(InputInterface $input): array { $errors = []; diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/ModeSwitcher.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/ModeSwitcher.php index 4326023293521..538deb3bac84f 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/ModeSwitcher.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/ModeSwitcher.php @@ -67,9 +67,9 @@ class ModeSwitcher /** * DimensionCollectionFactory * - * @var \Magento\Catalog\Model\Indexer\Product\Price\DimensionCollectionFactory + * @var \Magento\Catalog\Model\Indexer\Product\Price\DimensionProviderFactory */ - private $dimensionCollectionFactory; + private $dimensionProviderFactory; /** * @var array|null @@ -83,7 +83,7 @@ class ModeSwitcher * @param \Magento\Store\Api\WebsiteRepositoryInterface $websiteRepository * @param \Magento\Customer\Api\GroupRepositoryInterface $customerGroupRepository * @param \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder - * @param \Magento\Catalog\Model\Indexer\Product\Price\DimensionCollectionFactory $dimensionCollectionFactory + * @param \Magento\Catalog\Model\Indexer\Product\Price\DimensionProviderFactory $dimensionProviderFactory */ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $configReader, @@ -92,7 +92,7 @@ public function __construct( \Magento\Store\Api\WebsiteRepositoryInterface $websiteRepository, \Magento\Customer\Api\GroupRepositoryInterface $customerGroupRepository, \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder, - \Magento\Catalog\Model\Indexer\Product\Price\DimensionProviderFactory $dimensionCollectionFactory + \Magento\Catalog\Model\Indexer\Product\Price\DimensionProviderFactory $dimensionProviderFactory ) { $this->configReader = $configReader; $this->configWriter = $configWriter; @@ -100,7 +100,7 @@ public function __construct( $this->websiteRepository = $websiteRepository; $this->customerGroupRepository = $customerGroupRepository; $this->searchCriteriaBuilder = $searchCriteriaBuilder; - $this->dimensionCollectionFactory = $dimensionCollectionFactory; + $this->dimensionProviderFactory = $dimensionProviderFactory; } /** @@ -110,7 +110,7 @@ public function __construct( * * @return void */ - public function createTables($currentMode) + public function createTables(string $currentMode) { foreach ($this->getDimensionsArray($currentMode) as $dimensions) { if (!empty($dimensions)) { @@ -127,7 +127,7 @@ public function createTables($currentMode) * * @return void */ - public function moveData($currentMode, $previousMode) + public function moveData(string $currentMode, string $previousMode) { $dimensionsArrayForCurrentMode = $this->getDimensionsArray($currentMode); $dimensionsArrayForPreviousMode = $this->getDimensionsArray($previousMode); @@ -157,7 +157,7 @@ public function moveData($currentMode, $previousMode) * * @return void */ - public function dropTables($previousMode) + public function dropTables(string $previousMode) { foreach ($this->getDimensionsArray($previousMode) as $dimensions) { if (empty($dimensions)) { @@ -175,13 +175,13 @@ public function dropTables($previousMode) * * @return array */ - private function getDimensionsArray($mode) + private function getDimensionsArray(string $mode): \Magento\Framework\Indexer\MultiDimensionProviderInterface { if (isset($this->dimensionsArray[$mode])) { return $this->dimensionsArray[$mode]; } - $this->dimensionsArray[$mode] = $this->dimensionCollectionFactory->createByMode($mode); + $this->dimensionsArray[$mode] = $this->dimensionProviderFactory->createByMode($mode); return $this->dimensionsArray[$mode]; } @@ -195,7 +195,7 @@ private function getDimensionsArray($mode) * * @return void */ - private function insertFromOldTablesToNew($newTable, $oldTable, $dimensions = []) + private function insertFromOldTablesToNew(string $newTable, string $oldTable, array $dimensions = []) { $select = $this->tableMaintainer->getConnection()->select()->from($oldTable); diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php index cc3c72edab66f..2bae7dfa74a93 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php @@ -77,10 +77,10 @@ public function getConnection() /** * Return validated table name * - * @param string|string[] $table + * @param string $table * @return string */ - private function getTable($table) + private function getTable(string $table): string { return $this->resource->getTableName($table); } @@ -93,7 +93,7 @@ private function getTable($table) * * @return void */ - private function createTable($mainTableName, $newTableName) + private function createTable(string $mainTableName, string $newTableName) { if (!$this->getConnection()->isTableExists($newTableName)) { $this->getConnection()->createTable( @@ -109,7 +109,7 @@ private function createTable($mainTableName, $newTableName) * * @return void */ - private function dropTable($tableName) + private function dropTable(string $tableName) { if ($this->getConnection()->isTableExists($tableName)) { $this->getConnection()->dropTable($tableName); @@ -123,7 +123,7 @@ private function dropTable($tableName) * * @return void */ - private function truncateTable($tableName) + private function truncateTable(string $tableName) { if ($this->getConnection()->isTableExists($tableName)) { $this->getConnection()->truncateTable($tableName); @@ -137,7 +137,7 @@ private function truncateTable($tableName) * * @return string */ - private function getArrayKeyForTmpTable($dimensions) + private function getArrayKeyForTmpTable(array $dimensions): string { $key = 'tmp'; foreach ($dimensions as $dimension) { @@ -153,7 +153,7 @@ private function getArrayKeyForTmpTable($dimensions) * * @return string */ - public function getMainTable($dimensions) + public function getMainTable(array $dimensions): string { return $this->tableResolver->resolve(self::MAIN_INDEX_TABLE, $dimensions); } @@ -165,7 +165,7 @@ public function getMainTable($dimensions) * * @return void */ - public function createTablesForDimensions($dimensions) + public function createTablesForDimensions(array $dimensions) { $mainTableName = $this->getMainTable($dimensions); //Create index table for dimensions based on on main replica table @@ -190,7 +190,7 @@ public function createTablesForDimensions($dimensions) * * @return void */ - public function dropTablesForDimensions($dimensions) + public function dropTablesForDimensions(array $dimensions) { $mainTableName = $this->getMainTable($dimensions); $this->dropTable($mainTableName); @@ -206,7 +206,7 @@ public function dropTablesForDimensions($dimensions) * * @return void */ - public function truncateTablesForDimensions($dimensions) + public function truncateTablesForDimensions(array $dimensions) { $mainTableName = $this->getMainTable($dimensions); $this->truncateTable($mainTableName); @@ -222,7 +222,7 @@ public function truncateTablesForDimensions($dimensions) * * @return string */ - public function getMainReplicaTable($dimensions) + public function getMainReplicaTable(array $dimensions) { return $this->getMainTable($dimensions) . $this->additionalTableSuffix; } @@ -234,7 +234,7 @@ public function getMainReplicaTable($dimensions) * * @return void */ - public function createMainTmpTable($dimensions) + public function createMainTmpTable(array $dimensions) { if (!isset($this->mainTmpTable[$this->getArrayKeyForTmpTable($dimensions)])) { $originTableName = $this->getMainTable($dimensions); @@ -251,7 +251,7 @@ public function createMainTmpTable($dimensions) * * @return string */ - public function getMainTmpTable($dimensions) + public function getMainTmpTable(array $dimensions) { return $this->mainTmpTable[$this->getArrayKeyForTmpTable($dimensions)]; } From 400cd9f0c07cddc885f950614d546dc8854afb11 Mon Sep 17 00:00:00 2001 From: Andrii Voskoboinikov <avoskoboinikov@magento.com> Date: Tue, 29 May 2018 17:07:18 +0300 Subject: [PATCH 061/206] MAGETWO-91874: Adapt Full Action to use dimension --- .../Catalog/Model/Indexer/Product/Price/Action/Full.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php index 1f7ff3794e2de..cb1f07b818449 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php @@ -170,12 +170,6 @@ private function prepareTables() private function switchTables() { - // Switch default table - $this->activeTableSwitcher->switchTable( - $this->_defaultIndexerResource->getConnection(), - [$this->_defaultIndexerResource->getMainTable()] - ); - $currentMode = $this->configReader ->getValue(ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE) ?: ModeSwitcher::INPUT_KEY_NONE; @@ -186,7 +180,7 @@ private function switchTables() $dimensionTables = []; foreach ($dimensionsProviders as $dimension) { - $dimensionTables[] = $this->dimensionTableMaintainer->getMainReplicaTable($dimension); + $dimensionTables[] = $this->dimensionTableMaintainer->getMainTable($dimension); } if (count($dimensionTables) > 0) { From 6f7246e88afcd894dbf64cfe5226e9946116628b Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov <slopukhov@magento.com> Date: Wed, 30 May 2018 09:45:50 +0300 Subject: [PATCH 062/206] MAGETWO-91886: Add ability to configure dimensions --- .../Category/Product/TableMaintainer.php | 6 +- .../Indexer/Product/Price/TableMaintainer.php | 10 +- app/code/Magento/Catalog/etc/adminhtml/di.xml | 3 - ...iceIndexerDimensionsModeSetCommandTest.php | 153 ++++++++++++++++++ 4 files changed, 165 insertions(+), 7 deletions(-) create mode 100644 dev/tests/integration/testsuite/Magento/Setup/Console/Command/PriceIndexerDimensionsModeSetCommandTest.php diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Product/TableMaintainer.php b/app/code/Magento/Catalog/Model/Indexer/Category/Product/TableMaintainer.php index d2f8925d09a7b..685e3cb045867 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Category/Product/TableMaintainer.php +++ b/app/code/Magento/Catalog/Model/Indexer/Category/Product/TableMaintainer.php @@ -205,6 +205,10 @@ public function createMainTmpTable(int $storeId) */ public function getMainTmpTable(int $storeId) { - return $this->mainTmpTable[$storeId]; + if (isset($this->mainTmpTable[$storeId])) { + return $this->mainTmpTable[$storeId]; + } else { + return null; + } } } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php index 2bae7dfa74a93..1c65c663fbbc3 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php @@ -222,7 +222,7 @@ public function truncateTablesForDimensions(array $dimensions) * * @return string */ - public function getMainReplicaTable(array $dimensions) + public function getMainReplicaTable(array $dimensions): string { return $this->getMainTable($dimensions) . $this->additionalTableSuffix; } @@ -249,10 +249,14 @@ public function createMainTmpTable(array $dimensions) * * @param Dimension[] $dimensions * - * @return string + * @return string|null */ public function getMainTmpTable(array $dimensions) { - return $this->mainTmpTable[$this->getArrayKeyForTmpTable($dimensions)]; + if (isset($this->mainTmpTable[$this->getArrayKeyForTmpTable($dimensions)])) { + return $this->mainTmpTable[$this->getArrayKeyForTmpTable($dimensions)]; + } else { + return null; + } } } diff --git a/app/code/Magento/Catalog/etc/adminhtml/di.xml b/app/code/Magento/Catalog/etc/adminhtml/di.xml index 130c387924701..9739ee28a6dae 100644 --- a/app/code/Magento/Catalog/etc/adminhtml/di.xml +++ b/app/code/Magento/Catalog/etc/adminhtml/di.xml @@ -193,7 +193,4 @@ <type name="Magento\Eav\Api\AttributeSetRepositoryInterface"> <plugin name="remove_products" type="Magento\Catalog\Plugin\Model\AttributeSetRepository\RemoveProducts"/> </type> - <type name="Magento\Framework\App\ResourceConnection"> - <plugin name="get_catalog_category_product_index_table_name" type="Magento\Catalog\Model\Indexer\Category\Product\Plugin\TableResolver"/> - </type> </config> diff --git a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/PriceIndexerDimensionsModeSetCommandTest.php b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/PriceIndexerDimensionsModeSetCommandTest.php new file mode 100644 index 0000000000000..9aa6f30d8362d --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/PriceIndexerDimensionsModeSetCommandTest.php @@ -0,0 +1,153 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Setup\Console\Command; + +use Symfony\Component\Console\Tester\CommandTester; +use Magento\Framework\Console\Cli; +use Magento\Framework\ObjectManagerInterface; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\Catalog\Console\Command\PriceIndexerDimensionsModeSetCommand; +use Magento\Catalog\Model\Indexer\Product\Price\ModeSwitcher; + +/** + * Class PriceIndexerDimensionsModeSetCommand + * @package Magento\Setup\Console\Command + */ +class PriceIndexerDimensionsModeSetCommandTest extends \Magento\TestFramework\Indexer\TestCase +{ + /** @var ObjectManagerInterface */ + private $objectManager; + + /** @var GenerateFixturesCommand */ + private $command; + + /** @var CommandTester */ + private $commandTester; + + /** + * setUp + */ + public function setUp() + { + $this->objectManager = Bootstrap::getObjectManager(); + + $this->objectManager->get(\Magento\TestFramework\App\Config::class)->clean(); + + $this->command = $this->objectManager->create( + \Magento\Catalog\Console\Command\PriceIndexerDimensionsModeSetCommand::class + ); + + $this->commandTester = new CommandTester($this->command); + + parent::setUp(); + } + + /** + * tearDown + */ + public function tearDown() + { + parent::tearDown(); + } + + /** + * setUpBeforeClass + */ + public static function setUpBeforeClass() + { + $db = Bootstrap::getInstance()->getBootstrap() + ->getApplication() + ->getDbInstance(); + if (!$db->isDbDumpExists()) { + throw new \LogicException('DB dump does not exist.'); + } + $db->restoreFromDbDump(); + + parent::setUpBeforeClass(); + } + + /** + * @magentoAppArea adminhtml + * @magentoAppIsolation enabled + * + * @param $previousMode + * @param $currentMode + * @dataProvider modesDataProvider + */ + public function testSwitchMode($previousMode, $currentMode) + { + $this->commandTester->execute( + [ + PriceIndexerDimensionsModeSetCommand::INPUT_KEY_MODE => $currentMode + ] + ); + $expectedOutput = 'Dimensions mode for indexer Product Price was changed from \'' + . $previousMode . '\' to \'' . $currentMode . '\''; + + $actualOutput = $this->commandTester->getDisplay(); + + $this->assertContains($expectedOutput, $actualOutput); + + static::assertEquals( + Cli::RETURN_SUCCESS, + $this->commandTester->getStatusCode(), + $this->commandTester->getDisplay(true) + ); + } + + public function modesDataProvider() + { + return [ + [ModeSwitcher::INPUT_KEY_NONE, ModeSwitcher::INPUT_KEY_WEBSITE], + [ModeSwitcher::INPUT_KEY_WEBSITE, ModeSwitcher::INPUT_KEY_CUSTOMER_GROUP], + [ModeSwitcher::INPUT_KEY_CUSTOMER_GROUP, ModeSwitcher::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP], + [ModeSwitcher::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP, ModeSwitcher::INPUT_KEY_NONE], + [ModeSwitcher::INPUT_KEY_NONE, ModeSwitcher::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP], + [ModeSwitcher::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP, ModeSwitcher::INPUT_KEY_CUSTOMER_GROUP], + [ModeSwitcher::INPUT_KEY_CUSTOMER_GROUP, ModeSwitcher::INPUT_KEY_WEBSITE], + [ModeSwitcher::INPUT_KEY_WEBSITE, ModeSwitcher::INPUT_KEY_NONE], + ]; + } + + /** + * @magentoAppArea adminhtml + * @magentoAppIsolation enabled + */ + public function testSwitchModeForSameMode() + { + $this->commandTester->execute( + [ + PriceIndexerDimensionsModeSetCommand::INPUT_KEY_MODE => ModeSwitcher::INPUT_KEY_NONE + ] + ); + $expectedOutput = 'Dimensions mode for indexer Product Price has not been changed'; + + $actualOutput = $this->commandTester->getDisplay(); + + $this->assertContains($expectedOutput, $actualOutput); + + static::assertEquals( + Cli::RETURN_SUCCESS, + $this->commandTester->getStatusCode(), + $this->commandTester->getDisplay(true) + ); + } + + /** + * @magentoAppArea adminhtml + * @magentoAppIsolation enabled + * + * @expectedException \InvalidArgumentException + */ + public function testSwitchModeWithInvalidArgument() + { + $this->commandTester->execute( + [ + PriceIndexerDimensionsModeSetCommand::INPUT_KEY_MODE => ModeSwitcher::INPUT_KEY_NONE . '_not_valid' + ] + ); + } +} From 6cd93f12112d60a4e493c686377df36d9a8561d2 Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov <slopukhov@magento.com> Date: Wed, 30 May 2018 11:09:52 +0300 Subject: [PATCH 063/206] MAGETWO-91886: Add ability to configure dimensions --- .../Console/Command/PriceIndexerDimensionsModeSetCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/Console/Command/PriceIndexerDimensionsModeSetCommand.php b/app/code/Magento/Catalog/Console/Command/PriceIndexerDimensionsModeSetCommand.php index 03be0eb8c6f82..599b495f8bf8a 100644 --- a/app/code/Magento/Catalog/Console/Command/PriceIndexerDimensionsModeSetCommand.php +++ b/app/code/Magento/Catalog/Console/Command/PriceIndexerDimensionsModeSetCommand.php @@ -93,7 +93,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $errors = $this->validate($input); if ($errors) { - throw new \InvalidArgumentException(implode("\n", $errors)); + throw new \InvalidArgumentException(implode(PHP_EOL, $errors)); } $returnValue = \Magento\Framework\Console\Cli::RETURN_SUCCESS; From 1e996f2d4cecd5403bcc14c6701a62cf95e2b5ff Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov <slopukhov@magento.com> Date: Wed, 30 May 2018 13:57:44 +0300 Subject: [PATCH 064/206] MAGETWO-91886: Add ability to configure dimensions --- .../Indexer/Category/Product/TableMaintainer.php | 12 ++++++++---- .../Indexer/Product/Price/TableMaintainer.php | 14 +++++++++----- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Product/TableMaintainer.php b/app/code/Magento/Catalog/Model/Indexer/Category/Product/TableMaintainer.php index 685e3cb045867..1278434fcad43 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Category/Product/TableMaintainer.php +++ b/app/code/Magento/Catalog/Model/Indexer/Category/Product/TableMaintainer.php @@ -13,6 +13,9 @@ use Magento\Catalog\Model\Indexer\Category\Product\AbstractAction; use Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver as TableResolver; +/** + * Class encapsulate logic of work with tables per store in Category Product indexer + */ class TableMaintainer { /** @@ -202,13 +205,14 @@ public function createMainTmpTable(int $storeId) * @param $storeId * * @return string + * + * @throws \Exception */ public function getMainTmpTable(int $storeId) { - if (isset($this->mainTmpTable[$storeId])) { - return $this->mainTmpTable[$storeId]; - } else { - return null; + if (!isset($this->mainTmpTable[$storeId])) { + throw new \Exception('Temporary table does not exist'); } + return $this->mainTmpTable[$storeId]; } } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php index 1c65c663fbbc3..2d27c8c6ef169 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php @@ -12,6 +12,9 @@ use Magento\Framework\DB\Adapter\AdapterInterface; use Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver as TableResolver; +/** + * Class encapsulate logic of work with tables per store in Product Price indexer + */ class TableMaintainer { /** @@ -249,14 +252,15 @@ public function createMainTmpTable(array $dimensions) * * @param Dimension[] $dimensions * - * @return string|null + * @return string + * + * @throws \Exception */ public function getMainTmpTable(array $dimensions) { - if (isset($this->mainTmpTable[$this->getArrayKeyForTmpTable($dimensions)])) { - return $this->mainTmpTable[$this->getArrayKeyForTmpTable($dimensions)]; - } else { - return null; + if (!isset($this->mainTmpTable[$this->getArrayKeyForTmpTable($dimensions)])) { + throw new \Exception('Temporary table does not exist'); } + return $this->mainTmpTable[$this->getArrayKeyForTmpTable($dimensions)]; } } From 5fce8e8e9ebcf81059f7ce42f4a8754c78ffc4fb Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov <slopukhov@magento.com> Date: Wed, 30 May 2018 14:11:48 +0300 Subject: [PATCH 065/206] MAGETWO-91886: Add ability to configure dimensions --- .../Console/Command/PriceIndexerDimensionsModeSetCommand.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/code/Magento/Catalog/Console/Command/PriceIndexerDimensionsModeSetCommand.php b/app/code/Magento/Catalog/Console/Command/PriceIndexerDimensionsModeSetCommand.php index 599b495f8bf8a..d29b806a16af7 100644 --- a/app/code/Magento/Catalog/Console/Command/PriceIndexerDimensionsModeSetCommand.php +++ b/app/code/Magento/Catalog/Console/Command/PriceIndexerDimensionsModeSetCommand.php @@ -19,6 +19,8 @@ /** * Command to change price indexer dimensions mode + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class PriceIndexerDimensionsModeSetCommand extends AbstractIndexerCommand { From c5bd098a426c2d4e19931e5f7686d4017329af24 Mon Sep 17 00:00:00 2001 From: Andrii Voskoboinikov <avoskoboinikov@magento.com> Date: Wed, 30 May 2018 14:53:33 +0300 Subject: [PATCH 066/206] MAGETWO-91877: Adapt custom options select to use dimensions --- .../Price/Query/CustomOptionsPrice.php | 58 ++++++++++++++++--- 1 file changed, 50 insertions(+), 8 deletions(-) diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/CustomOptionsPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/CustomOptionsPrice.php index 3122c418203d8..9acea03c28597 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/CustomOptionsPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/CustomOptionsPrice.php @@ -25,26 +25,40 @@ class CustomOptionsPrice */ private $columnValueExpressionFactory; + /** + * @var \Magento\Catalog\Helper\Data + */ + private $dataHelper; + /** * @var string */ private $connectionName; + /** + * @var bool + */ + private $isPriceGlobalFlag; + /** * @param \Magento\Framework\App\ResourceConnection $resource * @param \Magento\Framework\EntityManager\MetadataPool $metadataPool + * @param \Magento\Framework\DB\Sql\ColumnValueExpressionFactory $columnValueExpressionFactory + * @param \Magento\Catalog\Helper\Data $dataHelper * @param string $connectionName */ public function __construct( \Magento\Framework\App\ResourceConnection $resource, \Magento\Framework\EntityManager\MetadataPool $metadataPool, \Magento\Framework\DB\Sql\ColumnValueExpressionFactory $columnValueExpressionFactory, + \Magento\Catalog\Helper\Data $dataHelper, $connectionName = 'indexer' ) { $this->resource = $resource; $this->metadataPool = $metadataPool; $this->connectionName = $connectionName; $this->columnValueExpressionFactory = $columnValueExpressionFactory; + $this->dataHelper = $dataHelper; } public function getSelectForOptionsWithMultipleValues($sourceTable) @@ -84,16 +98,26 @@ public function getSelectForOptionsWithMultipleValues($sourceTable) ['otpd' => $this->getTable('catalog_product_option_type_price')], 'otpd.option_type_id = ot.option_type_id AND otpd.store_id = 0', [] - )->joinLeft( + )->group( + ['i.entity_id', 'i.customer_group_id', 'i.website_id', 'o.option_id'] + ); + + if ($this->isPriceGlobal()) { + $optPriceType = 'otpd.price_type'; + $optPriceValue = 'otpd.price'; + } + + if (!$this->isPriceGlobal()) { + $select->joinLeft( ['otps' => $this->getTable('catalog_product_option_type_price')], 'otps.option_type_id = otpd.option_type_id AND otpd.store_id = cs.store_id', [] - )->group( - ['i.entity_id', 'i.customer_group_id', 'i.website_id', 'o.option_id'] ); - $optPriceType = $connection->getCheckSql('otps.option_type_price_id > 0', 'otps.price_type', 'otpd.price_type'); - $optPriceValue = $connection->getCheckSql('otps.option_type_price_id > 0', 'otps.price', 'otpd.price'); + $optPriceType = $connection->getCheckSql('otps.option_type_price_id > 0', 'otps.price_type', 'otpd.price_type'); + $optPriceValue = $connection->getCheckSql('otps.option_type_price_id > 0', 'otps.price', 'otpd.price'); + } + $minPriceRound = $this->columnValueExpressionFactory ->create([ 'expression' => "ROUND(i.price * ({$optPriceValue} / 100), 4)" @@ -172,14 +196,23 @@ public function getSelectForOptionsWithOneValue($sourceTable) ['opd' => $this->getTable('catalog_product_option_price')], 'opd.option_id = o.option_id AND opd.store_id = 0', [] - )->joinLeft( + ); + + if ($this->isPriceGlobal()) { + $optPriceType = 'opd.price_type'; + $optPriceValue = 'opd.price'; + } + + if (!$this->isPriceGlobal()) { + $select->joinLeft( ['ops' => $this->getTable('catalog_product_option_price')], 'ops.option_id = opd.option_id AND ops.store_id = cs.store_id', [] ); - $optPriceType = $connection->getCheckSql('ops.option_price_id > 0', 'ops.price_type', 'opd.price_type'); - $optPriceValue = $connection->getCheckSql('ops.option_price_id > 0', 'ops.price', 'opd.price'); + $optPriceType = $connection->getCheckSql('ops.option_price_id > 0', 'ops.price_type', 'opd.price_type'); + $optPriceValue = $connection->getCheckSql('ops.option_price_id > 0', 'ops.price', 'opd.price'); + } $minPriceRound = $this->columnValueExpressionFactory ->create([ @@ -264,4 +297,13 @@ private function getTable($tableName) { return $this->resource->getTableName($tableName, $this->connectionName); } + + private function isPriceGlobal() + { + if ($this->isPriceGlobalFlag === null) { + $this->isPriceGlobalFlag = $this->dataHelper->isPriceGlobal(); + } + + return $this->isPriceGlobalFlag; + } } From 412650ccdbc0a046555c50f4152e304a75507bb8 Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi <alugovyi@magento.com> Date: Wed, 30 May 2018 16:00:36 +0300 Subject: [PATCH 067/206] MAGETWO-91873: Create table resolver for price index --- .../Product/Price/Plugin/TableResolver.php | 142 ++++++++++++++++++ .../Product/Price/PriceTableResolver.php | 80 ++++++++++ .../ResourceModel/Layer/Filter/Price.php | 62 +++++++- .../ResourceModel/Product/Collection.php | 107 ++++++++++++- ...LinkedProductSelectBuilderByIndexPrice.php | 36 ++++- app/code/Magento/Catalog/etc/di.xml | 23 +++ app/code/Magento/Catalog/etc/frontend/di.xml | 4 + .../Magento/Catalog/etc/webapi_rest/di.xml | 4 + .../Magento/Catalog/etc/webapi_soap/di.xml | 4 + .../Aggregation/DataProvider/QueryBuilder.php | 38 ++++- .../Adapter/Mysql/Dynamic/DataProvider.php | 47 ++++-- .../Search/FilterMapper/ExclusionStrategy.php | 49 +++++- app/code/Magento/CatalogSearch/etc/di.xml | 21 +++ 13 files changed, 578 insertions(+), 39 deletions(-) create mode 100644 app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/TableResolver.php create mode 100644 app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/TableResolver.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/TableResolver.php new file mode 100644 index 0000000000000..914e39b3d2f3c --- /dev/null +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/TableResolver.php @@ -0,0 +1,142 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Catalog\Model\Indexer\Product\Price\Plugin; + +use Magento\Catalog\Model\Indexer\Product\Price\PriceTableResolver; +use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Framework\App\ResourceConnection; +use Magento\Catalog\Model\Indexer\Product\Price\ModeSwitcher; +use Magento\Framework\Indexer\DimensionFactory; +use Magento\Framework\Search\Request\IndexScopeResolverInterface; +use Magento\Framework\App\Http\Context; +use Magento\Framework\Indexer\Dimension; +use Magento\Store\Model\StoreManagerInterface; +use Magento\Customer\Model\Context as CustomerContext; +use Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProvider; +use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; + +/** + * Class that replace catalog_product_index_price table name on the table name segmented per dimension + */ +class TableResolver +{ + /** + * @var ScopeConfigInterface + */ + private $scopeConfig; + + /** + * @var IndexScopeResolverInterface + */ + private $priceTableResolver; + + /** + * @var StoreManagerInterface + */ + private $storeManager; + + /** + * @var Context + */ + private $httpContext; + + /** + * @var DimensionFactory + */ + private $dimensionFactory; + + /** + * @param ScopeConfigInterface $scopeConfig + * @param IndexScopeResolverInterface $priceTableResolver + * @param StoreManagerInterface $storeManager + * @param Context $context + * @param DimensionFactory $dimensionFactory + */ + public function __construct( + ScopeConfigInterface $scopeConfig, + IndexScopeResolverInterface $priceTableResolver, + StoreManagerInterface $storeManager, + Context $context, + DimensionFactory $dimensionFactory + ) { + $this->scopeConfig = $scopeConfig; + $this->priceTableResolver = $priceTableResolver; + $this->storeManager = $storeManager; + $this->httpContext = $context; + $this->dimensionFactory = $dimensionFactory; + } + + /** + * replacing catalog_product_index_price table name on the table name segmented per dimension + * @param ResourceConnection $subject + * @param string $result + * @param string|string[] $modelEntity + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @return string + */ + public function afterGetTableName( + ResourceConnection $subject, + string $result, + $modelEntity + ) { + if (!is_array($modelEntity) + && $modelEntity === 'catalog_product_index_price' + && $this->getMode() !== ModeSwitcher::INPUT_KEY_NONE + ) { + return $this->priceTableResolver->resolve('catalog_product_index_price', $this->getDimensions()); + } + return $result; + } + + private function getMode(): string + { + return $this->scopeConfig->getValue(ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE); + } + + private function getDimensions(): array + { + switch ($this->getMode()) { + case ModeSwitcher::INPUT_KEY_WEBSITE: + $return = [ + $this->createDimensionFromWebsite() + ]; + break; + case ModeSwitcher::INPUT_KEY_CUSTOMER_GROUP: + $return = [ + $this->createDimensionFromCustomerGroup() + ]; + break; + case ModeSwitcher::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP: + $return = [ + $this->createDimensionFromWebsite(), + $this->createDimensionFromCustomerGroup() + ]; + break; + default: + $return = []; + } + return $return; + } + + private function createDimensionFromWebsite(): Dimension + { + $storeKey = $this->httpContext->getValue(StoreManagerInterface::CONTEXT_STORE); + return $this->dimensionFactory->create( + WebsiteDataProvider::DIMENSION_NAME, + (string)$this->storeManager->getStore($storeKey)->getWebsiteId() + ); + } + + private function createDimensionFromCustomerGroup(): Dimension + { + return $this->dimensionFactory->create( + CustomerGroupDataProvider::DIMENSION_NAME, + (string)$this->httpContext->getValue(CustomerContext::CONTEXT_GROUP) + ); + } +} diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php new file mode 100644 index 0000000000000..064969f615295 --- /dev/null +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php @@ -0,0 +1,80 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Catalog\Model\Indexer\Product\Price; + +use Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver; +use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Framework\Search\Request\IndexScopeResolverInterface; +use Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProvider; +use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; + +class PriceTableResolver implements IndexScopeResolverInterface +{ + /** + * @var ScopeConfigInterface + */ + private $scopeConfig; + + /** + * @var IndexScopeResolver + */ + private $indexScopeResolver; + + /** + * @param ScopeConfigInterface $scopeConfig + * @param IndexScopeResolver $indexScopeResolver + */ + public function __construct( + ScopeConfigInterface $scopeConfig, + IndexScopeResolver $indexScopeResolver + ) { + $this->scopeConfig = $scopeConfig; + $this->indexScopeResolver = $indexScopeResolver; + } + + /** + * Return price table name based on dimension + * @param string $index + * @param array $dimensions + * @return string + */ + public function resolve($index, array $dimensions) + { + $dimensions = $this->getMixDimensions($dimensions); + return $this->indexScopeResolver->resolve($index, $dimensions); + } + + private function getMixDimensions($dimensions): array + { + $existDimensions = []; + foreach ($dimensions as $key => $dimension) { + $existDimensions[$dimension->getName()] = $dimension; + } + + switch ($this->scopeConfig->getValue(ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE)) { + case ModeSwitcher::INPUT_KEY_WEBSITE: + $return = [ + $existDimensions[WebsiteDataProvider::DIMENSION_NAME] + ]; + break; + case ModeSwitcher::INPUT_KEY_CUSTOMER_GROUP: + $return = [ + $existDimensions[CustomerGroupDataProvider::DIMENSION_NAME] + ]; + break; + case ModeSwitcher::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP: + $return = [ + $existDimensions[WebsiteDataProvider::DIMENSION_NAME], + $existDimensions[CustomerGroupDataProvider::DIMENSION_NAME] + ]; + break; + default: + $return = []; + } + return $return; + } +} diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Layer/Filter/Price.php b/app/code/Magento/Catalog/Model/ResourceModel/Layer/Filter/Price.php index bed129e19168f..8eba0ce1c138c 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Layer/Filter/Price.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Layer/Filter/Price.php @@ -5,6 +5,15 @@ */ namespace Magento\Catalog\Model\ResourceModel\Layer\Filter; +use Magento\Framework\App\Http\Context; +use Magento\Framework\App\ObjectManager; +use Magento\Framework\Indexer\DimensionFactory; +use Magento\Framework\Search\Request\IndexScopeResolverInterface; +use Magento\Store\Model\StoreManagerInterface; +use Magento\Customer\Model\Context as CustomerContext; +use Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProvider; +use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; + /** * Catalog Layer Price Filter resource model * @@ -41,6 +50,21 @@ class Price extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb */ private $storeManager; + /** + * @var IndexScopeResolverInterface|null + */ + private $priceTableResolver; + + /** + * @var Context + */ + private $httpContext; + + /** + * @var DimensionFactory|null + */ + private $dimensionFactory; + /** * @param \Magento\Framework\Model\ResourceModel\Db\Context $context * @param \Magento\Framework\Event\ManagerInterface $eventManager @@ -48,6 +72,9 @@ class Price extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb * @param \Magento\Customer\Model\Session $session * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param null $connectionName + * @param IndexScopeResolverInterface|null $priceTableResolver + * @param Context|null $httpContext + * @param DimensionFactory|null $dimensionFactory */ public function __construct( \Magento\Framework\Model\ResourceModel\Db\Context $context, @@ -55,12 +82,19 @@ public function __construct( \Magento\Catalog\Model\Layer\Resolver $layerResolver, \Magento\Customer\Model\Session $session, \Magento\Store\Model\StoreManagerInterface $storeManager, - $connectionName = null + $connectionName = null, + IndexScopeResolverInterface $priceTableResolver = null, + Context $httpContext = null, + DimensionFactory $dimensionFactory = null ) { $this->layer = $layerResolver->get(); $this->session = $session; $this->storeManager = $storeManager; $this->_eventManager = $eventManager; + $this->priceTableResolver = $priceTableResolver + ?? ObjectManager::getInstance()->get(IndexScopeResolverInterface::class); + $this->httpContext = $httpContext ?? ObjectManager::getInstance()->get(Context::class); + $this->dimensionFactory = $dimensionFactory ?? ObjectManager::getInstance()->get(DimensionFactory::class); parent::__construct($context, $connectionName); } @@ -119,10 +153,10 @@ protected function _getSelect() // remove join with main table $fromPart = $select->getPart(\Magento\Framework\DB\Select::FROM); if (!isset( - $fromPart[\Magento\Catalog\Model\ResourceModel\Product\Collection::INDEX_TABLE_ALIAS] - ) || !isset( - $fromPart[\Magento\Catalog\Model\ResourceModel\Product\Collection::MAIN_TABLE_ALIAS] - ) + $fromPart[\Magento\Catalog\Model\ResourceModel\Product\Collection::INDEX_TABLE_ALIAS] + ) || !isset( + $fromPart[\Magento\Catalog\Model\ResourceModel\Product\Collection::MAIN_TABLE_ALIAS] + ) ) { return $select; } @@ -368,12 +402,26 @@ public function applyPriceRange(\Magento\Catalog\Model\Layer\Filter\FilterInterf /** * Initialize connection and define main table name - * + * @deprecated * @return void */ protected function _construct() { - $this->_init('catalog_product_index_price', 'entity_id'); + $storeKey = $this->httpContext->getValue(StoreManagerInterface::CONTEXT_STORE); + $priceTableName = $this->priceTableResolver->resolve( + 'catalog_product_index_price', + [ + $this->dimensionFactory->create( + WebsiteDataProvider::DIMENSION_NAME, + (string)$this->storeManager->getStore($storeKey)->getWebsiteId() + ), + $this->dimensionFactory->create( + CustomerGroupDataProvider::DIMENSION_NAME, + (string)$this->httpContext->getValue(CustomerContext::CONTEXT_GROUP) + ) + ] + ); + $this->_init($priceTableName, 'entity_id'); } /** diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php index 915ba08c58220..dd5206e4c2bb9 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php @@ -14,11 +14,17 @@ use Magento\Catalog\Model\ResourceModel\Product\Collection\ProductLimitationFactory; use Magento\CatalogUrlRewrite\Model\ProductUrlRewriteGenerator; use Magento\Customer\Api\GroupManagementInterface; +use Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProvider; use Magento\Framework\App\ObjectManager; use Magento\Framework\DB\Select; use Magento\Framework\EntityManager\MetadataPool; +use Magento\Catalog\Model\Indexer\Product\Price\PriceTableResolver; +use Magento\Framework\Search\Request\IndexScopeResolverInterface; +use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; use Magento\Store\Model\Store; use Magento\Catalog\Model\Indexer\Category\Product\TableMaintainer; +use Magento\Catalog\Model\Indexer\Product\Price\DimensionProviderFactory; +use Magento\Framework\Indexer\DimensionFactory; /** * Product collection @@ -278,9 +284,27 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Collection\Abstrac */ private $tableMaintainer; + /** + * @var PriceTableResolver + */ + private $priceTableResolver; + /** + * @var DimensionProviderFactory + */ + private $dimensionProviderFactory; + + /** + * @var DimensionFactory + */ + private $dimensionFactory; + + /** + * @var IndexScopeResolverInterface + */ + private $indexScopeResolver; + /** * Collection constructor - * * @param \Magento\Framework\Data\Collection\EntityFactory $entityFactory * @param \Psr\Log\LoggerInterface $logger * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy @@ -304,7 +328,10 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Collection\Abstrac * @param ProductLimitationFactory|null $productLimitationFactory * @param MetadataPool|null $metadataPool * @param TableMaintainer|null $tableMaintainer - * + * @param PriceTableResolver|null $priceTableResolver + * @param DimensionProviderFactory|null $dimensionProviderFactory + * @param DimensionFactory|null $dimensionFactory + * @param IndexScopeResolverInterface|null $indexScopeResolver * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -330,7 +357,11 @@ public function __construct( \Magento\Framework\DB\Adapter\AdapterInterface $connection = null, ProductLimitationFactory $productLimitationFactory = null, MetadataPool $metadataPool = null, - TableMaintainer $tableMaintainer = null + TableMaintainer $tableMaintainer = null, + PriceTableResolver $priceTableResolver = null, + DimensionProviderFactory $dimensionProviderFactory = null, + DimensionFactory $dimensionFactory = null, + IndexScopeResolverInterface $indexScopeResolver = null ) { $this->moduleManager = $moduleManager; $this->_catalogProductFlatState = $catalogProductFlatState; @@ -361,6 +392,13 @@ public function __construct( $connection ); $this->tableMaintainer = $tableMaintainer ?: ObjectManager::getInstance()->get(TableMaintainer::class); + $this->dimensionProviderFactory = $dimensionProviderFactory + ?: ObjectManager::getInstance()->get(DimensionProviderFactory::class); + $this->priceTableResolver = $priceTableResolver ?: ObjectManager::getInstance()->get(PriceTableResolver::class); + $this->dimensionFactory = $dimensionFactory + ?: ObjectManager::getInstance()->get(DimensionFactory::class); + $this->indexScopeResolver = $indexScopeResolver + ?: ObjectManager::getInstance()->get(IndexScopeResolverInterface::class); } /** @@ -1897,12 +1935,33 @@ protected function _productLimitationPrice($joinLeft = false) 'max_price', 'tier_price', ]; - $tableName = ['price_index' => $this->getTable('catalog_product_index_price')]; - if ($joinLeft) { - $select->joinLeft($tableName, $joinCond, $colls); + + $joinFunction = $joinLeft + ? function ($tableName) use ($select, $joinLeft, $joinCond, $colls) { + $select->joinLeft($tableName, $joinCond, $colls); + } + : function ($tableName) use ($select, $joinLeft, $joinCond, $colls) { + $select->join($tableName, $joinCond, $colls); + }; + + if (isset($this->_productLimitationFilters['customer_group_id']) + || isset($this->_productLimitationFilters['website_id']) + ) { + $dimensions = $this->makeCurrentDimensions(); + + $tableName = [ + 'price_index' => $this->priceTableResolver->resolve( + 'catalog_product_index_price', + $dimensions + ) + ]; + $joinFunction($tableName); } else { - $select->join($tableName, $joinCond, $colls); + //handle rare case when price index is used on backend area where website/customer group is not passed. + $tableName = ['price_index' => $this->indexScopeResolver->resolve('catalog_product_index_price', [])]; + $joinFunction($tableName); } + // Set additional field filters foreach ($this->_priceDataFieldFilters as $filterData) { $select->where(call_user_func_array('sprintf', $filterData)); @@ -2407,4 +2466,38 @@ public function getPricesCount() return $this->_pricesCount; } + + /** + * @return array + */ + private function makeCurrentDimensions(): array + { + $dimensions = []; + + if (isset($this->_productLimitationFilters['customer_group_id'])) { + $dimensions[] = $this->dimensionFactory->create( + CustomerGroupDataProvider::DIMENSION_NAME, + $this->_productLimitationFilters['customer_group_id'] + ); + } else { + $dimensions[] = $this->dimensionFactory->create( + CustomerGroupDataProvider::DIMENSION_NAME, + $this->_customerSession->getCustomerGroupId() + ); + } + + if (isset($this->_productLimitationFilters['website_id'])) { + $dimensions[] = $this->dimensionFactory->create( + WebsiteDataProvider::DIMENSION_NAME, + $this->_productLimitationFilters['website_id'] + ); + } else { + $dimensions[] = $this->dimensionFactory->create( + WebsiteDataProvider::DIMENSION_NAME, + $this->_storeManager->getStore($this->getStoreId())->getWebsiteId() + ); + } + + return $dimensions; + } } diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/LinkedProductSelectBuilderByIndexPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/LinkedProductSelectBuilderByIndexPrice.php index ee1df8f23424d..f0558d6414267 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/LinkedProductSelectBuilderByIndexPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/LinkedProductSelectBuilderByIndexPrice.php @@ -7,9 +7,13 @@ use Magento\Catalog\Api\Data\ProductInterface; use Magento\Catalog\Model\ResourceModel\Product\BaseSelectProcessorInterface; +use Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProvider; use Magento\Framework\App\ObjectManager; use Magento\Framework\DB\Select; use Magento\Catalog\Model\ResourceModel\Product\LinkedProductSelectBuilderInterface; +use Magento\Framework\Indexer\DimensionFactory; +use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; +use Magento\Framework\Search\Request\IndexScopeResolverInterface; class LinkedProductSelectBuilderByIndexPrice implements LinkedProductSelectBuilderInterface { @@ -38,6 +42,16 @@ class LinkedProductSelectBuilderByIndexPrice implements LinkedProductSelectBuild */ private $baseSelectProcessor; + /** + * @var IndexScopeResolverInterface|null + */ + private $priceTableResolver; + + /** + * @var DimensionFactory|null + */ + private $dimensionFactory; + /** * LinkedProductSelectBuilderByIndexPrice constructor. * @param \Magento\Store\Model\StoreManagerInterface $storeManager @@ -45,13 +59,17 @@ class LinkedProductSelectBuilderByIndexPrice implements LinkedProductSelectBuild * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Framework\EntityManager\MetadataPool $metadataPool * @param BaseSelectProcessorInterface|null $baseSelectProcessor + * @param IndexScopeResolverInterface|null $priceTableResolver + * @param DimensionFactory|null $dimensionFactory */ public function __construct( \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\App\ResourceConnection $resourceConnection, \Magento\Customer\Model\Session $customerSession, \Magento\Framework\EntityManager\MetadataPool $metadataPool, - BaseSelectProcessorInterface $baseSelectProcessor = null + BaseSelectProcessorInterface $baseSelectProcessor = null, + IndexScopeResolverInterface $priceTableResolver = null, + DimensionFactory $dimensionFactory = null ) { $this->storeManager = $storeManager; $this->resource = $resourceConnection; @@ -59,6 +77,9 @@ public function __construct( $this->metadataPool = $metadataPool; $this->baseSelectProcessor = (null !== $baseSelectProcessor) ? $baseSelectProcessor : ObjectManager::getInstance()->get(BaseSelectProcessorInterface::class); + $this->priceTableResolver = $priceTableResolver + ?? ObjectManager::getInstance()->get(IndexScopeResolverInterface::class); + $this->dimensionFactory = $dimensionFactory ?? ObjectManager::getInstance()->get(DimensionFactory::class); } /** @@ -68,6 +89,8 @@ public function build($productId) { $linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField(); $productTable = $this->resource->getTableName('catalog_product_entity'); + $websiteId = $this->storeManager->getStore()->getWebsiteId(); + $customerGroupId = $this->customerSession->getCustomerGroupId(); $priceSelect = $this->resource->getConnection()->select() ->from(['parent' => $productTable], '') @@ -80,12 +103,17 @@ public function build($productId) sprintf('%s.entity_id = link.child_id', BaseSelectProcessorInterface::PRODUCT_TABLE_ALIAS), ['entity_id'] )->joinInner( - ['t' => $this->resource->getTableName('catalog_product_index_price')], + [ + 't' => $this->priceTableResolver->resolve('catalog_product_index_price', [ + $this->dimensionFactory->create(WebsiteDataProvider::DIMENSION_NAME, $websiteId), + $this->dimensionFactory->create(CustomerGroupDataProvider::DIMENSION_NAME, $customerGroupId), + ]) + ], sprintf('t.entity_id = %s.entity_id', BaseSelectProcessorInterface::PRODUCT_TABLE_ALIAS), [] )->where('parent.entity_id = ?', $productId) - ->where('t.website_id = ?', $this->storeManager->getStore()->getWebsiteId()) - ->where('t.customer_group_id = ?', $this->customerSession->getCustomerGroupId()) + ->where('t.website_id = ?', $websiteId) + ->where('t.customer_group_id = ?', $customerGroupId) ->order('t.min_price ' . Select::SQL_ASC) ->order(BaseSelectProcessorInterface::PRODUCT_TABLE_ALIAS . '.' . $linkField . ' ' . Select::SQL_ASC) ->limit(1); diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml index e426de94150ad..0286531457145 100644 --- a/app/code/Magento/Catalog/etc/di.xml +++ b/app/code/Magento/Catalog/etc/di.xml @@ -70,6 +70,8 @@ <preference for="Magento\Catalog\Api\Data\ProductRender\FormattedPriceInfoInterface" type="Magento\Catalog\Model\ProductRender\FormattedPriceInfo" /> <preference for="Magento\Framework\Indexer\BatchProviderInterface" type="Magento\Framework\Indexer\BatchProvider" /> <preference for="Magento\Catalog\Model\Indexer\Product\Price\UpdateIndexInterface" type="Magento\Catalog\Model\Indexer\Product\Price\InvalidateIndex" /> + <preference for="Magento\Framework\Search\Request\IndexScopeResolverInterface" + type="Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver"/> <type name="Magento\Customer\Model\ResourceModel\Visitor"> <plugin name="catalogLog" type="Magento\Catalog\Model\Plugin\Log" /> </type> @@ -1101,4 +1103,25 @@ </argument> </arguments> </type> + <type name="Magento\Catalog\Model\Indexer\Product\Price\Plugin\TableResolver"> + <arguments> + <argument name="priceTableResolver" xsi:type="object"> + Magento\Catalog\Model\Indexer\Product\Price\PriceTableResolver + </argument> + </arguments> + </type> + <type name="Magento\Catalog\Model\ResourceModel\Layer\Filter\Price"> + <arguments> + <argument name="priceTableResolver" xsi:type="object"> + Magento\Catalog\Model\Indexer\Product\Price\PriceTableResolver + </argument> + </arguments> + </type> + <type name="Magento\Catalog\Model\ResourceModel\Product\Indexer\LinkedProductSelectBuilderByIndexPrice"> + <arguments> + <argument name="priceTableResolver" xsi:type="object"> + Magento\Catalog\Model\Indexer\Product\Price\PriceTableResolver + </argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/Catalog/etc/frontend/di.xml b/app/code/Magento/Catalog/etc/frontend/di.xml index d62ecdb632ac4..471795e6c882f 100644 --- a/app/code/Magento/Catalog/etc/frontend/di.xml +++ b/app/code/Magento/Catalog/etc/frontend/di.xml @@ -82,4 +82,8 @@ <type name="Magento\Framework\App\ResourceConnection"> <plugin name="get_catalog_category_product_index_table_name" type="Magento\Catalog\Model\Indexer\Category\Product\Plugin\TableResolver"/> </type> + <type name="Magento\Framework\App\ResourceConnection"> + <plugin name="get_catalog_product_price_index_table_name" + type="Magento\Catalog\Model\Indexer\Product\Price\Plugin\TableResolver"/> + </type> </config> diff --git a/app/code/Magento/Catalog/etc/webapi_rest/di.xml b/app/code/Magento/Catalog/etc/webapi_rest/di.xml index 1e09b9eedb73e..74162ba7ab01e 100644 --- a/app/code/Magento/Catalog/etc/webapi_rest/di.xml +++ b/app/code/Magento/Catalog/etc/webapi_rest/di.xml @@ -19,4 +19,8 @@ <type name="Magento\Framework\App\ResourceConnection"> <plugin name="get_catalog_category_product_index_table_name" type="Magento\Catalog\Model\Indexer\Category\Product\Plugin\TableResolver"/> </type> + <type name="Magento\Framework\App\ResourceConnection"> + <plugin name="get_catalog_product_price_index_table_name" + type="Magento\Catalog\Model\Indexer\Product\Price\Plugin\TableResolver"/> + </type> </config> diff --git a/app/code/Magento/Catalog/etc/webapi_soap/di.xml b/app/code/Magento/Catalog/etc/webapi_soap/di.xml index a0d3e850b3c64..b7e2dfc35f4c5 100644 --- a/app/code/Magento/Catalog/etc/webapi_soap/di.xml +++ b/app/code/Magento/Catalog/etc/webapi_soap/di.xml @@ -18,4 +18,8 @@ <type name="Magento\Framework\App\ResourceConnection"> <plugin name="get_catalog_category_product_index_table_name" type="Magento\Catalog\Model\Indexer\Category\Product\Plugin\TableResolver"/> </type> + <type name="Magento\Framework\App\ResourceConnection"> + <plugin name="get_catalog_product_price_index_table_name" + type="Magento\Catalog\Model\Indexer\Product\Price\Plugin\TableResolver"/> + </type> </config> diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Aggregation/DataProvider/QueryBuilder.php b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Aggregation/DataProvider/QueryBuilder.php index ca077ef7227d5..f203493ddfc58 100644 --- a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Aggregation/DataProvider/QueryBuilder.php +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Aggregation/DataProvider/QueryBuilder.php @@ -8,18 +8,29 @@ use Magento\CatalogInventory\Model\Configuration as CatalogInventoryConfiguration; use Magento\CatalogInventory\Model\Stock; +use Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProvider; use Magento\Eav\Model\Entity\Attribute\AbstractAttribute; use Magento\Framework\App\ResourceConnection; use Magento\Framework\App\ScopeResolverInterface; use Magento\Framework\DB\Adapter\AdapterInterface; use Magento\Framework\DB\Select; +use Magento\Catalog\Model\Indexer\Product\Price\PriceTableResolver; use Magento\Framework\Search\Request\BucketInterface; +use Magento\Framework\App\ObjectManager; +use Magento\Framework\Indexer\DimensionFactory; +use Magento\Framework\Search\Request\IndexScopeResolverInterface; +use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; /** * Attribute query builder */ class QueryBuilder { + /** + * @var DimensionFactory + */ + private $dimensionFactory; + /** * @var Resource */ @@ -35,19 +46,31 @@ class QueryBuilder */ private $inventoryConfig; + /** + * @var IndexScopeResolverInterface + */ + private $priceTableResolver; + /** * @param ResourceConnection $resource * @param ScopeResolverInterface $scopeResolver * @param CatalogInventoryConfiguration $inventoryConfig + * @param IndexScopeResolverInterface $priceTableResolver + * @param DimensionFactory|null $dimensionFactory */ public function __construct( ResourceConnection $resource, ScopeResolverInterface $scopeResolver, - CatalogInventoryConfiguration $inventoryConfig + CatalogInventoryConfiguration $inventoryConfig, + IndexScopeResolverInterface $priceTableResolver = null, + DimensionFactory $dimensionFactory = null ) { $this->resource = $resource; $this->scopeResolver = $scopeResolver; $this->inventoryConfig = $inventoryConfig; + $this->priceTableResolver = $priceTableResolver + ?: ObjectManager::getInstance()->get(IndexScopeResolverInterface::class); + $this->dimensionFactory = $dimensionFactory ?: ObjectManager::getInstance()->get(DimensionFactory::class); } /** @@ -99,12 +122,19 @@ private function buildQueryForPriceAttribute( if (!$store instanceof \Magento\Store\Model\Store) { throw new \RuntimeException('Illegal scope resolved'); } + $websiteId = $store->getWebsiteId(); - $table = $this->resource->getTableName('catalog_product_index_price'); - $select->from(['main_table' => $table], null) + $tableName = $this->priceTableResolver->resolve( + 'catalog_product_index_price', + [ + $this->dimensionFactory->create(WebsiteDataProvider::DIMENSION_NAME, $websiteId), + $this->dimensionFactory->create(CustomerGroupDataProvider::DIMENSION_NAME, $customerGroupId), + ] + ); + $select->from(['main_table' => $tableName], null) ->columns([BucketInterface::FIELD_VALUE => 'main_table.min_price']) ->where('main_table.customer_group_id = ?', $customerGroupId) - ->where('main_table.website_id = ?', $store->getWebsiteId()); + ->where('main_table.website_id = ?', $websiteId); return $select; } diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Dynamic/DataProvider.php b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Dynamic/DataProvider.php index 8b7a7ed214e36..58cce85173f63 100644 --- a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Dynamic/DataProvider.php +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Dynamic/DataProvider.php @@ -6,17 +6,21 @@ namespace Magento\CatalogSearch\Model\Adapter\Mysql\Dynamic; use Magento\Catalog\Model\Layer\Filter\Price\Range; +use Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProvider; use Magento\Customer\Model\Session; use Magento\Framework\App\ResourceConnection; use Magento\Framework\DB\Adapter\AdapterInterface; use Magento\Framework\DB\Ddl\Table; use Magento\Framework\DB\Select; +use Magento\Framework\Indexer\DimensionFactory; use Magento\Framework\Search\Adapter\Mysql\Aggregation\DataProviderInterface as MysqlDataProviderInterface; use Magento\Framework\Search\Dynamic\DataProviderInterface; use Magento\Framework\Search\Dynamic\IntervalFactory; use Magento\Framework\Search\Request\BucketInterface; use Magento\Framework\App\ObjectManager; +use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; use Magento\Store\Model\StoreManager; +use \Magento\Framework\Search\Request\IndexScopeResolverInterface; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) @@ -58,6 +62,16 @@ class DataProvider implements DataProviderInterface */ private $storeManager; + /** + * @var IndexScopeResolverInterface + */ + private $priceTableResolver; + + /** + * @var DimensionFactory|null + */ + private $dimensionFactory; + /** * @param ResourceConnection $resource * @param Range $range @@ -65,6 +79,8 @@ class DataProvider implements DataProviderInterface * @param MysqlDataProviderInterface $dataProvider * @param IntervalFactory $intervalFactory * @param StoreManager $storeManager + * @param IndexScopeResolverInterface|null $priceTableResolver + * @param DimensionFactory|null $dimensionFactory */ public function __construct( ResourceConnection $resource, @@ -72,7 +88,9 @@ public function __construct( Session $customerSession, MysqlDataProviderInterface $dataProvider, IntervalFactory $intervalFactory, - StoreManager $storeManager = null + StoreManager $storeManager = null, + IndexScopeResolverInterface $priceTableResolver = null, + DimensionFactory $dimensionFactory = null ) { $this->resource = $resource; $this->connection = $resource->getConnection(); @@ -81,6 +99,8 @@ public function __construct( $this->dataProvider = $dataProvider; $this->intervalFactory = $intervalFactory; $this->storeManager = $storeManager ?: ObjectManager::getInstance()->get(StoreManager::class); + $this->priceTableResolver = $priceTableResolver ?: ObjectManager::getInstance()->get(IndexScopeResolverInterface::class); + $this->dimensionFactory = $dimensionFactory ?: ObjectManager::getInstance()->get(DimensionFactory::class); } /** @@ -104,16 +124,24 @@ public function getAggregations(\Magento\Framework\Search\Dynamic\EntityStorage ]; $select = $this->getSelect(); - - $tableName = $this->resource->getTableName('catalog_product_index_price'); + $websiteId = $this->storeManager->getStore()->getWebsiteId(); + $customerGroupId = $this->customerSession->getCustomerGroupId(); + + $tableName = $this->priceTableResolver->resolve( + 'catalog_product_index_price', + [ + $this->dimensionFactory->create(WebsiteDataProvider::DIMENSION_NAME, $websiteId), + $this->dimensionFactory->create(CustomerGroupDataProvider::DIMENSION_NAME, $customerGroupId), + ] + ); /** @var Table $table */ $table = $entityStorage->getSource(); $select->from(['main_table' => $tableName], []) ->where('main_table.entity_id in (select entity_id from ' . $table->getName() . ')') ->columns($aggregation); - $select = $this->setCustomerGroupId($select); - $select->where('main_table.website_id = ?', $this->storeManager->getStore()->getWebsiteId()); + $select->where('customer_group_id = ?', $customerGroupId); + $select->where('main_table.website_id = ?', $websiteId); return $this->connection->fetchRow($select); } @@ -192,13 +220,4 @@ private function getSelect() { return $this->connection->select(); } - - /** - * @param Select $select - * @return Select - */ - private function setCustomerGroupId($select) - { - return $select->where('customer_group_id = ?', $this->customerSession->getCustomerGroupId()); - } } diff --git a/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/ExclusionStrategy.php b/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/ExclusionStrategy.php index 66e0457e7fadd..4222fafbcb275 100644 --- a/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/ExclusionStrategy.php +++ b/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/ExclusionStrategy.php @@ -7,10 +7,19 @@ namespace Magento\CatalogSearch\Model\Search\FilterMapper; use Magento\CatalogSearch\Model\Adapter\Mysql\Filter\AliasResolver; +use Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProvider; +use Magento\Framework\App\Http\Context; use Magento\Framework\App\ObjectManager; +use Magento\Framework\Indexer\DimensionFactory; use Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver as TableResolver; use Magento\Framework\Search\Request\Dimension; use Magento\Catalog\Model\Indexer\Category\Product\AbstractAction; +use Magento\Customer\Model\Context as CustomerContext; + +; + +use Magento\Framework\Search\Request\IndexScopeResolverInterface; +use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; /** * Strategy which processes exclusions from general rules @@ -43,22 +52,46 @@ class ExclusionStrategy implements FilterStrategyInterface */ private $tableResolver; + /** + * @var IndexScopeResolverInterface + */ + private $priceTableResolver; + + /** + * @var DimensionFactory + */ + private $dimensionFactory; + + /** + * @var Context + */ + private $httpContext; + /** * @param \Magento\Framework\App\ResourceConnection $resourceConnection * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param AliasResolver $aliasResolver * @param TableResolver|null $tableResolver + * @param DimensionFactory $dimensionFactory + * @param IndexScopeResolverInterface $priceTableResolver + * @param Context $httpContext */ public function __construct( \Magento\Framework\App\ResourceConnection $resourceConnection, \Magento\Store\Model\StoreManagerInterface $storeManager, AliasResolver $aliasResolver, - TableResolver $tableResolver = null + TableResolver $tableResolver = null, + DimensionFactory $dimensionFactory = null, + IndexScopeResolverInterface $priceTableResolver = null, + Context $httpContext = null ) { $this->resourceConnection = $resourceConnection; $this->storeManager = $storeManager; $this->aliasResolver = $aliasResolver; $this->tableResolver = $tableResolver ?: ObjectManager::getInstance()->get(TableResolver::class); + $this->dimensionFactory = $dimensionFactory ?: ObjectManager::getInstance()->get(DimensionFactory::class); + $this->priceTableResolver = $priceTableResolver ?: ObjectManager::getInstance()->get(IndexScopeResolverInterface::class); + $this->httpContext = $httpContext ?: ObjectManager::getInstance()->get(Context::class); } /** @@ -93,7 +126,17 @@ private function applyPriceFilter( \Magento\Framework\DB\Select $select ) { $alias = $this->aliasResolver->getAlias($filter); - $tableName = $this->resourceConnection->getTableName('catalog_product_index_price'); + $websiteId = $this->storeManager->getWebsite()->getId(); + $tableName = $this->priceTableResolver->resolve( + 'catalog_product_index_price', + [ + $this->dimensionFactory->create(WebsiteDataProvider::DIMENSION_NAME, $websiteId), + $this->dimensionFactory->create( + CustomerGroupDataProvider::DIMENSION_NAME, + $this->httpContext->getValue(CustomerContext::CONTEXT_GROUP) + ) + ] + ); $mainTableAlias = $this->extractTableAliasFromSelect($select); $select->joinInner( @@ -102,7 +145,7 @@ private function applyPriceFilter( ], $this->resourceConnection->getConnection()->quoteInto( sprintf('%s.entity_id = price_index.entity_id AND price_index.website_id = ?', $mainTableAlias), - $this->storeManager->getWebsite()->getId() + $websiteId ), [] ); diff --git a/app/code/Magento/CatalogSearch/etc/di.xml b/app/code/Magento/CatalogSearch/etc/di.xml index 546f4a80e53a4..8dde97146ee22 100644 --- a/app/code/Magento/CatalogSearch/etc/di.xml +++ b/app/code/Magento/CatalogSearch/etc/di.xml @@ -310,4 +310,25 @@ <argument name="name" xsi:type="string">catalog_view_container</argument> </arguments> </type> + <type name="Magento\CatalogSearch\Model\Search\FilterMapper\ExclusionStrategy"> + <arguments> + <argument name="priceTableResolver" xsi:type="object"> + Magento\Catalog\Model\Indexer\Product\Price\PriceTableResolver + </argument> + </arguments> + </type> + <type name="Magento\CatalogSearch\Model\Adapter\Mysql\Dynamic\DataProvider"> + <arguments> + <argument name="priceTableResolver" xsi:type="object"> + Magento\Catalog\Model\Indexer\Product\Price\PriceTableResolver + </argument> + </arguments> + </type> + <type name="Magento\CatalogSearch\Model\Adapter\Mysql\Aggregation\DataProvider\QueryBuilder"> + <arguments> + <argument name="priceTableResolver" xsi:type="object"> + Magento\Catalog\Model\Indexer\Product\Price\PriceTableResolver + </argument> + </arguments> + </type> </config> From b9611814f633012e0a633a0dfa33f42e809d179a Mon Sep 17 00:00:00 2001 From: Michail Slabko <mslabko@magento.com> Date: Thu, 31 May 2018 15:54:05 +0300 Subject: [PATCH 068/206] MAGETWO-91875: Implement DimensionalIndexerInterface for Simple Product --- .../Indexer/Product/Price/AbstractAction.php | 14 +- .../Indexer/Product/Price/Action/Full.php | 96 +++++---- .../Indexer/Product/Price/TableMaintainer.php | 18 +- ...rice.php => CustomOptionPriceModifier.php} | 193 +++++++++++++++++- .../Product/Indexer/Price/Factory.php | 21 +- .../Indexer/Price/Query/BaseFinalPrice.php | 46 ++++- .../Indexer/Price/SimpleProductPrice.php | 110 ++++++++++ app/code/Magento/Catalog/etc/di.xml | 10 + .../Magento/Catalog/etc/product_types.xml | 2 + .../Indexer/DimensionalIndexerInterface.php | 3 +- 10 files changed, 437 insertions(+), 76 deletions(-) rename app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/{Query/CustomOptionsPrice.php => CustomOptionPriceModifier.php} (64%) create mode 100644 app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/SimpleProductPrice.php diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php index 4ff611aae9829..2a9e28b8baed3 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php @@ -5,6 +5,7 @@ */ namespace Magento\Catalog\Model\Indexer\Product\Price; +use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\PriceInterface; use Magento\Framework\App\ObjectManager; /** @@ -243,14 +244,17 @@ public function getTypeIndexers() $typeInfo['price_indexer'] ) ? $typeInfo['price_indexer'] : get_class($this->_defaultIndexerResource); - $isComposite = !empty($typeInfo['composite']); $indexer = $this->_indexerPriceFactory->create( $modelName - )->setTypeId( - $typeId - )->setIsComposite( - $isComposite ); + // left setters for backward compatibility + if ($indexer instanceof PriceInterface) { + $indexer->setTypeId( + $typeId + )->setIsComposite( + !empty($typeInfo['composite']) + ); + } $this->_indexers[$typeId] = $indexer; } } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php index cb1f07b818449..77c9f941bec2a 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php @@ -60,6 +60,16 @@ class Full extends \Magento\Catalog\Model\Indexer\Product\Price\AbstractAction */ private $configReader; + /** + * @var \Magento\Framework\App\ResourceConnection + */ + private $resource; + + /** + * @var string + */ + private $connectionName; + /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $config * @param \Magento\Store\Model\StoreManagerInterface $storeManager @@ -92,7 +102,9 @@ public function __construct( \Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher $activeTableSwitcher = null, \Magento\Catalog\Model\Indexer\Product\Price\DimensionProviderFactory $dimensionCollectionFactory = null, \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer $dimensionTableMaintainer = null, - \Magento\Framework\App\Config\ScopeConfigInterface $configReader = null + \Magento\Framework\App\Config\ScopeConfigInterface $configReader = null, + \Magento\Framework\App\ResourceConnection $resource = null, + $connectionName = 'indexer' ) { parent::__construct( $config, @@ -125,6 +137,10 @@ public function __construct( $this->configReader = $configReader ?: ObjectManager::getInstance()->get( \Magento\Framework\App\Config\ScopeConfigInterface::class ); + $this->resource = $resource ?? ObjectManager::getInstance()->get( + \Magento\Framework\App\ResourceConnection::class + ); + $this->connectionName = $connectionName; } /** @@ -141,15 +157,15 @@ public function execute($ids = null) $this->prepareTables(); /** @var \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\DefaultPrice $indexer */ - foreach ($this->getTypeIndexers() as $priceIndexer) { - $priceIndexer->getTableStrategy()->setUseIdxTable(false); + foreach ($this->getTypeIndexers() as $typeId => $priceIndexer) { if ($priceIndexer instanceof DimensionalIndexerInterface) { - $this->reindexProductTypeWithDimensions($priceIndexer); + $this->reindexProductTypeWithDimensions($priceIndexer, $typeId); continue; } - $this->reindexProductType($priceIndexer); + $priceIndexer->getTableStrategy()->setUseIdxTable(false); + $this->reindexProductType($priceIndexer, $typeId); } $this->switchTables(); @@ -191,35 +207,35 @@ private function switchTables() } } - private function reindexProductType(PriceInterface $priceIndexer) + private function reindexProductType(PriceInterface $priceIndexer, string $typeId) { - foreach ($this->getBatchesForIndexer($priceIndexer) as $batch) { - $this->reindexBatch($priceIndexer, $batch); + foreach ($this->getBatchesForIndexer($typeId) as $batch) { + $this->reindexBatch($priceIndexer, $batch, $typeId); } } - private function reindexProductTypeWithDimensions(PriceInterface $priceIndexer) + private function reindexProductTypeWithDimensions(DimensionalIndexerInterface $priceIndexer, string $typeId) { /** @var DimensionProviderInterface $dimensionsProviders */ $dimensionsProviders = $this->dimensionCollectionFactory->createByMode( ModeSwitcher::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP ); - foreach ($dimensionsProviders as $dimension) { - $this->reindexDimensions($priceIndexer, $dimension); + foreach ($dimensionsProviders as $dimensions) { + $this->reindexDimensions($priceIndexer, $dimensions, $typeId); } } - private function reindexDimensions(PriceInterface $priceIndexer, array $dimension) + private function reindexDimensions(DimensionalIndexerInterface $priceIndexer, array $dimensions, string $typeId) { - foreach ($this->getBatchesForIndexer($priceIndexer) as $batch) { - $this->reindexBatchWithinDimension($priceIndexer, $batch, $dimension); + foreach ($this->getBatchesForIndexer($typeId) as $batch) { + $this->reindexBatchWithinDimension($priceIndexer, $batch, $dimensions, $typeId); } } - private function reindexBatch(PriceInterface $priceIndexer, array $batch) + private function reindexBatch(PriceInterface $priceIndexer, array $batch, string $typeId) { - $entityIds = $this->getEntityIdsFromBatch($priceIndexer, $batch); + $entityIds = $this->getEntityIdsFromBatch($typeId, $batch); if (!empty($entityIds)) { // Temporary table will created if not exists @@ -242,44 +258,47 @@ private function reindexBatch(PriceInterface $priceIndexer, array $batch) } } - private function reindexBatchWithinDimension(DimensionalIndexerInterface $priceIndexer, array $batch, array $dimensions) + private function reindexBatchWithinDimension(DimensionalIndexerInterface $priceIndexer, array $batch, array $dimensions, string $typeId) { - $entityIds = $this->getEntityIdsFromBatch($priceIndexer, $batch); + $entityIds = $this->getEntityIdsFromBatch($typeId, $batch); if (!empty($entityIds)) { - // Temporary table will created if not exists -// $idxTableName = $this->_defaultIndexerResource->getIdxTableWithinDimension($dimensions); - $idxTableName = $this->_defaultIndexerResource->getIdxTable(); # TODO: replace with appropriate method according to dimension - $this->_emptyTable($idxTableName); + $this->dimensionTableMaintainer->createMainTmpTable($dimensions); + $temporaryTable = $this->dimensionTableMaintainer->getMainTmpTable($dimensions); + $this->_emptyTable($temporaryTable); - if ($priceIndexer->getIsComposite()) { - $this->_copyRelationIndexData($entityIds); - } + // TODO: will be handled in separate task + // if ($priceIndexer->getIsComposite()) { + // $this->_copyRelationIndexData($entityIds); + // } + + // TODO: handle inside index model and move index fulfilment into index model $this->_prepareTierPriceIndex($entityIds); - $priceIndexer->reindexByDimensions($entityIds, $dimensions); + $priceIndexer->executeByDimension($dimensions, \SplFixedArray::fromArray($entityIds)); // Sync data from temp table to index table - $this->_insertFromTable($idxTableName, $this->dimensionTableMaintainer->getMainReplicaTable($dimensions)); - - // Drop temporary index table - $priceIndexer->getConnection()->dropTable($idxTableName); + $this->_insertFromTable( + $temporaryTable, + $this->dimensionTableMaintainer->getMainReplicaTable($dimensions) + ); } } - private function getEntityIdsFromBatch(PriceInterface $priceIndexer, array $batch) + private function getEntityIdsFromBatch(string $typeId, array $batch) { + $connection = $this->resource->getConnection($this->connectionName); // Get entity ids from batch - $select = $priceIndexer->getConnection() + $select = $connection ->select() ->distinct(true) ->from( ['e' => $this->getProductMetaData()->getEntityTable()], $this->getProductMetaData()->getIdentifierField() ) - ->where('type_id = ?', $priceIndexer->getTypeId()); + ->where('type_id = ?', $typeId); - return $this->batchProvider->getBatchIds($priceIndexer->getConnection(), $select, $batch); + return $this->batchProvider->getBatchIds($connection, $select, $batch); } private function getProductMetaData() @@ -298,15 +317,16 @@ private function getReplicaTable() ); } - private function getBatchesForIndexer(PriceInterface $priceIndexer) + private function getBatchesForIndexer(string $typeId) { + $connection = $this->resource->getConnection($this->connectionName); return $this->batchProvider->getBatches( - $priceIndexer->getConnection(), + $connection, $this->getProductMetaData()->getEntityTable(), $this->getProductMetaData()->getIdentifierField(), $this->batchSizeCalculator->estimateBatchSize( - $priceIndexer->getConnection(), - $priceIndexer->getTypeId() + $connection, + $typeId ) ); } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php index 2d27c8c6ef169..6d159b90a1e11 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php @@ -52,27 +52,35 @@ class TableMaintainer */ private $mainTmpTable; + /** + * @var null|string + */ + private $connectionName; + /** * @param ResourceConnection $resource * @param TableResolver $tableResolver + * @param null $connectionName */ public function __construct( ResourceConnection $resource, - TableResolver $tableResolver + TableResolver $tableResolver, + $connectionName = null ) { $this->resource = $resource; $this->tableResolver = $tableResolver; + $this->connectionName = $connectionName; } /** - * Get connection + * Get connection for work with price indexer * * @return AdapterInterface */ - public function getConnection() + public function getConnection(): AdapterInterface { - if (!isset($this->connection)) { - $this->connection = $this->resource->getConnection(); + if (null === $this->connection) { + $this->connection = $this->resource->getConnection($this->connectionName); } return $this->connection; } diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/CustomOptionsPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/CustomOptionPriceModifier.php similarity index 64% rename from app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/CustomOptionsPrice.php rename to app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/CustomOptionPriceModifier.php index 9acea03c28597..64e4cc1fd6bbc 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/CustomOptionsPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/CustomOptionPriceModifier.php @@ -3,12 +3,19 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); -namespace Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\Query; +namespace Magento\Catalog\Model\ResourceModel\Product\Indexer\Price; -use \Magento\Catalog\Api\Data\ProductInterface; +use Magento\Catalog\Api\Data\ProductInterface; +use Magento\Framework\DB\Select; +use Magento\Framework\DB\Sql\ColumnValueExpression; -class CustomOptionsPrice + +/** + * Class for adding catalog rule prices to price index table. + */ +class CustomOptionPriceModifier implements PriceModifierInterface { /** * @var \Magento\Framework\App\ResourceConnection @@ -40,11 +47,22 @@ class CustomOptionsPrice */ private $isPriceGlobalFlag; + /** + * @var \Magento\Framework\DB\Adapter\AdapterInterface + */ + private $connection; + + /** + * @var \Magento\Framework\Indexer\Table\StrategyInterface + */ + private $tableStrategy; + /** * @param \Magento\Framework\App\ResourceConnection $resource * @param \Magento\Framework\EntityManager\MetadataPool $metadataPool * @param \Magento\Framework\DB\Sql\ColumnValueExpressionFactory $columnValueExpressionFactory * @param \Magento\Catalog\Helper\Data $dataHelper + * @param \Magento\Framework\Indexer\Table\StrategyInterface $tableStrategy * @param string $connectionName */ public function __construct( @@ -52,6 +70,7 @@ public function __construct( \Magento\Framework\EntityManager\MetadataPool $metadataPool, \Magento\Framework\DB\Sql\ColumnValueExpressionFactory $columnValueExpressionFactory, \Magento\Catalog\Helper\Data $dataHelper, + \Magento\Framework\Indexer\Table\StrategyInterface $tableStrategy, $connectionName = 'indexer' ) { $this->resource = $resource; @@ -59,9 +78,101 @@ public function __construct( $this->connectionName = $connectionName; $this->columnValueExpressionFactory = $columnValueExpressionFactory; $this->dataHelper = $dataHelper; + $this->tableStrategy = $tableStrategy; + } + + /** + * Apply custom option price to temporary index price table + * + * @param IndexTableStructure $priceTable + * @param array $entityIds + * @return void + * @throws \Exception + */ + public function modifyPrice(IndexTableStructure $priceTable, array $entityIds = []) + { + // no need to run all queries if current products have no custom options + if (!$this->checkIfCustomOptionsExist($priceTable)) { + return ; + } + + $connection = $this->getConnection(); + $finalPriceTable = $priceTable->getTableName(); + + $coaTable = $this->getCustomOptionAggregateTable(); + $this->prepareCustomOptionAggregateTable(); + + $copTable = $this->getCustomOptionPriceTable(); + $this->prepareCustomOptionPriceTable(); + + $select = $this->getSelectForOptionsWithMultipleValues($finalPriceTable); + $query = $select->insertFromSelect($coaTable); + $connection->query($query); + + $select = $this->getSelectForOptionsWithOneValue($finalPriceTable); + $query = $select->insertFromSelect($coaTable); + $connection->query($query); + + $select = $this->getSelectAggregated($coaTable); + $query = $select->insertFromSelect($copTable); + $connection->query($query); + + // update tmp price index with prices from custom options (from previous aggregated table) + $select = $this->getSelectForUpdate($copTable); + $query = $select->crossUpdateFromSelect(['i' => $finalPriceTable]); + $connection->query($query); + + $connection->delete($coaTable); + $connection->delete($copTable); + } + + /** + * @param IndexTableStructure $priceTable + * @return bool + * @throws \Exception + */ + private function checkIfCustomOptionsExist(IndexTableStructure $priceTable): bool + { + $metadata = $this->metadataPool->getMetadata(ProductInterface::class); + + $select = $this->getConnection() + ->select() + ->from( + ['i' => $priceTable->getTableName()], + ['entity_id'] + )->join( + ['e' => $this->getTable('catalog_product_entity')], + 'e.entity_id = i.entity_id', + [] + )->join( + ['o' => $this->getTable('catalog_product_option')], + 'o.product_id = e.' . $metadata->getLinkField(), + ['option_id'] + ); + + return !empty($this->getConnection()->fetchRow($select)); + } + + /** + * @return \Magento\Framework\DB\Adapter\AdapterInterface + */ + private function getConnection() + { + if (null === $this->connection) { + $this->connection = $this->resource->getConnection($this->connectionName); + } + + return $this->connection; } - public function getSelectForOptionsWithMultipleValues($sourceTable) + /** + * Prepare prices for products with custom options that has multiple values + * + * @param string $sourceTable + * @return \Magento\Framework\DB\Select + * @throws \Exception + */ + private function getSelectForOptionsWithMultipleValues(string $sourceTable): Select { $connection = $this->resource->getConnection($this->connectionName); $metadata = $this->metadataPool->getMetadata(ProductInterface::class); @@ -163,7 +274,14 @@ public function getSelectForOptionsWithMultipleValues($sourceTable) return $select; } - public function getSelectForOptionsWithOneValue($sourceTable) + /** + * Prepare prices for products with custom options that has single value + * + * @param string $sourceTable + * @return \Magento\Framework\DB\Select + * @throws \Exception + */ + private function getSelectForOptionsWithOneValue(string $sourceTable): Select { $connection = $this->resource->getConnection($this->connectionName); $metadata = $this->metadataPool->getMetadata(ProductInterface::class); @@ -242,7 +360,13 @@ public function getSelectForOptionsWithOneValue($sourceTable) return $select; } - public function getSelectAggregated($sourceTable) + /** + * Aggregate prices with one and multiply options into one table + * + * @param string $sourceTable + * @return \Magento\Framework\DB\Select + */ + private function getSelectAggregated(string $sourceTable): Select { $connection = $this->resource->getConnection($this->connectionName); @@ -264,7 +388,11 @@ public function getSelectAggregated($sourceTable) return $select; } - public function getSelectForUpdate($sourceTable) + /** + * @param string $sourceTable + * @return \Magento\Framework\DB\Select + */ + private function getSelectForUpdate(string $sourceTable): Select { $connection = $this->resource->getConnection($this->connectionName); @@ -276,8 +404,8 @@ public function getSelectForUpdate($sourceTable) ); $select->columns( [ - 'min_price' => new \Zend_Db_Expr('i.min_price + io.min_price'), - 'max_price' => new \Zend_Db_Expr('i.max_price + io.max_price'), + 'min_price' => new ColumnValueExpression('i.min_price + io.min_price'), + 'max_price' => new ColumnValueExpression('i.max_price + io.max_price'), 'tier_price' => $connection->getCheckSql( 'i.tier_price IS NOT NULL', 'i.tier_price + io.tier_price', @@ -293,12 +421,15 @@ public function getSelectForUpdate($sourceTable) * @param string $tableName * @return string */ - private function getTable($tableName) + private function getTable(string $tableName): string { return $this->resource->getTableName($tableName, $this->connectionName); } - private function isPriceGlobal() + /** + * @return bool + */ + private function isPriceGlobal(): bool { if ($this->isPriceGlobalFlag === null) { $this->isPriceGlobalFlag = $this->dataHelper->isPriceGlobal(); @@ -306,4 +437,44 @@ private function isPriceGlobal() return $this->isPriceGlobalFlag; } + + /** + * Retrieve table name for custom option temporary aggregation data + * + * @return string + */ + private function getCustomOptionAggregateTable(): string + { + return $this->tableStrategy->getTableName('catalog_product_index_price_opt_agr'); + } + + /** + * Retrieve table name for custom option prices data + * + * @return string + */ + private function getCustomOptionPriceTable(): string + { + return $this->tableStrategy->getTableName('catalog_product_index_price_opt'); + } + + /** + * Prepare table structure for custom option temporary aggregation data + * + * @return void + */ + private function prepareCustomOptionAggregateTable() + { + $this->getConnection()->delete($this->getCustomOptionAggregateTable()); + } + + /** + * Prepare table structure for custom option prices data + * + * @return void + */ + private function prepareCustomOptionPriceTable() + { + $this->getConnection()->delete($this->getCustomOptionPriceTable()); + } } diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Factory.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Factory.php index 21a7647214c26..9a310c7365ac9 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Factory.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Factory.php @@ -9,6 +9,8 @@ */ namespace Magento\Catalog\Model\ResourceModel\Product\Indexer\Price; +use Magento\Framework\Indexer\DimensionalIndexerInterface; + class Factory { /** @@ -40,14 +42,17 @@ public function create($className, array $data = []) { $indexerPrice = $this->_objectManager->create($className, $data); - if (!$indexerPrice instanceof \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\DefaultPrice) { - throw new \Magento\Framework\Exception\LocalizedException( - __( - '%1 doesn\'t extend \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\DefaultPrice', - $className - ) - ); + if ($indexerPrice instanceof PriceInterface || $indexerPrice instanceof DimensionalIndexerInterface) { + return $indexerPrice; } - return $indexerPrice; + + throw new \Magento\Framework\Exception\LocalizedException( + __( + 'Price indexer "%1" must implement %2 or %3', + $className, + PriceInterface::class, + DimensionalIndexerInterface::class + ) + ); } } diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php index 8bd77c644fa4b..bf3eea40a908a 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php @@ -8,7 +8,11 @@ namespace Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\Query; use Magento\Catalog\Model\Product\Attribute\Source\Status; +use Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProvider; use Magento\Framework\DB\Select; +use Magento\Framework\DB\Sql\ColumnValueExpression; +use Magento\Framework\Exception\InputException; +use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; /** * Prepare base select for Product Price index limited by specified dimensions: website and customer group @@ -35,6 +39,11 @@ class BaseFinalPrice */ private $moduleManager; + /** + * @var \Magento\Framework\Event\ManagerInterface + */ + private $eventManager; + /** * BaseFinalPrice constructor. * @param \Magento\Framework\App\ResourceConnection $resource @@ -46,25 +55,34 @@ public function __construct( \Magento\Framework\App\ResourceConnection $resource, JoinAttributeProcessor $joinAttributeProcessor, \Magento\Framework\Module\Manager $moduleManager, + \Magento\Framework\Event\ManagerInterface $eventManager, $connectionName = 'indexer' ) { $this->resource = $resource; $this->connectionName = $connectionName; $this->joinAttributeProcessor = $joinAttributeProcessor; $this->moduleManager = $moduleManager; + $this->eventManager = $eventManager; } /** - * @param int $websiteId - * @param int $customerGroupId + * @param array $dimensions * @param string $productType * @param array $entityIds * @return Select + * @throws \Magento\Framework\Exception\InputException * @throws \Magento\Framework\Exception\LocalizedException * @throws \Zend_Db_Select_Exception */ - public function getQuery(int $websiteId, int $customerGroupId, string $productType, array $entityIds = []): Select + public function getQuery(array $dimensions, string $productType, array $entityIds = []): Select { + if (!isset($dimensions[WebsiteDataProvider::DIMENSION_NAME], + $dimensions[CustomerGroupDataProvider::DIMENSION_NAME]) + ) { + throw new InputException(__('All dimensions for product index price must be provided')); + } + $websiteId = $dimensions[WebsiteDataProvider::DIMENSION_NAME]->getValue(); + $customerGroupId = $dimensions[CustomerGroupDataProvider::DIMENSION_NAME]->getValue(); $connection = $this->resource->getConnection($this->connectionName); $select = $connection->select()->from( @@ -114,7 +132,7 @@ public function getQuery(int $websiteId, int $customerGroupId, string $productTy $specialPrice, $maxUnsignedBigint ); - $tierPrice = new \Zend_Db_Expr('tp.min_price'); + $tierPrice = new ColumnValueExpression('tp.min_price'); $tierPriceExpr = $connection->getIfNullSql( $tierPrice, $maxUnsignedBigint @@ -127,12 +145,11 @@ public function getQuery(int $websiteId, int $customerGroupId, string $productTy $select->columns( [ - 'orig_price' => $connection->getIfNullSql($price, 0), - 'price' => $connection->getIfNullSql($finalPrice, 0), + 'price' => $connection->getIfNullSql($price, 0), //orig_price in catalog_product_index_price_final_tmp + 'final_price' => $connection->getIfNullSql($finalPrice, 0), //price in catalog_product_index_price_final_tmp 'min_price' => $connection->getIfNullSql($finalPrice, 0), 'max_price' => $connection->getIfNullSql($finalPrice, 0), 'tier_price' => $tierPrice, - 'base_tier' => $tierPrice, ] ); @@ -142,6 +159,21 @@ public function getQuery(int $websiteId, int $customerGroupId, string $productTy $select->where(sprintf('e.entity_id BETWEEN %s AND %s', min($entityIds), max($entityIds))); } + /** + * throw event for backward compatibility + */ + $this->eventManager->dispatch( + 'prepare_catalog_product_index_select', + [ + 'select' => $select, + 'entity_field' => new ColumnValueExpression('e.entity_id'), + 'website_field' => new ColumnValueExpression('pw.website_id'), + 'store_field' => new ColumnValueExpression('cwd.default_store_id'), + 'website_id' => new ColumnValueExpression($websiteId), + 'customer_group_id' => new ColumnValueExpression($customerGroupId), + ] + ); + return $select; } diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/SimpleProductPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/SimpleProductPrice.php new file mode 100644 index 0000000000000..6de02fa1729e1 --- /dev/null +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/SimpleProductPrice.php @@ -0,0 +1,110 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); +namespace Magento\Catalog\Model\ResourceModel\Product\Indexer\Price; + +use Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer; +use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\Query\BaseFinalPrice; +use Magento\Framework\App\ResourceConnection; +use Magento\Framework\Indexer\DimensionalIndexerInterface; + +/** + * Simple Product Type Price Indexer + */ +class SimpleProductPrice implements DimensionalIndexerInterface +{ + /** + * @var BaseFinalPrice + */ + private $baseFinalPrice; + + /** + * @var IndexTableStructureFactory + */ + private $indexTableStructureFactory; + + /** + * @var TableMaintainer + */ + private $tableMaintainer; + + /** + * @var string + */ + private $typeId; + + /** + * @var PriceModifierInterface[] + */ + private $priceModifiers; + + /** + * @param BaseFinalPrice $baseFinalPrice + * @param IndexTableStructureFactory $indexTableStructureFactory + * @param TableMaintainer $tableMaintainer + * @param string $typeId + * @param array $priceModifiers + */ + public function __construct( + BaseFinalPrice $baseFinalPrice, + IndexTableStructureFactory $indexTableStructureFactory, + TableMaintainer $tableMaintainer, + $typeId = \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE, + array $priceModifiers = [] + ) { + + $this->baseFinalPrice = $baseFinalPrice; + $this->indexTableStructureFactory = $indexTableStructureFactory; + $this->tableMaintainer = $tableMaintainer; + $this->typeId = $typeId; + $this->priceModifiers = $priceModifiers; + } + + /** + * Execute indexer by specified dimension. + * Accept array of dimensions DTO that represent indexer dimension + * + * @param \Magento\Framework\Indexer\Dimension[] $dimensions + * @param \Traversable|null $entityIds + * @return void + * @throws \Magento\Framework\Exception\LocalizedException + * @throws \Magento\Framework\Exception\InputException + * @throws \Zend_Db_Select_Exception + */ + public function executeByDimension(array $dimensions, \Traversable $entityIds = null) + { + $temporaryPriceTable = $this->indexTableStructureFactory->create([ + 'tableName' => $this->tableMaintainer->getMainTmpTable($dimensions), + 'entityField' => 'entity_id', + 'customerGroupField' => 'customer_group_id', + 'websiteField' => 'website_id', + 'taxClassField' => 'tax_class_id', + 'originalPriceField' => 'price', + 'finalPriceField' => 'final_price', + 'minPriceField' => 'min_price', + 'maxPriceField' => 'max_price', + 'tierPriceField' => 'tier_price', + ]); + $select = $this->baseFinalPrice->getQuery($dimensions, $this->typeId, iterator_to_array($entityIds)); + $query = $select->insertFromSelect($temporaryPriceTable->getTableName(), [], false); + $this->tableMaintainer->getConnection()->query($query); + + $this->applyPriceModifiers($temporaryPriceTable); + } + + /** + * Apply price modifiers to temporary price index table + * + * @param IndexTableStructure $temporaryPriceTable + * @return void + */ + private function applyPriceModifiers(IndexTableStructure $temporaryPriceTable) + { + foreach ($this->priceModifiers as $priceModifier) { + $priceModifier->modifyPrice($temporaryPriceTable); + } + } +} diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml index 0286531457145..1606b98bd2267 100644 --- a/app/code/Magento/Catalog/etc/di.xml +++ b/app/code/Magento/Catalog/etc/di.xml @@ -1124,4 +1124,14 @@ </argument> </arguments> </type> + <type name="Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\CustomOptionPriceModifier"> + <arguments> + <argument name="tableStrategy" xsi:type="object">Magento\Catalog\Model\ResourceModel\Product\Indexer\TemporaryTableStrategy</argument> + </arguments> + </type> + <type name="Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer"> + <arguments> + <argument name="connectionName" xsi:type="string">indexer</argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/Catalog/etc/product_types.xml b/app/code/Magento/Catalog/etc/product_types.xml index fe4922ab8fa1f..9072249b40bd6 100644 --- a/app/code/Magento/Catalog/etc/product_types.xml +++ b/app/code/Magento/Catalog/etc/product_types.xml @@ -7,11 +7,13 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Catalog:etc/product_types.xsd"> <type name="simple" label="Simple Product" modelInstance="Magento\Catalog\Model\Product\Type\Simple" indexPriority="10" sortOrder="10"> + <indexerModel instance="Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\SimpleProductPrice" /> <customAttributes> <attribute name="refundable" value="true"/> </customAttributes> </type> <type name="virtual" label="Virtual Product" modelInstance="Magento\Catalog\Model\Product\Type\Virtual" indexPriority="20" sortOrder="40"> + <indexerModel instance="Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\SimpleProductPrice" /> <customAttributes> <attribute name="is_real_product" value="false"/> <attribute name="refundable" value="false"/> diff --git a/lib/internal/Magento/Framework/Indexer/DimensionalIndexerInterface.php b/lib/internal/Magento/Framework/Indexer/DimensionalIndexerInterface.php index 7a0ad1e8143d3..b6ee900d6220f 100644 --- a/lib/internal/Magento/Framework/Indexer/DimensionalIndexerInterface.php +++ b/lib/internal/Magento/Framework/Indexer/DimensionalIndexerInterface.php @@ -8,7 +8,6 @@ namespace Magento\Framework\Indexer; /** - * @api * Run indexer by dimensions */ interface DimensionalIndexerInterface @@ -21,5 +20,5 @@ interface DimensionalIndexerInterface * @param array|null $entityIds * @return void */ - public function reindexByDimensions(array $dimensions, array $entityIds = null); + public function executeByDimension(array $dimensions, \Traversable $entityIds = null); } \ No newline at end of file From bc562087462cb264cdfdcd543b771d266dfd7f8d Mon Sep 17 00:00:00 2001 From: Michail Slabko <mslabko@magento.com> Date: Thu, 31 May 2018 15:58:14 +0300 Subject: [PATCH 069/206] MAGETWO-91875: Implement DimensionalIndexerInterface for Simple Product --- .../Product/Indexer/Price/DefaultPrice.php | 377 ++++++++++++++---- 1 file changed, 295 insertions(+), 82 deletions(-) diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php index 1c844a53c162a..1de0a480c9fbc 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php @@ -5,14 +5,7 @@ */ namespace Magento\Catalog\Model\ResourceModel\Product\Indexer\Price; -use Magento\Catalog\Model\Indexer\Product\Price\DimensionProviderFactory; use Magento\Catalog\Model\ResourceModel\Product\Indexer\AbstractIndexer; -use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\Query\BaseFinalPrice; -use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\Query\CustomOptionsPrice; -use Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProvider; -use Magento\Framework\App\ObjectManager; -use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; -use Magento\Catalog\Model\Indexer\Product\Price\ModeSwitcher; /** * Default Product Type Price Indexer Resource model @@ -70,21 +63,8 @@ class DefaultPrice extends AbstractIndexer implements PriceInterface private $priceModifiers = []; /** - * @var BaseFinalPrice - */ - private $baseFinalPrice; - - /** - * @var CustomOptionsPrice - */ - private $customOptionsPrice; - - /** - * @var DimensionCollectionFactory - */ - private $dimensionCollectionFactory; - - /** + * DefaultPrice constructor. + * * @param \Magento\Framework\Model\ResourceModel\Db\Context $context * @param \Magento\Framework\Indexer\Table\StrategyInterface $tableStrategy * @param \Magento\Eav\Model\Config $eavConfig @@ -102,9 +82,6 @@ public function __construct( \Magento\Framework\Module\Manager $moduleManager, $connectionName = null, IndexTableStructureFactory $indexTableStructureFactory = null, - BaseFinalPrice $baseFinalPrice = null, - CustomOptionsPrice $customOptionsPrice = null, - DimensionProviderFactory $dimensionCollectionFactory = null, array $priceModifiers = [] ) { $this->_eventManager = $eventManager; @@ -112,7 +89,7 @@ public function __construct( parent::__construct($context, $tableStrategy, $eavConfig, $connectionName); $this->indexTableStructureFactory = $indexTableStructureFactory ?: - ObjectManager::getInstance()->get(IndexTableStructureFactory::class); + \Magento\Framework\App\ObjectManager::getInstance()->get(IndexTableStructureFactory::class); foreach ($priceModifiers as $priceModifier) { if (!($priceModifier instanceof PriceModifierInterface)) { throw new \InvalidArgumentException( @@ -122,10 +99,6 @@ public function __construct( $this->priceModifiers[] = $priceModifier; } - $this->baseFinalPrice = $baseFinalPrice ?? ObjectManager::getInstance()->get(BaseFinalPrice::class); - $this->customOptionsPrice = $baseFinalPrice ?? ObjectManager::getInstance()->get(CustomOptionsPrice::class); - $this->dimensionCollectionFactory = $dimensionCollectionFactory - ?? ObjectManager::getInstance()->get(DimensionProviderFactory::class); } /** @@ -330,19 +303,10 @@ protected function prepareFinalPriceDataForType($entityIds, $type) { $finalPriceTable = $this->prepareFinalPriceTable(); - $dimensions = $this->dimensionCollectionFactory->createByMode( - ModeSwitcher::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP - ); - foreach ($dimensions as $dimension) { - $select = $this->getSelect( - $entityIds, - $type, - $dimension[WebsiteDataProvider::DIMENSION_NAME]->getValue(), - $dimension[CustomerGroupDataProvider::DIMENSION_NAME]->getValue() - ); - $query = $select->insertFromSelect($finalPriceTable->getTableName(), [], false); - $this->getConnection()->query($query); - } + $select = $this->getSelect($entityIds, $type); + $query = $select->insertFromSelect($finalPriceTable->getTableName(), [], false); + $this->getConnection()->query($query); + $this->applyDiscountPrices($finalPriceTable); return $this; @@ -360,9 +324,135 @@ protected function prepareFinalPriceDataForType($entityIds, $type) * @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @since 101.0.8 */ - protected function getSelect($entityIds = null, $type = null, int $websiteId = null, int $customerGroupId = null) + protected function getSelect($entityIds = null, $type = null) { - $select = $this->baseFinalPrice->getQuery($websiteId, $customerGroupId, $type, $entityIds); + $metadata = $this->getMetadataPool()->getMetadata(\Magento\Catalog\Api\Data\ProductInterface::class); + $connection = $this->getConnection(); + $select = $connection->select()->from( + ['e' => $this->getTable('catalog_product_entity')], + ['entity_id'] + )->join( + ['cg' => $this->getTable('customer_group')], + '', + ['customer_group_id'] + )->join( + ['cw' => $this->getTable('store_website')], + '', + ['website_id'] + )->join( + ['cwd' => $this->_getWebsiteDateTable()], + 'cw.website_id = cwd.website_id', + [] + )->join( + ['csg' => $this->getTable('store_group')], + 'csg.website_id = cw.website_id AND cw.default_group_id = csg.group_id', + [] + )->join( + ['cs' => $this->getTable('store')], + 'csg.default_store_id = cs.store_id AND cs.store_id != 0', + [] + )->join( + ['pw' => $this->getTable('catalog_product_website')], + 'pw.product_id = e.entity_id AND pw.website_id = cw.website_id', + [] + )->joinLeft( + ['tp' => $this->_getTierPriceIndexTable()], + 'tp.entity_id = e.entity_id AND tp.website_id = cw.website_id' . + ' AND tp.customer_group_id = cg.customer_group_id', + [] + ); + + if ($type !== null) { + $select->where('e.type_id = ?', $type); + } + + // add enable products limitation + $statusCond = $connection->quoteInto( + '=?', + \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED + ); + $this->_addAttributeToSelect( + $select, + 'status', + 'e.' . $metadata->getLinkField(), + 'cs.store_id', + $statusCond, + true + ); + if ($this->moduleManager->isEnabled('Magento_Tax')) { + $taxClassId = $this->_addAttributeToSelect( + $select, + 'tax_class_id', + 'e.' . $metadata->getLinkField(), + 'cs.store_id' + ); + } else { + $taxClassId = new \Zend_Db_Expr('0'); + } + $select->columns(['tax_class_id' => $taxClassId]); + + $price = $this->_addAttributeToSelect( + $select, + 'price', + 'e.' . $metadata->getLinkField(), + 'cs.store_id' + ); + $specialPrice = $this->_addAttributeToSelect( + $select, + 'special_price', + 'e.' . $metadata->getLinkField(), + 'cs.store_id' + ); + $specialFrom = $this->_addAttributeToSelect( + $select, + 'special_from_date', + 'e.' . $metadata->getLinkField(), + 'cs.store_id' + ); + $specialTo = $this->_addAttributeToSelect( + $select, + 'special_to_date', + 'e.' . $metadata->getLinkField(), + 'cs.store_id' + ); + $currentDate = 'cwd.website_date'; + + $maxUnsignedBigint = '~0'; + $specialFromDate = $connection->getDatePartSql($specialFrom); + $specialToDate = $connection->getDatePartSql($specialTo); + $specialFromExpr = "{$specialFrom} IS NULL OR {$specialFromDate} <= {$currentDate}"; + $specialToExpr = "{$specialTo} IS NULL OR {$specialToDate} >= {$currentDate}"; + $specialPriceExpr = $connection->getCheckSql( + "{$specialPrice} IS NOT NULL AND {$specialFromExpr} AND {$specialToExpr}", + $specialPrice, + $maxUnsignedBigint + ); + $tierPrice = new \Zend_Db_Expr('tp.min_price'); + $tierPriceExpr = $connection->getIfNullSql( + $tierPrice, + $maxUnsignedBigint + ); + $finalPrice = $connection->getLeastSql([ + $price, + $specialPriceExpr, + $tierPriceExpr, + ]); + + $select->columns( + [ + 'orig_price' => $connection->getIfNullSql($price, 0), + 'price' => $connection->getIfNullSql($finalPrice, 0), + 'min_price' => $connection->getIfNullSql($finalPrice, 0), + 'max_price' => $connection->getIfNullSql($finalPrice, 0), + 'tier_price' => $tierPrice, + 'base_tier' => $tierPrice, + ] + ); + + if ($entityIds !== null) { + $select->where('e.entity_id IN(?)', $entityIds); + } + /** * Add additional external limitation */ @@ -371,10 +461,8 @@ protected function getSelect($entityIds = null, $type = null, int $websiteId = n [ 'select' => $select, 'entity_field' => new \Zend_Db_Expr('e.entity_id'), - 'website_field' => new \Zend_Db_Expr('pw.website_id'), - 'store_field' => new \Zend_Db_Expr('cwd.default_store_id'), - 'website_id' => $websiteId, - 'customer_group_id' => $customerGroupId, + 'website_field' => new \Zend_Db_Expr('cw.website_id'), + 'store_field' => new \Zend_Db_Expr('cs.store_id'), ] ); @@ -444,38 +532,179 @@ private function applyDiscountPrices(IndexTableStructure $finalPriceTable) */ protected function _applyCustomOption() { - // no need to run all queries if current products have no custom options - if (!$this->checkIfCustomOptionsExist()) { - return $this; - } - $connection = $this->getConnection(); $finalPriceTable = $this->_getDefaultFinalPriceTable(); - $coaTable = $this->_getCustomOptionAggregateTable(); - $this->_prepareCustomOptionAggregateTable(); - $copTable = $this->_getCustomOptionPriceTable(); + $metadata = $this->getMetadataPool()->getMetadata(\Magento\Catalog\Api\Data\ProductInterface::class); + + $this->_prepareCustomOptionAggregateTable(); $this->_prepareCustomOptionPriceTable(); - // prepare prices for products with custom options that has multiple values - $select = $this->customOptionsPrice->getSelectForOptionsWithMultipleValues($finalPriceTable); + $select = $connection->select()->from( + ['i' => $finalPriceTable], + ['entity_id', 'customer_group_id', 'website_id'] + )->join( + ['e' => $this->getTable('catalog_product_entity')], + 'e.entity_id = i.entity_id', + [] + )->join( + ['cw' => $this->getTable('store_website')], + 'cw.website_id = i.website_id', + [] + )->join( + ['csg' => $this->getTable('store_group')], + 'csg.group_id = cw.default_group_id', + [] + )->join( + ['cs' => $this->getTable('store')], + 'cs.store_id = csg.default_store_id', + [] + )->join( + ['o' => $this->getTable('catalog_product_option')], + 'o.product_id = e.' . $metadata->getLinkField(), + ['option_id'] + )->join( + ['ot' => $this->getTable('catalog_product_option_type_value')], + 'ot.option_id = o.option_id', + [] + )->join( + ['otpd' => $this->getTable('catalog_product_option_type_price')], + 'otpd.option_type_id = ot.option_type_id AND otpd.store_id = 0', + [] + )->joinLeft( + ['otps' => $this->getTable('catalog_product_option_type_price')], + 'otps.option_type_id = otpd.option_type_id AND otpd.store_id = cs.store_id', + [] + )->group( + ['i.entity_id', 'i.customer_group_id', 'i.website_id', 'o.option_id'] + ); + + $optPriceType = $connection->getCheckSql('otps.option_type_price_id > 0', 'otps.price_type', 'otpd.price_type'); + $optPriceValue = $connection->getCheckSql('otps.option_type_price_id > 0', 'otps.price', 'otpd.price'); + $minPriceRound = new \Zend_Db_Expr("ROUND(i.price * ({$optPriceValue} / 100), 4)"); + $minPriceExpr = $connection->getCheckSql("{$optPriceType} = 'fixed'", $optPriceValue, $minPriceRound); + $minPriceMin = new \Zend_Db_Expr("MIN({$minPriceExpr})"); + $minPrice = $connection->getCheckSql("MIN(o.is_require) = 1", $minPriceMin, '0'); + + $tierPriceRound = new \Zend_Db_Expr("ROUND(i.base_tier * ({$optPriceValue} / 100), 4)"); + $tierPriceExpr = $connection->getCheckSql("{$optPriceType} = 'fixed'", $optPriceValue, $tierPriceRound); + $tierPriceMin = new \Zend_Db_Expr("MIN({$tierPriceExpr})"); + $tierPriceValue = $connection->getCheckSql("MIN(o.is_require) > 0", $tierPriceMin, 0); + $tierPrice = $connection->getCheckSql("MIN(i.base_tier) IS NOT NULL", $tierPriceValue, "NULL"); + + $maxPriceRound = new \Zend_Db_Expr("ROUND(i.price * ({$optPriceValue} / 100), 4)"); + $maxPriceExpr = $connection->getCheckSql("{$optPriceType} = 'fixed'", $optPriceValue, $maxPriceRound); + $maxPrice = $connection->getCheckSql( + "(MIN(o.type)='radio' OR MIN(o.type)='drop_down')", + "MAX({$maxPriceExpr})", + "SUM({$maxPriceExpr})" + ); + + $select->columns( + [ + 'min_price' => $minPrice, + 'max_price' => $maxPrice, + 'tier_price' => $tierPrice, + ] + ); + $query = $select->insertFromSelect($coaTable); $connection->query($query); - // prepare prices for products with custom options that has single value - $select = $this->customOptionsPrice->getSelectForOptionsWithOneValue($finalPriceTable); + $select = $connection->select()->from( + ['i' => $finalPriceTable], + ['entity_id', 'customer_group_id', 'website_id'] + )->join( + ['e' => $this->getTable('catalog_product_entity')], + 'e.entity_id = i.entity_id', + [] + )->join( + ['cw' => $this->getTable('store_website')], + 'cw.website_id = i.website_id', + [] + )->join( + ['csg' => $this->getTable('store_group')], + 'csg.group_id = cw.default_group_id', + [] + )->join( + ['cs' => $this->getTable('store')], + 'cs.store_id = csg.default_store_id', + [] + )->join( + ['o' => $this->getTable('catalog_product_option')], + 'o.product_id = e.' . $metadata->getLinkField(), + ['option_id'] + )->join( + ['opd' => $this->getTable('catalog_product_option_price')], + 'opd.option_id = o.option_id AND opd.store_id = 0', + [] + )->joinLeft( + ['ops' => $this->getTable('catalog_product_option_price')], + 'ops.option_id = opd.option_id AND ops.store_id = cs.store_id', + [] + ); + + $optPriceType = $connection->getCheckSql('ops.option_price_id > 0', 'ops.price_type', 'opd.price_type'); + $optPriceValue = $connection->getCheckSql('ops.option_price_id > 0', 'ops.price', 'opd.price'); + + $minPriceRound = new \Zend_Db_Expr("ROUND(i.price * ({$optPriceValue} / 100), 4)"); + $priceExpr = $connection->getCheckSql("{$optPriceType} = 'fixed'", $optPriceValue, $minPriceRound); + $minPrice = $connection->getCheckSql("{$priceExpr} > 0 AND o.is_require = 1", $priceExpr, 0); + + $maxPrice = $priceExpr; + + $tierPriceRound = new \Zend_Db_Expr("ROUND(i.base_tier * ({$optPriceValue} / 100), 4)"); + $tierPriceExpr = $connection->getCheckSql("{$optPriceType} = 'fixed'", $optPriceValue, $tierPriceRound); + $tierPriceValue = $connection->getCheckSql("{$tierPriceExpr} > 0 AND o.is_require = 1", $tierPriceExpr, 0); + $tierPrice = $connection->getCheckSql("i.base_tier IS NOT NULL", $tierPriceValue, "NULL"); + + $select->columns( + [ + 'min_price' => $minPrice, + 'max_price' => $maxPrice, + 'tier_price' => $tierPrice, + ] + ); + $query = $select->insertFromSelect($coaTable); $connection->query($query); - // aggregate prices from previous two cases into one table - $select = $this->customOptionsPrice->getSelectAggregated($coaTable); + $select = $connection->select()->from( + [$coaTable], + [ + 'entity_id', + 'customer_group_id', + 'website_id', + 'min_price' => 'SUM(min_price)', + 'max_price' => 'SUM(max_price)', + 'tier_price' => 'SUM(tier_price)', + ] + )->group( + ['entity_id', 'customer_group_id', 'website_id'] + ); $query = $select->insertFromSelect($copTable); $connection->query($query); - // update tmp price index with prices from custom options (from previous aggregated table) - $select = $this->customOptionsPrice->getSelectForUpdate($copTable); - $query = $select->crossUpdateFromSelect(['i' => $finalPriceTable]); + $table = ['i' => $finalPriceTable]; + $select = $connection->select()->join( + ['io' => $copTable], + 'i.entity_id = io.entity_id AND i.customer_group_id = io.customer_group_id' . + ' AND i.website_id = io.website_id', + [] + ); + $select->columns( + [ + 'min_price' => new \Zend_Db_Expr('i.min_price + io.min_price'), + 'max_price' => new \Zend_Db_Expr('i.max_price + io.max_price'), + 'tier_price' => $connection->getCheckSql( + 'i.tier_price IS NOT NULL', + 'i.tier_price + io.tier_price', + 'NULL' + ), + ] + ); + $query = $select->crossUpdateFromSelect($table); $connection->query($query); $connection->delete($coaTable); @@ -484,22 +713,6 @@ protected function _applyCustomOption() return $this; } - private function checkIfCustomOptionsExist() - { - $select = $this->getConnection() - ->select() - ->from( - ['i' => $this->_getDefaultFinalPriceTable()], - ['entity_id'] - )->join( - ['o' => $this->getTable('catalog_product_option')], - 'o.product_id = i.entity_id', - [] - ); - - return !empty($this->getConnection()->fetchRow($select)); - } - /** * Mode Final Prices index to primary temporary index table * From 2a5cf4e0cdbbccb5ba1582cfcac95b460067bad8 Mon Sep 17 00:00:00 2001 From: Andrii Voskoboinikov <avoskoboinikov@magento.com> Date: Thu, 31 May 2018 18:18:55 +0300 Subject: [PATCH 070/206] MAGETWO-91875: Implement DimensionalIndexerInterface for Simple Product --- .../Bundle/Model/ResourceModel/Indexer/Price.php | 3 ++- .../Model/Indexer/Product/Price/Action/Full.php | 3 --- .../Product/Indexer/Price/DefaultPrice.php | 12 +++++++++++- .../Product/Indexer/Price/Configurable.php | 4 +++- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/app/code/Magento/Bundle/Model/ResourceModel/Indexer/Price.php b/app/code/Magento/Bundle/Model/ResourceModel/Indexer/Price.php index 32f13e9457217..fe41098d3a565 100644 --- a/app/code/Magento/Bundle/Model/ResourceModel/Indexer/Price.php +++ b/app/code/Magento/Bundle/Model/ResourceModel/Indexer/Price.php @@ -274,6 +274,7 @@ protected function _calculateBundleOptionPrice() protected function _calculateBundleSelectionPrice($priceType) { $connection = $this->getConnection(); + $indexReplicaTable = $this->activeTableSwitcher->getAdditionalTableName($this->getMainTable()); if ($priceType == \Magento\Bundle\Model\Product\Price::PRICE_TYPE_FIXED) { $selectionPriceValue = $connection->getCheckSql( @@ -355,7 +356,7 @@ protected function _calculateBundleSelectionPrice($priceType) 'bs.selection_id = bsp.selection_id AND bsp.website_id = i.website_id', [''] )->join( - ['idx' => $this->getIdxTable()], + ['idx' => $indexReplicaTable], 'bs.product_id = idx.entity_id AND i.customer_group_id = idx.customer_group_id' . ' AND i.website_id = idx.website_id', [] diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php index 77c9f941bec2a..4c12c57c6ef51 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php @@ -242,9 +242,6 @@ private function reindexBatch(PriceInterface $priceIndexer, array $batch, string $idxTableName = $this->_defaultIndexerResource->getIdxTable(); $this->_emptyTable($idxTableName); - if ($priceIndexer->getIsComposite()) { - $this->_copyRelationIndexData($entityIds); - } $this->_prepareTierPriceIndex($entityIds); // Reindex entities by id diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php index 1de0a480c9fbc..108ae654f6533 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php @@ -62,6 +62,11 @@ class DefaultPrice extends AbstractIndexer implements PriceInterface */ private $priceModifiers = []; + /** + * @var \Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher + */ + protected $activeTableSwitcher; + /** * DefaultPrice constructor. * @@ -82,7 +87,8 @@ public function __construct( \Magento\Framework\Module\Manager $moduleManager, $connectionName = null, IndexTableStructureFactory $indexTableStructureFactory = null, - array $priceModifiers = [] + array $priceModifiers = [], + \Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher $activeTableSwitcher = null ) { $this->_eventManager = $eventManager; $this->moduleManager = $moduleManager; @@ -99,6 +105,10 @@ public function __construct( $this->priceModifiers[] = $priceModifier; } + + $this->activeTableSwitcher = $activeTableSwitcher ?: ObjectManager::getInstance()->get( + \Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher::class + ); } /** diff --git a/app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Indexer/Price/Configurable.php b/app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Indexer/Price/Configurable.php index a8fb60a4dcb22..7c5006789c9a2 100644 --- a/app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Indexer/Price/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Indexer/Price/Configurable.php @@ -76,6 +76,7 @@ protected function _prepareConfigurableOptionPriceTable() * * @param null|int|array $entityIds * @return \Magento\ConfigurableProduct\Model\ResourceModel\Product\Indexer\Price\Configurable + * @throws \Magento\Framework\Exception\LocalizedException */ protected function _applyConfigurableOption($entityIds = null) { @@ -84,11 +85,12 @@ protected function _applyConfigurableOption($entityIds = null) $copTable = $this->_getConfigurableOptionPriceTable(); $finalPriceTable = $this->_getDefaultFinalPriceTable(); $linkField = $metadata->getLinkField(); + $indexReplicaTable = $this->activeTableSwitcher->getAdditionalTableName($this->getMainTable()); $this->_prepareConfigurableOptionPriceTable(); $select = $connection->select()->from( - ['i' => $this->getIdxTable()], + ['i' => $indexReplicaTable], [] )->join( ['l' => $this->getTable('catalog_product_super_link')], From 92835cbfe1015c9d83e001a0d6e6bc719e88b0cd Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi <alugovyi@magento.com> Date: Thu, 31 May 2018 21:58:19 +0300 Subject: [PATCH 071/206] MAGETWO-91873: Create table resolver for price index --- .../ResourceModel/Layer/Filter/PriceTest.php | 48 ------------------- ...edProductSelectBuilderByIndexPriceTest.php | 18 ++++++- .../Search/FilterMapper/ExclusionStrategy.php | 5 +- .../DataProvider/QueryBuilderTest.php | 19 ++++++-- .../Mysql/Dynamic/DataProviderTest.php | 20 ++++++-- .../FilterMapper/ExclusionStrategyTest.php | 23 ++++++++- 6 files changed, 70 insertions(+), 63 deletions(-) delete mode 100644 app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Layer/Filter/PriceTest.php diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Layer/Filter/PriceTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Layer/Filter/PriceTest.php deleted file mode 100644 index 9fba7d833c25a..0000000000000 --- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Layer/Filter/PriceTest.php +++ /dev/null @@ -1,48 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Layer\Filter; - -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; - -class PriceTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var \Magento\Catalog\Model\ResourceModel\Layer\Filter\Price - */ - private $model; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $resourceMock; - - protected function setUp() - { - $objectManagerHelper = new ObjectManager($this); - - $contextMock = $this->getMockBuilder(\Magento\Framework\Model\ResourceModel\Db\Context::class) - ->disableOriginalConstructor() - ->getMock(); - $this->resourceMock = $this->getMockBuilder(\Magento\Framework\App\ResourceConnection::class) - ->disableOriginalConstructor() - ->getMock(); - $contextMock->expects($this->once())->method('getResources')->willReturn($this->resourceMock); - $this->model = $objectManagerHelper->getObject( - \Magento\Catalog\Model\ResourceModel\Layer\Filter\Price::class, - [ - 'context' => $contextMock - ] - ); - } - - public function testGetMainTable() - { - $expectedTableName = 'expectedTableName'; - $this->resourceMock->expects($this->once())->method('getTableName')->willReturn($expectedTableName); - $this->assertEquals($expectedTableName, $this->model->getMainTable()); - } -} diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/LinkedProductSelectBuilderByIndexPriceTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/LinkedProductSelectBuilderByIndexPriceTest.php index cec862ee9661f..be9ae1af079f1 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/LinkedProductSelectBuilderByIndexPriceTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/LinkedProductSelectBuilderByIndexPriceTest.php @@ -56,12 +56,26 @@ protected function setUp() $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\BaseSelectProcessorInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); + + $this->indexScopeResolverMock = $this->createMock( + \Magento\Framework\Search\Request\IndexScopeResolverInterface::class + ); + $this->dimensionMock = $this->createMock(\Magento\Framework\Indexer\Dimension::class); + $this->dimensionFactoryMock = $this->createMock(\Magento\Framework\Indexer\DimensionFactory::class); + $this->dimensionFactoryMock->method('create')->willReturn($this->dimensionMock); + $storeMock = $this->createMock(\Magento\Store\Api\Data\StoreInterface::class); + $storeMock->method('getId')->willReturn(1); + $storeMock->method('getWebsiteId')->willReturn(1); + $this->storeManagerMock->method('getStore')->willReturn($storeMock); + $this->model = new \Magento\Catalog\Model\ResourceModel\Product\Indexer\LinkedProductSelectBuilderByIndexPrice( $this->storeManagerMock, $this->resourceMock, $this->customerSessionMock, $this->metadataPoolMock, - $this->baseSelectProcessorMock + $this->baseSelectProcessorMock, + $this->indexScopeResolverMock, + $this->dimensionFactoryMock ); } @@ -79,7 +93,7 @@ public function testBuild() $storeMock = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class) ->getMockForAbstractClass(); $this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($storeMock); - $this->customerSessionMock->expects($this->once())->method('getCustomerGroupId'); + $this->customerSessionMock->expects($this->once())->method('getCustomerGroupId')->willReturn(1); $connection->expects($this->any())->method('select')->willReturn($select); $select->expects($this->any())->method('from')->willReturnSelf(); $select->expects($this->any())->method('joinInner')->willReturnSelf(); diff --git a/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/ExclusionStrategy.php b/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/ExclusionStrategy.php index 4222fafbcb275..f7edaa45ed29b 100644 --- a/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/ExclusionStrategy.php +++ b/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/ExclusionStrategy.php @@ -15,9 +15,6 @@ use Magento\Framework\Search\Request\Dimension; use Magento\Catalog\Model\Indexer\Category\Product\AbstractAction; use Magento\Customer\Model\Context as CustomerContext; - -; - use Magento\Framework\Search\Request\IndexScopeResolverInterface; use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; @@ -133,7 +130,7 @@ private function applyPriceFilter( $this->dimensionFactory->create(WebsiteDataProvider::DIMENSION_NAME, $websiteId), $this->dimensionFactory->create( CustomerGroupDataProvider::DIMENSION_NAME, - $this->httpContext->getValue(CustomerContext::CONTEXT_GROUP) + (string)$this->httpContext->getValue(CustomerContext::CONTEXT_GROUP) ) ] ); diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Aggregation/DataProvider/QueryBuilderTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Aggregation/DataProvider/QueryBuilderTest.php index b52664df749fe..85308187cbbd9 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Aggregation/DataProvider/QueryBuilderTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Aggregation/DataProvider/QueryBuilderTest.php @@ -57,10 +57,25 @@ protected function setUp() ->method('getConnection') ->willReturn($this->adapterMock); + $this->indexScopeResolverMock = $this->createMock( + \Magento\Framework\Search\Request\IndexScopeResolverInterface::class + ); + $this->dimensionMock = $this->createMock(\Magento\Framework\Indexer\Dimension::class); + $this->dimensionFactoryMock = $this->createMock(\Magento\Framework\Indexer\DimensionFactory::class); + $this->dimensionFactoryMock->method('create')->willReturn($this->dimensionMock); + $storeMock = $this->createMock(\Magento\Store\Api\Data\StoreInterface::class); + $storeMock->method('getId')->willReturn(1); + $storeMock->method('getWebsiteId')->willReturn(1); + $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->storeManagerMock->method('getStore')->willReturn($storeMock); + $this->indexScopeResolverMock->method('resolve')->willReturn('catalog_product_index_price'); + $this->model = new QueryBuilder( $this->resourceConnectionMock, $this->scopeResolverMock, - $this->inventoryConfigMock + $this->inventoryConfigMock, + $this->indexScopeResolverMock, + $this->dimensionFactoryMock ); } @@ -81,8 +96,6 @@ public function testBuildWithPriceAttributeCode() $this->scopeResolverMock->expects($this->once())->method('getScope') ->with($scope)->willReturn($storeMock); $storeMock->expects($this->once())->method('getWebsiteId')->willReturn(1); - $this->resourceConnectionMock->expects($this->once())->method('getTableName') - ->with('catalog_product_index_price')->willReturn('catalog_product_index_price'); $selectMock->expects($this->once())->method('from') ->with(['main_table' => 'catalog_product_index_price'], null) ->willReturn($selectMock); diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Dynamic/DataProviderTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Dynamic/DataProviderTest.php index 1aeeb0d9bd731..1186dd6936cc6 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Dynamic/DataProviderTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Dynamic/DataProviderTest.php @@ -74,6 +74,18 @@ protected function setUp() $this->mysqlDataProviderMock = $this->createMock(DataProviderInterface::class); $this->intervalFactoryMock = $this->createMock(IntervalFactory::class); $this->storeManagerMock = $this->createMock(StoreManager::class); + $this->indexScopeResolverMock = $this->createMock( + \Magento\Framework\Search\Request\IndexScopeResolverInterface::class + ); + $this->dimensionMock = $this->createMock(\Magento\Framework\Indexer\Dimension::class); + $this->dimensionFactoryMock = $this->createMock(\Magento\Framework\Indexer\DimensionFactory::class); + $this->dimensionFactoryMock->method('create')->willReturn($this->dimensionMock); + $storeMock = $this->createMock(\Magento\Store\Api\Data\StoreInterface::class); + $storeMock->method('getId')->willReturn(1); + $storeMock->method('getWebsiteId')->willReturn(1); + $this->storeManagerMock->method('getStore')->willReturn($storeMock); + $this->indexScopeResolverMock->method('resolve')->willReturn('catalog_product_index_price'); + $this->sessionMock->method('getCustomerGroupId')->willReturn(1); $this->model = new DataProvider( $this->resourceConnectionMock, @@ -81,7 +93,9 @@ protected function setUp() $this->sessionMock, $this->mysqlDataProviderMock, $this->intervalFactoryMock, - $this->storeManagerMock + $this->storeManagerMock, + $this->indexScopeResolverMock, + $this->dimensionFactoryMock ); } @@ -97,10 +111,6 @@ public function testGetAggregationsUsesFrontendPriceIndexerTable() $entityStorageMock = $this->createMock(EntityStorage::class); $entityStorageMock->expects($this->any())->method('getSource')->willReturn($tableMock); - $storeMock = $this->createMock(\Magento\Store\Api\Data\StoreInterface::class); - $storeMock->expects($this->once())->method('getWebsiteId')->willReturn(42); - $this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($storeMock); - $this->model->getAggregations($entityStorageMock); } } diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/FilterMapper/ExclusionStrategyTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/FilterMapper/ExclusionStrategyTest.php index 7c6cafd7e9924..409793999de20 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/FilterMapper/ExclusionStrategyTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/FilterMapper/ExclusionStrategyTest.php @@ -50,10 +50,31 @@ protected function setUp() $this->storeManagerMock = $this->createMock(StoreManagerInterface::class); $this->aliasResolverMock = $this->createMock(AliasResolver::class); + $this->indexScopeResolverMock = $this->createMock( + \Magento\Framework\Search\Request\IndexScopeResolverInterface::class + ); + $this->tableResolverMock = $this->createMock( + \Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver::class + ); + $this->dimensionMock = $this->createMock(\Magento\Framework\Indexer\Dimension::class); + $this->dimensionFactoryMock = $this->createMock(\Magento\Framework\Indexer\DimensionFactory::class); + $this->dimensionFactoryMock->method('create')->willReturn($this->dimensionMock); + $storeMock = $this->createMock(\Magento\Store\Api\Data\StoreInterface::class); + $storeMock->method('getId')->willReturn(1); + $storeMock->method('getWebsiteId')->willReturn(1); + $this->storeManagerMock->method('getStore')->willReturn($storeMock); + $this->indexScopeResolverMock->method('resolve')->willReturn('catalog_product_index_price'); + $this->httpContextMock = $this->createMock(\Magento\Framework\App\Http\Context::class); + $this->httpContextMock->method('getValue')->willReturn(1); + $this->model = new ExclusionStrategy( $this->resourceConnectionMock, $this->storeManagerMock, - $this->aliasResolverMock + $this->aliasResolverMock, + $this->tableResolverMock, + $this->dimensionFactoryMock, + $this->indexScopeResolverMock, + $this->httpContextMock ); } From fe464fea6873a7a4ee9689a0c36a9cb173ac3e3e Mon Sep 17 00:00:00 2001 From: Michail Slabko <mslabko@magento.com> Date: Fri, 1 Jun 2018 16:21:11 +0300 Subject: [PATCH 072/206] MAGETWO-91875: Implement DimensionalIndexerInterface for Simple Product --- .../Indexer/Product/Price/Action/Full.php | 10 ++++-- .../Product/Indexer/Price/DefaultPrice.php | 4 +++ .../Indexer/Price/Query/BaseFinalPrice.php | 35 ++++++++++++------- .../Indexer/Price/SimpleProductPrice.php | 1 - 4 files changed, 34 insertions(+), 16 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php index 4c12c57c6ef51..d0c68aa62cdd7 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php @@ -216,12 +216,16 @@ private function reindexProductType(PriceInterface $priceIndexer, string $typeId private function reindexProductTypeWithDimensions(DimensionalIndexerInterface $priceIndexer, string $typeId) { + $currentMode = $this->configReader + ->getValue(ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE) ?: ModeSwitcher::INPUT_KEY_NONE; + /** @var DimensionProviderInterface $dimensionsProviders */ - $dimensionsProviders = $this->dimensionCollectionFactory->createByMode( - ModeSwitcher::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP - ); + $dimensionsProviders = $this->dimensionCollectionFactory->createByMode($currentMode); foreach ($dimensionsProviders as $dimensions) { + $this->dimensionTableMaintainer->getConnection()->truncateTable( + $this->dimensionTableMaintainer->getMainReplicaTable($dimensions) + ); $this->reindexDimensions($priceIndexer, $dimensions, $typeId); } } diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php index 108ae654f6533..33c2ce0ecd458 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php @@ -6,6 +6,8 @@ namespace Magento\Catalog\Model\ResourceModel\Product\Indexer\Price; use Magento\Catalog\Model\ResourceModel\Product\Indexer\AbstractIndexer; +use Magento\Framework\App\ObjectManager; +use Magento\Framework\Indexer\DimensionalIndexerInterface; /** * Default Product Type Price Indexer Resource model @@ -16,6 +18,8 @@ * @author Magento Core Team <core@magentocommerce.com> * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @since 100.0.2 + * @deprecated Not used anymore for price indexation. Class left for backward compatibility + * @see DimensionalIndexerInterface */ class DefaultPrice extends AbstractIndexer implements PriceInterface { diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php index bf3eea40a908a..f3f678e8ce066 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php @@ -12,6 +12,7 @@ use Magento\Framework\DB\Select; use Magento\Framework\DB\Sql\ColumnValueExpression; use Magento\Framework\Exception\InputException; +use Magento\Framework\Indexer\Dimension; use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; /** @@ -44,6 +45,16 @@ class BaseFinalPrice */ private $eventManager; + /** + * Mapping between dimensions and field in database + * + * @var array + */ + private $dimensionToFieldMapper = [ + WebsiteDataProvider::DIMENSION_NAME => 'pw.website_id', + CustomerGroupDataProvider::DIMENSION_NAME => 'cg.customer_group_id', + ]; + /** * BaseFinalPrice constructor. * @param \Magento\Framework\App\ResourceConnection $resource @@ -66,7 +77,7 @@ public function __construct( } /** - * @param array $dimensions + * @param Dimension[] $dimensions * @param string $productType * @param array $entityIds * @return Select @@ -76,13 +87,6 @@ public function __construct( */ public function getQuery(array $dimensions, string $productType, array $entityIds = []): Select { - if (!isset($dimensions[WebsiteDataProvider::DIMENSION_NAME], - $dimensions[CustomerGroupDataProvider::DIMENSION_NAME]) - ) { - throw new InputException(__('All dimensions for product index price must be provided')); - } - $websiteId = $dimensions[WebsiteDataProvider::DIMENSION_NAME]->getValue(); - $customerGroupId = $dimensions[CustomerGroupDataProvider::DIMENSION_NAME]->getValue(); $connection = $this->resource->getConnection($this->connectionName); $select = $connection->select()->from( @@ -90,11 +94,11 @@ public function getQuery(array $dimensions, string $productType, array $entityId ['entity_id'] )->joinInner( ['cg' => $this->getTable('customer_group')], - sprintf('cg.customer_group_id = %s', $customerGroupId), + [], ['customer_group_id'] )->joinInner( ['pw' => $this->getTable('catalog_product_website')], - sprintf('pw.product_id = e.entity_id AND pw.website_id = %s', $websiteId), + 'pw.product_id = e.entity_id', ['pw.website_id'] )->joinInner( ['cwd' => $this->getTable('catalog_product_index_website')], @@ -107,6 +111,15 @@ public function getQuery(array $dimensions, string $productType, array $entityId [] ); + foreach ($dimensions as $dimension) { + if (!isset($this->dimensionToFieldMapper[$dimension->getName()])) { + throw new InputException( + __('Provided dimension %1 is not valid for Price indexer', $dimension->getName()) + ); + } + $select->where($this->dimensionToFieldMapper[$dimension->getName()] . ' = ?', $dimension->getValue()); + } + if ($this->moduleManager->isEnabled('Magento_Tax')) { $taxClassId = $this->joinAttributeProcessor->process($select,'tax_class_id'); } else { @@ -169,8 +182,6 @@ public function getQuery(array $dimensions, string $productType, array $entityId 'entity_field' => new ColumnValueExpression('e.entity_id'), 'website_field' => new ColumnValueExpression('pw.website_id'), 'store_field' => new ColumnValueExpression('cwd.default_store_id'), - 'website_id' => new ColumnValueExpression($websiteId), - 'customer_group_id' => new ColumnValueExpression($customerGroupId), ] ); diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/SimpleProductPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/SimpleProductPrice.php index 6de02fa1729e1..fa6c36bb5b8a5 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/SimpleProductPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/SimpleProductPrice.php @@ -8,7 +8,6 @@ use Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer; use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\Query\BaseFinalPrice; -use Magento\Framework\App\ResourceConnection; use Magento\Framework\Indexer\DimensionalIndexerInterface; /** From 55b476e284e56ce5f23dadb3b12d78569950750a Mon Sep 17 00:00:00 2001 From: Markus Haack <markus.haack@gmail.com> Date: Tue, 5 Jun 2018 13:32:18 +0200 Subject: [PATCH 073/206] Update webapi.xml to fix typo --- app/code/Magento/Checkout/etc/webapi.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Checkout/etc/webapi.xml b/app/code/Magento/Checkout/etc/webapi.xml index 7b435db200f19..26c601a4e9f38 100644 --- a/app/code/Magento/Checkout/etc/webapi.xml +++ b/app/code/Magento/Checkout/etc/webapi.xml @@ -104,7 +104,7 @@ <resource ref="anonymous" /> </resources> </route> - <!-- Managing My shipping information --> + <!-- Managing My payment information --> <route url="/V1/carts/mine/set-payment-information" method="POST"> <service class="Magento\Checkout\Api\PaymentInformationManagementInterface" method="savePaymentInformation"/> <resources> From a3de9ab0b5d0288c837b8e24f849354d1d95f681 Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi <alugovyi@magento.com> Date: Fri, 1 Jun 2018 16:21:36 +0300 Subject: [PATCH 074/206] MAGETWO-91873: Create table resolver for price index --- app/code/Magento/Catalog/etc/di.xml | 8 +------- app/code/Magento/Catalog/etc/frontend/di.xml | 5 +---- app/code/Magento/Catalog/etc/webapi_rest/di.xml | 5 +---- app/code/Magento/Catalog/etc/webapi_soap/di.xml | 5 +---- 4 files changed, 4 insertions(+), 19 deletions(-) diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml index 1606b98bd2267..9f1c9c13a6701 100644 --- a/app/code/Magento/Catalog/etc/di.xml +++ b/app/code/Magento/Catalog/etc/di.xml @@ -911,6 +911,7 @@ <type name="Magento\Catalog\Model\ResourceModel\Product\Indexer\LinkedProductSelectBuilderByIndexPrice"> <arguments> <argument name="baseSelectProcessor" xsi:type="object">Magento\Catalog\Model\ResourceModel\Product\CompositeBaseSelectProcessor</argument> + <argument name="priceTableResolver" xsi:type="object">Magento\Catalog\Model\Indexer\Product\Price\PriceTableResolver</argument> </arguments> </type> <type name="Magento\Catalog\Model\Product\Price\CostStorage"> @@ -1117,13 +1118,6 @@ </argument> </arguments> </type> - <type name="Magento\Catalog\Model\ResourceModel\Product\Indexer\LinkedProductSelectBuilderByIndexPrice"> - <arguments> - <argument name="priceTableResolver" xsi:type="object"> - Magento\Catalog\Model\Indexer\Product\Price\PriceTableResolver - </argument> - </arguments> - </type> <type name="Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\CustomOptionPriceModifier"> <arguments> <argument name="tableStrategy" xsi:type="object">Magento\Catalog\Model\ResourceModel\Product\Indexer\TemporaryTableStrategy</argument> diff --git a/app/code/Magento/Catalog/etc/frontend/di.xml b/app/code/Magento/Catalog/etc/frontend/di.xml index 471795e6c882f..a12380caa57d2 100644 --- a/app/code/Magento/Catalog/etc/frontend/di.xml +++ b/app/code/Magento/Catalog/etc/frontend/di.xml @@ -81,9 +81,6 @@ </virtualType> <type name="Magento\Framework\App\ResourceConnection"> <plugin name="get_catalog_category_product_index_table_name" type="Magento\Catalog\Model\Indexer\Category\Product\Plugin\TableResolver"/> - </type> - <type name="Magento\Framework\App\ResourceConnection"> - <plugin name="get_catalog_product_price_index_table_name" - type="Magento\Catalog\Model\Indexer\Product\Price\Plugin\TableResolver"/> + <plugin name="get_catalog_product_price_index_table_name" type="Magento\Catalog\Model\Indexer\Product\Price\Plugin\TableResolver"/> </type> </config> diff --git a/app/code/Magento/Catalog/etc/webapi_rest/di.xml b/app/code/Magento/Catalog/etc/webapi_rest/di.xml index 74162ba7ab01e..49c5eff91ee49 100644 --- a/app/code/Magento/Catalog/etc/webapi_rest/di.xml +++ b/app/code/Magento/Catalog/etc/webapi_rest/di.xml @@ -18,9 +18,6 @@ </type> <type name="Magento\Framework\App\ResourceConnection"> <plugin name="get_catalog_category_product_index_table_name" type="Magento\Catalog\Model\Indexer\Category\Product\Plugin\TableResolver"/> - </type> - <type name="Magento\Framework\App\ResourceConnection"> - <plugin name="get_catalog_product_price_index_table_name" - type="Magento\Catalog\Model\Indexer\Product\Price\Plugin\TableResolver"/> + <plugin name="get_catalog_product_price_index_table_name" type="Magento\Catalog\Model\Indexer\Product\Price\Plugin\TableResolver"/> </type> </config> diff --git a/app/code/Magento/Catalog/etc/webapi_soap/di.xml b/app/code/Magento/Catalog/etc/webapi_soap/di.xml index b7e2dfc35f4c5..2a5d60222e9f8 100644 --- a/app/code/Magento/Catalog/etc/webapi_soap/di.xml +++ b/app/code/Magento/Catalog/etc/webapi_soap/di.xml @@ -17,9 +17,6 @@ </type> <type name="Magento\Framework\App\ResourceConnection"> <plugin name="get_catalog_category_product_index_table_name" type="Magento\Catalog\Model\Indexer\Category\Product\Plugin\TableResolver"/> - </type> - <type name="Magento\Framework\App\ResourceConnection"> - <plugin name="get_catalog_product_price_index_table_name" - type="Magento\Catalog\Model\Indexer\Product\Price\Plugin\TableResolver"/> + <plugin name="get_catalog_product_price_index_table_name" type="Magento\Catalog\Model\Indexer\Product\Price\Plugin\TableResolver"/> </type> </config> From 8ba33d89e075d9290b7f0a44c626820fd35bada2 Mon Sep 17 00:00:00 2001 From: Michail Slabko <mslabko@magento.com> Date: Fri, 1 Jun 2018 20:18:32 +0300 Subject: [PATCH 075/206] MAGETWO-91875: Implement DimensionalIndexerInterface for Simple Product --- .../Indexer/Product/Price/AbstractAction.php | 64 ++++++++++--------- .../Magento/Catalog/etc/product_types.xml | 4 +- 2 files changed, 36 insertions(+), 32 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php index 2a9e28b8baed3..bdf423b9afedc 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php @@ -5,8 +5,9 @@ */ namespace Magento\Catalog\Model\Indexer\Product\Price; -use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\PriceInterface; +use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\DefaultPrice; use Magento\Framework\App\ObjectManager; +use Magento\Framework\Indexer\DimensionalIndexerInterface; /** * Abstract action reindex class @@ -18,7 +19,7 @@ abstract class AbstractAction /** * Default Product Type Price indexer resource model * - * @var \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\DefaultPrice + * @var DefaultPrice */ protected $_defaultIndexerResource; @@ -86,7 +87,7 @@ abstract class AbstractAction * @param \Magento\Framework\Stdlib\DateTime $dateTime * @param \Magento\Catalog\Model\Product\Type $catalogProductType * @param \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\Factory $indexerPriceFactory - * @param \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\DefaultPrice $defaultIndexerResource + * @param DefaultPrice $defaultIndexerResource * @param \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\TierPrice $tierPriceIndexResource */ public function __construct( @@ -97,7 +98,7 @@ public function __construct( \Magento\Framework\Stdlib\DateTime $dateTime, \Magento\Catalog\Model\Product\Type $catalogProductType, \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\Factory $indexerPriceFactory, - \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\DefaultPrice $defaultIndexerResource, + DefaultPrice $defaultIndexerResource, \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\TierPrice $tierPriceIndexResource = null ) { $this->_config = $config; @@ -248,7 +249,7 @@ public function getTypeIndexers() $modelName ); // left setters for backward compatibility - if ($indexer instanceof PriceInterface) { + if ($indexer instanceof DefaultPrice) { $indexer->setTypeId( $typeId )->setIsComposite( @@ -326,39 +327,41 @@ protected function _reindexRows($changedIds = []) $this->_prepareWebsiteDateTable(); $productsTypes = $this->getProductsTypes($changedIds); - $compositeIds = []; - $notCompositeIds = []; - foreach ($productsTypes as $productType => $entityIds) { - $indexer = $this->_getIndexer($productType); - if ($indexer->getIsComposite()) { - $compositeIds += $entityIds; - } else { - $notCompositeIds += $entityIds; - } - } - - if (!empty($notCompositeIds)) { - $parentProductsTypes = $this->getParentProductsTypes($notCompositeIds); - $productsTypes = array_merge_recursive($productsTypes, $parentProductsTypes); - foreach ($parentProductsTypes as $parentProductsIds) { - $compositeIds = $compositeIds + $parentProductsIds; - $changedIds = array_merge($changedIds, $parentProductsIds); - } + //TODO: tests with composite products +// foreach ($productsTypes as $productType => $entityIds) { +// $indexer = $this->_getIndexer($productType); +// if ($indexer->getIsComposite()) { +// $compositeIds += $entityIds; +// } else { +// $notCompositeIds += $entityIds; +// } +// } + + $parentProductsTypes = $this->getParentProductsTypes($changedIds); + $productsTypes = array_merge_recursive($productsTypes, $parentProductsTypes); + foreach ($parentProductsTypes as $parentProductsIds) { + $changedIds = array_merge($changedIds, $parentProductsIds); } + $changedIds = array_unique($changedIds); - if (!empty($compositeIds)) { - $this->_copyRelationIndexData($compositeIds, $notCompositeIds); - } - $this->_prepareTierPriceIndex($compositeIds + $notCompositeIds); + //TODO: check that it handled for composite products +// if (!empty($compositeIds)) { +// $this->_copyRelationIndexData($compositeIds, $notCompositeIds); +// } + $this->_prepareTierPriceIndex($changedIds); foreach ($productsTypes as $productType => $entityIds) { $indexer = $this->_getIndexer($productType); - $indexer->reindexEntity($entityIds); + if ($indexer instanceof DimensionalIndexerInterface) { + $indexer->executeByDimension([], \SplFixedArray::fromArray($entityIds)); + } else { + $indexer->reindexEntity($entityIds); + } } $this->_syncData($changedIds); - return $compositeIds + $notCompositeIds; + return $changedIds; } /** @@ -450,7 +453,8 @@ private function getProductsTypes(array $changedIds = []) } /** - * Get parent products types. + * Get parent products types + * Used for add composite products to reindex if we have only simple products in changed ids set * * @param array $productsIds * @return array diff --git a/app/code/Magento/Catalog/etc/product_types.xml b/app/code/Magento/Catalog/etc/product_types.xml index 9072249b40bd6..659a6df94431c 100644 --- a/app/code/Magento/Catalog/etc/product_types.xml +++ b/app/code/Magento/Catalog/etc/product_types.xml @@ -7,13 +7,13 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Catalog:etc/product_types.xsd"> <type name="simple" label="Simple Product" modelInstance="Magento\Catalog\Model\Product\Type\Simple" indexPriority="10" sortOrder="10"> - <indexerModel instance="Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\SimpleProductPrice" /> + <!--<indexerModel instance="Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\SimpleProductPrice" />--> <customAttributes> <attribute name="refundable" value="true"/> </customAttributes> </type> <type name="virtual" label="Virtual Product" modelInstance="Magento\Catalog\Model\Product\Type\Virtual" indexPriority="20" sortOrder="40"> - <indexerModel instance="Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\SimpleProductPrice" /> + <!--<indexerModel instance="Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\SimpleProductPrice" />--> <customAttributes> <attribute name="is_real_product" value="false"/> <attribute name="refundable" value="false"/> From b30324d1c32a74d1ad17f8eb32b2975746853a8c Mon Sep 17 00:00:00 2001 From: Michail Slabko <mslabko@magento.com> Date: Mon, 4 Jun 2018 19:49:44 +0300 Subject: [PATCH 076/206] MAGETWO-91875: Implement DimensionalIndexerInterface for Simple Product --- .../Model/Indexer/Product/Price/AbstractAction.php | 2 +- .../Catalog/Model/Indexer/Product/Price/Action/Full.php | 2 +- .../Model/Indexer/Product/Price/TableMaintainer.php | 4 ++-- .../Product/Indexer/Price/Query/BaseFinalPrice.php | 6 +++++- .../Product/Indexer/Price/SimpleProductPrice.php | 3 +++ app/code/Magento/Catalog/etc/di.xml | 7 +++++++ app/code/Magento/Catalog/etc/product_types.xml | 2 +- app/code/Magento/CatalogRule/etc/di.xml | 8 ++++++++ .../MultiDimensional/CustomerGroupDataProvider.php | 3 ++- .../Indexer/MultiDimensional/WebsiteDataProvider.php | 3 ++- 10 files changed, 32 insertions(+), 8 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php index bdf423b9afedc..e0448811219c7 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php @@ -354,7 +354,7 @@ protected function _reindexRows($changedIds = []) foreach ($productsTypes as $productType => $entityIds) { $indexer = $this->_getIndexer($productType); if ($indexer instanceof DimensionalIndexerInterface) { - $indexer->executeByDimension([], \SplFixedArray::fromArray($entityIds)); + $indexer->executeByDimension([], \SplFixedArray::fromArray($entityIds, false)); } else { $indexer->reindexEntity($entityIds); } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php index d0c68aa62cdd7..7fdd9afdddf1b 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php @@ -276,7 +276,7 @@ private function reindexBatchWithinDimension(DimensionalIndexerInterface $priceI // TODO: handle inside index model and move index fulfilment into index model $this->_prepareTierPriceIndex($entityIds); - $priceIndexer->executeByDimension($dimensions, \SplFixedArray::fromArray($entityIds)); + $priceIndexer->executeByDimension($dimensions, \SplFixedArray::fromArray($entityIds, false)); // Sync data from temp table to index table $this->_insertFromTable( diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php index 6d159b90a1e11..dfbce67e7f269 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php @@ -40,7 +40,7 @@ class TableMaintainer /** * Catalog tmp category index table name */ - private $tmpTableSuffix = '_tmp'; + private $tmpTableSuffix = '_temp'; //TODO: align with \Magento\Catalog\Model\ResourceModel\Product\Indexer\TemporaryTableStrategy::TEMP_SUFFIX /** * Catalog tmp category index table name @@ -150,7 +150,7 @@ private function truncateTable(string $tableName) */ private function getArrayKeyForTmpTable(array $dimensions): string { - $key = 'tmp'; + $key = 'temp'; foreach ($dimensions as $dimension) { $key .= $dimension->getName() . '_' . $dimension->getValue(); } diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php index f3f678e8ce066..a93aa7d25c62c 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php @@ -169,7 +169,11 @@ public function getQuery(array $dimensions, string $productType, array $entityId $select->where(sprintf("e.type_id = '%s'", $productType)); if ($entityIds !== null) { - $select->where(sprintf('e.entity_id BETWEEN %s AND %s', min($entityIds), max($entityIds))); + if (count($entityIds) > 1) { + $select->where(sprintf('e.entity_id BETWEEN %s AND %s', min($entityIds), max($entityIds))); + } else { + $select->where('e.entity_id = ?', $entityIds); + } } /** diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/SimpleProductPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/SimpleProductPrice.php index fa6c36bb5b8a5..a638bf1705f98 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/SimpleProductPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/SimpleProductPrice.php @@ -75,6 +75,9 @@ public function __construct( */ public function executeByDimension(array $dimensions, \Traversable $entityIds = null) { + // TODO: hot fix for rows reindex + $this->tableMaintainer->createMainTmpTable($dimensions); + $temporaryPriceTable = $this->indexTableStructureFactory->create([ 'tableName' => $this->tableMaintainer->getMainTmpTable($dimensions), 'entityField' => 'entity_id', diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml index 9f1c9c13a6701..199c083b7c78a 100644 --- a/app/code/Magento/Catalog/etc/di.xml +++ b/app/code/Magento/Catalog/etc/di.xml @@ -1128,4 +1128,11 @@ <argument name="connectionName" xsi:type="string">indexer</argument> </arguments> </type> + <type name="Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\SimpleProductPrice"> + <arguments> + <argument name="priceModifiers" xsi:type="array"> + <item name="customOptionPriceModifier" xsi:type="object">Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\CustomOptionPriceModifier</item> + </argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/Catalog/etc/product_types.xml b/app/code/Magento/Catalog/etc/product_types.xml index 659a6df94431c..a4747f93db047 100644 --- a/app/code/Magento/Catalog/etc/product_types.xml +++ b/app/code/Magento/Catalog/etc/product_types.xml @@ -7,7 +7,7 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Catalog:etc/product_types.xsd"> <type name="simple" label="Simple Product" modelInstance="Magento\Catalog\Model\Product\Type\Simple" indexPriority="10" sortOrder="10"> - <!--<indexerModel instance="Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\SimpleProductPrice" />--> + <indexerModel instance="Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\SimpleProductPrice" /> <customAttributes> <attribute name="refundable" value="true"/> </customAttributes> diff --git a/app/code/Magento/CatalogRule/etc/di.xml b/app/code/Magento/CatalogRule/etc/di.xml index 49f312d25dd0a..d63f26dca59cd 100644 --- a/app/code/Magento/CatalogRule/etc/di.xml +++ b/app/code/Magento/CatalogRule/etc/di.xml @@ -134,6 +134,14 @@ </argument> </arguments> </type> + <type name="Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\SimpleProductPrice"> + <arguments> + <argument name="priceModifiers" xsi:type="array"> + <item name="catalogRulePriceModifier" xsi:type="object">Magento\CatalogRule\Model\Indexer\ProductPriceIndexModifier</item> + </argument> + </arguments> + </type> + <virtualType name="CatalogRuleCustomConditionProvider" type="Magento\Framework\Api\SearchCriteria\CollectionProcessor\ConditionProcessor\CustomConditionProvider"> <arguments> <argument name="customConditionProcessors" xsi:type="array"> diff --git a/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php b/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php index 24f7c9c17bea5..879c94b101f97 100644 --- a/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php +++ b/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php @@ -57,7 +57,8 @@ private function getCustomerGroups() { if ($this->customerGroupsDataIterator === null) { $this->customerGroupsDataIterator = \SplFixedArray::fromArray( - $this->collectionFactory->create()->getAllIds() + $this->collectionFactory->create()->getAllIds(), + false ); } diff --git a/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php b/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php index 1e83e1333c27f..305a1cbac959a 100644 --- a/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php +++ b/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php @@ -64,7 +64,8 @@ private function getWebsites() $this->websitesDataIterator = \SplFixedArray::fromArray( $this->collectionFactory->create() ->addFieldToFilter('code', ['neq' => Store::ADMIN_CODE]) - ->getAllIds() + ->getAllIds(), + false ); } From 1413d65946c2e3e076a0605d2e5c739e0b339d83 Mon Sep 17 00:00:00 2001 From: Riccardo Tempesta <riccardo.tempesta@magespecialist.it> Date: Tue, 5 Jun 2018 18:38:13 +0200 Subject: [PATCH 077/206] FIX failing tests and PageConfig refactor --- .../Magento/Framework/View/Page/Config.php | 88 +++++++------------ .../Framework/View/Page/Config/Renderer.php | 42 ++++++--- .../Test/Unit/Page/Config/RendererTest.php | 9 +- 3 files changed, 66 insertions(+), 73 deletions(-) diff --git a/lib/internal/Magento/Framework/View/Page/Config.php b/lib/internal/Magento/Framework/View/Page/Config.php index 3cc9edbb6f5e1..6f7a1c1c5fbb2 100644 --- a/lib/internal/Magento/Framework/View/Page/Config.php +++ b/lib/internal/Magento/Framework/View/Page/Config.php @@ -7,7 +7,7 @@ namespace Magento\Framework\View\Page; use Magento\Framework\App; -use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\App\Area; use Magento\Framework\View; /** @@ -42,6 +42,7 @@ class Config const META_TITLE = 'title'; const META_KEYWORDS = 'keywords'; const META_ROBOTS = 'robots'; + const META_X_UI_COMPATIBLE = 'x_ua_compatible'; /** * Constant body attribute class @@ -253,7 +254,7 @@ public function getMetadata() */ public function setContentType($contentType) { - $this->setMetadata('content_type', $contentType); + $this->setMetadata(self::META_CONTENT_TYPE, $contentType); } /** @@ -264,10 +265,10 @@ public function setContentType($contentType) public function getContentType() { $this->build(); - if (strtolower($this->metadata['content_type']) === 'auto') { - $this->metadata['content_type'] = $this->getMediaType() . '; charset=' . $this->getCharset(); + if (strtolower($this->metadata[self::META_CONTENT_TYPE]) === 'auto') { + $this->metadata[self::META_CONTENT_TYPE] = $this->getMediaType() . '; charset=' . $this->getCharset(); } - return $this->metadata['content_type']; + return $this->metadata[self::META_CONTENT_TYPE]; } /** @@ -276,7 +277,7 @@ public function getContentType() */ public function setMediaType($mediaType) { - $this->setMetadata('media_type', $mediaType); + $this->setMetadata(self::META_MEDIA_TYPE, $mediaType); } /** @@ -287,13 +288,13 @@ public function setMediaType($mediaType) public function getMediaType() { $this->build(); - if (empty($this->metadata['media_type'])) { - $this->metadata['media_type'] = $this->scopeConfig->getValue( + if (empty($this->metadata[self::META_MEDIA_TYPE])) { + $this->metadata[self::META_MEDIA_TYPE] = $this->scopeConfig->getValue( 'design/head/default_media_type', \Magento\Store\Model\ScopeInterface::SCOPE_STORE ); } - return $this->metadata['media_type']; + return $this->metadata[self::META_MEDIA_TYPE]; } /** @@ -302,7 +303,7 @@ public function getMediaType() */ public function setCharset($charset) { - $this->setMetadata('charset', $charset); + $this->setMetadata(self::META_CHARSET, $charset); } /** @@ -313,13 +314,13 @@ public function setCharset($charset) public function getCharset() { $this->build(); - if (empty($this->metadata['charset'])) { - $this->metadata['charset'] = $this->scopeConfig->getValue( + if (empty($this->metadata[self::META_CHARSET])) { + $this->metadata[self::META_CHARSET] = $this->scopeConfig->getValue( 'design/head/default_charset', \Magento\Store\Model\ScopeInterface::SCOPE_STORE ); } - return $this->metadata['charset']; + return $this->metadata[self::META_CHARSET]; } /** @@ -328,7 +329,7 @@ public function getCharset() */ public function setDescription($description) { - $this->setMetadata('description', $description); + $this->setMetadata(self::META_DESCRIPTION, $description); } /** @@ -339,41 +340,13 @@ public function setDescription($description) public function getDescription() { $this->build(); - if (empty($this->metadata['description'])) { - $this->metadata['description'] = $this->scopeConfig->getValue( + if (empty($this->metadata[self::META_DESCRIPTION])) { + $this->metadata[self::META_DESCRIPTION] = $this->scopeConfig->getValue( 'design/head/default_description', \Magento\Store\Model\ScopeInterface::SCOPE_STORE ); } - return $this->metadata['description']; - } - - /** - * Get rendered metadata - * @param string $fieldName - * @return string - * @throws LocalizedException - */ - public function getRenderedMetaTagValue(string $fieldName) - { - switch ($fieldName) { - case self::META_DESCRIPTION: - return $this->getDescription(); - case self::META_CONTENT_TYPE: - return $this->getContentType(); - case self::META_MEDIA_TYPE: - return $this->getMediaType(); - case self::META_CHARSET: - return $this->getCharset(); - case self::META_KEYWORDS: - return $this->getKeywords(); - case self::META_ROBOTS: - return $this->getRobots(); - case self::META_TITLE: - return $this->getMetaTitle(); - default: - throw new LocalizedException(__('No rendered meta function for %1', $fieldName)); - } + return $this->metadata[self::META_DESCRIPTION]; } /** @@ -381,7 +354,7 @@ public function getRenderedMetaTagValue(string $fieldName) */ public function setMetaTitle($title) { - $this->setMetadata('title', $title); + $this->setMetadata(self::META_TITLE, $title); } /** @@ -392,11 +365,11 @@ public function setMetaTitle($title) public function getMetaTitle() { $this->build(); - if (empty($this->metadata['title'])) { + if (empty($this->metadata[self::META_TITLE])) { return ''; } - return $this->metadata['title']; + return $this->metadata[self::META_TITLE]; } /** @@ -405,7 +378,7 @@ public function getMetaTitle() */ public function setKeywords($keywords) { - $this->setMetadata('keywords', $keywords); + $this->setMetadata(self::META_KEYWORDS, $keywords); } /** @@ -416,13 +389,13 @@ public function setKeywords($keywords) public function getKeywords() { $this->build(); - if (empty($this->metadata['keywords'])) { - $this->metadata['keywords'] = $this->scopeConfig->getValue( + if (empty($this->metadata[self::META_KEYWORDS])) { + $this->metadata[self::META_KEYWORDS] = $this->scopeConfig->getValue( 'design/head/default_keywords', \Magento\Store\Model\ScopeInterface::SCOPE_STORE ); } - return $this->metadata['keywords']; + return $this->metadata[self::META_KEYWORDS]; } /** @@ -431,27 +404,28 @@ public function getKeywords() */ public function setRobots($robots) { - $this->setMetadata('robots', $robots); + $this->setMetadata(self::META_ROBOTS, $robots); } /** * Retrieve URL to robots file * * @return string + * @throws \Magento\Framework\Exception\LocalizedException */ public function getRobots() { - if ($this->getAreaResolver()->getAreaCode() !== 'frontend') { + if ($this->getAreaResolver()->getAreaCode() !== Area::AREA_FRONTEND) { return 'NOINDEX,NOFOLLOW'; } $this->build(); - if (empty($this->metadata['robots'])) { - $this->metadata['robots'] = $this->scopeConfig->getValue( + if (empty($this->metadata[self::META_ROBOTS])) { + $this->metadata[self::META_ROBOTS] = $this->scopeConfig->getValue( 'design/search_engine_robots/default_robots', \Magento\Store\Model\ScopeInterface::SCOPE_STORE ); } - return $this->metadata['robots']; + return $this->metadata[self::META_ROBOTS]; } /** diff --git a/lib/internal/Magento/Framework/View/Page/Config/Renderer.php b/lib/internal/Magento/Framework/View/Page/Config/Renderer.php index f251580441b2f..183f8d34ee41f 100644 --- a/lib/internal/Magento/Framework/View/Page/Config/Renderer.php +++ b/lib/internal/Magento/Framework/View/Page/Config/Renderer.php @@ -23,7 +23,7 @@ class Renderer implements RendererInterface protected $assetTypeOrder = ['css', 'ico', 'js']; /** - * @var \Magento\Framework\View\Page\Config + * @var Config */ protected $pageConfig; @@ -53,7 +53,7 @@ class Renderer implements RendererInterface protected $urlBuilder; /** - * @param \Magento\Framework\View\Page\Config $pageConfig + * @param Config $pageConfig * @param \Magento\Framework\View\Asset\MergeService $assetMergeService * @param \Magento\Framework\UrlInterface $urlBuilder * @param \Magento\Framework\Escaper $escaper @@ -137,10 +137,30 @@ public function renderMetadata() */ protected function processMetadataContent($name, $content) { - try { - return $this->pageConfig->getRenderedMetaTagValue((string) $name); - } catch (LocalizedException $e) { - return (string) $content; + switch ($name) { + case Config::META_DESCRIPTION: + return $this->pageConfig->getDescription(); + + case Config::META_CONTENT_TYPE: + return $this->pageConfig->getContentType(); + + case Config::META_MEDIA_TYPE: + return $this->pageConfig->getMediaType(); + + case Config::META_CHARSET: + return $this->pageConfig->getCharset(); + + case Config::META_KEYWORDS: + return $this->pageConfig->getKeywords(); + + case Config::META_ROBOTS: + return $this->pageConfig->getRobots(); + + case Config::META_TITLE: + return $this->pageConfig->getMetaTitle(); + + default: + return $content; } } @@ -155,19 +175,19 @@ protected function getMetadataTemplate($name) } switch ($name) { - case 'charset': + case Config::META_CHARSET: $metadataTemplate = '<meta charset="%content"/>' . "\n"; break; - case 'content_type': + case Config::META_CONTENT_TYPE: $metadataTemplate = '<meta http-equiv="Content-Type" content="%content"/>' . "\n"; break; - case 'x_ua_compatible': + case Config::META_X_UI_COMPATIBLE: $metadataTemplate = '<meta http-equiv="X-UA-Compatible" content="%content"/>' . "\n"; break; - case 'media_type': + case Config::META_MEDIA_TYPE: $metadataTemplate = false; break; @@ -354,7 +374,7 @@ protected function renderAssetHtml(\Magento\Framework\View\Asset\PropertyGroup $ ); $result .= sprintf($template, $asset->getUrl()); } - } catch (\Magento\Framework\Exception\LocalizedException $e) { + } catch (LocalizedException $e) { $this->logger->critical($e); $result .= sprintf($template, $this->urlBuilder->getUrl('', ['_direct' => 'core/index/notFound'])); } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Page/Config/RendererTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Page/Config/RendererTest.php index 1f110a9ec19b5..adb7c4f4ddd86 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Page/Config/RendererTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Page/Config/RendererTest.php @@ -157,15 +157,14 @@ public function testRenderMetadata() . '<meta http-equiv="X-UA-Compatible" content="x_ua_compatible_value"/>' . "\n" . '<meta property="og:video:secure_url" content="secure_url"/>' . "\n"; - $this->stringMock->expects($this->at(0)) - ->method('upperCaseWords') - ->with('charset', '_', '') - ->willReturn('Charset'); - $this->pageConfigMock->expects($this->once()) ->method('getCharset') ->willReturn($metadataValueCharset); + $this->pageConfigMock->expects($this->once()) + ->method('getContentType') + ->willReturn('content_type_value'); + $this->pageConfigMock ->expects($this->once()) ->method('getMetadata') From 2504952a54dbabd5b903e31807633f7ba1f0a77f Mon Sep 17 00:00:00 2001 From: Michail Slabko <mslabko@magento.com> Date: Tue, 5 Jun 2018 19:46:08 +0300 Subject: [PATCH 078/206] MAGETWO-92401: Stabilize full reindex - MAGETWO-64467 [Indexer optimizations] Tables sharding / segmentation for price indexer --- .../Price/CustomOptionPriceModifier.php | 42 ++++++------------- 1 file changed, 13 insertions(+), 29 deletions(-) diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/CustomOptionPriceModifier.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/CustomOptionPriceModifier.php index 64e4cc1fd6bbc..ef202e249e54a 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/CustomOptionPriceModifier.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/CustomOptionPriceModifier.php @@ -186,16 +186,8 @@ private function getSelectForOptionsWithMultipleValues(string $sourceTable): Sel 'e.entity_id = i.entity_id', [] )->join( - ['cw' => $this->getTable('store_website')], - 'cw.website_id = i.website_id', - [] - )->join( - ['csg' => $this->getTable('store_group')], - 'csg.group_id = cw.default_group_id', - [] - )->join( - ['cs' => $this->getTable('store')], - 'cs.store_id = csg.default_store_id', + ['cwd' => $this->getTable('catalog_product_index_website')], + 'i.website_id = cwd.website_id', [] )->join( ['o' => $this->getTable('catalog_product_option')], @@ -221,7 +213,7 @@ private function getSelectForOptionsWithMultipleValues(string $sourceTable): Sel if (!$this->isPriceGlobal()) { $select->joinLeft( ['otps' => $this->getTable('catalog_product_option_type_price')], - 'otps.option_type_id = otpd.option_type_id AND otpd.store_id = cs.store_id', + 'otps.option_type_id = otpd.option_type_id AND otpd.store_id = cwd.default_store_id', [] ); @@ -231,7 +223,7 @@ private function getSelectForOptionsWithMultipleValues(string $sourceTable): Sel $minPriceRound = $this->columnValueExpressionFactory ->create([ - 'expression' => "ROUND(i.price * ({$optPriceValue} / 100), 4)" + 'expression' => "ROUND(i.final_price * ({$optPriceValue} / 100), 4)" ]); $minPriceExpr = $connection->getCheckSql("{$optPriceType} = 'fixed'", $optPriceValue, $minPriceRound); $minPriceMin = $this->columnValueExpressionFactory @@ -242,7 +234,7 @@ private function getSelectForOptionsWithMultipleValues(string $sourceTable): Sel $tierPriceRound = $this->columnValueExpressionFactory ->create([ - 'expression' => "ROUND(i.base_tier * ({$optPriceValue} / 100), 4)" + 'expression' => "ROUND(i.tier_price * ({$optPriceValue} / 100), 4)" ]); $tierPriceExpr = $connection->getCheckSql("{$optPriceType} = 'fixed'", $optPriceValue, $tierPriceRound); $tierPriceMin = $this->columnValueExpressionFactory @@ -250,11 +242,11 @@ private function getSelectForOptionsWithMultipleValues(string $sourceTable): Sel 'expression' => "MIN({$tierPriceExpr})" ]); $tierPriceValue = $connection->getCheckSql("MIN(o.is_require) > 0", $tierPriceMin, 0); - $tierPrice = $connection->getCheckSql("MIN(i.base_tier) IS NOT NULL", $tierPriceValue, "NULL"); + $tierPrice = $connection->getCheckSql("MIN(i.tier_price) IS NOT NULL", $tierPriceValue, "NULL"); $maxPriceRound = $this->columnValueExpressionFactory ->create([ - 'expression' => "ROUND(i.price * ({$optPriceValue} / 100), 4)" + 'expression' => "ROUND(i.final_price * ({$optPriceValue} / 100), 4)" ]); $maxPriceExpr = $connection->getCheckSql("{$optPriceType} = 'fixed'", $optPriceValue, $maxPriceRound); $maxPrice = $connection->getCheckSql( @@ -295,16 +287,8 @@ private function getSelectForOptionsWithOneValue(string $sourceTable): Select 'e.entity_id = i.entity_id', [] )->join( - ['cw' => $this->getTable('store_website')], - 'cw.website_id = i.website_id', - [] - )->join( - ['csg' => $this->getTable('store_group')], - 'csg.group_id = cw.default_group_id', - [] - )->join( - ['cs' => $this->getTable('store')], - 'cs.store_id = csg.default_store_id', + ['cwd' => $this->getTable('catalog_product_index_website')], + 'i.website_id = cwd.website_id', [] )->join( ['o' => $this->getTable('catalog_product_option')], @@ -324,7 +308,7 @@ private function getSelectForOptionsWithOneValue(string $sourceTable): Select if (!$this->isPriceGlobal()) { $select->joinLeft( ['ops' => $this->getTable('catalog_product_option_price')], - 'ops.option_id = opd.option_id AND ops.store_id = cs.store_id', + 'ops.option_id = opd.option_id AND ops.store_id = cwd.default_store_id', [] ); @@ -334,7 +318,7 @@ private function getSelectForOptionsWithOneValue(string $sourceTable): Select $minPriceRound = $this->columnValueExpressionFactory ->create([ - 'expression' => "ROUND(i.price * ({$optPriceValue} / 100), 4)" + 'expression' => "ROUND(i.final_price * ({$optPriceValue} / 100), 4)" ]); $priceExpr = $connection->getCheckSql("{$optPriceType} = 'fixed'", $optPriceValue, $minPriceRound); $minPrice = $connection->getCheckSql("{$priceExpr} > 0 AND o.is_require = 1", $priceExpr, 0); @@ -343,11 +327,11 @@ private function getSelectForOptionsWithOneValue(string $sourceTable): Select $tierPriceRound = $this->columnValueExpressionFactory ->create([ - 'expression' => "ROUND(i.base_tier * ({$optPriceValue} / 100), 4)" + 'expression' => "ROUND(i.tier_price * ({$optPriceValue} / 100), 4)" ]); $tierPriceExpr = $connection->getCheckSql("{$optPriceType} = 'fixed'", $optPriceValue, $tierPriceRound); $tierPriceValue = $connection->getCheckSql("{$tierPriceExpr} > 0 AND o.is_require = 1", $tierPriceExpr, 0); - $tierPrice = $connection->getCheckSql("i.base_tier IS NOT NULL", $tierPriceValue, "NULL"); + $tierPrice = $connection->getCheckSql("i.tier_price IS NOT NULL", $tierPriceValue, "NULL"); $select->columns( [ From 3b9cda59b0900f9f621734e2b0417b6fa36674e2 Mon Sep 17 00:00:00 2001 From: Dmytro Cheshun <mitry@atwix.com> Date: Tue, 5 Jun 2018 23:09:02 +0300 Subject: [PATCH 079/206] Fix missing PHPDocs hinting for AdvancedPricingImportExport module classes, remove unused imports --- .../Model/Export/AdvancedPricing.php | 5 ++++- .../Model/Import/AdvancedPricing.php | 2 +- .../Import/AdvancedPricing/Validator.php | 1 + .../Unit/Model/Export/AdvancedPricingTest.php | 3 +++ .../Validator/TierPriceTest.php | 2 ++ .../Unit/Model/Import/AdvancedPricingTest.php | 22 ++++++++++++++++++- 6 files changed, 32 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/AdvancedPricingImportExport/Model/Export/AdvancedPricing.php b/app/code/Magento/AdvancedPricingImportExport/Model/Export/AdvancedPricing.php index 62a7aefa77550..3122a0a7ee648 100644 --- a/app/code/Magento/AdvancedPricingImportExport/Model/Export/AdvancedPricing.php +++ b/app/code/Magento/AdvancedPricingImportExport/Model/Export/AdvancedPricing.php @@ -103,7 +103,6 @@ class AdvancedPricing extends \Magento\CatalogImportExport\Model\Export\Product * @param \Magento\CatalogImportExport\Model\Export\RowCustomizerInterface $rowCustomizer * @param ImportProduct\StoreResolver $storeResolver * @param \Magento\Customer\Api\GroupRepositoryInterface $groupRepository - * @throws \Magento\Framework\Exception\LocalizedException * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -192,6 +191,7 @@ protected function initTypeModels() * Export process * * @return string + * @throws \Magento\Framework\Exception\LocalizedException */ public function export() { @@ -461,6 +461,7 @@ protected function getTierPrices(array $productLinksIds, $table) * * @param int $websiteId * @return string + * @throws \Magento\Framework\Exception\LocalizedException */ protected function _getWebsiteCode(int $websiteId): string { @@ -491,6 +492,8 @@ protected function _getWebsiteCode(int $websiteId): string * @param int $customerGroupId * @param int $allGroups * @return string + * @throws \Magento\Framework\Exception\LocalizedException + * @throws \Magento\Framework\Exception\NoSuchEntityException */ protected function _getCustomerGroupById( int $customerGroupId, diff --git a/app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing.php b/app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing.php index 0e8acb37104e6..754f5fd6c8c20 100644 --- a/app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing.php +++ b/app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing.php @@ -8,7 +8,6 @@ use Magento\CatalogImportExport\Model\Import\Product as ImportProduct; use Magento\CatalogImportExport\Model\Import\Product\RowValidatorInterface as ValidatorInterface; use Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface; -use Magento\Framework\App\ResourceConnection; /** * Class AdvancedPricing @@ -619,6 +618,7 @@ protected function processCountNewPrices(array $tierPrices) * Get product entity link field * * @return string + * @throws \Exception */ private function getProductEntityLinkField() { diff --git a/app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing/Validator.php b/app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing/Validator.php index 25a9fc244fe51..d939a3f7c392e 100644 --- a/app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing/Validator.php +++ b/app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing/Validator.php @@ -28,6 +28,7 @@ public function __construct($validators = []) * * @param array $value * @return bool + * @throws \Zend_Validate_Exception */ public function isValid($value) { diff --git a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Export/AdvancedPricingTest.php b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Export/AdvancedPricingTest.php index 48b4c58918740..0b7c717c1343c 100644 --- a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Export/AdvancedPricingTest.php +++ b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Export/AdvancedPricingTest.php @@ -347,6 +347,7 @@ protected function tearDown() * @param $object * @param $property * @return mixed + * @throws \ReflectionException */ protected function getPropertyValue($object, $property) { @@ -362,6 +363,8 @@ protected function getPropertyValue($object, $property) * @param $object * @param $property * @param $value + * @return mixed + * @throws \ReflectionException */ protected function setPropertyValue(&$object, $property, $value) { diff --git a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/TierPriceTest.php b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/TierPriceTest.php index bb64acb558320..371d62c37933d 100644 --- a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/TierPriceTest.php +++ b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/TierPriceTest.php @@ -340,6 +340,7 @@ public function isValidAddMessagesCallDataProvider() * @param object $object * @param string $property * @return mixed + * @throws \ReflectionException */ protected function getPropertyValue($object, $property) { @@ -357,6 +358,7 @@ protected function getPropertyValue($object, $property) * @param string $property * @param mixed $value * @return object + * @throws \ReflectionException */ protected function setPropertyValue(&$object, $property, $value) { diff --git a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricingTest.php b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricingTest.php index 6d130d93ee6a5..b0a59980df873 100644 --- a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricingTest.php +++ b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricingTest.php @@ -209,6 +209,10 @@ public function testGetEntityTypeCode() * Test method validateRow against its result. * * @dataProvider validateRowResultDataProvider + * @param array $rowData + * @param string|null $behavior + * @param bool $expectedResult + * @throws \ReflectionException */ public function testValidateRowResult($rowData, $behavior, $expectedResult) { @@ -234,6 +238,10 @@ public function testValidateRowResult($rowData, $behavior, $expectedResult) * Test method validateRow whether AddRowError is called. * * @dataProvider validateRowAddRowErrorCallDataProvider + * @param array $rowData + * @param string|null $behavior + * @param string $error + * @throws \ReflectionException */ public function testValidateRowAddRowErrorCall($rowData, $behavior, $error) { @@ -324,6 +332,13 @@ public function testSaveAdvancedPricing() * Take into consideration different data and check relative internal calls. * * @dataProvider saveAndReplaceAdvancedPricesAppendBehaviourDataProvider + * @param array $data + * @param string $tierCustomerGroupId + * @param string $groupCustomerGroupId + * @param string $tierWebsiteId + * @param string $groupWebsiteId + * @param array $expectedTierPrices + * @throws \ReflectionException */ public function testSaveAndReplaceAdvancedPricesAppendBehaviourDataAndCalls( $data, @@ -947,6 +962,7 @@ public function processCountExistingPricesDataProvider() * @param $object * @param $property * @return mixed + * @throws \ReflectionException */ protected function getPropertyValue($object, $property) { @@ -963,6 +979,8 @@ protected function getPropertyValue($object, $property) * @param $object * @param $property * @param $value + * @return mixed + * @throws \ReflectionException */ protected function setPropertyValue(&$object, $property, $value) { @@ -981,7 +999,8 @@ protected function setPropertyValue(&$object, $property, $value) * @param string $method * @param array $args * - * @return mixed the method result. + * @return mixed + * @throws \ReflectionException */ private function invokeMethod($object, $method, $args = []) { @@ -998,6 +1017,7 @@ private function invokeMethod($object, $method, $args = []) * @param array $methods * * @return \PHPUnit_Framework_MockObject_MockObject + * @throws \ReflectionException */ private function getAdvancedPricingMock($methods = []) { From 77a361305b24b26941425d75358b0dcfa7613e12 Mon Sep 17 00:00:00 2001 From: Michail Slabko <mslabko@magento.com> Date: Wed, 6 Jun 2018 10:49:37 +0300 Subject: [PATCH 080/206] MAGETWO-92401: Stabilize full reindex - MAGETWO-64467 [Indexer optimizations] Tables sharding / segmentation for price indexer --- .../Bundle/Model/ResourceModel/Indexer/Price.php | 3 +-- .../Model/Indexer/Product/Price/AbstractAction.php | 2 ++ .../Model/Indexer/Product/Price/Action/Full.php | 3 +++ .../Product/Indexer/Price/DefaultPrice.php | 12 +----------- .../Product/Indexer/Price/Configurable.php | 4 +--- 5 files changed, 8 insertions(+), 16 deletions(-) diff --git a/app/code/Magento/Bundle/Model/ResourceModel/Indexer/Price.php b/app/code/Magento/Bundle/Model/ResourceModel/Indexer/Price.php index fe41098d3a565..32f13e9457217 100644 --- a/app/code/Magento/Bundle/Model/ResourceModel/Indexer/Price.php +++ b/app/code/Magento/Bundle/Model/ResourceModel/Indexer/Price.php @@ -274,7 +274,6 @@ protected function _calculateBundleOptionPrice() protected function _calculateBundleSelectionPrice($priceType) { $connection = $this->getConnection(); - $indexReplicaTable = $this->activeTableSwitcher->getAdditionalTableName($this->getMainTable()); if ($priceType == \Magento\Bundle\Model\Product\Price::PRICE_TYPE_FIXED) { $selectionPriceValue = $connection->getCheckSql( @@ -356,7 +355,7 @@ protected function _calculateBundleSelectionPrice($priceType) 'bs.selection_id = bsp.selection_id AND bsp.website_id = i.website_id', [''] )->join( - ['idx' => $indexReplicaTable], + ['idx' => $this->getIdxTable()], 'bs.product_id = idx.entity_id AND i.customer_group_id = idx.customer_group_id' . ' AND i.website_id = idx.website_id', [] diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php index e0448811219c7..5814cefe95f58 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php @@ -356,6 +356,8 @@ protected function _reindexRows($changedIds = []) if ($indexer instanceof DimensionalIndexerInterface) { $indexer->executeByDimension([], \SplFixedArray::fromArray($entityIds, false)); } else { + // copy relation index data for backward compatibility + $this->_copyRelationIndexData($entityIds); $indexer->reindexEntity($entityIds); } } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php index 7fdd9afdddf1b..045f127761858 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php @@ -246,6 +246,9 @@ private function reindexBatch(PriceInterface $priceIndexer, array $batch, string $idxTableName = $this->_defaultIndexerResource->getIdxTable(); $this->_emptyTable($idxTableName); + if ($priceIndexer->getIsComposite()) { + $this->_copyRelationIndexData($entityIds); + } $this->_prepareTierPriceIndex($entityIds); // Reindex entities by id diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php index 33c2ce0ecd458..563f764f8a6b8 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php @@ -66,11 +66,6 @@ class DefaultPrice extends AbstractIndexer implements PriceInterface */ private $priceModifiers = []; - /** - * @var \Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher - */ - protected $activeTableSwitcher; - /** * DefaultPrice constructor. * @@ -91,8 +86,7 @@ public function __construct( \Magento\Framework\Module\Manager $moduleManager, $connectionName = null, IndexTableStructureFactory $indexTableStructureFactory = null, - array $priceModifiers = [], - \Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher $activeTableSwitcher = null + array $priceModifiers = [] ) { $this->_eventManager = $eventManager; $this->moduleManager = $moduleManager; @@ -109,10 +103,6 @@ public function __construct( $this->priceModifiers[] = $priceModifier; } - - $this->activeTableSwitcher = $activeTableSwitcher ?: ObjectManager::getInstance()->get( - \Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher::class - ); } /** diff --git a/app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Indexer/Price/Configurable.php b/app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Indexer/Price/Configurable.php index 7c5006789c9a2..a8fb60a4dcb22 100644 --- a/app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Indexer/Price/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Indexer/Price/Configurable.php @@ -76,7 +76,6 @@ protected function _prepareConfigurableOptionPriceTable() * * @param null|int|array $entityIds * @return \Magento\ConfigurableProduct\Model\ResourceModel\Product\Indexer\Price\Configurable - * @throws \Magento\Framework\Exception\LocalizedException */ protected function _applyConfigurableOption($entityIds = null) { @@ -85,12 +84,11 @@ protected function _applyConfigurableOption($entityIds = null) $copTable = $this->_getConfigurableOptionPriceTable(); $finalPriceTable = $this->_getDefaultFinalPriceTable(); $linkField = $metadata->getLinkField(); - $indexReplicaTable = $this->activeTableSwitcher->getAdditionalTableName($this->getMainTable()); $this->_prepareConfigurableOptionPriceTable(); $select = $connection->select()->from( - ['i' => $indexReplicaTable], + ['i' => $this->getIdxTable()], [] )->join( ['l' => $this->getTable('catalog_product_super_link')], From a61e3630f4d5a440bfcdbc7e88557545a3e0ada5 Mon Sep 17 00:00:00 2001 From: Victor Rad <vrad@magento.com> Date: Wed, 6 Jun 2018 12:40:01 +0300 Subject: [PATCH 081/206] MAGETWO-74021: "Catalog Products List" widget does not displays on frontend --- app/code/Magento/Rule/Model/Condition/Sql/Builder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Rule/Model/Condition/Sql/Builder.php b/app/code/Magento/Rule/Model/Condition/Sql/Builder.php index efea70d041b34..a9ee75bb393f9 100644 --- a/app/code/Magento/Rule/Model/Condition/Sql/Builder.php +++ b/app/code/Magento/Rule/Model/Condition/Sql/Builder.php @@ -127,7 +127,7 @@ protected function _joinTablesToCollection( * * @param AbstractCondition $condition * @param string $value - * @param bool $isDefaultStoreUsed + * @param bool $isDefaultStoreUsed no longer used because caused an issue about not existing table alias * @return string * @throws \Magento\Framework\Exception\LocalizedException * @SuppressWarnings(PHPMD.UnusedFormalParameter) From 170648e517c84d14ec01085a33e9b8a942b22e3e Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov <slopukhov@magento.com> Date: Wed, 6 Jun 2018 15:59:59 +0300 Subject: [PATCH 082/206] MAGETWO-91821: Handle website or customer group creation/deletion --- .../Indexer/Product/Price/Plugin/Website.php | 131 ++++++++++++++++-- app/code/Magento/Catalog/etc/di.xml | 2 +- 2 files changed, 119 insertions(+), 14 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/Website.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/Website.php index 269515e292e17..2d7e76b3d86f6 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/Website.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/Website.php @@ -5,33 +5,138 @@ */ namespace Magento\Catalog\Model\Indexer\Product\Price\Plugin; +use Magento\Catalog\Model\Indexer\Product\Price\Processor; +use Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer; +use Magento\Catalog\Model\Indexer\Product\Price\ModeSwitcher; +use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Framework\Indexer\DimensionFactory; +use Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProvider; +use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; +use Magento\Customer\Model\ResourceModel\Group\CollectionFactory as CustomerGroupCollectionFactory; +use Magento\Framework\Model\ResourceModel\Db\AbstractDb; +use Magento\Framework\Model\AbstractModel; + class Website { /** - * @var \Magento\Catalog\Model\Indexer\Product\Price\Processor + * @var Processor */ - protected $_processor; + private $processor; /** - * @param \Magento\Catalog\Model\Indexer\Product\Price\Processor $processor + * @var TableMaintainer */ - public function __construct(\Magento\Catalog\Model\Indexer\Product\Price\Processor $processor) - { - $this->_processor = $processor; + private $tableMaintainer; + + /** + * DimensionFactory + * + * @var DimensionFactory + */ + private $dimensionFactory; + + /** + * @var CustomerGroupCollectionFactory + */ + private $customerGroupCollectionFactory; + + /** + * ScopeConfigInterface + * + * @var ScopeConfigInterface + */ + private $configReader; + + /** + * @param Processor $processor + * @param TableMaintainer $tableMaintainer + * @param DimensionFactory $dimensionFactory + * @param CustomerGroupCollectionFactory $customerGroupCollectionFactory + * @param ScopeConfigInterface $configReader + */ + public function __construct( + Processor $processor, + TableMaintainer $tableMaintainer, + DimensionFactory $dimensionFactory, + CustomerGroupCollectionFactory $customerGroupCollectionFactory, + ScopeConfigInterface $configReader + ) { + $this->processor = $processor; + $this->tableMaintainer = $tableMaintainer; + $this->dimensionFactory = $dimensionFactory; + $this->customerGroupCollectionFactory = $customerGroupCollectionFactory; + $this->configReader = $configReader; } /** - * Invalidate price indexer + * @param AbstractDb $subject + * @param AbstractDb $objectResource + * @param AbstractModel $website * - * @param \Magento\Store\Model\ResourceModel\Website $subject - * @param \Magento\Store\Model\ResourceModel\Website $result - * @return \Magento\Store\Model\ResourceModel\Website + * @return AbstractDb + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function afterDelete(AbstractDb $subject, AbstractDb $objectResource, AbstractModel $website) + { + $this->processor->markIndexerAsInvalid(); + + foreach ($this->getAffectedDimensions($website->getId()) as $dimensions) { + $this->tableMaintainer->dropTablesForDimensions($dimensions); + } + + return $objectResource; + } + + /** + * @param AbstractDb $subject + * @param AbstractDb $objectResource + * @param AbstractModel $website * + * @return AbstractDb * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function afterDelete(\Magento\Store\Model\ResourceModel\Website $subject, $result) + public function afterSave(AbstractDb $subject, AbstractDb $objectResource, AbstractModel $website) + { + if ($website->isObjectNew()) { + foreach ($this->getAffectedDimensions($website->getId()) as $dimensions) { + $this->tableMaintainer->createTablesForDimensions($dimensions); + } + } + + return $objectResource; + } + + /** + * Get affected dimensions + * + * @param int $websiteId + * + * @return array + */ + private function getAffectedDimensions(int $websiteId): array { - $this->_processor->markIndexerAsInvalid(); - return $result; + $return = []; + + switch ($this->configReader->getValue(ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE)) { + case ModeSwitcher::INPUT_KEY_WEBSITE: + $return = [$this->dimensionFactory->create(WebsiteDataProvider::DIMENSION_NAME, $websiteId)]; + break; + case ModeSwitcher::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP: + $customerGroupIds = $this->customerGroupCollectionFactory->create()->getAllIds(); + foreach ($customerGroupIds as $customerGroupId) { + $return[] = [ + $this->dimensionFactory->create( + WebsiteDataProvider::DIMENSION_NAME, + (string)$websiteId + ), + $this->dimensionFactory->create( + CustomerGroupDataProvider::DIMENSION_NAME, + (string)$customerGroupId + ) + ]; + } + break; + } + return $return; } } diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml index 199c083b7c78a..dc3ee2d37b028 100644 --- a/app/code/Magento/Catalog/etc/di.xml +++ b/app/code/Magento/Catalog/etc/di.xml @@ -226,7 +226,7 @@ </arguments> </type> <type name="Magento\Store\Model\ResourceModel\Website"> - <plugin name="priceIndexerOnWebsiteDelete" type="Magento\Catalog\Model\Indexer\Product\Price\Plugin\Website"/> + <plugin name="priceIndexerOnWebsiteCreateAndDelete" type="Magento\Catalog\Model\Indexer\Product\Price\Plugin\Website"/> <plugin name="categoryProductWebsiteAfterDelete" type="\Magento\Catalog\Model\Indexer\Category\Product\Plugin\Website"/> </type> <type name="Magento\Store\Model\ResourceModel\Store"> From 06ff28f057e73700c28a1c5a92f5902f700deeda Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi <alugovyi@magento.com> Date: Wed, 6 Jun 2018 22:36:38 +0300 Subject: [PATCH 083/206] MAGETWO-91816: Adapt SharedCatalaog Copy price logic - MAGETWO-64467: [Indexer optimizations] Tables sharding / segmentation for price indexer --- app/code/Magento/Catalog/etc/di.xml | 2 -- app/etc/di.xml | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml index dc3ee2d37b028..ecd6839e283b6 100644 --- a/app/code/Magento/Catalog/etc/di.xml +++ b/app/code/Magento/Catalog/etc/di.xml @@ -70,8 +70,6 @@ <preference for="Magento\Catalog\Api\Data\ProductRender\FormattedPriceInfoInterface" type="Magento\Catalog\Model\ProductRender\FormattedPriceInfo" /> <preference for="Magento\Framework\Indexer\BatchProviderInterface" type="Magento\Framework\Indexer\BatchProvider" /> <preference for="Magento\Catalog\Model\Indexer\Product\Price\UpdateIndexInterface" type="Magento\Catalog\Model\Indexer\Product\Price\InvalidateIndex" /> - <preference for="Magento\Framework\Search\Request\IndexScopeResolverInterface" - type="Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver"/> <type name="Magento\Customer\Model\ResourceModel\Visitor"> <plugin name="catalogLog" type="Magento\Catalog\Model\Plugin\Log" /> </type> diff --git a/app/etc/di.xml b/app/etc/di.xml index 295716acf2fe5..fb768251a34b5 100755 --- a/app/etc/di.xml +++ b/app/etc/di.xml @@ -174,6 +174,7 @@ <preference for="Magento\Framework\View\Element\Message\InterpretationStrategyInterface" type="Magento\Framework\View\Element\Message\InterpretationMediator" /> <preference for="Magento\Framework\Indexer\Config\DependencyInfoProviderInterface" type="Magento\Framework\Indexer\Config\DependencyInfoProvider" /> <preference for="Magento\Framework\Indexer\MultiDimensionProviderInterface" type="\Magento\Framework\Indexer\MultiDimensionProvider" /> + <preference for="Magento\Framework\Search\Request\IndexScopeResolverInterface" type="Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver"/> <type name="Magento\Framework\Model\ResourceModel\Db\TransactionManager" shared="false" /> <type name="Magento\Framework\Acl\Data\Cache"> <arguments> From 5ce5f0336c911d67eff5dbba5544291ee7386ddc Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov <slopukhov@magento.com> Date: Thu, 7 Jun 2018 09:37:36 +0300 Subject: [PATCH 084/206] MAGETWO-91821: Handle website or customer group creation/deletion --- .../Product/Price/Plugin/CustomerGroup.php | 107 +++++++++++++++++- app/code/Magento/Catalog/etc/di.xml | 2 +- 2 files changed, 106 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CustomerGroup.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CustomerGroup.php index 32b2db8a7008c..6f0d468c37f82 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CustomerGroup.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CustomerGroup.php @@ -7,7 +7,15 @@ use Magento\Customer\Api\GroupRepositoryInterface; use Magento\Customer\Api\Data\GroupInterface; -use \Magento\Catalog\Model\Indexer\Product\Price\UpdateIndexInterface; +use Magento\Catalog\Model\Indexer\Product\Price\UpdateIndexInterface; +use Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer; +use Magento\Catalog\Model\Indexer\Product\Price\ModeSwitcher; +use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Framework\Indexer\DimensionFactory; +use Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProvider; +use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; +use Magento\Store\Model\ResourceModel\Website\CollectionFactory as WebsiteCollectionFactory; +use Magento\Store\Model\Store; class CustomerGroup { @@ -16,15 +24,51 @@ class CustomerGroup */ private $updateIndex; + /** + * @var TableMaintainer + */ + private $tableMaintainer; + + /** + * DimensionFactory + * + * @var DimensionFactory + */ + private $dimensionFactory; + + /** + * @var WebsiteCollectionFactory + */ + private $websiteCollectionFactory; + + /** + * ScopeConfigInterface + * + * @var ScopeConfigInterface + */ + private $configReader; + /** * Constructor * * @param UpdateIndexInterface $updateIndex + * @param TableMaintainer $tableMaintainer + * @param DimensionFactory $dimensionFactory + * @param WebsiteCollectionFactory $websiteCollectionFactory + * @param ScopeConfigInterface $configReader */ public function __construct( - UpdateIndexInterface $updateIndex + UpdateIndexInterface $updateIndex, + TableMaintainer $tableMaintainer, + DimensionFactory $dimensionFactory, + WebsiteCollectionFactory $websiteCollectionFactory, + ScopeConfigInterface $configReader ) { $this->updateIndex = $updateIndex; + $this->tableMaintainer = $tableMaintainer; + $this->dimensionFactory = $dimensionFactory; + $this->websiteCollectionFactory = $websiteCollectionFactory; + $this->configReader = $configReader; } /** @@ -43,7 +87,66 @@ public function aroundSave( ) { $isGroupNew = !$group->getId(); $group = $proceed($group); + if ($isGroupNew) { + foreach ($this->getAffectedDimensions($group->getId()) as $dimensions) { + $this->tableMaintainer->createTablesForDimensions($dimensions); + } + } $this->updateIndex->update($group, $isGroupNew); return $group; } + + /** + * @param GroupRepositoryInterface $subject + * @param bool $result + * @param string $groupId + * + * @return bool + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function afterDeleteById(GroupRepositoryInterface $subject, bool $result, string $groupId) + { + foreach ($this->getAffectedDimensions((int)$groupId) as $dimensions) { + $this->tableMaintainer->dropTablesForDimensions($dimensions); + } + + return $result; + } + + /** + * Get affected dimensions + * + * @param int $groupId + * + * @return array + */ + private function getAffectedDimensions(int $groupId): array + { + $return = []; + + switch ($this->configReader->getValue(ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE)) { + case ModeSwitcher::INPUT_KEY_CUSTOMER_GROUP: + $return = [$this->dimensionFactory->create(CustomerGroupDataProvider::DIMENSION_NAME, $groupId)]; + break; + case ModeSwitcher::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP: + $websiteIds = $this->websiteCollectionFactory->create() + ->addFieldToFilter('code', ['neq' => Store::ADMIN_CODE]) + ->getAllIds(); + + foreach ($websiteIds as $websiteId) { + $return[] = [ + $this->dimensionFactory->create( + WebsiteDataProvider::DIMENSION_NAME, + (string)$websiteId + ), + $this->dimensionFactory->create( + CustomerGroupDataProvider::DIMENSION_NAME, + (string)$groupId + ) + ]; + } + break; + } + return $return; + } } diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml index ecd6839e283b6..95b4bef002072 100644 --- a/app/code/Magento/Catalog/etc/di.xml +++ b/app/code/Magento/Catalog/etc/di.xml @@ -224,7 +224,7 @@ </arguments> </type> <type name="Magento\Store\Model\ResourceModel\Website"> - <plugin name="priceIndexerOnWebsiteCreateAndDelete" type="Magento\Catalog\Model\Indexer\Product\Price\Plugin\Website"/> + <plugin name="invalidatePriceIndexerOnWebsite" type="Magento\Catalog\Model\Indexer\Product\Price\Plugin\Website"/> <plugin name="categoryProductWebsiteAfterDelete" type="\Magento\Catalog\Model\Indexer\Category\Product\Plugin\Website"/> </type> <type name="Magento\Store\Model\ResourceModel\Store"> From d23c198b4a7e9f5237d19e999cb160ac4059e61e Mon Sep 17 00:00:00 2001 From: Francesco Marangi <f.marangi@mzentrale.de> Date: Thu, 7 Jun 2018 10:42:49 +0200 Subject: [PATCH 085/206] #15205: Postpone instantiation of session config by using a proxy --- app/etc/di.xml | 5 +++++ lib/internal/Magento/Framework/App/Response/Http.php | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/etc/di.xml b/app/etc/di.xml index 0a5c05cf1006d..4eaa7392592a4 100755 --- a/app/etc/di.xml +++ b/app/etc/di.xml @@ -233,6 +233,11 @@ <argument name="pathInfoProcessor" xsi:type="object">Magento\Backend\App\Request\PathInfoProcessor\Proxy</argument> </arguments> </type> + <type name="Magento\Framework\App\Response\Http"> + <arguments> + <argument name="sessionConfig" xsi:type="object">Magento\Framework\Session\Config\ConfigInterface\Proxy</argument> + </arguments> + </type> <preference for="Magento\Framework\Session\SaveHandlerInterface" type="Magento\Framework\Session\SaveHandler" /> <type name="Magento\Framework\Session\SaveHandlerFactory"> <arguments> diff --git a/lib/internal/Magento/Framework/App/Response/Http.php b/lib/internal/Magento/Framework/App/Response/Http.php index 62ff94e7043f5..ae900b0b423d9 100644 --- a/lib/internal/Magento/Framework/App/Response/Http.php +++ b/lib/internal/Magento/Framework/App/Response/Http.php @@ -71,14 +71,14 @@ public function __construct( CookieMetadataFactory $cookieMetadataFactory, Context $context, DateTime $dateTime, - ConfigInterface $sessionConfig = null + ConfigInterface $sessionConfig ) { $this->request = $request; $this->cookieManager = $cookieManager; $this->cookieMetadataFactory = $cookieMetadataFactory; $this->context = $context; $this->dateTime = $dateTime; - $this->sessionConfig = $sessionConfig ?: ObjectManager::getInstance()->get(ConfigInterface::class); + $this->sessionConfig = $sessionConfig; } /** From 04cc66a6650282491ed003edb707e101fbd50576 Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov <slopukhov@magento.com> Date: Thu, 7 Jun 2018 12:41:59 +0300 Subject: [PATCH 086/206] MAGETWO-91821: Handle website or customer group creation/deletion --- .../Product/Price/Plugin/CustomerGroup.php | 5 ++++- .../Indexer/Product/Price/Plugin/Website.php | 15 ++++----------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CustomerGroup.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CustomerGroup.php index 6f0d468c37f82..35375a713ccf0 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CustomerGroup.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CustomerGroup.php @@ -76,7 +76,8 @@ public function __construct( * * @param GroupRepositoryInterface $subject * @param \Closure $proceed - * @param GroupInterface $result + * @param GroupInterface $group + * * @return GroupInterface * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ @@ -97,6 +98,8 @@ public function aroundSave( } /** + * Update price index after customer group deleted + * * @param GroupRepositoryInterface $subject * @param bool $result * @param string $groupId diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/Website.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/Website.php index 2d7e76b3d86f6..719a6b4436158 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/Website.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/Website.php @@ -5,7 +5,6 @@ */ namespace Magento\Catalog\Model\Indexer\Product\Price\Plugin; -use Magento\Catalog\Model\Indexer\Product\Price\Processor; use Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer; use Magento\Catalog\Model\Indexer\Product\Price\ModeSwitcher; use Magento\Framework\App\Config\ScopeConfigInterface; @@ -18,11 +17,6 @@ class Website { - /** - * @var Processor - */ - private $processor; - /** * @var TableMaintainer */ @@ -48,20 +42,17 @@ class Website private $configReader; /** - * @param Processor $processor * @param TableMaintainer $tableMaintainer * @param DimensionFactory $dimensionFactory * @param CustomerGroupCollectionFactory $customerGroupCollectionFactory * @param ScopeConfigInterface $configReader */ public function __construct( - Processor $processor, TableMaintainer $tableMaintainer, DimensionFactory $dimensionFactory, CustomerGroupCollectionFactory $customerGroupCollectionFactory, ScopeConfigInterface $configReader ) { - $this->processor = $processor; $this->tableMaintainer = $tableMaintainer; $this->dimensionFactory = $dimensionFactory; $this->customerGroupCollectionFactory = $customerGroupCollectionFactory; @@ -69,6 +60,8 @@ public function __construct( } /** + * Update price index after website deleted + * * @param AbstractDb $subject * @param AbstractDb $objectResource * @param AbstractModel $website @@ -78,8 +71,6 @@ public function __construct( */ public function afterDelete(AbstractDb $subject, AbstractDb $objectResource, AbstractModel $website) { - $this->processor->markIndexerAsInvalid(); - foreach ($this->getAffectedDimensions($website->getId()) as $dimensions) { $this->tableMaintainer->dropTablesForDimensions($dimensions); } @@ -88,6 +79,8 @@ public function afterDelete(AbstractDb $subject, AbstractDb $objectResource, Abs } /** + * Update price index after website created + * * @param AbstractDb $subject * @param AbstractDb $objectResource * @param AbstractModel $website From 2d73f74645863ab8bc59137d8ad94399c3b023b3 Mon Sep 17 00:00:00 2001 From: Victor Rad <vrad@magento.com> Date: Thu, 7 Jun 2018 14:02:49 +0300 Subject: [PATCH 087/206] MAGETWO-74021: "Catalog Products List" widget does not displays on frontend --- app/code/Magento/CatalogWidget/Model/Rule/Condition/Product.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/CatalogWidget/Model/Rule/Condition/Product.php b/app/code/Magento/CatalogWidget/Model/Rule/Condition/Product.php index 9c679b8bfe9b0..f41318fcd5c24 100644 --- a/app/code/Magento/CatalogWidget/Model/Rule/Condition/Product.php +++ b/app/code/Magento/CatalogWidget/Model/Rule/Condition/Product.php @@ -118,7 +118,7 @@ public function addToCollection($collection) { $attribute = $this->getAttributeObject(); - if ($collection->isEnabledFlat()) { + if ($attribute->getUsedInProductListing() && $collection->isEnabledFlat()) { $alias = array_keys($collection->getSelect()->getPart('from'))[0]; $this->joinedAttributes[$attribute->getAttributeCode()] = $alias . '.' . $attribute->getAttributeCode(); return $this; From 73d221c72572cc9bcd57c70a4eedc3c92564b924 Mon Sep 17 00:00:00 2001 From: Victor Rad <vrad@magento.com> Date: Thu, 7 Jun 2018 16:13:09 +0300 Subject: [PATCH 088/206] MAGETWO-74021: "Catalog Products List" widget does not displays on frontend --- .../Catalog/Model/ResourceModel/Product/Collection.php | 5 +++-- .../Magento/CatalogWidget/Block/Product/ProductListTest.php | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php index 915ba08c58220..7dd4203d5021d 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php @@ -1060,14 +1060,15 @@ public function getAllAttributeValues($attribute) $select = clone $this->getSelect(); $attribute = $this->getEntity()->getAttribute($attribute); - $aiField = $this->getConnection()->getAutoIncrementField($this->getMainTable()); + $fieldMainTable = $this->getConnection()->getAutoIncrementField($this->getMainTable()); + $fieldJoinTable = $attribute->getEntity()->getLinkField(); $select->reset() ->from( ['cpe' => $this->getMainTable()], ['entity_id'] )->join( ['cpa' => $attribute->getBackend()->getTable()], - 'cpe.' . $aiField . ' = cpa.' . $aiField, + 'cpe.' . $fieldMainTable . ' = cpa.' . $fieldJoinTable, ['store_id', 'value'] )->where('attribute_id = ?', (int)$attribute->getId()); diff --git a/dev/tests/integration/testsuite/Magento/CatalogWidget/Block/Product/ProductListTest.php b/dev/tests/integration/testsuite/Magento/CatalogWidget/Block/Product/ProductListTest.php index 62baa8f3d70d1..3828d2b29e8e7 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogWidget/Block/Product/ProductListTest.php +++ b/dev/tests/integration/testsuite/Magento/CatalogWidget/Block/Product/ProductListTest.php @@ -115,6 +115,9 @@ public function testCreateCollectionWithDropdownAttributeStoreScope() . $dropdownAttributeOptionIds[1] . '`^]^]'; $this->block->setData('conditions_encoded', $encodedConditions); $this->performAssertions(2); + $attribute->setUsedInProductListing(0); + $attribute->save(); + $this->performAssertions(2); } /** From f588d60412bc9b92d89bc8a0f4d2e5991875559e Mon Sep 17 00:00:00 2001 From: Andrii Voskoboinikov <avoskoboinikov@magento.com> Date: Thu, 7 Jun 2018 18:12:53 +0300 Subject: [PATCH 089/206] MAGETWO-91823: Move Tier Price applying from Full Action --- .../Indexer/Product/Price/AbstractAction.php | 1 - .../Indexer/Product/Price/Action/Full.php | 4 - .../Product/Indexer/Price/DefaultPrice.php | 78 +++++++++++-- .../Indexer/Price/Query/BaseFinalPrice.php | 105 ++++++++++++++++-- 4 files changed, 165 insertions(+), 23 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php index 5814cefe95f58..6eff4f4c60da2 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php @@ -349,7 +349,6 @@ protected function _reindexRows($changedIds = []) // if (!empty($compositeIds)) { // $this->_copyRelationIndexData($compositeIds, $notCompositeIds); // } - $this->_prepareTierPriceIndex($changedIds); foreach ($productsTypes as $productType => $entityIds) { $indexer = $this->_getIndexer($productType); diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php index 045f127761858..e9da5a4b73489 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php @@ -249,7 +249,6 @@ private function reindexBatch(PriceInterface $priceIndexer, array $batch, string if ($priceIndexer->getIsComposite()) { $this->_copyRelationIndexData($entityIds); } - $this->_prepareTierPriceIndex($entityIds); // Reindex entities by id $priceIndexer->reindexEntity($entityIds); @@ -276,9 +275,6 @@ private function reindexBatchWithinDimension(DimensionalIndexerInterface $priceI // $this->_copyRelationIndexData($entityIds); // } - // TODO: handle inside index model and move index fulfilment into index model - $this->_prepareTierPriceIndex($entityIds); - $priceIndexer->executeByDimension($dimensions, \SplFixedArray::fromArray($entityIds, false)); // Sync data from temp table to index table diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php index 563f764f8a6b8..59e6999aa817e 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php @@ -360,9 +360,29 @@ protected function getSelect($entityIds = null, $type = null) 'pw.product_id = e.entity_id AND pw.website_id = cw.website_id', [] )->joinLeft( - ['tp' => $this->_getTierPriceIndexTable()], - 'tp.entity_id = e.entity_id AND tp.website_id = cw.website_id' . - ' AND tp.customer_group_id = cg.customer_group_id', + // we need this only for BCC in case someone expects table `tp` to be present in query + ['tp' => $this->getTable('catalog_product_index_tier_price')], + 'tp.entity_id = e.entity_id AND tp.customer_group_id = cg.customer_group_id AND tp.website_id = pw.website_id', + [] + )->joinLeft( + // calculate tier price specified as Website = `All Websites` and Customer Group = `Specific Customer Group` + ['tier_price_1' => $this->getTable('catalog_product_entity_tier_price')], + 'tier_price_1.row_id = e.row_id AND tier_price_1.all_groups = 0 AND tier_price_1.customer_group_id = cg.customer_group_id AND tier_price_1.qty = 1 AND tier_price_1.website_id = 0', + [] + )->joinLeft( + // calculate tier price specified as Website = `Specific Website` and Customer Group = `Specific Customer Group` + ['tier_price_2' => $this->getTable('catalog_product_entity_tier_price')], + 'tier_price_2.row_id = e.row_id AND tier_price_2.all_groups = 0 AND tier_price_2.customer_group_id = cg.customer_group_id AND tier_price_2.qty = 1 AND tier_price_2.website_id = cw.website_id', + [] + )->joinLeft( + // calculate tier price specified as Website = `All Websites` and Customer Group = `ALL GROUPS` + ['tier_price_3' => $this->getTable('catalog_product_entity_tier_price')], + 'tier_price_3.row_id = e.row_id AND tier_price_3.all_groups = 1 AND tier_price_3.customer_group_id = 0 AND tier_price_3.qty = 1 AND tier_price_3.website_id = 0', + [] + )->joinLeft( + // calculate tier price specified as Website = `Specific Website` and Customer Group = `ALL GROUPS` + ['tier_price_4' => $this->getTable('catalog_product_entity_tier_price')], + 'tier_price_4.row_id = e.row_id AND tier_price_4.all_groups = 1 AND tier_price_4.customer_group_id = 0 AND tier_price_4.qty = 1 AND tier_price_4.website_id = cw.website_id', [] ); @@ -431,11 +451,8 @@ protected function getSelect($entityIds = null, $type = null) $specialPrice, $maxUnsignedBigint ); - $tierPrice = new \Zend_Db_Expr('tp.min_price'); - $tierPriceExpr = $connection->getIfNullSql( - $tierPrice, - $maxUnsignedBigint - ); + $tierPrice = $this->getTotalTierPriceExpression($price); + $tierPriceExpr = $connection->getIfNullSql($tierPrice, $maxUnsignedBigint); $finalPrice = $connection->getLeastSql([ $price, $specialPriceExpr, @@ -795,4 +812,49 @@ protected function hasEntity() return $this->hasEntity; } + + protected function getTotalTierPriceExpression(\Zend_Db_Expr $priceExpression) + { + $maxUnsignedBigint = '~0'; + + return $this->getConnection()->getCheckSql( + implode( + ' AND ', + [ + 'tier_price_1.value_id is NULL', + 'tier_price_2.value_id is NULL', + 'tier_price_3.value_id is NULL', + 'tier_price_4.value_id is NULL' + ] + ), + 'NULL', + $this->getConnection()->getLeastSql([ + $this->getConnection()->getIfNullSql( + $this->getTierPriceExpressionForTable('tier_price_1', $priceExpression), + $maxUnsignedBigint + ), + $this->getConnection()->getIfNullSql( + $this->getTierPriceExpressionForTable('tier_price_2', $priceExpression), + $maxUnsignedBigint + ), + $this->getConnection()->getIfNullSql( + $this->getTierPriceExpressionForTable('tier_price_3', $priceExpression), + $maxUnsignedBigint + ), + $this->getConnection()->getIfNullSql( + $this->getTierPriceExpressionForTable('tier_price_4', $priceExpression), + $maxUnsignedBigint + ), + ]) + ); + } + + private function getTierPriceExpressionForTable($tableAlias, \Zend_Db_Expr $priceExpression) + { + return $this->getConnection()->getCheckSql( + sprintf('%s.value = 0', $tableAlias), + sprintf('ROUND(%s * (1 - ROUND(%s.percentage_value * cwd.rate, 4) / 100), 4)', $priceExpression, $tableAlias), + sprintf('ROUND(%s.value * cwd.rate, 4)', $tableAlias) + ); + } } diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php index a93aa7d25c62c..8274411d47ee2 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php @@ -55,6 +55,11 @@ class BaseFinalPrice CustomerGroupDataProvider::DIMENSION_NAME => 'cg.customer_group_id', ]; + /** + * @var \Magento\Framework\DB\Adapter\AdapterInterface + */ + private $connection; + /** * BaseFinalPrice constructor. * @param \Magento\Framework\App\ResourceConnection $resource @@ -87,14 +92,19 @@ public function __construct( */ public function getQuery(array $dimensions, string $productType, array $entityIds = []): Select { - $connection = $this->resource->getConnection($this->connectionName); + $connection = $this->getConnection(); $select = $connection->select()->from( ['e' => $this->getTable('catalog_product_entity')], ['entity_id'] )->joinInner( ['cg' => $this->getTable('customer_group')], - [], + array_key_exists(CustomerGroupDataProvider::DIMENSION_NAME, $dimensions) + ? sprintf( + '%s = %s', + $this->dimensionToFieldMapper[CustomerGroupDataProvider::DIMENSION_NAME], + $dimensions[CustomerGroupDataProvider::DIMENSION_NAME]->getValue() + ) : '', ['customer_group_id'] )->joinInner( ['pw' => $this->getTable('catalog_product_website')], @@ -105,9 +115,29 @@ public function getQuery(array $dimensions, string $productType, array $entityId 'pw.website_id = cwd.website_id', [] )->joinLeft( - ['tp' => $this->getTable('catalog_product_index_tier_price')], //TODO: alligig with tier price - 'tp.entity_id = e.entity_id AND tp.website_id = pw.website_id' . - ' AND tp.customer_group_id = cg.customer_group_id', + // we need this only for BCC in case someone expects table `tp` to be present in query + ['tp' => $this->getTable('catalog_product_index_tier_price')], + 'tp.entity_id = e.entity_id AND tp.customer_group_id = cg.customer_group_id AND tp.website_id = pw.website_id', + [] + )->joinLeft( + // calculate tier price specified as Website = `All Websites` and Customer Group = `Specific Customer Group` + ['tier_price_1' => $this->getTable('catalog_product_entity_tier_price')], + 'tier_price_1.row_id = e.row_id AND tier_price_1.all_groups = 0 AND tier_price_1.customer_group_id = cg.customer_group_id AND tier_price_1.qty = 1 AND tier_price_1.website_id = 0', + [] + )->joinLeft( + // calculate tier price specified as Website = `Specific Website` and Customer Group = `Specific Customer Group` + ['tier_price_2' => $this->getTable('catalog_product_entity_tier_price')], + 'tier_price_2.row_id = e.row_id AND tier_price_2.all_groups = 0 AND tier_price_2.customer_group_id = cg.customer_group_id AND tier_price_2.qty = 1 AND tier_price_2.website_id = pw.website_id', + [] + )->joinLeft( + // calculate tier price specified as Website = `All Websites` and Customer Group = `ALL GROUPS` + ['tier_price_3' => $this->getTable('catalog_product_entity_tier_price')], + 'tier_price_3.row_id = e.row_id AND tier_price_3.all_groups = 1 AND tier_price_3.customer_group_id = 0 AND tier_price_3.qty = 1 AND tier_price_3.website_id = 0', + [] + )->joinLeft( + // calculate tier price specified as Website = `Specific Website` and Customer Group = `ALL GROUPS` + ['tier_price_4' => $this->getTable('catalog_product_entity_tier_price')], + 'tier_price_4.row_id = e.row_id AND tier_price_4.all_groups = 1 AND tier_price_4.customer_group_id = 0 AND tier_price_4.qty = 1 AND tier_price_4.website_id = pw.website_id', [] ); @@ -145,11 +175,8 @@ public function getQuery(array $dimensions, string $productType, array $entityId $specialPrice, $maxUnsignedBigint ); - $tierPrice = new ColumnValueExpression('tp.min_price'); - $tierPriceExpr = $connection->getIfNullSql( - $tierPrice, - $maxUnsignedBigint - ); + $tierPrice = $this->getTotalTierPriceExpression($price); + $tierPriceExpr = $connection->getIfNullSql($tierPrice, $maxUnsignedBigint); $finalPrice = $connection->getLeastSql([ $price, $specialPriceExpr, @@ -192,6 +219,64 @@ public function getQuery(array $dimensions, string $productType, array $entityId return $select; } + private function getTotalTierPriceExpression(\Zend_Db_Expr $priceExpression) + { + $maxUnsignedBigint = '~0'; + + return $this->getConnection()->getCheckSql( + implode( + ' AND ', + [ + 'tier_price_1.value_id is NULL', + 'tier_price_2.value_id is NULL', + 'tier_price_3.value_id is NULL', + 'tier_price_4.value_id is NULL' + ] + ), + 'NULL', + $this->getConnection()->getLeastSql([ + $this->getConnection()->getIfNullSql( + $this->getTierPriceExpressionForTable('tier_price_1', $priceExpression), + $maxUnsignedBigint + ), + $this->getConnection()->getIfNullSql( + $this->getTierPriceExpressionForTable('tier_price_2', $priceExpression), + $maxUnsignedBigint + ), + $this->getConnection()->getIfNullSql( + $this->getTierPriceExpressionForTable('tier_price_3', $priceExpression), + $maxUnsignedBigint + ), + $this->getConnection()->getIfNullSql( + $this->getTierPriceExpressionForTable('tier_price_4', $priceExpression), + $maxUnsignedBigint + ), + ]) + ); + } + + private function getTierPriceExpressionForTable($tableAlias, \Zend_Db_Expr $priceExpression): \Zend_Db_Expr + { + return $this->getConnection()->getCheckSql( + sprintf('%s.value = 0', $tableAlias), + sprintf('ROUND(%s * (1 - ROUND(%s.percentage_value * cwd.rate, 4) / 100), 4)', $priceExpression, $tableAlias), + sprintf('ROUND(%s.value * cwd.rate, 4)', $tableAlias) + ); + } + + /** + * return \Magento\Framework\DB\Adapter\AdapterInterface + * @throws \DomainException + */ + private function getConnection(): \Magento\Framework\DB\Adapter\AdapterInterface + { + if ($this->connection === null) { + $this->connection = $this->resource->getConnection($this->connectionName); + } + + return $this->connection; + } + /** * @param string $tableName * @return string From 610d6e03eb2aed834efd05d1d568f6b2e4f0cb4a Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov <slopukhov@magento.com> Date: Fri, 8 Jun 2018 08:24:20 +0300 Subject: [PATCH 090/206] MAGETWO-91821: Handle website or customer group creation/deletion --- .../Model/Indexer/Product/Price/Plugin/CustomerGroup.php | 2 +- .../Catalog/Model/Indexer/Product/Price/Plugin/Website.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CustomerGroup.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CustomerGroup.php index 35375a713ccf0..e0dd908f0dd3f 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CustomerGroup.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CustomerGroup.php @@ -129,7 +129,7 @@ private function getAffectedDimensions(int $groupId): array switch ($this->configReader->getValue(ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE)) { case ModeSwitcher::INPUT_KEY_CUSTOMER_GROUP: - $return = [$this->dimensionFactory->create(CustomerGroupDataProvider::DIMENSION_NAME, $groupId)]; + $return[] = [$this->dimensionFactory->create(CustomerGroupDataProvider::DIMENSION_NAME, $groupId)]; break; case ModeSwitcher::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP: $websiteIds = $this->websiteCollectionFactory->create() diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/Website.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/Website.php index 719a6b4436158..d8ae250e37f9a 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/Website.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/Website.php @@ -112,7 +112,7 @@ private function getAffectedDimensions(int $websiteId): array switch ($this->configReader->getValue(ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE)) { case ModeSwitcher::INPUT_KEY_WEBSITE: - $return = [$this->dimensionFactory->create(WebsiteDataProvider::DIMENSION_NAME, $websiteId)]; + $return[] = [$this->dimensionFactory->create(WebsiteDataProvider::DIMENSION_NAME, $websiteId)]; break; case ModeSwitcher::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP: $customerGroupIds = $this->customerGroupCollectionFactory->create()->getAllIds(); From 051b2992e65d9dad5363660014ae60fd78a76091 Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov <slopukhov@magento.com> Date: Fri, 8 Jun 2018 10:51:11 +0300 Subject: [PATCH 091/206] MAGETWO-91821: Handle website or customer group creation/deletion --- .../Product/Price/Plugin/WebsiteTest.php | 97 ++++++++++++++++--- 1 file changed, 85 insertions(+), 12 deletions(-) diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Plugin/WebsiteTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Plugin/WebsiteTest.php index d551822d975ea..24a110111be10 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Plugin/WebsiteTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Plugin/WebsiteTest.php @@ -10,38 +10,111 @@ class WebsiteTest extends \PHPUnit\Framework\TestCase /** * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager */ - protected $_objectManager; + protected $objectManager; /** * @var \Magento\Catalog\Model\Indexer\Product\Price\Plugin\Website */ - protected $_model; + protected $model; /** * @var \Magento\Catalog\Model\Indexer\Product\Price\Processor|\PHPUnit_Framework_MockObject_MockObject */ - protected $_priceProcessorMock; + protected $scopeConfig; + + /** + * @var \Magento\Framework\Indexer\DimensionFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $dimensionFactory; + + /** + * @var \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer|\PHPUnit_Framework_MockObject_MockObject + */ + protected $tableMaintainer; protected function setUp() { - $this->_objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->_priceProcessorMock = $this->createPartialMock( - \Magento\Catalog\Model\Indexer\Product\Price\Processor::class, - ['markIndexerAsInvalid'] + $this->scopeConfig = $this->createPartialMock( + \Magento\Framework\App\Config\ScopeConfigInterface::class, + ['getValue', 'isSetFlag'] ); - $this->_model = $this->_objectManager->getObject( + $this->dimensionFactory = $this->createPartialMock( + \Magento\Framework\Indexer\DimensionFactory::class, + ['create'] + ); + + $this->tableMaintainer = $this->createPartialMock( + \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer::class, + ['dropTablesForDimensions', 'createTablesForDimensions'] + ); + + $this->model = $this->objectManager->getObject( \Magento\Catalog\Model\Indexer\Product\Price\Plugin\Website::class, - ['processor' => $this->_priceProcessorMock] + [ + 'configReader' => $this->scopeConfig, + 'dimensionFactory' => $this->dimensionFactory, + 'tableMaintainer' => $this->tableMaintainer, + ] ); } public function testAfterDelete() { - $this->_priceProcessorMock->expects($this->once())->method('markIndexerAsInvalid'); + $dimensionMock = $this->createMock(\Magento\Framework\Indexer\Dimension::class); - $websiteMock = $this->createMock(\Magento\Store\Model\ResourceModel\Website::class); - $this->assertEquals('return_value', $this->_model->afterDelete($websiteMock, 'return_value')); + $this->scopeConfig->expects($this->once())->method('getValue')->willReturn( + \Magento\Catalog\Model\Indexer\Product\Price\ModeSwitcher::INPUT_KEY_WEBSITE + ); + $this->dimensionFactory->expects($this->once())->method('create')->willReturn( + $dimensionMock + ); + $this->tableMaintainer->expects($this->once())->method('dropTablesForDimensions')->with( + [$dimensionMock] + ); + + $subjectMock = $this->createMock(\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class); + $objectResourceMock = $this->createMock(\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class); + $websiteMock = $this->createMock(\Magento\Framework\Model\AbstractModel::class); + $websiteMock->expects($this->once()) + ->method('getId') + ->willReturn(1); + + $this->assertEquals( + $objectResourceMock, + $this->model->afterDelete($subjectMock, $objectResourceMock, $websiteMock) + ); + } + + public function testAfterSave() + { + $dimensionMock = $this->createMock(\Magento\Framework\Indexer\Dimension::class); + + $this->scopeConfig->expects($this->once())->method('getValue')->willReturn( + \Magento\Catalog\Model\Indexer\Product\Price\ModeSwitcher::INPUT_KEY_WEBSITE + ); + $this->dimensionFactory->expects($this->once())->method('create')->willReturn( + $dimensionMock + ); + $this->tableMaintainer->expects($this->once())->method('createTablesForDimensions')->with( + [$dimensionMock] + ); + + $subjectMock = $this->createMock(\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class); + $objectResourceMock = $this->createMock(\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class); + $websiteMock = $this->createMock(\Magento\Framework\Model\AbstractModel::class); + $websiteMock->expects($this->once()) + ->method('getId') + ->willReturn(1); + $websiteMock->expects($this->once()) + ->method('isObjectNew') + ->willReturn(true); + + $this->assertEquals( + $objectResourceMock, + $this->model->afterSave($subjectMock, $objectResourceMock, $websiteMock) + ); } } From b0b82d0025d0556e0a05951c54c997f45623015a Mon Sep 17 00:00:00 2001 From: Francesco Marangi <f.marangi@mzentrale.de> Date: Fri, 8 Jun 2018 09:52:37 +0200 Subject: [PATCH 092/206] #15929: Apply changes to HTTP response also to its subclasses --- .../Magento/MediaStorage/Model/File/Storage/Response.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/MediaStorage/Model/File/Storage/Response.php b/app/code/Magento/MediaStorage/Model/File/Storage/Response.php index 216068c9fc32a..0549c24fbd039 100644 --- a/app/code/Magento/MediaStorage/Model/File/Storage/Response.php +++ b/app/code/Magento/MediaStorage/Model/File/Storage/Response.php @@ -7,6 +7,7 @@ use Magento\Framework\App\Response\Http; use Magento\Framework\App\Request\Http as HttpRequest; +use Magento\Framework\Session\Config\ConfigInterface; use Magento\Framework\Stdlib\Cookie\CookieMetadataFactory; use Magento\Framework\Stdlib\CookieManagerInterface; @@ -34,6 +35,7 @@ class Response extends Http implements * @param CookieMetadataFactory $cookieMetadataFactory * @param \Magento\Framework\App\Http\Context $context * @param \Magento\Framework\Stdlib\DateTime $dateTime + * @param ConfigInterface $sessionConfig * @param \Magento\Framework\File\Transfer\Adapter\Http $transferAdapter */ public function __construct( @@ -42,9 +44,10 @@ public function __construct( CookieMetadataFactory $cookieMetadataFactory, \Magento\Framework\App\Http\Context $context, \Magento\Framework\Stdlib\DateTime $dateTime, + ConfigInterface $sessionConfig, \Magento\Framework\File\Transfer\Adapter\Http $transferAdapter ) { - parent::__construct($request, $cookieManager, $cookieMetadataFactory, $context, $dateTime); + parent::__construct($request, $cookieManager, $cookieMetadataFactory, $context, $dateTime, $sessionConfig); $this->_transferAdapter = $transferAdapter; } From 7e835c3cdecf70cf36c36968d4cd4bac7574b3eb Mon Sep 17 00:00:00 2001 From: Francesco Marangi <f.marangi@mzentrale.de> Date: Fri, 8 Jun 2018 12:26:13 +0200 Subject: [PATCH 093/206] #15929: Reset changes to HTTP response classes --- .../Magento/MediaStorage/Model/File/Storage/Response.php | 5 +---- lib/internal/Magento/Framework/App/Response/Http.php | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/app/code/Magento/MediaStorage/Model/File/Storage/Response.php b/app/code/Magento/MediaStorage/Model/File/Storage/Response.php index 0549c24fbd039..216068c9fc32a 100644 --- a/app/code/Magento/MediaStorage/Model/File/Storage/Response.php +++ b/app/code/Magento/MediaStorage/Model/File/Storage/Response.php @@ -7,7 +7,6 @@ use Magento\Framework\App\Response\Http; use Magento\Framework\App\Request\Http as HttpRequest; -use Magento\Framework\Session\Config\ConfigInterface; use Magento\Framework\Stdlib\Cookie\CookieMetadataFactory; use Magento\Framework\Stdlib\CookieManagerInterface; @@ -35,7 +34,6 @@ class Response extends Http implements * @param CookieMetadataFactory $cookieMetadataFactory * @param \Magento\Framework\App\Http\Context $context * @param \Magento\Framework\Stdlib\DateTime $dateTime - * @param ConfigInterface $sessionConfig * @param \Magento\Framework\File\Transfer\Adapter\Http $transferAdapter */ public function __construct( @@ -44,10 +42,9 @@ public function __construct( CookieMetadataFactory $cookieMetadataFactory, \Magento\Framework\App\Http\Context $context, \Magento\Framework\Stdlib\DateTime $dateTime, - ConfigInterface $sessionConfig, \Magento\Framework\File\Transfer\Adapter\Http $transferAdapter ) { - parent::__construct($request, $cookieManager, $cookieMetadataFactory, $context, $dateTime, $sessionConfig); + parent::__construct($request, $cookieManager, $cookieMetadataFactory, $context, $dateTime); $this->_transferAdapter = $transferAdapter; } diff --git a/lib/internal/Magento/Framework/App/Response/Http.php b/lib/internal/Magento/Framework/App/Response/Http.php index ae900b0b423d9..62ff94e7043f5 100644 --- a/lib/internal/Magento/Framework/App/Response/Http.php +++ b/lib/internal/Magento/Framework/App/Response/Http.php @@ -71,14 +71,14 @@ public function __construct( CookieMetadataFactory $cookieMetadataFactory, Context $context, DateTime $dateTime, - ConfigInterface $sessionConfig + ConfigInterface $sessionConfig = null ) { $this->request = $request; $this->cookieManager = $cookieManager; $this->cookieMetadataFactory = $cookieMetadataFactory; $this->context = $context; $this->dateTime = $dateTime; - $this->sessionConfig = $sessionConfig; + $this->sessionConfig = $sessionConfig ?: ObjectManager::getInstance()->get(ConfigInterface::class); } /** From 952c0c2a2a120a3f039d376b63690fc5d88d4adf Mon Sep 17 00:00:00 2001 From: Michail Slabko <mslabko@magento.com> Date: Fri, 8 Jun 2018 13:35:25 +0300 Subject: [PATCH 094/206] MAGETWO-92394: Implement partial reindex - MAGETWO-64467 [Indexer optimizations] Tables sharding / segmentation for price indexer --- .../Model/ResourceModel/Indexer/Price.php | 2 +- .../Indexer/Product/Price/AbstractAction.php | 31 +++------- .../Indexer/Product/Price/Action/Full.php | 16 ++--- .../Product/Indexer/Price/DefaultPrice.php | 58 +++++++++++++++---- .../Indexer/Price/Query/BaseFinalPrice.php | 17 ++++-- .../Product/Indexer/Price/Configurable.php | 2 +- .../Product/Indexer/Price/Grouped.php | 2 +- 7 files changed, 79 insertions(+), 49 deletions(-) diff --git a/app/code/Magento/Bundle/Model/ResourceModel/Indexer/Price.php b/app/code/Magento/Bundle/Model/ResourceModel/Indexer/Price.php index 32f13e9457217..765b9374c66ed 100644 --- a/app/code/Magento/Bundle/Model/ResourceModel/Indexer/Price.php +++ b/app/code/Magento/Bundle/Model/ResourceModel/Indexer/Price.php @@ -355,7 +355,7 @@ protected function _calculateBundleSelectionPrice($priceType) 'bs.selection_id = bsp.selection_id AND bsp.website_id = i.website_id', [''] )->join( - ['idx' => $this->getIdxTable()], + ['idx' => $this->getIndexTableForCompositeProducts()], 'bs.product_id = idx.entity_id AND i.customer_group_id = idx.customer_group_id' . ' AND i.website_id = idx.website_id', [] diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php index 6eff4f4c60da2..4f85b14152444 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php @@ -327,40 +327,20 @@ protected function _reindexRows($changedIds = []) $this->_prepareWebsiteDateTable(); $productsTypes = $this->getProductsTypes($changedIds); - - //TODO: tests with composite products -// foreach ($productsTypes as $productType => $entityIds) { -// $indexer = $this->_getIndexer($productType); -// if ($indexer->getIsComposite()) { -// $compositeIds += $entityIds; -// } else { -// $notCompositeIds += $entityIds; -// } -// } - $parentProductsTypes = $this->getParentProductsTypes($changedIds); - $productsTypes = array_merge_recursive($productsTypes, $parentProductsTypes); - foreach ($parentProductsTypes as $parentProductsIds) { - $changedIds = array_merge($changedIds, $parentProductsIds); - } - $changedIds = array_unique($changedIds); - //TODO: check that it handled for composite products -// if (!empty($compositeIds)) { -// $this->_copyRelationIndexData($compositeIds, $notCompositeIds); -// } + $changedIds = array_merge($changedIds, ...array_values($parentProductsTypes)); + $productsTypes = array_merge_recursive($productsTypes, $parentProductsTypes); foreach ($productsTypes as $productType => $entityIds) { $indexer = $this->_getIndexer($productType); if ($indexer instanceof DimensionalIndexerInterface) { $indexer->executeByDimension([], \SplFixedArray::fromArray($entityIds, false)); } else { - // copy relation index data for backward compatibility - $this->_copyRelationIndexData($entityIds); $indexer->reindexEntity($entityIds); } + $this->_syncData($entityIds); } - $this->_syncData($changedIds); return $changedIds; } @@ -371,7 +351,10 @@ protected function _reindexRows($changedIds = []) * @param null|array $parentIds * @param array $excludeIds * @return \Magento\Catalog\Model\Indexer\Product\Price\AbstractAction - */ + * @deprecated Not used anymore. All composite products read data directly from main price indexer table or replica + * table for partial or full reindex correspondingly + * @see \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\DefaultPrice::getIndexTableForCompositeProducts + */ protected function _copyRelationIndexData($parentIds, $excludeIds = null) { $linkField = $this->getProductIdFieldName(); diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php index e9da5a4b73489..2350b97e94cee 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php @@ -164,6 +164,9 @@ public function execute($ids = null) continue; } + //TODO: fix dirty hac + $priceIndexer->setIsPartial(false); + $priceIndexer->getTableStrategy()->setUseIdxTable(false); $this->reindexProductType($priceIndexer, $typeId); } @@ -182,6 +185,12 @@ private function prepareTables() // Prepare replica table for indexation. $this->_defaultIndexerResource->getConnection()->truncateTable($this->getReplicaTable()); + + // TODO: truncate by dimensions +// $this->dimensionTableMaintainer->getConnection()->truncateTable( +// $this->dimensionTableMaintainer->getMainReplicaTable($dimensions) +// ); + } private function switchTables() @@ -223,9 +232,6 @@ private function reindexProductTypeWithDimensions(DimensionalIndexerInterface $p $dimensionsProviders = $this->dimensionCollectionFactory->createByMode($currentMode); foreach ($dimensionsProviders as $dimensions) { - $this->dimensionTableMaintainer->getConnection()->truncateTable( - $this->dimensionTableMaintainer->getMainReplicaTable($dimensions) - ); $this->reindexDimensions($priceIndexer, $dimensions, $typeId); } } @@ -246,10 +252,6 @@ private function reindexBatch(PriceInterface $priceIndexer, array $batch, string $idxTableName = $this->_defaultIndexerResource->getIdxTable(); $this->_emptyTable($idxTableName); - if ($priceIndexer->getIsComposite()) { - $this->_copyRelationIndexData($entityIds); - } - // Reindex entities by id $priceIndexer->reindexEntity($entityIds); diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php index 59e6999aa817e..602a1bc91b842 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php @@ -66,6 +66,11 @@ class DefaultPrice extends AbstractIndexer implements PriceInterface */ private $priceModifiers = []; + /** + * @var \Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher + */ + private $activeTableSwitcher; + /** * DefaultPrice constructor. * @@ -86,7 +91,8 @@ public function __construct( \Magento\Framework\Module\Manager $moduleManager, $connectionName = null, IndexTableStructureFactory $indexTableStructureFactory = null, - array $priceModifiers = [] + array $priceModifiers = [], + \Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher $activeTableSwitcher = null ) { $this->_eventManager = $eventManager; $this->moduleManager = $moduleManager; @@ -103,6 +109,9 @@ public function __construct( $this->priceModifiers[] = $priceModifier; } + $this->activeTableSwitcher = $activeTableSwitcher ?: ObjectManager::getInstance()->get( + \Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher::class + ); } /** @@ -331,6 +340,7 @@ protected function prepareFinalPriceDataForType($entityIds, $type) protected function getSelect($entityIds = null, $type = null) { $metadata = $this->getMetadataPool()->getMetadata(\Magento\Catalog\Api\Data\ProductInterface::class); + $linkField = $metadata->getLinkField(); $connection = $this->getConnection(); $select = $connection->select()->from( ['e' => $this->getTable('catalog_product_entity')], @@ -367,22 +377,22 @@ protected function getSelect($entityIds = null, $type = null) )->joinLeft( // calculate tier price specified as Website = `All Websites` and Customer Group = `Specific Customer Group` ['tier_price_1' => $this->getTable('catalog_product_entity_tier_price')], - 'tier_price_1.row_id = e.row_id AND tier_price_1.all_groups = 0 AND tier_price_1.customer_group_id = cg.customer_group_id AND tier_price_1.qty = 1 AND tier_price_1.website_id = 0', + 'tier_price_1.' . $linkField . ' = e.' . $linkField . ' AND tier_price_1.all_groups = 0 AND tier_price_1.customer_group_id = cg.customer_group_id AND tier_price_1.qty = 1 AND tier_price_1.website_id = 0', [] )->joinLeft( // calculate tier price specified as Website = `Specific Website` and Customer Group = `Specific Customer Group` ['tier_price_2' => $this->getTable('catalog_product_entity_tier_price')], - 'tier_price_2.row_id = e.row_id AND tier_price_2.all_groups = 0 AND tier_price_2.customer_group_id = cg.customer_group_id AND tier_price_2.qty = 1 AND tier_price_2.website_id = cw.website_id', + 'tier_price_2.' . $linkField . ' = e.' . $linkField . ' AND tier_price_2.all_groups = 0 AND tier_price_2.customer_group_id = cg.customer_group_id AND tier_price_2.qty = 1 AND tier_price_2.website_id = cw.website_id', [] )->joinLeft( // calculate tier price specified as Website = `All Websites` and Customer Group = `ALL GROUPS` ['tier_price_3' => $this->getTable('catalog_product_entity_tier_price')], - 'tier_price_3.row_id = e.row_id AND tier_price_3.all_groups = 1 AND tier_price_3.customer_group_id = 0 AND tier_price_3.qty = 1 AND tier_price_3.website_id = 0', + 'tier_price_3.' . $linkField . ' = e.' . $linkField . ' AND tier_price_3.all_groups = 1 AND tier_price_3.customer_group_id = 0 AND tier_price_3.qty = 1 AND tier_price_3.website_id = 0', [] )->joinLeft( // calculate tier price specified as Website = `Specific Website` and Customer Group = `ALL GROUPS` ['tier_price_4' => $this->getTable('catalog_product_entity_tier_price')], - 'tier_price_4.row_id = e.row_id AND tier_price_4.all_groups = 1 AND tier_price_4.customer_group_id = 0 AND tier_price_4.qty = 1 AND tier_price_4.website_id = cw.website_id', + 'tier_price_4.' . $linkField . ' = e.' . $linkField . ' AND tier_price_4.all_groups = 1 AND tier_price_4.customer_group_id = 0 AND tier_price_4.qty = 1 AND tier_price_4.website_id = cw.website_id', [] ); @@ -398,7 +408,7 @@ protected function getSelect($entityIds = null, $type = null) $this->_addAttributeToSelect( $select, 'status', - 'e.' . $metadata->getLinkField(), + 'e.' . $linkField, 'cs.store_id', $statusCond, true @@ -407,7 +417,7 @@ protected function getSelect($entityIds = null, $type = null) $taxClassId = $this->_addAttributeToSelect( $select, 'tax_class_id', - 'e.' . $metadata->getLinkField(), + 'e.' . $linkField, 'cs.store_id' ); } else { @@ -418,25 +428,25 @@ protected function getSelect($entityIds = null, $type = null) $price = $this->_addAttributeToSelect( $select, 'price', - 'e.' . $metadata->getLinkField(), + 'e.' . $linkField, 'cs.store_id' ); $specialPrice = $this->_addAttributeToSelect( $select, 'special_price', - 'e.' . $metadata->getLinkField(), + 'e.' . $linkField, 'cs.store_id' ); $specialFrom = $this->_addAttributeToSelect( $select, 'special_from_date', - 'e.' . $metadata->getLinkField(), + 'e.' . $linkField, 'cs.store_id' ); $specialTo = $this->_addAttributeToSelect( $select, 'special_to_date', - 'e.' . $metadata->getLinkField(), + 'e.' . $linkField, 'cs.store_id' ); $currentDate = 'cwd.website_date'; @@ -792,6 +802,32 @@ public function getIdxTable($table = null) return $this->tableStrategy->getTableName('catalog_product_index_price'); } + /** + * Return index table name depends in indexation mode: main price index table for partial reindex + * and replica table for full reindex + * + * @return string + * @throws \Magento\Framework\Exception\LocalizedException + */ + protected function getIndexTableForCompositeProducts() + { + // TODO: temporary fix, move to composite products + return $this->isPartial + ? $this->getMainTable() + : $this->activeTableSwitcher->getAdditionalTableName($this->getMainTable()); + } + + private $isPartial = true; + + /** + * @param bool $isPartial + * TODO: fix dirty hac + */ + public function setIsPartial(bool $isPartial) + { + $this->isPartial = $isPartial; + } + /** * @return bool */ diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php index 8274411d47ee2..5418f717231a9 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php @@ -60,6 +60,11 @@ class BaseFinalPrice */ private $connection; + /** + * @var \Magento\Framework\EntityManager\MetadataPool + */ + private $metadataPool; + /** * BaseFinalPrice constructor. * @param \Magento\Framework\App\ResourceConnection $resource @@ -72,6 +77,7 @@ public function __construct( JoinAttributeProcessor $joinAttributeProcessor, \Magento\Framework\Module\Manager $moduleManager, \Magento\Framework\Event\ManagerInterface $eventManager, + \Magento\Framework\EntityManager\MetadataPool $metadataPool, $connectionName = 'indexer' ) { $this->resource = $resource; @@ -79,6 +85,7 @@ public function __construct( $this->joinAttributeProcessor = $joinAttributeProcessor; $this->moduleManager = $moduleManager; $this->eventManager = $eventManager; + $this->metadataPool = $metadataPool; } /** @@ -93,6 +100,8 @@ public function __construct( public function getQuery(array $dimensions, string $productType, array $entityIds = []): Select { $connection = $this->getConnection(); + $metadata = $this->metadataPool->getMetadata(\Magento\Catalog\Api\Data\ProductInterface::class); + $linkField = $metadata->getLinkField(); $select = $connection->select()->from( ['e' => $this->getTable('catalog_product_entity')], @@ -122,22 +131,22 @@ public function getQuery(array $dimensions, string $productType, array $entityId )->joinLeft( // calculate tier price specified as Website = `All Websites` and Customer Group = `Specific Customer Group` ['tier_price_1' => $this->getTable('catalog_product_entity_tier_price')], - 'tier_price_1.row_id = e.row_id AND tier_price_1.all_groups = 0 AND tier_price_1.customer_group_id = cg.customer_group_id AND tier_price_1.qty = 1 AND tier_price_1.website_id = 0', + 'tier_price_1.' . $linkField . ' = e.' . $linkField . ' AND tier_price_1.all_groups = 0 AND tier_price_1.customer_group_id = cg.customer_group_id AND tier_price_1.qty = 1 AND tier_price_1.website_id = 0', [] )->joinLeft( // calculate tier price specified as Website = `Specific Website` and Customer Group = `Specific Customer Group` ['tier_price_2' => $this->getTable('catalog_product_entity_tier_price')], - 'tier_price_2.row_id = e.row_id AND tier_price_2.all_groups = 0 AND tier_price_2.customer_group_id = cg.customer_group_id AND tier_price_2.qty = 1 AND tier_price_2.website_id = pw.website_id', + 'tier_price_2.' . $linkField . ' = e.' . $linkField . ' AND tier_price_2.all_groups = 0 AND tier_price_2.customer_group_id = cg.customer_group_id AND tier_price_2.qty = 1 AND tier_price_2.website_id = pw.website_id', [] )->joinLeft( // calculate tier price specified as Website = `All Websites` and Customer Group = `ALL GROUPS` ['tier_price_3' => $this->getTable('catalog_product_entity_tier_price')], - 'tier_price_3.row_id = e.row_id AND tier_price_3.all_groups = 1 AND tier_price_3.customer_group_id = 0 AND tier_price_3.qty = 1 AND tier_price_3.website_id = 0', + 'tier_price_3.' . $linkField . ' = e.' . $linkField . ' AND tier_price_3.all_groups = 1 AND tier_price_3.customer_group_id = 0 AND tier_price_3.qty = 1 AND tier_price_3.website_id = 0', [] )->joinLeft( // calculate tier price specified as Website = `Specific Website` and Customer Group = `ALL GROUPS` ['tier_price_4' => $this->getTable('catalog_product_entity_tier_price')], - 'tier_price_4.row_id = e.row_id AND tier_price_4.all_groups = 1 AND tier_price_4.customer_group_id = 0 AND tier_price_4.qty = 1 AND tier_price_4.website_id = pw.website_id', + 'tier_price_4.' . $linkField . ' = e.' . $linkField . ' AND tier_price_4.all_groups = 1 AND tier_price_4.customer_group_id = 0 AND tier_price_4.qty = 1 AND tier_price_4.website_id = pw.website_id', [] ); diff --git a/app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Indexer/Price/Configurable.php b/app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Indexer/Price/Configurable.php index a8fb60a4dcb22..82ad0540be749 100644 --- a/app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Indexer/Price/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Indexer/Price/Configurable.php @@ -88,7 +88,7 @@ protected function _applyConfigurableOption($entityIds = null) $this->_prepareConfigurableOptionPriceTable(); $select = $connection->select()->from( - ['i' => $this->getIdxTable()], + ['i' => $this->getIndexTableForCompositeProducts()], [] )->join( ['l' => $this->getTable('catalog_product_super_link')], diff --git a/app/code/Magento/GroupedProduct/Model/ResourceModel/Product/Indexer/Price/Grouped.php b/app/code/Magento/GroupedProduct/Model/ResourceModel/Product/Indexer/Price/Grouped.php index cbbb58d3c24c8..27a394b7b035f 100644 --- a/app/code/Magento/GroupedProduct/Model/ResourceModel/Product/Indexer/Price/Grouped.php +++ b/app/code/Magento/GroupedProduct/Model/ResourceModel/Product/Indexer/Price/Grouped.php @@ -103,7 +103,7 @@ protected function _prepareGroupedProductPriceDataSelect($entityIds = null) 'le.entity_id = l.linked_product_id', [] )->joinLeft( - ['i' => $table], + ['i' => $this->getIndexTableForCompositeProducts()], 'i.entity_id = l.linked_product_id AND i.website_id = cw.website_id' . ' AND i.customer_group_id = cg.customer_group_id', [ From 15489f9e4e27ad7d715aecd1c00cdfacb16a872d Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov <slopukhov@magento.com> Date: Fri, 8 Jun 2018 16:21:05 +0300 Subject: [PATCH 095/206] MAGETWO-91886: Add ability to configure dimensions --- app/code/Magento/Catalog/Setup/UpgradeData.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/Setup/UpgradeData.php b/app/code/Magento/Catalog/Setup/UpgradeData.php index 123daf45de312..703b8f9888e0f 100644 --- a/app/code/Magento/Catalog/Setup/UpgradeData.php +++ b/app/code/Magento/Catalog/Setup/UpgradeData.php @@ -497,7 +497,7 @@ private function savePriceIndexerDimensionsMode(ModuleDataSetupInterface $setup) 'scope' => 'default', 'scope_id' => 0, 'path' => \Magento\Catalog\Model\Indexer\Product\Price\ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE, - 'value' => 'none' + 'value' => \Magento\Catalog\Model\Indexer\Product\Price\ModeSwitcher::INPUT_KEY_NONE ] ); } From ef2f317eb401ebcdd365d456d21c28b5edf73bd9 Mon Sep 17 00:00:00 2001 From: olysenko <olysenko@magento.com> Date: Fri, 8 Jun 2018 18:44:56 +0300 Subject: [PATCH 096/206] MAGETWO-88217: Guest users unable to sign up to newsletters between stores --- .../Controller/Subscriber/NewAction.php | 2 ++ .../Magento/Newsletter/Model/Subscriber.php | 32 +++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Newsletter/Controller/Subscriber/NewAction.php b/app/code/Magento/Newsletter/Controller/Subscriber/NewAction.php index 13ab40665e591..5d4590dd3f578 100644 --- a/app/code/Magento/Newsletter/Controller/Subscriber/NewAction.php +++ b/app/code/Magento/Newsletter/Controller/Subscriber/NewAction.php @@ -125,8 +125,10 @@ public function execute() $this->validateEmailAvailable($email); $subscriber = $this->_subscriberFactory->create()->loadByEmail($email); + $storeId = $this->_storeManager->getStore()->getId(); if ($subscriber->getId() && $subscriber->getSubscriberStatus() == \Magento\Newsletter\Model\Subscriber::STATUS_SUBSCRIBED + && $subscriber->getStoreId() === $storeId ) { throw new \Magento\Framework\Exception\LocalizedException( __('This email address is already subscribed.') diff --git a/app/code/Magento/Newsletter/Model/Subscriber.php b/app/code/Magento/Newsletter/Model/Subscriber.php index 8f29798472f19..7e663c1e2e2f2 100644 --- a/app/code/Magento/Newsletter/Model/Subscriber.php +++ b/app/code/Magento/Newsletter/Model/Subscriber.php @@ -11,6 +11,8 @@ use Magento\Framework\Exception\MailException; use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\Stdlib\DateTime\DateTime; +use Magento\Customer\Api\Data\CustomerInterfaceFactory; +use Magento\Framework\Api\DataObjectHelper; /** * Subscriber model @@ -129,6 +131,16 @@ class Subscriber extends \Magento\Framework\Model\AbstractModel */ protected $inlineTranslation; + /** + * @var CustomerInterfaceFactory + */ + private $customerFactory; + + /** + * @var DataObjectHelper + */ + private $dataObjectHelper; + /** * Initialize dependencies. * @@ -146,6 +158,8 @@ class Subscriber extends \Magento\Framework\Model\AbstractModel * @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection * @param array $data * @param DateTime|null $dateTime + * @param CustomerInterfaceFactory|null $customerFactory + * @param DataObjectHelper|null $dataObjectHelper * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -162,7 +176,9 @@ public function __construct( \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [], - DateTime $dateTime = null + DateTime $dateTime = null, + CustomerInterfaceFactory $customerFactory = null, + DataObjectHelper $dataObjectHelper = null ) { $this->_newsletterData = $newsletterData; $this->_scopeConfig = $scopeConfig; @@ -173,6 +189,8 @@ public function __construct( $this->customerAccountManagement = $customerAccountManagement; $this->inlineTranslation = $inlineTranslation; $this->dateTime = $dateTime ?: ObjectManager::getInstance()->get(DateTime::class); + $this->customerFactory = $customerFactory ?: ObjectManager::getInstance()->get(CustomerInterfaceFactory::class); + $this->dataObjectHelper = $dataObjectHelper ?: ObjectManager::getInstance()->get(DataObjectHelper::class); parent::__construct($context, $registry, $resource, $resourceCollection, $data); } @@ -405,7 +423,17 @@ public function randomSequence($length = 32) */ public function subscribe($email) { - $this->loadByEmail($email); + $storeId = $this->_storeManager->getStore()->getId(); + $customerData = ['store_id' => $storeId, 'email'=> $email]; + + /** @var \Magento\Customer\Api\Data\CustomerInterface $customer */ + $customer = $this->customerFactory->create(); + $this->dataObjectHelper->populateWithArray( + $customer, + $customerData, + \Magento\Customer\Api\Data\CustomerInterface::class + ); + $this->getResource()->loadByCustomerData($customer); if ($this->getId() && $this->getStatus() == self::STATUS_SUBSCRIBED) { return $this->getStatus(); From 09fa975c26802950462f2296219fc0ceb0b82d1f Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov <slopukhov@magento.com> Date: Mon, 11 Jun 2018 09:24:34 +0300 Subject: [PATCH 097/206] MAGETWO-92395: Fix full reindex for custom product price indexer mode --- .../Indexer/Product/Price/Action/Full.php | 55 ++++++++++++++++--- 1 file changed, 46 insertions(+), 9 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php index 2350b97e94cee..d9d8954404148 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php @@ -13,6 +13,8 @@ use Magento\Framework\Indexer\DimensionalIndexerInterface; use Magento\Catalog\Model\Indexer\Product\Price\ModeSwitcher; use Magento\Framework\Indexer\DimensionProviderInterface; +use Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProvider; +use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; /** * Class Full reindex action @@ -186,11 +188,16 @@ private function prepareTables() // Prepare replica table for indexation. $this->_defaultIndexerResource->getConnection()->truncateTable($this->getReplicaTable()); - // TODO: truncate by dimensions -// $this->dimensionTableMaintainer->getConnection()->truncateTable( -// $this->dimensionTableMaintainer->getMainReplicaTable($dimensions) -// ); + //Truncate replica tables by dimensions + $currentMode = $this->configReader + ->getValue(ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE) ?: ModeSwitcher::INPUT_KEY_NONE; + /** @var DimensionProviderInterface $dimensionsProviders */ + $dimensionsProviders = $this->dimensionCollectionFactory->createByMode($currentMode); + foreach ($dimensionsProviders as $dimension) { + $dimensionTable = $this->dimensionTableMaintainer->getMainReplicaTable($dimension); + $this->_defaultIndexerResource->getConnection()->truncateTable($dimensionTable); + } } private function switchTables() @@ -202,16 +209,46 @@ private function switchTables() $dimensionsProviders = $this->dimensionCollectionFactory->createByMode($currentMode); // Switch dimension tables - $dimensionTables = []; + $mainTablesByDimension = []; - foreach ($dimensionsProviders as $dimension) { - $dimensionTables[] = $this->dimensionTableMaintainer->getMainTable($dimension); + //Get data from indexers with old realisation (old replica table) + $select = $this->dimensionTableMaintainer->getConnection()->select()->from( + $this->dimensionTableMaintainer->getMainReplicaTable([]) + ); + + foreach ($dimensionsProviders as $dimensions) { + $mainTablesByDimension[] = $this->dimensionTableMaintainer->getMainTable($dimensions); + + //Move data from indexers with old realisation + if ($currentMode !== ModeSwitcher::INPUT_KEY_NONE) { + $replicaTablesByDimension = $this->dimensionTableMaintainer->getMainReplicaTable($dimensions); + + foreach ($dimensions as $dimension) { + if ($dimension->getName() === WebsiteDataProvider::DIMENSION_NAME) { + $select->where('website_id = ?', $dimension->getValue()); + } + if ($dimension->getName() === CustomerGroupDataProvider::DIMENSION_NAME) { + $select->where('customer_group_id = ?', $dimension->getValue()); + } + } + $this->dimensionTableMaintainer->getConnection()->query( + $this->dimensionTableMaintainer->getConnection()->insertFromSelect( + $select, + $replicaTablesByDimension + ) + ); + } } - if (count($dimensionTables) > 0) { + //Clean data from indexers with old realisation (old replica table) + $this->_defaultIndexerResource->getConnection()->truncateTable( + $this->dimensionTableMaintainer->getMainReplicaTable([]) + ); + + if (count($mainTablesByDimension) > 0) { $this->activeTableSwitcher->switchTable( $this->_defaultIndexerResource->getConnection(), - $dimensionTables + $mainTablesByDimension ); } } From 0c90fc1500e7581a21e5022688dcbff0b7ff2cdb Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi <alugovyi@magento.com> Date: Fri, 8 Jun 2018 20:20:11 +0300 Subject: [PATCH 098/206] MAGETWO-64467: [Indexer optimizations] Tables sharding / segmentation for price indexer --- .../Catalog/Model/Indexer/Category/Product/TableMaintainer.php | 2 +- .../Catalog/Model/Indexer/Product/Price/TableMaintainer.php | 2 +- .../Adapter/Mysql/Plugin/Aggregation/Category/DataProvider.php | 2 +- .../Model/Search/FilterMapper/ExclusionStrategy.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Product/TableMaintainer.php b/app/code/Magento/Catalog/Model/Indexer/Category/Product/TableMaintainer.php index 1278434fcad43..341b84b425fe8 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Category/Product/TableMaintainer.php +++ b/app/code/Magento/Catalog/Model/Indexer/Category/Product/TableMaintainer.php @@ -11,7 +11,7 @@ use Magento\Framework\Search\Request\Dimension; use Magento\Framework\DB\Adapter\AdapterInterface; use Magento\Catalog\Model\Indexer\Category\Product\AbstractAction; -use Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver as TableResolver; +use Magento\Framework\Search\Request\IndexScopeResolverInterface as TableResolver; /** * Class encapsulate logic of work with tables per store in Category Product indexer diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php index dfbce67e7f269..55214e07c79e3 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php @@ -10,7 +10,7 @@ use Magento\Framework\App\ResourceConnection; use Magento\Framework\Search\Request\Dimension; use Magento\Framework\DB\Adapter\AdapterInterface; -use Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver as TableResolver; +use Magento\Framework\Search\Request\IndexScopeResolverInterface as TableResolver; /** * Class encapsulate logic of work with tables per store in Product Price indexer diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Plugin/Aggregation/Category/DataProvider.php b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Plugin/Aggregation/Category/DataProvider.php index 182ecf873d77a..94432bbfe4a71 100644 --- a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Plugin/Aggregation/Category/DataProvider.php +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Plugin/Aggregation/Category/DataProvider.php @@ -13,7 +13,7 @@ use Magento\Framework\Search\Request\BucketInterface; use Magento\Framework\Search\Request\Dimension; use Magento\Framework\App\ObjectManager; -use Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver as TableResolver; +use Magento\Framework\Search\Request\IndexScopeResolverInterface as TableResolver; use Magento\Catalog\Model\Indexer\Category\Product\AbstractAction; /** diff --git a/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/ExclusionStrategy.php b/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/ExclusionStrategy.php index f7edaa45ed29b..c3ef6290f62a0 100644 --- a/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/ExclusionStrategy.php +++ b/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/ExclusionStrategy.php @@ -11,7 +11,7 @@ use Magento\Framework\App\Http\Context; use Magento\Framework\App\ObjectManager; use Magento\Framework\Indexer\DimensionFactory; -use Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver as TableResolver; +use Magento\Framework\Search\Request\IndexScopeResolverInterface as TableResolver; use Magento\Framework\Search\Request\Dimension; use Magento\Catalog\Model\Indexer\Category\Product\AbstractAction; use Magento\Customer\Model\Context as CustomerContext; From 4ce9f26b03fb185846d687c33e4f18bddfc95478 Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov <slopukhov@magento.com> Date: Mon, 11 Jun 2018 11:12:40 +0300 Subject: [PATCH 099/206] MAGETWO-92395: Fix full reindex for custom product price indexer mode --- .../Indexer/Product/Price/Action/Full.php | 23 ++++--------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php index d9d8954404148..5848ee30590a9 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php @@ -62,16 +62,6 @@ class Full extends \Magento\Catalog\Model\Indexer\Product\Price\AbstractAction */ private $configReader; - /** - * @var \Magento\Framework\App\ResourceConnection - */ - private $resource; - - /** - * @var string - */ - private $connectionName; - /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $config * @param \Magento\Store\Model\StoreManagerInterface $storeManager @@ -86,6 +76,7 @@ class Full extends \Magento\Catalog\Model\Indexer\Product\Price\AbstractAction * @param \Magento\Framework\Indexer\BatchProviderInterface|null $batchProvider * @param \Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher|null $activeTableSwitcher * @param \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer|null $dimensionTableMaintainer + * @param \Magento\Framework\App\Config\ScopeConfigInterface|null $configReader * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -104,9 +95,7 @@ public function __construct( \Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher $activeTableSwitcher = null, \Magento\Catalog\Model\Indexer\Product\Price\DimensionProviderFactory $dimensionCollectionFactory = null, \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer $dimensionTableMaintainer = null, - \Magento\Framework\App\Config\ScopeConfigInterface $configReader = null, - \Magento\Framework\App\ResourceConnection $resource = null, - $connectionName = 'indexer' + \Magento\Framework\App\Config\ScopeConfigInterface $configReader = null ) { parent::__construct( $config, @@ -139,10 +128,6 @@ public function __construct( $this->configReader = $configReader ?: ObjectManager::getInstance()->get( \Magento\Framework\App\Config\ScopeConfigInterface::class ); - $this->resource = $resource ?? ObjectManager::getInstance()->get( - \Magento\Framework\App\ResourceConnection::class - ); - $this->connectionName = $connectionName; } /** @@ -326,7 +311,7 @@ private function reindexBatchWithinDimension(DimensionalIndexerInterface $priceI private function getEntityIdsFromBatch(string $typeId, array $batch) { - $connection = $this->resource->getConnection($this->connectionName); + $connection = $this->_defaultIndexerResource->getConnection(); // Get entity ids from batch $select = $connection ->select() @@ -358,7 +343,7 @@ private function getReplicaTable() private function getBatchesForIndexer(string $typeId) { - $connection = $this->resource->getConnection($this->connectionName); + $connection = $this->_defaultIndexerResource->getConnection(); return $this->batchProvider->getBatches( $connection, $this->getProductMetaData()->getEntityTable(), From 9b60553d94650231b93b2ece15b050b6b0fd6d82 Mon Sep 17 00:00:00 2001 From: Viktor Sevch <svitja@ukr.net> Date: Mon, 11 Jun 2018 11:38:46 +0300 Subject: [PATCH 100/206] MAGETWO-92504: Products sorting in category is reverted to sort by product ID --- .../FunctionalTest/Catalog/Data/CategoryData.xml | 4 ++++ .../FunctionalTest/Catalog/Data/ProductData.xml | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Data/CategoryData.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Data/CategoryData.xml index ce78681b4360b..a8141eb1486f8 100644 --- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Data/CategoryData.xml +++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Data/CategoryData.xml @@ -13,6 +13,10 @@ <data key="name_lwr" unique="suffix">simplecategory</data> <data key="is_active">true</data> </entity> + <entity name="ApiCategory" type="category"> + <data key="name" unique="suffix">ApiCategory</data> + <data key="is_active">true</data> + </entity> <entity name="SimpleSubCategory" type="category"> <data key="name" unique="suffix">SimpleSubCategory</data> <data key="name_lwr" unique="suffix">simplesubcategory</data> diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Data/ProductData.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Data/ProductData.xml index 289e3fbb98fc6..bb7613fe79adc 100644 --- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Data/ProductData.xml +++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Data/ProductData.xml @@ -21,6 +21,19 @@ <requiredEntity type="product_extension_attribute">EavStockItem</requiredEntity> <requiredEntity type="custom_attribute_array">CustomAttributeCategoryIds</requiredEntity> </entity> + <entity name="ApiSimpleProduct" type="product"> + <data key="sku" unique="suffix">api-simple-product</data> + <data key="type_id">simple</data> + <data key="attribute_set_id">4</data> + <data key="visibility">4</data> + <data key="name" unique="suffix">Api Simple Product</data> + <data key="price">123.00</data> + <data key="urlKey" unique="suffix">api-simple-product</data> + <data key="status">1</data> + <data key="quantity">100</data> + <requiredEntity type="product_extension_attribute">EavStockItem</requiredEntity> + <requiredEntity type="custom_attribute_array">CustomAttributeCategoryIds</requiredEntity> + </entity> <entity name="SimpleProduct" type="product"> <data key="sku" unique="suffix">SimpleProduct</data> <data key="type_id">simple</data> From 884acddd08bbc2a62d8f0a410867d7c269d6f3c0 Mon Sep 17 00:00:00 2001 From: Ievgen Sentiabov <isentiabov@magento.com> Date: Mon, 11 Jun 2018 12:35:13 +0300 Subject: [PATCH 101/206] MAGETWO-92509: Can't reorder sales order with configurable product - Added correct link to a parent product entity --- .../OrderedProductAvailabilityChecker.php | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/app/code/Magento/ConfigurableProductSales/Model/Order/Reorder/OrderedProductAvailabilityChecker.php b/app/code/Magento/ConfigurableProductSales/Model/Order/Reorder/OrderedProductAvailabilityChecker.php index 42d7d91fb90e8..8ef1e24125981 100644 --- a/app/code/Magento/ConfigurableProductSales/Model/Order/Reorder/OrderedProductAvailabilityChecker.php +++ b/app/code/Magento/ConfigurableProductSales/Model/Order/Reorder/OrderedProductAvailabilityChecker.php @@ -5,11 +5,12 @@ */ namespace Magento\ConfigurableProductSales\Model\Order\Reorder; -use Magento\Sales\Model\Order\Reorder\OrderedProductAvailabilityCheckerInterface; -use Magento\Sales\Model\Order\Item; use Magento\Catalog\Api\Data\ProductInterface; +use Magento\Catalog\Api\ProductRepositoryInterface; use Magento\Framework\App\ResourceConnection; use Magento\Framework\EntityManager\MetadataPool; +use Magento\Sales\Model\Order\Item; +use Magento\Sales\Model\Order\Reorder\OrderedProductAvailabilityCheckerInterface; use Magento\Store\Model\Store; /** @@ -27,16 +28,24 @@ class OrderedProductAvailabilityChecker implements OrderedProductAvailabilityChe */ private $metadataPool; + /** + * @var ProductRepositoryInterface + */ + private $productRepository; + /** * @param ResourceConnection $resourceConnection * @param MetadataPool $metadataPool + * @param ProductRepositoryInterface $productRepository */ public function __construct( ResourceConnection $resourceConnection, - MetadataPool $metadataPool + MetadataPool $metadataPool, + ProductRepositoryInterface $productRepository ) { $this->resourceConnection = $resourceConnection; $this->metadataPool = $metadataPool; + $this->productRepository = $productRepository; } /** @@ -48,7 +57,9 @@ public function isAvailable(Item $item) $superAttribute = $buyRequest->getData()['super_attribute'] ?? []; $connection = $this->getConnection(); $select = $connection->select(); - $orderItemParentId = $item->getParentItem()->getProductId(); + $linkField = $this->getMetadata()->getLinkField(); + $parentItem = $this->productRepository->getById($item->getParentItem()->getProductId()); + $orderItemParentId = $parentItem->getData($linkField); $select->from( ['cpe' => $this->resourceConnection->getTableName('catalog_product_entity')], ['cpe.entity_id'] @@ -67,7 +78,7 @@ public function isAvailable(Item $item) ['cpid' . $attributeId => $this->resourceConnection->getTableName('catalog_product_entity_int')], sprintf( 'cpe.%1$s = cpid%2$d.%1$s AND cpid%2$d.attribute_id = %2$d AND cpid%2$d.store_id = %3$d', - $this->getMetadata()->getLinkField(), + $linkField, $attributeId, Store::DEFAULT_STORE_ID ), @@ -77,7 +88,7 @@ public function isAvailable(Item $item) ['cpis' . $attributeId => $this->resourceConnection->getTableName('catalog_product_entity_int')], sprintf( 'cpe.%1$s = cpis%2$d.%1$s AND cpis%2$d.attribute_id = %2$d AND cpis%2$d.store_id = %3$d', - $this->getMetadata()->getLinkField(), + $linkField, $attributeId, $item->getStoreId() ), From 89e90b5964da99f229d82f8036800ab2b3ec9a6f Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov <slopukhov@magento.com> Date: Mon, 11 Jun 2018 14:02:29 +0300 Subject: [PATCH 102/206] MAGETWO-92395: Fix full reindex for custom product price indexer mode --- .../Model/Indexer/Product/Price/Action/Full.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php index 5848ee30590a9..59119294b08d9 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php @@ -145,7 +145,6 @@ public function execute($ids = null) /** @var \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\DefaultPrice $indexer */ foreach ($this->getTypeIndexers() as $typeId => $priceIndexer) { - if ($priceIndexer instanceof DimensionalIndexerInterface) { $this->reindexProductTypeWithDimensions($priceIndexer, $typeId); continue; @@ -225,17 +224,17 @@ private function switchTables() } } - //Clean data from indexers with old realisation (old replica table) - $this->_defaultIndexerResource->getConnection()->truncateTable( - $this->dimensionTableMaintainer->getMainReplicaTable([]) - ); - if (count($mainTablesByDimension) > 0) { $this->activeTableSwitcher->switchTable( $this->_defaultIndexerResource->getConnection(), $mainTablesByDimension ); } + + //Clean data from indexers with old realisation (old replica table) + $this->_defaultIndexerResource->getConnection()->truncateTable( + $this->dimensionTableMaintainer->getMainReplicaTable([]) + ); } private function reindexProductType(PriceInterface $priceIndexer, string $typeId) From 3bf3533ff655809a46e85d52720365079d1f5d0f Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov <slopukhov@magento.com> Date: Mon, 11 Jun 2018 14:03:43 +0300 Subject: [PATCH 103/206] MAGETWO-92395: Fix full reindex for custom product price indexer mode --- .../Catalog/Model/Indexer/Product/Price/Action/Full.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php index 59119294b08d9..66bac57fea4eb 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php @@ -230,11 +230,6 @@ private function switchTables() $mainTablesByDimension ); } - - //Clean data from indexers with old realisation (old replica table) - $this->_defaultIndexerResource->getConnection()->truncateTable( - $this->dimensionTableMaintainer->getMainReplicaTable([]) - ); } private function reindexProductType(PriceInterface $priceIndexer, string $typeId) From 6b9b020aeb9d1fc708da49a9643919995f0c6531 Mon Sep 17 00:00:00 2001 From: Michail Slabko <mslabko@magento.com> Date: Mon, 11 Jun 2018 14:43:23 +0300 Subject: [PATCH 104/206] MAGETWO-92394: Implement partial reindex - MAGETWO-64467 [Indexer optimizations] Tables sharding / segmentation for price indexer --- .../Indexer/Product/Price/AbstractAction.php | 114 ++++++++++++++++-- .../Indexer/Price/SimpleProductPrice.php | 10 +- app/code/Magento/Catalog/etc/di.xml | 5 + .../Magento/Catalog/etc/product_types.xml | 2 +- 4 files changed, 116 insertions(+), 15 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php index 4f85b14152444..33adb7af95ffc 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php @@ -6,8 +6,10 @@ namespace Magento\Catalog\Model\Indexer\Product\Price; use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\DefaultPrice; +use Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProvider; use Magento\Framework\App\ObjectManager; use Magento\Framework\Indexer\DimensionalIndexerInterface; +use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; /** * Abstract action reindex class @@ -79,6 +81,21 @@ abstract class AbstractAction */ private $tierPriceIndexResource; + /** + * @var \Magento\Catalog\Model\Indexer\Product\Price\DimensionProviderFactory + */ + private $dimensionCollectionFactory; + + /** + * @var \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer + */ + private $configReader; + + /** + * @var TableMaintainer + */ + private $tableMaintainer; + /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $config * @param \Magento\Store\Model\StoreManagerInterface $storeManager @@ -99,7 +116,10 @@ public function __construct( \Magento\Catalog\Model\Product\Type $catalogProductType, \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\Factory $indexerPriceFactory, DefaultPrice $defaultIndexerResource, - \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\TierPrice $tierPriceIndexResource = null + \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\TierPrice $tierPriceIndexResource = null, + \Magento\Catalog\Model\Indexer\Product\Price\DimensionProviderFactory $dimensionCollectionFactory = null, + \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer $tableMaintainer = null, + \Magento\Framework\App\Config\ScopeConfigInterface $configReader = null ) { $this->_config = $config; $this->_storeManager = $storeManager; @@ -110,9 +130,18 @@ public function __construct( $this->_indexerPriceFactory = $indexerPriceFactory; $this->_defaultIndexerResource = $defaultIndexerResource; $this->_connection = $this->_defaultIndexerResource->getConnection(); - $this->tierPriceIndexResource = $tierPriceIndexResource ?: ObjectManager::getInstance()->get( + $this->tierPriceIndexResource = $tierPriceIndexResource ?? ObjectManager::getInstance()->get( \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\TierPrice::class ); + $this->dimensionCollectionFactory = $dimensionCollectionFactory ?? ObjectManager::getInstance()->get( + \Magento\Catalog\Model\Indexer\Product\Price\DimensionProviderFactory::class + ); + $this->configReader = $configReader ?? ObjectManager::getInstance()->get( + \Magento\Framework\App\Config\ScopeConfigInterface::class + ); + $this->tableMaintainer = $tableMaintainer ?? ObjectManager::getInstance()->get( + \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer::class + ); } /** @@ -130,13 +159,68 @@ abstract public function execute($ids); * @return \Magento\Catalog\Model\Indexer\Product\Price\AbstractAction */ protected function _syncData(array $processIds = []) + { + $currentMode = $this->configReader + ->getValue(ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE) ?: ModeSwitcher::INPUT_KEY_NONE; + $dimensionsProviders = $this->dimensionCollectionFactory->createByMode($currentMode); + + // for backward compatibility split data from old idx table on dimension tables + foreach ($dimensionsProviders as $dimensions) { + $insertSelect = $this->_connection->select()->from( + ['ip_tmp' => $this->_defaultIndexerResource->getIdxTable()] + ); + + // delete invalid rows + $select = $this->_connection->select()->from( + ['index_price' => $this->tableMaintainer->getMainTable($dimensions)], + null + )->joinLeft( + ['ip_tmp' => $this->_defaultIndexerResource->getIdxTable()], + 'index_price.entity_id = ip_tmp.entity_id AND index_price.website_id = ip_tmp.website_id', + [] + )->where( + 'ip_tmp.entity_id IS NULL' + ); + if (!empty($processIds)) { + $select->where('index_price.entity_id IN(?)', $processIds); + } + foreach ($dimensions as $dimension) { + if ($dimension->getName() === WebsiteDataProvider::DIMENSION_NAME) { + $select->where('ip_tmp.website_id = ?', $dimension->getValue()); + $insertSelect->where('ip_tmp.website_id = ?', $dimension->getValue()); + } + if ($dimension->getName() === CustomerGroupDataProvider::DIMENSION_NAME) { + $select->where('ip_tmp.customer_group_id = ?', $dimension->getValue()); + $insertSelect->where('ip_tmp.customer_group_id = ?', $dimension->getValue()); + } + } + + $query = $select->deleteFromSelect('index_price'); + $this->_connection->query($query); + $query = $insertSelect->insertFromSelect($this->tableMaintainer->getMainTable($dimensions)); + $this->_connection->query($query); + + } + return $this; + } + + + /** + * Synchronize data between index storage and original storage + * + * @param array $dimensions + * @param array $processIds + * @return \Magento\Catalog\Model\Indexer\Product\Price\AbstractAction + * @throws \Exception + */ + private function syncDataByDimensions(array $dimensions, array $processIds = []) { // delete invalid rows $select = $this->_connection->select()->from( - ['index_price' => $this->getIndexTargetTable()], + ['index_price' => $this->tableMaintainer->getMainTable($dimensions)], null )->joinLeft( - ['ip_tmp' => $this->_defaultIndexerResource->getIdxTable()], + ['ip_tmp' => $this->tableMaintainer->getMainTmpTable($dimensions)], 'index_price.entity_id = ip_tmp.entity_id AND index_price.website_id = ip_tmp.website_id', [] )->where( @@ -149,8 +233,8 @@ protected function _syncData(array $processIds = []) $this->_connection->query($sql); $this->_insertFromTable( - $this->_defaultIndexerResource->getIdxTable(), - $this->getIndexTargetTable() + $this->tableMaintainer->getMainTmpTable($dimensions), + $this->tableMaintainer->getMainTable($dimensions) ); return $this; } @@ -323,7 +407,6 @@ protected function _emptyTable($table) */ protected function _reindexRows($changedIds = []) { - $this->_emptyTable($this->_defaultIndexerResource->getIdxTable()); $this->_prepareWebsiteDateTable(); $productsTypes = $this->getProductsTypes($changedIds); @@ -331,15 +414,28 @@ protected function _reindexRows($changedIds = []) $changedIds = array_merge($changedIds, ...array_values($parentProductsTypes)); $productsTypes = array_merge_recursive($productsTypes, $parentProductsTypes); + $syncDataForNonDimensionalIndexers = false; foreach ($productsTypes as $productType => $entityIds) { $indexer = $this->_getIndexer($productType); if ($indexer instanceof DimensionalIndexerInterface) { - $indexer->executeByDimension([], \SplFixedArray::fromArray($entityIds, false)); + $currentMode = $this->configReader + ->getValue(ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE) ?: ModeSwitcher::INPUT_KEY_NONE; + $dimensionsProviders = $this->dimensionCollectionFactory->createByMode($currentMode); + foreach ($dimensionsProviders as $dimensions) { + $this->tableMaintainer->createMainTmpTable($dimensions); + $this->_emptyTable($this->tableMaintainer->getMainTmpTable($dimensions)); + $indexer->executeByDimension($dimensions, \SplFixedArray::fromArray($entityIds, false)); + $this->syncDataByDimensions($dimensions, $entityIds); + } } else { + $syncDataForNonDimensionalIndexers = true; + $this->_emptyTable($this->_defaultIndexerResource->getIdxTable()); $indexer->reindexEntity($entityIds); } - $this->_syncData($entityIds); + if ($syncDataForNonDimensionalIndexers) { + $this->_syncData($entityIds); + } } return $changedIds; diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/SimpleProductPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/SimpleProductPrice.php index a638bf1705f98..03149348aa0c7 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/SimpleProductPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/SimpleProductPrice.php @@ -33,7 +33,7 @@ class SimpleProductPrice implements DimensionalIndexerInterface /** * @var string */ - private $typeId; + private $productType; /** * @var PriceModifierInterface[] @@ -44,21 +44,21 @@ class SimpleProductPrice implements DimensionalIndexerInterface * @param BaseFinalPrice $baseFinalPrice * @param IndexTableStructureFactory $indexTableStructureFactory * @param TableMaintainer $tableMaintainer - * @param string $typeId + * @param string $productType * @param array $priceModifiers */ public function __construct( BaseFinalPrice $baseFinalPrice, IndexTableStructureFactory $indexTableStructureFactory, TableMaintainer $tableMaintainer, - $typeId = \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE, + $productType = \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE, array $priceModifiers = [] ) { $this->baseFinalPrice = $baseFinalPrice; $this->indexTableStructureFactory = $indexTableStructureFactory; $this->tableMaintainer = $tableMaintainer; - $this->typeId = $typeId; + $this->productType = $productType; $this->priceModifiers = $priceModifiers; } @@ -90,7 +90,7 @@ public function executeByDimension(array $dimensions, \Traversable $entityIds = 'maxPriceField' => 'max_price', 'tierPriceField' => 'tier_price', ]); - $select = $this->baseFinalPrice->getQuery($dimensions, $this->typeId, iterator_to_array($entityIds)); + $select = $this->baseFinalPrice->getQuery($dimensions, $this->productType, iterator_to_array($entityIds)); $query = $select->insertFromSelect($temporaryPriceTable->getTableName(), [], false); $this->tableMaintainer->getConnection()->query($query); diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml index 95b4bef002072..fd14167dea117 100644 --- a/app/code/Magento/Catalog/etc/di.xml +++ b/app/code/Magento/Catalog/etc/di.xml @@ -1133,4 +1133,9 @@ </argument> </arguments> </type> + <virtualType name="Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\VirtualProductPrice" type="Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\SimpleProductPrice"> + <arguments> + <argument name="productType" xsi:type="string">virtual</argument> + </arguments> + </virtualType> </config> diff --git a/app/code/Magento/Catalog/etc/product_types.xml b/app/code/Magento/Catalog/etc/product_types.xml index a4747f93db047..fdcb67ae484d2 100644 --- a/app/code/Magento/Catalog/etc/product_types.xml +++ b/app/code/Magento/Catalog/etc/product_types.xml @@ -13,7 +13,7 @@ </customAttributes> </type> <type name="virtual" label="Virtual Product" modelInstance="Magento\Catalog\Model\Product\Type\Virtual" indexPriority="20" sortOrder="40"> - <!--<indexerModel instance="Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\SimpleProductPrice" />--> + <indexerModel instance="Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\VirtualProductPrice" /> <customAttributes> <attribute name="is_real_product" value="false"/> <attribute name="refundable" value="false"/> From a15ed8ac77a6497afd133fbfd0f29c5c89449098 Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov <slopukhov@magento.com> Date: Mon, 11 Jun 2018 14:53:34 +0300 Subject: [PATCH 105/206] MAGETWO-92395: Fix full reindex for custom product price indexer mode --- .../Indexer/Product/Price/Action/Full.php | 328 +++++++++++++----- 1 file changed, 233 insertions(+), 95 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php index 66bac57fea4eb..bed52bc4cfd66 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php @@ -18,6 +18,7 @@ /** * Class Full reindex action + * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Full extends \Magento\Catalog\Model\Indexer\Product\Price\AbstractAction @@ -135,130 +136,217 @@ public function __construct( * * @param array|int|null $ids * @return void - * @throws \Magento\Framework\Exception\LocalizedException + * @throws \Exception * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function execute($ids = null) { try { + //Prepare indexer tables before full reindex $this->prepareTables(); /** @var \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\DefaultPrice $indexer */ foreach ($this->getTypeIndexers() as $typeId => $priceIndexer) { if ($priceIndexer instanceof DimensionalIndexerInterface) { + //New price reindex mechanism $this->reindexProductTypeWithDimensions($priceIndexer, $typeId); continue; } //TODO: fix dirty hac $priceIndexer->setIsPartial(false); - $priceIndexer->getTableStrategy()->setUseIdxTable(false); + + //Old price reindex mechanism $this->reindexProductType($priceIndexer, $typeId); } + //Final replacement of tables from replica to main $this->switchTables(); } catch (\Exception $e) { throw new LocalizedException(__($e->getMessage()), $e); } } + /** + * Prepare indexer tables before full reindex + * + * @return void + * @throws \Exception + */ private function prepareTables() { $this->_defaultIndexerResource->getTableStrategy()->setUseIdxTable(false); $this->_prepareWebsiteDateTable(); - // Prepare replica table for indexation. - $this->_defaultIndexerResource->getConnection()->truncateTable($this->getReplicaTable()); + $this->truncateReplicaTable(); + + $this->truncateReplicaTablesByDimensions(); + } + + /** + * Get current price indexer mode + * + * @return string + */ + private function getCurrentMode() + { + return $this->configReader->getValue( + ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE + ) ?: ModeSwitcher::INPUT_KEY_NONE; + } - //Truncate replica tables by dimensions - $currentMode = $this->configReader - ->getValue(ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE) ?: ModeSwitcher::INPUT_KEY_NONE; + /** + * Truncate main replica table + * + * @return void + * @throws \Exception + */ + private function truncateReplicaTable() + { + $this->_defaultIndexerResource->getConnection()->truncateTable($this->getReplicaTable()); + } + /** + * Truncate replica tables by dimensions + * + * @return void + * @throws \Exception + */ + private function truncateReplicaTablesByDimensions() + { /** @var DimensionProviderInterface $dimensionsProviders */ - $dimensionsProviders = $this->dimensionCollectionFactory->createByMode($currentMode); + $dimensionsProviders = $this->dimensionCollectionFactory->createByMode($this->getCurrentMode()); foreach ($dimensionsProviders as $dimension) { $dimensionTable = $this->dimensionTableMaintainer->getMainReplicaTable($dimension); $this->_defaultIndexerResource->getConnection()->truncateTable($dimensionTable); } } - private function switchTables() + /** + * Reindex new 'Dimensional' price indexer by product type + * + * @param DimensionalIndexerInterface $priceIndexer + * @param string $typeId + * + * @return void + * @throws \Exception + */ + private function reindexProductTypeWithDimensions(DimensionalIndexerInterface $priceIndexer, string $typeId) { - $currentMode = $this->configReader - ->getValue(ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE) ?: ModeSwitcher::INPUT_KEY_NONE; - /** @var DimensionProviderInterface $dimensionsProviders */ - $dimensionsProviders = $this->dimensionCollectionFactory->createByMode($currentMode); - - // Switch dimension tables - $mainTablesByDimension = []; - - //Get data from indexers with old realisation (old replica table) - $select = $this->dimensionTableMaintainer->getConnection()->select()->from( - $this->dimensionTableMaintainer->getMainReplicaTable([]) - ); + $dimensionsProviders = $this->dimensionCollectionFactory->createByMode($this->getCurrentMode()); foreach ($dimensionsProviders as $dimensions) { - $mainTablesByDimension[] = $this->dimensionTableMaintainer->getMainTable($dimensions); - - //Move data from indexers with old realisation - if ($currentMode !== ModeSwitcher::INPUT_KEY_NONE) { - $replicaTablesByDimension = $this->dimensionTableMaintainer->getMainReplicaTable($dimensions); - - foreach ($dimensions as $dimension) { - if ($dimension->getName() === WebsiteDataProvider::DIMENSION_NAME) { - $select->where('website_id = ?', $dimension->getValue()); - } - if ($dimension->getName() === CustomerGroupDataProvider::DIMENSION_NAME) { - $select->where('customer_group_id = ?', $dimension->getValue()); - } - } - $this->dimensionTableMaintainer->getConnection()->query( - $this->dimensionTableMaintainer->getConnection()->insertFromSelect( - $select, - $replicaTablesByDimension - ) - ); - } - } - - if (count($mainTablesByDimension) > 0) { - $this->activeTableSwitcher->switchTable( - $this->_defaultIndexerResource->getConnection(), - $mainTablesByDimension - ); + $this->reindexByBatches($priceIndexer, $dimensions, $typeId); } } - private function reindexProductType(PriceInterface $priceIndexer, string $typeId) + /** + * Reindex new 'Dimensional' price indexer by batches + * + * @param DimensionalIndexerInterface $priceIndexer + * @param array $dimensions + * @param string $typeId + * + * @return void + * @throws \Exception + */ + private function reindexByBatches(DimensionalIndexerInterface $priceIndexer, array $dimensions, string $typeId) { foreach ($this->getBatchesForIndexer($typeId) as $batch) { - $this->reindexBatch($priceIndexer, $batch, $typeId); + $this->reindexByBatchWithDimensions($priceIndexer, $batch, $dimensions, $typeId); } } - private function reindexProductTypeWithDimensions(DimensionalIndexerInterface $priceIndexer, string $typeId) + /** + * Get batches for new 'Dimensional' price indexer + * + * @param string $typeId + * + * @return \Generator + * @throws \Exception + */ + private function getBatchesForIndexer(string $typeId) { - $currentMode = $this->configReader - ->getValue(ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE) ?: ModeSwitcher::INPUT_KEY_NONE; + $connection = $this->_defaultIndexerResource->getConnection(); + return $this->batchProvider->getBatches( + $connection, + $this->getProductMetaData()->getEntityTable(), + $this->getProductMetaData()->getIdentifierField(), + $this->batchSizeCalculator->estimateBatchSize( + $connection, + $typeId + ) + ); + } - /** @var DimensionProviderInterface $dimensionsProviders */ - $dimensionsProviders = $this->dimensionCollectionFactory->createByMode($currentMode); + /** + * Reindex by batch for new 'Dimensional' price indexer + * + * @param DimensionalIndexerInterface $priceIndexer + * @param array $batch + * @param array $dimensions + * @param string $typeId + * + * @return void + * @throws \Exception + */ + private function reindexByBatchWithDimensions( + DimensionalIndexerInterface $priceIndexer, + array $batch, + array $dimensions, + string $typeId + ) { + $entityIds = $this->getEntityIdsFromBatch($typeId, $batch); - foreach ($dimensionsProviders as $dimensions) { - $this->reindexDimensions($priceIndexer, $dimensions, $typeId); + if (!empty($entityIds)) { + $this->dimensionTableMaintainer->createMainTmpTable($dimensions); + $temporaryTable = $this->dimensionTableMaintainer->getMainTmpTable($dimensions); + $this->_emptyTable($temporaryTable); + + // TODO: will be handled in separate task + // if ($priceIndexer->getIsComposite()) { + // $this->_copyRelationIndexData($entityIds); + // } + + $priceIndexer->executeByDimension($dimensions, \SplFixedArray::fromArray($entityIds, false)); + + // Sync data from temp table to index table + $this->_insertFromTable( + $temporaryTable, + $this->dimensionTableMaintainer->getMainReplicaTable($dimensions) + ); } } - private function reindexDimensions(DimensionalIndexerInterface $priceIndexer, array $dimensions, string $typeId) + /** + * Reindex old price indexer by product type + * + * @param PriceInterface $priceIndexer + * @param string $typeId + * + * @return void + * @throws \Exception + */ + private function reindexProductType(PriceInterface $priceIndexer, string $typeId) { foreach ($this->getBatchesForIndexer($typeId) as $batch) { - $this->reindexBatchWithinDimension($priceIndexer, $batch, $dimensions, $typeId); + $this->reindexBatch($priceIndexer, $batch, $typeId); } } + /** + * Reindex by batch for old price indexer + * + * @param PriceInterface $priceIndexer + * @param array $batch + * @param string $typeId + * + * @return void + * @throws \Exception + */ private function reindexBatch(PriceInterface $priceIndexer, array $batch, string $typeId) { $entityIds = $this->getEntityIdsFromBatch($typeId, $batch); @@ -275,37 +363,23 @@ private function reindexBatch(PriceInterface $priceIndexer, array $batch, string $this->_insertFromTable($idxTableName, $this->getReplicaTable()); // Drop temporary index table - $priceIndexer->getConnection()->dropTable($idxTableName); - } - } - - private function reindexBatchWithinDimension(DimensionalIndexerInterface $priceIndexer, array $batch, array $dimensions, string $typeId) - { - $entityIds = $this->getEntityIdsFromBatch($typeId, $batch); - - if (!empty($entityIds)) { - $this->dimensionTableMaintainer->createMainTmpTable($dimensions); - $temporaryTable = $this->dimensionTableMaintainer->getMainTmpTable($dimensions); - $this->_emptyTable($temporaryTable); - - // TODO: will be handled in separate task - // if ($priceIndexer->getIsComposite()) { - // $this->_copyRelationIndexData($entityIds); - // } - - $priceIndexer->executeByDimension($dimensions, \SplFixedArray::fromArray($entityIds, false)); - - // Sync data from temp table to index table - $this->_insertFromTable( - $temporaryTable, - $this->dimensionTableMaintainer->getMainReplicaTable($dimensions) - ); + $this->_defaultIndexerResource->getConnection()->dropTable($idxTableName); } } + /** + * Get Entity Ids from batch + * + * @param string $typeId + * @param array $batch + * + * @return array + * @throws \Exception + */ private function getEntityIdsFromBatch(string $typeId, array $batch) { $connection = $this->_defaultIndexerResource->getConnection(); + // Get entity ids from batch $select = $connection ->select() @@ -319,6 +393,12 @@ private function getEntityIdsFromBatch(string $typeId, array $batch) return $this->batchProvider->getBatchIds($connection, $select, $batch); } + /** + * Get product meta data + * + * @return EntityMetadataInterface + * @throws \Exception + */ private function getProductMetaData() { if ($this->productMetaDataCached === null) { @@ -328,6 +408,12 @@ private function getProductMetaData() return $this->productMetaDataCached; } + /** + * Get replica table + * + * @return string + * @throws \Exception + */ private function getReplicaTable() { return $this->activeTableSwitcher->getAdditionalTableName( @@ -335,21 +421,73 @@ private function getReplicaTable() ); } - private function getBatchesForIndexer(string $typeId) + /** + * Replacement of tables from replica to main + * + * @return void + */ + private function switchTables() { - $connection = $this->_defaultIndexerResource->getConnection(); - return $this->batchProvider->getBatches( - $connection, - $this->getProductMetaData()->getEntityTable(), - $this->getProductMetaData()->getIdentifierField(), - $this->batchSizeCalculator->estimateBatchSize( - $connection, - $typeId - ) + /** @var DimensionProviderInterface $dimensionsProviders */ + $dimensionsProviders = $this->dimensionCollectionFactory->createByMode($this->getCurrentMode()); + + // Switch dimension tables + $mainTablesByDimension = []; + + foreach ($dimensionsProviders as $dimensions) { + $mainTablesByDimension[] = $this->dimensionTableMaintainer->getMainTable($dimensions); + + //Move data from indexers with old realisation + $this->moveDataFromReplicaTableToReplicaTables($dimensions); + } + + if (count($mainTablesByDimension) > 0) { + $this->activeTableSwitcher->switchTable( + $this->_defaultIndexerResource->getConnection(), + $mainTablesByDimension + ); + } + } + + /** + * Move data from replica table to replica tables (by dimensions) + * Data from old price indexer mechanism moves to data with new indexer mechanism by dimensions + * + * @param array $dimensions + * + * @return void + */ + private function moveDataFromReplicaTableToReplicaTables(array $dimensions) + { + //TODO: need to update logic for run this move only when replica table is not empty + $select = $this->dimensionTableMaintainer->getConnection()->select()->from( + $this->dimensionTableMaintainer->getMainReplicaTable([]) ); + + if ($this->getCurrentMode() !== ModeSwitcher::INPUT_KEY_NONE) { + $replicaTablesByDimension = $this->dimensionTableMaintainer->getMainReplicaTable($dimensions); + + foreach ($dimensions as $dimension) { + if ($dimension->getName() === WebsiteDataProvider::DIMENSION_NAME) { + $select->where('website_id = ?', $dimension->getValue()); + } + if ($dimension->getName() === CustomerGroupDataProvider::DIMENSION_NAME) { + $select->where('customer_group_id = ?', $dimension->getValue()); + } + } + + $this->dimensionTableMaintainer->getConnection()->query( + $this->dimensionTableMaintainer->getConnection()->insertFromSelect( + $select, + $replicaTablesByDimension + ) + ); + } } /** + * @deprecated + * * @inheritdoc */ protected function getIndexTargetTable() From 808cfd7c7e399a1fc9a04ff0f223f2301f96c614 Mon Sep 17 00:00:00 2001 From: DianaRusin <rusind95@gmail.com> Date: Mon, 11 Jun 2018 17:08:12 +0300 Subject: [PATCH 106/206] MAGETWO-88102: [Magento Cloud] Catalog_category_product_index table doesn't update after deleting category --- .../Catalog/Model/ResourceModel/Category.php | 26 ++++++- .../Unit/Model/ResourceModel/CategoryTest.php | 12 ++- .../Fulltext/Model/Plugin/Category.php | 45 ++++++++++++ .../CatalogSearch/etc/adminhtml/di.xml | 8 ++ .../CatalogSearch/etc/webapi_rest/di.xml | 12 +++ .../CatalogSearch/etc/webapi_soap/di.xml | 12 +++ .../Model/Indexer/Category/ProductTest.php | 30 ++++++++ .../Fulltext/Model/Plugin/CategoryTest.php | 73 +++++++++++++++++++ 8 files changed, 216 insertions(+), 2 deletions(-) create mode 100644 app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Model/Plugin/Category.php create mode 100644 app/code/Magento/CatalogSearch/etc/webapi_rest/di.xml create mode 100644 app/code/Magento/CatalogSearch/etc/webapi_soap/di.xml create mode 100644 dev/tests/integration/testsuite/Magento/CatalogSearch/Model/Indexer/Fulltext/Model/Plugin/CategoryTest.php diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Category.php b/app/code/Magento/Catalog/Model/ResourceModel/Category.php index 6c9867359d40b..1f3b2642953c8 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Category.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Category.php @@ -11,6 +11,8 @@ */ namespace Magento\Catalog\Model\ResourceModel; +use Magento\Catalog\Model\Indexer\Category\Product\Processor; +use Magento\Framework\DataObject; use Magento\Framework\EntityManager\EntityManager; /** @@ -82,6 +84,11 @@ class Category extends AbstractResource */ protected $aggregateCount; + /** + * @var Processor + */ + private $indexerProcessor; + /** * Category constructor. * @param \Magento\Eav\Model\Entity\Context $context @@ -92,6 +99,7 @@ class Category extends AbstractResource * @param Category\CollectionFactory $categoryCollectionFactory * @param array $data * @param \Magento\Framework\Serialize\Serializer\Json|null $serializer + * @param Processor|null $indexerProcessor */ public function __construct( \Magento\Eav\Model\Entity\Context $context, @@ -101,7 +109,8 @@ public function __construct( \Magento\Catalog\Model\ResourceModel\Category\TreeFactory $categoryTreeFactory, \Magento\Catalog\Model\ResourceModel\Category\CollectionFactory $categoryCollectionFactory, $data = [], - \Magento\Framework\Serialize\Serializer\Json $serializer = null + \Magento\Framework\Serialize\Serializer\Json $serializer = null, + Processor $indexerProcessor = null ) { parent::__construct( $context, @@ -115,6 +124,8 @@ public function __construct( $this->connectionName = 'catalog'; $this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance() ->get(\Magento\Framework\Serialize\Serializer\Json::class); + $this->indexerProcessor = $indexerProcessor ?: \Magento\Framework\App\ObjectManager::getInstance() + ->get(Processor::class); } /** @@ -197,6 +208,19 @@ protected function _beforeDelete(\Magento\Framework\DataObject $object) $this->deleteChildren($object); } + /** + * Mark Category indexer as invalid to be picked up by cron. + * + * @param DataObject $object + * @return $this + */ + protected function _afterDelete(DataObject $object): Category + { + $this->indexerProcessor->markIndexerAsInvalid(); + + return parent::_afterDelete($object); + } + /** * Delete children categories of specific category * diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/CategoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/CategoryTest.php index 4812751792f18..2ac0b65c22e03 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/CategoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/CategoryTest.php @@ -7,6 +7,7 @@ namespace Magento\Catalog\Test\Unit\Model\ResourceModel; use Magento\Catalog\Model\Factory; +use Magento\Catalog\Model\Indexer\Category\Product\Processor; use Magento\Catalog\Model\ResourceModel\Category; use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory; use Magento\Eav\Model\Config; @@ -91,6 +92,11 @@ class CategoryTest extends \PHPUnit\Framework\TestCase */ private $serializerMock; + /** + * @var Processor|\PHPUnit_Framework_MockObject_MockObject + */ + private $indexerProcessorMock; + /** * {@inheritDoc} */ @@ -121,6 +127,9 @@ protected function setUp() $this->collectionFactoryMock = $this->getMockBuilder(CollectionFactory::class) ->disableOriginalConstructor() ->getMock(); + $this->indexerProcessorMock = $this->getMockBuilder(Processor::class) + ->disableOriginalConstructor() + ->getMock(); $this->serializerMock = $this->getMockBuilder(Json::class)->getMock(); @@ -132,7 +141,8 @@ protected function setUp() $this->treeFactoryMock, $this->collectionFactoryMock, [], - $this->serializerMock + $this->serializerMock, + $this->indexerProcessorMock ); } diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Model/Plugin/Category.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Model/Plugin/Category.php new file mode 100644 index 0000000000000..fe68c6321e472 --- /dev/null +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Model/Plugin/Category.php @@ -0,0 +1,45 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\CatalogSearch\Model\Indexer\Fulltext\Model\Plugin; + +use Magento\Catalog\Model\ResourceModel\Category as Resource; +use Magento\CatalogSearch\Model\Indexer\Fulltext\Processor; + +/** + * Perform indexer invalidation after a category delete. + */ +class Category +{ + /** + * @var Processor + */ + private $fulltextIndexerProcessor; + + /** + * @param Processor $fulltextIndexerProcessor + */ + public function __construct(Processor $fulltextIndexerProcessor) + { + $this->fulltextIndexerProcessor = $fulltextIndexerProcessor; + } + + /** + * Mark fulltext indexer as invalid post-deletion of category. + * + * @param Resource $subjectCategory + * @param Resource $resultCategory + * @return Resource + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function afterDelete(Resource $subjectCategory, Resource $resultCategory): Resource + { + $this->fulltextIndexerProcessor->markIndexerAsInvalid(); + + return $resultCategory; + } +} diff --git a/app/code/Magento/CatalogSearch/etc/adminhtml/di.xml b/app/code/Magento/CatalogSearch/etc/adminhtml/di.xml index 7877ff04b24fd..2d41d17889e49 100644 --- a/app/code/Magento/CatalogSearch/etc/adminhtml/di.xml +++ b/app/code/Magento/CatalogSearch/etc/adminhtml/di.xml @@ -26,4 +26,12 @@ </argument> </arguments> </type> + <type name="Magento\Catalog\Model\ProductLink\Search"> + <arguments> + <argument name="filter" xsi:type="object">Magento\CatalogSearch\Ui\DataProvider\Product\AddFulltextFilterToCollection</argument> + </arguments> + </type> + <type name="Magento\Catalog\Model\ResourceModel\Category"> + <plugin name="fulltext_search_indexer" type="Magento\CatalogSearch\Model\Indexer\Fulltext\Model\Plugin\Category"/> + </type> </config> diff --git a/app/code/Magento/CatalogSearch/etc/webapi_rest/di.xml b/app/code/Magento/CatalogSearch/etc/webapi_rest/di.xml new file mode 100644 index 0000000000000..c7293783dc609 --- /dev/null +++ b/app/code/Magento/CatalogSearch/etc/webapi_rest/di.xml @@ -0,0 +1,12 @@ +<?xml version="1.0"?> +<!-- +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> + <type name="Magento\Catalog\Model\ResourceModel\Category"> + <plugin name="fulltext_search_indexer" type="Magento\CatalogSearch\Model\Indexer\Fulltext\Model\Plugin\Category"/> + </type> +</config> diff --git a/app/code/Magento/CatalogSearch/etc/webapi_soap/di.xml b/app/code/Magento/CatalogSearch/etc/webapi_soap/di.xml new file mode 100644 index 0000000000000..c7293783dc609 --- /dev/null +++ b/app/code/Magento/CatalogSearch/etc/webapi_soap/di.xml @@ -0,0 +1,12 @@ +<?xml version="1.0"?> +<!-- +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> + <type name="Magento\Catalog\Model\ResourceModel\Category"> + <plugin name="fulltext_search_indexer" type="Magento\CatalogSearch\Model\Indexer\Fulltext\Model\Plugin\Category"/> + </type> +</config> diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Category/ProductTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Category/ProductTest.php index 6efd2638c0d52..8ee3025f44d79 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Category/ProductTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Category/ProductTest.php @@ -27,6 +27,11 @@ class ProductTest extends \PHPUnit\Framework\TestCase */ protected $productResource; + /** + * @var \Magento\Catalog\Api\CategoryRepositoryInterface + */ + private $categoryRepository; + protected function setUp() { /** @var \Magento\Framework\Indexer\IndexerInterface indexer */ @@ -39,6 +44,10 @@ protected function setUp() $this->productResource = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( \Magento\Catalog\Model\ResourceModel\Product::class ); + + $this->categoryRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + \Magento\Catalog\Api\CategoryRepositoryInterface::class + ); } /** @@ -200,6 +209,27 @@ public function testCategoryCreate() } } + /** + * @magentoAppArea adminhtml + * @depends testReindexAll + * + * @return void + */ + public function testCatalogCategoryProductIndexInvalidateAfterDelete(): void + { + $indexerShouldBeValid = (bool)$this->indexer->isInvalid(); + + $categories = $this->getCategories(1); + $this->categoryRepository->delete(array_pop($categories)); + + $state = $this->indexer->getState(); + $state->loadByIndexer($this->indexer->getId()); + $status = $state->getStatus(); + + $this->assertFalse($indexerShouldBeValid); + $this->assertEquals(\Magento\Framework\Indexer\StateInterface::STATUS_INVALID, $status); + } + /** * @param int $count * @return Category[] diff --git a/dev/tests/integration/testsuite/Magento/CatalogSearch/Model/Indexer/Fulltext/Model/Plugin/CategoryTest.php b/dev/tests/integration/testsuite/Magento/CatalogSearch/Model/Indexer/Fulltext/Model/Plugin/CategoryTest.php new file mode 100644 index 0000000000000..496996039de28 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/CatalogSearch/Model/Indexer/Fulltext/Model/Plugin/CategoryTest.php @@ -0,0 +1,73 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\CatalogSearch\Model\Indexer\Fulltext\Model\Plugin; + +use Magento\Catalog\Api\CategoryRepositoryInterface; +use Magento\Catalog\Model\Category; +use Magento\CatalogSearch\Model\Indexer\Fulltext\Processor; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\Framework\Indexer\StateInterface; + +/** + * Test for Magento\CatalogSearch\Model\Indexer\Fulltext\Model\Plugin\Category + */ +class CategoryTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var Processor + */ + private $indexerProcessor; + + /** + * @var CategoryRepositoryInterface + */ + private $categoryRepository; + + protected function setUp() + { + $this->indexerProcessor = Bootstrap::getObjectManager()->create(Processor::class); + $this->categoryRepository = Bootstrap::getObjectManager()->create(CategoryRepositoryInterface::class); + } + + /** + * @magentoDataFixture Magento/Catalog/_files/indexer_catalog_category.php + * @magentoAppArea adminhtml + * + * @return void + */ + public function testIndexerInvalidatedAfterCategoryDelete(): void + { + $this->indexerProcessor->reindexAll(); + $isIndexerValid = (bool)$this->indexerProcessor->getIndexer()->isValid(); + + $category = $this->getCategories(1); + $this->categoryRepository->delete(array_pop($category)); + + $state = $this->indexerProcessor->getIndexer()->getState(); + $state->loadByIndexer($this->indexerProcessor->getIndexerId()); + $status = $state->getStatus(); + + $this->assertTrue($isIndexerValid); + $this->assertEquals(StateInterface::STATUS_INVALID, $status); + } + + /** + * @param int $count + * @return Category[] + */ + private function getCategories(int $count): array + { + /** @var Category $category */ + $category = Bootstrap::getObjectManager()->create(Category::class); + + $result = $category->getCollection()->addAttributeToSelect('name')->getItems(); + $result = array_slice($result, 2); + + return array_slice($result, 0, $count); + } +} From 2ddc0453740b8d4d4d278d5e9b62cf4f506c036c Mon Sep 17 00:00:00 2001 From: DianaRusin <rusind95@gmail.com> Date: Mon, 11 Jun 2018 17:40:06 +0300 Subject: [PATCH 107/206] MAGETWO-88102: [Magento Cloud] Catalog_category_product_index table doesn't update after deleting category --- .../Magento/Catalog/Model/Indexer/Category/ProductTest.php | 2 +- .../Model/Indexer/Fulltext/Model/Plugin/CategoryTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Category/ProductTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Category/ProductTest.php index 8ee3025f44d79..849287517c838 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Category/ProductTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Category/ProductTest.php @@ -215,7 +215,7 @@ public function testCategoryCreate() * * @return void */ - public function testCatalogCategoryProductIndexInvalidateAfterDelete(): void + public function testCatalogCategoryProductIndexInvalidateAfterDelete() { $indexerShouldBeValid = (bool)$this->indexer->isInvalid(); diff --git a/dev/tests/integration/testsuite/Magento/CatalogSearch/Model/Indexer/Fulltext/Model/Plugin/CategoryTest.php b/dev/tests/integration/testsuite/Magento/CatalogSearch/Model/Indexer/Fulltext/Model/Plugin/CategoryTest.php index 496996039de28..fbcd41e8b63b5 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogSearch/Model/Indexer/Fulltext/Model/Plugin/CategoryTest.php +++ b/dev/tests/integration/testsuite/Magento/CatalogSearch/Model/Indexer/Fulltext/Model/Plugin/CategoryTest.php @@ -40,7 +40,7 @@ protected function setUp() * * @return void */ - public function testIndexerInvalidatedAfterCategoryDelete(): void + public function testIndexerInvalidatedAfterCategoryDelete() { $this->indexerProcessor->reindexAll(); $isIndexerValid = (bool)$this->indexerProcessor->getIndexer()->isValid(); From d77e58a62dea1e7991a67464cbe84a323e30b66d Mon Sep 17 00:00:00 2001 From: olysenko <olysenko@magento.com> Date: Mon, 11 Jun 2018 17:44:53 +0300 Subject: [PATCH 108/206] MAGETWO-88217: Guest users unable to sign up to newsletters between stores --- .../Controller/Subscriber/NewAction.php | 2 - .../Magento/Newsletter/Model/Subscriber.php | 24 ++++---- .../Test/Unit/Model/SubscriberTest.php | 58 +++++++++++++++++-- 3 files changed, 64 insertions(+), 20 deletions(-) diff --git a/app/code/Magento/Newsletter/Controller/Subscriber/NewAction.php b/app/code/Magento/Newsletter/Controller/Subscriber/NewAction.php index 5d4590dd3f578..13ab40665e591 100644 --- a/app/code/Magento/Newsletter/Controller/Subscriber/NewAction.php +++ b/app/code/Magento/Newsletter/Controller/Subscriber/NewAction.php @@ -125,10 +125,8 @@ public function execute() $this->validateEmailAvailable($email); $subscriber = $this->_subscriberFactory->create()->loadByEmail($email); - $storeId = $this->_storeManager->getStore()->getId(); if ($subscriber->getId() && $subscriber->getSubscriberStatus() == \Magento\Newsletter\Model\Subscriber::STATUS_SUBSCRIBED - && $subscriber->getStoreId() === $storeId ) { throw new \Magento\Framework\Exception\LocalizedException( __('This email address is already subscribed.') diff --git a/app/code/Magento/Newsletter/Model/Subscriber.php b/app/code/Magento/Newsletter/Model/Subscriber.php index 7e663c1e2e2f2..e713e6aacaac9 100644 --- a/app/code/Magento/Newsletter/Model/Subscriber.php +++ b/app/code/Magento/Newsletter/Model/Subscriber.php @@ -364,7 +364,17 @@ public function isSubscribed() */ public function loadByEmail($subscriberEmail) { - $this->addData($this->getResource()->loadByEmail($subscriberEmail)); + $storeId = $this->_storeManager->getStore()->getId(); + $customerData = ['store_id' => $storeId, 'email'=> $subscriberEmail]; + + /** @var \Magento\Customer\Api\Data\CustomerInterface $customer */ + $customer = $this->customerFactory->create(); + $this->dataObjectHelper->populateWithArray( + $customer, + $customerData, + \Magento\Customer\Api\Data\CustomerInterface::class + ); + $this->addData($this->getResource()->loadByCustomerData($customer)); return $this; } @@ -423,17 +433,7 @@ public function randomSequence($length = 32) */ public function subscribe($email) { - $storeId = $this->_storeManager->getStore()->getId(); - $customerData = ['store_id' => $storeId, 'email'=> $email]; - - /** @var \Magento\Customer\Api\Data\CustomerInterface $customer */ - $customer = $this->customerFactory->create(); - $this->dataObjectHelper->populateWithArray( - $customer, - $customerData, - \Magento\Customer\Api\Data\CustomerInterface::class - ); - $this->getResource()->loadByCustomerData($customer); + $this->loadByEmail($email); if ($this->getId() && $this->getStatus() == self::STATUS_SUBSCRIBED) { return $this->getStatus(); diff --git a/app/code/Magento/Newsletter/Test/Unit/Model/SubscriberTest.php b/app/code/Magento/Newsletter/Test/Unit/Model/SubscriberTest.php index 7dd96be11bcbe..8e1e1a44d68b7 100644 --- a/app/code/Magento/Newsletter/Test/Unit/Model/SubscriberTest.php +++ b/app/code/Magento/Newsletter/Test/Unit/Model/SubscriberTest.php @@ -60,6 +60,16 @@ class SubscriberTest extends \PHPUnit\Framework\TestCase */ protected $objectManager; + /** + * @var \Magento\Framework\Api\DataObjectHelper|\PHPUnit_Framework_MockObject_MockObject + */ + private $dataObjectHelper; + + /** + * @var \Magento\Customer\Api\Data\CustomerInterfaceFactory|\PHPUnit_Framework_MockObject_MockObject + */ + private $customerFactory; + /** * @var \Magento\Newsletter\Model\Subscriber */ @@ -94,7 +104,13 @@ protected function setUp() 'received' ]); $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - + $this->customerFactory = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterfaceFactory::class) + ->setMethods(['create']) + ->disableOriginalConstructor() + ->getMock(); + $this->dataObjectHelper = $this->getMockBuilder(\Magento\Framework\Api\DataObjectHelper::class) + ->disableOriginalConstructor() + ->getMock(); $this->subscriber = $this->objectManager->getObject( \Magento\Newsletter\Model\Subscriber::class, [ @@ -106,7 +122,9 @@ protected function setUp() 'customerRepository' => $this->customerRepository, 'customerAccountManagement' => $this->customerAccountManagement, 'inlineTranslation' => $this->inlineTranslation, - 'resource' => $this->resource + 'resource' => $this->resource, + 'customerFactory' => $this->customerFactory, + 'dataObjectHelper' => $this->dataObjectHelper ] ); } @@ -114,7 +132,21 @@ protected function setUp() public function testSubscribe() { $email = 'subscriber_email@magento.com'; - $this->resource->expects($this->any())->method('loadByEmail')->willReturn( + $storeId = 1; + $customerData = ['store_id' => $storeId, 'email' => $email]; + $storeModel = $this->getMockBuilder(\Magento\Store\Model\Store::class) + ->disableOriginalConstructor() + ->getMock(); + $this->storeManager->expects($this->any())->method('getStore')->willReturn($storeModel); + $storeModel->expects($this->any())->method('getId')->willReturn($storeId); + $customer = $this->createMock(\Magento\Customer\Api\Data\CustomerInterface::class); + $this->customerFactory->expects($this->once())->method('create')->willReturn($customer); + $this->dataObjectHelper->expects($this->once())->method('populateWithArray')->with( + $customer, + $customerData, + \Magento\Customer\Api\Data\CustomerInterface::class + ); + $this->resource->expects($this->any())->method('loadByCustomerData')->with($customer)->willReturn( [ 'subscriber_status' => 3, 'subscriber_email' => $email, @@ -128,7 +160,7 @@ public function testSubscribe() $this->customerSession->expects($this->any())->method('getCustomerId')->willReturn(1); $customerDataModel->expects($this->any())->method('getEmail')->willReturn($email); $this->customerRepository->expects($this->any())->method('getById')->willReturn($customerDataModel); - $customerDataModel->expects($this->any())->method('getStoreId')->willReturn(1); + $customerDataModel->expects($this->any())->method('getStoreId')->willReturn($storeId); $customerDataModel->expects($this->any())->method('getId')->willReturn(1); $this->sendEmailCheck(); $this->resource->expects($this->atLeastOnce())->method('save')->willReturnSelf(); @@ -139,7 +171,21 @@ public function testSubscribe() public function testSubscribeNotLoggedIn() { $email = 'subscriber_email@magento.com'; - $this->resource->expects($this->any())->method('loadByEmail')->willReturn( + $storeId = 1; + $customerData = ['store_id' => $storeId, 'email' => $email]; + $storeModel = $this->getMockBuilder(\Magento\Store\Model\Store::class) + ->disableOriginalConstructor() + ->getMock(); + $this->storeManager->expects($this->any())->method('getStore')->willReturn($storeModel); + $storeModel->expects($this->any())->method('getId')->willReturn($storeId); + $customer = $this->createMock(\Magento\Customer\Api\Data\CustomerInterface::class); + $this->customerFactory->expects($this->once())->method('create')->willReturn($customer); + $this->dataObjectHelper->expects($this->once())->method('populateWithArray')->with( + $customer, + $customerData, + \Magento\Customer\Api\Data\CustomerInterface::class + ); + $this->resource->expects($this->any())->method('loadByCustomerData')->with($customer)->willReturn( [ 'subscriber_status' => 3, 'subscriber_email' => $email, @@ -153,7 +199,7 @@ public function testSubscribeNotLoggedIn() $this->customerSession->expects($this->any())->method('getCustomerId')->willReturn(1); $customerDataModel->expects($this->any())->method('getEmail')->willReturn($email); $this->customerRepository->expects($this->any())->method('getById')->willReturn($customerDataModel); - $customerDataModel->expects($this->any())->method('getStoreId')->willReturn(1); + $customerDataModel->expects($this->any())->method('getStoreId')->willReturn($storeId); $customerDataModel->expects($this->any())->method('getId')->willReturn(1); $this->sendEmailCheck(); $this->resource->expects($this->atLeastOnce())->method('save')->willReturnSelf(); From 89a8c1d078f28e29cfdb4e119f0374e704dabc3c Mon Sep 17 00:00:00 2001 From: Ievgen Sentiabov <isentiabov@magento.com> Date: Mon, 11 Jun 2018 17:54:23 +0300 Subject: [PATCH 109/206] MAGETWO-91035: Shipping Progress Dates are wrong for Tracking Popup - Specified full datetime for date formatting --- .../Shipping/view/frontend/templates/tracking/progress.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Shipping/view/frontend/templates/tracking/progress.phtml b/app/code/Magento/Shipping/view/frontend/templates/tracking/progress.phtml index 84126d8eeb636..237eba09ff802 100644 --- a/app/code/Magento/Shipping/view/frontend/templates/tracking/progress.phtml +++ b/app/code/Magento/Shipping/view/frontend/templates/tracking/progress.phtml @@ -23,7 +23,7 @@ $track = $block->getData('track'); </thead> <tbody> <?php foreach ($track->getProgressdetail() as $detail): ?> - <?php $detailDate = (!empty($detail['deliverydate']) ? $parentBlock->formatDeliveryDate($detail['deliverydate']) : ''); ?> + <?php $detailDate = (!empty($detail['deliverydate']) ? $parentBlock->formatDeliveryDate($detail['deliverydate'] . ' ' . $detail['deliverytime']) : ''); ?> <?php $detailTime = (!empty($detail['deliverytime']) ? $parentBlock->formatDeliveryTime($detail['deliverytime'], $detail['deliverydate']) : ''); ?> <tr> <td data-th="<?= $block->escapeHtml(__('Location')) ?>" class="col location"> From 8ceb788fa1c3ab97e63df0c95fd0f4f407e90663 Mon Sep 17 00:00:00 2001 From: Myroslav Dobra <dmaraptor@gmail.com> Date: Tue, 12 Jun 2018 09:03:50 +0300 Subject: [PATCH 110/206] MAGETWO-87721: Custom Options are corruputed when saving product to a different website --- .../Page/AdminConfigurationStoresPage.xml | 17 ++++ .../Section/AdminProductFormSection.xml | 4 + ...ductWithCustomOptionsSecondWebsiteTest.xml | 93 +++++++++++++++++++ .../ConfigWebUrlOptionsActionGroup.xml | 32 +++++++ .../Config/Section/GeneralSection.xml | 35 +++++++ .../AdminCreateNewStoreGroupActionGroup.xml | 23 +++++ .../AdminCreateWebsiteActionGroup.xml | 21 +++++ .../AdminDeleteWebsiteActionGroup.xml | 24 +++++ .../Store/Page/AdminSystemStoreGroupPage.xml | 12 +++ .../Page/AdminSystemStoreWebsitePage.xml | 12 +++ .../Section/AdminNewStoreGroupSection.xml | 3 +- .../Section/AdminNewWebsiteActionsSection.xml | 12 +++ .../Store/Section/AdminNewWebsiteSection.xml | 15 +++ 13 files changed, 302 insertions(+), 1 deletion(-) create mode 100644 dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Backend/Page/AdminConfigurationStoresPage.xml create mode 100644 dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Test/SaveProductWithCustomOptionsSecondWebsiteTest.xml create mode 100644 dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Config/ActionGroup/ConfigWebUrlOptionsActionGroup.xml create mode 100644 dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Config/Section/GeneralSection.xml create mode 100644 dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/ActionGroup/AdminCreateNewStoreGroupActionGroup.xml create mode 100644 dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/ActionGroup/AdminCreateWebsiteActionGroup.xml create mode 100644 dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/ActionGroup/AdminDeleteWebsiteActionGroup.xml create mode 100644 dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/Page/AdminSystemStoreGroupPage.xml create mode 100644 dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/Page/AdminSystemStoreWebsitePage.xml create mode 100644 dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/Section/AdminNewWebsiteActionsSection.xml create mode 100644 dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/Section/AdminNewWebsiteSection.xml diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Backend/Page/AdminConfigurationStoresPage.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Backend/Page/AdminConfigurationStoresPage.xml new file mode 100644 index 0000000000000..9d977546a382d --- /dev/null +++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Backend/Page/AdminConfigurationStoresPage.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/PageObject.xsd"> + <page name="ConfigurationStoresPage" url="admin/system_config/edit/section/cms/" area="admin" module="Catalog"> + <section name="WYSIWYGOptionsSection"/> + </page> + <page name="WebConfigurationPage" url="admin/system_config/edit/section/web/" area="admin" module="Backend"> + <section name="WYSIWYGOptionsSection"/> + </page> +</pages> diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Section/AdminProductFormSection.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Section/AdminProductFormSection.xml index 909f69fc49c63..ffed1db4c522b 100644 --- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Section/AdminProductFormSection.xml +++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Section/AdminProductFormSection.xml @@ -19,6 +19,10 @@ <element name="visibility" type="select" selector="//select[@name='product[visibility]']"/> <element name="visibilityUseDefault" type="checkbox" selector="//input[@name='use_default[visibility]']"/> </section> + <section name="ProductInWebsitesSection"> + <element name="sectionHeader" type="button" selector="div[data-index='websites']" timeout="30"/> + <element name="website" type="checkbox" selector="//label[contains(text(), '{{var1}}')]/parent::div//input[@type='checkbox']" parameterized="true"/> + </section> <section name="ProductWYSIWYGSection"> <element name="Switcher" type="button" selector="//select[@id='dropdown-switcher']"/> <element name="v4" type ="button" selector="//select[@id='dropdown-switcher']/option[text()='TinyMCE 4.3.6']" /> diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Test/SaveProductWithCustomOptionsSecondWebsiteTest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Test/SaveProductWithCustomOptionsSecondWebsiteTest.xml new file mode 100644 index 0000000000000..eddf551df2f3d --- /dev/null +++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Test/SaveProductWithCustomOptionsSecondWebsiteTest.xml @@ -0,0 +1,93 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd"> + <test name="SaveProductWithCustomOptionsAdditionalWebsiteTest"> + <annotations> + <features value="Save a product with Custom Options and assign to a different website"/> + <stories value="Purchase a product with Custom Options of different types"/> + <title value="You should be able to save a product with custom options assigned to a different website"/> + <description value="Custom Options should not be split when saving the product after assigning to a different website"/> + <severity value="MAJOR"/> + <testCaseId value="MAGETWO-87721"/> + <group value="product"/> + </annotations> + + <after> + <actionGroup ref="ResetWebUrlOptions" stepKey="resetUrlOption"/> + <actionGroup ref="AdminDeleteWebsiteActionGroup" stepKey="deleteWebsite"/> + + <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + </after> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="EnableWebUrlOptions" stepKey="addStoreCodeToUrls"/> + <actionGroup ref="AdminCreateWebsiteActionGroup" stepKey="addnewWebsite"/> + <actionGroup ref="AdminCreateNewStoreGroupActionGroup" stepKey="addNewStoreGroup"/> + + <!--Create Store view --> + <amOnPage url="{{AdminSystemStorePage.url}}" stepKey="amOnAdminSystemStorePage"/> + <click selector="{{AdminStoresMainActionsSection.createStoreViewButton}}" stepKey="createStoreViewButton"/> + <waitForPageLoad stepKey="waitForProductPageLoad"/> + <selectOption userInput="Second Store" selector="{{AdminNewStoreSection.storeGrpDropdown}}" stepKey="selectStoreGroup"/> + <fillField userInput="Second Store View" selector="{{AdminNewStoreSection.storeNameTextField}}" stepKey="fillStoreViewName"/> + <fillField userInput="second_store_view" selector="{{AdminNewStoreSection.storeCodeTextField}}" stepKey="fillStoreViewCode"/> + <selectOption userInput="1" selector="{{AdminNewStoreSection.statusDropdown}}" stepKey="enableStoreViewStatus"/> + <click selector="{{AdminStoresMainActionsSection.saveButton}}" stepKey="clickStoreViewSaveButton"/> + <waitForElementVisible selector="{{AdminNewStoreSection.acceptNewStoreViewCreation}}" stepKey="waitForAcceptNewStoreViewCreationModal" /> + <conditionalClick selector="{{AdminNewStoreSection.acceptNewStoreViewCreation}}" dependentSelector="{{AdminNewStoreSection.acceptNewStoreViewCreation}}" visible="true" stepKey="AcceptNewStoreViewCreation"/> + <waitForElementVisible selector="{{AdminStoresGridSection.storeFilterTextField}}" stepKey="waitForPageReolad"/> + <see userInput="You saved the store view." stepKey="seeSaveMessage" /> + + <!--Create a Simple Product with Custom Options --> + <amOnPage url="{{AdminProductIndexPage.url}}" stepKey="navigateToCatalogProductGrid"/> + <click selector="{{AdminProductGridActionSection.addProductToggle}}" stepKey="clickAddProductDropdown"/> + <click selector="{{AdminProductGridActionSection.addSimpleProduct}}" stepKey="clickAddSimpleProduct"/> + <fillField userInput="{{_defaultProduct.name}}" selector="{{AdminProductFormSection.productName}}" stepKey="fillName"/> + <fillField userInput="{{_defaultProduct.sku}}" selector="{{AdminProductFormSection.productSku}}" stepKey="fillSKU"/> + <fillField userInput="{{_defaultProduct.price}}" selector="{{AdminProductFormSection.productPrice}}" stepKey="fillPrice"/> + <fillField userInput="{{_defaultProduct.quantity}}" selector="{{AdminProductFormSection.productQuantity}}" stepKey="fillQuantity"/> + + <!--Click Customizable Options--> + <conditionalClick selector="{{AdminProductCustomizableOptionsSection.customezableOptions}}" dependentSelector="{{AdminProductCustomizableOptionsSection.checkIfCustomizableOptionsTabOpen}}" visible="true" stepKey="clickIfContentTabCloses2"/> + <click selector="{{AdminProductCustomizableOptionsSection.addOptionBtn}}" stepKey="clickAddOption"/> + <waitForPageLoad stepKey="waitAfterAddOption"/> + <fillField selector="input[name='product[options][0][title]']" userInput="Radio Option" stepKey="fillOptionTitle"/> + <click selector=".admin__dynamic-rows[data-index='options'] .action-select" stepKey="openOptionTypeDropDown"/> + <click selector=".admin__dynamic-rows[data-index='options'] .action-menu._active li:nth-of-type(3) li:nth-of-type(2)" stepKey="selectRadioButtonType"/> + + <!--Add Option Values --> + <click selector="{{AdminProductCustomizableOptionsSection.clickAddValue('Radio Option')}}" stepKey="clickAddValue1"/> + <fillField selector="{{AdminProductCustomizableOptionsSection.fillOptionValueTitle('Radio Option', '0')}}" userInput="option 1" stepKey="fillOptionValueTitle1"/> + <fillField selector="{{AdminProductCustomizableOptionsSection.fillOptionValuePrice('Radio Option', '0')}}" userInput="5" stepKey="fillOptionValuePrice1"/> + + <click selector="{{AdminProductCustomizableOptionsSection.clickAddValue('Radio Option')}}" stepKey="clickAddValue2"/> + <fillField selector="{{AdminProductCustomizableOptionsSection.fillOptionValueTitle('Radio Option', '1')}}" userInput="option 2" stepKey="fillOptionValueTitle2"/> + <fillField selector="{{AdminProductCustomizableOptionsSection.fillOptionValuePrice('Radio Option', '1')}}" userInput="6" stepKey="fillOptionValuePrice2"/> + + <click selector="{{AdminProductCustomizableOptionsSection.clickAddValue('Radio Option')}}" stepKey="clickAddValue3"/> + <fillField selector="{{AdminProductCustomizableOptionsSection.fillOptionValueTitle('Radio Option', '2')}}" userInput="option 3" stepKey="fillOptionValueTitle3"/> + <fillField selector="{{AdminProductCustomizableOptionsSection.fillOptionValuePrice('Radio Option', '2')}}" userInput="7" stepKey="fillOptionValuePrice3"/> + + <!--Save the product with custom options --> + <click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="clickSaveButton"/> + <waitForLoadingMaskToDisappear stepKey="waitProductPageSave"/> + <seeElement selector="{{AdminProductMessagesSection.successMessage}}" stepKey="seeProductSavedMessage"/> + + <!-- Add this product to second website --> + <click selector="{{ProductInWebsitesSection.sectionHeader}}" stepKey="openProductInWebsitesSection1"/> + <click selector="{{ProductInWebsitesSection.website('Second Website')}}" stepKey="selectSecondWebsite"/> + <click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="clickSave"/> + <waitForLoadingMaskToDisappear stepKey="waitForProductPagetoSaveAgain"/> + <seeElement selector="{{AdminProductMessagesSection.successMessage}}" stepKey="seeSaveProductMessageAgain"/> + + <click selector="{{AdminProductCustomizableOptionsSection.customezableOptions}}" stepKey="openCustomOptionsSection"/> + <seeNumberOfElements selector=".admin__dynamic-rows[data-index='values'] tr.data-row" userInput="3" stepKey="see4RowsOfOptions"/> + + </test> +</tests> diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Config/ActionGroup/ConfigWebUrlOptionsActionGroup.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Config/ActionGroup/ConfigWebUrlOptionsActionGroup.xml new file mode 100644 index 0000000000000..c7537db3f80cf --- /dev/null +++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Config/ActionGroup/ConfigWebUrlOptionsActionGroup.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd"> + <actionGroup name="EnableWebUrlOptions"> + <amOnPage url="{{WebConfigurationPage.url}}" stepKey="navigateToWebConfigurationPage"/> + <waitForPageLoad stepKey="waitForPageLoad"/> + <conditionalClick selector="{{WebSection.UrlOptionsTab}}" dependentSelector="{{WebSection.CheckIfUrlOptionsTabExpand}}" visible="true" stepKey="expandUrlSectionTab"/> + <waitForElementVisible selector="{{UrlOptionsSection.addStoreCodeToUrl}}" stepKey="seeAddStoreCodeToUrl"/> + <uncheckOption selector="{{UrlOptionsSection.systemValueForStoreCode}}" stepKey="uncheckUseSystemValue"/> + <selectOption selector="{{UrlOptionsSection.addStoreCodeToUrl}}" userInput="Yes" stepKey="enableStoreCode"/> + <click selector="{{WebSection.UrlOptionsTab}}" stepKey="collapseUrlOptions"/> + <click selector="{{ContentManagementSection.Save}}" stepKey="saveConfig" /> + </actionGroup> + <actionGroup name="ResetWebUrlOptions"> + <amOnPage url="{{WebConfigurationPage.url}}" stepKey="navigateToWebConfigurationPagetoReset"/> + <waitForPageLoad stepKey="waitForPageLoad2"/> + <conditionalClick selector="{{WebSection.UrlOptionsTab}}" dependentSelector="{{WebSection.CheckIfUrlOptionsTabExpand}}" visible="true" stepKey="closeUrlSectionTab"/> + <waitForElementVisible selector="{{UrlOptionsSection.addStoreCodeToUrl}}" stepKey="seeAddStoreCodeToUrl2"/> + <!--<uncheckOption selector="{{UrlOptionsSection.systemValueForStoreCode}}" stepKey="uncheckUseSystemValue"/>--> + <selectOption selector="{{UrlOptionsSection.addStoreCodeToUrl}}" userInput="No" stepKey="enableStoreCode"/> + <checkOption selector="{{UrlOptionsSection.systemValueForStoreCode}}" stepKey="checkUseSystemValue"/> + <click selector="{{WebSection.UrlOptionsTab}}" stepKey="collapseUrlOptions"/> + <click selector="{{ContentManagementSection.Save}}" stepKey="saveConfig"/> + </actionGroup> +</actionGroups> \ No newline at end of file diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Config/Section/GeneralSection.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Config/Section/GeneralSection.xml new file mode 100644 index 0000000000000..7da40964768cf --- /dev/null +++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Config/Section/GeneralSection.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd"> + <section name="ContentManagementSection"> + <element name="WYSIWYGOptions" type="button" selector="#cms_wysiwyg-head"/> + <element name="CheckIfTabExpand" type="button" selector="#cms_wysiwyg-head:not(.open)"/> + <element name="EnableSystemValue" type="button" selector="#cms_wysiwyg_enabled_inherit"/> + <element name="EnableWYSIWYG" type="button" selector="#cms_wysiwyg_enabled"/> + <element name="SwitcherSystemValue" type="button" selector="#cms_wysiwyg_editor_inherit"/> + <element name="Switcher" type="button" selector="#cms_wysiwyg_editor" /> + <element name="Save" type="button" selector="#save"/> + </section> + <section name="WebSection"> + <element name="DefaultLayoutsTab" type="button" selector="#web_default_layouts-head"/> + <element name="CheckIfTabExpand" type="button" selector="#web_default_layouts-head:not(.open)"/> + <element name="UrlOptionsTab" type="button" selector="#web_url-head"/> + <element name="CheckIfUrlOptionsTabExpand" type="button" selector="#web_url-head:not(.open)"/> + </section> + <section name="DefaultLayoutsSection"> + <element name="productLayout" type="select" selector="#web_default_layouts_default_product_layout"/> + <element name="categoryLayout" type="select" selector="#web_default_layouts_default_category_layout"/> + <element name="pageLayout" type="select" selector="#web_default_layouts_default_cms_layout"/> + </section> + <section name="UrlOptionsSection"> + <element name="addStoreCodeToUrl" type="select" selector="#web_url_use_store"/> + <element name="systemValueForStoreCode" type="checkbox" selector="#web_url_use_store_inherit"/> + </section> +</sections> diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/ActionGroup/AdminCreateNewStoreGroupActionGroup.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/ActionGroup/AdminCreateNewStoreGroupActionGroup.xml new file mode 100644 index 0000000000000..83aa1a4735935 --- /dev/null +++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/ActionGroup/AdminCreateNewStoreGroupActionGroup.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<!-- Admin creates new Store group --> +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AdminCreateNewStoreGroupActionGroup"> + <amOnPage url="{{AdminSystemStoreGroupPage.url}}" stepKey="navigateToNewStoreView"/> + <waitForPageLoad stepKey="waitForPageLoad1" /> + <!--Create Store group --> + <selectOption selector="{{AdminNewStoreGroupSection.storeGrpWebsiteDropdown}}" userInput="Second Website" stepKey="selectWebsite" /> + <fillField selector="{{AdminNewStoreGroupSection.storeGrpNameTextField}}" userInput="Second Store" stepKey="enterStoreGroupName" /> + <fillField selector="{{AdminNewStoreGroupSection.storeGrpCodeTextField}}" userInput="second_store" stepKey="enterStoreGroupCode" /> + <selectOption selector="{{AdminNewStoreGroupSection.storeRootCategoryDropdown}}" userInput="Default Category" stepKey="chooseRootCategory" /> + <click selector="{{AdminStoreGroupActionsSection.saveButton}}" stepKey="clickSaveStoreGroup" /> + <waitForElementVisible selector="{{AdminStoresGridSection.storeGrpFilterTextField}}" stepKey="waitForStoreGridReload"/> + <see userInput="You saved the store." stepKey="seeSavedMessage" /> + </actionGroup> +</actionGroups> \ No newline at end of file diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/ActionGroup/AdminCreateWebsiteActionGroup.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/ActionGroup/AdminCreateWebsiteActionGroup.xml new file mode 100644 index 0000000000000..c34e6c0814bb8 --- /dev/null +++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/ActionGroup/AdminCreateWebsiteActionGroup.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<!-- Admin creates new custom website --> +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AdminCreateWebsiteActionGroup"> + <amOnPage url="{{AdminSystemStoreWebsitePage.url}}" stepKey="navigateToNewWebsitePage"/> + <waitForPageLoad stepKey="waitForStoresPageLoad"/> + <!--Create Website--> + <fillField selector="{{AdminNewWebsiteSection.name}}" userInput="Second Website" stepKey="enterWebsiteName" /> + <fillField selector="{{AdminNewWebsiteSection.code}}" userInput="second_website" stepKey="enterWebsiteCode" /> + <click selector="{{AdminNewWebsiteActionsSection.saveWebsite}}" stepKey="clickSaveWebsite" /> + <waitForElementVisible selector="{{AdminStoresGridSection.websiteFilterTextField}}" stepKey="waitForStoreGridToReload"/> + <see userInput="You saved the website." stepKey="seeSavedMessage" /> + </actionGroup> +</actionGroups> \ No newline at end of file diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/ActionGroup/AdminDeleteWebsiteActionGroup.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/ActionGroup/AdminDeleteWebsiteActionGroup.xml new file mode 100644 index 0000000000000..9b61315f0d5b8 --- /dev/null +++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/ActionGroup/AdminDeleteWebsiteActionGroup.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AdminDeleteWebsiteActionGroup"> + <amOnPage url="{{AdminSystemStorePage.url}}" stepKey="amOnAdminSystemStorePage"/> + <click selector="{{AdminStoresGridSection.resetButton}}" stepKey="resetSearchFilter"/> + <fillField userInput="Second Website" selector="{{AdminStoresGridSection.websiteFilterTextField}}" stepKey="fillSearchWebsiteField"/> + <click selector="{{AdminStoresGridSection.searchButton}}" stepKey="clickSearchButton"/> + <see userInput="Second Website" selector="{{AdminStoresGridSection.websiteNameInFirstRow}}" stepKey="verifyThatCorrectWebsiteFound"/> + <click selector="{{AdminStoresGridSection.websiteNameInFirstRow}}" stepKey="clickEditExistingStoreRow"/> + <waitForPageLoad stepKey="waitForStoreToLoad"/> + <click selector="{{AdminStoresMainActionsSection.deleteButton}}" stepKey="clickDeleteWebsiteButtonOnEditWebsitePage"/> + <selectOption userInput="No" selector="{{AdminStoresDeleteStoreGroupSection.createDbBackup}}" stepKey="setCreateDbBackupToNo"/> + <click selector="{{AdminStoresDeleteStoreGroupSection.deleteStoreGroupButton}}" stepKey="clickDeleteWebsiteButton"/> + <waitForElementVisible selector="{{AdminStoresGridSection.websiteFilterTextField}}" stepKey="waitForStoreGridToReload"/> + <see userInput="You deleted the website." stepKey="seeSavedMessage"/> + </actionGroup> +</actionGroups> \ No newline at end of file diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/Page/AdminSystemStoreGroupPage.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/Page/AdminSystemStoreGroupPage.xml new file mode 100644 index 0000000000000..9c203241283dc --- /dev/null +++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/Page/AdminSystemStoreGroupPage.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/PageObject.xsd"> + <page name="AdminSystemStoreGroupPage" url="admin/system_store/newGroup" module="Magento_Store" area="admin"> + <section name="AdminNewStoreGroupSection"/> + </page> +</pages> \ No newline at end of file diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/Page/AdminSystemStoreWebsitePage.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/Page/AdminSystemStoreWebsitePage.xml new file mode 100644 index 0000000000000..6b28b2f04ea09 --- /dev/null +++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/Page/AdminSystemStoreWebsitePage.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/PageObject.xsd"> + <page name="AdminSystemStoreWebsitePage" url="admin/system_store/newWebsite" module="Magento_Store" area="admin"> + <section name="AdminNewWebsiteSection"/> + </page> +</pages> \ No newline at end of file diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/Section/AdminNewStoreGroupSection.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/Section/AdminNewStoreGroupSection.xml index fd2563586b303..be22aa7f8c120 100644 --- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/Section/AdminNewStoreGroupSection.xml +++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/Section/AdminNewStoreGroupSection.xml @@ -7,8 +7,9 @@ --> <sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd"> <section name="AdminNewStoreGroupSection"> + <element name="storeGrpWebsiteDropdown" type="select" selector="#group_website_id"/> <element name="storeGrpNameTextField" type="input" selector="#group_name"/> <element name="storeGrpCodeTextField" type="input" selector="#group_code"/> - <element name="storeRootCategoryDropdown" type="button" selector="#group_root_category_id"/> + <element name="storeRootCategoryDropdown" type="select" selector="#group_root_category_id"/> </section> </sections> diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/Section/AdminNewWebsiteActionsSection.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/Section/AdminNewWebsiteActionsSection.xml new file mode 100644 index 0000000000000..18d1ef2642ef8 --- /dev/null +++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/Section/AdminNewWebsiteActionsSection.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd"> + <section name="AdminNewWebsiteActionsSection"> + <element name="saveWebsite" type="button" selector="#save" timeout="30"/> + </section> +</sections> \ No newline at end of file diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/Section/AdminNewWebsiteSection.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/Section/AdminNewWebsiteSection.xml new file mode 100644 index 0000000000000..1195d1c76b0cd --- /dev/null +++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/Section/AdminNewWebsiteSection.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd"> + <section name="AdminNewWebsiteSection"> + <element name="name" type="input" selector="#website_name"/> + <element name="code" type="input" selector="#website_code"/> + </section> +</sections> From ea90a7426cf993658c0c84b26671f7b3faf9ea51 Mon Sep 17 00:00:00 2001 From: Viktor Sevch <svitja@ukr.net> Date: Tue, 12 Jun 2018 12:25:30 +0300 Subject: [PATCH 111/206] MAGETWO-75427: Hint on product option with Maximum Characters should count down as more characters are entered --- app/code/Magento/Catalog/i18n/en_US.csv | 3 + .../product/view/options/type/text.phtml | 19 ++++- .../web/js/product/remaining-characters.js | 62 ++++++++++++++ .../web/css/source/_module.less | 7 +- .../Test/Block/Product/View/CustomOptions.php | 14 +++- .../js/product/remaining-characters.test.js | 84 +++++++++++++++++++ 6 files changed, 182 insertions(+), 7 deletions(-) create mode 100644 app/code/Magento/Catalog/view/frontend/web/js/product/remaining-characters.js create mode 100644 dev/tests/js/jasmine/tests/app/code/Magento/Catalog/frontend/js/product/remaining-characters.test.js diff --git a/app/code/Magento/Catalog/i18n/en_US.csv b/app/code/Magento/Catalog/i18n/en_US.csv index a316bac5d3584..b8b2d25d58b48 100644 --- a/app/code/Magento/Catalog/i18n/en_US.csv +++ b/app/code/Magento/Catalog/i18n/en_US.csv @@ -516,6 +516,9 @@ Groups,Groups "Maximum image width","Maximum image width" "Maximum image height","Maximum image height" "Maximum number of characters:","Maximum number of characters:" +"Maximum %1 characters", "Maximum %1 characters" +"too many", "too many" +"remaining", "remaining" "start typing to search template","start typing to search template" "Product online","Product online" "Product offline","Product offline" diff --git a/app/code/Magento/Catalog/view/frontend/templates/product/view/options/type/text.phtml b/app/code/Magento/Catalog/view/frontend/templates/product/view/options/type/text.phtml index 11aedc33c2d42..852e0095f2f66 100644 --- a/app/code/Magento/Catalog/view/frontend/templates/product/view/options/type/text.phtml +++ b/app/code/Magento/Catalog/view/frontend/templates/product/view/options/type/text.phtml @@ -61,8 +61,23 @@ $class = ($_option->getIsRequire()) ? ' required' : ''; cols="25"><?= $block->escapeHtml($block->getDefaultValue()) ?></textarea> <?php endif; ?> <?php if ($_option->getMaxCharacters()): ?> - <p class="note"><?= /* @escapeNotVerified */ __('Maximum number of characters:') ?> - <strong><?= /* @escapeNotVerified */ $_option->getMaxCharacters() ?></strong></p> + <p class="note note_<?= /* @escapeNotVerified */ $_option->getId() ?>"> + <?= /* @escapeNotVerified */ __('Maximum %1 characters', $_option->getMaxCharacters()) ?> + <span class="character-counter no-display"></span> + </p> <?php endif; ?> </div> + <?php if ($_option->getMaxCharacters()): ?> + <script type="text/x-magento-init"> + { + "[data-selector='options[<?= /* @escapeNotVerified */ $_option->getId() ?>]']": { + "Magento_Catalog/js/product/remaining-characters": { + "maxLength": "<?= /* @escapeNotVerified */ $_option->getMaxCharacters() ?>", + "noteSelector": ".note_<?= /* @escapeNotVerified */ $_option->getId() ?>", + "counterSelector": ".note_<?= /* @escapeNotVerified */ $_option->getId() ?> .character-counter" + } + } + } + </script> + <?php endif; ?> </div> diff --git a/app/code/Magento/Catalog/view/frontend/web/js/product/remaining-characters.js b/app/code/Magento/Catalog/view/frontend/web/js/product/remaining-characters.js new file mode 100644 index 0000000000000..3e29e1ebd4d9c --- /dev/null +++ b/app/code/Magento/Catalog/view/frontend/web/js/product/remaining-characters.js @@ -0,0 +1,62 @@ +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +define([ + 'jquery', + 'mage/translate', + 'jquery/ui' +], function ($, $t) { + 'use strict'; + + $.widget('mage.remainingCharacters', { + options: { + remainingText: $t('remaining'), + tooManyText: $t('too many'), + errorClass: 'mage-error', + noDisplayClass: 'no-display' + }, + + /** + * Initializes custom option component + * + * @private + */ + _create: function () { + this.note = $(this.options.noteSelector); + this.counter = $(this.options.counterSelector); + + this.updateCharacterCount(); + this.element.on('change keyup paste', this.updateCharacterCount.bind(this)); + }, + + /** + * Updates counter message + */ + updateCharacterCount: function () { + var length = this.element.val().length, + diff = this.options.maxLength - length; + + this.counter.text(this._formatMessage(diff)); + this.counter.toggleClass(this.options.noDisplayClass, length === 0); + this.note.toggleClass(this.options.errorClass, diff < 0); + }, + + /** + * Format remaining characters message + * + * @param {int} diff + * @returns {String} + * @private + */ + _formatMessage: function (diff) { + var count = Math.abs(diff), + qualifier = diff < 0 ? this.options.tooManyText : this.options.remainingText; + + return '(' + count + ' ' + qualifier + ')'; + } + }); + + return $.mage.remainingCharacters; +}); diff --git a/app/design/frontend/Magento/luma/Magento_Catalog/web/css/source/_module.less b/app/design/frontend/Magento/luma/Magento_Catalog/web/css/source/_module.less index 6f7da202c16e6..228c6947c938b 100644 --- a/app/design/frontend/Magento/luma/Magento_Catalog/web/css/source/_module.less +++ b/app/design/frontend/Magento/luma/Magento_Catalog/web/css/source/_module.less @@ -336,6 +336,11 @@ .lib-css(margin-top, @indent__xs); } } + .field { + .note.mage-error { + color: @error__color; + } + } } .product-options-bottom .price-box, @@ -789,7 +794,7 @@ clear: both; max-width: 100%; overflow-x: auto; - position: relative; // Needed for Safari(iOS) to properly render "overflow-x" rule. + position: relative; // Needed for Safari(iOS) to properly render 'overflow-x' rule. .table-comparison > tbody > tr { > th, diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View/CustomOptions.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View/CustomOptions.php index 5e9e5526eb685..9f05a4ade8a37 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View/CustomOptions.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View/CustomOptions.php @@ -58,7 +58,7 @@ class CustomOptions extends Form * * @var string */ - protected $maxCharacters = './/div[@class="control"]/p[@class="note"]/strong'; + protected $maxCharacters = './/div[@class="control"]/p[contains(@class, "note")]'; /** * Selector for label of option value element @@ -72,7 +72,7 @@ class CustomOptions extends Form * * @var string */ - protected $noteByNumber = './/*[@class="note"][%d]/strong'; + protected $noteByNumber = './/*[contains(@class, "note")][%d]/strong'; /** * Selector for select element of option @@ -220,13 +220,19 @@ public function isJsMessageVisible($customOptionTitle) protected function getFieldData(SimpleElement $option) { $price = $this->getOptionPriceNotice($option); - $maxCharacters = $option->find($this->maxCharacters, Locator::SELECTOR_XPATH); + $maxCharactersElement = $option->find($this->maxCharacters, Locator::SELECTOR_XPATH); + + $maxCharacters = null; + if ($maxCharactersElement->isVisible()) { + preg_match('/\s([0-9]+)\s/', $maxCharactersElement->getText(), $match); + $maxCharacters = isset($match[1]) ? $match[1] : $maxCharactersElement->getText(); + } return [ 'options' => [ [ 'price' => floatval($price), - 'max_characters' => $maxCharacters->isVisible() ? $maxCharacters->getText() : null, + 'max_characters' => $maxCharacters, ], ] ]; diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Catalog/frontend/js/product/remaining-characters.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Catalog/frontend/js/product/remaining-characters.test.js new file mode 100644 index 0000000000000..3b64385a8894b --- /dev/null +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Catalog/frontend/js/product/remaining-characters.test.js @@ -0,0 +1,84 @@ +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +/* eslint-disable max-nested-callbacks */ +define([ + 'Magento_Catalog/js/product/remaining-characters', + 'jquery' +], function (remainingCharacters, $) { + 'use strict'; + + describe('Magento_Catalog/js/product/remaining-characters', function () { + var widget, + note; + + beforeEach(function () { + widget = $('<input type="text" data-selector="options[1]"/>'); + note = $('<p class="note note_1"><span class="character-counter"></span></p>'); + $('body').append(widget).append(note); + + widget.remainingCharacters({ + maxLength: '10', + noteSelector: '.note_1', + counterSelector: '.note_1 .character-counter' + }); + }); + + afterEach(function () { + widget.remove(); + note.remove(); + }); + + describe('Note text is updated on input change', function () { + it('check empty input', function () { + var testData = { + input: '', + action: 'change', + expectedText: '(10 remaining)' + }; + + widget.val(testData.input); + widget.trigger(testData.action); + expect(note.find('.character-counter').text()).toBe(testData.expectedText); + }); + + it('check input length less than character limit', function () { + var testData = { + input: 'abc', + action: 'change', + expectedText: '(7 remaining)' + }; + + widget.val(testData.input); + widget.trigger(testData.action); + expect(note.find('.character-counter').text()).toBe(testData.expectedText); + }); + + it('check input length equals character limit', function () { + var testData = { + input: 'abcdefghij', + action: 'paste', + expectedText: '(0 remaining)' + }; + + widget.val(testData.input); + widget.trigger(testData.action); + expect(note.find('.character-counter').text()).toBe(testData.expectedText); + }); + + it('check input length greater than character limit', function () { + var testData = { + input: 'abcdefghijkl', + action: 'change', + expectedText: '(2 too many)' + }; + + widget.val(testData.input); + widget.trigger(testData.action); + expect(note.find('.character-counter').text()).toBe(testData.expectedText); + }); + }); + }); +}); From 995e19209c06e761df972405ef41605a090a1ecc Mon Sep 17 00:00:00 2001 From: Andrii Voskoboinikov <avoskoboinikov@magento.com> Date: Tue, 12 Jun 2018 12:38:58 +0300 Subject: [PATCH 112/206] MAGETWO-92693: Some improvements on product create|edit page in admin area --- .../Controller/Adminhtml/Product/Builder.php | 71 ++++++++++++----- .../Catalog/Model/ProductRepository.php | 12 +-- .../Product/Form/Modifier/Eav.php | 78 +++++++++++++++++-- .../Magento/Eav/Model/AttributeRepository.php | 11 ++- .../Entity/Collection/AbstractCollection.php | 2 +- .../Eav/Model/ResourceModel/Helper.php | 5 ++ 6 files changed, 144 insertions(+), 35 deletions(-) diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Builder.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Builder.php index 4fa61b2b372c2..39a00bfcdc399 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Builder.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Builder.php @@ -11,6 +11,9 @@ use Magento\Store\Model\StoreFactory; use Psr\Log\LoggerInterface as Logger; use Magento\Framework\Registry; +use Magento\Catalog\Api\ProductRepositoryInterface; +use Magento\Catalog\Model\Product; +use Magento\Catalog\Model\Product\Type as ProductTypes; class Builder { @@ -39,6 +42,11 @@ class Builder */ protected $storeFactory; + /** + * @var ProductRepositoryInterface + */ + protected $productRepository; + /** * Constructor * @@ -53,7 +61,8 @@ public function __construct( Logger $logger, Registry $registry, WysiwygModel\Config $wysiwygConfig, - StoreFactory $storeFactory = null + StoreFactory $storeFactory = null, + ProductRepositoryInterface $productRepository = null ) { $this->productFactory = $productFactory; $this->logger = $logger; @@ -61,6 +70,8 @@ public function __construct( $this->wysiwygConfig = $wysiwygConfig; $this->storeFactory = $storeFactory ?: \Magento\Framework\App\ObjectManager::getInstance() ->get(\Magento\Store\Model\StoreFactory::class); + $this->productRepository = $productRepository ?: \Magento\Framework\App\ObjectManager::getInstance() + ->get(ProductRepositoryInterface::class); } /** @@ -68,40 +79,62 @@ public function __construct( * * @param RequestInterface $request * @return \Magento\Catalog\Model\Product + * @throws \RuntimeException */ public function build(RequestInterface $request) { - $productId = (int)$request->getParam('id'); - /** @var $product \Magento\Catalog\Model\Product */ - $product = $this->productFactory->create(); - $product->setStoreId($request->getParam('store', 0)); - $store = $this->storeFactory->create(); - $store->load($request->getParam('store', 0)); - + $productId = (int) $request->getParam('id'); + $storeId = (int) $request->getParam('store', 0); + $attributeSetId = (int) $request->getParam('set'); $typeId = $request->getParam('type'); - if (!$productId && $typeId) { - $product->setTypeId($typeId); - } - $product->setData('_edit_mode', true); if ($productId) { try { - $product->load($productId); + $product = $this->productRepository->getById($productId, true, $storeId); } catch (\Exception $e) { - $product->setTypeId(\Magento\Catalog\Model\Product\Type::DEFAULT_TYPE); + $product = $this->createEmptyProduct(ProductTypes::DEFAULT_TYPE, $attributeSetId, $storeId); $this->logger->critical($e); } + } else { + $product = $this->createEmptyProduct($typeId, $attributeSetId, $storeId); } - $setId = (int)$request->getParam('set'); - if ($setId) { - $product->setAttributeSetId($setId); - } + $store = $this->storeFactory->create(); + $store->load($storeId); $this->registry->register('product', $product); $this->registry->register('current_product', $product); $this->registry->register('current_store', $store); - $this->wysiwygConfig->setStoreId($request->getParam('store')); + + $this->wysiwygConfig->setStoreId($storeId); + + return $product; + } + + /** + * @param int $typeId + * @param int $attributeSetId + * @param int $storeId + * @return \Magento\Catalog\Model\Product + */ + private function createEmptyProduct($typeId, $attributeSetId, $storeId): Product + { + /** @var $product \Magento\Catalog\Model\Product */ + $product = $this->productFactory->create(); + $product->setData('_edit_mode', true); + + if ($typeId !== null) { + $product->setTypeId($typeId); + } + + if ($storeId !== null) { + $product->setStoreId($storeId); + } + + if ($attributeSetId !== null) { + $product->setAttributeSetId($attributeSetId); + } + return $product; } } diff --git a/app/code/Magento/Catalog/Model/ProductRepository.php b/app/code/Magento/Catalog/Model/ProductRepository.php index 95c3346028a80..7594089ca114c 100644 --- a/app/code/Magento/Catalog/Model/ProductRepository.php +++ b/app/code/Magento/Catalog/Model/ProductRepository.php @@ -234,19 +234,13 @@ public function get($sku, $editMode = false, $storeId = null, $forceReload = fal $cacheKey = $this->getCacheKey([$editMode, $storeId]); $cachedProduct = $this->getProductFromLocalCache($sku, $cacheKey); if ($cachedProduct === null || $forceReload) { - $product = $this->productFactory->create(); - $productId = $this->resourceModel->getIdBySku($sku); if (!$productId) { throw new NoSuchEntityException(__('Requested product doesn\'t exist')); } - if ($editMode) { - $product->setData('_edit_mode', true); - } - if ($storeId !== null) { - $product->setData('store_id', $storeId); - } - $product->load($productId); + + $product = $this->getById($productId, $editMode, $storeId, $forceReload); + $this->cacheProduct($cacheKey, $product); $cachedProduct = $product; } diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php index a4cc15c0a52dd..3a698200f8d78 100755 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php @@ -31,6 +31,7 @@ use Magento\Ui\Component\Form\Fieldset; use Magento\Ui\DataProvider\Mapper\FormElement as FormElementMapper; use Magento\Ui\DataProvider\Mapper\MetaProperties as MetaPropertiesMapper; +use Magento\Eav\Model\ResourceModel\Entity\Attribute\CollectionFactory as AttributeCollectionFactory; /** * Class Eav @@ -187,6 +188,12 @@ class Eav extends AbstractModifier */ private $localeCurrency; + /** + * internal cache for attribute models + * @var array + */ + private $attributesCache = []; + /** * @param LocatorInterface $locator * @param CatalogEavValidationRules $catalogEavValidationRules @@ -228,7 +235,8 @@ public function __construct( ScopeOverriddenValue $scopeOverriddenValue, DataPersistorInterface $dataPersistor, $attributesToDisable = [], - $attributesToEliminate = [] + $attributesToEliminate = [], + AttributeCollectionFactory $attributeCollectionFactory = null ) { $this->locator = $locator; $this->catalogEavValidationRules = $catalogEavValidationRules; @@ -249,6 +257,8 @@ public function __construct( $this->dataPersistor = $dataPersistor; $this->attributesToDisable = $attributesToDisable; $this->attributesToEliminate = $attributesToEliminate; + $this->attributeCollectionFactory = $attributeCollectionFactory ?: \Magento\Framework\App\ObjectManager::getInstance() + ->get(AttributeCollectionFactory::class); } /** @@ -485,9 +495,7 @@ private function getAttributeSetId() private function getAttributes() { if (!$this->attributes) { - foreach ($this->getGroups() as $group) { - $this->attributes[$this->calculateGroupCode($group)] = $this->loadAttributes($group); - } + $this->attributes = $this->loadAttributesForGroups($this->getGroups()); } return $this->attributes; @@ -524,6 +532,60 @@ private function loadAttributes(AttributeGroupInterface $group) return $attributes; } + /** + * @param AttributeGroupInterface[] ...$groups + * @return @return ProductAttributeInterface[] + */ + private function loadAttributesForGroups(array $groups) + { + $attributes = []; + $groupIds = []; + + // foreach just works faster than array_walk() or array_column() + foreach ($groups as $group) { + $groupIds[$group->getAttributeGroupId()] = $this->calculateGroupCode($group); + $attributes[$this->calculateGroupCode($group)] = []; + } + + $collection = $this->attributeCollectionFactory->create(); + $collection->setAttributeGroupFilter(array_keys($groupIds)); + + $attrs = $collection->getItems(); + + $map = []; + + foreach ($attrs as $a) { + $map[$a->getAttributeId()] = $a->getAttributeGroupId(); + } + + $sortOrder = $this->sortOrderBuilder + ->setField('sort_order') + ->setAscendingDirection() + ->create(); + + $searchCriteria = $this->searchCriteriaBuilder + ->addFilter(AttributeGroupInterface::GROUP_ID, array_keys($groupIds), 'in') + ->addFilter(ProductAttributeInterface::IS_VISIBLE, 1) + ->addSortOrder($sortOrder) + ->create(); + + $groupAttributes = $this->attributeRepository->getList($searchCriteria)->getItems(); + + $productType = $this->getProductType(); + + foreach ($groupAttributes as $attribute) { + $applyTo = $attribute->getApplyTo(); + $isRelated = !$applyTo || in_array($productType, $applyTo); + if ($isRelated) { + $attributeGroupId = $map[$attribute->getAttributeId()]; + $attributeGroupCode = $groupIds[$attributeGroupId]; + $attributes[$attributeGroupCode][] = $attribute; + } + } + + return $attributes; + } + /** * Get attribute codes of prev set * @@ -905,7 +967,13 @@ private function isScopeGlobal($attribute) */ private function getAttributeModel($attribute) { - return $this->eavAttributeFactory->create()->load($attribute->getAttributeId()); + $attributeId = $attribute->getAttributeId(); + + if (!array_key_exists($attributeId, $this->attributesCache)) { + $this->attributesCache[$attributeId] = $this->eavAttributeFactory->create()->load($attributeId); + } + + return $this->attributesCache[$attributeId]; } /** diff --git a/app/code/Magento/Eav/Model/AttributeRepository.php b/app/code/Magento/Eav/Model/AttributeRepository.php index 3f20558d03d78..5ea3ec485f4d9 100644 --- a/app/code/Magento/Eav/Model/AttributeRepository.php +++ b/app/code/Magento/Eav/Model/AttributeRepository.php @@ -141,7 +141,16 @@ public function getList($entityTypeCode, \Magento\Framework\Api\SearchCriteriaIn $searchResults = $this->searchResultsFactory->create(); $searchResults->setSearchCriteria($searchCriteria); $searchResults->setItems($attributes); - $searchResults->setTotalCount($attributeCollection->getSize()); + + // if $searchCriteria has no page size - we can use count() on $attributeCollection + // otherwise - we have to use getSize() on $attributeCollection + // with this approach we can eliminate excessive COUNT requests in case page size is empty + if ($searchCriteria->getPageSize()) { + $searchResults->setTotalCount($attributeCollection->getSize()); + } else { + $searchResults->setTotalCount(count($attributeCollection)); + } + return $searchResults; } diff --git a/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php b/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php index d61166e5c71a9..fb428994ebf8e 100644 --- a/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php +++ b/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php @@ -1175,7 +1175,7 @@ public function _loadAttributes($printQuery = false, $logQuery = false) $attributeTypes[$table] ); } - $selectGroups = $this->_resourceHelper->getLoadAttributesSelectGroups($selects); + $selectGroups = $this->_resourceHelper->mergeToOneGroup($selects); foreach ($selectGroups as $selects) { if (!empty($selects)) { try { diff --git a/app/code/Magento/Eav/Model/ResourceModel/Helper.php b/app/code/Magento/Eav/Model/ResourceModel/Helper.php index 65e2fb250cecd..233393a75df47 100644 --- a/app/code/Magento/Eav/Model/ResourceModel/Helper.php +++ b/app/code/Magento/Eav/Model/ResourceModel/Helper.php @@ -83,4 +83,9 @@ public function getLoadAttributesSelectGroups($selects) } return $mainGroup; } + + public function mergeToOneGroup($selects) + { + return [$this->getLoadAttributesSelectGroups($selects)]; + } } From d45aaccb10efc0a314cb60c6090cd3f23ef400b8 Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov <slopukhov@magento.com> Date: Tue, 12 Jun 2018 15:38:23 +0300 Subject: [PATCH 113/206] MAGETWO-92395: Fix full reindex for custom product price indexer mode --- .../Model/ResourceModel/Indexer/Price.php | 2 +- .../Indexer/Product/Price/AbstractAction.php | 75 ++++++++++++++----- .../Indexer/Product/Price/Action/Full.php | 8 +- .../Product/Indexer/Price/Configurable.php | 2 +- .../Product/Indexer/Price/Grouped.php | 2 +- 5 files changed, 66 insertions(+), 23 deletions(-) diff --git a/app/code/Magento/Bundle/Model/ResourceModel/Indexer/Price.php b/app/code/Magento/Bundle/Model/ResourceModel/Indexer/Price.php index 765b9374c66ed..32f13e9457217 100644 --- a/app/code/Magento/Bundle/Model/ResourceModel/Indexer/Price.php +++ b/app/code/Magento/Bundle/Model/ResourceModel/Indexer/Price.php @@ -355,7 +355,7 @@ protected function _calculateBundleSelectionPrice($priceType) 'bs.selection_id = bsp.selection_id AND bsp.website_id = i.website_id', [''] )->join( - ['idx' => $this->getIndexTableForCompositeProducts()], + ['idx' => $this->getIdxTable()], 'bs.product_id = idx.entity_id AND i.customer_group_id = idx.customer_group_id' . ' AND i.website_id = idx.website_id', [] diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php index 33adb7af95ffc..d2d64bd2ea0bb 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php @@ -10,6 +10,7 @@ use Magento\Framework\App\ObjectManager; use Magento\Framework\Indexer\DimensionalIndexerInterface; use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; +use Magento\Framework\Indexer\DimensionProviderInterface; /** * Abstract action reindex class @@ -105,7 +106,10 @@ abstract class AbstractAction * @param \Magento\Catalog\Model\Product\Type $catalogProductType * @param \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\Factory $indexerPriceFactory * @param DefaultPrice $defaultIndexerResource - * @param \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\TierPrice $tierPriceIndexResource + * @param \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\TierPrice|null $tierPriceIndexResource + * @param DimensionProviderFactory|null $dimensionCollectionFactory + * @param TableMaintainer|null $tableMaintainer + * @param \Magento\Framework\App\Config\ScopeConfigInterface|null $configReader */ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $config, @@ -160,9 +164,7 @@ abstract public function execute($ids); */ protected function _syncData(array $processIds = []) { - $currentMode = $this->configReader - ->getValue(ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE) ?: ModeSwitcher::INPUT_KEY_NONE; - $dimensionsProviders = $this->dimensionCollectionFactory->createByMode($currentMode); + $dimensionsProviders = $this->dimensionCollectionFactory->createByMode($this->getCurrentMode()); // for backward compatibility split data from old idx table on dimension tables foreach ($dimensionsProviders as $dimensions) { @@ -414,14 +416,11 @@ protected function _reindexRows($changedIds = []) $changedIds = array_merge($changedIds, ...array_values($parentProductsTypes)); $productsTypes = array_merge_recursive($productsTypes, $parentProductsTypes); - $syncDataForNonDimensionalIndexers = false; foreach ($productsTypes as $productType => $entityIds) { $indexer = $this->_getIndexer($productType); if ($indexer instanceof DimensionalIndexerInterface) { - $currentMode = $this->configReader - ->getValue(ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE) ?: ModeSwitcher::INPUT_KEY_NONE; - $dimensionsProviders = $this->dimensionCollectionFactory->createByMode($currentMode); + $dimensionsProviders = $this->dimensionCollectionFactory->createByMode($this->getCurrentMode()); foreach ($dimensionsProviders as $dimensions) { $this->tableMaintainer->createMainTmpTable($dimensions); $this->_emptyTable($this->tableMaintainer->getMainTmpTable($dimensions)); @@ -429,11 +428,9 @@ protected function _reindexRows($changedIds = []) $this->syncDataByDimensions($dimensions, $entityIds); } } else { - $syncDataForNonDimensionalIndexers = true; $this->_emptyTable($this->_defaultIndexerResource->getIdxTable()); + $this->_copyRelationIndexData($entityIds); $indexer->reindexEntity($entityIds); - } - if ($syncDataForNonDimensionalIndexers) { $this->_syncData($entityIds); } } @@ -472,19 +469,59 @@ protected function _copyRelationIndexData($parentIds, $excludeIds = null) $children = $this->_connection->fetchCol($select); if ($children) { - $select = $this->_connection->select()->from( - $this->getIndexTargetTable() - )->where( - 'entity_id IN(?)', - $children - ); - $query = $select->insertFromSelect($this->_defaultIndexerResource->getIdxTable(), [], false); - $this->_connection->query($query); + /** @var DimensionProviderInterface $dimensionsProviders */ + $dimensionsProviders = $this->dimensionCollectionFactory->createByMode($this->getCurrentMode()); + foreach ($dimensionsProviders as $dimensions) { + $select = $this->_connection->select()->from( + $this->getIndexTargetTableByDimension( + $this->getIndexTargetTable(), + $dimensions + ) + )->where( + 'entity_id IN(?)', + $children + ); + $query = $select->insertFromSelect($this->_defaultIndexerResource->getIdxTable(), [], false); + $this->_connection->query($query); + } } return $this; } + /** + * Get current price indexer mode + * + * @return string + */ + private function getCurrentMode() + { + return $this->configReader->getValue( + ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE + ) ?: ModeSwitcher::INPUT_KEY_NONE; + } + + /** + * Retrieve index table by dimension that will be used for write operations. + * + * This method is used during both partial and full reindex to identify the table. + * + * @param string $indexTargetTable + * @param \Magento\Framework\Search\Request\Dimension[] $dimensions + * + * @return string + */ + private function getIndexTargetTableByDimension(string $indexTargetTable, array $dimensions) + { + if ($indexTargetTable === self::getIndexTargetTable()) { + $indexTargetTable = $this->tableMaintainer->getMainTable($dimensions); + } + if ($indexTargetTable === self::getIndexTargetTable() . '_replica') { + $indexTargetTable = $this->tableMaintainer->getMainReplicaTable($dimensions); + } + return $indexTargetTable; + } + /** * Retrieve index table that will be used for write operations. * diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php index bed52bc4cfd66..8c9a2ed96fcb6 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php @@ -356,6 +356,10 @@ private function reindexBatch(PriceInterface $priceIndexer, array $batch, string $idxTableName = $this->_defaultIndexerResource->getIdxTable(); $this->_emptyTable($idxTableName); + if ($priceIndexer->getIsComposite()) { + $this->_copyRelationIndexData($entityIds); + } + // Reindex entities by id $priceIndexer->reindexEntity($entityIds); @@ -479,7 +483,9 @@ private function moveDataFromReplicaTableToReplicaTables(array $dimensions) $this->dimensionTableMaintainer->getConnection()->query( $this->dimensionTableMaintainer->getConnection()->insertFromSelect( $select, - $replicaTablesByDimension + $replicaTablesByDimension, + [], + \Magento\Framework\DB\Adapter\AdapterInterface::INSERT_ON_DUPLICATE ) ); } diff --git a/app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Indexer/Price/Configurable.php b/app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Indexer/Price/Configurable.php index 82ad0540be749..a8fb60a4dcb22 100644 --- a/app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Indexer/Price/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Indexer/Price/Configurable.php @@ -88,7 +88,7 @@ protected function _applyConfigurableOption($entityIds = null) $this->_prepareConfigurableOptionPriceTable(); $select = $connection->select()->from( - ['i' => $this->getIndexTableForCompositeProducts()], + ['i' => $this->getIdxTable()], [] )->join( ['l' => $this->getTable('catalog_product_super_link')], diff --git a/app/code/Magento/GroupedProduct/Model/ResourceModel/Product/Indexer/Price/Grouped.php b/app/code/Magento/GroupedProduct/Model/ResourceModel/Product/Indexer/Price/Grouped.php index 27a394b7b035f..cbbb58d3c24c8 100644 --- a/app/code/Magento/GroupedProduct/Model/ResourceModel/Product/Indexer/Price/Grouped.php +++ b/app/code/Magento/GroupedProduct/Model/ResourceModel/Product/Indexer/Price/Grouped.php @@ -103,7 +103,7 @@ protected function _prepareGroupedProductPriceDataSelect($entityIds = null) 'le.entity_id = l.linked_product_id', [] )->joinLeft( - ['i' => $this->getIndexTableForCompositeProducts()], + ['i' => $table], 'i.entity_id = l.linked_product_id AND i.website_id = cw.website_id' . ' AND i.customer_group_id = cg.customer_group_id', [ From ca10471955cdf797725728ad5483a32873e9f273 Mon Sep 17 00:00:00 2001 From: Michail Slabko <mslabko@magento.com> Date: Tue, 12 Jun 2018 15:50:21 +0300 Subject: [PATCH 114/206] MAGETWO-92394: Implement partial reindex - MAGETWO-64467 [Indexer optimizations] Tables sharding / segmentation for price indexer --- app/code/Magento/CatalogInventory/etc/di.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/code/Magento/CatalogInventory/etc/di.xml b/app/code/Magento/CatalogInventory/etc/di.xml index 264f25d24647e..0ee419df54ae4 100644 --- a/app/code/Magento/CatalogInventory/etc/di.xml +++ b/app/code/Magento/CatalogInventory/etc/di.xml @@ -125,6 +125,14 @@ </argument> </arguments> </type> + <type name="Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\SimpleProductPrice"> + <arguments> + <argument name="priceModifiers" xsi:type="array"> + <item name="inventoryProductPriceIndexFilter" xsi:type="object">Magento\CatalogInventory\Model\Indexer\ProductPriceIndexFilter</item> + </argument> + </arguments> + </type> + <type name="Magento\CatalogInventory\Model\ResourceModel\Stock\Item"> <plugin name="priceIndexUpdater" type="Magento\CatalogInventory\Model\Plugin\PriceIndexUpdater" /> </type> From 36e1ece1c9f2a3649814c0126670c4c16c5d4d6e Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi <alugovyi@magento.com> Date: Tue, 12 Jun 2018 16:24:43 +0300 Subject: [PATCH 115/206] MAGETWO-64467: [Indexer optimizations] Tables sharding / segmentation for price indexer --- .../Magento/Framework/Search/Adapter/Mysql/AdapterTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dev/tests/integration/testsuite/Magento/Framework/Search/Adapter/Mysql/AdapterTest.php b/dev/tests/integration/testsuite/Magento/Framework/Search/Adapter/Mysql/AdapterTest.php index d25349cd3fe33..9771d3f0564c1 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Search/Adapter/Mysql/AdapterTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Search/Adapter/Mysql/AdapterTest.php @@ -21,7 +21,7 @@ * @magentoDataFixture Magento/Framework/Search/_files/products.php * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class AdapterTest extends \PHPUnit\Framework\TestCase +class AdapterTest extends \Magento\TestFramework\Indexer\TestCase { /** * @var \Magento\Framework\Search\AdapterInterface @@ -170,6 +170,8 @@ public function testMatchOrderedQuery() $this->assertEquals(5, $queryResponse->count()); $this->assertOrderedProductIds($queryResponse, $expectedIds); + + self::tearDownAfterClass(); } /** From b457120543b4e9cfe42f2f672c9a6eae0e429366 Mon Sep 17 00:00:00 2001 From: Andrii Voskoboinikov <avoskoboinikov@magento.com> Date: Tue, 12 Jun 2018 16:40:24 +0300 Subject: [PATCH 116/206] MAGETWO-92693: Some improvements on product create|edit page in admin area --- .../Magento/Catalog/Controller/Adminhtml/Product/Builder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Builder.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Builder.php index 39a00bfcdc399..166dc09117d28 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Builder.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Builder.php @@ -131,7 +131,7 @@ private function createEmptyProduct($typeId, $attributeSetId, $storeId): Product $product->setStoreId($storeId); } - if ($attributeSetId !== null) { + if ($attributeSetId) { $product->setAttributeSetId($attributeSetId); } From 208114aeaf72e9528714430aece215b63a6dc716 Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi <alugovyi@magento.com> Date: Tue, 12 Jun 2018 17:57:16 +0300 Subject: [PATCH 117/206] MAGETWO-64467: [Indexer optimizations] Tables sharding / segmentation for price indexer --- .../Magento/Framework/Search/Adapter/Mysql/AdapterTest.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Framework/Search/Adapter/Mysql/AdapterTest.php b/dev/tests/integration/testsuite/Magento/Framework/Search/Adapter/Mysql/AdapterTest.php index 9771d3f0564c1..d25349cd3fe33 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Search/Adapter/Mysql/AdapterTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Search/Adapter/Mysql/AdapterTest.php @@ -21,7 +21,7 @@ * @magentoDataFixture Magento/Framework/Search/_files/products.php * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class AdapterTest extends \Magento\TestFramework\Indexer\TestCase +class AdapterTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\Search\AdapterInterface @@ -170,8 +170,6 @@ public function testMatchOrderedQuery() $this->assertEquals(5, $queryResponse->count()); $this->assertOrderedProductIds($queryResponse, $expectedIds); - - self::tearDownAfterClass(); } /** From ae0933cea51f89d5e9068b50ccc937ec4f5cb26a Mon Sep 17 00:00:00 2001 From: Andrii Voskoboinikov <avoskoboinikov@magento.com> Date: Tue, 12 Jun 2018 18:49:02 +0300 Subject: [PATCH 118/206] MAGETWO-92693: Some improvements on product create|edit page in admin area --- .../Entity/Collection/AbstractCollection.php | 2 +- .../Eav/Model/ResourceModel/Helper.php | 48 ++++++++++++++++--- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php b/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php index fb428994ebf8e..d61166e5c71a9 100644 --- a/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php +++ b/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php @@ -1175,7 +1175,7 @@ public function _loadAttributes($printQuery = false, $logQuery = false) $attributeTypes[$table] ); } - $selectGroups = $this->_resourceHelper->mergeToOneGroup($selects); + $selectGroups = $this->_resourceHelper->getLoadAttributesSelectGroups($selects); foreach ($selectGroups as $selects) { if (!empty($selects)) { try { diff --git a/app/code/Magento/Eav/Model/ResourceModel/Helper.php b/app/code/Magento/Eav/Model/ResourceModel/Helper.php index 233393a75df47..fc8a47994a6aa 100644 --- a/app/code/Magento/Eav/Model/ResourceModel/Helper.php +++ b/app/code/Magento/Eav/Model/ResourceModel/Helper.php @@ -46,6 +46,19 @@ public function __construct(\Magento\Framework\App\ResourceConnection $resource, \Magento\Framework\DB\Ddl\Table::TYPE_VARBINARY => 'blob', ]; + /** + * Attribute types that can be united via UNION into one query + * while selecting attribute`s data from tables like `catalog_product_entity_datatype` + * + * This helps to run one query with all data types instead of one per each data type + * + * This data types are determined as 'groupable' because their tables have the same structure + * which means that they can be used in one UNION query + * + * @var array + */ + private $_groupableTypes = ['varchar', 'text', 'decimal', 'datetime', 'int']; + /** * Returns DDL type by column type in database * @@ -72,20 +85,41 @@ public function getDdlTypeByColumnType($columnType) /** * Groups selects to separate unions depend on type * + * E.g. for input array: + * [ + * varchar => [select1, select2], + * text => [select3], + * int => [select4], + * bool => [select5] + * ] + * + * The result array will be: + * [ + * 0 => [select1, select2, select3, select4] // contains queries for varchar & text & int + * 1 => [select5] // contains queries for bool + * ] + * * @param array $selects * @return array */ public function getLoadAttributesSelectGroups($selects) { $mainGroup = []; - foreach ($selects as $selectGroup) { - $mainGroup = array_merge($mainGroup, $selectGroup); + + foreach ($selects as $dataType => $selectGroup) { + if (in_array($dataType, $this->_groupableTypes)) { + $mainGroup['all'][] = $selectGroup; + continue; + } + + $mainGroup[$dataType] = $selectGroup; } - return $mainGroup; - } - public function mergeToOneGroup($selects) - { - return [$this->getLoadAttributesSelectGroups($selects)]; + if (array_key_exists('all', $mainGroup)) { + // it is better to call array_merge once after loop instead of calling it on each loop + $mainGroup['all'] = array_merge(...$mainGroup['all']); + } + + return array_values($mainGroup); } } From c3aa634899214be262b7cae8faf902dcd3fff3ee Mon Sep 17 00:00:00 2001 From: Andrii Voskoboinikov <avoskoboinikov@magento.com> Date: Tue, 12 Jun 2018 18:58:23 +0300 Subject: [PATCH 119/206] MAGETWO-92693: Some improvements on product create|edit page in admin area --- .../Product/Form/Modifier/Eav.php | 52 +++++-------------- 1 file changed, 13 insertions(+), 39 deletions(-) diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php index 3a698200f8d78..d6103e18c6e36 100755 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php @@ -194,6 +194,11 @@ class Eav extends AbstractModifier */ private $attributesCache = []; + /** + * @var AttributeCollectionFactory + */ + private $attributeCollectionFactory; + /** * @param LocatorInterface $locator * @param CatalogEavValidationRules $catalogEavValidationRules @@ -214,6 +219,7 @@ class Eav extends AbstractModifier * @param DataPersistorInterface $dataPersistor * @param array $attributesToDisable * @param array $attributesToEliminate + * @param AttributeCollectionFactory $attributeCollectionFactory * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -257,8 +263,8 @@ public function __construct( $this->dataPersistor = $dataPersistor; $this->attributesToDisable = $attributesToDisable; $this->attributesToEliminate = $attributesToEliminate; - $this->attributeCollectionFactory = $attributeCollectionFactory ?: \Magento\Framework\App\ObjectManager::getInstance() - ->get(AttributeCollectionFactory::class); + $this->attributeCollectionFactory = $attributeCollectionFactory + ?: \Magento\Framework\App\ObjectManager::getInstance()->get(AttributeCollectionFactory::class); } /** @@ -502,37 +508,8 @@ private function getAttributes() } /** - * Loading product attributes from group + * Loads attributes for specified groups at once * - * @param AttributeGroupInterface $group - * @return ProductAttributeInterface[] - */ - private function loadAttributes(AttributeGroupInterface $group) - { - $attributes = []; - $sortOrder = $this->sortOrderBuilder - ->setField('sort_order') - ->setAscendingDirection() - ->create(); - $searchCriteria = $this->searchCriteriaBuilder - ->addFilter(AttributeGroupInterface::GROUP_ID, $group->getAttributeGroupId()) - ->addFilter(ProductAttributeInterface::IS_VISIBLE, 1) - ->addSortOrder($sortOrder) - ->create(); - $groupAttributes = $this->attributeRepository->getList($searchCriteria)->getItems(); - $productType = $this->getProductType(); - foreach ($groupAttributes as $attribute) { - $applyTo = $attribute->getApplyTo(); - $isRelated = !$applyTo || in_array($productType, $applyTo); - if ($isRelated) { - $attributes[] = $attribute; - } - } - - return $attributes; - } - - /** * @param AttributeGroupInterface[] ...$groups * @return @return ProductAttributeInterface[] */ @@ -541,7 +518,6 @@ private function loadAttributesForGroups(array $groups) $attributes = []; $groupIds = []; - // foreach just works faster than array_walk() or array_column() foreach ($groups as $group) { $groupIds[$group->getAttributeGroupId()] = $this->calculateGroupCode($group); $attributes[$this->calculateGroupCode($group)] = []; @@ -550,12 +526,10 @@ private function loadAttributesForGroups(array $groups) $collection = $this->attributeCollectionFactory->create(); $collection->setAttributeGroupFilter(array_keys($groupIds)); - $attrs = $collection->getItems(); - - $map = []; + $mapAttributeToGroup = []; - foreach ($attrs as $a) { - $map[$a->getAttributeId()] = $a->getAttributeGroupId(); + foreach ($collection->getItems() as $attribute) { + $mapAttributeToGroup[$attribute->getAttributeId()] = $attribute->getAttributeGroupId(); } $sortOrder = $this->sortOrderBuilder @@ -577,7 +551,7 @@ private function loadAttributesForGroups(array $groups) $applyTo = $attribute->getApplyTo(); $isRelated = !$applyTo || in_array($productType, $applyTo); if ($isRelated) { - $attributeGroupId = $map[$attribute->getAttributeId()]; + $attributeGroupId = $mapAttributeToGroup[$attribute->getAttributeId()]; $attributeGroupCode = $groupIds[$attributeGroupId]; $attributes[$attributeGroupCode][] = $attribute; } From 278b7dde3117a219ac011906da49781bfe5e0d41 Mon Sep 17 00:00:00 2001 From: Michail Slabko <mslabko@magento.com> Date: Tue, 12 Jun 2018 20:50:19 +0300 Subject: [PATCH 120/206] MAGETWO-92394: Implement partial reindex - MAGETWO-64467 [Indexer optimizations] Tables sharding / segmentation for price indexer --- .../Indexer/Product/Price/AbstractAction.php | 93 +++++++------------ .../Indexer/Product/Price/TableMaintainer.php | 10 +- 2 files changed, 40 insertions(+), 63 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php index d2d64bd2ea0bb..19e076c0a2f1c 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php @@ -161,6 +161,8 @@ abstract public function execute($ids); * * @param array $processIds * @return \Magento\Catalog\Model\Indexer\Product\Price\AbstractAction + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @deprecated Used only for backward compatibility for indexer, which not support indexation by dimensions */ protected function _syncData(array $processIds = []) { @@ -172,33 +174,15 @@ protected function _syncData(array $processIds = []) ['ip_tmp' => $this->_defaultIndexerResource->getIdxTable()] ); - // delete invalid rows - $select = $this->_connection->select()->from( - ['index_price' => $this->tableMaintainer->getMainTable($dimensions)], - null - )->joinLeft( - ['ip_tmp' => $this->_defaultIndexerResource->getIdxTable()], - 'index_price.entity_id = ip_tmp.entity_id AND index_price.website_id = ip_tmp.website_id', - [] - )->where( - 'ip_tmp.entity_id IS NULL' - ); - if (!empty($processIds)) { - $select->where('index_price.entity_id IN(?)', $processIds); - } foreach ($dimensions as $dimension) { if ($dimension->getName() === WebsiteDataProvider::DIMENSION_NAME) { - $select->where('ip_tmp.website_id = ?', $dimension->getValue()); $insertSelect->where('ip_tmp.website_id = ?', $dimension->getValue()); } if ($dimension->getName() === CustomerGroupDataProvider::DIMENSION_NAME) { - $select->where('ip_tmp.customer_group_id = ?', $dimension->getValue()); $insertSelect->where('ip_tmp.customer_group_id = ?', $dimension->getValue()); } } - $query = $select->deleteFromSelect('index_price'); - $this->_connection->query($query); $query = $insertSelect->insertFromSelect($this->tableMaintainer->getMainTable($dimensions)); $this->_connection->query($query); @@ -206,41 +190,6 @@ protected function _syncData(array $processIds = []) return $this; } - - /** - * Synchronize data between index storage and original storage - * - * @param array $dimensions - * @param array $processIds - * @return \Magento\Catalog\Model\Indexer\Product\Price\AbstractAction - * @throws \Exception - */ - private function syncDataByDimensions(array $dimensions, array $processIds = []) - { - // delete invalid rows - $select = $this->_connection->select()->from( - ['index_price' => $this->tableMaintainer->getMainTable($dimensions)], - null - )->joinLeft( - ['ip_tmp' => $this->tableMaintainer->getMainTmpTable($dimensions)], - 'index_price.entity_id = ip_tmp.entity_id AND index_price.website_id = ip_tmp.website_id', - [] - )->where( - 'ip_tmp.entity_id IS NULL' - ); - if (!empty($processIds)) { - $select->where('index_price.entity_id IN(?)', $processIds); - } - $sql = $select->deleteFromSelect('index_price'); - $this->_connection->query($sql); - - $this->_insertFromTable( - $this->tableMaintainer->getMainTmpTable($dimensions), - $this->tableMaintainer->getMainTable($dimensions) - ); - return $this; - } - /** * Prepare website current dates table * @@ -423,11 +372,17 @@ protected function _reindexRows($changedIds = []) $dimensionsProviders = $this->dimensionCollectionFactory->createByMode($this->getCurrentMode()); foreach ($dimensionsProviders as $dimensions) { $this->tableMaintainer->createMainTmpTable($dimensions); - $this->_emptyTable($this->tableMaintainer->getMainTmpTable($dimensions)); + $temporaryTable = $this->tableMaintainer->getMainTmpTable($dimensions); + $this->_emptyTable($temporaryTable); $indexer->executeByDimension($dimensions, \SplFixedArray::fromArray($entityIds, false)); - $this->syncDataByDimensions($dimensions, $entityIds); + // copy to index + $this->_insertFromTable( + $temporaryTable, + $this->tableMaintainer->getMainTable($dimensions) + ); } } else { + // handle 3d-party indexers for backward compatibility $this->_emptyTable($this->_defaultIndexerResource->getIdxTable()); $this->_copyRelationIndexData($entityIds); $indexer->reindexEntity($entityIds); @@ -435,17 +390,41 @@ protected function _reindexRows($changedIds = []) } } + if (!$productsTypes && $changedIds) { + $this->deleteIndexData($changedIds); + } + return $changedIds; } + /** + * @param array $entityIds + * @return void + */ + private function deleteIndexData(array $entityIds) + { + $dimensionsProviders = $this->dimensionCollectionFactory->createByMode($this->getCurrentMode()); + + foreach ($dimensionsProviders as $dimensions) { + $select = $this->_connection->select()->from( + ['index_price' => $this->tableMaintainer->getMainTable($dimensions)], + null + )->where('index_price.entity_id IN (?)', $entityIds); + $query = $select->deleteFromSelect('index_price'); + $this->_connection->query($query); + } + } + /** * Copy relations product index from primary index to temporary index table by parent entity * * @param null|array $parentIds * @param array $excludeIds * @return \Magento\Catalog\Model\Indexer\Product\Price\AbstractAction - * @deprecated Not used anymore. All composite products read data directly from main price indexer table or replica - * table for partial or full reindex correspondingly + * @deprecated Used only for backward compatibility for do not broke custom indexer implementation + * which do not work by dimensions. + * For indexers, which support dimensions all composite products read data directly from main price indexer table + * or replica table for partial or full reindex correspondingly. * @see \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\DefaultPrice::getIndexTableForCompositeProducts */ protected function _copyRelationIndexData($parentIds, $excludeIds = null) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php index 55214e07c79e3..cb9c633017bed 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php @@ -247,12 +247,10 @@ public function getMainReplicaTable(array $dimensions): string */ public function createMainTmpTable(array $dimensions) { - if (!isset($this->mainTmpTable[$this->getArrayKeyForTmpTable($dimensions)])) { - $originTableName = $this->getMainTable($dimensions); - $temporaryTableName = $this->getMainTable($dimensions) . $this->tmpTableSuffix; - $this->getConnection()->createTemporaryTableLike($temporaryTableName, $originTableName, true); - $this->mainTmpTable[$this->getArrayKeyForTmpTable($dimensions)] = $temporaryTableName; - } + $originTableName = $this->getMainTable($dimensions); + $temporaryTableName = $this->getMainTable($dimensions) . $this->tmpTableSuffix; + $this->getConnection()->createTemporaryTableLike($temporaryTableName, $originTableName, true); + $this->mainTmpTable[$this->getArrayKeyForTmpTable($dimensions)] = $temporaryTableName; } /** From bc871ed32539da97189fa102e18d9e119911d539 Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov <slopukhov@magento.com> Date: Wed, 13 Jun 2018 09:55:11 +0300 Subject: [PATCH 121/206] MAGETWO-91820: Stabilize builds --- .../Indexer/Product/Price/AbstractAction.php | 4 +-- .../Product/Price/PriceTableResolver.php | 2 +- .../ResourceModel/Layer/Filter/Price.php | 7 ++-- .../Price/CustomOptionPriceModifier.php | 8 +++-- .../Product/Indexer/Price/DefaultPrice.php | 31 +++++++++++----- .../Indexer/Price/Query/BaseFinalPrice.php | 36 +++++++++++++------ ...edProductSelectBuilderByIndexPriceTest.php | 3 ++ .../Aggregation/DataProvider/QueryBuilder.php | 4 ++- .../Adapter/Mysql/Dynamic/DataProvider.php | 4 ++- .../Search/FilterMapper/ExclusionStrategy.php | 6 +++- .../DataProvider/QueryBuilderTest.php | 4 ++- .../FilterMapper/ExclusionStrategyTest.php | 3 ++ .../CustomerGroupDataProvider.php | 3 +- .../MultiDimensional/WebsiteDataProvider.php | 3 +- .../Indexer/DimensionProviderInterface.php | 6 ++-- .../Indexer/DimensionalIndexerInterface.php | 2 +- .../MultiDimensionProviderInterface.php | 6 ++-- 17 files changed, 90 insertions(+), 42 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php index 19e076c0a2f1c..05818fbcf962f 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php @@ -110,6 +110,7 @@ abstract class AbstractAction * @param DimensionProviderFactory|null $dimensionCollectionFactory * @param TableMaintainer|null $tableMaintainer * @param \Magento\Framework\App\Config\ScopeConfigInterface|null $configReader + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $config, @@ -185,7 +186,6 @@ protected function _syncData(array $processIds = []) $query = $insertSelect->insertFromSelect($this->tableMaintainer->getMainTable($dimensions)); $this->_connection->query($query); - } return $this; } @@ -426,7 +426,7 @@ private function deleteIndexData(array $entityIds) * For indexers, which support dimensions all composite products read data directly from main price indexer table * or replica table for partial or full reindex correspondingly. * @see \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\DefaultPrice::getIndexTableForCompositeProducts - */ + */ protected function _copyRelationIndexData($parentIds, $excludeIds = null) { $linkField = $this->getProductIdFieldName(); diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php index 064969f615295..2b560981fe96a 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php @@ -51,7 +51,7 @@ public function resolve($index, array $dimensions) private function getMixDimensions($dimensions): array { $existDimensions = []; - foreach ($dimensions as $key => $dimension) { + foreach ($dimensions as $dimension) { $existDimensions[$dimension->getName()] = $dimension; } diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Layer/Filter/Price.php b/app/code/Magento/Catalog/Model/ResourceModel/Layer/Filter/Price.php index 8eba0ce1c138c..263c104027090 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Layer/Filter/Price.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Layer/Filter/Price.php @@ -152,11 +152,8 @@ protected function _getSelect() // remove join with main table $fromPart = $select->getPart(\Magento\Framework\DB\Select::FROM); - if (!isset( - $fromPart[\Magento\Catalog\Model\ResourceModel\Product\Collection::INDEX_TABLE_ALIAS] - ) || !isset( - $fromPart[\Magento\Catalog\Model\ResourceModel\Product\Collection::MAIN_TABLE_ALIAS] - ) + if (!isset($fromPart[\Magento\Catalog\Model\ResourceModel\Product\Collection::INDEX_TABLE_ALIAS]) || + !isset($fromPart[\Magento\Catalog\Model\ResourceModel\Product\Collection::MAIN_TABLE_ALIAS]) ) { return $select; } diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/CustomOptionPriceModifier.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/CustomOptionPriceModifier.php index ef202e249e54a..8861ab9ed8e80 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/CustomOptionPriceModifier.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/CustomOptionPriceModifier.php @@ -11,7 +11,6 @@ use Magento\Framework\DB\Select; use Magento\Framework\DB\Sql\ColumnValueExpression; - /** * Class for adding catalog rule prices to price index table. */ @@ -88,6 +87,7 @@ public function __construct( * @param array $entityIds * @return void * @throws \Exception + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function modifyPrice(IndexTableStructure $priceTable, array $entityIds = []) { @@ -217,7 +217,11 @@ private function getSelectForOptionsWithMultipleValues(string $sourceTable): Sel [] ); - $optPriceType = $connection->getCheckSql('otps.option_type_price_id > 0', 'otps.price_type', 'otpd.price_type'); + $optPriceType = $connection->getCheckSql( + 'otps.option_type_price_id > 0', + 'otps.price_type', + 'otpd.price_type' + ); $optPriceValue = $connection->getCheckSql('otps.option_type_price_id > 0', 'otps.price', 'otpd.price'); } diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php index a79733371a7ec..72edd12fedf23 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php @@ -67,8 +67,8 @@ class DefaultPrice extends AbstractIndexer implements PriceInterface private $priceModifiers = []; /** - * @var \Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher - */ + * @var \Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher + */ private $activeTableSwitcher; /** @@ -372,27 +372,36 @@ protected function getSelect($entityIds = null, $type = null) )->joinLeft( // we need this only for BCC in case someone expects table `tp` to be present in query ['tp' => $this->getTable('catalog_product_index_tier_price')], - 'tp.entity_id = e.entity_id AND tp.customer_group_id = cg.customer_group_id AND tp.website_id = pw.website_id', + 'tp.entity_id = e.entity_id AND tp.customer_group_id = cg.customer_group_id' . + ' AND tp.website_id = pw.website_id', [] )->joinLeft( // calculate tier price specified as Website = `All Websites` and Customer Group = `Specific Customer Group` ['tier_price_1' => $this->getTable('catalog_product_entity_tier_price')], - 'tier_price_1.' . $linkField . ' = e.' . $linkField . ' AND tier_price_1.all_groups = 0 AND tier_price_1.customer_group_id = cg.customer_group_id AND tier_price_1.qty = 1 AND tier_price_1.website_id = 0', + 'tier_price_1.' . $linkField . ' = e.' . $linkField . ' AND tier_price_1.all_groups = 0' . + ' AND tier_price_1.customer_group_id = cg.customer_group_id AND tier_price_1.qty = 1' . + ' AND tier_price_1.website_id = 0', [] )->joinLeft( - // calculate tier price specified as Website = `Specific Website` and Customer Group = `Specific Customer Group` + // calculate tier price specified as Website = `Specific Website` + //and Customer Group = `Specific Customer Group` ['tier_price_2' => $this->getTable('catalog_product_entity_tier_price')], - 'tier_price_2.' . $linkField . ' = e.' . $linkField . ' AND tier_price_2.all_groups = 0 AND tier_price_2.customer_group_id = cg.customer_group_id AND tier_price_2.qty = 1 AND tier_price_2.website_id = cw.website_id', + 'tier_price_2.' . $linkField . ' = e.' . $linkField . ' AND tier_price_2.all_groups = 0' . + ' AND tier_price_2.customer_group_id = cg.customer_group_id AND tier_price_2.qty = 1' . + ' AND tier_price_2.website_id = cw.website_id', [] )->joinLeft( // calculate tier price specified as Website = `All Websites` and Customer Group = `ALL GROUPS` ['tier_price_3' => $this->getTable('catalog_product_entity_tier_price')], - 'tier_price_3.' . $linkField . ' = e.' . $linkField . ' AND tier_price_3.all_groups = 1 AND tier_price_3.customer_group_id = 0 AND tier_price_3.qty = 1 AND tier_price_3.website_id = 0', + 'tier_price_3.' . $linkField . ' = e.' . $linkField . ' AND tier_price_3.all_groups = 1' . + ' AND tier_price_3.customer_group_id = 0 AND tier_price_3.qty = 1 AND tier_price_3.website_id = 0', [] )->joinLeft( // calculate tier price specified as Website = `Specific Website` and Customer Group = `ALL GROUPS` ['tier_price_4' => $this->getTable('catalog_product_entity_tier_price')], - 'tier_price_4.' . $linkField . ' = e.' . $linkField . ' AND tier_price_4.all_groups = 1 AND tier_price_4.customer_group_id = 0 AND tier_price_4.qty = 1 AND tier_price_4.website_id = cw.website_id', + 'tier_price_4.' . $linkField . ' = e.' . $linkField . ' AND tier_price_4.all_groups = 1' . + ' AND tier_price_4.customer_group_id = 0 AND tier_price_4.qty = 1' . + ' AND tier_price_4.website_id = cw.website_id', [] ); @@ -889,7 +898,11 @@ private function getTierPriceExpressionForTable($tableAlias, \Zend_Db_Expr $pric { return $this->getConnection()->getCheckSql( sprintf('%s.value = 0', $tableAlias), - sprintf('ROUND(%s * (1 - ROUND(%s.percentage_value * cwd.rate, 4) / 100), 4)', $priceExpression, $tableAlias), + sprintf( + 'ROUND(%s * (1 - ROUND(%s.percentage_value * cwd.rate, 4) / 100), 4)', + $priceExpression, + $tableAlias + ), sprintf('ROUND(%s.value * cwd.rate, 4)', $tableAlias) ); } diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php index 5418f717231a9..7da924481bfa0 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php @@ -17,6 +17,7 @@ /** * Prepare base select for Product Price index limited by specified dimensions: website and customer group + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class BaseFinalPrice { @@ -126,27 +127,36 @@ public function getQuery(array $dimensions, string $productType, array $entityId )->joinLeft( // we need this only for BCC in case someone expects table `tp` to be present in query ['tp' => $this->getTable('catalog_product_index_tier_price')], - 'tp.entity_id = e.entity_id AND tp.customer_group_id = cg.customer_group_id AND tp.website_id = pw.website_id', + 'tp.entity_id = e.entity_id AND' . + ' tp.customer_group_id = cg.customer_group_id AND tp.website_id = pw.website_id', [] )->joinLeft( // calculate tier price specified as Website = `All Websites` and Customer Group = `Specific Customer Group` ['tier_price_1' => $this->getTable('catalog_product_entity_tier_price')], - 'tier_price_1.' . $linkField . ' = e.' . $linkField . ' AND tier_price_1.all_groups = 0 AND tier_price_1.customer_group_id = cg.customer_group_id AND tier_price_1.qty = 1 AND tier_price_1.website_id = 0', + 'tier_price_1.' . $linkField . ' = e.' . $linkField . ' AND tier_price_1.all_groups = 0' . + ' AND tier_price_1.customer_group_id = cg.customer_group_id AND tier_price_1.qty = 1' . + ' AND tier_price_1.website_id = 0', [] )->joinLeft( - // calculate tier price specified as Website = `Specific Website` and Customer Group = `Specific Customer Group` + // calculate tier price specified as Website = `Specific Website` + //and Customer Group = `Specific Customer Group` ['tier_price_2' => $this->getTable('catalog_product_entity_tier_price')], - 'tier_price_2.' . $linkField . ' = e.' . $linkField . ' AND tier_price_2.all_groups = 0 AND tier_price_2.customer_group_id = cg.customer_group_id AND tier_price_2.qty = 1 AND tier_price_2.website_id = pw.website_id', + 'tier_price_2.' . $linkField . ' = e.' . $linkField . ' AND tier_price_2.all_groups = 0 ' . + 'AND tier_price_2.customer_group_id = cg.customer_group_id AND tier_price_2.qty = 1' . + ' AND tier_price_2.website_id = pw.website_id', [] )->joinLeft( // calculate tier price specified as Website = `All Websites` and Customer Group = `ALL GROUPS` ['tier_price_3' => $this->getTable('catalog_product_entity_tier_price')], - 'tier_price_3.' . $linkField . ' = e.' . $linkField . ' AND tier_price_3.all_groups = 1 AND tier_price_3.customer_group_id = 0 AND tier_price_3.qty = 1 AND tier_price_3.website_id = 0', + 'tier_price_3.' . $linkField . ' = e.' . $linkField . ' AND tier_price_3.all_groups = 1 ' . + 'AND tier_price_3.customer_group_id = 0 AND tier_price_3.qty = 1 AND tier_price_3.website_id = 0', [] )->joinLeft( // calculate tier price specified as Website = `Specific Website` and Customer Group = `ALL GROUPS` ['tier_price_4' => $this->getTable('catalog_product_entity_tier_price')], - 'tier_price_4.' . $linkField . ' = e.' . $linkField . ' AND tier_price_4.all_groups = 1 AND tier_price_4.customer_group_id = 0 AND tier_price_4.qty = 1 AND tier_price_4.website_id = pw.website_id', + 'tier_price_4.' . $linkField . ' = e.' . $linkField . ' AND tier_price_4.all_groups = 1' . + ' AND tier_price_4.customer_group_id = 0 AND tier_price_4.qty = 1' . + ' AND tier_price_4.website_id = pw.website_id', [] ); @@ -160,7 +170,7 @@ public function getQuery(array $dimensions, string $productType, array $entityId } if ($this->moduleManager->isEnabled('Magento_Tax')) { - $taxClassId = $this->joinAttributeProcessor->process($select,'tax_class_id'); + $taxClassId = $this->joinAttributeProcessor->process($select, 'tax_class_id'); } else { $taxClassId = new \Zend_Db_Expr(0); } @@ -194,8 +204,10 @@ public function getQuery(array $dimensions, string $productType, array $entityId $select->columns( [ - 'price' => $connection->getIfNullSql($price, 0), //orig_price in catalog_product_index_price_final_tmp - 'final_price' => $connection->getIfNullSql($finalPrice, 0), //price in catalog_product_index_price_final_tmp + //orig_price in catalog_product_index_price_final_tmp + 'price' => $connection->getIfNullSql($price, 0), + //price in catalog_product_index_price_final_tmp + 'final_price' => $connection->getIfNullSql($finalPrice, 0), 'min_price' => $connection->getIfNullSql($finalPrice, 0), 'max_price' => $connection->getIfNullSql($finalPrice, 0), 'tier_price' => $tierPrice, @@ -268,7 +280,11 @@ private function getTierPriceExpressionForTable($tableAlias, \Zend_Db_Expr $pric { return $this->getConnection()->getCheckSql( sprintf('%s.value = 0', $tableAlias), - sprintf('ROUND(%s * (1 - ROUND(%s.percentage_value * cwd.rate, 4) / 100), 4)', $priceExpression, $tableAlias), + sprintf( + 'ROUND(%s * (1 - ROUND(%s.percentage_value * cwd.rate, 4) / 100), 4)', + $priceExpression, + $tableAlias + ), sprintf('ROUND(%s.value * cwd.rate, 4)', $tableAlias) ); } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/LinkedProductSelectBuilderByIndexPriceTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/LinkedProductSelectBuilderByIndexPriceTest.php index be9ae1af079f1..6f3d8e1a84b17 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/LinkedProductSelectBuilderByIndexPriceTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/LinkedProductSelectBuilderByIndexPriceTest.php @@ -7,6 +7,9 @@ use Magento\Catalog\Model\ResourceModel\Product\BaseSelectProcessorInterface; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class LinkedProductSelectBuilderByIndexPriceTest extends \PHPUnit\Framework\TestCase { /** diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Aggregation/DataProvider/QueryBuilder.php b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Aggregation/DataProvider/QueryBuilder.php index f203493ddfc58..f0443cd4c2614 100644 --- a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Aggregation/DataProvider/QueryBuilder.php +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Aggregation/DataProvider/QueryBuilder.php @@ -22,7 +22,9 @@ use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; /** - * Attribute query builder + * Attribute query builder + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class QueryBuilder { diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Dynamic/DataProvider.php b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Dynamic/DataProvider.php index 58cce85173f63..b382e2f0a3897 100644 --- a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Dynamic/DataProvider.php +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Dynamic/DataProvider.php @@ -99,7 +99,9 @@ public function __construct( $this->dataProvider = $dataProvider; $this->intervalFactory = $intervalFactory; $this->storeManager = $storeManager ?: ObjectManager::getInstance()->get(StoreManager::class); - $this->priceTableResolver = $priceTableResolver ?: ObjectManager::getInstance()->get(IndexScopeResolverInterface::class); + $this->priceTableResolver = $priceTableResolver ?: ObjectManager::getInstance()->get( + IndexScopeResolverInterface::class + ); $this->dimensionFactory = $dimensionFactory ?: ObjectManager::getInstance()->get(DimensionFactory::class); } diff --git a/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/ExclusionStrategy.php b/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/ExclusionStrategy.php index c3ef6290f62a0..cd2dd0a7f9e26 100644 --- a/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/ExclusionStrategy.php +++ b/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/ExclusionStrategy.php @@ -20,6 +20,8 @@ /** * Strategy which processes exclusions from general rules + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class ExclusionStrategy implements FilterStrategyInterface { @@ -87,7 +89,9 @@ public function __construct( $this->aliasResolver = $aliasResolver; $this->tableResolver = $tableResolver ?: ObjectManager::getInstance()->get(TableResolver::class); $this->dimensionFactory = $dimensionFactory ?: ObjectManager::getInstance()->get(DimensionFactory::class); - $this->priceTableResolver = $priceTableResolver ?: ObjectManager::getInstance()->get(IndexScopeResolverInterface::class); + $this->priceTableResolver = $priceTableResolver ?: ObjectManager::getInstance()->get( + IndexScopeResolverInterface::class + ); $this->httpContext = $httpContext ?: ObjectManager::getInstance()->get(Context::class); } diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Aggregation/DataProvider/QueryBuilderTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Aggregation/DataProvider/QueryBuilderTest.php index 85308187cbbd9..72379c3819dea 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Aggregation/DataProvider/QueryBuilderTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Aggregation/DataProvider/QueryBuilderTest.php @@ -17,7 +17,9 @@ use Magento\Store\Model\Store; /** - * Test for Magento\CatalogSearch\Model\Adapter\Mysql\Aggregation\DataProvider\QueryBuilder. + * Test for Magento\CatalogSearch\Model\Adapter\Mysql\Aggregation\DataProvider\QueryBuilder. + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class QueryBuilderTest extends \PHPUnit\Framework\TestCase { diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/FilterMapper/ExclusionStrategyTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/FilterMapper/ExclusionStrategyTest.php index 409793999de20..09591532f9f06 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/FilterMapper/ExclusionStrategyTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/FilterMapper/ExclusionStrategyTest.php @@ -15,6 +15,9 @@ use Magento\Framework\Search\Request\Filter\Term; use Magento\Store\Api\Data\WebsiteInterface; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class ExclusionStrategyTest extends \PHPUnit\Framework\TestCase { /** diff --git a/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php b/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php index 879c94b101f97..72de801c78cd0 100644 --- a/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php +++ b/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php @@ -33,7 +33,8 @@ class CustomerGroupDataProvider implements DimensionProviderInterface */ private $dimensionFactory; - public function __construct(CustomerGroupCollectionFactory $collectionFactory, DimensionFactory $dimensionFactory) { + public function __construct(CustomerGroupCollectionFactory $collectionFactory, DimensionFactory $dimensionFactory) + { $this->dimensionFactory = $dimensionFactory; $this->collectionFactory = $collectionFactory; } diff --git a/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php b/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php index 305a1cbac959a..45e26eeb2203a 100644 --- a/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php +++ b/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php @@ -38,7 +38,8 @@ class WebsiteDataProvider implements DimensionProviderInterface * @param WebsiteCollectionFactory $collectionFactory * @param DimensionFactory $dimensionFactory */ - public function __construct(WebsiteCollectionFactory $collectionFactory, DimensionFactory $dimensionFactory){ + public function __construct(WebsiteCollectionFactory $collectionFactory, DimensionFactory $dimensionFactory) + { $this->dimensionFactory = $dimensionFactory; $this->collectionFactory = $collectionFactory; } diff --git a/lib/internal/Magento/Framework/Indexer/DimensionProviderInterface.php b/lib/internal/Magento/Framework/Indexer/DimensionProviderInterface.php index 992388dd33bf4..40b12912ca11f 100644 --- a/lib/internal/Magento/Framework/Indexer/DimensionProviderInterface.php +++ b/lib/internal/Magento/Framework/Indexer/DimensionProviderInterface.php @@ -13,8 +13,8 @@ interface DimensionProviderInterface extends \IteratorAggregate, \Countable { /** - * Get Dimension Iterator. Returns yielded value of \Magento\Framework\Indexer\Dimension - * @return \Traversable|\Magento\Framework\Indexer\Dimension[] - */ + * Get Dimension Iterator. Returns yielded value of \Magento\Framework\Indexer\Dimension + * @return \Traversable|\Magento\Framework\Indexer\Dimension[] + */ public function getIterator(): \Traversable; } diff --git a/lib/internal/Magento/Framework/Indexer/DimensionalIndexerInterface.php b/lib/internal/Magento/Framework/Indexer/DimensionalIndexerInterface.php index b6ee900d6220f..2c22118cda1dc 100644 --- a/lib/internal/Magento/Framework/Indexer/DimensionalIndexerInterface.php +++ b/lib/internal/Magento/Framework/Indexer/DimensionalIndexerInterface.php @@ -21,4 +21,4 @@ interface DimensionalIndexerInterface * @return void */ public function executeByDimension(array $dimensions, \Traversable $entityIds = null); -} \ No newline at end of file +} diff --git a/lib/internal/Magento/Framework/Indexer/MultiDimensionProviderInterface.php b/lib/internal/Magento/Framework/Indexer/MultiDimensionProviderInterface.php index 745bd4989a9b7..4f73e1ff79fe3 100644 --- a/lib/internal/Magento/Framework/Indexer/MultiDimensionProviderInterface.php +++ b/lib/internal/Magento/Framework/Indexer/MultiDimensionProviderInterface.php @@ -14,8 +14,8 @@ interface MultiDimensionProviderInterface extends \IteratorAggregate { /** - * Returns [\Magento\Framework\Indexer\Dimension, ...] for each iteration - * @return \Traversable|[\Magento\Framework\Indexer\Dimension,] - */ + * Returns [\Magento\Framework\Indexer\Dimension, ...] for each iteration + * @return \Traversable|[\Magento\Framework\Indexer\Dimension,] + */ public function getIterator(): \Traversable; } From 6dee2f60ce6cab8080bb6242eb97187fea535717 Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov <slopukhov@magento.com> Date: Wed, 13 Jun 2018 10:09:14 +0300 Subject: [PATCH 122/206] MAGETWO-91820: Stabilize builds --- .../Catalog/Model/Indexer/Product/Price/AbstractAction.php | 1 + .../ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php | 1 + 2 files changed, 2 insertions(+) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php index 05818fbcf962f..e59753ae9eaad 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php @@ -110,6 +110,7 @@ abstract class AbstractAction * @param DimensionProviderFactory|null $dimensionCollectionFactory * @param TableMaintainer|null $tableMaintainer * @param \Magento\Framework\App\Config\ScopeConfigInterface|null $configReader + * @SuppressWarnings(PHPMD.NPathComplexity) * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function __construct( diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php index 7da924481bfa0..0af245e87e64b 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php @@ -97,6 +97,7 @@ public function __construct( * @throws \Magento\Framework\Exception\InputException * @throws \Magento\Framework\Exception\LocalizedException * @throws \Zend_Db_Select_Exception + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function getQuery(array $dimensions, string $productType, array $entityIds = []): Select { From 90f0cb926101b1dc6ad535ce807436033fbdadc6 Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov <slopukhov@magento.com> Date: Wed, 13 Jun 2018 10:19:38 +0300 Subject: [PATCH 123/206] MAGETWO-91820: Stabilize builds --- .../Catalog/Model/Indexer/Product/Price/AbstractAction.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php index e59753ae9eaad..5d545c17883b9 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php @@ -112,6 +112,7 @@ abstract class AbstractAction * @param \Magento\Framework\App\Config\ScopeConfigInterface|null $configReader * @SuppressWarnings(PHPMD.NPathComplexity) * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $config, From a91f6b96906732dd4b478e286ea3ad8c93c16fe6 Mon Sep 17 00:00:00 2001 From: Michail Slabko <mslabko@magento.com> Date: Wed, 13 Jun 2018 11:53:46 +0300 Subject: [PATCH 124/206] MAGETWO-92394: Implement partial reindex - MAGETWO-64467 [Indexer optimizations] Tables sharding / segmentation for price indexer --- .../Catalog/Model/Indexer/Product/Price/AbstractAction.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php index 5d545c17883b9..a134a65220b74 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php @@ -368,6 +368,9 @@ protected function _reindexRows($changedIds = []) $changedIds = array_merge($changedIds, ...array_values($parentProductsTypes)); $productsTypes = array_merge_recursive($productsTypes, $parentProductsTypes); + if ($changedIds) { + $this->deleteIndexData($changedIds); + } foreach ($productsTypes as $productType => $entityIds) { $indexer = $this->_getIndexer($productType); if ($indexer instanceof DimensionalIndexerInterface) { @@ -392,10 +395,6 @@ protected function _reindexRows($changedIds = []) } } - if (!$productsTypes && $changedIds) { - $this->deleteIndexData($changedIds); - } - return $changedIds; } From ee0381a99972bf0459840d2823206993843cb38f Mon Sep 17 00:00:00 2001 From: Myroslav Dobra <dmaraptor@gmail.com> Date: Wed, 13 Jun 2018 13:18:01 +0300 Subject: [PATCH 125/206] MAGETWO-87721: Custom Options are corruputed when saving product to a different website --- .../Test/SaveProductWithCustomOptionsSecondWebsiteTest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Test/SaveProductWithCustomOptionsSecondWebsiteTest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Test/SaveProductWithCustomOptionsSecondWebsiteTest.xml index eddf551df2f3d..efd42b7f7a427 100644 --- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Test/SaveProductWithCustomOptionsSecondWebsiteTest.xml +++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Test/SaveProductWithCustomOptionsSecondWebsiteTest.xml @@ -15,7 +15,7 @@ <title value="You should be able to save a product with custom options assigned to a different website"/> <description value="Custom Options should not be split when saving the product after assigning to a different website"/> <severity value="MAJOR"/> - <testCaseId value="MAGETWO-87721"/> + <testCaseId value="MAGETWO-92749"/> <group value="product"/> </annotations> From 00b4b3baea716e90ed11220def46d651013f7deb Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov <slopukhov@magento.com> Date: Wed, 13 Jun 2018 15:19:47 +0300 Subject: [PATCH 126/206] MAGETWO-91820: Stabilize builds --- .../Catalog/Api/ProductRenderListInterfaceTest.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRenderListInterfaceTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRenderListInterfaceTest.php index 9b16e0c0a06d3..fb3ff3b134081 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRenderListInterfaceTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRenderListInterfaceTest.php @@ -7,6 +7,8 @@ use Magento\Framework\Api\FilterBuilder; use Magento\Framework\Api\SearchCriteriaBuilder; +use Magento\Framework\Api\SortOrder; +use Magento\Framework\Api\SortOrderBuilder; use Magento\TestFramework\Helper\Bootstrap; use Magento\TestFramework\TestCase\WebapiAbstract; @@ -23,7 +25,6 @@ class ProductRenderListInterfaceTest extends WebapiAbstract * @magentoApiDataFixture Magento/Catalog/_files/product_special_price.php * @dataProvider productRenderInfoProvider * @param array $expectedRenderInfo - * @param string $ids * @return void */ public function testGetList(array $expectedRenderInfo) @@ -31,6 +32,12 @@ public function testGetList(array $expectedRenderInfo) $expectedIds = [21, 31]; /** @var FilterBuilder $filterBuilder */ $filterBuilder = Bootstrap::getObjectManager()->create(FilterBuilder::class); + /** @var SortOrderBuilder $sortOrderBuilder */ + $sortOrderBuilder = Bootstrap::getObjectManager()->create(SortOrderBuilder::class); + $sortOrder = $sortOrderBuilder + ->setField('entity_id') + ->setDirection(SortOrder::SORT_ASC) + ->create(); /** @var SearchCriteriaBuilder $searchCriteriaBuilder */ $searchCriteriaBuilder = Bootstrap::getObjectManager() @@ -42,7 +49,8 @@ public function testGetList(array $expectedRenderInfo) ->setConditionType('in') ->create(); - $searchCriteriaBuilder->addFilters([$filter1]); + $searchCriteriaBuilder->addFilters([$filter1]) + ->addSortOrder($sortOrder); $searchData['search_criteria'] = $searchCriteriaBuilder->create()->__toArray(); $searchData['store_id'] = 1; From 9a8d2a8fa9203fbcb6be996f266bf7c9ecbb8603 Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi <alugovyi@magento.com> Date: Wed, 13 Jun 2018 16:22:48 +0300 Subject: [PATCH 127/206] MAGETWO-64467: [Indexer optimizations] Tables sharding / segmentation for price indexer --- .../Model/Indexer/Product/Price/PriceTableResolver.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php index 2b560981fe96a..459cdcd95096b 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php @@ -52,6 +52,10 @@ private function getMixDimensions($dimensions): array { $existDimensions = []; foreach ($dimensions as $dimension) { + if (!$dimension->getValue()) { + echo (new \Exception())->getTraceAsString(); die; + throw new \Exception('Dimension value can not be empty'); + } $existDimensions[$dimension->getName()] = $dimension; } From 66616de398258148828330ec7afe448bc45da0a5 Mon Sep 17 00:00:00 2001 From: DianaRusin <rusind95@gmail.com> Date: Wed, 13 Jun 2018 17:36:59 +0300 Subject: [PATCH 128/206] MAGETWO-88102: [Magento Cloud] Catalog_category_product_index table doesn't update after deleting category --- .../Model/Indexer/Fulltext/Model/Plugin/CategoryTest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dev/tests/integration/testsuite/Magento/CatalogSearch/Model/Indexer/Fulltext/Model/Plugin/CategoryTest.php b/dev/tests/integration/testsuite/Magento/CatalogSearch/Model/Indexer/Fulltext/Model/Plugin/CategoryTest.php index fbcd41e8b63b5..49667993377f7 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogSearch/Model/Indexer/Fulltext/Model/Plugin/CategoryTest.php +++ b/dev/tests/integration/testsuite/Magento/CatalogSearch/Model/Indexer/Fulltext/Model/Plugin/CategoryTest.php @@ -28,6 +28,9 @@ class CategoryTest extends \PHPUnit\Framework\TestCase */ private $categoryRepository; + /** + * @inheritdoc + */ protected function setUp() { $this->indexerProcessor = Bootstrap::getObjectManager()->create(Processor::class); From c4369e8de7bd89fb44df76ae7cab00121e304d2c Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi <alugovyi@magento.com> Date: Wed, 13 Jun 2018 20:53:37 +0300 Subject: [PATCH 129/206] MAGETWO-64467: [Indexer optimizations] Tables sharding / segmentation for price indexer --- .../Model/Indexer/Product/Price/PriceTableResolver.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php index 459cdcd95096b..7db25ed841eeb 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php @@ -44,7 +44,9 @@ public function __construct( */ public function resolve($index, array $dimensions) { - $dimensions = $this->getMixDimensions($dimensions); + if ($index == 'catalog_product_index_price') { + $dimensions = $this->getMixDimensions($dimensions); + } return $this->indexScopeResolver->resolve($index, $dimensions); } @@ -53,7 +55,6 @@ private function getMixDimensions($dimensions): array $existDimensions = []; foreach ($dimensions as $dimension) { if (!$dimension->getValue()) { - echo (new \Exception())->getTraceAsString(); die; throw new \Exception('Dimension value can not be empty'); } $existDimensions[$dimension->getName()] = $dimension; From 6d95cb2d952156ebdc4af31960792c0e9907571f Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi <alugovyi@magento.com> Date: Thu, 14 Jun 2018 09:59:30 +0300 Subject: [PATCH 130/206] MAGETWO-64467: [Indexer optimizations] Tables sharding / segmentation for price indexer --- .../Catalog/Model/Indexer/Product/Price/PriceTableResolver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php index 7db25ed841eeb..b4820fbe2d097 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php @@ -54,7 +54,7 @@ private function getMixDimensions($dimensions): array { $existDimensions = []; foreach ($dimensions as $dimension) { - if (!$dimension->getValue()) { + if ((string)$dimension->getValue() !== '') { throw new \Exception('Dimension value can not be empty'); } $existDimensions[$dimension->getName()] = $dimension; From 429519eb94da43f22c6557079c415237f95c9b54 Mon Sep 17 00:00:00 2001 From: Michail Slabko <mslabko@magento.com> Date: Thu, 14 Jun 2018 10:59:07 +0300 Subject: [PATCH 131/206] MAGETWO-92394: Implement partial reindex - MAGETWO-64467 [Indexer optimizations] Tables sharding / segmentation for price indexer --- .../Model/Indexer/Product/Price/PriceTableResolver.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php index b4820fbe2d097..e500da9326a64 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php @@ -54,8 +54,8 @@ private function getMixDimensions($dimensions): array { $existDimensions = []; foreach ($dimensions as $dimension) { - if ((string)$dimension->getValue() !== '') { - throw new \Exception('Dimension value can not be empty'); + if ((string)$dimension->getValue() === '') { + throw new \Exception(sprintf('Dimension value of "%s" can not be empty', $dimension->getName())); } $existDimensions[$dimension->getName()] = $dimension; } From 2f86386f29b877e2ffa4f56bb450ea6edeb55915 Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov <slopukhov@magento.com> Date: Thu, 14 Jun 2018 12:02:03 +0300 Subject: [PATCH 132/206] MAGETWO-91820: Stabilize builds --- .../ResourceModel/Product/Collection.php | 100 ++++-------------- 1 file changed, 21 insertions(+), 79 deletions(-) diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php index dd5206e4c2bb9..a399ee38849f5 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php @@ -19,11 +19,9 @@ use Magento\Framework\DB\Select; use Magento\Framework\EntityManager\MetadataPool; use Magento\Catalog\Model\Indexer\Product\Price\PriceTableResolver; -use Magento\Framework\Search\Request\IndexScopeResolverInterface; use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; use Magento\Store\Model\Store; use Magento\Catalog\Model\Indexer\Category\Product\TableMaintainer; -use Magento\Catalog\Model\Indexer\Product\Price\DimensionProviderFactory; use Magento\Framework\Indexer\DimensionFactory; /** @@ -288,21 +286,12 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Collection\Abstrac * @var PriceTableResolver */ private $priceTableResolver; - /** - * @var DimensionProviderFactory - */ - private $dimensionProviderFactory; /** * @var DimensionFactory */ private $dimensionFactory; - /** - * @var IndexScopeResolverInterface - */ - private $indexScopeResolver; - /** * Collection constructor * @param \Magento\Framework\Data\Collection\EntityFactory $entityFactory @@ -329,9 +318,7 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Collection\Abstrac * @param MetadataPool|null $metadataPool * @param TableMaintainer|null $tableMaintainer * @param PriceTableResolver|null $priceTableResolver - * @param DimensionProviderFactory|null $dimensionProviderFactory * @param DimensionFactory|null $dimensionFactory - * @param IndexScopeResolverInterface|null $indexScopeResolver * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -359,9 +346,7 @@ public function __construct( MetadataPool $metadataPool = null, TableMaintainer $tableMaintainer = null, PriceTableResolver $priceTableResolver = null, - DimensionProviderFactory $dimensionProviderFactory = null, - DimensionFactory $dimensionFactory = null, - IndexScopeResolverInterface $indexScopeResolver = null + DimensionFactory $dimensionFactory = null ) { $this->moduleManager = $moduleManager; $this->_catalogProductFlatState = $catalogProductFlatState; @@ -392,13 +377,9 @@ public function __construct( $connection ); $this->tableMaintainer = $tableMaintainer ?: ObjectManager::getInstance()->get(TableMaintainer::class); - $this->dimensionProviderFactory = $dimensionProviderFactory - ?: ObjectManager::getInstance()->get(DimensionProviderFactory::class); $this->priceTableResolver = $priceTableResolver ?: ObjectManager::getInstance()->get(PriceTableResolver::class); $this->dimensionFactory = $dimensionFactory ?: ObjectManager::getInstance()->get(DimensionFactory::class); - $this->indexScopeResolver = $indexScopeResolver - ?: ObjectManager::getInstance()->get(IndexScopeResolverInterface::class); } /** @@ -1900,7 +1881,7 @@ protected function _productLimitationJoinPrice() protected function _productLimitationPrice($joinLeft = false) { $filters = $this->_productLimitationFilters; - if (!$filters->isUsingPriceIndex()) { + if (!$filters->isUsingPriceIndex() || !$filters['website_id'] || !$filters['customer_group_id']) { return $this; } @@ -1936,32 +1917,27 @@ protected function _productLimitationPrice($joinLeft = false) 'tier_price', ]; - $joinFunction = $joinLeft - ? function ($tableName) use ($select, $joinLeft, $joinCond, $colls) { - $select->joinLeft($tableName, $joinCond, $colls); - } - : function ($tableName) use ($select, $joinLeft, $joinCond, $colls) { - $select->join($tableName, $joinCond, $colls); - }; - - if (isset($this->_productLimitationFilters['customer_group_id']) - || isset($this->_productLimitationFilters['website_id']) - ) { - $dimensions = $this->makeCurrentDimensions(); - - $tableName = [ - 'price_index' => $this->priceTableResolver->resolve( - 'catalog_product_index_price', - $dimensions - ) - ]; - $joinFunction($tableName); + $tableName = [ + 'price_index' => $this->priceTableResolver->resolve( + 'catalog_product_index_price', + [ + $this->dimensionFactory->create( + CustomerGroupDataProvider::DIMENSION_NAME, + $filters['customer_group_id'] + ), + $this->dimensionFactory->create( + WebsiteDataProvider::DIMENSION_NAME, + $filters['website_id'] + ) + ] + ) + ]; + + if ($joinLeft) { + $select->joinLeft($tableName, $joinCond, $colls); } else { - //handle rare case when price index is used on backend area where website/customer group is not passed. - $tableName = ['price_index' => $this->indexScopeResolver->resolve('catalog_product_index_price', [])]; - $joinFunction($tableName); + $select->join($tableName, $joinCond, $colls); } - // Set additional field filters foreach ($this->_priceDataFieldFilters as $filterData) { $select->where(call_user_func_array('sprintf', $filterData)); @@ -2466,38 +2442,4 @@ public function getPricesCount() return $this->_pricesCount; } - - /** - * @return array - */ - private function makeCurrentDimensions(): array - { - $dimensions = []; - - if (isset($this->_productLimitationFilters['customer_group_id'])) { - $dimensions[] = $this->dimensionFactory->create( - CustomerGroupDataProvider::DIMENSION_NAME, - $this->_productLimitationFilters['customer_group_id'] - ); - } else { - $dimensions[] = $this->dimensionFactory->create( - CustomerGroupDataProvider::DIMENSION_NAME, - $this->_customerSession->getCustomerGroupId() - ); - } - - if (isset($this->_productLimitationFilters['website_id'])) { - $dimensions[] = $this->dimensionFactory->create( - WebsiteDataProvider::DIMENSION_NAME, - $this->_productLimitationFilters['website_id'] - ); - } else { - $dimensions[] = $this->dimensionFactory->create( - WebsiteDataProvider::DIMENSION_NAME, - $this->_storeManager->getStore($this->getStoreId())->getWebsiteId() - ); - } - - return $dimensions; - } } From 9d29cbb2fd08da9c7d4b9422643db974551b0865 Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov <slopukhov@magento.com> Date: Thu, 14 Jun 2018 12:34:05 +0300 Subject: [PATCH 133/206] MAGETWO-91820: Stabilize builds --- .../Model/Indexer/Product/Price/Plugin/CustomerGroup.php | 4 +++- .../Catalog/Model/Indexer/Product/Price/Plugin/Website.php | 2 +- .../Catalog/Model/ResourceModel/Product/Collection.php | 4 ++-- .../Indexer/LinkedProductSelectBuilderByIndexPrice.php | 7 +++++-- .../Mysql/Aggregation/DataProvider/QueryBuilder.php | 4 ++-- .../Model/Adapter/Mysql/Dynamic/DataProvider.php | 4 ++-- .../Model/Search/FilterMapper/ExclusionStrategy.php | 2 +- .../Indexer/MultiDimensional/CustomerGroupDataProvider.php | 2 +- .../Model/Indexer/MultiDimensional/WebsiteDataProvider.php | 2 +- 9 files changed, 18 insertions(+), 13 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CustomerGroup.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CustomerGroup.php index e0dd908f0dd3f..1e2fd7422f42e 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CustomerGroup.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CustomerGroup.php @@ -129,7 +129,9 @@ private function getAffectedDimensions(int $groupId): array switch ($this->configReader->getValue(ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE)) { case ModeSwitcher::INPUT_KEY_CUSTOMER_GROUP: - $return[] = [$this->dimensionFactory->create(CustomerGroupDataProvider::DIMENSION_NAME, $groupId)]; + $return[] = [ + $this->dimensionFactory->create(CustomerGroupDataProvider::DIMENSION_NAME, (string)$groupId) + ]; break; case ModeSwitcher::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP: $websiteIds = $this->websiteCollectionFactory->create() diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/Website.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/Website.php index d8ae250e37f9a..815660140529d 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/Website.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/Website.php @@ -112,7 +112,7 @@ private function getAffectedDimensions(int $websiteId): array switch ($this->configReader->getValue(ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE)) { case ModeSwitcher::INPUT_KEY_WEBSITE: - $return[] = [$this->dimensionFactory->create(WebsiteDataProvider::DIMENSION_NAME, $websiteId)]; + $return[] = [$this->dimensionFactory->create(WebsiteDataProvider::DIMENSION_NAME, (string)$websiteId)]; break; case ModeSwitcher::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP: $customerGroupIds = $this->customerGroupCollectionFactory->create()->getAllIds(); diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php index a399ee38849f5..9ed2e892994a7 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php @@ -1923,11 +1923,11 @@ protected function _productLimitationPrice($joinLeft = false) [ $this->dimensionFactory->create( CustomerGroupDataProvider::DIMENSION_NAME, - $filters['customer_group_id'] + (string)$filters['customer_group_id'] ), $this->dimensionFactory->create( WebsiteDataProvider::DIMENSION_NAME, - $filters['website_id'] + (string)$filters['website_id'] ) ] ) diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/LinkedProductSelectBuilderByIndexPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/LinkedProductSelectBuilderByIndexPrice.php index f0558d6414267..09ce46e47b05a 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/LinkedProductSelectBuilderByIndexPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/LinkedProductSelectBuilderByIndexPrice.php @@ -105,8 +105,11 @@ public function build($productId) )->joinInner( [ 't' => $this->priceTableResolver->resolve('catalog_product_index_price', [ - $this->dimensionFactory->create(WebsiteDataProvider::DIMENSION_NAME, $websiteId), - $this->dimensionFactory->create(CustomerGroupDataProvider::DIMENSION_NAME, $customerGroupId), + $this->dimensionFactory->create(WebsiteDataProvider::DIMENSION_NAME, (string)$websiteId), + $this->dimensionFactory->create( + CustomerGroupDataProvider::DIMENSION_NAME, + (string)$customerGroupId + ), ]) ], sprintf('t.entity_id = %s.entity_id', BaseSelectProcessorInterface::PRODUCT_TABLE_ALIAS), diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Aggregation/DataProvider/QueryBuilder.php b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Aggregation/DataProvider/QueryBuilder.php index f0443cd4c2614..26c5dd5f9b7fd 100644 --- a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Aggregation/DataProvider/QueryBuilder.php +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Aggregation/DataProvider/QueryBuilder.php @@ -129,8 +129,8 @@ private function buildQueryForPriceAttribute( $tableName = $this->priceTableResolver->resolve( 'catalog_product_index_price', [ - $this->dimensionFactory->create(WebsiteDataProvider::DIMENSION_NAME, $websiteId), - $this->dimensionFactory->create(CustomerGroupDataProvider::DIMENSION_NAME, $customerGroupId), + $this->dimensionFactory->create(WebsiteDataProvider::DIMENSION_NAME, (string)$websiteId), + $this->dimensionFactory->create(CustomerGroupDataProvider::DIMENSION_NAME, (string)$customerGroupId), ] ); $select->from(['main_table' => $tableName], null) diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Dynamic/DataProvider.php b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Dynamic/DataProvider.php index b382e2f0a3897..4e7961977d6c5 100644 --- a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Dynamic/DataProvider.php +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Dynamic/DataProvider.php @@ -132,8 +132,8 @@ public function getAggregations(\Magento\Framework\Search\Dynamic\EntityStorage $tableName = $this->priceTableResolver->resolve( 'catalog_product_index_price', [ - $this->dimensionFactory->create(WebsiteDataProvider::DIMENSION_NAME, $websiteId), - $this->dimensionFactory->create(CustomerGroupDataProvider::DIMENSION_NAME, $customerGroupId), + $this->dimensionFactory->create(WebsiteDataProvider::DIMENSION_NAME, (string)$websiteId), + $this->dimensionFactory->create(CustomerGroupDataProvider::DIMENSION_NAME, (string)$customerGroupId), ] ); /** @var Table $table */ diff --git a/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/ExclusionStrategy.php b/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/ExclusionStrategy.php index cd2dd0a7f9e26..131ea208ea569 100644 --- a/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/ExclusionStrategy.php +++ b/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/ExclusionStrategy.php @@ -131,7 +131,7 @@ private function applyPriceFilter( $tableName = $this->priceTableResolver->resolve( 'catalog_product_index_price', [ - $this->dimensionFactory->create(WebsiteDataProvider::DIMENSION_NAME, $websiteId), + $this->dimensionFactory->create(WebsiteDataProvider::DIMENSION_NAME, (string)$websiteId), $this->dimensionFactory->create( CustomerGroupDataProvider::DIMENSION_NAME, (string)$this->httpContext->getValue(CustomerContext::CONTEXT_GROUP) diff --git a/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php b/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php index 72de801c78cd0..6492338d15a24 100644 --- a/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php +++ b/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php @@ -42,7 +42,7 @@ public function __construct(CustomerGroupCollectionFactory $collectionFactory, D public function getIterator(): \Traversable { foreach ($this->getCustomerGroups() as $customerGroup) { - yield $this->dimensionFactory->create(self::DIMENSION_NAME, $customerGroup); + yield $this->dimensionFactory->create(self::DIMENSION_NAME, (string)$customerGroup); } } diff --git a/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php b/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php index 45e26eeb2203a..1bb575d302234 100644 --- a/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php +++ b/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php @@ -47,7 +47,7 @@ public function __construct(WebsiteCollectionFactory $collectionFactory, Dimensi public function getIterator(): \Traversable { foreach ($this->getWebsites() as $website) { - yield $this->dimensionFactory->create(self::DIMENSION_NAME, $website); + yield $this->dimensionFactory->create(self::DIMENSION_NAME, (string)$website); } } From fc93a27dd989efc287ceb70bed7140ae2ef68759 Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov <slopukhov@magento.com> Date: Thu, 14 Jun 2018 12:43:46 +0300 Subject: [PATCH 134/206] MAGETWO-91820: Stabilize builds --- .../Catalog/Model/ResourceModel/Product/Collection.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php index 9ed2e892994a7..f28b4deb93e51 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php @@ -1881,7 +1881,10 @@ protected function _productLimitationJoinPrice() protected function _productLimitationPrice($joinLeft = false) { $filters = $this->_productLimitationFilters; - if (!$filters->isUsingPriceIndex() || !$filters['website_id'] || !$filters['customer_group_id']) { + if (!$filters->isUsingPriceIndex() || + (string)$filters['website_id'] === '' || + (string)$filters['customer_group_id'] === '' + ) { return $this; } From b1b2a8cd61303516a285a62c86a4e729e6f9162e Mon Sep 17 00:00:00 2001 From: Michail Slabko <mslabko@magento.com> Date: Thu, 14 Jun 2018 18:00:53 +0300 Subject: [PATCH 135/206] MAGETWO-91820: Stabilize builds - MAGETWO-64467 [Indexer optimizations] Tables sharding / segmentation for price indexer --- .../Indexer/Product/Price/AbstractAction.php | 41 +++-------- .../Indexer/Product/Price/Action/Full.php | 70 +++++++------------ .../Price/DimensionProviderFactory.php | 22 +++++- .../Product/Price/Plugin/TableResolver.php | 1 - app/code/Magento/Catalog/etc/di.xml | 11 ++- 5 files changed, 64 insertions(+), 81 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php index a134a65220b74..797236065e168 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php @@ -87,11 +87,6 @@ abstract class AbstractAction */ private $dimensionCollectionFactory; - /** - * @var \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer - */ - private $configReader; - /** * @var TableMaintainer */ @@ -109,7 +104,6 @@ abstract class AbstractAction * @param \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\TierPrice|null $tierPriceIndexResource * @param DimensionProviderFactory|null $dimensionCollectionFactory * @param TableMaintainer|null $tableMaintainer - * @param \Magento\Framework\App\Config\ScopeConfigInterface|null $configReader * @SuppressWarnings(PHPMD.NPathComplexity) * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -125,8 +119,7 @@ public function __construct( DefaultPrice $defaultIndexerResource, \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\TierPrice $tierPriceIndexResource = null, \Magento\Catalog\Model\Indexer\Product\Price\DimensionProviderFactory $dimensionCollectionFactory = null, - \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer $tableMaintainer = null, - \Magento\Framework\App\Config\ScopeConfigInterface $configReader = null + \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer $tableMaintainer = null ) { $this->_config = $config; $this->_storeManager = $storeManager; @@ -143,9 +136,6 @@ public function __construct( $this->dimensionCollectionFactory = $dimensionCollectionFactory ?? ObjectManager::getInstance()->get( \Magento\Catalog\Model\Indexer\Product\Price\DimensionProviderFactory::class ); - $this->configReader = $configReader ?? ObjectManager::getInstance()->get( - \Magento\Framework\App\Config\ScopeConfigInterface::class - ); $this->tableMaintainer = $tableMaintainer ?? ObjectManager::getInstance()->get( \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer::class ); @@ -169,7 +159,7 @@ abstract public function execute($ids); */ protected function _syncData(array $processIds = []) { - $dimensionsProviders = $this->dimensionCollectionFactory->createByMode($this->getCurrentMode()); + $dimensionsProviders = $this->dimensionCollectionFactory->createByMode(); // for backward compatibility split data from old idx table on dimension tables foreach ($dimensionsProviders as $dimensions) { @@ -374,7 +364,7 @@ protected function _reindexRows($changedIds = []) foreach ($productsTypes as $productType => $entityIds) { $indexer = $this->_getIndexer($productType); if ($indexer instanceof DimensionalIndexerInterface) { - $dimensionsProviders = $this->dimensionCollectionFactory->createByMode($this->getCurrentMode()); + $dimensionsProviders = $this->dimensionCollectionFactory->createByMode(); foreach ($dimensionsProviders as $dimensions) { $this->tableMaintainer->createMainTmpTable($dimensions); $temporaryTable = $this->tableMaintainer->getMainTmpTable($dimensions); @@ -404,7 +394,7 @@ protected function _reindexRows($changedIds = []) */ private function deleteIndexData(array $entityIds) { - $dimensionsProviders = $this->dimensionCollectionFactory->createByMode($this->getCurrentMode()); + $dimensionsProviders = $this->dimensionCollectionFactory->createByMode(); foreach ($dimensionsProviders as $dimensions) { $select = $this->_connection->select()->from( @@ -450,13 +440,10 @@ protected function _copyRelationIndexData($parentIds, $excludeIds = null) if ($children) { /** @var DimensionProviderInterface $dimensionsProviders */ - $dimensionsProviders = $this->dimensionCollectionFactory->createByMode($this->getCurrentMode()); + $dimensionsProviders = $this->dimensionCollectionFactory->createByMode(); foreach ($dimensionsProviders as $dimensions) { $select = $this->_connection->select()->from( - $this->getIndexTargetTableByDimension( - $this->getIndexTargetTable(), - $dimensions - ) + $this->getIndexTargetTableByDimension($dimensions) )->where( 'entity_id IN(?)', $children @@ -469,30 +456,18 @@ protected function _copyRelationIndexData($parentIds, $excludeIds = null) return $this; } - /** - * Get current price indexer mode - * - * @return string - */ - private function getCurrentMode() - { - return $this->configReader->getValue( - ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE - ) ?: ModeSwitcher::INPUT_KEY_NONE; - } - /** * Retrieve index table by dimension that will be used for write operations. * * This method is used during both partial and full reindex to identify the table. * - * @param string $indexTargetTable * @param \Magento\Framework\Search\Request\Dimension[] $dimensions * * @return string */ - private function getIndexTargetTableByDimension(string $indexTargetTable, array $dimensions) + private function getIndexTargetTableByDimension(array $dimensions) { + $indexTargetTable = $this->getIndexTargetTable(); if ($indexTargetTable === self::getIndexTargetTable()) { $indexTargetTable = $this->tableMaintainer->getMainTable($dimensions); } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php index 8c9a2ed96fcb6..ba6b163c56c49 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php @@ -11,7 +11,6 @@ use Magento\Catalog\Api\Data\ProductInterface; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Indexer\DimensionalIndexerInterface; -use Magento\Catalog\Model\Indexer\Product\Price\ModeSwitcher; use Magento\Framework\Indexer\DimensionProviderInterface; use Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProvider; use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; @@ -51,7 +50,7 @@ class Full extends \Magento\Catalog\Model\Indexer\Product\Price\AbstractAction /** * @var \Magento\Catalog\Model\Indexer\Product\Price\DimensionProviderFactory */ - private $dimensionCollectionFactory; + private $dimensionProviderFactory; /** * @var \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer @@ -120,7 +119,7 @@ public function __construct( $this->activeTableSwitcher = $activeTableSwitcher ?: ObjectManager::getInstance()->get( \Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher::class ); - $this->dimensionCollectionFactory = $dimensionCollectionFactory ?: ObjectManager::getInstance()->get( + $this->dimensionProviderFactory = $dimensionCollectionFactory ?: ObjectManager::getInstance()->get( \Magento\Catalog\Model\Indexer\Product\Price\DimensionProviderFactory::class ); $this->dimensionTableMaintainer = $dimensionTableMaintainer ?: ObjectManager::getInstance()->get( @@ -185,18 +184,6 @@ private function prepareTables() $this->truncateReplicaTablesByDimensions(); } - /** - * Get current price indexer mode - * - * @return string - */ - private function getCurrentMode() - { - return $this->configReader->getValue( - ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE - ) ?: ModeSwitcher::INPUT_KEY_NONE; - } - /** * Truncate main replica table * @@ -217,7 +204,7 @@ private function truncateReplicaTable() private function truncateReplicaTablesByDimensions() { /** @var DimensionProviderInterface $dimensionsProviders */ - $dimensionsProviders = $this->dimensionCollectionFactory->createByMode($this->getCurrentMode()); + $dimensionsProviders = $this->dimensionProviderFactory->createByMode(); foreach ($dimensionsProviders as $dimension) { $dimensionTable = $this->dimensionTableMaintainer->getMainReplicaTable($dimension); $this->_defaultIndexerResource->getConnection()->truncateTable($dimensionTable); @@ -236,7 +223,7 @@ private function truncateReplicaTablesByDimensions() private function reindexProductTypeWithDimensions(DimensionalIndexerInterface $priceIndexer, string $typeId) { /** @var DimensionProviderInterface $dimensionsProviders */ - $dimensionsProviders = $this->dimensionCollectionFactory->createByMode($this->getCurrentMode()); + $dimensionsProviders = $this->dimensionProviderFactory->createByMode(); foreach ($dimensionsProviders as $dimensions) { $this->reindexByBatches($priceIndexer, $dimensions, $typeId); @@ -306,11 +293,6 @@ private function reindexByBatchWithDimensions( $temporaryTable = $this->dimensionTableMaintainer->getMainTmpTable($dimensions); $this->_emptyTable($temporaryTable); - // TODO: will be handled in separate task - // if ($priceIndexer->getIsComposite()) { - // $this->_copyRelationIndexData($entityIds); - // } - $priceIndexer->executeByDimension($dimensions, \SplFixedArray::fromArray($entityIds, false)); // Sync data from temp table to index table @@ -432,8 +414,7 @@ private function getReplicaTable() */ private function switchTables() { - /** @var DimensionProviderInterface $dimensionsProviders */ - $dimensionsProviders = $this->dimensionCollectionFactory->createByMode($this->getCurrentMode()); + $dimensionsProviders = $this->dimensionProviderFactory->createByMode(); // Switch dimension tables $mainTablesByDimension = []; @@ -454,8 +435,8 @@ private function switchTables() } /** - * Move data from replica table to replica tables (by dimensions) - * Data from old price indexer mechanism moves to data with new indexer mechanism by dimensions + * Move data from old price indexer mechanism to new indexer mechanism by dimensions. + * Used only for backward compatibility * * @param array $dimensions * @@ -463,32 +444,33 @@ private function switchTables() */ private function moveDataFromReplicaTableToReplicaTables(array $dimensions) { + if (!$dimensions) { + return ; + } //TODO: need to update logic for run this move only when replica table is not empty $select = $this->dimensionTableMaintainer->getConnection()->select()->from( $this->dimensionTableMaintainer->getMainReplicaTable([]) ); - if ($this->getCurrentMode() !== ModeSwitcher::INPUT_KEY_NONE) { - $replicaTablesByDimension = $this->dimensionTableMaintainer->getMainReplicaTable($dimensions); + $replicaTablesByDimension = $this->dimensionTableMaintainer->getMainReplicaTable($dimensions); - foreach ($dimensions as $dimension) { - if ($dimension->getName() === WebsiteDataProvider::DIMENSION_NAME) { - $select->where('website_id = ?', $dimension->getValue()); - } - if ($dimension->getName() === CustomerGroupDataProvider::DIMENSION_NAME) { - $select->where('customer_group_id = ?', $dimension->getValue()); - } + foreach ($dimensions as $dimension) { + if ($dimension->getName() === WebsiteDataProvider::DIMENSION_NAME) { + $select->where('website_id = ?', $dimension->getValue()); + } + if ($dimension->getName() === CustomerGroupDataProvider::DIMENSION_NAME) { + $select->where('customer_group_id = ?', $dimension->getValue()); } - - $this->dimensionTableMaintainer->getConnection()->query( - $this->dimensionTableMaintainer->getConnection()->insertFromSelect( - $select, - $replicaTablesByDimension, - [], - \Magento\Framework\DB\Adapter\AdapterInterface::INSERT_ON_DUPLICATE - ) - ); } + + $this->dimensionTableMaintainer->getConnection()->query( + $this->dimensionTableMaintainer->getConnection()->insertFromSelect( + $select, + $replicaTablesByDimension, + [], + \Magento\Framework\DB\Adapter\AdapterInterface::INSERT_ON_DUPLICATE + ) + ); } /** diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionProviderFactory.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionProviderFactory.php index 733730ccadeab..f9657ff329680 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionProviderFactory.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionProviderFactory.php @@ -34,8 +34,21 @@ class DimensionProviderFactory */ private $modesConfiguration; + /** + * @var \Magento\Framework\App\Config\ScopeConfigInterface + */ + private $scopeConfig; + + /** + * @param \Magento\Framework\Indexer\MultiDimensionProviderInterfaceFactory $multiDimensionProviderFactory + * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig + * @param array $dimensionProviders + * @param array $modes + * @param array $modesConfiguration + */ public function __construct( \Magento\Framework\Indexer\MultiDimensionProviderInterfaceFactory $multiDimensionProviderFactory, + \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, array $dimensionProviders, array $modes, array $modesConfiguration @@ -44,16 +57,21 @@ public function __construct( $this->dimensionProviders = $dimensionProviders; $this->modes = $modes; $this->modesConfiguration = $modesConfiguration; + $this->scopeConfig = $scopeConfig; } /** * Create MultiDimensionProviderInterface for specified "dimension mode" - which dimensions indexer use for sharding * - * @param string $dimensionsMode + * @param string|null $dimensionsMode * @return MultiDimensionProviderInterface */ - public function createByMode(string $dimensionsMode): MultiDimensionProviderInterface + public function createByMode(string $dimensionsMode = null): MultiDimensionProviderInterface { + if (null === $dimensionsMode) { + $dimensionsMode = $this->scopeConfig->getValue(ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE) + ?: ModeSwitcher::INPUT_KEY_NONE; + } if (!in_array($dimensionsMode, $this->modes)) { throw new \InvalidArgumentException( sprintf('Undefined dimension mode "%s".', $dimensionsMode) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/TableResolver.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/TableResolver.php index 914e39b3d2f3c..68f81642d3abf 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/TableResolver.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/TableResolver.php @@ -7,7 +7,6 @@ namespace Magento\Catalog\Model\Indexer\Product\Price\Plugin; -use Magento\Catalog\Model\Indexer\Product\Price\PriceTableResolver; use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\App\ResourceConnection; use Magento\Catalog\Model\Indexer\Product\Price\ModeSwitcher; diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml index fd14167dea117..b91fb092555d5 100644 --- a/app/code/Magento/Catalog/etc/di.xml +++ b/app/code/Magento/Catalog/etc/di.xml @@ -1104,8 +1104,17 @@ </type> <type name="Magento\Catalog\Model\Indexer\Product\Price\Plugin\TableResolver"> <arguments> + <argument name="scopeConfig" xsi:type="object"> + Magento\Framework\App\Config\ScopeConfigInterface\Proxy + </argument> <argument name="priceTableResolver" xsi:type="object"> - Magento\Catalog\Model\Indexer\Product\Price\PriceTableResolver + Magento\Catalog\Model\Indexer\Product\Price\PriceTableResolver\Proxy + </argument> + <argument name="storeManager" xsi:type="object"> + Magento\Store\Model\StoreManagerInterface\Proxy + </argument> + <argument name="context" xsi:type="object"> + Magento\Framework\App\Http\Context\Proxy </argument> </arguments> </type> From 00876741623b71448ee2635361156a67e3845349 Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi <alugovyi@magento.com> Date: Thu, 14 Jun 2018 18:41:05 +0300 Subject: [PATCH 136/206] MAGETWO-64467: [Indexer optimizations] Tables sharding / segmentation for price indexer --- app/code/Magento/Customer/etc/di.xml | 7 +++++++ app/code/Magento/Store/etc/di.xml | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/app/code/Magento/Customer/etc/di.xml b/app/code/Magento/Customer/etc/di.xml index d37d6ee49edfb..fa7dd80882632 100644 --- a/app/code/Magento/Customer/etc/di.xml +++ b/app/code/Magento/Customer/etc/di.xml @@ -75,6 +75,13 @@ <argument name="addressConfig" xsi:type="object">Magento\Customer\Model\Address\Config\Proxy</argument> </arguments> </type> + <type name="Magento\Framework\App\Http\Context"> + <arguments> + <argument name="default" xsi:type="array"> + <item name="customer_group" xsi:type="const">Magento\Customer\Api\Data\GroupInterface::NOT_LOGGED_IN_ID</item> + </argument> + </arguments> + </type> <type name="Magento\Customer\Model\Config\Share"> <arguments> <argument name="customerResource" xsi:type="object">Magento\Customer\Model\ResourceModel\Customer\Proxy</argument> diff --git a/app/code/Magento/Store/etc/di.xml b/app/code/Magento/Store/etc/di.xml index 27133de270e2f..1f26e4826da0c 100644 --- a/app/code/Magento/Store/etc/di.xml +++ b/app/code/Magento/Store/etc/di.xml @@ -25,6 +25,13 @@ <preference for="Magento\Framework\App\ScopeFallbackResolverInterface" type="Magento\Store\Model\ScopeFallbackResolver"/> <preference for="Magento\Framework\App\ScopeTreeProviderInterface" type="Magento\Store\Model\ScopeTreeProvider"/> <preference for="Magento\Framework\App\ScopeValidatorInterface" type="Magento\Store\Model\ScopeValidator"/> + <type name="Magento\Framework\App\Http\Context"> + <arguments> + <argument name="default" xsi:type="array"> + <item name="website" xsi:type="string">0</item> + </argument> + </arguments> + </type> <type name="Magento\Framework\App\Response\Http"> <plugin name="genericHeaderPlugin" type="Magento\Framework\App\Response\HeaderManager"/> </type> From a892d87bc3b7fe2819ccdff01ef04b30a72fbe70 Mon Sep 17 00:00:00 2001 From: Iurii Ivashchenko <iivashchenko@magento.com> Date: Tue, 12 Jun 2018 11:26:32 +0300 Subject: [PATCH 137/206] MAGETWO-91411: Delete action in grid could be sent multiple times --- .../Adminhtml/Product/MassDelete.php | 9 +- .../Ui/Component/MassAction/Filter.php | 14 +- .../Adminhtml/Index/MassAssignGroupTest.php | 110 ++++++++---- .../Adminhtml/Index/MassDeleteTest.php | 156 +++++++++++++++--- .../Adminhtml/Index/MassSubscribeTest.php | 74 +++++++-- .../_files/five_repository_customers.php | 49 ++++++ .../five_repository_customers_rollback.php | 29 ++++ 7 files changed, 353 insertions(+), 88 deletions(-) create mode 100644 dev/tests/integration/testsuite/Magento/Customer/_files/five_repository_customers.php create mode 100644 dev/tests/integration/testsuite/Magento/Customer/_files/five_repository_customers_rollback.php diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/MassDelete.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/MassDelete.php index 2402fb213cda0..366356597fdfb 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/MassDelete.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/MassDelete.php @@ -64,9 +64,12 @@ public function execute() $this->productRepository->delete($product); $productDeleted++; } - $this->messageManager->addSuccess( - __('A total of %1 record(s) have been deleted.', $productDeleted) - ); + + if ($productDeleted) { + $this->messageManager->addSuccess( + __('A total of %1 record(s) have been deleted.', $productDeleted) + ); + } return $this->resultFactory->create(ResultFactory::TYPE_REDIRECT)->setPath('catalog/*/index'); } diff --git a/app/code/Magento/Ui/Component/MassAction/Filter.php b/app/code/Magento/Ui/Component/MassAction/Filter.php index 6b089233c210a..483cf1ed154f0 100644 --- a/app/code/Magento/Ui/Component/MassAction/Filter.php +++ b/app/code/Magento/Ui/Component/MassAction/Filter.php @@ -98,14 +98,12 @@ public function getCollection(AbstractDb $collection) throw new LocalizedException(__('Please select item(s).')); } } - /** @var \Magento\Customer\Model\ResourceModel\Customer\Collection $collection */ - $idsArray = $this->getFilterIds(); - if (!empty($idsArray)) { - $collection->addFieldToFilter( - $collection->getIdFieldName(), - ['in' => $idsArray] - ); - } + + $collection->addFieldToFilter( + $collection->getIdFieldName(), + ['in' => $this->getFilterIds()] + ); + return $collection; } diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/MassAssignGroupTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/MassAssignGroupTest.php index b2ecd5bf7c3a2..5fc5f8b968ea9 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/MassAssignGroupTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/MassAssignGroupTest.php @@ -3,15 +3,21 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Customer\Controller\Adminhtml\Index; -use Magento\TestFramework\Helper\Bootstrap; use Magento\Customer\Api\CustomerRepositoryInterface; +use Magento\Customer\Api\Data\CustomerInterface; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Message\MessageInterface; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\TestCase\AbstractBackendController; /** * @magentoAppArea adminhtml */ -class MassAssignGroupTest extends \Magento\TestFramework\TestCase\AbstractBackendController +class MassAssignGroupTest extends AbstractBackendController { /** * Base controller URL @@ -28,9 +34,7 @@ class MassAssignGroupTest extends \Magento\TestFramework\TestCase\AbstractBacken protected function setUp() { parent::setUp(); - $this->customerRepository = Bootstrap::getObjectManager()->get( - \Magento\Customer\Api\CustomerRepositoryInterface::class - ); + $this->customerRepository = Bootstrap::getObjectManager()->get(CustomerRepositoryInterface::class); } protected function tearDown() @@ -47,66 +51,100 @@ protected function tearDown() } /** - * @magentoDataFixture Magento/Customer/_files/customer.php + * Tests os update a single customer record. + * + * @magentoDataFixture Magento/Customer/_files/five_repository_customers.php + * @magentoDbIsolation disabled */ public function testMassAssignGroupAction() { - $customer = $this->customerRepository->getById(1); - $this->assertEquals(1, $customer->getGroupId()); + $customerEmail = 'customer1@example.com'; + try { + /** @var CustomerInterface $customer */ + $customer = $this->customerRepository->get($customerEmail); + $this->assertEquals(1, $customer->getGroupId()); - $this->getRequest() - ->setParam('group', 0) - ->setPostValue('namespace', 'customer_listing') - ->setPostValue('selected', [1]); - $this->dispatch('backend/customer/index/massAssignGroup'); - $this->assertSessionMessages( - $this->equalTo(['A total of 1 record(s) were updated.']), - \Magento\Framework\Message\MessageInterface::TYPE_SUCCESS - ); - $this->assertRedirect($this->stringStartsWith($this->baseControllerUrl)); + $params = [ + 'group' => 0, + 'namespace' => 'customer_listing', + 'selected' => [$customer->getId()] + ]; - $customer = $this->customerRepository->getById(1); - $this->assertEquals(0, $customer->getGroupId()); + $this->getRequest()->setParams($params); + $this->dispatch('backend/customer/index/massAssignGroup'); + $this->assertSessionMessages( + self::equalTo(['A total of 1 record(s) were updated.']), + MessageInterface::TYPE_SUCCESS + ); + $this->assertRedirect($this->stringStartsWith($this->baseControllerUrl)); + + $customer = $this->customerRepository->get($customerEmail); + $this->assertEquals(0, $customer->getGroupId()); + } catch (LocalizedException $e) { + self::fail($e->getMessage()); + } } /** - * @magentoDataFixture Magento/Customer/_files/twenty_one_customers.php + * Tests os update a multiple customer records. + * + * @magentoDataFixture Magento/Customer/_files/five_repository_customers.php + * @magentoDbIsolation disabled */ public function testLargeGroupMassAssignGroupAction() { - - for ($i = 1; $i < 22; $i++) { - $customer = $this->customerRepository->getById($i); - $this->assertEquals(1, $customer->getGroupId()); + $ids = []; + for ($i = 1; $i <= 5; $i++) { + /** @var CustomerInterface $customer */ + try { + $customer = $this->customerRepository->get('customer'.$i.'@example.com'); + $this->assertEquals(1, $customer->getGroupId()); + $ids[] = $customer->getId(); + } catch (\Exception $e) { + self::fail($e->getMessage()); + } } - $this->getRequest() - ->setParam('group', 0) - ->setPostValue('namespace', 'customer_listing') - ->setPostValue('selected', [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21]); + $params = [ + 'group' => 0, + 'namespace' => 'customer_listing', + 'selected' => $ids, + ]; + + $this->getRequest()->setParams($params); $this->dispatch('backend/customer/index/massAssignGroup'); $this->assertSessionMessages( - $this->equalTo(['A total of 21 record(s) were updated.']), - \Magento\Framework\Message\MessageInterface::TYPE_SUCCESS + self::equalTo(['A total of 5 record(s) were updated.']), + MessageInterface::TYPE_SUCCESS ); $this->assertRedirect($this->stringStartsWith($this->baseControllerUrl)); - for ($i = 1; $i < 22; $i++) { - $customer = $this->customerRepository->getById($i); - $this->assertEquals(0, $customer->getGroupId()); + for ($i = 1; $i < 5; $i++) { + try { + /** @var CustomerInterface $customer */ + $customer = $this->customerRepository->get('customer'.$i.'@example.com'); + $this->assertEquals(0, $customer->getGroupId()); + } catch (\Exception $e) { + self::fail($e->getMessage()); + } } } /** * Valid group Id but no customer Ids specified + * * @magentoDbIsolation enabled */ public function testMassAssignGroupActionNoCustomerIds() { - $this->getRequest()->setParam('group', 0)->setPostValue('namespace', 'customer_listing'); + $params = [ + 'group' => 0, + 'namespace' => 'customer_listing', + ]; + $this->getRequest()->setParams($params); $this->dispatch('backend/customer/index/massAssignGroup'); $this->assertSessionMessages( $this->equalTo(['Please select item(s).']), - \Magento\Framework\Message\MessageInterface::TYPE_ERROR + MessageInterface::TYPE_ERROR ); } } diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/MassDeleteTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/MassDeleteTest.php index ace40f982e8fe..7048aa2c20f7f 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/MassDeleteTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/MassDeleteTest.php @@ -3,60 +3,166 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Customer\Controller\Adminhtml\Index; +use Magento\Customer\Api\CustomerRepositoryInterface; +use Magento\Customer\Api\Data\CustomerInterface; +use Magento\Framework\Exception\LocalizedException; +use PHPUnit\Framework\Constraint\Constraint; +use Magento\Framework\Message\MessageInterface; use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\TestCase\AbstractBackendController; /** * @magentoAppArea adminhtml */ -class MassDeleteTest extends \Magento\TestFramework\TestCase\AbstractBackendController +class MassDeleteTest extends AbstractBackendController { + /** + * @var CustomerRepositoryInterface + */ + private $customerRepository; + /** * Base controller URL * * @var string */ - protected $baseControllerUrl = 'http://localhost/index.php/backend/customer/index/index'; + private $baseControllerUrl = 'http://localhost/index.php/backend/customer/index/index'; - protected function tearDown() + protected function setUp() { - /** - * Unset customer data - */ - Bootstrap::getObjectManager()->get(\Magento\Backend\Model\Session::class)->setCustomerData(null); + parent::setUp(); + $this->customerRepository = Bootstrap::getObjectManager()->get(CustomerRepositoryInterface::class); + } - /** - * Unset messages - */ - Bootstrap::getObjectManager()->get(\Magento\Backend\Model\Session::class)->getMessages(true); + /** + * Validates failure attempts to delete customers from grid. + * + * @param array|null $ids + * @param Constraint $constraint + * @param string|null $messageType + * @magentoDataFixture Magento/Customer/_files/five_repository_customers.php + * @magentoDbIsolation disabled + * @dataProvider failedRequestDataProvider + */ + public function testFailedMassDeleteAction($ids, Constraint $constraint, $messageType) + { + $this->massDeleteAssertions($ids, $constraint, $messageType); + } + + /** + * Validates success attempt to delete customer from grid. + * + * @param array $emails + * @param Constraint $constraint + * @param string $messageType + * @magentoDataFixture Magento/Customer/_files/five_repository_customers.php + * @magentoDbIsolation disabled + * @dataProvider successRequestDataProvider + */ + public function testSuccessMassDeleteAction(array $emails, Constraint $constraint, string $messageType) + { + try { + $ids = []; + foreach ($emails as $email) { + /** @var CustomerInterface $customer */ + $customer = $this->customerRepository->get($email); + $ids[] = $customer->getId(); + } + + $this->massDeleteAssertions( + $ids, + $constraint, + $messageType + ); + } catch (LocalizedException $e) { + self::fail($e->getMessage()); + } } /** - * @magentoDataFixture Magento/Customer/_files/customer.php + * Performs required request and assertions. + * + * @param array|null $ids + * @param Constraint $constraint + * @param string|null $messageType */ - public function testMassDeleteAction() + private function massDeleteAssertions($ids, Constraint $constraint, $messageType) { - $this->getRequest()->setPostValue('selected', [1])->setPostValue('namespace', 'customer_listing'); + $requestData = [ + 'selected' => $ids, + 'namespace' => 'customer_listing', + ]; + + $this->getRequest()->setParams($requestData); $this->dispatch('backend/customer/index/massDelete'); $this->assertSessionMessages( - $this->equalTo(['A total of 1 record(s) were deleted.']), - \Magento\Framework\Message\MessageInterface::TYPE_SUCCESS + $constraint, + $messageType ); $this->assertRedirect($this->stringStartsWith($this->baseControllerUrl)); } /** - * Valid group Id but no customer Ids specified - * @magentoDbIsolation enabled + * Provides sets of data for unsuccessful attempts. + * + * @return array */ - public function testMassDeleteActionNoCustomerIds() + public function failedRequestDataProvider(): array { - $this->getRequest()->setPostValue('namespace', 'customer_listing'); - $this->dispatch('backend/customer/index/massDelete'); - $this->assertSessionMessages( - $this->equalTo(['Please select item(s).']), - \Magento\Framework\Message\MessageInterface::TYPE_ERROR - ); + return [ + [ + 'ids' => [], + 'constraint' => self::equalTo(['Please select item(s).']), + 'messageType' => MessageInterface::TYPE_ERROR, + ], + [ + 'ids' => [111], + 'constraint' => self::isEmpty(), + 'messageType' => null, + ], + [ + 'ids' => null, + 'constraint' => self::equalTo(['Please select item(s).']), + 'messageType' => MessageInterface::TYPE_ERROR, + ] + ]; + } + + /** + * Provides sets of data for successful attempts. + * + * @return array + */ + public function successRequestDataProvider(): array + { + return [ + [ + 'customerEmails' => ['customer1@example.com'], + 'constraint' => self::equalTo(['A total of 1 record(s) were deleted.']), + 'messageType' => MessageInterface::TYPE_SUCCESS, + ], + [ + 'customerEmails' => ['customer2@example.com', 'customer3@example.com'], + 'constraint' => self::equalTo(['A total of 2 record(s) were deleted.']), + 'messageType' => MessageInterface::TYPE_SUCCESS, + ], + ]; + } + + protected function tearDown() + { + /** + * Unset customer data + */ + Bootstrap::getObjectManager()->get(\Magento\Backend\Model\Session::class)->setCustomerData(null); + + /** + * Unset messages + */ + Bootstrap::getObjectManager()->get(\Magento\Backend\Model\Session::class)->getMessages(true); } } diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/MassSubscribeTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/MassSubscribeTest.php index d09688e9cda79..27b78ea065821 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/MassSubscribeTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/MassSubscribeTest.php @@ -3,10 +3,16 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Customer\Controller\Adminhtml\Index; +use Magento\Framework\Message\MessageInterface; use Magento\Newsletter\Model\Subscriber; +use Magento\Newsletter\Model\SubscriberFactory; use Magento\TestFramework\Helper\Bootstrap; +use Magento\Customer\Api\CustomerRepositoryInterface; +use Magento\Customer\Api\Data\CustomerInterface; /** * @magentoAppArea adminhtml @@ -34,49 +40,85 @@ protected function tearDown() } /** - * @magentoDataFixture Magento/Customer/_files/two_customers.php + * Tests subscriber status of customers. + * + * @magentoDataFixture Magento/Customer/_files/five_repository_customers.php + * @magentoDbIsolation disabled */ public function testMassSubscriberAction() { - // Pre-condition - /** @var \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory */ - $subscriberFactory = Bootstrap::getObjectManager()->get(\Magento\Newsletter\Model\SubscriberFactory::class); - $this->assertNull($subscriberFactory->create()->loadByCustomerId(1)->getSubscriberStatus()); - $this->assertNull($subscriberFactory->create()->loadByCustomerId(2)->getSubscriberStatus()); - // Setup - $this->getRequest()->setPostValue('selected', [1, 2])->setPostValue('namespace', 'customer_listing'); + /** @var SubscriberFactory $subscriberFactory */ + $subscriberFactory = Bootstrap::getObjectManager()->get(SubscriberFactory::class); + $customerRepository = Bootstrap::getObjectManager()->get(CustomerRepositoryInterface::class); + + $this->assertNull( + $subscriberFactory->create() + ->loadByEmail('customer1@example.com') + ->getSubscriberStatus() + ); + $this->assertNull( + $subscriberFactory->create() + ->loadByEmail('customer2@example.com') + ->getSubscriberStatus() + ); + + try { + /** @var CustomerInterface $customer1 */ + $customer1 = $customerRepository->get('customer1@example.com'); + /** @var CustomerInterface $customer2 */ + $customer2 = $customerRepository->get('customer2@example.com'); + } catch (\Exception $e) { + self::fail($e->getMessage()); + } + + $params = [ + 'selected' => [ + $customer1->getId(), + $customer2->getId(), + ], + 'namespace' => 'customer_listing', + ]; + $this->getRequest()->setParams($params); - // Test $this->dispatch('backend/customer/index/massSubscribe'); // Assertions $this->assertRedirect($this->stringStartsWith($this->baseControllerUrl)); $this->assertSessionMessages( - $this->equalTo(['A total of 2 record(s) were updated.']), - \Magento\Framework\Message\MessageInterface::TYPE_SUCCESS + self::equalTo(['A total of 2 record(s) were updated.']), + MessageInterface::TYPE_SUCCESS ); $this->assertEquals( Subscriber::STATUS_SUBSCRIBED, - $subscriberFactory->create()->loadByCustomerId(1)->getSubscriberStatus() + $subscriberFactory->create() + ->loadByEmail('customer1@example.com') + ->getSubscriberStatus() ); $this->assertEquals( Subscriber::STATUS_SUBSCRIBED, - $subscriberFactory->create()->loadByCustomerId(2)->getSubscriberStatus() + $subscriberFactory->create() + ->loadByEmail('customer2@example.com') + ->getSubscriberStatus() ); } /** + * @magentoAppIsolation enabled * @magentoDbIsolation enabled */ public function testMassSubscriberActionNoSelection() { - $this->getRequest()->setPostValue('namespace', 'customer_listing'); + $params = [ + 'namespace' => 'customer_listing' + ]; + + $this->getRequest()->setParams($params); $this->dispatch('backend/customer/index/massSubscribe'); $this->assertRedirect($this->stringStartsWith($this->baseControllerUrl)); $this->assertSessionMessages( - $this->equalTo(['Please select item(s).']), - \Magento\Framework\Message\MessageInterface::TYPE_ERROR + self::equalTo(['Please select item(s).']), + MessageInterface::TYPE_ERROR ); } } diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/five_repository_customers.php b/dev/tests/integration/testsuite/Magento/Customer/_files/five_repository_customers.php new file mode 100644 index 0000000000000..7849764ca219b --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/five_repository_customers.php @@ -0,0 +1,49 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Customer\Api\CustomerRepositoryInterface; +use Magento\Customer\Api\Data\CustomerInterface; +use Magento\Customer\Api\Data\CustomerInterfaceFactory; +use Magento\Customer\Model\Customer; +use Magento\Eav\Model\Config as EavModelConfig; +use Magento\Framework\Indexer\IndexerInterface; +use Magento\Framework\Indexer\IndexerRegistry; +use Magento\TestFramework\Helper\Bootstrap; + +$objectManager = Bootstrap::getObjectManager(); + +/** @var CustomerRepositoryInterface $customerRepository */ +$customerRepository = $objectManager->create(CustomerRepositoryInterface::class); +/** @var CustomerInterfaceFactory $customerFactory */ +$customerFactory = $objectManager->get(CustomerInterfaceFactory::class); + +for ($i=1; $i<=5; $i++) { + /** @var CustomerInterface $customer */ + $customer = $customerFactory->create(); + $customer->setFirstname('John') + ->setGroupId(1) + ->setLastname('Smith') + ->setWebsiteId(1) + ->setEmail('customer'.$i.'@example.com'); + try { + $customerRepository->save($customer, 'password'); + } catch (\Exception $e) { + } +} + +/** @var EavModelConfig $eavConfig */ +$eavConfig = $objectManager->get(EavModelConfig::class); +$eavConfig->clear(); + +/** @var IndexerRegistry $indexerRegistry */ +$indexerRegistry = $objectManager->create(IndexerRegistry::class); +/** @var IndexerInterface $indexer */ +$indexer = $indexerRegistry->get(Customer::CUSTOMER_GRID_INDEXER_ID); +try { + $indexer->reindexAll(); +} catch (\Exception $e) { +} diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/five_repository_customers_rollback.php b/dev/tests/integration/testsuite/Magento/Customer/_files/five_repository_customers_rollback.php new file mode 100644 index 0000000000000..f9062fb6083c5 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/five_repository_customers_rollback.php @@ -0,0 +1,29 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Customer\Api\CustomerRepositoryInterface; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\Customer\Api\Data\CustomerInterface; +use Magento\Eav\Model\Config as EavModelConfig; + +$objectManager = Bootstrap::getObjectManager(); + +/** @var CustomerRepositoryInterface $repository */ +$customerRepository = $objectManager->create(CustomerRepositoryInterface::class); + +for ($i=1; $i<=5; $i++) { + try { + /** @var CustomerInterface $customer */ + $customer = $customerRepository->get('customer'.$i.'@example.com'); + $customerRepository->delete($customer); + } catch (\Exception $e) { + } +} + +/** @var EavModelConfig $eavConfig */ +$eavConfig = $objectManager->get(EavModelConfig::class); +$eavConfig->clear(); From 71e655f1fe65ef1999904d837104d150d34bed6c Mon Sep 17 00:00:00 2001 From: Michail Slabko <mslabko@magento.com> Date: Thu, 14 Jun 2018 21:29:03 +0300 Subject: [PATCH 138/206] MAGETWO-91820: Stabilize builds - MAGETWO-64467 [Indexer optimizations] Tables sharding / segmentation for price indexer --- .../PriceIndexerDimensionsModeSetCommand.php | 25 +++--- .../Price/DimensionModeConfiguration.php | 89 +++++++++++++++++++ .../Price/DimensionProviderFactory.php | 86 +++++------------- .../Indexer/Product/Price/ModeSwitcher.php | 54 ----------- .../Product/Price/Plugin/CustomerGroup.php | 86 ++++++++---------- .../Product/Price/Plugin/TableResolver.php | 79 ++++++++-------- .../Indexer/Product/Price/Plugin/Website.php | 75 ++++++++-------- .../Product/Price/PriceTableResolver.php | 54 +++++------ .../Magento/Catalog/Setup/UpgradeData.php | 3 +- .../Product/Price/Plugin/WebsiteTest.php | 6 +- app/code/Magento/Catalog/etc/di.xml | 22 +---- .../MultiDimensional/WebsiteDataProvider.php | 4 + ...iceIndexerDimensionsModeSetCommandTest.php | 21 ++--- .../Request/IndexScopeResolverInterface.php | 4 +- 14 files changed, 283 insertions(+), 325 deletions(-) create mode 100644 app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionModeConfiguration.php diff --git a/app/code/Magento/Catalog/Console/Command/PriceIndexerDimensionsModeSetCommand.php b/app/code/Magento/Catalog/Console/Command/PriceIndexerDimensionsModeSetCommand.php index d29b806a16af7..736f2ad4bea46 100644 --- a/app/code/Magento/Catalog/Console/Command/PriceIndexerDimensionsModeSetCommand.php +++ b/app/code/Magento/Catalog/Console/Command/PriceIndexerDimensionsModeSetCommand.php @@ -5,6 +5,7 @@ */ namespace Magento\Catalog\Console\Command; +use Magento\Catalog\Model\Indexer\Product\Price\DimensionModeConfiguration; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputOption; @@ -106,7 +107,7 @@ protected function execute(InputInterface $input, OutputInterface $output) try { $currentMode = $input->getArgument(self::INPUT_KEY_MODE); $previousMode = $this->configReader->getValue(ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE) ?: - ModeSwitcher::INPUT_KEY_NONE; + DimensionModeConfiguration::DIMENSION_NONE; if ($previousMode !== $currentMode) { //Create new tables and move data @@ -152,9 +153,9 @@ public function getInputList(): array $modeOptions[] = new InputArgument( self::INPUT_KEY_MODE, InputArgument::REQUIRED, - 'Indexer dimensions mode ['. ModeSwitcher::INPUT_KEY_NONE . '|' . ModeSwitcher::INPUT_KEY_WEBSITE - . '|' . ModeSwitcher::INPUT_KEY_CUSTOMER_GROUP - . '|' . ModeSwitcher::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP .']' + 'Indexer dimensions mode ['. DimensionModeConfiguration::DIMENSION_NONE . '|' . DimensionModeConfiguration::DIMENSION_WEBSITE + . '|' . DimensionModeConfiguration::DIMENSION_CUSTOMER_GROUP + . '|' . DimensionModeConfiguration::DIMENSION_WEBSITE_AND_CUSTOMER_GROUP .']' ); return $modeOptions; } @@ -170,10 +171,10 @@ public function validate(InputInterface $input): array $errors = []; $acceptedModeValues = ' Accepted values for ' . self::INPUT_KEY_MODE . ' are \'' - . ModeSwitcher::INPUT_KEY_NONE . '\', \'' - . ModeSwitcher::INPUT_KEY_WEBSITE . '\', \'' - . ModeSwitcher::INPUT_KEY_CUSTOMER_GROUP . '\', \'' - . ModeSwitcher::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP . '\''; + . DimensionModeConfiguration::DIMENSION_NONE . '\', \'' + . DimensionModeConfiguration::DIMENSION_WEBSITE . '\', \'' + . DimensionModeConfiguration::DIMENSION_CUSTOMER_GROUP . '\', \'' + . DimensionModeConfiguration::DIMENSION_WEBSITE_AND_CUSTOMER_GROUP . '\''; $inputMode = $input->getArgument(self::INPUT_KEY_MODE); if (!$inputMode) { @@ -181,10 +182,10 @@ public function validate(InputInterface $input): array } elseif (!in_array( $inputMode, [ - ModeSwitcher::INPUT_KEY_NONE, - ModeSwitcher::INPUT_KEY_WEBSITE, - ModeSwitcher::INPUT_KEY_CUSTOMER_GROUP, - ModeSwitcher::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP + DimensionModeConfiguration::DIMENSION_NONE, + DimensionModeConfiguration::DIMENSION_WEBSITE, + DimensionModeConfiguration::DIMENSION_CUSTOMER_GROUP, + DimensionModeConfiguration::DIMENSION_WEBSITE_AND_CUSTOMER_GROUP ] )) { $errors[] = $acceptedModeValues; diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionModeConfiguration.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionModeConfiguration.php new file mode 100644 index 0000000000000..cd13d10593fe9 --- /dev/null +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionModeConfiguration.php @@ -0,0 +1,89 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); +namespace Magento\Catalog\Model\Indexer\Product\Price; + +use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; +use Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProvider; + +class DimensionModeConfiguration +{ + /**#@+ + * Available modes of dimensions for product price indexer + */ + const DIMENSION_NONE = 'none'; + const DIMENSION_WEBSITE = 'website'; + const DIMENSION_CUSTOMER_GROUP = 'customer_group'; + const DIMENSION_WEBSITE_AND_CUSTOMER_GROUP = 'website_and_customer_group'; + /**#@-*/ + + /** + * Mapping between dimension mode and dimension provider name + * + * @var array + */ + private $modesMapping = [ + self::DIMENSION_NONE => [ + ], + self::DIMENSION_WEBSITE => [ + WebsiteDataProvider::DIMENSION_NAME + ], + self::DIMENSION_CUSTOMER_GROUP => [ + CustomerGroupDataProvider::DIMENSION_NAME + ], + self::DIMENSION_WEBSITE_AND_CUSTOMER_GROUP => [ + WebsiteDataProvider::DIMENSION_NAME, + CustomerGroupDataProvider::DIMENSION_NAME + ], + ]; + /** + * @var ScopeConfigInterface + */ + private $scopeConfig; + + /** + * @var string + */ + private $currentMode; + + /** + * @param ScopeConfigInterface $scopeConfig + */ + public function __construct(ScopeConfigInterface $scopeConfig) + { + $this->scopeConfig = $scopeConfig; + } + + /** + * Get names of dimensions which used for current mode + * + * @param string|null $mode + * @return string[] + */ + public function getDimensionConfiguration(string $mode = null) + { + if ($mode && !isset($this->modesMapping[$mode])) { + throw new \InvalidArgumentException( + sprintf('Undefined dimension mode "%s".', $mode) + ); + } + return $this->modesMapping[$mode ?? $this->getCurrentMode()]; + } + + /** + * @return string + */ + private function getCurrentMode(): string + { + if (null === $this->currentMode) { + $this->currentMode = $this->scopeConfig->getValue(ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE) + ?: self::DIMENSION_NONE; + } + + return $this->currentMode; + } +} diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionProviderFactory.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionProviderFactory.php index f9657ff329680..75214a7ae7e4a 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionProviderFactory.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionProviderFactory.php @@ -5,59 +5,39 @@ */ namespace Magento\Catalog\Model\Indexer\Product\Price; +use Magento\Framework\Indexer\DimensionProviderInterface; use Magento\Framework\Indexer\MultiDimensionProviderInterface; class DimensionProviderFactory { - /** - * - */ - const EMPTY_CONFIGURATION = '-'; - /** * @var \Magento\Framework\Indexer\MultiDimensionProviderFactory */ private $multiDimensionProviderFactory; /** - * @var array + * @var DimensionProviderInterface[] */ private $dimensionProviders; /** - * @var array - */ - private $modes; - - /** - * @var array + * @var DimensionModeConfiguration */ - private $modesConfiguration; - - /** - * @var \Magento\Framework\App\Config\ScopeConfigInterface - */ - private $scopeConfig; + private $dimensionModeConfiguration; /** * @param \Magento\Framework\Indexer\MultiDimensionProviderInterfaceFactory $multiDimensionProviderFactory - * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig + * @param DimensionModeConfiguration $dimensionModeConfiguration * @param array $dimensionProviders - * @param array $modes - * @param array $modesConfiguration */ public function __construct( \Magento\Framework\Indexer\MultiDimensionProviderInterfaceFactory $multiDimensionProviderFactory, - \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - array $dimensionProviders, - array $modes, - array $modesConfiguration + DimensionModeConfiguration $dimensionModeConfiguration, + array $dimensionProviders ) { $this->multiDimensionProviderFactory = $multiDimensionProviderFactory; $this->dimensionProviders = $dimensionProviders; - $this->modes = $modes; - $this->modesConfiguration = $modesConfiguration; - $this->scopeConfig = $scopeConfig; + $this->dimensionModeConfiguration = $dimensionModeConfiguration; } /** @@ -68,49 +48,27 @@ public function __construct( */ public function createByMode(string $dimensionsMode = null): MultiDimensionProviderInterface { - if (null === $dimensionsMode) { - $dimensionsMode = $this->scopeConfig->getValue(ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE) - ?: ModeSwitcher::INPUT_KEY_NONE; - } - if (!in_array($dimensionsMode, $this->modes)) { - throw new \InvalidArgumentException( - sprintf('Undefined dimension mode "%s".', $dimensionsMode) - ); + $dimensionConfiguration = $this->dimensionModeConfiguration->getDimensionConfiguration($dimensionsMode); + $dimensionProvidersMap = []; + foreach ($this->dimensionProviders as $dimensionProvider) { + // TODO: fix hac by getDimensionName? + $dimensionProvidersMap[$dimensionProvider::DIMENSION_NAME] = $dimensionProvider; } - $modeConfigurationKey = array_search($dimensionsMode, $this->modes, true); - if (!array_key_exists($modeConfigurationKey, $this->modesConfiguration)) { - throw new \InvalidArgumentException( - sprintf('Missing configuration for mode "%s".', $dimensionsMode) - ); - } - - return $this->multiDimensionProviderFactory->create( - [ - 'dimensionProviders' => $this->getDataProviders($modeConfigurationKey) - ] - ); - } - - private function getDataProviders($modeConfigurationKey): array - { - $modeConfiguration = $this->modesConfiguration[$modeConfigurationKey]; $providers = []; - - if ($modeConfiguration === self::EMPTY_CONFIGURATION) { - return $providers; - } - - foreach ($modeConfiguration as $modeDataProviderName) { - if (!array_key_exists($modeDataProviderName, $this->dimensionProviders)) { + foreach ($dimensionConfiguration as $dimensionName) { + if (!isset($dimensionProvidersMap[$dimensionName])) { throw new \InvalidArgumentException( - sprintf('Missing data provider "%s".', $modeDataProviderName) + sprintf('Missing data provider for Dimension with name "%s".', $dimensionName) ); } - - $providers[] = clone $this->dimensionProviders[$modeDataProviderName]; + $providers[] = clone $dimensionProvidersMap[$dimensionName]; } - return $providers; + return $this->multiDimensionProviderFactory->create( + [ + 'dimensionProviders' => $providers + ] + ); } } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/ModeSwitcher.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/ModeSwitcher.php index 538deb3bac84f..3a89e6cd391fb 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/ModeSwitcher.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/ModeSwitcher.php @@ -16,26 +16,8 @@ */ class ModeSwitcher { - const INPUT_KEY_NONE = 'none'; - const INPUT_KEY_WEBSITE = 'website'; - const INPUT_KEY_CUSTOMER_GROUP = 'customer_group'; - const INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP = 'website_and_customer_group'; const XML_PATH_PRICE_DIMENSIONS_MODE = 'indexer/catalog_product_price/dimensions_mode'; - /** - * ScopeConfigInterface - * - * @var \Magento\Framework\App\Config\ScopeConfigInterface - */ - private $configReader; - - /** - * ConfigInterface - * - * @var \Magento\Framework\App\Config\ConfigResource\ConfigInterface - */ - private $configWriter; - /** * TableMaintainer * @@ -43,27 +25,6 @@ class ModeSwitcher */ private $tableMaintainer; - /** - * WebsiteRepositoryInterface - * - * @var \Magento\Store\Api\WebsiteRepositoryInterface - */ - private $websiteRepository; - - /** - * GroupRepositoryInterface - * - * @var \Magento\Customer\Api\GroupRepositoryInterface - */ - private $customerGroupRepository; - - /** - * SearchCriteriaBuilder - * - * @var \Magento\Framework\Api\SearchCriteriaBuilder - */ - private $searchCriteriaBuilder; - /** * DimensionCollectionFactory * @@ -77,29 +38,14 @@ class ModeSwitcher private $dimensionsArray; /** - * @param \Magento\Framework\App\Config\ScopeConfigInterface $configReader - * @param \Magento\Framework\App\Config\ConfigResource\ConfigInterface $configWriter * @param \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer $tableMaintainer - * @param \Magento\Store\Api\WebsiteRepositoryInterface $websiteRepository - * @param \Magento\Customer\Api\GroupRepositoryInterface $customerGroupRepository - * @param \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder * @param \Magento\Catalog\Model\Indexer\Product\Price\DimensionProviderFactory $dimensionProviderFactory */ public function __construct( - \Magento\Framework\App\Config\ScopeConfigInterface $configReader, - \Magento\Framework\App\Config\ConfigResource\ConfigInterface $configWriter, \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer $tableMaintainer, - \Magento\Store\Api\WebsiteRepositoryInterface $websiteRepository, - \Magento\Customer\Api\GroupRepositoryInterface $customerGroupRepository, - \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder, \Magento\Catalog\Model\Indexer\Product\Price\DimensionProviderFactory $dimensionProviderFactory ) { - $this->configReader = $configReader; - $this->configWriter = $configWriter; $this->tableMaintainer = $tableMaintainer; - $this->websiteRepository = $websiteRepository; - $this->customerGroupRepository = $customerGroupRepository; - $this->searchCriteriaBuilder = $searchCriteriaBuilder; $this->dimensionProviderFactory = $dimensionProviderFactory; } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CustomerGroup.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CustomerGroup.php index 1e2fd7422f42e..b762b714290c9 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CustomerGroup.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CustomerGroup.php @@ -5,17 +5,15 @@ */ namespace Magento\Catalog\Model\Indexer\Product\Price\Plugin; +use Magento\Catalog\Model\Indexer\Product\Price\DimensionModeConfiguration; use Magento\Customer\Api\GroupRepositoryInterface; use Magento\Customer\Api\Data\GroupInterface; use Magento\Catalog\Model\Indexer\Product\Price\UpdateIndexInterface; use Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer; -use Magento\Catalog\Model\Indexer\Product\Price\ModeSwitcher; -use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Framework\Indexer\Dimension; use Magento\Framework\Indexer\DimensionFactory; use Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProvider; use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; -use Magento\Store\Model\ResourceModel\Website\CollectionFactory as WebsiteCollectionFactory; -use Magento\Store\Model\Store; class CustomerGroup { @@ -37,38 +35,34 @@ class CustomerGroup private $dimensionFactory; /** - * @var WebsiteCollectionFactory + * @var DimensionModeConfiguration */ - private $websiteCollectionFactory; + private $dimensionModeConfiguration; /** - * ScopeConfigInterface - * - * @var ScopeConfigInterface + * @var WebsiteDataProvider */ - private $configReader; + private $websiteDataProvider; /** - * Constructor - * * @param UpdateIndexInterface $updateIndex * @param TableMaintainer $tableMaintainer * @param DimensionFactory $dimensionFactory - * @param WebsiteCollectionFactory $websiteCollectionFactory - * @param ScopeConfigInterface $configReader + * @param DimensionModeConfiguration $dimensionModeConfiguration + * @param WebsiteDataProvider $websiteDataProvider */ public function __construct( UpdateIndexInterface $updateIndex, TableMaintainer $tableMaintainer, DimensionFactory $dimensionFactory, - WebsiteCollectionFactory $websiteCollectionFactory, - ScopeConfigInterface $configReader + DimensionModeConfiguration $dimensionModeConfiguration, + WebsiteDataProvider $websiteDataProvider ) { $this->updateIndex = $updateIndex; $this->tableMaintainer = $tableMaintainer; $this->dimensionFactory = $dimensionFactory; - $this->websiteCollectionFactory = $websiteCollectionFactory; - $this->configReader = $configReader; + $this->dimensionModeConfiguration = $dimensionModeConfiguration; + $this->websiteDataProvider = $websiteDataProvider; } /** @@ -89,7 +83,7 @@ public function aroundSave( $isGroupNew = !$group->getId(); $group = $proceed($group); if ($isGroupNew) { - foreach ($this->getAffectedDimensions($group->getId()) as $dimensions) { + foreach ($this->getAffectedDimensions((string)$group->getId()) as $dimensions) { $this->tableMaintainer->createTablesForDimensions($dimensions); } } @@ -109,7 +103,7 @@ public function aroundSave( */ public function afterDeleteById(GroupRepositoryInterface $subject, bool $result, string $groupId) { - foreach ($this->getAffectedDimensions((int)$groupId) as $dimensions) { + foreach ($this->getAffectedDimensions($groupId) as $dimensions) { $this->tableMaintainer->dropTablesForDimensions($dimensions); } @@ -119,39 +113,33 @@ public function afterDeleteById(GroupRepositoryInterface $subject, bool $result, /** * Get affected dimensions * - * @param int $groupId - * - * @return array + * @param string $groupId + * @return Dimension[][] */ - private function getAffectedDimensions(int $groupId): array + private function getAffectedDimensions(string $groupId): array { - $return = []; + $currentDimensions = $this->dimensionModeConfiguration->getDimensionConfiguration(); + // do not return dimensions if Customer Group dimension is not present in configuration + if (!in_array( CustomerGroupDataProvider::DIMENSION_NAME, $currentDimensions, true)) { + return []; + } + $customerGroupDimension = $this->dimensionFactory->create( + CustomerGroupDataProvider::DIMENSION_NAME, + $groupId + ); - switch ($this->configReader->getValue(ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE)) { - case ModeSwitcher::INPUT_KEY_CUSTOMER_GROUP: - $return[] = [ - $this->dimensionFactory->create(CustomerGroupDataProvider::DIMENSION_NAME, (string)$groupId) + $dimensions = []; + if (in_array( WebsiteDataProvider::DIMENSION_NAME, $currentDimensions, true)) { + foreach ($this->websiteDataProvider as $websiteDimension) { + $dimensions[] = [ + $customerGroupDimension, + $websiteDimension ]; - break; - case ModeSwitcher::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP: - $websiteIds = $this->websiteCollectionFactory->create() - ->addFieldToFilter('code', ['neq' => Store::ADMIN_CODE]) - ->getAllIds(); - - foreach ($websiteIds as $websiteId) { - $return[] = [ - $this->dimensionFactory->create( - WebsiteDataProvider::DIMENSION_NAME, - (string)$websiteId - ), - $this->dimensionFactory->create( - CustomerGroupDataProvider::DIMENSION_NAME, - (string)$groupId - ) - ]; - } - break; + } + } else { + $dimensions[] = [$customerGroupDimension]; } - return $return; + + return $dimensions; } } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/TableResolver.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/TableResolver.php index 68f81642d3abf..8c0dc26d8fd4d 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/TableResolver.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/TableResolver.php @@ -7,9 +7,9 @@ namespace Magento\Catalog\Model\Indexer\Product\Price\Plugin; +use Magento\Catalog\Model\Indexer\Product\Price\DimensionModeConfiguration; use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\App\ResourceConnection; -use Magento\Catalog\Model\Indexer\Product\Price\ModeSwitcher; use Magento\Framework\Indexer\DimensionFactory; use Magento\Framework\Search\Request\IndexScopeResolverInterface; use Magento\Framework\App\Http\Context; @@ -20,15 +20,11 @@ use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; /** - * Class that replace catalog_product_index_price table name on the table name segmented per dimension + * Replace catalog_product_index_price table name on the table name segmented per dimension. + * Used only for backward compatibility */ class TableResolver { - /** - * @var ScopeConfigInterface - */ - private $scopeConfig; - /** * @var IndexScopeResolverInterface */ @@ -49,79 +45,79 @@ class TableResolver */ private $dimensionFactory; + /** + * @var DimensionModeConfiguration + */ + private $dimensionModeConfiguration; + /** * @param ScopeConfigInterface $scopeConfig * @param IndexScopeResolverInterface $priceTableResolver * @param StoreManagerInterface $storeManager * @param Context $context * @param DimensionFactory $dimensionFactory + * @param DimensionModeConfiguration $dimensionModeConfiguration */ public function __construct( ScopeConfigInterface $scopeConfig, IndexScopeResolverInterface $priceTableResolver, StoreManagerInterface $storeManager, Context $context, - DimensionFactory $dimensionFactory + DimensionFactory $dimensionFactory, + DimensionModeConfiguration $dimensionModeConfiguration ) { - $this->scopeConfig = $scopeConfig; $this->priceTableResolver = $priceTableResolver; $this->storeManager = $storeManager; $this->httpContext = $context; $this->dimensionFactory = $dimensionFactory; + $this->dimensionModeConfiguration = $dimensionModeConfiguration; } /** - * replacing catalog_product_index_price table name on the table name segmented per dimension + * Replacing catalog_product_index_price table name on the table name segmented per dimension + * * @param ResourceConnection $subject * @param string $result * @param string|string[] $modelEntity - * @SuppressWarnings(PHPMD.UnusedFormalParameter) * @return string + * @throws \Magento\Framework\Exception\NoSuchEntityException + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function afterGetTableName( ResourceConnection $subject, string $result, $modelEntity ) { - if (!is_array($modelEntity) - && $modelEntity === 'catalog_product_index_price' - && $this->getMode() !== ModeSwitcher::INPUT_KEY_NONE - ) { + if (!is_array($modelEntity) && $modelEntity === 'catalog_product_index_price') { return $this->priceTableResolver->resolve('catalog_product_index_price', $this->getDimensions()); } - return $result; - } - private function getMode(): string - { - return $this->scopeConfig->getValue(ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE); + return $result; } + /** + * @return Dimension[] + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ private function getDimensions(): array { - switch ($this->getMode()) { - case ModeSwitcher::INPUT_KEY_WEBSITE: - $return = [ - $this->createDimensionFromWebsite() - ]; - break; - case ModeSwitcher::INPUT_KEY_CUSTOMER_GROUP: - $return = [ - $this->createDimensionFromCustomerGroup() - ]; - break; - case ModeSwitcher::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP: - $return = [ - $this->createDimensionFromWebsite(), - $this->createDimensionFromCustomerGroup() - ]; - break; - default: - $return = []; + $dimensions = []; + foreach ($this->dimensionModeConfiguration->getDimensionConfiguration() as $dimensionName) { + if ($dimensionName === WebsiteDataProvider::DIMENSION_NAME) { + $dimensions[] = $this->createDimensionFromWebsite(); + } + if ($dimensionName === CustomerGroupDataProvider::DIMENSION_NAME) { + $dimensions[] = $this->createDimensionFromCustomerGroup(); + } } - return $return; + + return $dimensions; } + /** + * @return Dimension + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ private function createDimensionFromWebsite(): Dimension { $storeKey = $this->httpContext->getValue(StoreManagerInterface::CONTEXT_STORE); @@ -131,6 +127,9 @@ private function createDimensionFromWebsite(): Dimension ); } + /** + * @return Dimension + */ private function createDimensionFromCustomerGroup(): Dimension { return $this->dimensionFactory->create( diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/Website.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/Website.php index 815660140529d..2db0cfd495278 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/Website.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/Website.php @@ -5,13 +5,12 @@ */ namespace Magento\Catalog\Model\Indexer\Product\Price\Plugin; +use Magento\Catalog\Model\Indexer\Product\Price\DimensionModeConfiguration; use Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer; -use Magento\Catalog\Model\Indexer\Product\Price\ModeSwitcher; -use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Framework\Indexer\Dimension; use Magento\Framework\Indexer\DimensionFactory; use Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProvider; use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; -use Magento\Customer\Model\ResourceModel\Group\CollectionFactory as CustomerGroupCollectionFactory; use Magento\Framework\Model\ResourceModel\Db\AbstractDb; use Magento\Framework\Model\AbstractModel; @@ -30,33 +29,31 @@ class Website private $dimensionFactory; /** - * @var CustomerGroupCollectionFactory + * @var DimensionModeConfiguration */ - private $customerGroupCollectionFactory; + private $dimensionModeConfiguration; /** - * ScopeConfigInterface - * - * @var ScopeConfigInterface + * @var CustomerGroupDataProvider */ - private $configReader; + private $customerGroupDataProvider; /** * @param TableMaintainer $tableMaintainer * @param DimensionFactory $dimensionFactory - * @param CustomerGroupCollectionFactory $customerGroupCollectionFactory - * @param ScopeConfigInterface $configReader + * @param DimensionModeConfiguration $dimensionModeConfiguration + * @param CustomerGroupDataProvider $customerGroupDataProvider */ public function __construct( TableMaintainer $tableMaintainer, DimensionFactory $dimensionFactory, - CustomerGroupCollectionFactory $customerGroupCollectionFactory, - ScopeConfigInterface $configReader + DimensionModeConfiguration $dimensionModeConfiguration, + CustomerGroupDataProvider $customerGroupDataProvider ) { $this->tableMaintainer = $tableMaintainer; $this->dimensionFactory = $dimensionFactory; - $this->customerGroupCollectionFactory = $customerGroupCollectionFactory; - $this->configReader = $configReader; + $this->dimensionModeConfiguration = $dimensionModeConfiguration; + $this->customerGroupDataProvider = $customerGroupDataProvider; } /** @@ -102,34 +99,34 @@ public function afterSave(AbstractDb $subject, AbstractDb $objectResource, Abstr /** * Get affected dimensions * - * @param int $websiteId + * @param string $websiteId * - * @return array + * @return Dimension[][] */ - private function getAffectedDimensions(int $websiteId): array + private function getAffectedDimensions(string $websiteId): array { - $return = []; + $currentDimensions = $this->dimensionModeConfiguration->getDimensionConfiguration(); + // do not return dimensions if Website dimension is not present in configuration + if (!in_array( WebsiteDataProvider::DIMENSION_NAME, $currentDimensions, true)) { + return []; + } + $websiteDimension = $this->dimensionFactory->create( + WebsiteDataProvider::DIMENSION_NAME, + $websiteId + ); - switch ($this->configReader->getValue(ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE)) { - case ModeSwitcher::INPUT_KEY_WEBSITE: - $return[] = [$this->dimensionFactory->create(WebsiteDataProvider::DIMENSION_NAME, (string)$websiteId)]; - break; - case ModeSwitcher::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP: - $customerGroupIds = $this->customerGroupCollectionFactory->create()->getAllIds(); - foreach ($customerGroupIds as $customerGroupId) { - $return[] = [ - $this->dimensionFactory->create( - WebsiteDataProvider::DIMENSION_NAME, - (string)$websiteId - ), - $this->dimensionFactory->create( - CustomerGroupDataProvider::DIMENSION_NAME, - (string)$customerGroupId - ) - ]; - } - break; + $dimensions = []; + if (in_array( CustomerGroupDataProvider::DIMENSION_NAME, $currentDimensions, true)) { + foreach ($this->customerGroupDataProvider as $customerGroupDimension) { + $dimensions[] = [ + $customerGroupDimension, + $websiteDimension + ]; + } + } else { + $dimensions[] = [$websiteDimension]; } - return $return; + + return $dimensions; } } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php index e500da9326a64..1e2763235bb34 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php @@ -6,23 +6,22 @@ namespace Magento\Catalog\Model\Indexer\Product\Price; +use Magento\Framework\Indexer\Dimension; use Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver; use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\Search\Request\IndexScopeResolverInterface; -use Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProvider; -use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; class PriceTableResolver implements IndexScopeResolverInterface { /** - * @var ScopeConfigInterface + * @var IndexScopeResolver */ - private $scopeConfig; + private $indexScopeResolver; /** - * @var IndexScopeResolver + * @var DimensionModeConfiguration */ - private $indexScopeResolver; + private $dimensionModeConfiguration; /** * @param ScopeConfigInterface $scopeConfig @@ -30,10 +29,11 @@ class PriceTableResolver implements IndexScopeResolverInterface */ public function __construct( ScopeConfigInterface $scopeConfig, - IndexScopeResolver $indexScopeResolver + IndexScopeResolver $indexScopeResolver, + DimensionModeConfiguration $dimensionModeConfiguration ) { - $this->scopeConfig = $scopeConfig; $this->indexScopeResolver = $indexScopeResolver; + $this->dimensionModeConfiguration = $dimensionModeConfiguration; } /** @@ -44,42 +44,30 @@ public function __construct( */ public function resolve($index, array $dimensions) { - if ($index == 'catalog_product_index_price') { - $dimensions = $this->getMixDimensions($dimensions); + if ($index === 'catalog_product_index_price') { + $dimensions = $this->filterDimensions($dimensions); } return $this->indexScopeResolver->resolve($index, $dimensions); } - private function getMixDimensions($dimensions): array + /** + * @param Dimension[] $dimensions + * @return array + * @throws \Exception + */ + private function filterDimensions($dimensions): array { $existDimensions = []; + $currentDimensions = $this->dimensionModeConfiguration->getDimensionConfiguration(); foreach ($dimensions as $dimension) { if ((string)$dimension->getValue() === '') { throw new \Exception(sprintf('Dimension value of "%s" can not be empty', $dimension->getName())); } - $existDimensions[$dimension->getName()] = $dimension; + if (in_array($dimension->getName(), $currentDimensions, true)) { + $existDimensions[] = $dimension; + } } - switch ($this->scopeConfig->getValue(ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE)) { - case ModeSwitcher::INPUT_KEY_WEBSITE: - $return = [ - $existDimensions[WebsiteDataProvider::DIMENSION_NAME] - ]; - break; - case ModeSwitcher::INPUT_KEY_CUSTOMER_GROUP: - $return = [ - $existDimensions[CustomerGroupDataProvider::DIMENSION_NAME] - ]; - break; - case ModeSwitcher::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP: - $return = [ - $existDimensions[WebsiteDataProvider::DIMENSION_NAME], - $existDimensions[CustomerGroupDataProvider::DIMENSION_NAME] - ]; - break; - default: - $return = []; - } - return $return; + return $existDimensions; } } diff --git a/app/code/Magento/Catalog/Setup/UpgradeData.php b/app/code/Magento/Catalog/Setup/UpgradeData.php index 703b8f9888e0f..e8d8582b07f96 100644 --- a/app/code/Magento/Catalog/Setup/UpgradeData.php +++ b/app/code/Magento/Catalog/Setup/UpgradeData.php @@ -5,6 +5,7 @@ */ namespace Magento\Catalog\Setup; +use Magento\Catalog\Model\Indexer\Product\Price\DimensionModeConfiguration; use Magento\Eav\Setup\EavSetup; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\ModuleDataSetupInterface; @@ -497,7 +498,7 @@ private function savePriceIndexerDimensionsMode(ModuleDataSetupInterface $setup) 'scope' => 'default', 'scope_id' => 0, 'path' => \Magento\Catalog\Model\Indexer\Product\Price\ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE, - 'value' => \Magento\Catalog\Model\Indexer\Product\Price\ModeSwitcher::INPUT_KEY_NONE + 'value' => DimensionModeConfiguration::DIMENSION_NONE ] ); } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Plugin/WebsiteTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Plugin/WebsiteTest.php index 24a110111be10..507f22cf052b1 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Plugin/WebsiteTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Plugin/WebsiteTest.php @@ -5,6 +5,8 @@ */ namespace Magento\Catalog\Test\Unit\Model\Indexer\Product\Price\Plugin; +use Magento\Catalog\Model\Indexer\Product\Price\DimensionModeConfiguration; + class WebsiteTest extends \PHPUnit\Framework\TestCase { /** @@ -66,7 +68,7 @@ public function testAfterDelete() $dimensionMock = $this->createMock(\Magento\Framework\Indexer\Dimension::class); $this->scopeConfig->expects($this->once())->method('getValue')->willReturn( - \Magento\Catalog\Model\Indexer\Product\Price\ModeSwitcher::INPUT_KEY_WEBSITE + DimensionModeConfiguration::DIMENSION_WEBSITE ); $this->dimensionFactory->expects($this->once())->method('create')->willReturn( $dimensionMock @@ -93,7 +95,7 @@ public function testAfterSave() $dimensionMock = $this->createMock(\Magento\Framework\Indexer\Dimension::class); $this->scopeConfig->expects($this->once())->method('getValue')->willReturn( - \Magento\Catalog\Model\Indexer\Product\Price\ModeSwitcher::INPUT_KEY_WEBSITE + DimensionModeConfiguration::DIMENSION_WEBSITE ); $this->dimensionFactory->expects($this->once())->method('create')->willReturn( $dimensionMock diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml index b91fb092555d5..afd117787657b 100644 --- a/app/code/Magento/Catalog/etc/di.xml +++ b/app/code/Magento/Catalog/etc/di.xml @@ -1081,25 +1081,6 @@ <item name="websites" xsi:type="object">Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider</item> <item name="customer_groups" xsi:type="object">Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProvider</item> </argument> - <argument name="modes" xsi:type="array"> - <item name="mode-1" xsi:type="const">Magento\Catalog\Model\Indexer\Product\Price\ModeSwitcher::INPUT_KEY_NONE</item> - <item name="mode-2" xsi:type="const">Magento\Catalog\Model\Indexer\Product\Price\ModeSwitcher::INPUT_KEY_WEBSITE</item> - <item name="mode-3" xsi:type="const">Magento\Catalog\Model\Indexer\Product\Price\ModeSwitcher::INPUT_KEY_CUSTOMER_GROUP</item> - <item name="mode-4" xsi:type="const">Magento\Catalog\Model\Indexer\Product\Price\ModeSwitcher::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP</item> - </argument> - <argument name="modesConfiguration" xsi:type="array"> - <item name="mode-1" xsi:type="const">Magento\Catalog\Model\Indexer\Product\Price\DimensionProviderFactory::EMPTY_CONFIGURATION</item> - <item name="mode-2" xsi:type="array"> - <item name="websites" xsi:type="string">websites</item> - </item> - <item name="mode-3" xsi:type="array"> - <item name="customer_groups" xsi:type="string">customer_groups</item> - </item> - <item name="mode-4" xsi:type="array"> - <item name="websites" xsi:type="string">websites</item> - <item name="customer_groups" xsi:type="string">customer_groups</item> - </item> - </argument> </arguments> </type> <type name="Magento\Catalog\Model\Indexer\Product\Price\Plugin\TableResolver"> @@ -1116,6 +1097,9 @@ <argument name="context" xsi:type="object"> Magento\Framework\App\Http\Context\Proxy </argument> + <!--<argument name="dimensionModeConfiguration" xsi:type="object">--> + <!--Magento\Catalog\Model\Indexer\Product\Price\DimensionModeConfiguration\Proxy--> + <!--</argument>--> </arguments> </type> <type name="Magento\Catalog\Model\ResourceModel\Layer\Filter\Price"> diff --git a/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php b/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php index 1bb575d302234..fa62827287033 100644 --- a/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php +++ b/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php @@ -6,6 +6,7 @@ namespace Magento\Store\Model\Indexer\MultiDimensional; +use Magento\Framework\Indexer\Dimension; use Magento\Store\Model\ResourceModel\Website\CollectionFactory as WebsiteCollectionFactory; use Magento\Framework\Indexer\DimensionFactory; use Magento\Framework\Indexer\DimensionProviderInterface; @@ -44,6 +45,9 @@ public function __construct(WebsiteCollectionFactory $collectionFactory, Dimensi $this->collectionFactory = $collectionFactory; } + /** + * @return Dimension[]|\Traversable + */ public function getIterator(): \Traversable { foreach ($this->getWebsites() as $website) { diff --git a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/PriceIndexerDimensionsModeSetCommandTest.php b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/PriceIndexerDimensionsModeSetCommandTest.php index 9aa6f30d8362d..a7e1fbea4dffb 100644 --- a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/PriceIndexerDimensionsModeSetCommandTest.php +++ b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/PriceIndexerDimensionsModeSetCommandTest.php @@ -5,6 +5,7 @@ */ namespace Magento\Setup\Console\Command; +use Magento\Catalog\Model\Indexer\Product\Price\DimensionModeConfiguration; use Symfony\Component\Console\Tester\CommandTester; use Magento\Framework\Console\Cli; use Magento\Framework\ObjectManagerInterface; @@ -101,14 +102,14 @@ public function testSwitchMode($previousMode, $currentMode) public function modesDataProvider() { return [ - [ModeSwitcher::INPUT_KEY_NONE, ModeSwitcher::INPUT_KEY_WEBSITE], - [ModeSwitcher::INPUT_KEY_WEBSITE, ModeSwitcher::INPUT_KEY_CUSTOMER_GROUP], - [ModeSwitcher::INPUT_KEY_CUSTOMER_GROUP, ModeSwitcher::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP], - [ModeSwitcher::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP, ModeSwitcher::INPUT_KEY_NONE], - [ModeSwitcher::INPUT_KEY_NONE, ModeSwitcher::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP], - [ModeSwitcher::INPUT_KEY_WEBSITE_AND_CUSTOMER_GROUP, ModeSwitcher::INPUT_KEY_CUSTOMER_GROUP], - [ModeSwitcher::INPUT_KEY_CUSTOMER_GROUP, ModeSwitcher::INPUT_KEY_WEBSITE], - [ModeSwitcher::INPUT_KEY_WEBSITE, ModeSwitcher::INPUT_KEY_NONE], + [DimensionModeConfiguration::DIMENSION_NONE, DimensionModeConfiguration::DIMENSION_WEBSITE], + [DimensionModeConfiguration::DIMENSION_WEBSITE, DimensionModeConfiguration::DIMENSION_CUSTOMER_GROUP], + [DimensionModeConfiguration::DIMENSION_CUSTOMER_GROUP, DimensionModeConfiguration::DIMENSION_WEBSITE_AND_CUSTOMER_GROUP], + [DimensionModeConfiguration::DIMENSION_WEBSITE_AND_CUSTOMER_GROUP, DimensionModeConfiguration::DIMENSION_NONE], + [DimensionModeConfiguration::DIMENSION_NONE, DimensionModeConfiguration::DIMENSION_WEBSITE_AND_CUSTOMER_GROUP], + [DimensionModeConfiguration::DIMENSION_WEBSITE_AND_CUSTOMER_GROUP, DimensionModeConfiguration::DIMENSION_CUSTOMER_GROUP], + [DimensionModeConfiguration::DIMENSION_CUSTOMER_GROUP, DimensionModeConfiguration::DIMENSION_WEBSITE], + [DimensionModeConfiguration::DIMENSION_WEBSITE, DimensionModeConfiguration::DIMENSION_NONE], ]; } @@ -120,7 +121,7 @@ public function testSwitchModeForSameMode() { $this->commandTester->execute( [ - PriceIndexerDimensionsModeSetCommand::INPUT_KEY_MODE => ModeSwitcher::INPUT_KEY_NONE + PriceIndexerDimensionsModeSetCommand::INPUT_KEY_MODE => DimensionModeConfiguration::DIMENSION_NONE ] ); $expectedOutput = 'Dimensions mode for indexer Product Price has not been changed'; @@ -146,7 +147,7 @@ public function testSwitchModeWithInvalidArgument() { $this->commandTester->execute( [ - PriceIndexerDimensionsModeSetCommand::INPUT_KEY_MODE => ModeSwitcher::INPUT_KEY_NONE . '_not_valid' + PriceIndexerDimensionsModeSetCommand::INPUT_KEY_MODE => DimensionModeConfiguration::DIMENSION_NONE . '_not_valid' ] ); } diff --git a/lib/internal/Magento/Framework/Search/Request/IndexScopeResolverInterface.php b/lib/internal/Magento/Framework/Search/Request/IndexScopeResolverInterface.php index d9412cb8517fa..9e907883bb2b9 100644 --- a/lib/internal/Magento/Framework/Search/Request/IndexScopeResolverInterface.php +++ b/lib/internal/Magento/Framework/Search/Request/IndexScopeResolverInterface.php @@ -6,8 +6,8 @@ namespace Magento\Framework\Search\Request; /** - * Interface \Magento\Framework\Search\Request\IndexScopeResolverInterface - * + * Resolve table name by provided dimensions. Scope Resolver must accept all dimensions that potentially can be used to + * resolve table name, but certain implementation can filter them if needed */ interface IndexScopeResolverInterface { From a09ee80a89dc97d59f5799038ebd4ff6d9b100fc Mon Sep 17 00:00:00 2001 From: "Leandro F. L" <lfluvisotto@gmail.com> Date: Thu, 14 Jun 2018 20:37:30 +0200 Subject: [PATCH 139/206] Fix case mismatch call (class/method) --- .../Unit/Model/Export/AdvancedPricingTest.php | 2 +- .../System/Config/AdditionalCommentTest.php | 4 ++-- .../System/Config/CollectionTimeLabelTest.php | 2 +- .../Config/SubscriptionStatusLabelTest.php | 2 +- .../Adminhtml/System/Config/VerticalTest.php | 2 +- .../Test/Unit/ReportXml/QueryTest.php | 2 +- .../Gateway/Response/CardDetailsHandler.php | 2 +- .../Gateway/Response/VaultDetailsHandler.php | 2 +- .../Braintree/Model/Ui/ConfigProvider.php | 2 +- .../Test/Unit/Gateway/Config/ConfigTest.php | 2 +- .../Magento/Catalog/Model/Product/Image.php | 2 +- .../Product/ShowUpdateResultTest.php | 2 +- .../Model/Import/Product/Option.php | 2 +- .../Magento/Checkout/Setup/InstallData.php | 2 +- .../Test/Unit/Block/Widget/NameTest.php | 2 +- .../Unit/Model/Customer/DataProviderTest.php | 2 +- .../Attribute/CollectionTest.php | 2 +- .../ResourceModel/Problem/Collection.php | 4 ++-- .../Model/ResourceModel/Queue/Collection.php | 2 +- .../Test/Unit/Block/Info/SubstitutionTest.php | 2 +- .../Unit/Gateway/Http/Client/SoapTest.php | 2 +- .../Payment/Test/Unit/Model/InfoTest.php | 2 +- .../PreventExpressCheckoutObserverTest.php | 2 +- .../GuestCart/GuestCartManagementTest.php | 2 +- .../Controller/Adminhtml/Order/Unhold.php | 2 +- .../Unit/Block/Order/Create/TotalsTest.php | 6 ++--- .../SalesRule/Model/ResourceModel/Rule.php | 2 +- .../Shipping/Model/Shipping/Labels.php | 8 +++---- .../Test/Unit/Model/Resolver/GroupTest.php | 2 +- .../Test/Unit/Model/Resolver/StoreTest.php | 2 +- .../Test/Unit/Model/Resolver/WebsiteTest.php | 2 +- .../Unit/Model/TaxClass/Type/CustomerTest.php | 6 ++--- .../Command/ThemeUninstallCommandTest.php | 2 +- .../System/Design/Theme/UploadJsTest.php | 24 +++++++++---------- .../Unit/Model/ResourceModel/UserTest.php | 2 +- .../Framework/App/Test/Unit/BootstrapTest.php | 2 +- .../App/Test/Unit/StaticResourceTest.php | 2 +- .../Test/Unit/DependencyCheckerTest.php | 2 +- .../Framework/Config/Composer/Package.php | 2 +- .../Test/Unit/Router/Route/FactoryTest.php | 2 +- lib/internal/Magento/Framework/File/Size.php | 4 ++-- .../Filesystem/Test/Unit/DriverPoolTest.php | 2 +- .../Magento/Framework/Image/Adapter/Gd2.php | 8 +++---- .../Magento/Framework/Indexer/Action/Base.php | 2 +- .../Test/Unit/Factory/FactoryTest.php | 2 +- .../Magento/Framework/RequireJs/Config.php | 2 +- .../Unit/DateTime/DateTimeFormatterTest.php | 2 +- .../Unit/Matcher/MethodInvokedAtIndexTest.php | 2 +- .../FileCollector/AggregatedFileCollector.php | 2 +- .../Framework/View/Model/Layout/Merge.php | 2 +- .../View/Page/Config/Reader/Head.php | 2 +- .../Unit/Element/Html/Link/CurrentTest.php | 2 +- .../Message/MessageConfigurationsPoolTest.php | 4 ++-- .../Framework/View/Test/Unit/LayoutTest.php | 2 +- .../Magento/Setup/Model/PhpReadinessCheck.php | 4 ++-- 55 files changed, 81 insertions(+), 81 deletions(-) diff --git a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Export/AdvancedPricingTest.php b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Export/AdvancedPricingTest.php index 48b4c58918740..17e7ffc20c5e9 100644 --- a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Export/AdvancedPricingTest.php +++ b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Export/AdvancedPricingTest.php @@ -213,7 +213,7 @@ protected function setUp() '_getCustomerGroupById', 'correctExportData' ]); - $this->advancedPricing = $this->getMockbuilder( + $this->advancedPricing = $this->getMockBuilder( \Magento\AdvancedPricingImportExport\Model\Export\AdvancedPricing::class ) ->setMethods($mockMethods) diff --git a/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/AdditionalCommentTest.php b/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/AdditionalCommentTest.php index cbf06264096ac..407e323aeaae6 100644 --- a/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/AdditionalCommentTest.php +++ b/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/AdditionalCommentTest.php @@ -65,11 +65,11 @@ public function testRender() ->method('getLabel') ->willReturn('Comment label'); $html = $this->additionalComment->render($this->abstractElementMock); - $this->assertRegexp( + $this->assertRegExp( "/New comment/", $html ); - $this->assertRegexp( + $this->assertRegExp( "/Comment label/", $html ); diff --git a/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/CollectionTimeLabelTest.php b/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/CollectionTimeLabelTest.php index a652cf6b3d548..54612076a757f 100644 --- a/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/CollectionTimeLabelTest.php +++ b/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/CollectionTimeLabelTest.php @@ -73,7 +73,7 @@ public function testRender() $this->abstractElementMock->expects($this->any()) ->method('getComment') ->willReturn('Eastern Standard Time (America/New_York)'); - $this->assertRegexp( + $this->assertRegExp( "/Eastern Standard Time \(America\/New_York\)/", $this->collectionTimeLabel->render($this->abstractElementMock) ); diff --git a/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/SubscriptionStatusLabelTest.php b/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/SubscriptionStatusLabelTest.php index 09e753e4ac8aa..0806187ebac01 100644 --- a/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/SubscriptionStatusLabelTest.php +++ b/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/SubscriptionStatusLabelTest.php @@ -77,7 +77,7 @@ public function testRender() $this->abstractElementMock->expects($this->any()) ->method('getComment') ->willReturn('Subscription status: Enabled'); - $this->assertRegexp( + $this->assertRegExp( "/Subscription status: Enabled/", $this->subscriptionStatusLabel->render($this->abstractElementMock) ); diff --git a/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/VerticalTest.php b/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/VerticalTest.php index abce48c36c86a..6a0cecc781062 100644 --- a/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/VerticalTest.php +++ b/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/VerticalTest.php @@ -65,7 +65,7 @@ public function testRender() ->method('getHint') ->willReturn('New hint'); $html = $this->vertical->render($this->abstractElementMock); - $this->assertRegexp( + $this->assertRegExp( "/New comment/", $html ); diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/QueryTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/QueryTest.php index a4b08a9ce5e0a..fd924abdd9f44 100644 --- a/app/code/Magento/Analytics/Test/Unit/ReportXml/QueryTest.php +++ b/app/code/Magento/Analytics/Test/Unit/ReportXml/QueryTest.php @@ -49,7 +49,7 @@ protected function setUp() ->disableOriginalConstructor() ->getMock(); - $this->selectHydratorMock = $this->getMockBuilder(selectHydrator::class) + $this->selectHydratorMock = $this->getMockBuilder(SelectHydrator::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Braintree/Gateway/Response/CardDetailsHandler.php b/app/code/Magento/Braintree/Gateway/Response/CardDetailsHandler.php index e89e604867baa..32abeac4c8ffb 100644 --- a/app/code/Magento/Braintree/Gateway/Response/CardDetailsHandler.php +++ b/app/code/Magento/Braintree/Gateway/Response/CardDetailsHandler.php @@ -85,7 +85,7 @@ public function handle(array $handlingSubject, array $response) private function getCreditCardType($type) { $replaced = str_replace(' ', '-', strtolower($type)); - $mapper = $this->config->getCctypesMapper(); + $mapper = $this->config->getCcTypesMapper(); return $mapper[$replaced]; } diff --git a/app/code/Magento/Braintree/Gateway/Response/VaultDetailsHandler.php b/app/code/Magento/Braintree/Gateway/Response/VaultDetailsHandler.php index 89bf7f14692b0..ca46e3b0ab93c 100644 --- a/app/code/Magento/Braintree/Gateway/Response/VaultDetailsHandler.php +++ b/app/code/Magento/Braintree/Gateway/Response/VaultDetailsHandler.php @@ -156,7 +156,7 @@ private function convertDetailsToJSON($details) private function getCreditCardType($type) { $replaced = str_replace(' ', '-', strtolower($type)); - $mapper = $this->config->getCctypesMapper(); + $mapper = $this->config->getCcTypesMapper(); return $mapper[$replaced]; } diff --git a/app/code/Magento/Braintree/Model/Ui/ConfigProvider.php b/app/code/Magento/Braintree/Model/Ui/ConfigProvider.php index 6ab69923760ce..5c4a1c9598d1d 100644 --- a/app/code/Magento/Braintree/Model/Ui/ConfigProvider.php +++ b/app/code/Magento/Braintree/Model/Ui/ConfigProvider.php @@ -70,7 +70,7 @@ public function getConfig() self::CODE => [ 'isActive' => $this->config->isActive($storeId), 'clientToken' => $this->getClientToken(), - 'ccTypesMapper' => $this->config->getCctypesMapper(), + 'ccTypesMapper' => $this->config->getCcTypesMapper(), 'sdkUrl' => $this->config->getSdkUrl(), 'countrySpecificCardTypes' => $this->config->getCountrySpecificCardTypeConfig($storeId), 'availableCardTypes' => $this->config->getAvailableCardTypes($storeId), diff --git a/app/code/Magento/Braintree/Test/Unit/Gateway/Config/ConfigTest.php b/app/code/Magento/Braintree/Test/Unit/Gateway/Config/ConfigTest.php index 7b9d59a5bc482..36ea3aea465dd 100644 --- a/app/code/Magento/Braintree/Test/Unit/Gateway/Config/ConfigTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Gateway/Config/ConfigTest.php @@ -142,7 +142,7 @@ public function testGetCcTypesMapper($value, $expected) static::assertEquals( $expected, - $this->model->getCctypesMapper() + $this->model->getCcTypesMapper() ); } diff --git a/app/code/Magento/Catalog/Model/Product/Image.php b/app/code/Magento/Catalog/Model/Product/Image.php index 971f34e02f9e5..ffae39cb6ed05 100644 --- a/app/code/Magento/Catalog/Model/Product/Image.php +++ b/app/code/Magento/Catalog/Model/Product/Image.php @@ -826,7 +826,7 @@ public function getResizedImageInfo() $image = $this->imageAsset->getPath(); } - $imageProperties = $this->getimagesize($image); + $imageProperties = $this->getImageSize($image); return $imageProperties; } finally { diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/ShowUpdateResultTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/ShowUpdateResultTest.php index ba716fdb53c89..47a60a1916142 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/ShowUpdateResultTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/ShowUpdateResultTest.php @@ -58,7 +58,7 @@ protected function getContext() $objectManagerMock = $this->getMockForAbstractClass(\Magento\Framework\ObjectManagerInterface::class); $objectManagerMock->expects($this->any()) ->method('get') - ->willreturn($productActionMock); + ->willReturn($productActionMock); $eventManager = $this->getMockBuilder(\Magento\Framework\Event\Manager::class) ->setMethods(['dispatch']) diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php b/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php index 0a6e8032d484a..d2b03936f4f0f 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php @@ -1214,7 +1214,7 @@ protected function _importData() $optionsToRemove = []; foreach ($bunch as $rowNumber => $rowData) { - if (isset($optionId, $valueId) && empty($rowData[PRODUCT::COL_STORE_VIEW_CODE])) { + if (isset($optionId, $valueId) && empty($rowData[Product::COL_STORE_VIEW_CODE])) { $nextOptionId = $optionId; $nextValueId = $valueId; } diff --git a/app/code/Magento/Checkout/Setup/InstallData.php b/app/code/Magento/Checkout/Setup/InstallData.php index 38879e06d65ac..58b118c482307 100644 --- a/app/code/Magento/Checkout/Setup/InstallData.php +++ b/app/code/Magento/Checkout/Setup/InstallData.php @@ -816,7 +816,7 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $connection->commit(); } catch (\Exception $e) { - $connection->rollback(); + $connection->rollBack(); throw $e; } } diff --git a/app/code/Magento/Customer/Test/Unit/Block/Widget/NameTest.php b/app/code/Magento/Customer/Test/Unit/Block/Widget/NameTest.php index 3f174484df3e1..bd81400f47e74 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Widget/NameTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Widget/NameTest.php @@ -453,7 +453,7 @@ private function _setUpIsAttributeRequired() */ $this->_block->setForceUseCustomerAttributes(false); $this->_block->setForceUseCustomerRequiredAttributes(true); - $this->_block->setObject(new \StdClass()); + $this->_block->setObject(new \stdClass()); /** * The first call to isRequired() is false so that the second if conditional in the other code path diff --git a/app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php b/app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php index 029949c5f35b0..71b99586f6fb4 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php @@ -1266,7 +1266,7 @@ public function testGetDataWithVisibleAttributesWithAccountEdit() $helper = new ObjectManager($this); $context = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponent\ContextInterface::class) ->setMethods(['getRequestParam']) - ->getMockforAbstractClass(); + ->getMockForAbstractClass(); $context->expects($this->any()) ->method('getRequestParam') ->with('request-field-name') diff --git a/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Attribute/CollectionTest.php b/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Attribute/CollectionTest.php index 823f32f46b9a5..bc34c3b6e5d3a 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Attribute/CollectionTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Attribute/CollectionTest.php @@ -112,7 +112,7 @@ protected function setUp() $this->connectionMock->expects($this->any())->method('quoteIdentifier')->will($this->returnArgument(0)); $this->connectionMock->expects($this->any()) ->method('describeTable') - ->will($this->returnvalueMap( + ->will($this->returnValueMap( [ [ 'some_main_table', diff --git a/app/code/Magento/Newsletter/Model/ResourceModel/Problem/Collection.php b/app/code/Magento/Newsletter/Model/ResourceModel/Problem/Collection.php index 6854b90a8888c..ce0e1446d216c 100644 --- a/app/code/Magento/Newsletter/Model/ResourceModel/Problem/Collection.php +++ b/app/code/Magento/Newsletter/Model/ResourceModel/Problem/Collection.php @@ -165,8 +165,8 @@ protected function _addCustomersData() $customerName = $this->_customerView->getCustomerName($customer); foreach ($problems as $problem) { $problem->setCustomerName($customerName) - ->setCustomerFirstName($customer->getFirstName()) - ->setCustomerLastName($customer->getLastName()); + ->setCustomerFirstName($customer->getFirstname()) + ->setCustomerLastName($customer->getLastname()); } } catch (NoSuchEntityException $e) { // do nothing if customer is not found by id diff --git a/app/code/Magento/Newsletter/Model/ResourceModel/Queue/Collection.php b/app/code/Magento/Newsletter/Model/ResourceModel/Queue/Collection.php index 3e221047ec40a..0f0a97fd9e983 100644 --- a/app/code/Magento/Newsletter/Model/ResourceModel/Queue/Collection.php +++ b/app/code/Magento/Newsletter/Model/ResourceModel/Queue/Collection.php @@ -221,7 +221,7 @@ public function addOnlyForSendingFilter() [\Magento\Newsletter\Model\Queue::STATUS_SENDING, \Magento\Newsletter\Model\Queue::STATUS_NEVER] )->where( 'main_table.queue_start_at < ?', - $this->_date->gmtdate() + $this->_date->gmtDate() )->where( 'main_table.queue_start_at IS NOT NULL' ); diff --git a/app/code/Magento/Payment/Test/Unit/Block/Info/SubstitutionTest.php b/app/code/Magento/Payment/Test/Unit/Block/Info/SubstitutionTest.php index 729da9eb8196d..268d4f39ba634 100644 --- a/app/code/Magento/Payment/Test/Unit/Block/Info/SubstitutionTest.php +++ b/app/code/Magento/Payment/Test/Unit/Block/Info/SubstitutionTest.php @@ -136,7 +136,7 @@ public function testBeforeToHtml() $infoMock->expects($this->once())->method('getMethodInstance')->will($this->returnValue($methodMock)); $this->block->setInfo($infoMock); - $fakeBlock = new \StdClass(); + $fakeBlock = new \stdClass(); $this->layout->expects( $this->any() )->method( diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Http/Client/SoapTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Http/Client/SoapTest.php index 546dadfb1bf62..af26ea428a235 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Http/Client/SoapTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Http/Client/SoapTest.php @@ -64,7 +64,7 @@ public function testPlaceRequest() $expectedResult = [ 'result' => [] ]; - $soapResult = new \StdClass(); + $soapResult = new \stdClass(); $this->logger->expects(static::at(0)) ->method('debug') diff --git a/app/code/Magento/Payment/Test/Unit/Model/InfoTest.php b/app/code/Magento/Payment/Test/Unit/Model/InfoTest.php index 3203f1498b9a3..93279f308eefa 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/InfoTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/InfoTest.php @@ -176,7 +176,7 @@ public function testDecrypt() */ public function testSetAdditionalInformationException() { - $this->info->setAdditionalInformation('object', new \StdClass()); + $this->info->setAdditionalInformation('object', new \stdClass()); } /** diff --git a/app/code/Magento/Persistent/Test/Unit/Observer/PreventExpressCheckoutObserverTest.php b/app/code/Magento/Persistent/Test/Unit/Observer/PreventExpressCheckoutObserverTest.php index 7749377bbfcd0..669728804af1a 100644 --- a/app/code/Magento/Persistent/Test/Unit/Observer/PreventExpressCheckoutObserverTest.php +++ b/app/code/Magento/Persistent/Test/Unit/Observer/PreventExpressCheckoutObserverTest.php @@ -122,7 +122,7 @@ public function testPreventExpressCheckoutEmpty() $this->_event->setControllerAction(null); $this->_model->execute($this->_observer); - $this->_event->setControllerAction(new \StdClass()); + $this->_event->setControllerAction(new \stdClass()); $this->_model->execute($this->_observer); $expectedActionName = 'realAction'; diff --git a/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartManagementTest.php index ee0ffd3bcc666..73ed2e65b41a9 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartManagementTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartManagementTest.php @@ -94,7 +94,7 @@ public function testCreateEmptyCart() $cartId = 1; $this->quoteIdMaskMock->expects($this->once())->method('setQuoteId')->with($cartId)->willReturnSelf(); $this->quoteIdMaskMock->expects($this->once())->method('save')->willReturnSelf(); - $this->quoteIdMaskMock->expects($this->once())->method('getMaskedId')->willreturn($maskedCartId); + $this->quoteIdMaskMock->expects($this->once())->method('getMaskedId')->willReturn($maskedCartId); $this->quoteIdMaskFactoryMock->expects($this->once())->method('create')->willReturn($this->quoteIdMaskMock); $this->quoteManagementMock->expects($this->once())->method('createEmptyCart')->willReturn($cartId); diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Unhold.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Unhold.php index 752ab088689c8..fa9676856a442 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Unhold.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Unhold.php @@ -32,7 +32,7 @@ public function execute() if (!$order->canUnhold()) { throw new \Magento\Framework\Exception\LocalizedException(__('Can\'t unhold order.')); } - $this->orderManagement->unhold($order->getEntityId()); + $this->orderManagement->unHold($order->getEntityId()); $this->messageManager->addSuccess(__('You released the order from holding status.')); } catch (\Magento\Framework\Exception\LocalizedException $e) { $this->messageManager->addError($e->getMessage()); diff --git a/app/code/Magento/Sales/Test/Unit/Block/Order/Create/TotalsTest.php b/app/code/Magento/Sales/Test/Unit/Block/Order/Create/TotalsTest.php index 2a839dd018dba..492cfee5f5d83 100644 --- a/app/code/Magento/Sales/Test/Unit/Block/Order/Create/TotalsTest.php +++ b/app/code/Magento/Sales/Test/Unit/Block/Order/Create/TotalsTest.php @@ -70,10 +70,10 @@ protected function setUp() $this->quoteMock->expects($this->any()) ->method('getBillingAddress') - ->willreturn($this->billingAddressMock); + ->willReturn($this->billingAddressMock); $this->quoteMock->expects($this->any()) ->method('getShippingAddress') - ->willreturn($this->shippingAddressMock); + ->willReturn($this->shippingAddressMock); $this->sessionQuoteMock->expects($this->any())->method('getQuote')->willReturn($this->quoteMock); $this->totals = $this->helperManager->getObject( \Magento\Sales\Block\Adminhtml\Order\Create\Totals::class, @@ -88,7 +88,7 @@ public function testGetTotals($isVirtual) { $expected = 'expected'; $this->quoteMock->expects($this->at(1))->method('collectTotals'); - $this->quoteMock->expects($this->once())->method('isVirtual')->willreturn($isVirtual); + $this->quoteMock->expects($this->once())->method('isVirtual')->willReturn($isVirtual); if ($isVirtual) { $this->billingAddressMock->expects($this->once())->method('getTotals')->willReturn($expected); } else { diff --git a/app/code/Magento/SalesRule/Model/ResourceModel/Rule.php b/app/code/Magento/SalesRule/Model/ResourceModel/Rule.php index 794fc94d6a2a8..3a5ed16fdd2fd 100644 --- a/app/code/Magento/SalesRule/Model/ResourceModel/Rule.php +++ b/app/code/Magento/SalesRule/Model/ResourceModel/Rule.php @@ -239,7 +239,7 @@ public function saveStoreLabels($ruleId, $labels) $connection->delete($table, ['rule_id=?' => $ruleId, 'store_id IN (?)' => $deleteByStoreIds]); } } catch (\Exception $e) { - $connection->rollback(); + $connection->rollBack(); throw $e; } $connection->commit(); diff --git a/app/code/Magento/Shipping/Model/Shipping/Labels.php b/app/code/Magento/Shipping/Model/Shipping/Labels.php index b1709b0a16998..15f0c88a7944a 100644 --- a/app/code/Magento/Shipping/Model/Shipping/Labels.php +++ b/app/code/Magento/Shipping/Model/Shipping/Labels.php @@ -117,8 +117,8 @@ public function requestToShipment(Shipment $orderShipment) ) ); - if (!$admin->getFirstname() - || !$admin->getLastname() + if (!$admin->getFirstName() + || !$admin->getLastName() || !$storeInfo->getName() || !$storeInfo->getPhone() || !$originStreet1 @@ -187,8 +187,8 @@ protected function setShipperDetails( ); $request->setShipperContactPersonName($storeAdmin->getName()); - $request->setShipperContactPersonFirstName($storeAdmin->getFirstname()); - $request->setShipperContactPersonLastName($storeAdmin->getLastname()); + $request->setShipperContactPersonFirstName($storeAdmin->getFirstName()); + $request->setShipperContactPersonLastName($storeAdmin->getLastName()); $request->setShipperContactCompanyName($store->getName()); $request->setShipperContactPhoneNumber($store->getPhone()); $request->setShipperEmail($storeAdmin->getEmail()); diff --git a/app/code/Magento/Store/Test/Unit/Model/Resolver/GroupTest.php b/app/code/Magento/Store/Test/Unit/Model/Resolver/GroupTest.php index 9817bd532c18a..6fade2de934e4 100644 --- a/app/code/Magento/Store/Test/Unit/Model/Resolver/GroupTest.php +++ b/app/code/Magento/Store/Test/Unit/Model/Resolver/GroupTest.php @@ -53,7 +53,7 @@ public function testGetScope() */ public function testGetScopeWithInvalidScope() { - $scopeMock = new \StdClass(); + $scopeMock = new \stdClass(); $this->storeManagerMock ->expects($this->once()) ->method('getGroup') diff --git a/app/code/Magento/Store/Test/Unit/Model/Resolver/StoreTest.php b/app/code/Magento/Store/Test/Unit/Model/Resolver/StoreTest.php index 958cfdea37bab..50a043f45bc16 100644 --- a/app/code/Magento/Store/Test/Unit/Model/Resolver/StoreTest.php +++ b/app/code/Magento/Store/Test/Unit/Model/Resolver/StoreTest.php @@ -52,7 +52,7 @@ public function testGetScope() */ public function testGetScopeWithInvalidScope() { - $scopeMock = new \StdClass(); + $scopeMock = new \stdClass(); $this->_storeManagerMock ->expects($this->once()) ->method('getStore') diff --git a/app/code/Magento/Store/Test/Unit/Model/Resolver/WebsiteTest.php b/app/code/Magento/Store/Test/Unit/Model/Resolver/WebsiteTest.php index c5b3dbaff99be..5c33090f28eeb 100644 --- a/app/code/Magento/Store/Test/Unit/Model/Resolver/WebsiteTest.php +++ b/app/code/Magento/Store/Test/Unit/Model/Resolver/WebsiteTest.php @@ -52,7 +52,7 @@ public function testGetScope() */ public function testGetScopeWithInvalidScope() { - $scopeMock = new \StdClass(); + $scopeMock = new \stdClass(); $this->_storeManagerMock ->expects($this->once()) ->method('getWebsite') diff --git a/app/code/Magento/Tax/Test/Unit/Model/TaxClass/Type/CustomerTest.php b/app/code/Magento/Tax/Test/Unit/Model/TaxClass/Type/CustomerTest.php index fc27e68c8e55b..707b999c5e467 100644 --- a/app/code/Magento/Tax/Test/Unit/Model/TaxClass/Type/CustomerTest.php +++ b/app/code/Magento/Tax/Test/Unit/Model/TaxClass/Type/CustomerTest.php @@ -26,9 +26,9 @@ public function testIsAssignedToObjects() $filterBuilder->expects($this->once())->method('setField')->with( \Magento\Customer\Api\Data\GroupInterface::TAX_CLASS_ID - )->willReturnself(); - $filterBuilder->expects($this->once())->method('setValue')->willReturnself(); - $filterBuilder->expects($this->once())->method('create')->willReturnself(); + )->willReturnSelf(); + $filterBuilder->expects($this->once())->method('setValue')->willReturnSelf(); + $filterBuilder->expects($this->once())->method('create')->willReturnSelf(); $filterGroupBuilder = $this->createMock(\Magento\Framework\Api\Search\FilterGroupBuilder::class); $searchCriteriaBuilder = $this->getMockBuilder(\Magento\Framework\Api\SearchCriteriaBuilder::class) diff --git a/app/code/Magento/Theme/Test/Unit/Console/Command/ThemeUninstallCommandTest.php b/app/code/Magento/Theme/Test/Unit/Console/Command/ThemeUninstallCommandTest.php index 2ae889e69bb12..36daf7d4aff48 100644 --- a/app/code/Magento/Theme/Test/Unit/Console/Command/ThemeUninstallCommandTest.php +++ b/app/code/Magento/Theme/Test/Unit/Console/Command/ThemeUninstallCommandTest.php @@ -8,7 +8,7 @@ use Magento\Framework\App\Console\MaintenanceModeEnabler; use Magento\Theme\Console\Command\ThemeUninstallCommand; -use Magento\Theme\Model\Theme\themePackageInfo; +use Magento\Theme\Model\Theme\ThemePackageInfo; use Magento\Theme\Model\Theme\ThemeUninstaller; use Magento\Theme\Model\Theme\ThemeDependencyChecker; use Symfony\Component\Console\Tester\CommandTester; diff --git a/app/code/Magento/Theme/Test/Unit/Controller/Adminhtml/System/Design/Theme/UploadJsTest.php b/app/code/Magento/Theme/Test/Unit/Controller/Adminhtml/System/Design/Theme/UploadJsTest.php index d5919db5edcba..bbcaa87acb9c3 100644 --- a/app/code/Magento/Theme/Test/Unit/Controller/Adminhtml/System/Design/Theme/UploadJsTest.php +++ b/app/code/Magento/Theme/Test/Unit/Controller/Adminhtml/System/Design/Theme/UploadJsTest.php @@ -63,22 +63,22 @@ public function testExecuteWithoutTheme() ->expects($this->at(0)) ->method('get') ->with(\Magento\Theme\Model\Uploader\Service::class) - ->WillReturn($this->serviceModel); + ->willReturn($this->serviceModel); $this->_objectManagerMock ->expects($this->at(1)) ->method('get') ->with(\Magento\Framework\View\Design\Theme\FlyweightFactory::class) - ->WillReturn($this->themeFactory); + ->willReturn($this->themeFactory); $this->_objectManagerMock ->expects($this->at(2)) ->method('get') ->with(\Magento\Framework\View\Design\Theme\Customization\File\Js::class) - ->WillReturn($this->customizationJs); + ->willReturn($this->customizationJs); $this->_objectManagerMock ->expects($this->at(3)) ->method('get') ->with(\Magento\Framework\Json\Helper\Data::class) - ->WillReturn($this->jsonHelper); + ->willReturn($this->jsonHelper); $this->themeFactory->expects($this->once()) ->method('create') @@ -107,21 +107,21 @@ public function testExecuteWithException() $this->_objectManagerMock->expects($this->at(0)) ->method('get') ->with(\Magento\Theme\Model\Uploader\Service::class) - ->WillReturn($this->serviceModel); + ->willReturn($this->serviceModel); $this->_objectManagerMock->expects($this->at(1)) ->method('get') ->with(\Magento\Framework\View\Design\Theme\FlyweightFactory::class) - ->WillReturn($this->themeFactory); + ->willReturn($this->themeFactory); $this->_objectManagerMock ->expects($this->at(2)) ->method('get') ->with(\Magento\Framework\View\Design\Theme\Customization\File\Js::class) - ->WillReturn($this->customizationJs); + ->willReturn($this->customizationJs); $this->_objectManagerMock ->expects($this->at(4)) ->method('get') ->with(\Magento\Framework\Json\Helper\Data::class) - ->WillReturn($this->jsonHelper); + ->willReturn($this->jsonHelper); $this->themeFactory->expects($this->once()) ->method('create') @@ -172,19 +172,19 @@ public function testExecute() $this->_objectManagerMock->expects($this->at(0)) ->method('get') ->with(\Magento\Theme\Model\Uploader\Service::class) - ->WillReturn($this->serviceModel); + ->willReturn($this->serviceModel); $this->_objectManagerMock->expects($this->at(1)) ->method('get') ->with(\Magento\Framework\View\Design\Theme\FlyweightFactory::class) - ->WillReturn($this->themeFactory); + ->willReturn($this->themeFactory); $this->_objectManagerMock->expects($this->at(2)) ->method('get') ->with(\Magento\Framework\View\Design\Theme\Customization\File\Js::class) - ->WillReturn($this->customizationJs); + ->willReturn($this->customizationJs); $this->_objectManagerMock->expects($this->at(4)) ->method('get') ->with(\Magento\Framework\Json\Helper\Data::class) - ->WillReturn($this->jsonHelper); + ->willReturn($this->jsonHelper); $this->themeFactory->expects($this->once()) ->method('create') diff --git a/app/code/Magento/User/Test/Unit/Model/ResourceModel/UserTest.php b/app/code/Magento/User/Test/Unit/Model/ResourceModel/UserTest.php index ff0873c369075..28bfe34a05733 100644 --- a/app/code/Magento/User/Test/Unit/Model/ResourceModel/UserTest.php +++ b/app/code/Magento/User/Test/Unit/Model/ResourceModel/UserTest.php @@ -330,7 +330,7 @@ public function testDeleteFromRole() $roleId = 44; $methodUserMock->expects($this->once())->method('getUserId')->willReturn($uid); $this->resourceMock->expects($this->atLeastOnce())->method('getConnection')->willReturn($this->dbAdapterMock); - $methodUserMock->expects($this->atleastOnce())->method('getRoleId')->willReturn($roleId); + $methodUserMock->expects($this->atLeastOnce())->method('getRoleId')->willReturn($roleId); $this->dbAdapterMock->expects($this->once())->method('delete'); $this->assertInstanceOf( diff --git a/lib/internal/Magento/Framework/App/Test/Unit/BootstrapTest.php b/lib/internal/Magento/Framework/App/Test/Unit/BootstrapTest.php index 1e2947084ee6b..4b04507dcedc0 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/BootstrapTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/BootstrapTest.php @@ -135,7 +135,7 @@ public function testCreateFilesystemDriverPool() ); /** @var \Magento\Framework\Filesystem\DriverPool $result */ $this->assertInstanceOf(\Magento\Framework\Filesystem\DriverPool::class, $result); - $this->assertInstanceof($driverClass, $result->getDriver('custom')); + $this->assertInstanceOf($driverClass, $result->getDriver('custom')); } public function testGetParams() diff --git a/lib/internal/Magento/Framework/App/Test/Unit/StaticResourceTest.php b/lib/internal/Magento/Framework/App/Test/Unit/StaticResourceTest.php index 3074a951159b8..618b67663304a 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/StaticResourceTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/StaticResourceTest.php @@ -271,7 +271,7 @@ public function testLaunchPathAbove() { $this->stateMock->expects($this->once()) ->method('getMode') - ->willreturn(State::MODE_DEVELOPER); + ->willReturn(State::MODE_DEVELOPER); $this->requestMock->expects($this->once()) ->method('get') ->with('resource') diff --git a/lib/internal/Magento/Framework/Composer/Test/Unit/DependencyCheckerTest.php b/lib/internal/Magento/Framework/Composer/Test/Unit/DependencyCheckerTest.php index 801d99373bc50..15ceb0c6c2755 100644 --- a/lib/internal/Magento/Framework/Composer/Test/Unit/DependencyCheckerTest.php +++ b/lib/internal/Magento/Framework/Composer/Test/Unit/DependencyCheckerTest.php @@ -69,7 +69,7 @@ function ($input, $buffer) { $buffer->writeln($output); } ); - $composerApp->Expects($this->at(6))->method('run')->willReturnCallback( + $composerApp->expects($this->at(6))->method('run')->willReturnCallback( function ($input, $buffer) { $output = 'magento/package-d requires magento/package-c (1.0)' . PHP_EOL . 'magento/project-community-edition requires magento/package-a (1.0)' . PHP_EOL; diff --git a/lib/internal/Magento/Framework/Config/Composer/Package.php b/lib/internal/Magento/Framework/Config/Composer/Package.php index a8ff6ac724c3f..5e75f0be4b104 100644 --- a/lib/internal/Magento/Framework/Config/Composer/Package.php +++ b/lib/internal/Magento/Framework/Config/Composer/Package.php @@ -83,7 +83,7 @@ public function get($propertyPath, $filter = null) * @param int $index * @return mixed */ - private function traverseGet(\StdClass $json, array $chain, $index = 0) + private function traverseGet(\stdClass $json, array $chain, $index = 0) { $property = $chain[$index]; if (!property_exists($json, $property)) { diff --git a/lib/internal/Magento/Framework/Controller/Test/Unit/Router/Route/FactoryTest.php b/lib/internal/Magento/Framework/Controller/Test/Unit/Router/Route/FactoryTest.php index 87adadbd34e3b..2b53541022505 100644 --- a/lib/internal/Magento/Framework/Controller/Test/Unit/Router/Route/FactoryTest.php +++ b/lib/internal/Magento/Framework/Controller/Test/Unit/Router/Route/FactoryTest.php @@ -69,7 +69,7 @@ public function testCreateRouteNegative() { $this->objectManager->expects($this->once()) ->method('create') - ->will($this->returnValue(new \StdClass())); + ->will($this->returnValue(new \stdClass())); $object = new Factory($this->objectManager); $object->createRoute( diff --git a/lib/internal/Magento/Framework/File/Size.php b/lib/internal/Magento/Framework/File/Size.php index 6f48024f71c16..c259069637293 100644 --- a/lib/internal/Magento/Framework/File/Size.php +++ b/lib/internal/Magento/Framework/File/Size.php @@ -36,7 +36,7 @@ class Size */ public function getPostMaxSize() { - return $this->_iniget('post_max_size'); + return $this->_iniGet('post_max_size'); } /** @@ -46,7 +46,7 @@ public function getPostMaxSize() */ public function getUploadMaxSize() { - return $this->_iniget('upload_max_filesize'); + return $this->_iniGet('upload_max_filesize'); } /** diff --git a/lib/internal/Magento/Framework/Filesystem/Test/Unit/DriverPoolTest.php b/lib/internal/Magento/Framework/Filesystem/Test/Unit/DriverPoolTest.php index 8e550ff0597d7..1aaedbc475446 100644 --- a/lib/internal/Magento/Framework/Filesystem/Test/Unit/DriverPoolTest.php +++ b/lib/internal/Magento/Framework/Filesystem/Test/Unit/DriverPoolTest.php @@ -38,6 +38,6 @@ public function testCustomDriver() */ public function testCustomDriverException() { - new DriverPool(['custom' => new \StdClass()]); + new DriverPool(['custom' => new \stdClass()]); } } diff --git a/lib/internal/Magento/Framework/Image/Adapter/Gd2.php b/lib/internal/Magento/Framework/Image/Adapter/Gd2.php index a36e41a526466..33d73768b3b07 100644 --- a/lib/internal/Magento/Framework/Image/Adapter/Gd2.php +++ b/lib/internal/Magento/Framework/Image/Adapter/Gd2.php @@ -106,7 +106,7 @@ protected function _getImageNeedMemorySize($file) } return round( - ($imageInfo[0] * $imageInfo[1] * $imageInfo['bits'] * $imageInfo['channels'] / 8 + Pow(2, 16)) * 1.65 + ($imageInfo[0] * $imageInfo[1] * $imageInfo['bits'] * $imageInfo['channels'] / 8 + pow(2, 16)) * 1.65 ); } @@ -426,7 +426,7 @@ public function watermark($imagePath, $positionX = 0, $positionY = 0, $opacity = imagecolortransparent($newWatermark, $col); imagefilledrectangle($newWatermark, 0, 0, $this->getWatermarkWidth(), $this->getWatermarkHeight(), $col); imagealphablending($newWatermark, true); - imageSaveAlpha($newWatermark, true); + imagesavealpha($newWatermark, true); imagecopyresampled( $newWatermark, $watermark, @@ -451,7 +451,7 @@ public function watermark($imagePath, $positionX = 0, $positionY = 0, $opacity = imagecolortransparent($newWatermark, $col); imagefilledrectangle($newWatermark, 0, 0, $this->_imageSrcWidth, $this->_imageSrcHeight, $col); imagealphablending($newWatermark, true); - imageSaveAlpha($newWatermark, true); + imagesavealpha($newWatermark, true); imagecopyresampled( $newWatermark, $watermark, @@ -669,7 +669,7 @@ private function imageDestroy() private function _saveAlpha($imageHandler) { $background = imagecolorallocate($imageHandler, 0, 0, 0); - ImageColorTransparent($imageHandler, $background); + imagecolortransparent($imageHandler, $background); imagealphablending($imageHandler, false); imagesavealpha($imageHandler, true); } diff --git a/lib/internal/Magento/Framework/Indexer/Action/Base.php b/lib/internal/Magento/Framework/Indexer/Action/Base.php index 11cf1cec62636..636335192cbc5 100644 --- a/lib/internal/Magento/Framework/Indexer/Action/Base.php +++ b/lib/internal/Magento/Framework/Indexer/Action/Base.php @@ -221,7 +221,7 @@ protected function prepareDataSource(array $ids = []) { return !count($ids) ? $this->createResultCollection() - : $this->createResultCollection()->addFieldToFilter($this->getPrimaryResource()->getIdFieldname(), $ids); + : $this->createResultCollection()->addFieldToFilter($this->getPrimaryResource()->getIdFieldName(), $ids); } /** diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Factory/FactoryTest.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Factory/FactoryTest.php index 8deb2750653e7..25a49074c1ad3 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Factory/FactoryTest.php +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Factory/FactoryTest.php @@ -37,7 +37,7 @@ protected function setUp() public function testCreateNoArgs() { - $this->assertInstanceOf('StdClass', $this->factory->create(\StdClass::class)); + $this->assertInstanceOf('StdClass', $this->factory->create(\stdClass::class)); } /** diff --git a/lib/internal/Magento/Framework/RequireJs/Config.php b/lib/internal/Magento/Framework/RequireJs/Config.php index 08131b2cccea3..ae45e29f38911 100644 --- a/lib/internal/Magento/Framework/RequireJs/Config.php +++ b/lib/internal/Magento/Framework/RequireJs/Config.php @@ -157,7 +157,7 @@ public function getConfig() $customConfigFiles = $this->fileSource->getFiles($this->design->getDesignTheme(), self::CONFIG_FILE_NAME); foreach ($customConfigFiles as $file) { /** @var $fileReader \Magento\Framework\Filesystem\File\Read */ - $fileReader = $this->readFactory->create($file->getFileName(), DriverPool::FILE); + $fileReader = $this->readFactory->create($file->getFilename(), DriverPool::FILE); $config = $fileReader->readAll($file->getName()); $distributedConfig .= str_replace( ['%config%', '%context%'], diff --git a/lib/internal/Magento/Framework/Stdlib/Test/Unit/DateTime/DateTimeFormatterTest.php b/lib/internal/Magento/Framework/Stdlib/Test/Unit/DateTime/DateTimeFormatterTest.php index 5012c6a47f1c5..f90b1b2c3fd15 100644 --- a/lib/internal/Magento/Framework/Stdlib/Test/Unit/DateTime/DateTimeFormatterTest.php +++ b/lib/internal/Magento/Framework/Stdlib/Test/Unit/DateTime/DateTimeFormatterTest.php @@ -133,6 +133,6 @@ public function testFormatObjectIfPassedWrongFormat() $reflectionProperty = $reflection->getProperty('localeResolver'); $reflectionProperty->setAccessible(true); $reflectionProperty->setValue($dateTimeFormatter, $this->localeResolverMock); - $dateTimeFormatter->formatObject(new \DateTime('2013-06-06 17:05:06 Europe/Dublin'), new \StdClass()); + $dateTimeFormatter->formatObject(new \DateTime('2013-06-06 17:05:06 Europe/Dublin'), new \stdClass()); } } diff --git a/lib/internal/Magento/Framework/TestFramework/Test/Unit/Unit/Matcher/MethodInvokedAtIndexTest.php b/lib/internal/Magento/Framework/TestFramework/Test/Unit/Unit/Matcher/MethodInvokedAtIndexTest.php index 9721cdb8f9331..52dd39cb7a558 100644 --- a/lib/internal/Magento/Framework/TestFramework/Test/Unit/Unit/Matcher/MethodInvokedAtIndexTest.php +++ b/lib/internal/Magento/Framework/TestFramework/Test/Unit/Unit/Matcher/MethodInvokedAtIndexTest.php @@ -16,7 +16,7 @@ public function testMatches() 'ValidMethodName', [], 'void', - new \StdClass() + new \stdClass() ); $matcher = new \Magento\Framework\TestFramework\Unit\Matcher\MethodInvokedAtIndex(0); $this->assertTrue($matcher->matches($invocationObject)); diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/Config/FileCollector/AggregatedFileCollector.php b/lib/internal/Magento/Framework/View/Element/UiComponent/Config/FileCollector/AggregatedFileCollector.php index 17a320164dad3..9ba7833a355d7 100644 --- a/lib/internal/Magento/Framework/View/Element/UiComponent/Config/FileCollector/AggregatedFileCollector.php +++ b/lib/internal/Magento/Framework/View/Element/UiComponent/Config/FileCollector/AggregatedFileCollector.php @@ -75,7 +75,7 @@ public function collectFiles($searchPattern = null) } $files = $this->collectorAggregated->getFiles($this->design->getDesignTheme(), $searchPattern); foreach ($files as $file) { - $fullFileName = $file->getFileName(); + $fullFileName = $file->getFilename(); $fileDir = dirname($fullFileName); $fileName = basename($fullFileName); $dirRead = $this->readFactory->create($fileDir); diff --git a/lib/internal/Magento/Framework/View/Model/Layout/Merge.php b/lib/internal/Magento/Framework/View/Model/Layout/Merge.php index 06b00afe42ad9..5be878720620b 100644 --- a/lib/internal/Magento/Framework/View/Model/Layout/Merge.php +++ b/lib/internal/Magento/Framework/View/Model/Layout/Merge.php @@ -663,7 +663,7 @@ public function getFileLayoutUpdatesXml() $result = $this->_loadXmlString($result); } else { $result = $this->_loadFileLayoutUpdatesXml(); - $this->_saveCache($result->asXml(), $cacheId); + $this->_saveCache($result->asXML(), $cacheId); } $this->layoutUpdatesCache = $result; return $result; diff --git a/lib/internal/Magento/Framework/View/Page/Config/Reader/Head.php b/lib/internal/Magento/Framework/View/Page/Config/Reader/Head.php index a596b85decff9..510da2b1b1ca9 100644 --- a/lib/internal/Magento/Framework/View/Page/Config/Reader/Head.php +++ b/lib/internal/Magento/Framework/View/Page/Config/Reader/Head.php @@ -147,6 +147,6 @@ private function setMetadata($pageConfigStructure, $node) $metadataName = $node->getAttribute('name'); } - $pageConfigStructure->setMetaData($metadataName, $node->getAttribute('content')); + $pageConfigStructure->setMetadata($metadataName, $node->getAttribute('content')); } } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/Link/CurrentTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/Link/CurrentTest.php index 4515a29c65e4f..909748722a081 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/Link/CurrentTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/Link/CurrentTest.php @@ -57,7 +57,7 @@ public function testIsCurrentIfIsset() /** @var \Magento\Framework\View\Element\Html\Link\Current $link */ $link = $this->_objectManager->getObject(\Magento\Framework\View\Element\Html\Link\Current::class); $link->setCurrent(true); - $this->assertTrue($link->IsCurrent()); + $this->assertTrue($link->isCurrent()); } public function testIsCurrent() diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/Message/MessageConfigurationsPoolTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/Message/MessageConfigurationsPoolTest.php index 1330f0563fc71..406036ed808b9 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/Message/MessageConfigurationsPoolTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/Message/MessageConfigurationsPoolTest.php @@ -54,7 +54,7 @@ public function wrongRenderersDataProvider() return [ [['message_identifier' => []]], [['message_identifier' => ['renderer' => 5]]], - [['message_identifier' => ['renderer' => new \StdClass]]], + [['message_identifier' => ['renderer' => new \stdClass]]], ]; } @@ -87,7 +87,7 @@ public function wrongDataDataProvider() [ [ 'message_identifier' => - ['renderer' => 'RendererCode', 'data' => new \StdClass] + ['renderer' => 'RendererCode', 'data' => new \stdClass] ] ], ]; diff --git a/lib/internal/Magento/Framework/View/Test/Unit/LayoutTest.php b/lib/internal/Magento/Framework/View/Test/Unit/LayoutTest.php index c0300164e26fe..f8a8939bbfe36 100755 --- a/lib/internal/Magento/Framework/View/Test/Unit/LayoutTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/LayoutTest.php @@ -273,7 +273,7 @@ public function testGenerateXml() ->with($this->equalTo([])) ->will($this->returnSelf()); $this->assertSame($this->model, $this->model->generateXml()); - $this->assertSame('<some_update>123</some_update>', $this->model->getNode('some_update')->asXml()); + $this->assertSame('<some_update>123</some_update>', $this->model->getNode('some_update')->asXML()); } public function testGetChildBlock() diff --git a/setup/src/Magento/Setup/Model/PhpReadinessCheck.php b/setup/src/Magento/Setup/Model/PhpReadinessCheck.php index c2bdafa8df82e..2c4967c4c2ffd 100644 --- a/setup/src/Magento/Setup/Model/PhpReadinessCheck.php +++ b/setup/src/Magento/Setup/Model/PhpReadinessCheck.php @@ -286,7 +286,7 @@ private function checkPopulateRawPostSetting() $data = []; $error = false; - $iniSetting = intVal(ini_get('always_populate_raw_post_data')); + $iniSetting = intval(ini_get('always_populate_raw_post_data')); $checkVersionConstraint = $this->versionParser->parseConstraints('~5.6.0'); $normalizedPhpVersion = $this->getNormalizedCurrentPhpVersion(PHP_VERSION); @@ -302,7 +302,7 @@ private function checkPopulateRawPostSetting() Please open your php.ini file and set always_populate_raw_post_data to -1. If you need more help please call your hosting provider.', PHP_VERSION, - intVal(ini_get('always_populate_raw_post_data')) + intval(ini_get('always_populate_raw_post_data')) ); $data['always_populate_raw_post_data'] = [ From 70cbd3cf8b46d18824b316c55c93ea68ffbc47d3 Mon Sep 17 00:00:00 2001 From: Iurii Ivashchenko <iivashchenko@magento.com> Date: Fri, 15 Jun 2018 10:44:19 +0300 Subject: [PATCH 140/206] MAGETWO-91411: Delete action in grid could be sent multiple times - test refactoring --- .../Adminhtml/Index/MassAssignGroupTest.php | 64 ++++++++----------- .../Adminhtml/Index/MassDeleteTest.php | 54 ++++++++-------- .../Adminhtml/Index/MassSubscribeTest.php | 17 ++--- .../_files/five_repository_customers.php | 2 +- .../five_repository_customers_rollback.php | 2 +- 5 files changed, 60 insertions(+), 79 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/MassAssignGroupTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/MassAssignGroupTest.php index 5fc5f8b968ea9..7c64c946e7db9 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/MassAssignGroupTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/MassAssignGroupTest.php @@ -7,9 +7,9 @@ namespace Magento\Customer\Controller\Adminhtml\Index; +use Magento\Backend\Model\Session; use Magento\Customer\Api\CustomerRepositoryInterface; use Magento\Customer\Api\Data\CustomerInterface; -use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Message\MessageInterface; use Magento\TestFramework\Helper\Bootstrap; use Magento\TestFramework\TestCase\AbstractBackendController; @@ -42,12 +42,12 @@ protected function tearDown() /** * Unset customer data */ - Bootstrap::getObjectManager()->get(\Magento\Backend\Model\Session::class)->setCustomerData(null); + Bootstrap::getObjectManager()->get(Session::class)->setCustomerData(null); /** * Unset messages */ - Bootstrap::getObjectManager()->get(\Magento\Backend\Model\Session::class)->getMessages(true); + Bootstrap::getObjectManager()->get(Session::class)->getMessages(true); } /** @@ -59,30 +59,26 @@ protected function tearDown() public function testMassAssignGroupAction() { $customerEmail = 'customer1@example.com'; - try { - /** @var CustomerInterface $customer */ - $customer = $this->customerRepository->get($customerEmail); - $this->assertEquals(1, $customer->getGroupId()); + /** @var CustomerInterface $customer */ + $customer = $this->customerRepository->get($customerEmail); + $this->assertEquals(1, $customer->getGroupId()); - $params = [ - 'group' => 0, - 'namespace' => 'customer_listing', - 'selected' => [$customer->getId()] - ]; + $params = [ + 'group' => 0, + 'namespace' => 'customer_listing', + 'selected' => [$customer->getId()] + ]; - $this->getRequest()->setParams($params); - $this->dispatch('backend/customer/index/massAssignGroup'); - $this->assertSessionMessages( - self::equalTo(['A total of 1 record(s) were updated.']), - MessageInterface::TYPE_SUCCESS - ); - $this->assertRedirect($this->stringStartsWith($this->baseControllerUrl)); + $this->getRequest()->setParams($params); + $this->dispatch('backend/customer/index/massAssignGroup'); + $this->assertSessionMessages( + self::equalTo(['A total of 1 record(s) were updated.']), + MessageInterface::TYPE_SUCCESS + ); + $this->assertRedirect($this->stringStartsWith($this->baseControllerUrl)); - $customer = $this->customerRepository->get($customerEmail); - $this->assertEquals(0, $customer->getGroupId()); - } catch (LocalizedException $e) { - self::fail($e->getMessage()); - } + $customer = $this->customerRepository->get($customerEmail); + $this->assertEquals(0, $customer->getGroupId()); } /** @@ -96,13 +92,9 @@ public function testLargeGroupMassAssignGroupAction() $ids = []; for ($i = 1; $i <= 5; $i++) { /** @var CustomerInterface $customer */ - try { - $customer = $this->customerRepository->get('customer'.$i.'@example.com'); - $this->assertEquals(1, $customer->getGroupId()); - $ids[] = $customer->getId(); - } catch (\Exception $e) { - self::fail($e->getMessage()); - } + $customer = $this->customerRepository->get('customer' . $i . '@example.com'); + $this->assertEquals(1, $customer->getGroupId()); + $ids[] = $customer->getId(); } $params = [ @@ -119,13 +111,9 @@ public function testLargeGroupMassAssignGroupAction() ); $this->assertRedirect($this->stringStartsWith($this->baseControllerUrl)); for ($i = 1; $i < 5; $i++) { - try { - /** @var CustomerInterface $customer */ - $customer = $this->customerRepository->get('customer'.$i.'@example.com'); - $this->assertEquals(0, $customer->getGroupId()); - } catch (\Exception $e) { - self::fail($e->getMessage()); - } + /** @var CustomerInterface $customer */ + $customer = $this->customerRepository->get('customer' . $i . '@example.com'); + $this->assertEquals(0, $customer->getGroupId()); } } diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/MassDeleteTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/MassDeleteTest.php index 7048aa2c20f7f..2a916c1c00c66 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/MassDeleteTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/MassDeleteTest.php @@ -7,9 +7,9 @@ namespace Magento\Customer\Controller\Adminhtml\Index; +use Magento\Backend\Model\Session; use Magento\Customer\Api\CustomerRepositoryInterface; use Magento\Customer\Api\Data\CustomerInterface; -use Magento\Framework\Exception\LocalizedException; use PHPUnit\Framework\Constraint\Constraint; use Magento\Framework\Message\MessageInterface; use Magento\TestFramework\Helper\Bootstrap; @@ -38,6 +38,19 @@ protected function setUp() $this->customerRepository = Bootstrap::getObjectManager()->get(CustomerRepositoryInterface::class); } + protected function tearDown() + { + /** + * Unset customer data + */ + Bootstrap::getObjectManager()->get(Session::class)->setCustomerData(null); + + /** + * Unset messages + */ + Bootstrap::getObjectManager()->get(Session::class)->getMessages(true); + } + /** * Validates failure attempts to delete customers from grid. * @@ -65,22 +78,18 @@ public function testFailedMassDeleteAction($ids, Constraint $constraint, $messag */ public function testSuccessMassDeleteAction(array $emails, Constraint $constraint, string $messageType) { - try { - $ids = []; - foreach ($emails as $email) { - /** @var CustomerInterface $customer */ - $customer = $this->customerRepository->get($email); - $ids[] = $customer->getId(); - } - - $this->massDeleteAssertions( - $ids, - $constraint, - $messageType - ); - } catch (LocalizedException $e) { - self::fail($e->getMessage()); + $ids = []; + foreach ($emails as $email) { + /** @var CustomerInterface $customer */ + $customer = $this->customerRepository->get($email); + $ids[] = $customer->getId(); } + + $this->massDeleteAssertions( + $ids, + $constraint, + $messageType + ); } /** @@ -152,17 +161,4 @@ public function successRequestDataProvider(): array ], ]; } - - protected function tearDown() - { - /** - * Unset customer data - */ - Bootstrap::getObjectManager()->get(\Magento\Backend\Model\Session::class)->setCustomerData(null); - - /** - * Unset messages - */ - Bootstrap::getObjectManager()->get(\Magento\Backend\Model\Session::class)->getMessages(true); - } } diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/MassSubscribeTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/MassSubscribeTest.php index 27b78ea065821..e4b9eed2e53d5 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/MassSubscribeTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/MassSubscribeTest.php @@ -7,6 +7,7 @@ namespace Magento\Customer\Controller\Adminhtml\Index; +use Magento\Backend\Model\Session; use Magento\Framework\Message\MessageInterface; use Magento\Newsletter\Model\Subscriber; use Magento\Newsletter\Model\SubscriberFactory; @@ -31,12 +32,12 @@ protected function tearDown() /** * Unset customer data */ - Bootstrap::getObjectManager()->get(\Magento\Backend\Model\Session::class)->setCustomerData(null); + Bootstrap::getObjectManager()->get(Session::class)->setCustomerData(null); /** * Unset messages */ - Bootstrap::getObjectManager()->get(\Magento\Backend\Model\Session::class)->getMessages(true); + Bootstrap::getObjectManager()->get(Session::class)->getMessages(true); } /** @@ -62,14 +63,10 @@ public function testMassSubscriberAction() ->getSubscriberStatus() ); - try { - /** @var CustomerInterface $customer1 */ - $customer1 = $customerRepository->get('customer1@example.com'); - /** @var CustomerInterface $customer2 */ - $customer2 = $customerRepository->get('customer2@example.com'); - } catch (\Exception $e) { - self::fail($e->getMessage()); - } + /** @var CustomerInterface $customer1 */ + $customer1 = $customerRepository->get('customer1@example.com'); + /** @var CustomerInterface $customer2 */ + $customer2 = $customerRepository->get('customer2@example.com'); $params = [ 'selected' => [ diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/five_repository_customers.php b/dev/tests/integration/testsuite/Magento/Customer/_files/five_repository_customers.php index 7849764ca219b..1722e471a5bbc 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/_files/five_repository_customers.php +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/five_repository_customers.php @@ -21,7 +21,7 @@ /** @var CustomerInterfaceFactory $customerFactory */ $customerFactory = $objectManager->get(CustomerInterfaceFactory::class); -for ($i=1; $i<=5; $i++) { +for ($i = 1; $i <= 5; $i++) { /** @var CustomerInterface $customer */ $customer = $customerFactory->create(); $customer->setFirstname('John') diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/five_repository_customers_rollback.php b/dev/tests/integration/testsuite/Magento/Customer/_files/five_repository_customers_rollback.php index f9062fb6083c5..5272d9cdbf06d 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/_files/five_repository_customers_rollback.php +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/five_repository_customers_rollback.php @@ -15,7 +15,7 @@ /** @var CustomerRepositoryInterface $repository */ $customerRepository = $objectManager->create(CustomerRepositoryInterface::class); -for ($i=1; $i<=5; $i++) { +for ($i = 1; $i <= 5; $i++) { try { /** @var CustomerInterface $customer */ $customer = $customerRepository->get('customer'.$i.'@example.com'); From f90409cbc22e392249e089f972297a5edf2798fc Mon Sep 17 00:00:00 2001 From: Michail Slabko <mslabko@magento.com> Date: Fri, 15 Jun 2018 12:10:07 +0300 Subject: [PATCH 141/206] MAGETWO-91820: Stabilize builds - MAGETWO-64467 [Indexer optimizations] Tables sharding / segmentation for price indexer --- .../Product/Price/DimensionModeConfiguration.php | 4 ++-- .../Indexer/Product/Price/Plugin/TableResolver.php | 10 +++++++--- app/code/Magento/Catalog/etc/di.xml | 1 + 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionModeConfiguration.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionModeConfiguration.php index cd13d10593fe9..91fd384fcf23e 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionModeConfiguration.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionModeConfiguration.php @@ -64,7 +64,7 @@ public function __construct(ScopeConfigInterface $scopeConfig) * @param string|null $mode * @return string[] */ - public function getDimensionConfiguration(string $mode = null) + public function getDimensionConfiguration(string $mode = null): array { if ($mode && !isset($this->modesMapping[$mode])) { throw new \InvalidArgumentException( @@ -77,7 +77,7 @@ public function getDimensionConfiguration(string $mode = null) /** * @return string */ - private function getCurrentMode(): string + public function getCurrentMode(): string { if (null === $this->currentMode) { $this->currentMode = $this->scopeConfig->getValue(ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/TableResolver.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/TableResolver.php index 8c0dc26d8fd4d..0b0d3432c4d2a 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/TableResolver.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/TableResolver.php @@ -78,7 +78,7 @@ public function __construct( * * @param ResourceConnection $subject * @param string $result - * @param string|string[] $modelEntity + * @param string|string[] $tableName * @return string * @throws \Magento\Framework\Exception\NoSuchEntityException * @SuppressWarnings(PHPMD.UnusedFormalParameter) @@ -86,9 +86,13 @@ public function __construct( public function afterGetTableName( ResourceConnection $subject, string $result, - $modelEntity + $tableName ) { - if (!is_array($modelEntity) && $modelEntity === 'catalog_product_index_price') { + if ( + !is_array($tableName) + && $tableName === 'catalog_product_index_price' + && $this->dimensionModeConfiguration->getCurrentMode() !== DimensionModeConfiguration::DIMENSION_NONE + ) { return $this->priceTableResolver->resolve('catalog_product_index_price', $this->getDimensions()); } diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml index afd117787657b..10d068e61f22c 100644 --- a/app/code/Magento/Catalog/etc/di.xml +++ b/app/code/Magento/Catalog/etc/di.xml @@ -1097,6 +1097,7 @@ <argument name="context" xsi:type="object"> Magento\Framework\App\Http\Context\Proxy </argument> + <!-- Unccomment after fix issue with Proxy generation --> <!--<argument name="dimensionModeConfiguration" xsi:type="object">--> <!--Magento\Catalog\Model\Indexer\Product\Price\DimensionModeConfiguration\Proxy--> <!--</argument>--> From f85feba891abe0323c1a4a26e942295be386862e Mon Sep 17 00:00:00 2001 From: Michail Slabko <mslabko@magento.com> Date: Fri, 15 Jun 2018 12:20:37 +0300 Subject: [PATCH 142/206] MAGETWO-91820: Stabilize builds - MAGETWO-64467 [Indexer optimizations] Tables sharding / segmentation for price indexer --- .../PriceIndexerDimensionsModeSetCommand.php | 3 ++- .../Product/Price/Plugin/CustomerGroup.php | 4 ++-- .../Product/Price/Plugin/TableResolver.php | 3 --- .../Indexer/Product/Price/Plugin/Website.php | 4 ++-- .../Product/Price/PriceTableResolver.php | 4 +--- app/code/Magento/Catalog/etc/di.xml | 3 --- ...iceIndexerDimensionsModeSetCommandTest.php | 20 +++++++++++++++---- 7 files changed, 23 insertions(+), 18 deletions(-) diff --git a/app/code/Magento/Catalog/Console/Command/PriceIndexerDimensionsModeSetCommand.php b/app/code/Magento/Catalog/Console/Command/PriceIndexerDimensionsModeSetCommand.php index 736f2ad4bea46..0660d4d6ceb36 100644 --- a/app/code/Magento/Catalog/Console/Command/PriceIndexerDimensionsModeSetCommand.php +++ b/app/code/Magento/Catalog/Console/Command/PriceIndexerDimensionsModeSetCommand.php @@ -153,7 +153,8 @@ public function getInputList(): array $modeOptions[] = new InputArgument( self::INPUT_KEY_MODE, InputArgument::REQUIRED, - 'Indexer dimensions mode ['. DimensionModeConfiguration::DIMENSION_NONE . '|' . DimensionModeConfiguration::DIMENSION_WEBSITE + 'Indexer dimensions mode ['. DimensionModeConfiguration::DIMENSION_NONE + . '|' . DimensionModeConfiguration::DIMENSION_WEBSITE . '|' . DimensionModeConfiguration::DIMENSION_CUSTOMER_GROUP . '|' . DimensionModeConfiguration::DIMENSION_WEBSITE_AND_CUSTOMER_GROUP .']' ); diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CustomerGroup.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CustomerGroup.php index b762b714290c9..84e53834cd838 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CustomerGroup.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CustomerGroup.php @@ -120,7 +120,7 @@ private function getAffectedDimensions(string $groupId): array { $currentDimensions = $this->dimensionModeConfiguration->getDimensionConfiguration(); // do not return dimensions if Customer Group dimension is not present in configuration - if (!in_array( CustomerGroupDataProvider::DIMENSION_NAME, $currentDimensions, true)) { + if (!in_array(CustomerGroupDataProvider::DIMENSION_NAME, $currentDimensions, true)) { return []; } $customerGroupDimension = $this->dimensionFactory->create( @@ -129,7 +129,7 @@ private function getAffectedDimensions(string $groupId): array ); $dimensions = []; - if (in_array( WebsiteDataProvider::DIMENSION_NAME, $currentDimensions, true)) { + if (in_array(WebsiteDataProvider::DIMENSION_NAME, $currentDimensions, true)) { foreach ($this->websiteDataProvider as $websiteDimension) { $dimensions[] = [ $customerGroupDimension, diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/TableResolver.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/TableResolver.php index 0b0d3432c4d2a..f165bd6d2467f 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/TableResolver.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/TableResolver.php @@ -8,7 +8,6 @@ namespace Magento\Catalog\Model\Indexer\Product\Price\Plugin; use Magento\Catalog\Model\Indexer\Product\Price\DimensionModeConfiguration; -use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\App\ResourceConnection; use Magento\Framework\Indexer\DimensionFactory; use Magento\Framework\Search\Request\IndexScopeResolverInterface; @@ -51,7 +50,6 @@ class TableResolver private $dimensionModeConfiguration; /** - * @param ScopeConfigInterface $scopeConfig * @param IndexScopeResolverInterface $priceTableResolver * @param StoreManagerInterface $storeManager * @param Context $context @@ -59,7 +57,6 @@ class TableResolver * @param DimensionModeConfiguration $dimensionModeConfiguration */ public function __construct( - ScopeConfigInterface $scopeConfig, IndexScopeResolverInterface $priceTableResolver, StoreManagerInterface $storeManager, Context $context, diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/Website.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/Website.php index 2db0cfd495278..30b0a80c9e4ee 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/Website.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/Website.php @@ -107,7 +107,7 @@ private function getAffectedDimensions(string $websiteId): array { $currentDimensions = $this->dimensionModeConfiguration->getDimensionConfiguration(); // do not return dimensions if Website dimension is not present in configuration - if (!in_array( WebsiteDataProvider::DIMENSION_NAME, $currentDimensions, true)) { + if (!in_array(WebsiteDataProvider::DIMENSION_NAME, $currentDimensions, true)) { return []; } $websiteDimension = $this->dimensionFactory->create( @@ -116,7 +116,7 @@ private function getAffectedDimensions(string $websiteId): array ); $dimensions = []; - if (in_array( CustomerGroupDataProvider::DIMENSION_NAME, $currentDimensions, true)) { + if (in_array(CustomerGroupDataProvider::DIMENSION_NAME, $currentDimensions, true)) { foreach ($this->customerGroupDataProvider as $customerGroupDimension) { $dimensions[] = [ $customerGroupDimension, diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php index 1e2763235bb34..b690d6f871d37 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php @@ -8,7 +8,6 @@ use Magento\Framework\Indexer\Dimension; use Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver; -use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\Search\Request\IndexScopeResolverInterface; class PriceTableResolver implements IndexScopeResolverInterface @@ -24,11 +23,10 @@ class PriceTableResolver implements IndexScopeResolverInterface private $dimensionModeConfiguration; /** - * @param ScopeConfigInterface $scopeConfig * @param IndexScopeResolver $indexScopeResolver + * @param DimensionModeConfiguration $dimensionModeConfiguration */ public function __construct( - ScopeConfigInterface $scopeConfig, IndexScopeResolver $indexScopeResolver, DimensionModeConfiguration $dimensionModeConfiguration ) { diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml index 10d068e61f22c..eb6118225f5d9 100644 --- a/app/code/Magento/Catalog/etc/di.xml +++ b/app/code/Magento/Catalog/etc/di.xml @@ -1085,9 +1085,6 @@ </type> <type name="Magento\Catalog\Model\Indexer\Product\Price\Plugin\TableResolver"> <arguments> - <argument name="scopeConfig" xsi:type="object"> - Magento\Framework\App\Config\ScopeConfigInterface\Proxy - </argument> <argument name="priceTableResolver" xsi:type="object"> Magento\Catalog\Model\Indexer\Product\Price\PriceTableResolver\Proxy </argument> diff --git a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/PriceIndexerDimensionsModeSetCommandTest.php b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/PriceIndexerDimensionsModeSetCommandTest.php index a7e1fbea4dffb..c8bdf3201220a 100644 --- a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/PriceIndexerDimensionsModeSetCommandTest.php +++ b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/PriceIndexerDimensionsModeSetCommandTest.php @@ -104,10 +104,22 @@ public function modesDataProvider() return [ [DimensionModeConfiguration::DIMENSION_NONE, DimensionModeConfiguration::DIMENSION_WEBSITE], [DimensionModeConfiguration::DIMENSION_WEBSITE, DimensionModeConfiguration::DIMENSION_CUSTOMER_GROUP], - [DimensionModeConfiguration::DIMENSION_CUSTOMER_GROUP, DimensionModeConfiguration::DIMENSION_WEBSITE_AND_CUSTOMER_GROUP], - [DimensionModeConfiguration::DIMENSION_WEBSITE_AND_CUSTOMER_GROUP, DimensionModeConfiguration::DIMENSION_NONE], - [DimensionModeConfiguration::DIMENSION_NONE, DimensionModeConfiguration::DIMENSION_WEBSITE_AND_CUSTOMER_GROUP], - [DimensionModeConfiguration::DIMENSION_WEBSITE_AND_CUSTOMER_GROUP, DimensionModeConfiguration::DIMENSION_CUSTOMER_GROUP], + [ + DimensionModeConfiguration::DIMENSION_CUSTOMER_GROUP, + DimensionModeConfiguration::DIMENSION_WEBSITE_AND_CUSTOMER_GROUP + ], + [ + DimensionModeConfiguration::DIMENSION_WEBSITE_AND_CUSTOMER_GROUP, + DimensionModeConfiguration::DIMENSION_NONE + ], + [ + DimensionModeConfiguration::DIMENSION_NONE, + DimensionModeConfiguration::DIMENSION_WEBSITE_AND_CUSTOMER_GROUP + ], + [ + DimensionModeConfiguration::DIMENSION_WEBSITE_AND_CUSTOMER_GROUP, + DimensionModeConfiguration::DIMENSION_CUSTOMER_GROUP + ], [DimensionModeConfiguration::DIMENSION_CUSTOMER_GROUP, DimensionModeConfiguration::DIMENSION_WEBSITE], [DimensionModeConfiguration::DIMENSION_WEBSITE, DimensionModeConfiguration::DIMENSION_NONE], ]; From aaafe3c1d218787664345b173c7aebbd4dbb5d1c Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov <slopukhov@magento.com> Date: Fri, 15 Jun 2018 13:16:51 +0300 Subject: [PATCH 143/206] MAGETWO-91820: Stabilize builds --- .../Model/Indexer/Product/Price/Plugin/TableResolver.php | 3 +-- .../Command/PriceIndexerDimensionsModeSetCommandTest.php | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/TableResolver.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/TableResolver.php index f165bd6d2467f..1c11206864542 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/TableResolver.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/TableResolver.php @@ -85,8 +85,7 @@ public function afterGetTableName( string $result, $tableName ) { - if ( - !is_array($tableName) + if (!is_array($tableName) && $tableName === 'catalog_product_index_price' && $this->dimensionModeConfiguration->getCurrentMode() !== DimensionModeConfiguration::DIMENSION_NONE ) { diff --git a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/PriceIndexerDimensionsModeSetCommandTest.php b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/PriceIndexerDimensionsModeSetCommandTest.php index c8bdf3201220a..f8c65117976eb 100644 --- a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/PriceIndexerDimensionsModeSetCommandTest.php +++ b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/PriceIndexerDimensionsModeSetCommandTest.php @@ -159,7 +159,8 @@ public function testSwitchModeWithInvalidArgument() { $this->commandTester->execute( [ - PriceIndexerDimensionsModeSetCommand::INPUT_KEY_MODE => DimensionModeConfiguration::DIMENSION_NONE . '_not_valid' + PriceIndexerDimensionsModeSetCommand::INPUT_KEY_MODE => DimensionModeConfiguration::DIMENSION_NONE . + '_not_valid' ] ); } From 1ab103d4f2c9390ee0e74f0c711554f8558c647e Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov <slopukhov@magento.com> Date: Fri, 15 Jun 2018 13:38:51 +0300 Subject: [PATCH 144/206] MAGETWO-91820: Stabilize builds --- .../Product/Price/Plugin/WebsiteTest.php | 95 +++++++++++++++---- 1 file changed, 78 insertions(+), 17 deletions(-) diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Plugin/WebsiteTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Plugin/WebsiteTest.php index 507f22cf052b1..c88b6695b779f 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Plugin/WebsiteTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Plugin/WebsiteTest.php @@ -19,11 +19,6 @@ class WebsiteTest extends \PHPUnit\Framework\TestCase */ protected $model; - /** - * @var \Magento\Catalog\Model\Indexer\Product\Price\Processor|\PHPUnit_Framework_MockObject_MockObject - */ - protected $scopeConfig; - /** * @var \Magento\Framework\Indexer\DimensionFactory|\PHPUnit_Framework_MockObject_MockObject */ @@ -34,15 +29,15 @@ class WebsiteTest extends \PHPUnit\Framework\TestCase */ protected $tableMaintainer; + /** + * @var DimensionModeConfiguration|\PHPUnit_Framework_MockObject_MockObject + */ + protected $dimensionModeConfiguration; + protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->scopeConfig = $this->createPartialMock( - \Magento\Framework\App\Config\ScopeConfigInterface::class, - ['getValue', 'isSetFlag'] - ); - $this->dimensionFactory = $this->createPartialMock( \Magento\Framework\Indexer\DimensionFactory::class, ['create'] @@ -53,12 +48,17 @@ protected function setUp() ['dropTablesForDimensions', 'createTablesForDimensions'] ); + $this->dimensionModeConfiguration = $this->createPartialMock( + DimensionModeConfiguration::class, + ['getDimensionConfiguration'] + ); + $this->model = $this->objectManager->getObject( \Magento\Catalog\Model\Indexer\Product\Price\Plugin\Website::class, [ - 'configReader' => $this->scopeConfig, 'dimensionFactory' => $this->dimensionFactory, 'tableMaintainer' => $this->tableMaintainer, + 'dimensionModeConfiguration' => $this->dimensionModeConfiguration, ] ); } @@ -67,9 +67,6 @@ public function testAfterDelete() { $dimensionMock = $this->createMock(\Magento\Framework\Indexer\Dimension::class); - $this->scopeConfig->expects($this->once())->method('getValue')->willReturn( - DimensionModeConfiguration::DIMENSION_WEBSITE - ); $this->dimensionFactory->expects($this->once())->method('create')->willReturn( $dimensionMock ); @@ -77,6 +74,10 @@ public function testAfterDelete() [$dimensionMock] ); + $this->dimensionModeConfiguration->expects($this->once())->method('getDimensionConfiguration')->willReturn( + [\Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider::DIMENSION_NAME] + ); + $subjectMock = $this->createMock(\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class); $objectResourceMock = $this->createMock(\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class); $websiteMock = $this->createMock(\Magento\Framework\Model\AbstractModel::class); @@ -90,13 +91,38 @@ public function testAfterDelete() ); } - public function testAfterSave() + public function testAfterDeleteOnModeWithoutWebsiteDimension() { $dimensionMock = $this->createMock(\Magento\Framework\Indexer\Dimension::class); - $this->scopeConfig->expects($this->once())->method('getValue')->willReturn( - DimensionModeConfiguration::DIMENSION_WEBSITE + $this->dimensionFactory->expects($this->never())->method('create')->willReturn( + $dimensionMock + ); + $this->tableMaintainer->expects($this->never())->method('dropTablesForDimensions')->with( + [$dimensionMock] ); + + $this->dimensionModeConfiguration->expects($this->once())->method('getDimensionConfiguration')->willReturn( + [] + ); + + $subjectMock = $this->createMock(\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class); + $objectResourceMock = $this->createMock(\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class); + $websiteMock = $this->createMock(\Magento\Framework\Model\AbstractModel::class); + $websiteMock->expects($this->once()) + ->method('getId') + ->willReturn(1); + + $this->assertEquals( + $objectResourceMock, + $this->model->afterDelete($subjectMock, $objectResourceMock, $websiteMock) + ); + } + + public function testAfterSave() + { + $dimensionMock = $this->createMock(\Magento\Framework\Indexer\Dimension::class); + $this->dimensionFactory->expects($this->once())->method('create')->willReturn( $dimensionMock ); @@ -104,6 +130,41 @@ public function testAfterSave() [$dimensionMock] ); + $this->dimensionModeConfiguration->expects($this->once())->method('getDimensionConfiguration')->willReturn( + [\Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider::DIMENSION_NAME] + ); + + $subjectMock = $this->createMock(\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class); + $objectResourceMock = $this->createMock(\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class); + $websiteMock = $this->createMock(\Magento\Framework\Model\AbstractModel::class); + $websiteMock->expects($this->once()) + ->method('getId') + ->willReturn(1); + $websiteMock->expects($this->once()) + ->method('isObjectNew') + ->willReturn(true); + + $this->assertEquals( + $objectResourceMock, + $this->model->afterSave($subjectMock, $objectResourceMock, $websiteMock) + ); + } + + public function testAfterSaveOnModeWithoutWebsiteDimension() + { + $dimensionMock = $this->createMock(\Magento\Framework\Indexer\Dimension::class); + + $this->dimensionFactory->expects($this->never())->method('create')->willReturn( + $dimensionMock + ); + $this->tableMaintainer->expects($this->never())->method('createTablesForDimensions')->with( + [$dimensionMock] + ); + + $this->dimensionModeConfiguration->expects($this->once())->method('getDimensionConfiguration')->willReturn( + [] + ); + $subjectMock = $this->createMock(\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class); $objectResourceMock = $this->createMock(\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class); $websiteMock = $this->createMock(\Magento\Framework\Model\AbstractModel::class); From b08a1e80fc86718e02554c86bc4fc7881c57680e Mon Sep 17 00:00:00 2001 From: Andrii Voskoboinikov <avoskoboinikov@magento.com> Date: Fri, 15 Jun 2018 14:41:57 +0300 Subject: [PATCH 145/206] MAGETWO-92693: Some improvements on product create|edit page in admin area --- .../Test/Unit/Model/ProductRepositoryTest.php | 66 ++++++++++++------- 1 file changed, 43 insertions(+), 23 deletions(-) diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php index a9760d81bbac4..5239ae6fdc91a 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php @@ -195,6 +195,7 @@ protected function setUp() 'load', 'getOptions', 'getSku', + 'getId', 'hasGalleryAttribute', 'getMediaConfig', 'getMediaAttributes', @@ -282,7 +283,7 @@ protected function setUp() */ public function testGetAbsentProduct() { - $this->productFactory->expects($this->once())->method('create') + $this->productFactory->expects($this->never())->method('create') ->will($this->returnValue($this->product)); $this->resourceModelMock->expects($this->once())->method('getIdBySku')->with('test_sku') ->will($this->returnValue(null)); @@ -293,25 +294,27 @@ public function testGetAbsentProduct() public function testCreateCreatesProduct() { $sku = 'test_sku'; - $this->productFactory->expects($this->once())->method('create') - ->will($this->returnValue($this->product)); $this->resourceModelMock->expects($this->once())->method('getIdBySku')->with($sku) ->will($this->returnValue('test_id')); + $this->productFactory->expects($this->once())->method('create') + ->will($this->returnValue($this->product)); $this->product->expects($this->once())->method('load')->with('test_id'); - $this->product->expects($this->once())->method('getSku')->willReturn($sku); + $this->product->expects($this->any())->method('getId')->willReturn('test_id'); + $this->product->expects($this->any())->method('getSku')->willReturn($sku); $this->assertEquals($this->product, $this->model->get($sku)); } public function testGetProductInEditMode() { $sku = 'test_sku'; - $this->productFactory->expects($this->once())->method('create') - ->will($this->returnValue($this->product)); $this->resourceModelMock->expects($this->once())->method('getIdBySku')->with($sku) ->will($this->returnValue('test_id')); + $this->productFactory->expects($this->once())->method('create') + ->will($this->returnValue($this->product)); $this->product->expects($this->once())->method('setData')->with('_edit_mode', true); $this->product->expects($this->once())->method('load')->with('test_id'); - $this->product->expects($this->once())->method('getSku')->willReturn($sku); + $this->product->expects($this->any())->method('getId')->willReturn('test_id'); + $this->product->expects($this->any())->method('getSku')->willReturn($sku); $this->assertEquals($this->product, $this->model->get($sku, true)); } @@ -319,12 +322,13 @@ public function testGetBySkuWithSpace() { $trimmedSku = 'test_sku'; $sku = 'test_sku '; - $this->productFactory->expects($this->once())->method('create') - ->will($this->returnValue($this->product)); $this->resourceModelMock->expects($this->once())->method('getIdBySku')->with($sku) ->will($this->returnValue('test_id')); + $this->productFactory->expects($this->once())->method('create') + ->will($this->returnValue($this->product)); $this->product->expects($this->once())->method('load')->with('test_id'); - $this->product->expects($this->once())->method('getSku')->willReturn($trimmedSku); + $this->product->expects($this->any())->method('getId')->willReturn('test_id'); + $this->product->expects($this->any())->method('getSku')->willReturn($trimmedSku); $this->assertEquals($this->product, $this->model->get($sku)); } @@ -333,12 +337,12 @@ public function testGetWithSetStoreId() $productId = 123; $sku = 'test-sku'; $storeId = 7; - $this->productFactory->expects($this->once())->method('create')->willReturn($this->product); $this->resourceModelMock->expects($this->once())->method('getIdBySku')->with($sku)->willReturn($productId); + $this->productFactory->expects($this->once())->method('create')->willReturn($this->product); $this->product->expects($this->once())->method('setData')->with('store_id', $storeId); $this->product->expects($this->once())->method('load')->with($productId); - $this->product->expects($this->once())->method('getId')->willReturn($productId); - $this->product->expects($this->once())->method('getSku')->willReturn($sku); + $this->product->expects($this->any())->method('getId')->willReturn($productId); + $this->product->expects($this->any())->method('getSku')->willReturn($sku); $this->assertSame($this->product, $this->model->get($sku, false, $storeId)); } @@ -498,13 +502,13 @@ public function testGetForcedReload() $editMode = false; $storeId = 0; + $this->resourceModelMock->expects($this->exactly(2))->method('getIdBySku') + ->with($sku)->willReturn($id); $this->productFactory->expects($this->exactly(2))->method('create') ->will($this->returnValue($this->product)); $this->product->expects($this->exactly(2))->method('load'); - $this->product->expects($this->exactly(2))->method('getId')->willReturn($sku); - $this->resourceModelMock->expects($this->exactly(2))->method('getIdBySku') - ->with($sku)->willReturn($id); - $this->product->expects($this->exactly(2))->method('getSku')->willReturn($sku); + $this->product->expects($this->any())->method('getId')->willReturn($id); + $this->product->expects($this->any())->method('getSku')->willReturn($sku); $this->assertEquals($this->product, $this->model->get($sku, $editMode, $storeId)); //second invocation should just return from cache @@ -550,8 +554,9 @@ public function testGetBySkuFromCacheInitializedInGetById() public function testSaveExisting() { + $id = 100; $this->storeManagerMock->expects($this->any())->method('getWebsites')->willReturn([1 => 'default']); - $this->resourceModelMock->expects($this->any())->method('getIdBySku')->will($this->returnValue(100)); + $this->resourceModelMock->expects($this->any())->method('getIdBySku')->will($this->returnValue($id)); $this->productFactory->expects($this->any()) ->method('create') ->will($this->returnValue($this->product)); @@ -565,15 +570,20 @@ public function testSaveExisting() ->will($this->returnValue($this->productData)); $this->product->expects($this->once())->method('getWebsiteIds')->willReturn([]); $this->product->expects($this->atLeastOnce())->method('getSku')->willReturn($this->productData['sku']); + $this->product->expects($this->at(0))->method('getId')->willReturn(null); + $this->product->expects($this->any())->method('getId')->willReturn($id); $this->assertEquals($this->product, $this->model->save($this->product)); } public function testSaveNew() { + $id = 100; $this->storeManagerMock->expects($this->any())->method('getWebsites')->willReturn([1 => 'default']); $this->resourceModelMock->expects($this->at(0))->method('getIdBySku')->will($this->returnValue(null)); - $this->resourceModelMock->expects($this->at(3))->method('getIdBySku')->will($this->returnValue(100)); + $this->resourceModelMock->expects($this->at(3))->method('getIdBySku')->will($this->returnValue($id)); + $this->product->expects($this->at(0))->method('getId')->willReturn(null); + $this->product->expects($this->any())->method('getId')->willReturn($id); $this->productFactory->expects($this->any()) ->method('create') ->will($this->returnValue($this->product)); @@ -603,7 +613,7 @@ public function testSaveUnableToSaveException() $this->resourceModelMock->expects($this->exactly(1)) ->method('getIdBySku') ->willReturn(null); - $this->productFactory->expects($this->exactly(2)) + $this->productFactory->expects($this->exactly(1)) ->method('create') ->will($this->returnValue($this->product)); $this->initializationHelperMock->expects($this->never())->method('initialize'); @@ -633,7 +643,7 @@ public function testSaveException() $this->resourceModelMock->expects($this->exactly(1)) ->method('getIdBySku') ->willReturn(null); - $this->productFactory->expects($this->exactly(2)) + $this->productFactory->expects($this->exactly(1)) ->method('create') ->will($this->returnValue($this->product)); $this->initializationHelperMock->expects($this->never())->method('initialize'); @@ -662,7 +672,7 @@ public function testSaveInvalidProductException() { $this->storeManagerMock->expects($this->any())->method('getWebsites')->willReturn([1 => 'default']); $this->resourceModelMock->expects($this->exactly(1))->method('getIdBySku')->will($this->returnValue(null)); - $this->productFactory->expects($this->exactly(2)) + $this->productFactory->expects($this->exactly(1)) ->method('create') ->will($this->returnValue($this->product)); $this->initializationHelperMock->expects($this->never())->method('initialize'); @@ -744,6 +754,7 @@ public function testDeleteById() ->will($this->returnValue('42')); $this->product->expects($this->once())->method('load')->with('42'); $this->product->expects($this->atLeastOnce())->method('getSku')->willReturn($sku); + $this->product->expects($this->atLeastOnce())->method('getId')->willReturn(42); $this->assertTrue($this->model->deleteById($sku)); } @@ -842,8 +853,9 @@ public function cacheKeyDataProvider() */ public function testSaveExistingWithOptions(array $newOptions, array $existingOptions, array $expectedData) { + $id = 100; $this->storeManagerMock->expects($this->any())->method('getWebsites')->willReturn([1 => 'default']); - $this->resourceModelMock->expects($this->any())->method('getIdBySku')->will($this->returnValue(100)); + $this->resourceModelMock->expects($this->any())->method('getIdBySku')->will($this->returnValue($id)); $this->productFactory->expects($this->any()) ->method('create') ->will($this->returnValue($this->initializedProductMock)); @@ -863,6 +875,8 @@ public function testSaveExistingWithOptions(array $newOptions, array $existingOp $this->initializedProductMock->expects($this->atLeastOnce()) ->method('getSku')->willReturn($this->productData['sku']); $this->product->expects($this->atLeastOnce())->method('getSku')->willReturn($this->productData['sku']); + $this->initializedProductMock->expects($this->at(0))->method('getId')->willReturn(null); + $this->initializedProductMock->expects($this->any())->method('getId')->willReturn($id); $this->assertEquals($this->initializedProductMock, $this->model->save($this->product)); } @@ -1019,6 +1033,7 @@ public function testSaveWithLinks(array $newLinks, array $existingLinks, array $ $this->productFactory->expects($this->any()) ->method('create') ->will($this->returnValue($this->initializedProductMock)); + $this->initializedProductMock->method('getId')->willReturn(100); $this->initializationHelperMock->expects($this->never())->method('initialize'); $this->resourceModelMock->expects($this->once())->method('validate')->with($this->initializedProductMock) ->willReturn(true); @@ -1260,6 +1275,8 @@ public function testSaveExistingWithNewMediaGalleryEntries() $this->initializedProductMock->expects($this->atLeastOnce()) ->method('getSku')->willReturn($this->productData['sku']); $this->product->expects($this->atLeastOnce())->method('getSku')->willReturn($this->productData['sku']); + $this->initializedProductMock->expects($this->at(0))->method('getId')->willReturn(null); + $this->initializedProductMock->expects($this->any())->method('getId')->willReturn(100); $this->model->save($this->product); } @@ -1301,6 +1318,8 @@ public function testSaveWithDifferentWebsites() $this->product->method('setWebsiteIds')->willReturn([2,3]); $this->product->method('getSku') ->willReturn('simple'); + $this->product->expects($this->at(0))->method('getId')->willReturn(null); + $this->product->expects($this->any())->method('getId')->willReturn(100); $this->assertEquals($this->product, $this->model->save($this->product)); } @@ -1353,6 +1372,7 @@ public function testSaveExistingWithMediaGalleryEntries() ->method('getSku')->willReturn($this->productData['sku']); $this->product->expects($this->atLeastOnce())->method('getSku')->willReturn($this->productData['sku']); $this->product->expects($this->any())->method('getMediaGalleryEntries')->willReturn(null); + $this->initializedProductMock->expects($this->any())->method('getId')->willReturn(100); $this->model->save($this->product); } } From 3845d9d34636c3c2604887e103e2034d082bdc50 Mon Sep 17 00:00:00 2001 From: Stas Kozar <stas.kozar@transoftgroup.com> Date: Fri, 15 Jun 2018 14:56:29 +0300 Subject: [PATCH 146/206] MAGETWO-73967: [2.2.x] - [Github]Can not save attribute #5907 --- .../Adminhtml/Product/Attribute/Save.php | 25 +- .../Catalog/view/adminhtml/web/js/options.js | 34 ++- .../Product/Attribute/Plugin/Save.php | 12 +- .../adminhtml/web/js/product-attributes.js | 28 +++ .../Adminhtml/Product/AttributeTest.php | 106 +++++++++ .../Adminhtml/Product/AttributeTest.php | 214 ++++++++++++++++++ .../Test/Integrity/HhvmCompatibilityTest.php | 32 ++- 7 files changed, 445 insertions(+), 6 deletions(-) create mode 100644 dev/tests/integration/testsuite/Magento/Swatches/Controller/Adminhtml/Product/AttributeTest.php diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Save.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Save.php index 98d5182bbadb2..b9f9b739f4fa3 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Save.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Save.php @@ -115,6 +115,7 @@ public function execute() { $data = $this->getRequest()->getPostValue(); if ($data) { + $this->preprocessOptionsData($data); $setId = $this->getRequest()->getParam('set'); $attributeSet = null; @@ -210,7 +211,7 @@ public function execute() $data['attribute_code'] = $model->getAttributeCode(); $data['is_user_defined'] = $model->getIsUserDefined(); - $data['frontend_input'] = $model->getFrontendInput(); + $data['frontend_input'] = $data['frontend_input'] ?? $model->getFrontendInput(); } else { /** * @todo add to helper and specify all relations for properties @@ -311,6 +312,28 @@ public function execute() return $this->returnResult('catalog/*/', [], ['error' => true]); } + /** + * Extract options data from serialized options field and append to data array. + * + * This logic is required to overcome max_input_vars php limit + * that may vary and/or be inaccessible to change on different instances. + * + * @param array $data + * @return void + */ + private function preprocessOptionsData(&$data) + { + if (isset($data['serialized_options'])) { + $serializedOptions = json_decode($data['serialized_options'], JSON_OBJECT_AS_ARRAY); + foreach ($serializedOptions as $serializedOption) { + $option = []; + parse_str($serializedOption, $option); + $data = array_replace_recursive($data, $option); + } + } + unset($data['serialized_options']); + } + /** * @param string $path * @param array $params diff --git a/app/code/Magento/Catalog/view/adminhtml/web/js/options.js b/app/code/Magento/Catalog/view/adminhtml/web/js/options.js index 787516a9abf29..6ea005915763c 100644 --- a/app/code/Magento/Catalog/view/adminhtml/web/js/options.js +++ b/app/code/Magento/Catalog/view/adminhtml/web/js/options.js @@ -13,12 +13,16 @@ define([ 'jquery/ui', 'prototype', 'form', - 'validation' + 'validation', + 'mage/translate' ], function (jQuery, mageTemplate, rg) { 'use strict'; return function (config) { - var attributeOption = { + var optionPanel = jQuery('#manage-options-panel'), + optionsValues = [], + editForm = jQuery('#edit_form'), + attributeOption = { table: $('attribute-options-table'), itemCount: 0, totalItems: 0, @@ -150,7 +154,7 @@ define([ attributeOption.remove(event); }); - jQuery('#manage-options-panel').on('render', function () { + optionPanel.on('render', function () { attributeOption.ignoreValidate(); if (attributeOption.rendered) { @@ -176,7 +180,31 @@ define([ }); }); } + editForm.on('submit', function () { + optionPanel.find('input') + .each(function () { + if (this.disabled) { + return; + } + if (this.type === 'checkbox' || this.type === 'radio') { + if (this.checked) { + optionsValues.push(this.name + '=' + jQuery(this).val()); + } + } else { + optionsValues.push(this.name + '=' + jQuery(this).val()); + } + }); + jQuery('<input>') + .attr({ + type: 'hidden', + name: 'serialized_options' + }) + .val(JSON.stringify(optionsValues)) + .prependTo(editForm); + optionPanel.find('table') + .replaceWith(jQuery('<div>').text(jQuery.mage.__('Sending attribute values as package.'))); + }); window.attributeOption = attributeOption; window.optionDefaultInputType = attributeOption.getOptionInputType(); diff --git a/app/code/Magento/Swatches/Controller/Adminhtml/Product/Attribute/Plugin/Save.php b/app/code/Magento/Swatches/Controller/Adminhtml/Product/Attribute/Plugin/Save.php index dfda76372df1f..383c97a166d34 100644 --- a/app/code/Magento/Swatches/Controller/Adminhtml/Product/Attribute/Plugin/Save.php +++ b/app/code/Magento/Swatches/Controller/Adminhtml/Product/Attribute/Plugin/Save.php @@ -11,7 +11,7 @@ use Magento\Swatches\Model\Swatch; /** - * Class Save + * Plugin for product attribute save controller. */ class Save { @@ -24,7 +24,17 @@ class Save public function beforeDispatch(Attribute\Save $subject, RequestInterface $request) { $data = $request->getPostValue(); + if (isset($data['frontend_input'])) { + //Data is serialized to overcome issues caused by max_input_vars value if it's modification is unavailable. + //See subject controller code and comments for more info. + if (isset($data['serialized_swatch_values']) + && in_array($data['frontend_input'], ['swatch_visual', 'swatch_text']) + ) { + $data['serialized_options'] = $data['serialized_swatch_values']; + unset($data['serialized_swatch_values']); + } + switch ($data['frontend_input']) { case 'swatch_visual': $data[Swatch::SWATCH_INPUT_TYPE_KEY] = Swatch::SWATCH_INPUT_TYPE_VISUAL; diff --git a/app/code/Magento/Swatches/view/adminhtml/web/js/product-attributes.js b/app/code/Magento/Swatches/view/adminhtml/web/js/product-attributes.js index ec24c11ef854d..1a58e4b6f2e7a 100644 --- a/app/code/Magento/Swatches/view/adminhtml/web/js/product-attributes.js +++ b/app/code/Magento/Swatches/view/adminhtml/web/js/product-attributes.js @@ -413,6 +413,8 @@ define([ }; $(function () { + var editForm = $('#edit_form'); + $('#frontend_input').bind('change', function () { swatchProductAttributes.bindAttributeInputType(); }); @@ -426,6 +428,32 @@ define([ $('.attribute-popup .collapse, [data-role="advanced_fieldset-content"]') .collapsable() .collapse('hide'); + + editForm.on('submit', function () { + var activePanel, + swatchValues = [], + swatchVisualPanel = $('#swatch-visual-options-panel'), + swatchTextPanel = $('#swatch-text-options-panel'); + + activePanel = swatchTextPanel.is(':visible') ? swatchTextPanel : swatchVisualPanel; + + activePanel.find('table input') + .each(function () { + swatchValues.push(this.name + '=' + $(this).val()); + }); + + $('<input>').attr({ + type: 'hidden', + name: 'serialized_swatch_values' + }) + .val(JSON.stringify(swatchValues)) + .prependTo(editForm); + + [swatchVisualPanel, swatchTextPanel].forEach(function (el) { + $(el).find('table') + .replaceWith($('<div>').text($.mage.__('Sending swatch values as package.'))); + }); + }); }); window.saveAttributeInNewSet = swatchProductAttributes.saveAttributeInNewSet; diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/AttributeTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/AttributeTest.php index 6e93f61c1eb3a..098b18d6f38c9 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/AttributeTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/AttributeTest.php @@ -5,6 +5,8 @@ */ namespace Magento\Catalog\Controller\Adminhtml\Product; +use Magento\Framework\Exception\LocalizedException; + /** * @magentoAppArea adminhtml * @magentoDbIsolation enabled @@ -221,6 +223,110 @@ public function testSaveActionCleanAttributeLabelCache() $this->assertEquals('new string translation', $this->_translate('string to translate')); } + /** + * Get attribute data preset. + * + * @return array + */ + private function getLargeOptionsSetAttributeData(): array + { + return [ + 'frontend_label' => [ + 0 => 'testdrop1', + 1 => '', + 2 => '', + ], + 'frontend_input' => 'select', + 'is_required' => '0', + 'update_product_preview_image' => '0', + 'use_product_image_for_swatch' => '0', + 'visual_swatch_validation' => '', + 'visual_swatch_validation_unique' => '', + 'text_swatch_validation' => '', + 'text_swatch_validation_unique' => '', + 'attribute_code' => 'test_many_options', + 'is_global' => '0', + 'default_value_text' => '', + 'default_value_yesno' => '0', + 'default_value_date' => '', + 'default_value_textarea' => '', + 'is_unique' => '0', + 'is_used_in_grid' => '1', + 'is_visible_in_grid' => '1', + 'is_filterable_in_grid' => '1', + 'is_searchable' => '0', + 'is_comparable' => '0', + 'is_filterable' => '0', + 'is_filterable_in_search' => '0', + 'is_used_for_promo_rules' => '0', + 'is_html_allowed_on_front' => '1', + 'is_visible_on_front' => '0', + 'used_in_product_listing' => '0', + 'used_for_sort_by' => '0', + 'swatch_input_type' => 'dropdown', + ]; + } + + /** + * Test attribute saving with large amount of options exceeding maximum allowed by max_input_vars limit. + * + * @return void + */ + public function testLargeOptionsDataSet() + { + $maxInputVars = ini_get('max_input_vars'); + // Each option is at least 4 variables array (order, admin value, first store view value, delete flag). + // Set options count to exceed max_input_vars by 100 options (400 variables). + $optionsCount = floor($maxInputVars / 4) + 100; + $attributeData = $this->getLargeOptionsSetAttributeData(); + $optionsData = []; + $expectedOptionsLabels = []; + for ($i = 0; $i < $optionsCount; $i++) { + $order = $i + 1; + $expectedOptionLabelOnStoreView = "value_{$i}_store_1"; + $expectedOptionsLabels[$i+1] = $expectedOptionLabelOnStoreView; + $optionsData []= "option[order][option_{$i}]={$order}"; + $optionsData []= "option[value][option_{$i}][0]=value_{$i}_admin"; + $optionsData []= "option[value][option_{$i}][1]={$expectedOptionLabelOnStoreView}"; + $optionsData []= "option[delete][option_{$i}="; + } + $attributeData['serialized_options'] = json_encode($optionsData); + $this->getRequest()->setPostValue($attributeData); + $this->dispatch('backend/catalog/product_attribute/save'); + $entityTypeId = $this->_objectManager->create( + \Magento\Eav\Model\Entity::class + )->setType( + \Magento\Catalog\Model\Product::ENTITY + )->getTypeId(); + + /** @var $attribute \Magento\Catalog\Model\ResourceModel\Eav\Attribute */ + $attribute = $this->_objectManager->create( + \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class + )->setEntityTypeId( + $entityTypeId + ); + try { + $attribute->loadByCode($entityTypeId, 'test_many_options'); + $options = $attribute->getOptions(); + // assert that all options are saved without truncation + $this->assertEquals( + $optionsCount + 1, + count($options), + 'Expected options count does not match (regarding first empty option for non-required attribute)' + ); + + foreach ($expectedOptionsLabels as $optionOrderNum => $label) { + $this->assertEquals( + $label, + $options[$optionOrderNum]->getLabel(), + "Label for option #{$optionOrderNum} does not match expected." + ); + } + } catch (LocalizedException $e) { + $this->fail('Test failed with exception on attribute model load: ' . $e); + } + } + /** * Return translation for a string literal belonging to backend area * diff --git a/dev/tests/integration/testsuite/Magento/Swatches/Controller/Adminhtml/Product/AttributeTest.php b/dev/tests/integration/testsuite/Magento/Swatches/Controller/Adminhtml/Product/AttributeTest.php new file mode 100644 index 0000000000000..be9fd96d75892 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Swatches/Controller/Adminhtml/Product/AttributeTest.php @@ -0,0 +1,214 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Swatches\Controller\Adminhtml\Product; + +use Magento\Framework\Exception\LocalizedException; + +/** + * Test for product attribute save controller. + * + * @magentoAppArea adminhtml + * @magentoDbIsolation enabled + */ +class AttributeTest extends \Magento\TestFramework\TestCase\AbstractBackendController +{ + /** + * Generate random hex color. + * + * @return string + */ + private function getRandomColor(): string + { + return '#' . str_pad(dechex(mt_rand(0, 0xFFFFFF)), 6, '0', STR_PAD_LEFT); + } + + /** + * Get visual swatches data set. + * + * @param int $optionsCount + * @return array + */ + private function getSwatchVisualDataSet(int $optionsCount): array + { + $optionsData = []; + $expectedOptionsLabels = []; + for ($i = 0; $i < $optionsCount; $i++) { + $order = $i + 1; + $expectedOptionLabelOnStoreView = "value_{$i}_store_1"; + $expectedOptionsLabels[$i+1] = $expectedOptionLabelOnStoreView; + $optionsData []= "optionvisual[order][option_{$i}]={$order}"; + $optionsData []= "defaultvisual[]=option_{$i}"; + $optionsData []= "swatchvisual[value][option_{$i}]={$this->getRandomColor()}"; + $optionsData []= "optionvisual[value][option_{$i}][0]=value_{$i}_admin"; + $optionsData []= "optionvisual[value][option_{$i}][1]={$expectedOptionLabelOnStoreView}"; + $optionsData []= "optionvisual[delete][option_{$i}]="; + } + $optionsData []= "visual_swatch_validation="; + $optionsData []= "visual_swatch_validation_unique="; + return [ + 'attribute_data' => array_merge_recursive( + [ + 'serialized_swatch_values' => json_encode($optionsData), + ], + $this->getAttributePreset(), + [ + 'frontend_input' => 'swatch_visual', + ] + ), + 'expected_options_count' => $optionsCount + 1, + 'expected_store_labels' => $expectedOptionsLabels, + ]; + } + + /** + * Get text swatches data set. + * + * @param int $optionsCount + * @return array + */ + private function getSwatchTextDataSet(int $optionsCount): array + { + $optionsData = []; + $expectedOptionsLabels = []; + for ($i = 0; $i < $optionsCount; $i++) { + $order = $i + 1; + $expectedOptionLabelOnStoreView = "value_{$i}_store_1"; + $expectedOptionsLabels[$i+1] = $expectedOptionLabelOnStoreView; + $optionsData []= "optiontext[order][option_{$i}]={$order}"; + $optionsData []= "defaulttext[]=option_{$i}"; + $optionsData []= "swatchtext[value][option_{$i}]=x{$i}"; + $optionsData []= "optiontext[value][option_{$i}][0]=value_{$i}_admin"; + $optionsData []= "optiontext[value][option_{$i}][1]={$expectedOptionLabelOnStoreView}"; + $optionsData []= "optiontext[delete][option_{$i}]="; + } + $optionsData []= "text_swatch_validation="; + $optionsData []= "text_swatch_validation_unique="; + return [ + 'attribute_data' => array_merge_recursive( + [ + 'serialized_swatch_values' => json_encode($optionsData), + ], + $this->getAttributePreset(), + [ + 'frontend_input' => 'swatch_text', + ] + ), + 'expected_options_count' => $optionsCount + 1, + 'expected_store_labels' => $expectedOptionsLabels, + ]; + } + + /** + * Get data preset for new attribute. + * + * @return array + */ + private function getAttributePreset(): array + { + return [ + 'serialized_options' => '[]', + 'form_key' => 'XxtpPYjm2YPYUlAt', + 'frontend_label' => [ + 0 => 'asdasd', + 1 => '', + 2 => '', + ], + 'is_required' => '0', + 'update_product_preview_image' => '0', + 'use_product_image_for_swatch' => '0', + 'is_global' => '0', + 'default_value_text' => '512', + 'default_value_yesno' => '1', + 'default_value_date' => '1/1/70', + 'default_value_textarea' => '512', + 'is_unique' => '0', + 'is_used_in_grid' => '1', + 'is_visible_in_grid' => '1', + 'is_filterable_in_grid' => '1', + 'is_searchable' => '0', + 'is_comparable' => '0', + 'is_filterable' => '0', + 'is_filterable_in_search' => '0', + 'position' => '0', + 'is_used_for_promo_rules' => '0', + 'is_html_allowed_on_front' => '1', + 'is_visible_on_front' => '0', + 'used_in_product_listing' => '0', + 'used_for_sort_by' => '0', + 'attribute_code' => 'test_many_swatches', + ]; + } + + /** + * Data provider for large swatches amount test. + * + * @return array + */ + public function getLargeSwatchesAmountAttributeData(): array + { + $maxInputVars = ini_get('max_input_vars'); + // Each option is at least 7 variables array for a visual swatch. + // Set options count to exceed max_input_vars by 20 options (140 variables). + $swatchVisualOptionsCount = (int)floor($maxInputVars / 7) + 20; + $swatchTextOptionsCount = (int)floor($maxInputVars / 4) + 80; + return [ + 'visual swatches' => $this->getSwatchVisualDataSet($swatchVisualOptionsCount), + 'text swatches' => $this->getSwatchTextDataSet($swatchTextOptionsCount), + ]; + } + + /** + * Test attribute saving with large amount of options exceeding maximum allowed by max_input_vars limit. + * + * @dataProvider getLargeSwatchesAmountAttributeData() + * @param array $attributeData + * @param int $expectedOptionsCount + * @param array $expectedLabels + * @return void + */ + public function testLargeOptionsDataSet( + array $attributeData, + int $expectedOptionsCount, + array $expectedLabels + ) { + $this->getRequest()->setPostValue($attributeData); + $this->dispatch('backend/catalog/product_attribute/save'); + $entityTypeId = $this->_objectManager->create( + \Magento\Eav\Model\Entity::class + )->setType( + \Magento\Catalog\Model\Product::ENTITY + )->getTypeId(); + + /** @var $attribute \Magento\Catalog\Model\ResourceModel\Eav\Attribute */ + $attribute = $this->_objectManager->create( + \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class + )->setEntityTypeId( + $entityTypeId + ); + try { + $attribute->loadByCode($entityTypeId, 'test_many_swatches'); + $options = $attribute->getOptions(); + // assert that all options are saved without truncation + $this->assertEquals( + $expectedOptionsCount, + count($options), + 'Expected options count does not match (regarding first empty option for non-required attribute)' + ); + + foreach ($expectedLabels as $optionOrderNum => $label) { + $this->assertEquals( + $label, + $options[$optionOrderNum]->getLabel(), + "Label for option #{$optionOrderNum} does not match expected." + ); + } + } catch (LocalizedException $e) { + $this->fail('Test failed with exception on attribute model load: ' . $e); + } + } +} diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/HhvmCompatibilityTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/HhvmCompatibilityTest.php index e33b771b3c645..dc4145ec2002c 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/HhvmCompatibilityTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/HhvmCompatibilityTest.php @@ -47,6 +47,24 @@ class HhvmCompatibilityTest extends \PHPUnit\Framework\TestCase 'serialize_precision', ]; + /** + * Whitelist of variables allowed in files. + * + * @var array + */ + private $whitelistVarsInFiles = [ + 'max_input_vars' => [ + 'integration/testsuite/Magento/Swatches/Controller/Adminhtml/Product/AttributeTest.php', + 'integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/AttributeTest.php', + ], + ]; + + /** + * Test allowed directives. + * + * @SuppressWarnings(PHPMD.NPathComplexity) + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + */ public function testAllowedIniGetSetDirectives() { $deniedDirectives = []; @@ -55,7 +73,19 @@ public function testAllowedIniGetSetDirectives() if ($fileDirectives) { $fileDeniedDirectives = array_diff($fileDirectives, $this->allowedDirectives); if ($fileDeniedDirectives) { - $deniedDirectives[$file] = array_unique($fileDeniedDirectives); + $deniedDirectivesInFile = array_unique($fileDeniedDirectives); + foreach ($deniedDirectivesInFile as $key => $deniedDirective) { + if (isset($this->whitelistVarsInFiles[$deniedDirective])) { + foreach ($this->whitelistVarsInFiles[$deniedDirective] as $whitelistFile) { + if (strpos($file, $whitelistFile) !== false) { + unset($deniedDirectivesInFile[$key]); + } + } + } + } + if ($deniedDirectivesInFile) { + $deniedDirectives[$file] = $deniedDirectivesInFile; + } } } } From 74e20f5fad39a10b88558bfbee3a98f70caedb4d Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi <alugovyi@magento.com> Date: Fri, 15 Jun 2018 15:05:08 +0300 Subject: [PATCH 147/206] MAGETWO-64467: [Indexer optimizations] Tables sharding / segmentation for price indexer --- .../Model/Export/AdvancedPricingTest.php | 2 +- .../testsuite/Magento/Quote/Model/Quote/AddressTest.php | 2 +- .../Magento/Tax/Model/Sales/Total/Quote/SubtotalTest.php | 1 + .../testsuite/Magento/Tax/Model/Sales/Total/Quote/TaxTest.php | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/AdvancedPricingImportExport/Model/Export/AdvancedPricingTest.php b/dev/tests/integration/testsuite/Magento/AdvancedPricingImportExport/Model/Export/AdvancedPricingTest.php index 1aea568395c99..665337a48068f 100644 --- a/dev/tests/integration/testsuite/Magento/AdvancedPricingImportExport/Model/Export/AdvancedPricingTest.php +++ b/dev/tests/integration/testsuite/Magento/AdvancedPricingImportExport/Model/Export/AdvancedPricingTest.php @@ -94,7 +94,7 @@ private function assertDiscountTypes($exportContent) /** * @magentoAppArea adminhtml - * @magentoDbIsolation enabled + * @magentoDbIsolation disabled * @magentoAppIsolation enabled * @magentoConfigFixture current_store catalog/price/scope 1 * @magentoDataFixture Magento/AdvancedPricingImportExport/_files/product_with_second_website.php diff --git a/dev/tests/integration/testsuite/Magento/Quote/Model/Quote/AddressTest.php b/dev/tests/integration/testsuite/Magento/Quote/Model/Quote/AddressTest.php index 08945190b9e85..f7b50ccbf7c0e 100644 --- a/dev/tests/integration/testsuite/Magento/Quote/Model/Quote/AddressTest.php +++ b/dev/tests/integration/testsuite/Magento/Quote/Model/Quote/AddressTest.php @@ -326,7 +326,7 @@ public function dataProvider() * @magentoConfigFixture default_store carriers/flatrate/price 5 * @magentoConfigFixture fixture_second_store_store carriers/flatrate/price 10 * @magentoAppIsolation enabled - * @magentoDbIsolation enabled + * @magentoDbIsolation disabled * @dataProvider requestShippingRatesDataProvider */ public function testRequestShippingRates($storeCode, $expectedRate) diff --git a/dev/tests/integration/testsuite/Magento/Tax/Model/Sales/Total/Quote/SubtotalTest.php b/dev/tests/integration/testsuite/Magento/Tax/Model/Sales/Total/Quote/SubtotalTest.php index 729ed5cc7a8e7..ecc48e0276779 100644 --- a/dev/tests/integration/testsuite/Magento/Tax/Model/Sales/Total/Quote/SubtotalTest.php +++ b/dev/tests/integration/testsuite/Magento/Tax/Model/Sales/Total/Quote/SubtotalTest.php @@ -14,6 +14,7 @@ * Test \Magento\Tax\Model\Sales\Total\Quote\Subtotal * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @magentoDbIsolation disabled */ class SubtotalTest extends \PHPUnit\Framework\TestCase { diff --git a/dev/tests/integration/testsuite/Magento/Tax/Model/Sales/Total/Quote/TaxTest.php b/dev/tests/integration/testsuite/Magento/Tax/Model/Sales/Total/Quote/TaxTest.php index 9b498afc2500d..80e4d5d316546 100644 --- a/dev/tests/integration/testsuite/Magento/Tax/Model/Sales/Total/Quote/TaxTest.php +++ b/dev/tests/integration/testsuite/Magento/Tax/Model/Sales/Total/Quote/TaxTest.php @@ -227,7 +227,7 @@ protected function verifyResult($quoteAddress, $expectedResults) * @param array $configData * @param array $quoteData * @param array $expectedResults - * @magentoDbIsolation enabled + * @magentoDbIsolation disabled * @magentoAppIsolation enabled * @dataProvider taxDataProvider * @return void From f2a82b124206523a96a9406a7bb056bc9a35a633 Mon Sep 17 00:00:00 2001 From: Andrii Voskoboinikov <avoskoboinikov@magento.com> Date: Fri, 15 Jun 2018 17:29:17 +0300 Subject: [PATCH 148/206] MAGETWO-92693: Some improvements on product create|edit page in admin area --- .../Controller/Adminhtml/Product/Builder.php | 3 +- .../Adminhtml/Product/BuilderTest.php | 209 ++++++++++++------ 2 files changed, 140 insertions(+), 72 deletions(-) diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Builder.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Builder.php index 166dc09117d28..5398f6004ac36 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Builder.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Builder.php @@ -55,6 +55,7 @@ class Builder * @param Registry $registry * @param WysiwygModel\Config $wysiwygConfig * @param StoreFactory|null $storeFactory + * @param ProductRepositoryInterface|null $productRepository */ public function __construct( ProductFactory $productFactory, @@ -84,7 +85,7 @@ public function __construct( public function build(RequestInterface $request) { $productId = (int) $request->getParam('id'); - $storeId = (int) $request->getParam('store', 0); + $storeId = $request->getParam('store', 0); $attributeSetId = (int) $request->getParam('set'); $typeId = $request->getParam('type'); diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/BuilderTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/BuilderTest.php index 4113ce636d66b..c71fa90fb02dd 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/BuilderTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/BuilderTest.php @@ -14,6 +14,9 @@ use Magento\Framework\Registry; use Magento\Cms\Model\Wysiwyg\Config as WysiwygConfig; use Magento\Framework\App\Request\Http; +use Magento\Catalog\Api\ProductRepositoryInterface; +use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Catalog\Model\Product\Type as ProductTypes; /** * Class BuilderTest @@ -67,6 +70,11 @@ class BuilderTest extends \PHPUnit\Framework\TestCase */ protected $storeFactoryMock; + /** + * @var ProductRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $productRepositoryMock; + /** * @var StoreInterface|\PHPUnit_Framework_MockObject_MockObject */ @@ -90,9 +98,10 @@ protected function setUp() ->setMethods(['load']) ->getMockForAbstractClass(); - $this->storeFactoryMock->expects($this->any()) - ->method('create') - ->willReturn($this->storeMock); + $this->productRepositoryMock = $this->getMockBuilder(ProductRepositoryInterface::class) + ->setMethods(['getById']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); $this->builder = $this->objectManager->getObject( Builder::class, @@ -102,140 +111,198 @@ protected function setUp() 'registry' => $this->registryMock, 'wysiwygConfig' => $this->wysiwygConfigMock, 'storeFactory' => $this->storeFactoryMock, + 'productRepository' => $this->productRepositoryMock ] ); } public function testBuildWhenProductExistAndPossibleToLoadProduct() { + $productId = 2; + $productType = 'type_id'; + $productStore = 'store'; + $productSet = 3; + $valueMap = [ - ['id', null, 2], - ['store', 0, 'some_store'], - ['type', null, 'type_id'], - ['set', null, 3], - ['store', null, 'store'], + ['id', null, $productId], + ['type', null, $productType], + ['set', null, $productSet], + ['store', 0, $productStore], ]; + $this->requestMock->expects($this->any()) ->method('getParam') ->willReturnMap($valueMap); - $this->productFactoryMock->expects($this->once()) + + $this->productRepositoryMock->expects($this->any()) + ->method('getById') + ->with($productId, true, $productStore) + ->willReturn($this->productMock); + + $this->storeFactoryMock->expects($this->any()) ->method('create') - ->will($this->returnValue($this->productMock)); - $this->productMock->expects($this->once()) - ->method('setStoreId') - ->with('some_store') - ->willReturnSelf(); - $this->productMock->expects($this->never()) - ->method('setTypeId'); - $this->productMock->expects($this->once()) + ->willReturn($this->storeMock); + + $this->storeMock->expects($this->any()) ->method('load') - ->with(2) - ->will($this->returnSelf()); - $this->productMock->expects($this->once()) - ->method('setAttributeSetId') - ->with(3) - ->will($this->returnSelf()); + ->with($productStore) + ->willReturnSelf(); + $registryValueMap = [ ['product', $this->productMock, $this->registryMock], ['current_product', $this->productMock, $this->registryMock], + ['current_store', $this->registryMock, $this->storeMock], ]; + $this->registryMock->expects($this->any()) ->method('register') ->willReturn($registryValueMap); + $this->wysiwygConfigMock->expects($this->once()) ->method('setStoreId') - ->with('store'); + ->with($productStore); + $this->assertEquals($this->productMock, $this->builder->build($this->requestMock)); } public function testBuildWhenImpossibleLoadProduct() { + $productId = 2; + $productType = 'type_id'; + $productStore = 'store'; + $productSet = 3; + $valueMap = [ - ['id', null, 15], - ['store', 0, 'some_store'], - ['type', null, 'type_id'], - ['set', null, 3], - ['store', null, 'store'], + ['id', null, $productId], + ['type', null, $productType], + ['set', null, $productSet], + ['store', 0, $productStore], ]; + $this->requestMock->expects($this->any()) ->method('getParam') - ->will($this->returnValueMap($valueMap)); + ->willReturnMap($valueMap); + + $this->productRepositoryMock->expects($this->any()) + ->method('getById') + ->with($productId, true, $productStore) + ->willThrowException(new NoSuchEntityException()); + $this->productFactoryMock->expects($this->once()) ->method('create') - ->willReturn($this->productMock); - $this->productMock->expects($this->once()) - ->method('setStoreId') - ->with('some_store') - ->willReturnSelf(); - $this->productMock->expects($this->once()) + ->will($this->returnValue($this->productMock)); + + $this->productMock->expects($this->any()) + ->method('setData') + ->with('_edit_mode', true); + + $this->productMock->expects($this->any()) ->method('setTypeId') - ->with(\Magento\Catalog\Model\Product\Type::DEFAULT_TYPE) - ->willReturnSelf(); - $this->productMock->expects($this->once()) - ->method('load') - ->with(15) - ->willThrowException(new \Exception()); + ->with(ProductTypes::DEFAULT_TYPE); + + $this->productMock->expects($this->any()) + ->method('setStoreId') + ->with($productStore); + + $this->productMock->expects($this->any()) + ->method('setAttributeSetId') + ->with($productSet); + $this->loggerMock->expects($this->once()) ->method('critical'); - $this->productMock->expects($this->once()) - ->method('setAttributeSetId') - ->with(3) - ->will($this->returnSelf()); + + $this->storeFactoryMock->expects($this->any()) + ->method('create') + ->willReturn($this->storeMock); + + $this->storeMock->expects($this->any()) + ->method('load') + ->with($productStore) + ->willReturnSelf(); + $registryValueMap = [ ['product', $this->productMock, $this->registryMock], ['current_product', $this->productMock, $this->registryMock], + ['current_store', $this->registryMock, $this->storeMock], ]; + $this->registryMock->expects($this->any()) ->method('register') - ->will($this->returnValueMap($registryValueMap)); + ->willReturn($registryValueMap); + $this->wysiwygConfigMock->expects($this->once()) ->method('setStoreId') - ->with('store'); + ->with($productStore); + $this->assertEquals($this->productMock, $this->builder->build($this->requestMock)); } public function testBuildWhenProductNotExist() { + $productId = 0; + $productType = 'type_id'; + $productStore = 'store'; + $productSet = 3; + $valueMap = [ - ['id', null, null], - ['store', 0, 'some_store'], - ['type', null, 'type_id'], - ['set', null, 3], - ['store', null, 'store'], + ['id', null, $productId], + ['type', null, $productType], + ['set', null, $productSet], + ['store', 0, $productStore], ]; + $this->requestMock->expects($this->any()) ->method('getParam') - ->will($this->returnValueMap($valueMap)); + ->willReturnMap($valueMap); + + $this->productRepositoryMock->expects($this->any()) + ->method('getById') + ->with($productId, true, $productStore) + ->willThrowException(new NoSuchEntityException()); + $this->productFactoryMock->expects($this->once()) ->method('create') - ->willReturn($this->productMock); - $this->productMock->expects($this->once()) - ->method('setStoreId') - ->with('some_store') - ->willReturnSelf(); - $productValueMap = [ - ['type_id', $this->productMock], - [\Magento\Catalog\Model\Product\Type::DEFAULT_TYPE, $this->productMock], - ]; + ->will($this->returnValue($this->productMock)); + + $this->productMock->expects($this->any()) + ->method('setData') + ->with('_edit_mode', true); + $this->productMock->expects($this->any()) ->method('setTypeId') - ->willReturnMap($productValueMap); - $this->productMock->expects($this->never()) - ->method('load'); - $this->productMock->expects($this->once()) + ->with($productType); + + $this->productMock->expects($this->any()) + ->method('setStoreId') + ->with($productStore); + + $this->productMock->expects($this->any()) ->method('setAttributeSetId') - ->with(3) - ->will($this->returnSelf()); + ->with($productSet); + + $this->storeFactoryMock->expects($this->any()) + ->method('create') + ->willReturn($this->storeMock); + + $this->storeMock->expects($this->any()) + ->method('load') + ->with($productStore) + ->willReturnSelf(); + $registryValueMap = [ ['product', $this->productMock, $this->registryMock], ['current_product', $this->productMock, $this->registryMock], + ['current_store', $this->registryMock, $this->storeMock], ]; + $this->registryMock->expects($this->any()) ->method('register') - ->will($this->returnValueMap($registryValueMap)); + ->willReturn($registryValueMap); + $this->wysiwygConfigMock->expects($this->once()) ->method('setStoreId') - ->with('store'); + ->with($productStore); + $this->assertEquals($this->productMock, $this->builder->build($this->requestMock)); } } From aabed9cf76abd7dd2af822a1b955bbddfc8f61a2 Mon Sep 17 00:00:00 2001 From: Andrii Voskoboinikov <avoskoboinikov@magento.com> Date: Fri, 15 Jun 2018 18:13:12 +0300 Subject: [PATCH 149/206] MAGETWO-92693: Some improvements on product create|edit page in admin area --- .../Product/Form/Modifier/EavTest.php | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php index 528f54fd69730..eba68eb993efa 100755 --- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php @@ -20,6 +20,7 @@ use Magento\Catalog\Model\ResourceModel\Eav\Attribute as EavAttribute; use Magento\Eav\Model\Entity\Type as EntityType; use Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection as AttributeCollection; +use Magento\Eav\Model\ResourceModel\Entity\Attribute\CollectionFactory as AttributeCollectionFactory; use Magento\Ui\DataProvider\Mapper\FormElement as FormElementMapper; use Magento\Ui\DataProvider\Mapper\MetaProperties as MetaPropertiesMapper; use Magento\Framework\Api\SearchCriteriaBuilder; @@ -88,6 +89,11 @@ class EavTest extends AbstractModifierTest */ private $entityTypeMock; + /** + * @var AttributeCollectionFactory|\PHPUnit_Framework_MockObject_MockObject + */ + private $attributeCollectionFactoryMock; + /** * @var AttributeCollection|\PHPUnit_Framework_MockObject_MockObject */ @@ -226,6 +232,10 @@ protected function setUp() $this->entityTypeMock = $this->getMockBuilder(EntityType::class) ->disableOriginalConstructor() ->getMock(); + $this->attributeCollectionFactoryMock = $this->getMockBuilder(AttributeCollectionFactory::class) + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); $this->attributeCollectionMock = $this->getMockBuilder(AttributeCollection::class) ->disableOriginalConstructor() ->getMock(); @@ -332,7 +342,7 @@ protected function setUp() $this->eavAttributeMock->expects($this->any()) ->method('load') ->willReturnSelf(); - + $this->eav =$this->getModel(); $this->objectManager->setBackwardCompatibleProperty( $this->eav, @@ -361,7 +371,8 @@ protected function createModel() 'attributeRepository' => $this->attributeRepositoryMock, 'arrayManager' => $this->arrayManagerMock, 'eavAttributeFactory' => $this->eavAttributeFactoryMock, - '_eventManager' => $this->eventManagerMock + '_eventManager' => $this->eventManagerMock, + 'attributeCollectionFactory' => $this->attributeCollectionFactoryMock ]); } @@ -375,6 +386,16 @@ public function testModifyData() ] ]; + $this->attributeCollectionFactoryMock->expects($this->once()) + ->method('create') + ->willReturn($this->attributeCollectionMock); + + $this->attributeCollectionMock->expects($this->any()) + ->method('getItems') + ->willReturn([ + $this->eavAttributeMock + ]); + $this->locatorMock->expects($this->any()) ->method('getProduct') ->willReturn($this->productMock); From 0b36079de1ec2d9ba24396973925b28ce958ff7b Mon Sep 17 00:00:00 2001 From: Andrii Voskoboinikov <avoskoboinikov@magento.com> Date: Fri, 15 Jun 2018 18:25:36 +0300 Subject: [PATCH 150/206] MAGETWO-92693: Some improvements on product create|edit page in admin area --- .../Magento/Eav/Test/Unit/Model/AttributeRepositoryTest.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/code/Magento/Eav/Test/Unit/Model/AttributeRepositoryTest.php b/app/code/Magento/Eav/Test/Unit/Model/AttributeRepositoryTest.php index c225941c9eb35..5db0fc3ff5426 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/AttributeRepositoryTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/AttributeRepositoryTest.php @@ -124,8 +124,13 @@ public function testGetList() $collectionSize = 1; $searchCriteriaMock = $this->getMockBuilder(SearchCriteriaInterface::class) + ->setMethods(['getPageSize']) ->getMockForAbstractClass(); + $searchCriteriaMock->expects($this->any()) + ->method('getPageSize') + ->willReturn($collectionSize); + $attributeMock = $this->createAttributeMock($attributeCode, $attributeId); $attributeCollectionMock = $this->getMockBuilder(Collection::class) From 4a836f7444b049a37f7bcb34a91886427b3eab06 Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi <alugovyi@magento.com> Date: Fri, 15 Jun 2018 21:53:47 +0300 Subject: [PATCH 151/206] MAGETWO-64467: [Indexer optimizations] Tables sharding / segmentation for price indexer --- .../Model/Export/AdvancedPricingTest.php | 18 ++++++++-- .../Magento/Quote/Model/Quote/AddressTest.php | 15 ++++++++- .../Model/Sales/Total/Quote/SubtotalTest.php | 18 ++++++++-- .../Tax/Model/Sales/Total/Quote/TaxTest.php | 33 ++++++++++++++----- 4 files changed, 71 insertions(+), 13 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/AdvancedPricingImportExport/Model/Export/AdvancedPricingTest.php b/dev/tests/integration/testsuite/Magento/AdvancedPricingImportExport/Model/Export/AdvancedPricingTest.php index 665337a48068f..481cc629c6777 100644 --- a/dev/tests/integration/testsuite/Magento/AdvancedPricingImportExport/Model/Export/AdvancedPricingTest.php +++ b/dev/tests/integration/testsuite/Magento/AdvancedPricingImportExport/Model/Export/AdvancedPricingTest.php @@ -7,7 +7,7 @@ use Magento\Framework\App\Filesystem\DirectoryList; -class AdvancedPricingTest extends \PHPUnit\Framework\TestCase +class AdvancedPricingTest extends \Magento\TestFramework\Indexer\TestCase { /** * @var \Magento\AdvancedPricingImportExport\Model\Export\AdvancedPricing @@ -24,6 +24,19 @@ class AdvancedPricingTest extends \PHPUnit\Framework\TestCase */ protected $fileSystem; + public static function setUpBeforeClass() + { + $db = \Magento\TestFramework\Helper\Bootstrap::getInstance()->getBootstrap() + ->getApplication() + ->getDbInstance(); + if (!$db->isDbDumpExists()) { + throw new \LogicException('DB dump does not exist.'); + } + $db->restoreFromDbDump(); + + parent::setUpBeforeClass(); + } + protected function setUp() { parent::setUp(); @@ -37,7 +50,7 @@ protected function setUp() /** * @magentoAppArea adminhtml - * @magentoDbIsolation enabled + * @magentoDbIsolation disabled * @magentoAppIsolation enabled * @magentoDataFixture Magento/Catalog/_files/product_simple.php */ @@ -49,6 +62,7 @@ public function testExport() $index = 0; $ids = []; $origPricingData = []; + $skus = ['simple']; while (isset($skus[$index])) { $ids[$index] = $productRepository->get($skus[$index])->getId(); $origPricingData[$index] = $this->objectManager->create(\Magento\Catalog\Model\Product::class) diff --git a/dev/tests/integration/testsuite/Magento/Quote/Model/Quote/AddressTest.php b/dev/tests/integration/testsuite/Magento/Quote/Model/Quote/AddressTest.php index f7b50ccbf7c0e..a609e730de269 100644 --- a/dev/tests/integration/testsuite/Magento/Quote/Model/Quote/AddressTest.php +++ b/dev/tests/integration/testsuite/Magento/Quote/Model/Quote/AddressTest.php @@ -12,7 +12,7 @@ * @magentoDataFixture Magento/Sales/_files/quote_with_customer.php * @magentoDataFixture Magento/Customer/_files/customer_two_addresses.php */ -class AddressTest extends \PHPUnit\Framework\TestCase +class AddressTest extends \Magento\TestFramework\Indexer\TestCase { /** @var \Magento\Quote\Model\Quote $quote */ protected $_quote; @@ -29,6 +29,19 @@ class AddressTest extends \PHPUnit\Framework\TestCase /** @var StoreRepositoryInterface */ private $storeRepository; + public static function setUpBeforeClass() + { + $db = \Magento\TestFramework\Helper\Bootstrap::getInstance()->getBootstrap() + ->getApplication() + ->getDbInstance(); + if (!$db->isDbDumpExists()) { + throw new \LogicException('DB dump does not exist.'); + } + $db->restoreFromDbDump(); + + parent::setUpBeforeClass(); + } + /** * Initialize quote and customer fixtures */ diff --git a/dev/tests/integration/testsuite/Magento/Tax/Model/Sales/Total/Quote/SubtotalTest.php b/dev/tests/integration/testsuite/Magento/Tax/Model/Sales/Total/Quote/SubtotalTest.php index ecc48e0276779..cb16ee3cb934c 100644 --- a/dev/tests/integration/testsuite/Magento/Tax/Model/Sales/Total/Quote/SubtotalTest.php +++ b/dev/tests/integration/testsuite/Magento/Tax/Model/Sales/Total/Quote/SubtotalTest.php @@ -14,9 +14,8 @@ * Test \Magento\Tax\Model\Sales\Total\Quote\Subtotal * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - * @magentoDbIsolation disabled */ -class SubtotalTest extends \PHPUnit\Framework\TestCase +class SubtotalTest extends \Magento\TestFramework\Indexer\TestCase { /** * Object Manager @@ -30,6 +29,19 @@ class SubtotalTest extends \PHPUnit\Framework\TestCase */ private $productRepository; + public static function setUpBeforeClass() + { + $db = \Magento\TestFramework\Helper\Bootstrap::getInstance()->getBootstrap() + ->getApplication() + ->getDbInstance(); + if (!$db->isDbDumpExists()) { + throw new \LogicException('DB dump does not exist.'); + } + $db->restoreFromDbDump(); + + parent::setUpBeforeClass(); + } + protected function setUp() { $this->objectManager = Bootstrap::getObjectManager(); @@ -47,6 +59,7 @@ protected function getCustomerById($id) /** * @magentoAppIsolation enabled + * @magentoDbIsolation enabled * @magentoDataFixture Magento/Customer/_files/customer.php * @magentoDataFixture Magento/Customer/_files/customer_address.php * @magentoDataFixture Magento/Tax/_files/tax_classes.php @@ -165,6 +178,7 @@ public function collectUnitBasedDataProvider() } /** + * @magentoDbIsolation disabled * @magentoDataFixture Magento/Customer/_files/customer.php * @magentoDataFixture Magento/Customer/_files/customer_address.php * @magentoDataFixture Magento/Tax/_files/tax_classes.php diff --git a/dev/tests/integration/testsuite/Magento/Tax/Model/Sales/Total/Quote/TaxTest.php b/dev/tests/integration/testsuite/Magento/Tax/Model/Sales/Total/Quote/TaxTest.php index 80e4d5d316546..0513dd1c7d3c4 100644 --- a/dev/tests/integration/testsuite/Magento/Tax/Model/Sales/Total/Quote/TaxTest.php +++ b/dev/tests/integration/testsuite/Magento/Tax/Model/Sales/Total/Quote/TaxTest.php @@ -5,6 +5,7 @@ */ namespace Magento\Tax\Model\Sales\Total\Quote; +use Magento\Quote\Model\Quote\TotalsCollector; use Magento\Tax\Model\Calculation; use Magento\TestFramework\Helper\Bootstrap; @@ -15,7 +16,7 @@ * Class TaxTest * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class TaxTest extends \PHPUnit\Framework\TestCase +class TaxTest extends \Magento\TestFramework\Indexer\TestCase { /** * Utility object for setting up tax rates, tax classes and tax rules @@ -24,6 +25,21 @@ class TaxTest extends \PHPUnit\Framework\TestCase */ protected $setupUtil = null; + /** + * @var TotalsCollector + */ + private $totalsCollector; + + public function setUp() + { + /** @var \Magento\Framework\ObjectManagerInterface $objectManager */ + $objectManager = Bootstrap::getObjectManager(); + $this->totalsCollector = $objectManager->create(TotalsCollector::class); + $this->setupUtil = new SetupUtil($objectManager); + + parent::setUp(); + } + /** * Test taxes collection for quote. * @@ -234,18 +250,19 @@ protected function verifyResult($quoteAddress, $expectedResults) */ public function testTaxCalculation($configData, $quoteData, $expectedResults) { - /** @var \Magento\Framework\ObjectManagerInterface $objectManager */ - $objectManager = Bootstrap::getObjectManager(); - /** @var \Magento\Quote\Model\Quote\TotalsCollector $totalsCollector */ - $totalsCollector = $objectManager->create(\Magento\Quote\Model\Quote\TotalsCollector::class); - + $db = \Magento\TestFramework\Helper\Bootstrap::getInstance()->getBootstrap() + ->getApplication() + ->getDbInstance(); + if (!$db->isDbDumpExists()) { + throw new \LogicException('DB dump does not exist.'); + } + $db->restoreFromDbDump(); //Setup tax configurations - $this->setupUtil = new SetupUtil($objectManager); $this->setupUtil->setupTax($configData); $quote = $this->setupUtil->setupQuote($quoteData); $quoteAddress = $quote->getShippingAddress(); - $totalsCollector->collectAddressTotals($quote, $quoteAddress); + $this->totalsCollector->collectAddressTotals($quote, $quoteAddress); $this->verifyResult($quoteAddress, $expectedResults); } From 3cf1d74ee38f31a053963a797033cfa73290d9e8 Mon Sep 17 00:00:00 2001 From: Piyush Dankhara <dankhrapiyush@gmail.com> Date: Sat, 16 Jun 2018 22:36:45 -0700 Subject: [PATCH 152/206] Improve trim email address in customer account login page --- .../view/frontend/templates/form/login.phtml | 11 +--- .../view/frontend/web/js/trim-username.js | 65 ------------------- lib/web/mage/trim-input.js | 60 +++++++++++++++++ 3 files changed, 61 insertions(+), 75 deletions(-) delete mode 100644 app/code/Magento/Customer/view/frontend/web/js/trim-username.js create mode 100644 lib/web/mage/trim-input.js diff --git a/app/code/Magento/Customer/view/frontend/templates/form/login.phtml b/app/code/Magento/Customer/view/frontend/templates/form/login.phtml index 77e250c5de923..2d44dde215139 100644 --- a/app/code/Magento/Customer/view/frontend/templates/form/login.phtml +++ b/app/code/Magento/Customer/view/frontend/templates/form/login.phtml @@ -24,7 +24,7 @@ <div class="field email required"> <label class="label" for="email"><span><?= $block->escapeHtml(__('Email')) ?></span></label> <div class="control"> - <input name="login[username]" value="<?= $block->escapeHtmlAttr($block->getUsername()) ?>" <?php if ($block->isAutocompleteDisabled()): ?> autocomplete="off"<?php endif; ?> id="email" type="email" class="input-text" title="<?= $block->escapeHtmlAttr(__('Email')) ?>" data-validate="{required:true, 'validate-email':true}"> + <input name="login[username]" value="<?= $block->escapeHtmlAttr($block->getUsername()) ?>" <?php if ($block->isAutocompleteDisabled()): ?> autocomplete="off"<?php endif; ?> id="email" type="email" class="input-text" title="<?= $block->escapeHtmlAttr(__('Email')) ?>" data-mage-init='{"mage/trim-input":{}}' data-validate="{required:true, 'validate-email':true}"> </div> </div> <div class="field password required"> @@ -43,12 +43,3 @@ </div> </div> -<script type="text/x-magento-init"> - { - ".field.email": { - "Magento_Customer/js/trim-username": { - "formSelector": "form.form-login" - } - } - } -</script> diff --git a/app/code/Magento/Customer/view/frontend/web/js/trim-username.js b/app/code/Magento/Customer/view/frontend/web/js/trim-username.js deleted file mode 100644 index 69f89cb8fe01f..0000000000000 --- a/app/code/Magento/Customer/view/frontend/web/js/trim-username.js +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ - -define([ - 'jquery' -], function ($) { - 'use strict'; - - $.widget('mage.trimUsername', { - options: { - cache: {}, - formSelector: 'form', - emailSelector: 'input[type="email"]' - }, - - /** - * Widget initialization - * @private - */ - _create: function () { - // We need to look outside the module for backward compatibility, since someone can already use the module. - // @todo Narrow this selector in 2.3 so it doesn't accidentally finds the the email field from the - // newsletter email field or any other "email" field. - this.options.cache.email = $(this.options.formSelector).find(this.options.emailSelector); - this._bind(); - }, - - /** - * Event binding, will monitor change, keyup and paste events. - * @private - */ - _bind: function () { - if (this.options.cache.email.length) { - this._on(this.options.cache.email, { - 'change': this._trimUsername, - 'keyup': this._trimUsername, - 'paste': this._trimUsername - }); - } - }, - - /** - * Trim username - * @private - */ - _trimUsername: function () { - var username = this._getUsername().trim(); - - this.options.cache.email.val(username); - }, - - /** - * Get username value - * @returns {*} - * @private - */ - _getUsername: function () { - return this.options.cache.email.val(); - } - }); - - return $.mage.trimUsername; -}); diff --git a/lib/web/mage/trim-input.js b/lib/web/mage/trim-input.js new file mode 100644 index 0000000000000..678192dcf61ac --- /dev/null +++ b/lib/web/mage/trim-input.js @@ -0,0 +1,60 @@ +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +define([ + 'jquery' +], function ($) { + 'use strict'; + + $.widget('mage.trimInput', { + options: { + cache: {} + }, + + /** + * Widget initialization + * @private + */ + _create: function () { + this.options.cache.input = $(this.element); + this._bind(); + }, + + /** + * Event binding, will monitor change, keyup and paste events. + * @private + */ + _bind: function () { + if (this.options.cache.input.length) { + this._on(this.options.cache.input, { + 'change': this._trimInput, + 'keyup': this._trimInput, + 'paste': this._trimInput + }); + } + }, + + /** + * Trim value + * @private + */ + _trimInput: function () { + var input = this._getInputValue().trim(); + + this.options.cache.input.val(input); + }, + + /** + * Get input value + * @returns {*} + * @private + */ + _getInputValue: function () { + return this.options.cache.input.val(); + } + }); + + return $.mage.trimInput; +}); From bd7d3b4bedf9db467018d068bf8d71869dadef33 Mon Sep 17 00:00:00 2001 From: Piyush Dankhara <dankhrapiyush@gmail.com> Date: Sat, 16 Jun 2018 22:37:13 -0700 Subject: [PATCH 153/206] Trim email address in create new customer account page --- .../Magento/Customer/view/frontend/templates/form/register.phtml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Customer/view/frontend/templates/form/register.phtml b/app/code/Magento/Customer/view/frontend/templates/form/register.phtml index 43e4e92fd0904..0f7648265ef8b 100644 --- a/app/code/Magento/Customer/view/frontend/templates/form/register.phtml +++ b/app/code/Magento/Customer/view/frontend/templates/form/register.phtml @@ -142,6 +142,7 @@ class="input-text" data-password-min-length="<?= $block->escapeHtmlAttr($block->getMinimumPasswordLength()) ?>" data-password-min-character-sets="<?= $block->escapeHtmlAttr($block->getRequiredCharacterClassesNumber()) ?>" + data-mage-init='{"mage/trim-input":{}}' data-validate="{required:true, 'validate-customer-password':true}" autocomplete="off"> <div id="password-strength-meter-container" data-role="password-strength-meter" aria-live="polite"> From 8a17d2c4ef07beed652807c654e91d135589b664 Mon Sep 17 00:00:00 2001 From: Piyush Dankhara <dankhrapiyush@gmail.com> Date: Sat, 16 Jun 2018 22:44:52 -0700 Subject: [PATCH 154/206] Trim email address in customer authentication popup --- .../Customer/view/frontend/web/js/model/authentication-popup.js | 2 +- .../view/frontend/web/template/authentication-popup.html | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Customer/view/frontend/web/js/model/authentication-popup.js b/app/code/Magento/Customer/view/frontend/web/js/model/authentication-popup.js index 3fc65c266e895..c1ca395e46cbb 100644 --- a/app/code/Magento/Customer/view/frontend/web/js/model/authentication-popup.js +++ b/app/code/Magento/Customer/view/frontend/web/js/model/authentication-popup.js @@ -34,7 +34,7 @@ define([ /** Show login popup window */ showModal: function () { - $(this.modalWindow).modal('openModal'); + $(this.modalWindow).modal('openModal').trigger('contentUpdated'); } }; }); diff --git a/app/code/Magento/Customer/view/frontend/web/template/authentication-popup.html b/app/code/Magento/Customer/view/frontend/web/template/authentication-popup.html index 6b3a232cd3e39..ca4f8b4f03b13 100644 --- a/app/code/Magento/Customer/view/frontend/web/template/authentication-popup.html +++ b/app/code/Magento/Customer/view/frontend/web/template/authentication-popup.html @@ -60,6 +60,7 @@ id="customer-email" type="email" class="input-text" + data-mage-init='{"mage/trim-input":{}}' data-bind="attr: {autocomplete: autocomplete}" data-validate="{required:true, 'validate-email':true}"> </div> From a7839e29562e7bb3a3afd57caa8bc9f7cd9b9144 Mon Sep 17 00:00:00 2001 From: Oleh Kravets <xpoback@gmail.com> Date: Sun, 17 Jun 2018 10:59:17 +0200 Subject: [PATCH 155/206] magento/magento2#16184: Fix type error in payment void method --- app/code/Magento/Authorizenet/Model/Directpost.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Authorizenet/Model/Directpost.php b/app/code/Magento/Authorizenet/Model/Directpost.php index de567a8895f7e..9186acce83b4c 100644 --- a/app/code/Magento/Authorizenet/Model/Directpost.php +++ b/app/code/Magento/Authorizenet/Model/Directpost.php @@ -814,10 +814,14 @@ protected function declineOrder(\Magento\Sales\Model\Order $order, $message = '' { try { $response = $this->getResponse(); - if ($voidPayment && $response->getXTransId() && strtoupper($response->getXType()) - == self::REQUEST_TYPE_AUTH_ONLY + if ($voidPayment + && $response->getXTransId() + && strtoupper($response->getXType()) == self::REQUEST_TYPE_AUTH_ONLY ) { - $order->getPayment()->setTransactionId(null)->setParentTransactionId($response->getXTransId())->void(); + $order->getPayment() + ->setTransactionId(null) + ->setParentTransactionId($response->getXTransId()) + ->void($response); } $order->registerCancellation($message)->save(); } catch (\Exception $e) { From d2d1440549c0abd2adb9051f855b9fb8ea15f759 Mon Sep 17 00:00:00 2001 From: Michail Slabko <mslabko@magento.com> Date: Sun, 17 Jun 2018 22:22:52 +0300 Subject: [PATCH 156/206] MAGETWO-91820: Stabilize builds - MAGETWO-64467 [Indexer optimizations] Tables sharding / segmentation for price indexer --- .../Indexer/Product/Price/AbstractAction.php | 23 +++---- .../Indexer/Product/Price/Action/Full.php | 37 ++++-------- ...ory.php => DimensionCollectionFactory.php} | 14 ++--- .../Price/DimensionModeConfiguration.php | 5 +- .../Indexer/Product/Price/ModeSwitcher.php | 14 ++--- .../Product/Price/Plugin/TableResolver.php | 4 +- app/code/Magento/Catalog/etc/di.xml | 2 +- .../CustomerGroupDataProvider.php | 5 -- .../MultiDimensional/WebsiteDataProvider.php | 5 -- app/etc/di.xml | 1 - .../Indexer/DimensionProviderInterface.php | 2 +- .../Indexer/MultiDimensionProvider.php | 60 +++++++------------ .../MultiDimensionProviderInterface.php | 21 ------- 13 files changed, 61 insertions(+), 132 deletions(-) rename app/code/Magento/Catalog/Model/Indexer/Product/Price/{DimensionProviderFactory.php => DimensionCollectionFactory.php} (78%) delete mode 100644 lib/internal/Magento/Framework/Indexer/MultiDimensionProviderInterface.php diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php index 797236065e168..7342dbb01af30 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php @@ -83,7 +83,7 @@ abstract class AbstractAction private $tierPriceIndexResource; /** - * @var \Magento\Catalog\Model\Indexer\Product\Price\DimensionProviderFactory + * @var \Magento\Catalog\Model\Indexer\Product\Price\DimensionCollectionFactory */ private $dimensionCollectionFactory; @@ -102,7 +102,7 @@ abstract class AbstractAction * @param \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\Factory $indexerPriceFactory * @param DefaultPrice $defaultIndexerResource * @param \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\TierPrice|null $tierPriceIndexResource - * @param DimensionProviderFactory|null $dimensionCollectionFactory + * @param DimensionCollectionFactory|null $dimensionCollectionFactory * @param TableMaintainer|null $tableMaintainer * @SuppressWarnings(PHPMD.NPathComplexity) * @SuppressWarnings(PHPMD.CyclomaticComplexity) @@ -118,7 +118,7 @@ public function __construct( \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\Factory $indexerPriceFactory, DefaultPrice $defaultIndexerResource, \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\TierPrice $tierPriceIndexResource = null, - \Magento\Catalog\Model\Indexer\Product\Price\DimensionProviderFactory $dimensionCollectionFactory = null, + \Magento\Catalog\Model\Indexer\Product\Price\DimensionCollectionFactory $dimensionCollectionFactory = null, \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer $tableMaintainer = null ) { $this->_config = $config; @@ -134,7 +134,7 @@ public function __construct( \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\TierPrice::class ); $this->dimensionCollectionFactory = $dimensionCollectionFactory ?? ObjectManager::getInstance()->get( - \Magento\Catalog\Model\Indexer\Product\Price\DimensionProviderFactory::class + \Magento\Catalog\Model\Indexer\Product\Price\DimensionCollectionFactory::class ); $this->tableMaintainer = $tableMaintainer ?? ObjectManager::getInstance()->get( \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer::class @@ -159,10 +159,8 @@ abstract public function execute($ids); */ protected function _syncData(array $processIds = []) { - $dimensionsProviders = $this->dimensionCollectionFactory->createByMode(); - // for backward compatibility split data from old idx table on dimension tables - foreach ($dimensionsProviders as $dimensions) { + foreach ($this->dimensionCollectionFactory->create() as $dimensions) { $insertSelect = $this->_connection->select()->from( ['ip_tmp' => $this->_defaultIndexerResource->getIdxTable()] ); @@ -364,8 +362,7 @@ protected function _reindexRows($changedIds = []) foreach ($productsTypes as $productType => $entityIds) { $indexer = $this->_getIndexer($productType); if ($indexer instanceof DimensionalIndexerInterface) { - $dimensionsProviders = $this->dimensionCollectionFactory->createByMode(); - foreach ($dimensionsProviders as $dimensions) { + foreach ($this->dimensionCollectionFactory->create() as $dimensions) { $this->tableMaintainer->createMainTmpTable($dimensions); $temporaryTable = $this->tableMaintainer->getMainTmpTable($dimensions); $this->_emptyTable($temporaryTable); @@ -394,9 +391,7 @@ protected function _reindexRows($changedIds = []) */ private function deleteIndexData(array $entityIds) { - $dimensionsProviders = $this->dimensionCollectionFactory->createByMode(); - - foreach ($dimensionsProviders as $dimensions) { + foreach ($this->dimensionCollectionFactory->create() as $dimensions) { $select = $this->_connection->select()->from( ['index_price' => $this->tableMaintainer->getMainTable($dimensions)], null @@ -439,9 +434,7 @@ protected function _copyRelationIndexData($parentIds, $excludeIds = null) $children = $this->_connection->fetchCol($select); if ($children) { - /** @var DimensionProviderInterface $dimensionsProviders */ - $dimensionsProviders = $this->dimensionCollectionFactory->createByMode(); - foreach ($dimensionsProviders as $dimensions) { + foreach ($this->dimensionCollectionFactory->create() as $dimensions) { $select = $this->_connection->select()->from( $this->getIndexTargetTableByDimension($dimensions) )->where( diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php index ba6b163c56c49..3d5554f523f4a 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php @@ -11,7 +11,6 @@ use Magento\Catalog\Api\Data\ProductInterface; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Indexer\DimensionalIndexerInterface; -use Magento\Framework\Indexer\DimensionProviderInterface; use Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProvider; use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; @@ -48,20 +47,15 @@ class Full extends \Magento\Catalog\Model\Indexer\Product\Price\AbstractAction private $productMetaDataCached; /** - * @var \Magento\Catalog\Model\Indexer\Product\Price\DimensionProviderFactory + * @var \Magento\Catalog\Model\Indexer\Product\Price\DimensionCollectionFactory */ - private $dimensionProviderFactory; + private $dimensionCollectionFactory; /** * @var \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer */ private $dimensionTableMaintainer; - /** - * @var \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer - */ - private $configReader; - /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $config * @param \Magento\Store\Model\StoreManagerInterface $storeManager @@ -75,8 +69,8 @@ class Full extends \Magento\Catalog\Model\Indexer\Product\Price\AbstractAction * @param \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\BatchSizeCalculator|null $batchSizeCalculator * @param \Magento\Framework\Indexer\BatchProviderInterface|null $batchProvider * @param \Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher|null $activeTableSwitcher + * @param \Magento\Catalog\Model\Indexer\Product\Price\DimensionCollectionFactory|null $dimensionCollectionFactory * @param \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer|null $dimensionTableMaintainer - * @param \Magento\Framework\App\Config\ScopeConfigInterface|null $configReader * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -93,9 +87,8 @@ public function __construct( \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\BatchSizeCalculator $batchSizeCalculator = null, \Magento\Framework\Indexer\BatchProviderInterface $batchProvider = null, \Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher $activeTableSwitcher = null, - \Magento\Catalog\Model\Indexer\Product\Price\DimensionProviderFactory $dimensionCollectionFactory = null, - \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer $dimensionTableMaintainer = null, - \Magento\Framework\App\Config\ScopeConfigInterface $configReader = null + \Magento\Catalog\Model\Indexer\Product\Price\DimensionCollectionFactory $dimensionCollectionFactory = null, + \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer $dimensionTableMaintainer = null ) { parent::__construct( $config, @@ -119,15 +112,12 @@ public function __construct( $this->activeTableSwitcher = $activeTableSwitcher ?: ObjectManager::getInstance()->get( \Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher::class ); - $this->dimensionProviderFactory = $dimensionCollectionFactory ?: ObjectManager::getInstance()->get( - \Magento\Catalog\Model\Indexer\Product\Price\DimensionProviderFactory::class + $this->dimensionCollectionFactory = $dimensionCollectionFactory ?: ObjectManager::getInstance()->get( + \Magento\Catalog\Model\Indexer\Product\Price\DimensionCollectionFactory::class ); $this->dimensionTableMaintainer = $dimensionTableMaintainer ?: ObjectManager::getInstance()->get( \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer::class ); - $this->configReader = $configReader ?: ObjectManager::getInstance()->get( - \Magento\Framework\App\Config\ScopeConfigInterface::class - ); } /** @@ -203,9 +193,7 @@ private function truncateReplicaTable() */ private function truncateReplicaTablesByDimensions() { - /** @var DimensionProviderInterface $dimensionsProviders */ - $dimensionsProviders = $this->dimensionProviderFactory->createByMode(); - foreach ($dimensionsProviders as $dimension) { + foreach ($this->dimensionCollectionFactory->create() as $dimension) { $dimensionTable = $this->dimensionTableMaintainer->getMainReplicaTable($dimension); $this->_defaultIndexerResource->getConnection()->truncateTable($dimensionTable); } @@ -222,10 +210,7 @@ private function truncateReplicaTablesByDimensions() */ private function reindexProductTypeWithDimensions(DimensionalIndexerInterface $priceIndexer, string $typeId) { - /** @var DimensionProviderInterface $dimensionsProviders */ - $dimensionsProviders = $this->dimensionProviderFactory->createByMode(); - - foreach ($dimensionsProviders as $dimensions) { + foreach ($this->dimensionCollectionFactory->create() as $dimensions) { $this->reindexByBatches($priceIndexer, $dimensions, $typeId); } } @@ -414,12 +399,10 @@ private function getReplicaTable() */ private function switchTables() { - $dimensionsProviders = $this->dimensionProviderFactory->createByMode(); - // Switch dimension tables $mainTablesByDimension = []; - foreach ($dimensionsProviders as $dimensions) { + foreach ($this->dimensionCollectionFactory->create() as $dimensions) { $mainTablesByDimension[] = $this->dimensionTableMaintainer->getMainTable($dimensions); //Move data from indexers with old realisation diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionProviderFactory.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionCollectionFactory.php similarity index 78% rename from app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionProviderFactory.php rename to app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionCollectionFactory.php index 75214a7ae7e4a..c5ccff49501b6 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionProviderFactory.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionCollectionFactory.php @@ -6,9 +6,9 @@ namespace Magento\Catalog\Model\Indexer\Product\Price; use Magento\Framework\Indexer\DimensionProviderInterface; -use Magento\Framework\Indexer\MultiDimensionProviderInterface; +use Magento\Framework\Indexer\MultiDimensionProvider; -class DimensionProviderFactory +class DimensionCollectionFactory { /** * @var \Magento\Framework\Indexer\MultiDimensionProviderFactory @@ -26,12 +26,12 @@ class DimensionProviderFactory private $dimensionModeConfiguration; /** - * @param \Magento\Framework\Indexer\MultiDimensionProviderInterfaceFactory $multiDimensionProviderFactory + * @param \Magento\Framework\Indexer\MultiDimensionProviderFactory $multiDimensionProviderFactory * @param DimensionModeConfiguration $dimensionModeConfiguration * @param array $dimensionProviders */ public function __construct( - \Magento\Framework\Indexer\MultiDimensionProviderInterfaceFactory $multiDimensionProviderFactory, + \Magento\Framework\Indexer\MultiDimensionProviderFactory $multiDimensionProviderFactory, DimensionModeConfiguration $dimensionModeConfiguration, array $dimensionProviders ) { @@ -41,12 +41,12 @@ public function __construct( } /** - * Create MultiDimensionProviderInterface for specified "dimension mode" - which dimensions indexer use for sharding + * Create MultiDimensionProvider for specified "dimension mode" - which dimensions indexer use for sharding * * @param string|null $dimensionsMode - * @return MultiDimensionProviderInterface + * @return MultiDimensionProvider */ - public function createByMode(string $dimensionsMode = null): MultiDimensionProviderInterface + public function create(string $dimensionsMode = null): MultiDimensionProvider { $dimensionConfiguration = $this->dimensionModeConfiguration->getDimensionConfiguration($dimensionsMode); $dimensionProvidersMap = []; diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionModeConfiguration.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionModeConfiguration.php index 91fd384fcf23e..c9b00ed807d55 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionModeConfiguration.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionModeConfiguration.php @@ -59,7 +59,8 @@ public function __construct(ScopeConfigInterface $scopeConfig) } /** - * Get names of dimensions which used for current mode + * Get names of dimensions which used for provided mode. + * By default return dimensions for current enabled mode * * @param string|null $mode * @return string[] @@ -77,7 +78,7 @@ public function getDimensionConfiguration(string $mode = null): array /** * @return string */ - public function getCurrentMode(): string + private function getCurrentMode(): string { if (null === $this->currentMode) { $this->currentMode = $this->scopeConfig->getValue(ModeSwitcher::XML_PATH_PRICE_DIMENSIONS_MODE) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/ModeSwitcher.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/ModeSwitcher.php index 3a89e6cd391fb..07cafb21fd85a 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/ModeSwitcher.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/ModeSwitcher.php @@ -28,9 +28,9 @@ class ModeSwitcher /** * DimensionCollectionFactory * - * @var \Magento\Catalog\Model\Indexer\Product\Price\DimensionProviderFactory + * @var \Magento\Catalog\Model\Indexer\Product\Price\DimensionCollectionFactory */ - private $dimensionProviderFactory; + private $dimensionCollectionFactory; /** * @var array|null @@ -39,14 +39,14 @@ class ModeSwitcher /** * @param \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer $tableMaintainer - * @param \Magento\Catalog\Model\Indexer\Product\Price\DimensionProviderFactory $dimensionProviderFactory + * @param \Magento\Catalog\Model\Indexer\Product\Price\DimensionCollectionFactory $dimensionCollectionFactory */ public function __construct( \Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer $tableMaintainer, - \Magento\Catalog\Model\Indexer\Product\Price\DimensionProviderFactory $dimensionProviderFactory + \Magento\Catalog\Model\Indexer\Product\Price\DimensionCollectionFactory $dimensionCollectionFactory ) { $this->tableMaintainer = $tableMaintainer; - $this->dimensionProviderFactory = $dimensionProviderFactory; + $this->dimensionCollectionFactory = $dimensionCollectionFactory; } /** @@ -121,13 +121,13 @@ public function dropTables(string $previousMode) * * @return array */ - private function getDimensionsArray(string $mode): \Magento\Framework\Indexer\MultiDimensionProviderInterface + private function getDimensionsArray(string $mode): \Magento\Framework\Indexer\MultiDimensionProvider { if (isset($this->dimensionsArray[$mode])) { return $this->dimensionsArray[$mode]; } - $this->dimensionsArray[$mode] = $this->dimensionProviderFactory->createByMode($mode); + $this->dimensionsArray[$mode] = $this->dimensionCollectionFactory->create($mode); return $this->dimensionsArray[$mode]; } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/TableResolver.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/TableResolver.php index 1c11206864542..826f203190a79 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/TableResolver.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/TableResolver.php @@ -71,7 +71,7 @@ public function __construct( } /** - * Replacing catalog_product_index_price table name on the table name segmented per dimension + * Replacing catalog_product_index_price table name on the table name segmented per dimension. * * @param ResourceConnection $subject * @param string $result @@ -87,7 +87,7 @@ public function afterGetTableName( ) { if (!is_array($tableName) && $tableName === 'catalog_product_index_price' - && $this->dimensionModeConfiguration->getCurrentMode() !== DimensionModeConfiguration::DIMENSION_NONE + && $this->dimensionModeConfiguration->getDimensionConfiguration() ) { return $this->priceTableResolver->resolve('catalog_product_index_price', $this->getDimensions()); } diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml index 369818790919d..a6e255f3a9cf1 100644 --- a/app/code/Magento/Catalog/etc/di.xml +++ b/app/code/Magento/Catalog/etc/di.xml @@ -1076,7 +1076,7 @@ <argument name="nativeAttributeConditionBuilder" xsi:type="object">Magento\Catalog\Model\Api\SearchCriteria\CollectionProcessor\ConditionProcessor\ConditionBuilder\NativeAttributeCondition</argument> </arguments> </type> - <type name="Magento\Catalog\Model\Indexer\Product\Price\DimensionProviderFactory"> + <type name="Magento\Catalog\Model\Indexer\Product\Price\DimensionCollectionFactory"> <arguments> <argument name="dimensionProviders" xsi:type="array"> <item name="websites" xsi:type="object">Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider</item> diff --git a/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php b/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php index 6492338d15a24..a6bc6be5768b3 100644 --- a/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php +++ b/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php @@ -46,11 +46,6 @@ public function getIterator(): \Traversable } } - public function count(): int - { - return $this->getCustomerGroups()->count(); - } - /** * @return \SplFixedArray */ diff --git a/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php b/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php index fa62827287033..734b71b5a1e9d 100644 --- a/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php +++ b/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php @@ -55,11 +55,6 @@ public function getIterator(): \Traversable } } - public function count(): int - { - return $this->getWebsites()->count(); - } - /** * @return \SplFixedArray */ diff --git a/app/etc/di.xml b/app/etc/di.xml index fb768251a34b5..fcc1ae5521df3 100755 --- a/app/etc/di.xml +++ b/app/etc/di.xml @@ -173,7 +173,6 @@ <preference for="Magento\Framework\View\Page\FaviconInterface" type="Magento\Theme\Model\Favicon\Favicon" /> <preference for="Magento\Framework\View\Element\Message\InterpretationStrategyInterface" type="Magento\Framework\View\Element\Message\InterpretationMediator" /> <preference for="Magento\Framework\Indexer\Config\DependencyInfoProviderInterface" type="Magento\Framework\Indexer\Config\DependencyInfoProvider" /> - <preference for="Magento\Framework\Indexer\MultiDimensionProviderInterface" type="\Magento\Framework\Indexer\MultiDimensionProvider" /> <preference for="Magento\Framework\Search\Request\IndexScopeResolverInterface" type="Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver"/> <type name="Magento\Framework\Model\ResourceModel\Db\TransactionManager" shared="false" /> <type name="Magento\Framework\Acl\Data\Cache"> diff --git a/lib/internal/Magento/Framework/Indexer/DimensionProviderInterface.php b/lib/internal/Magento/Framework/Indexer/DimensionProviderInterface.php index 40b12912ca11f..82cb3a48957db 100644 --- a/lib/internal/Magento/Framework/Indexer/DimensionProviderInterface.php +++ b/lib/internal/Magento/Framework/Indexer/DimensionProviderInterface.php @@ -10,7 +10,7 @@ /** * Provide a list of dimensions */ -interface DimensionProviderInterface extends \IteratorAggregate, \Countable +interface DimensionProviderInterface extends \IteratorAggregate { /** * Get Dimension Iterator. Returns yielded value of \Magento\Framework\Indexer\Dimension diff --git a/lib/internal/Magento/Framework/Indexer/MultiDimensionProvider.php b/lib/internal/Magento/Framework/Indexer/MultiDimensionProvider.php index 21274fe633075..6dee6cd01d8d1 100644 --- a/lib/internal/Magento/Framework/Indexer/MultiDimensionProvider.php +++ b/lib/internal/Magento/Framework/Indexer/MultiDimensionProvider.php @@ -6,7 +6,10 @@ namespace Magento\Framework\Indexer; -class MultiDimensionProvider implements MultiDimensionProviderInterface +/** + * Multiply dimensions from provided DimensionProviderInterface + */ +class MultiDimensionProvider implements \IteratorAggregate { /** * @var array @@ -23,11 +26,6 @@ class MultiDimensionProvider implements MultiDimensionProviderInterface */ private $dimensionsProvidersCount = 0; - /** - * @var int - */ - private $dimensionsCount; - /** * @param DimensionProviderInterface[] $dimensionProviders */ @@ -36,45 +34,39 @@ public function __construct(array $dimensionProviders = []) foreach ($dimensionProviders as $dimensionDataProvider) { $this->addDimensionDataProvider($dimensionDataProvider); } + foreach ($this->dimensionsDataProviders as $dimensionDataProvider) { + $this->dimensionsIterators[] = $dimensionDataProvider->getIterator(); + } } + /** + * @return \Traversable|Dimension[][] + */ public function getIterator(): \Traversable { - $this->initDataIterators(); - $dimensionsCount = $this->count(); - - for ($i = 0; $i < $dimensionsCount; $i++) { - yield $this->getCurrentDimension(); - $this->setNextDimension(); - } - if (!$dimensionsCount) { + if (!$this->dimensionsIterators) { yield []; - } - } - - public function count(): int - { - if ($this->dimensionsCount === null) { - $counts = []; - - foreach ($this->dimensionsDataProviders as $dimensionsDataProvider) { - $counts[] = count($dimensionsDataProvider); + } else { + while (true) { + $dimensions = $this->getCurrentDimension(); + if (!$dimensions) { + break; + } + yield $dimensions; + $this->setNextDimension(); } - - $this->dimensionsCount = count($counts) === 0 ? 0 : array_product($counts); } - - return $this->dimensionsCount; } private function getCurrentDimension(): array { $dimensions = []; - foreach ($this->dimensionsIterators as $dimensionIterator) { + if (!$dimensionIterator->valid()) { + return []; + } /** @var Dimension $dimension */ $dimension = $dimensionIterator->current(); - $dimensions[$dimension->getName()] = $dimension; } @@ -98,12 +90,4 @@ private function addDimensionDataProvider(DimensionProviderInterface $dimensionD $this->dimensionsDataProviders[] = $dimensionDataProvider; $this->dimensionsProvidersCount++; } - - private function initDataIterators() - { - $this->dimensionsIterators = []; - foreach ($this->dimensionsDataProviders as $dimensionDataProvider) { - $this->dimensionsIterators[] = $dimensionDataProvider->getIterator(); - } - } } diff --git a/lib/internal/Magento/Framework/Indexer/MultiDimensionProviderInterface.php b/lib/internal/Magento/Framework/Indexer/MultiDimensionProviderInterface.php deleted file mode 100644 index 4f73e1ff79fe3..0000000000000 --- a/lib/internal/Magento/Framework/Indexer/MultiDimensionProviderInterface.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -declare(strict_types=1); - -namespace Magento\Framework\Indexer; - -/** - * Provide a list of multi dimensions. - * Used for multiply several dimension and return array of dimensions during iteration - */ -interface MultiDimensionProviderInterface extends \IteratorAggregate -{ - /** - * Returns [\Magento\Framework\Indexer\Dimension, ...] for each iteration - * @return \Traversable|[\Magento\Framework\Indexer\Dimension,] - */ - public function getIterator(): \Traversable; -} From d5fc7d469500cab834831d62c59d0aa5ead7cfa8 Mon Sep 17 00:00:00 2001 From: Michail Slabko <mslabko@magento.com> Date: Sun, 17 Jun 2018 22:46:32 +0300 Subject: [PATCH 157/206] MAGETWO-91820: Stabilize builds - MAGETWO-64467 [Indexer optimizations] Tables sharding / segmentation for price indexer --- .../Indexer/Product/Price/AbstractAction.php | 9 ++++---- .../Indexer/Product/Price/Action/Full.php | 8 +++---- .../Price/DimensionModeConfiguration.php | 12 +++++----- .../Indexer/Product/Price/ModeSwitcher.php | 8 +++---- .../Product/Price/Plugin/CustomerGroup.php | 22 +++++++++---------- .../Product/Price/Plugin/TableResolver.php | 12 +++++----- .../Indexer/Product/Price/Plugin/Website.php | 22 +++++++++---------- .../ResourceModel/Layer/Filter/Price.php | 8 +++---- .../ResourceModel/Product/Collection.php | 8 +++---- ...LinkedProductSelectBuilderByIndexPrice.php | 8 +++---- .../Indexer/Price/Query/BaseFinalPrice.php | 14 ++++++------ .../Product/Price/Plugin/WebsiteTest.php | 4 ++-- app/code/Magento/Catalog/etc/di.xml | 8 +++++-- .../Aggregation/DataProvider/QueryBuilder.php | 16 +++++++++----- .../Adapter/Mysql/Dynamic/DataProvider.php | 14 ++++++++---- .../Search/FilterMapper/ExclusionStrategy.php | 8 +++---- ...php => CustomerGroupDimensionProvider.php} | 13 +++++------ ...vider.php => WebsiteDimensionProvider.php} | 17 ++++++-------- 18 files changed, 109 insertions(+), 102 deletions(-) rename app/code/Magento/Customer/Model/Indexer/{MultiDimensional/CustomerGroupDataProvider.php => CustomerGroupDimensionProvider.php} (78%) rename app/code/Magento/Store/Model/Indexer/{MultiDimensional/WebsiteDataProvider.php => WebsiteDimensionProvider.php} (77%) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php index 7342dbb01af30..eebbb6b44180e 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php @@ -6,11 +6,10 @@ namespace Magento\Catalog\Model\Indexer\Product\Price; use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\DefaultPrice; -use Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProvider; +use Magento\Customer\Model\Indexer\CustomerGroupDimensionProvider; use Magento\Framework\App\ObjectManager; use Magento\Framework\Indexer\DimensionalIndexerInterface; -use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; -use Magento\Framework\Indexer\DimensionProviderInterface; +use Magento\Store\Model\Indexer\WebsiteDimensionProvider; /** * Abstract action reindex class @@ -166,10 +165,10 @@ protected function _syncData(array $processIds = []) ); foreach ($dimensions as $dimension) { - if ($dimension->getName() === WebsiteDataProvider::DIMENSION_NAME) { + if ($dimension->getName() === WebsiteDimensionProvider::DIMENSION_NAME) { $insertSelect->where('ip_tmp.website_id = ?', $dimension->getValue()); } - if ($dimension->getName() === CustomerGroupDataProvider::DIMENSION_NAME) { + if ($dimension->getName() === CustomerGroupDimensionProvider::DIMENSION_NAME) { $insertSelect->where('ip_tmp.customer_group_id = ?', $dimension->getValue()); } } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php index 3d5554f523f4a..4c83481e081bc 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php @@ -11,8 +11,8 @@ use Magento\Catalog\Api\Data\ProductInterface; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Indexer\DimensionalIndexerInterface; -use Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProvider; -use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; +use Magento\Customer\Model\Indexer\CustomerGroupDimensionProvider; +use Magento\Store\Model\Indexer\WebsiteDimensionProvider; /** * Class Full reindex action @@ -438,10 +438,10 @@ private function moveDataFromReplicaTableToReplicaTables(array $dimensions) $replicaTablesByDimension = $this->dimensionTableMaintainer->getMainReplicaTable($dimensions); foreach ($dimensions as $dimension) { - if ($dimension->getName() === WebsiteDataProvider::DIMENSION_NAME) { + if ($dimension->getName() === WebsiteDimensionProvider::DIMENSION_NAME) { $select->where('website_id = ?', $dimension->getValue()); } - if ($dimension->getName() === CustomerGroupDataProvider::DIMENSION_NAME) { + if ($dimension->getName() === CustomerGroupDimensionProvider::DIMENSION_NAME) { $select->where('customer_group_id = ?', $dimension->getValue()); } } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionModeConfiguration.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionModeConfiguration.php index c9b00ed807d55..e5935dac92a36 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionModeConfiguration.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionModeConfiguration.php @@ -7,8 +7,8 @@ namespace Magento\Catalog\Model\Indexer\Product\Price; use Magento\Framework\App\Config\ScopeConfigInterface; -use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; -use Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProvider; +use Magento\Store\Model\Indexer\WebsiteDimensionProvider; +use Magento\Customer\Model\Indexer\CustomerGroupDimensionProvider; class DimensionModeConfiguration { @@ -30,14 +30,14 @@ class DimensionModeConfiguration self::DIMENSION_NONE => [ ], self::DIMENSION_WEBSITE => [ - WebsiteDataProvider::DIMENSION_NAME + WebsiteDimensionProvider::DIMENSION_NAME ], self::DIMENSION_CUSTOMER_GROUP => [ - CustomerGroupDataProvider::DIMENSION_NAME + CustomerGroupDimensionProvider::DIMENSION_NAME ], self::DIMENSION_WEBSITE_AND_CUSTOMER_GROUP => [ - WebsiteDataProvider::DIMENSION_NAME, - CustomerGroupDataProvider::DIMENSION_NAME + WebsiteDimensionProvider::DIMENSION_NAME, + CustomerGroupDimensionProvider::DIMENSION_NAME ], ]; /** diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/ModeSwitcher.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/ModeSwitcher.php index 07cafb21fd85a..d160a5859abe4 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/ModeSwitcher.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/ModeSwitcher.php @@ -8,8 +8,8 @@ namespace Magento\Catalog\Model\Indexer\Product\Price; use Magento\Framework\Search\Request\Dimension; -use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; -use Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProvider; +use Magento\Store\Model\Indexer\WebsiteDimensionProvider; +use Magento\Customer\Model\Indexer\CustomerGroupDimensionProvider; /** * Class to prepare new tables for new indexer mode @@ -146,10 +146,10 @@ private function insertFromOldTablesToNew(string $newTable, string $oldTable, ar $select = $this->tableMaintainer->getConnection()->select()->from($oldTable); foreach ($dimensions as $dimension) { - if ($dimension->getName() === WebsiteDataProvider::DIMENSION_NAME) { + if ($dimension->getName() === WebsiteDimensionProvider::DIMENSION_NAME) { $select->where('website_id = ?', $dimension->getValue()); } - if ($dimension->getName() === CustomerGroupDataProvider::DIMENSION_NAME) { + if ($dimension->getName() === CustomerGroupDimensionProvider::DIMENSION_NAME) { $select->where('customer_group_id = ?', $dimension->getValue()); } } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CustomerGroup.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CustomerGroup.php index 84e53834cd838..9b99ee8c8dc8c 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CustomerGroup.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CustomerGroup.php @@ -12,8 +12,8 @@ use Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer; use Magento\Framework\Indexer\Dimension; use Magento\Framework\Indexer\DimensionFactory; -use Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProvider; -use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; +use Magento\Customer\Model\Indexer\CustomerGroupDimensionProvider; +use Magento\Store\Model\Indexer\WebsiteDimensionProvider; class CustomerGroup { @@ -40,29 +40,29 @@ class CustomerGroup private $dimensionModeConfiguration; /** - * @var WebsiteDataProvider + * @var WebsiteDimensionProvider */ - private $websiteDataProvider; + private $websiteDimensionProvider; /** * @param UpdateIndexInterface $updateIndex * @param TableMaintainer $tableMaintainer * @param DimensionFactory $dimensionFactory * @param DimensionModeConfiguration $dimensionModeConfiguration - * @param WebsiteDataProvider $websiteDataProvider + * @param WebsiteDimensionProvider $websiteDimensionProvider */ public function __construct( UpdateIndexInterface $updateIndex, TableMaintainer $tableMaintainer, DimensionFactory $dimensionFactory, DimensionModeConfiguration $dimensionModeConfiguration, - WebsiteDataProvider $websiteDataProvider + WebsiteDimensionProvider $websiteDimensionProvider ) { $this->updateIndex = $updateIndex; $this->tableMaintainer = $tableMaintainer; $this->dimensionFactory = $dimensionFactory; $this->dimensionModeConfiguration = $dimensionModeConfiguration; - $this->websiteDataProvider = $websiteDataProvider; + $this->websiteDimensionProvider = $websiteDimensionProvider; } /** @@ -120,17 +120,17 @@ private function getAffectedDimensions(string $groupId): array { $currentDimensions = $this->dimensionModeConfiguration->getDimensionConfiguration(); // do not return dimensions if Customer Group dimension is not present in configuration - if (!in_array(CustomerGroupDataProvider::DIMENSION_NAME, $currentDimensions, true)) { + if (!in_array(CustomerGroupDimensionProvider::DIMENSION_NAME, $currentDimensions, true)) { return []; } $customerGroupDimension = $this->dimensionFactory->create( - CustomerGroupDataProvider::DIMENSION_NAME, + CustomerGroupDimensionProvider::DIMENSION_NAME, $groupId ); $dimensions = []; - if (in_array(WebsiteDataProvider::DIMENSION_NAME, $currentDimensions, true)) { - foreach ($this->websiteDataProvider as $websiteDimension) { + if (in_array(WebsiteDimensionProvider::DIMENSION_NAME, $currentDimensions, true)) { + foreach ($this->websiteDimensionProvider as $websiteDimension) { $dimensions[] = [ $customerGroupDimension, $websiteDimension diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/TableResolver.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/TableResolver.php index 826f203190a79..fbeec22783090 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/TableResolver.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/TableResolver.php @@ -15,8 +15,8 @@ use Magento\Framework\Indexer\Dimension; use Magento\Store\Model\StoreManagerInterface; use Magento\Customer\Model\Context as CustomerContext; -use Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProvider; -use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; +use Magento\Customer\Model\Indexer\CustomerGroupDimensionProvider; +use Magento\Store\Model\Indexer\WebsiteDimensionProvider; /** * Replace catalog_product_index_price table name on the table name segmented per dimension. @@ -103,10 +103,10 @@ private function getDimensions(): array { $dimensions = []; foreach ($this->dimensionModeConfiguration->getDimensionConfiguration() as $dimensionName) { - if ($dimensionName === WebsiteDataProvider::DIMENSION_NAME) { + if ($dimensionName === WebsiteDimensionProvider::DIMENSION_NAME) { $dimensions[] = $this->createDimensionFromWebsite(); } - if ($dimensionName === CustomerGroupDataProvider::DIMENSION_NAME) { + if ($dimensionName === CustomerGroupDimensionProvider::DIMENSION_NAME) { $dimensions[] = $this->createDimensionFromCustomerGroup(); } } @@ -122,7 +122,7 @@ private function createDimensionFromWebsite(): Dimension { $storeKey = $this->httpContext->getValue(StoreManagerInterface::CONTEXT_STORE); return $this->dimensionFactory->create( - WebsiteDataProvider::DIMENSION_NAME, + WebsiteDimensionProvider::DIMENSION_NAME, (string)$this->storeManager->getStore($storeKey)->getWebsiteId() ); } @@ -133,7 +133,7 @@ private function createDimensionFromWebsite(): Dimension private function createDimensionFromCustomerGroup(): Dimension { return $this->dimensionFactory->create( - CustomerGroupDataProvider::DIMENSION_NAME, + CustomerGroupDimensionProvider::DIMENSION_NAME, (string)$this->httpContext->getValue(CustomerContext::CONTEXT_GROUP) ); } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/Website.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/Website.php index 30b0a80c9e4ee..4831680f07c33 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/Website.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/Website.php @@ -9,8 +9,8 @@ use Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer; use Magento\Framework\Indexer\Dimension; use Magento\Framework\Indexer\DimensionFactory; -use Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProvider; -use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; +use Magento\Customer\Model\Indexer\CustomerGroupDimensionProvider; +use Magento\Store\Model\Indexer\WebsiteDimensionProvider; use Magento\Framework\Model\ResourceModel\Db\AbstractDb; use Magento\Framework\Model\AbstractModel; @@ -34,26 +34,26 @@ class Website private $dimensionModeConfiguration; /** - * @var CustomerGroupDataProvider + * @var CustomerGroupDimensionProvider */ - private $customerGroupDataProvider; + private $customerGroupDimensionProvider; /** * @param TableMaintainer $tableMaintainer * @param DimensionFactory $dimensionFactory * @param DimensionModeConfiguration $dimensionModeConfiguration - * @param CustomerGroupDataProvider $customerGroupDataProvider + * @param CustomerGroupDimensionProvider $customerGroupDimensionProvider */ public function __construct( TableMaintainer $tableMaintainer, DimensionFactory $dimensionFactory, DimensionModeConfiguration $dimensionModeConfiguration, - CustomerGroupDataProvider $customerGroupDataProvider + CustomerGroupDimensionProvider $customerGroupDimensionProvider ) { $this->tableMaintainer = $tableMaintainer; $this->dimensionFactory = $dimensionFactory; $this->dimensionModeConfiguration = $dimensionModeConfiguration; - $this->customerGroupDataProvider = $customerGroupDataProvider; + $this->customerGroupDimensionProvider = $customerGroupDimensionProvider; } /** @@ -107,17 +107,17 @@ private function getAffectedDimensions(string $websiteId): array { $currentDimensions = $this->dimensionModeConfiguration->getDimensionConfiguration(); // do not return dimensions if Website dimension is not present in configuration - if (!in_array(WebsiteDataProvider::DIMENSION_NAME, $currentDimensions, true)) { + if (!in_array(WebsiteDimensionProvider::DIMENSION_NAME, $currentDimensions, true)) { return []; } $websiteDimension = $this->dimensionFactory->create( - WebsiteDataProvider::DIMENSION_NAME, + WebsiteDimensionProvider::DIMENSION_NAME, $websiteId ); $dimensions = []; - if (in_array(CustomerGroupDataProvider::DIMENSION_NAME, $currentDimensions, true)) { - foreach ($this->customerGroupDataProvider as $customerGroupDimension) { + if (in_array(CustomerGroupDimensionProvider::DIMENSION_NAME, $currentDimensions, true)) { + foreach ($this->customerGroupDimensionProvider as $customerGroupDimension) { $dimensions[] = [ $customerGroupDimension, $websiteDimension diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Layer/Filter/Price.php b/app/code/Magento/Catalog/Model/ResourceModel/Layer/Filter/Price.php index 263c104027090..7f66e5e253706 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Layer/Filter/Price.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Layer/Filter/Price.php @@ -11,8 +11,8 @@ use Magento\Framework\Search\Request\IndexScopeResolverInterface; use Magento\Store\Model\StoreManagerInterface; use Magento\Customer\Model\Context as CustomerContext; -use Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProvider; -use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; +use Magento\Customer\Model\Indexer\CustomerGroupDimensionProvider; +use Magento\Store\Model\Indexer\WebsiteDimensionProvider; /** * Catalog Layer Price Filter resource model @@ -409,11 +409,11 @@ protected function _construct() 'catalog_product_index_price', [ $this->dimensionFactory->create( - WebsiteDataProvider::DIMENSION_NAME, + WebsiteDimensionProvider::DIMENSION_NAME, (string)$this->storeManager->getStore($storeKey)->getWebsiteId() ), $this->dimensionFactory->create( - CustomerGroupDataProvider::DIMENSION_NAME, + CustomerGroupDimensionProvider::DIMENSION_NAME, (string)$this->httpContext->getValue(CustomerContext::CONTEXT_GROUP) ) ] diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php index f28b4deb93e51..9dc4dce716951 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php @@ -14,12 +14,12 @@ use Magento\Catalog\Model\ResourceModel\Product\Collection\ProductLimitationFactory; use Magento\CatalogUrlRewrite\Model\ProductUrlRewriteGenerator; use Magento\Customer\Api\GroupManagementInterface; -use Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProvider; +use Magento\Customer\Model\Indexer\CustomerGroupDimensionProvider; use Magento\Framework\App\ObjectManager; use Magento\Framework\DB\Select; use Magento\Framework\EntityManager\MetadataPool; use Magento\Catalog\Model\Indexer\Product\Price\PriceTableResolver; -use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; +use Magento\Store\Model\Indexer\WebsiteDimensionProvider; use Magento\Store\Model\Store; use Magento\Catalog\Model\Indexer\Category\Product\TableMaintainer; use Magento\Framework\Indexer\DimensionFactory; @@ -1925,11 +1925,11 @@ protected function _productLimitationPrice($joinLeft = false) 'catalog_product_index_price', [ $this->dimensionFactory->create( - CustomerGroupDataProvider::DIMENSION_NAME, + CustomerGroupDimensionProvider::DIMENSION_NAME, (string)$filters['customer_group_id'] ), $this->dimensionFactory->create( - WebsiteDataProvider::DIMENSION_NAME, + WebsiteDimensionProvider::DIMENSION_NAME, (string)$filters['website_id'] ) ] diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/LinkedProductSelectBuilderByIndexPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/LinkedProductSelectBuilderByIndexPrice.php index 09ce46e47b05a..ebe04fb63b217 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/LinkedProductSelectBuilderByIndexPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/LinkedProductSelectBuilderByIndexPrice.php @@ -7,12 +7,12 @@ use Magento\Catalog\Api\Data\ProductInterface; use Magento\Catalog\Model\ResourceModel\Product\BaseSelectProcessorInterface; -use Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProvider; +use Magento\Customer\Model\Indexer\CustomerGroupDimensionProvider; use Magento\Framework\App\ObjectManager; use Magento\Framework\DB\Select; use Magento\Catalog\Model\ResourceModel\Product\LinkedProductSelectBuilderInterface; use Magento\Framework\Indexer\DimensionFactory; -use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; +use Magento\Store\Model\Indexer\WebsiteDimensionProvider; use Magento\Framework\Search\Request\IndexScopeResolverInterface; class LinkedProductSelectBuilderByIndexPrice implements LinkedProductSelectBuilderInterface @@ -105,9 +105,9 @@ public function build($productId) )->joinInner( [ 't' => $this->priceTableResolver->resolve('catalog_product_index_price', [ - $this->dimensionFactory->create(WebsiteDataProvider::DIMENSION_NAME, (string)$websiteId), + $this->dimensionFactory->create(WebsiteDimensionProvider::DIMENSION_NAME, (string)$websiteId), $this->dimensionFactory->create( - CustomerGroupDataProvider::DIMENSION_NAME, + CustomerGroupDimensionProvider::DIMENSION_NAME, (string)$customerGroupId ), ]) diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php index 0af245e87e64b..668a0c82b8cbf 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php @@ -8,12 +8,12 @@ namespace Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\Query; use Magento\Catalog\Model\Product\Attribute\Source\Status; -use Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProvider; +use Magento\Customer\Model\Indexer\CustomerGroupDimensionProvider; use Magento\Framework\DB\Select; use Magento\Framework\DB\Sql\ColumnValueExpression; use Magento\Framework\Exception\InputException; use Magento\Framework\Indexer\Dimension; -use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; +use Magento\Store\Model\Indexer\WebsiteDimensionProvider; /** * Prepare base select for Product Price index limited by specified dimensions: website and customer group @@ -52,8 +52,8 @@ class BaseFinalPrice * @var array */ private $dimensionToFieldMapper = [ - WebsiteDataProvider::DIMENSION_NAME => 'pw.website_id', - CustomerGroupDataProvider::DIMENSION_NAME => 'cg.customer_group_id', + WebsiteDimensionProvider::DIMENSION_NAME => 'pw.website_id', + CustomerGroupDimensionProvider::DIMENSION_NAME => 'cg.customer_group_id', ]; /** @@ -110,11 +110,11 @@ public function getQuery(array $dimensions, string $productType, array $entityId ['entity_id'] )->joinInner( ['cg' => $this->getTable('customer_group')], - array_key_exists(CustomerGroupDataProvider::DIMENSION_NAME, $dimensions) + array_key_exists(CustomerGroupDimensionProvider::DIMENSION_NAME, $dimensions) ? sprintf( '%s = %s', - $this->dimensionToFieldMapper[CustomerGroupDataProvider::DIMENSION_NAME], - $dimensions[CustomerGroupDataProvider::DIMENSION_NAME]->getValue() + $this->dimensionToFieldMapper[CustomerGroupDimensionProvider::DIMENSION_NAME], + $dimensions[CustomerGroupDimensionProvider::DIMENSION_NAME]->getValue() ) : '', ['customer_group_id'] )->joinInner( diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Plugin/WebsiteTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Plugin/WebsiteTest.php index c88b6695b779f..1a5fea5e12769 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Plugin/WebsiteTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Plugin/WebsiteTest.php @@ -75,7 +75,7 @@ public function testAfterDelete() ); $this->dimensionModeConfiguration->expects($this->once())->method('getDimensionConfiguration')->willReturn( - [\Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider::DIMENSION_NAME] + [\Magento\Store\Model\Indexer\WebsiteDimensionProvider::DIMENSION_NAME] ); $subjectMock = $this->createMock(\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class); @@ -131,7 +131,7 @@ public function testAfterSave() ); $this->dimensionModeConfiguration->expects($this->once())->method('getDimensionConfiguration')->willReturn( - [\Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider::DIMENSION_NAME] + [\Magento\Store\Model\Indexer\WebsiteDimensionProvider::DIMENSION_NAME] ); $subjectMock = $this->createMock(\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class); diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml index a6e255f3a9cf1..e56cb5487f7ee 100644 --- a/app/code/Magento/Catalog/etc/di.xml +++ b/app/code/Magento/Catalog/etc/di.xml @@ -1079,8 +1079,12 @@ <type name="Magento\Catalog\Model\Indexer\Product\Price\DimensionCollectionFactory"> <arguments> <argument name="dimensionProviders" xsi:type="array"> - <item name="websites" xsi:type="object">Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider</item> - <item name="customer_groups" xsi:type="object">Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProvider</item> + <item name="websites" xsi:type="object"> + Magento\Store\Model\Indexer\WebsiteDimensionProvider + </item> + <item name="customer_groups" xsi:type="object"> + Magento\Customer\Model\Indexer\CustomerGroupDimensionProvider + </item> </argument> </arguments> </type> diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Aggregation/DataProvider/QueryBuilder.php b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Aggregation/DataProvider/QueryBuilder.php index 26c5dd5f9b7fd..7ebf71f424439 100644 --- a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Aggregation/DataProvider/QueryBuilder.php +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Aggregation/DataProvider/QueryBuilder.php @@ -8,18 +8,16 @@ use Magento\CatalogInventory\Model\Configuration as CatalogInventoryConfiguration; use Magento\CatalogInventory\Model\Stock; -use Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProvider; +use Magento\Customer\Model\Indexer\CustomerGroupDimensionProvider; use Magento\Eav\Model\Entity\Attribute\AbstractAttribute; use Magento\Framework\App\ResourceConnection; use Magento\Framework\App\ScopeResolverInterface; -use Magento\Framework\DB\Adapter\AdapterInterface; use Magento\Framework\DB\Select; -use Magento\Catalog\Model\Indexer\Product\Price\PriceTableResolver; use Magento\Framework\Search\Request\BucketInterface; use Magento\Framework\App\ObjectManager; use Magento\Framework\Indexer\DimensionFactory; use Magento\Framework\Search\Request\IndexScopeResolverInterface; -use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; +use Magento\Store\Model\Indexer\WebsiteDimensionProvider; /** * Attribute query builder @@ -129,8 +127,14 @@ private function buildQueryForPriceAttribute( $tableName = $this->priceTableResolver->resolve( 'catalog_product_index_price', [ - $this->dimensionFactory->create(WebsiteDataProvider::DIMENSION_NAME, (string)$websiteId), - $this->dimensionFactory->create(CustomerGroupDataProvider::DIMENSION_NAME, (string)$customerGroupId), + $this->dimensionFactory->create( + WebsiteDimensionProvider::DIMENSION_NAME, + (string)$websiteId + ), + $this->dimensionFactory->create( + CustomerGroupDimensionProvider::DIMENSION_NAME, + (string)$customerGroupId + ), ] ); $select->from(['main_table' => $tableName], null) diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Dynamic/DataProvider.php b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Dynamic/DataProvider.php index 4e7961977d6c5..d2e653ac9b9ae 100644 --- a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Dynamic/DataProvider.php +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Dynamic/DataProvider.php @@ -6,7 +6,7 @@ namespace Magento\CatalogSearch\Model\Adapter\Mysql\Dynamic; use Magento\Catalog\Model\Layer\Filter\Price\Range; -use Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProvider; +use Magento\Customer\Model\Indexer\CustomerGroupDimensionProvider; use Magento\Customer\Model\Session; use Magento\Framework\App\ResourceConnection; use Magento\Framework\DB\Adapter\AdapterInterface; @@ -18,7 +18,7 @@ use Magento\Framework\Search\Dynamic\IntervalFactory; use Magento\Framework\Search\Request\BucketInterface; use Magento\Framework\App\ObjectManager; -use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; +use Magento\Store\Model\Indexer\WebsiteDimensionProvider; use Magento\Store\Model\StoreManager; use \Magento\Framework\Search\Request\IndexScopeResolverInterface; @@ -132,8 +132,14 @@ public function getAggregations(\Magento\Framework\Search\Dynamic\EntityStorage $tableName = $this->priceTableResolver->resolve( 'catalog_product_index_price', [ - $this->dimensionFactory->create(WebsiteDataProvider::DIMENSION_NAME, (string)$websiteId), - $this->dimensionFactory->create(CustomerGroupDataProvider::DIMENSION_NAME, (string)$customerGroupId), + $this->dimensionFactory->create( + WebsiteDimensionProvider::DIMENSION_NAME, + (string)$websiteId + ), + $this->dimensionFactory->create( + CustomerGroupDimensionProvider::DIMENSION_NAME, + (string)$customerGroupId + ), ] ); /** @var Table $table */ diff --git a/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/ExclusionStrategy.php b/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/ExclusionStrategy.php index 131ea208ea569..512dd69aad952 100644 --- a/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/ExclusionStrategy.php +++ b/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/ExclusionStrategy.php @@ -7,7 +7,7 @@ namespace Magento\CatalogSearch\Model\Search\FilterMapper; use Magento\CatalogSearch\Model\Adapter\Mysql\Filter\AliasResolver; -use Magento\Customer\Model\Indexer\MultiDimensional\CustomerGroupDataProvider; +use Magento\Customer\Model\Indexer\CustomerGroupDimensionProvider; use Magento\Framework\App\Http\Context; use Magento\Framework\App\ObjectManager; use Magento\Framework\Indexer\DimensionFactory; @@ -16,7 +16,7 @@ use Magento\Catalog\Model\Indexer\Category\Product\AbstractAction; use Magento\Customer\Model\Context as CustomerContext; use Magento\Framework\Search\Request\IndexScopeResolverInterface; -use Magento\Store\Model\Indexer\MultiDimensional\WebsiteDataProvider; +use Magento\Store\Model\Indexer\WebsiteDimensionProvider; /** * Strategy which processes exclusions from general rules @@ -131,9 +131,9 @@ private function applyPriceFilter( $tableName = $this->priceTableResolver->resolve( 'catalog_product_index_price', [ - $this->dimensionFactory->create(WebsiteDataProvider::DIMENSION_NAME, (string)$websiteId), + $this->dimensionFactory->create(WebsiteDimensionProvider::DIMENSION_NAME, (string)$websiteId), $this->dimensionFactory->create( - CustomerGroupDataProvider::DIMENSION_NAME, + CustomerGroupDimensionProvider::DIMENSION_NAME, (string)$this->httpContext->getValue(CustomerContext::CONTEXT_GROUP) ) ] diff --git a/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php b/app/code/Magento/Customer/Model/Indexer/CustomerGroupDimensionProvider.php similarity index 78% rename from app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php rename to app/code/Magento/Customer/Model/Indexer/CustomerGroupDimensionProvider.php index a6bc6be5768b3..d1797923a7a33 100644 --- a/app/code/Magento/Customer/Model/Indexer/MultiDimensional/CustomerGroupDataProvider.php +++ b/app/code/Magento/Customer/Model/Indexer/CustomerGroupDimensionProvider.php @@ -4,13 +4,13 @@ * See COPYING.txt for license details. */ -namespace Magento\Customer\Model\Indexer\MultiDimensional; +namespace Magento\Customer\Model\Indexer; use Magento\Customer\Model\ResourceModel\Group\CollectionFactory as CustomerGroupCollectionFactory; use Magento\Framework\Indexer\DimensionFactory; use Magento\Framework\Indexer\DimensionProviderInterface; -class CustomerGroupDataProvider implements DimensionProviderInterface +class CustomerGroupDimensionProvider implements DimensionProviderInterface { /** * Name for customer group dimension for multidimensional indexer @@ -47,15 +47,12 @@ public function getIterator(): \Traversable } /** - * @return \SplFixedArray + * @return array */ - private function getCustomerGroups() + private function getCustomerGroups(): array { if ($this->customerGroupsDataIterator === null) { - $this->customerGroupsDataIterator = \SplFixedArray::fromArray( - $this->collectionFactory->create()->getAllIds(), - false - ); + $this->customerGroupsDataIterator = $this->collectionFactory->create()->getAllIds(); } return $this->customerGroupsDataIterator; diff --git a/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php b/app/code/Magento/Store/Model/Indexer/WebsiteDimensionProvider.php similarity index 77% rename from app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php rename to app/code/Magento/Store/Model/Indexer/WebsiteDimensionProvider.php index 734b71b5a1e9d..4aa0768fbaa98 100644 --- a/app/code/Magento/Store/Model/Indexer/MultiDimensional/WebsiteDataProvider.php +++ b/app/code/Magento/Store/Model/Indexer/WebsiteDimensionProvider.php @@ -4,7 +4,7 @@ * See COPYING.txt for license details. */ -namespace Magento\Store\Model\Indexer\MultiDimensional; +namespace Magento\Store\Model\Indexer; use Magento\Framework\Indexer\Dimension; use Magento\Store\Model\ResourceModel\Website\CollectionFactory as WebsiteCollectionFactory; @@ -12,7 +12,7 @@ use Magento\Framework\Indexer\DimensionProviderInterface; use Magento\Store\Model\Store; -class WebsiteDataProvider implements DimensionProviderInterface +class WebsiteDimensionProvider implements DimensionProviderInterface { /** * Name for website dimension for multidimensional indexer @@ -56,17 +56,14 @@ public function getIterator(): \Traversable } /** - * @return \SplFixedArray + * @return array */ - private function getWebsites() + private function getWebsites(): array { if ($this->websitesDataIterator === null) { - $this->websitesDataIterator = \SplFixedArray::fromArray( - $this->collectionFactory->create() - ->addFieldToFilter('code', ['neq' => Store::ADMIN_CODE]) - ->getAllIds(), - false - ); + $this->websitesDataIterator = $this->collectionFactory->create() + ->addFieldToFilter('code', ['neq' => Store::ADMIN_CODE]) + ->getAllIds(); } return $this->websitesDataIterator; From e8c6dcd5f64ef7474c09aa102dd7504b826edd48 Mon Sep 17 00:00:00 2001 From: OlgaVasyltsun <olga.vasyltsun@transoftgroup.com> Date: Mon, 18 Jun 2018 08:22:37 +0300 Subject: [PATCH 158/206] MAGETWO-90837: Can't save customer address on adminhtml when country restriction is enabled --- .../Model/Address/AbstractAddress.php | 38 +++++++++++++++++- .../Model/Address/AbstractAddressTest.php | 40 ++++++++++++++----- 2 files changed, 65 insertions(+), 13 deletions(-) diff --git a/app/code/Magento/Customer/Model/Address/AbstractAddress.php b/app/code/Magento/Customer/Model/Address/AbstractAddress.php index eb541850a1bc1..4b7926c54f0ab 100644 --- a/app/code/Magento/Customer/Model/Address/AbstractAddress.php +++ b/app/code/Magento/Customer/Model/Address/AbstractAddress.php @@ -13,6 +13,8 @@ use Magento\Customer\Api\Data\RegionInterfaceFactory; use Magento\Customer\Model\Data\Address as AddressData; use Magento\Framework\Model\AbstractExtensibleModel; +use Magento\Framework\App\ObjectManager; +use Magento\Store\Model\ScopeInterface; /** * Address abstract model @@ -119,6 +121,16 @@ class AbstractAddress extends AbstractExtensibleModel implements AddressModelInt */ protected $dataObjectHelper; + /** + * @var \Magento\Directory\Model\AllowedCountries + */ + private $allowedCountriesReader; + + /** + * @var \Magento\Customer\Model\Config\Share + */ + private $shareConfig; + /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry @@ -154,7 +166,9 @@ public function __construct( \Magento\Framework\Api\DataObjectHelper $dataObjectHelper, \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, - array $data = [] + array $data = [], + \Magento\Directory\Model\AllowedCountries $allowedCountriesReader = null, + \Magento\Customer\Model\Config\Share $shareConfig = null ) { $this->_directoryData = $directoryData; $data = $this->_implodeArrayField($data); @@ -166,6 +180,10 @@ public function __construct( $this->addressDataFactory = $addressDataFactory; $this->regionDataFactory = $regionDataFactory; $this->dataObjectHelper = $dataObjectHelper; + $this->allowedCountriesReader = $allowedCountriesReader + ?: ObjectManager::getInstance()->get(\Magento\Directory\Model\AllowedCountries::class); + $this->shareConfig = $shareConfig + ?: ObjectManager::getInstance()->get(\Magento\Customer\Model\Config\Share::class); parent::__construct( $context, $registry, @@ -623,7 +641,7 @@ public function validate() $errors[] = __('%fieldName is a required field.', ['fieldName' => 'countryId']); } else { //Checking if such country exists. - if (!in_array($countryId, $this->_directoryData->getCountryCollection()->getAllIds(), true)) { + if (!in_array($countryId, $this->getWebsiteAllowedCountries(), true)) { $errors[] = __( 'Invalid value of "%value" provided for the %fieldName field.', [ @@ -667,6 +685,22 @@ public function validate() return $errors; } + /** + * Return allowed counties per website. + * + * @return array + */ + private function getWebsiteAllowedCountries(): array + { + $websiteId = null; + + if (!$this->shareConfig->isGlobalScope()) { + $websiteId = $this->getCustomer() ? $this->getCustomer()->getWebsiteId() : null; + } + + return $this->allowedCountriesReader->getAllowedCountries(ScopeInterface::SCOPE_WEBSITE, $websiteId); + } + /** * @return \Magento\Directory\Model\Region */ diff --git a/app/code/Magento/Customer/Test/Unit/Model/Address/AbstractAddressTest.php b/app/code/Magento/Customer/Test/Unit/Model/Address/AbstractAddressTest.php index 453ec208e8846..178cfac467cd2 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Address/AbstractAddressTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Address/AbstractAddressTest.php @@ -6,6 +6,8 @@ namespace Magento\Customer\Test\Unit\Model\Address; +use Magento\Store\Model\ScopeInterface; + /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ @@ -38,6 +40,16 @@ class AbstractAddressTest extends \PHPUnit\Framework\TestCase /** @var \Magento\Framework\Data\Collection\AbstractDb|\PHPUnit_Framework_MockObject_MockObject */ protected $resourceCollectionMock; + /** + * @var \Magento\Directory\Model\AllowedCountries|\PHPUnit_Framework_MockObject_MockObject + */ + private $allowedCountriesReaderMock; + + /** + * @var \Magento\Customer\Model\Config\Share|\PHPUnit_Framework_MockObject_MockObject + */ + private $shareConfigMock; + /** @var \Magento\Customer\Model\Address\AbstractAddress */ protected $model; @@ -72,6 +84,15 @@ protected function setUp() $this->resourceCollectionMock = $this->getMockBuilder(\Magento\Framework\Data\Collection\AbstractDb::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); + $this->allowedCountriesReaderMock = $this->createPartialMock( + \Magento\Directory\Model\AllowedCountries::class, + ['getAllowedCountries'] + ); + $this->shareConfigMock = $this->createPartialMock( + \Magento\Customer\Model\Config\Share::class, + ['isGlobalScope'] + ); + $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $this->objectManager->getObject( \Magento\Customer\Model\Address\AbstractAddress::class, @@ -84,7 +105,9 @@ protected function setUp() 'regionFactory' => $this->regionFactoryMock, 'countryFactory' => $this->countryFactoryMock, 'resource' => $this->resourceMock, - 'resourceCollection' => $this->resourceCollectionMock + 'resourceCollection' => $this->resourceCollectionMock, + 'allowedCountriesReader' => $this->allowedCountriesReaderMock, + 'shareConfig' => $this->shareConfigMock, ] ); } @@ -302,16 +325,11 @@ public function testValidate(array $data, $expected) $this->directoryDataMock->expects($this->any()) ->method('isRegionRequired'); - $countryCollectionMock = $this->getMockBuilder(\Magento\Directory\Model\ResourceModel\Country\Collection::class) - ->disableOriginalConstructor() - ->setMethods(['getAllIds']) - ->getMock(); - - $this->directoryDataMock->expects($this->any()) - ->method('getCountryCollection') - ->willReturn($countryCollectionMock); - - $countryCollectionMock->expects($this->any())->method('getAllIds')->willReturn([$countryId]); + $this->shareConfigMock->method('isGlobalScope')->willReturn(false); + $this->allowedCountriesReaderMock + ->method('getAllowedCountries') + ->with(ScopeInterface::SCOPE_WEBSITE, null) + ->willReturn([$countryId]); $regionModelMock = $this->getMockBuilder(\Magento\Directory\Model\Region::class) ->disableOriginalConstructor() From e687fedbe27a3cc9c8ae5d6f34d0a9952b4eb6b4 Mon Sep 17 00:00:00 2001 From: Ronak Patel <ronak2ram@gmail.com> Date: Mon, 18 Jun 2018 12:00:41 +0530 Subject: [PATCH 159/206] Update Info.php --- app/code/Magento/Sales/Block/Order/Info.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Sales/Block/Order/Info.php b/app/code/Magento/Sales/Block/Order/Info.php index db3dbdbfde40b..689a55f06896c 100644 --- a/app/code/Magento/Sales/Block/Order/Info.php +++ b/app/code/Magento/Sales/Block/Order/Info.php @@ -23,7 +23,7 @@ class Info extends \Magento\Framework\View\Element\Template /** * @var string */ - protected $_template = 'order/info.phtml'; + protected $_template = 'Magento_Sales::order/info.phtml'; /** * Core registry From 6d6624169341e6e6753418fefd2c67b35b0539a9 Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov <slopukhov@magento.com> Date: Mon, 18 Jun 2018 10:05:35 +0300 Subject: [PATCH 160/206] MAGETWO-91820: Stabilize builds --- app/code/Magento/Store/etc/di.xml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/code/Magento/Store/etc/di.xml b/app/code/Magento/Store/etc/di.xml index 162bfb0604c79..5f088558b41d9 100644 --- a/app/code/Magento/Store/etc/di.xml +++ b/app/code/Magento/Store/etc/di.xml @@ -425,4 +425,13 @@ </argument> </arguments> </type> + <type name="Magento\Store\Model\StoreSwitcher"> + <arguments> + <argument name="storeSwitchers" xsi:type="array"> + <item name="cleanTargetUrl" xsi:type="object">Magento\Store\Model\StoreSwitcher\CleanTargetUrl</item> + <item name="manageStoreCookie" xsi:type="object">Magento\Store\Model\StoreSwitcher\ManageStoreCookie</item> + <item name="managePrivateContent" xsi:type="object">Magento\Store\Model\StoreSwitcher\ManagePrivateContent</item> + </argument> + </arguments> + </type> </config> From c8339935011e8c6f1cb0eea7d5789d304d6a6c32 Mon Sep 17 00:00:00 2001 From: Michail Slabko <mslabko@magento.com> Date: Mon, 18 Jun 2018 14:14:05 +0300 Subject: [PATCH 161/206] MAGETWO-91820: Stabilize builds - MAGETWO-64467 [Indexer optimizations] Tables sharding / segmentation for price indexer --- .../Indexer/Product/Price/AbstractAction.php | 1 - .../Indexer/Product/Price/Action/Full.php | 2 -- .../Indexer/Product/Price/TableMaintainer.php | 2 +- .../Product/Indexer/Price/DefaultPrice.php | 26 ------------------- .../Price/Query/JoinAttributeProcessor.php | 18 +++---------- .../Indexer/Price/SimpleProductPrice.php | 10 +------ .../Indexer/DimensionalIndexerInterface.php | 2 +- 7 files changed, 7 insertions(+), 54 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php index eebbb6b44180e..ac06041a789cb 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php @@ -410,7 +410,6 @@ private function deleteIndexData(array $entityIds) * which do not work by dimensions. * For indexers, which support dimensions all composite products read data directly from main price indexer table * or replica table for partial or full reindex correspondingly. - * @see \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\DefaultPrice::getIndexTableForCompositeProducts */ protected function _copyRelationIndexData($parentIds, $excludeIds = null) { diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php index 4c83481e081bc..7c4cc08886a5e 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php @@ -142,8 +142,6 @@ public function execute($ids = null) continue; } - //TODO: fix dirty hac - $priceIndexer->setIsPartial(false); $priceIndexer->getTableStrategy()->setUseIdxTable(false); //Old price reindex mechanism diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php index cb9c633017bed..ef06405af1429 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php @@ -40,7 +40,7 @@ class TableMaintainer /** * Catalog tmp category index table name */ - private $tmpTableSuffix = '_temp'; //TODO: align with \Magento\Catalog\Model\ResourceModel\Product\Indexer\TemporaryTableStrategy::TEMP_SUFFIX + private $tmpTableSuffix = '_temp'; /** * Catalog tmp category index table name diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php index 72edd12fedf23..0a659180950c4 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php @@ -811,32 +811,6 @@ public function getIdxTable($table = null) return $this->tableStrategy->getTableName('catalog_product_index_price'); } - /** - * Return index table name depends in indexation mode: main price index table for partial reindex - * and replica table for full reindex - * - * @return string - * @throws \Magento\Framework\Exception\LocalizedException - */ - protected function getIndexTableForCompositeProducts() - { - // TODO: temporary fix, move to composite products - return $this->isPartial - ? $this->getMainTable() - : $this->activeTableSwitcher->getAdditionalTableName($this->getMainTable()); - } - - private $isPartial = true; - - /** - * @param bool $isPartial - * TODO: fix dirty hac - */ - public function setIsPartial(bool $isPartial) - { - $this->isPartial = $isPartial; - } - /** * @return bool */ diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/JoinAttributeProcessor.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/JoinAttributeProcessor.php index 0caf13281cacb..7673e57f3f443 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/JoinAttributeProcessor.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/JoinAttributeProcessor.php @@ -9,6 +9,7 @@ use Magento\Catalog\Api\Data\ProductInterface; use Magento\Framework\DB\Select; +use Magento\Framework\DB\Sql\Expression; /** * Allows to join product attribute to Select. Used for build price index for specified dimension @@ -25,11 +26,6 @@ class JoinAttributeProcessor */ private $metadataPool; - /** - * @var \Magento\Store\Model\StoreManagerInterface - */ - private $storeManager; - /** * @var \Magento\Framework\App\ResourceConnection */ @@ -41,13 +37,10 @@ class JoinAttributeProcessor private $connectionName; /** - * JoinProcessor constructor. - * @param \Magento\Framework\App\ResourceConnection $resource * @param \Magento\Eav\Model\Config $eavConfig - * @param \Magento\Framework\Module\Manager $moduleManager - * @param \Magento\Catalog\Helper\Data $dataHelper * @param \Magento\Framework\EntityManager\MetadataPool $metadataPool * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\App\ResourceConnection $resource * @param string $connectionName */ public function __construct( @@ -59,21 +52,19 @@ public function __construct( ) { $this->eavConfig = $eavConfig; $this->metadataPool = $metadataPool; - $this->storeManager = $storeManager; $this->resource = $resource; $this->connectionName = $connectionName; } /** * @param Select $select - * @param int $websiteId * @param string $attributeCode * @param string|null $attributeValue * @return \Zend_Db_Expr * @throws \Magento\Framework\Exception\LocalizedException * @throws \Zend_Db_Select_Exception */ - public function process(Select $select, $attributeCode, $attributeValue = null) + public function process(Select $select, $attributeCode, $attributeValue = null): \Zend_Db_Expr { $attribute = $this->eavConfig->getAttribute(\Magento\Catalog\Model\Product::ENTITY, $attributeCode); $attributeId = $attribute->getAttributeId(); @@ -83,7 +74,6 @@ public function process(Select $select, $attributeCode, $attributeValue = null) $productIdField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField(); if ($attribute->isScopeGlobal()) { - //TODO: refactor global join - move outside if statement $alias = 'ta_' . $attributeCode; $select->{$joinType}( [$alias => $attributeTable], @@ -91,7 +81,7 @@ public function process(Select $select, $attributeCode, $attributeValue = null) " AND {$alias}.store_id = 0", [] ); - $whereExpression = new \Zend_Db_Expr("{$alias}.value"); + $whereExpression = new Expression("{$alias}.value"); } else { $dAlias = 'tad_' . $attributeCode; $sAlias = 'tas_' . $attributeCode; diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/SimpleProductPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/SimpleProductPrice.php index 03149348aa0c7..8a761a0e67fa7 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/SimpleProductPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/SimpleProductPrice.php @@ -63,15 +63,7 @@ public function __construct( } /** - * Execute indexer by specified dimension. - * Accept array of dimensions DTO that represent indexer dimension - * - * @param \Magento\Framework\Indexer\Dimension[] $dimensions - * @param \Traversable|null $entityIds - * @return void - * @throws \Magento\Framework\Exception\LocalizedException - * @throws \Magento\Framework\Exception\InputException - * @throws \Zend_Db_Select_Exception + * {@inheritdoc} */ public function executeByDimension(array $dimensions, \Traversable $entityIds = null) { diff --git a/lib/internal/Magento/Framework/Indexer/DimensionalIndexerInterface.php b/lib/internal/Magento/Framework/Indexer/DimensionalIndexerInterface.php index 2c22118cda1dc..32eaa0a3ff28b 100644 --- a/lib/internal/Magento/Framework/Indexer/DimensionalIndexerInterface.php +++ b/lib/internal/Magento/Framework/Indexer/DimensionalIndexerInterface.php @@ -17,7 +17,7 @@ interface DimensionalIndexerInterface * Accept array of dimensions DTO that represent indexer dimension * * @param \Magento\Framework\Indexer\Dimension[] $dimensions - * @param array|null $entityIds + * @param \Traversable|null $entityIds * @return void */ public function executeByDimension(array $dimensions, \Traversable $entityIds = null); From 8cee2f1d250fa6206cabee21f4563521e48fac29 Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov <slopukhov@magento.com> Date: Mon, 18 Jun 2018 14:25:18 +0300 Subject: [PATCH 162/206] MAGETWO-91820: Stabilize builds --- app/code/Magento/Catalog/etc/di.xml | 1 + .../Indexer/ScopeResolver/IndexScopeResolver.php | 12 +++++++----- .../Unit/ScopeResolver/IndexScopeResolverTest.php | 14 ++++++++++++-- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml index e56cb5487f7ee..a6b12135fa6e0 100644 --- a/app/code/Magento/Catalog/etc/di.xml +++ b/app/code/Magento/Catalog/etc/di.xml @@ -1120,6 +1120,7 @@ <type name="Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer"> <arguments> <argument name="connectionName" xsi:type="string">indexer</argument> + <argument name="tableResolver" xsi:type="object">Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver</argument> </arguments> </type> <type name="Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\SimpleProductPrice"> diff --git a/lib/internal/Magento/Framework/Indexer/ScopeResolver/IndexScopeResolver.php b/lib/internal/Magento/Framework/Indexer/ScopeResolver/IndexScopeResolver.php index 891a6cd1efe12..e0be02cf09546 100644 --- a/lib/internal/Magento/Framework/Indexer/ScopeResolver/IndexScopeResolver.php +++ b/lib/internal/Magento/Framework/Indexer/ScopeResolver/IndexScopeResolver.php @@ -42,18 +42,20 @@ public function __construct( */ public function resolve($index, array $dimensions) { - $tableNameParts = [$index]; + $mainPart = [$index]; + $tableNameParts = []; foreach ($dimensions as $dimension) { switch ($dimension->getName()) { case 'scope': - $tableNameParts[] = $dimension->getName() . $this->getScopeId($dimension); + $tableNameParts[$dimension->getName()] = $dimension->getName() . $this->getScopeId($dimension); break; default: - $tableNameParts[] = $dimension->getName() . $dimension->getValue(); + $tableNameParts[$dimension->getName()] = $dimension->getName() . $dimension->getValue(); } } - - return $this->resource->getTableName(implode('_', $tableNameParts)); + ksort($tableNameParts); + $result = array_merge($mainPart, $tableNameParts); + return $this->resource->getTableName(implode('_', $result)); } /** diff --git a/lib/internal/Magento/Framework/Indexer/Test/Unit/ScopeResolver/IndexScopeResolverTest.php b/lib/internal/Magento/Framework/Indexer/Test/Unit/ScopeResolver/IndexScopeResolverTest.php index ae898657ccecf..b193a3eecdd98 100644 --- a/lib/internal/Magento/Framework/Indexer/Test/Unit/ScopeResolver/IndexScopeResolverTest.php +++ b/lib/internal/Magento/Framework/Indexer/Test/Unit/ScopeResolver/IndexScopeResolverTest.php @@ -103,9 +103,19 @@ public function resolveDataProvider() ], [ 'index' => 'index_name', - 'dimensions' => [['dimension', 10], ['dimension', 20]], + 'dimensions' => [['first', 10], ['second', 20]], // actually you will get exception here thrown in ScopeResolverInterface - 'expected' => 'index_name_dimension10_dimension20' + 'expected' => 'index_name_first10_second20' + ], + [ + 'index' => 'index_name', + 'dimensions' => [['second', 10], ['first', 20]], + 'expected' => 'index_name_first20_second10' + ], + [ + 'index' => 'index_name', + 'dimensions' => [[-1, 10], ['first', 20]], + 'expected' => 'index_name_-110_first20' ] ]; } From de1b7173363e403398e942f7599ba039c8aa7e75 Mon Sep 17 00:00:00 2001 From: Stas Kozar <stas.kozar@transoftgroup.com> Date: Mon, 18 Jun 2018 14:35:53 +0300 Subject: [PATCH 163/206] MAGETWO-92312: Wrong price and Cart Subtotal at mini shopping cart --- .../Checkout/view/frontend/web/js/model/totals.js | 15 ++++++--------- .../view/frontend/web/js/view/minicart.js | 8 ++++---- .../view/frontend/web/js/customer-data.js | 8 +++----- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/app/code/Magento/Checkout/view/frontend/web/js/model/totals.js b/app/code/Magento/Checkout/view/frontend/web/js/model/totals.js index a0bdf0a17d7fe..aba0c31b998d1 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/model/totals.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/model/totals.js @@ -14,20 +14,17 @@ define([ 'use strict'; var quoteItems = ko.observable(quote.totals().items), - cartData = customerData.get('cart'); + cartData = customerData.get('cart'), + quoteSubtotal = parseFloat(quote.totals().subtotal), + subtotalAmount = parseFloat(cartData().subtotalAmount); quote.totals.subscribe(function (newValue) { quoteItems(newValue.items); }); - cartData.subscribe(function () { - var quoteSubtotal = parseFloat(quote.totals().subtotal), - subtotalAmount = parseFloat(cartData().subtotalAmount); - - if (quoteSubtotal !== subtotalAmount) { - customerData.reload(['cart'], false); - } - }, this); + if (quoteSubtotal !== subtotalAmount) { + customerData.reload(['cart'], false); + } return { totals: quote.totals, diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/minicart.js b/app/code/Magento/Checkout/view/frontend/web/js/view/minicart.js index 33223e9ae3c24..a2f8c8c56ff33 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/minicart.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/minicart.js @@ -94,10 +94,6 @@ define([ this.isLoading(addToCartCalls > 0); sidebarInitialized = false; this.update(updatedCart); - - if (cartData()['website_id'] !== window.checkout.websiteId) { - customerData.reload(['cart'], false); - } initSidebar(); }, this); $('[data-block="minicart"]').on('contentLoading', function () { @@ -105,6 +101,10 @@ define([ self.isLoading(true); }); + if (cartData()['website_id'] !== window.checkout.websiteId) { + customerData.reload(['cart'], false); + } + return this._super(); }, isLoading: ko.observable(false), diff --git a/app/code/Magento/Customer/view/frontend/web/js/customer-data.js b/app/code/Magento/Customer/view/frontend/web/js/customer-data.js index 15df80f360bf7..c4672c48e1f4a 100644 --- a/app/code/Magento/Customer/view/frontend/web/js/customer-data.js +++ b/app/code/Magento/Customer/view/frontend/web/js/customer-data.js @@ -232,11 +232,9 @@ define([ if (!_.isEmpty(privateContent)) { countryData = this.get('directory-data'); - countryData.subscribe(function () { - if (_.isEmpty(countryData())) { - customerData.reload(['directory-data'], false); - } - }, this); + if (_.isEmpty(countryData())) { + customerData.reload(['directory-data'], false); + } } }, From 4d507e093ad44eb3e8b81cc98eda09261b9631d0 Mon Sep 17 00:00:00 2001 From: Platform Team <platform.team@vaimo.com> Date: Mon, 18 Jun 2018 13:38:08 +0200 Subject: [PATCH 164/206] Setting deploy mode to production with --skip-compilation flag should not clear generated code --- setup/src/Magento/Setup/Console/CompilerPreparation.php | 1 - 1 file changed, 1 deletion(-) diff --git a/setup/src/Magento/Setup/Console/CompilerPreparation.php b/setup/src/Magento/Setup/Console/CompilerPreparation.php index 9ea938d51fb37..c39c721b61716 100644 --- a/setup/src/Magento/Setup/Console/CompilerPreparation.php +++ b/setup/src/Magento/Setup/Console/CompilerPreparation.php @@ -105,7 +105,6 @@ private function getCompilerInvalidationCommands() 'module:disable', 'module:enable', 'module:uninstall', - 'deploy:mode:set' ]; } From 20cbe6bb08872be61c346a12fed7ec6b5b5e652d Mon Sep 17 00:00:00 2001 From: Viktor Tymchynskyi <vtymchynskyi@magento.com> Date: Fri, 15 Jun 2018 16:28:18 +0300 Subject: [PATCH 165/206] MAGETWO-89034: Not Visible Custom Address Attributes Showing on Checkout --- .../Checkout/Model/DefaultConfigProvider.php | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Checkout/Model/DefaultConfigProvider.php b/app/code/Magento/Checkout/Model/DefaultConfigProvider.php index 5335e31b6b574..89eb7bfcce7f1 100644 --- a/app/code/Magento/Checkout/Model/DefaultConfigProvider.php +++ b/app/code/Magento/Checkout/Model/DefaultConfigProvider.php @@ -8,12 +8,14 @@ use Magento\Catalog\Helper\Product\ConfigurationPool; use Magento\Checkout\Helper\Data as CheckoutHelper; use Magento\Checkout\Model\Session as CheckoutSession; +use Magento\Customer\Api\AddressMetadataInterface; use Magento\Customer\Api\CustomerRepositoryInterface as CustomerRepository; use Magento\Customer\Model\Context as CustomerContext; use Magento\Customer\Model\Session as CustomerSession; use Magento\Customer\Model\Url as CustomerUrlManager; use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\App\Http\Context as HttpContext; +use Magento\Framework\App\ObjectManager; use Magento\Framework\Data\Form\FormKey; use Magento\Framework\Locale\FormatInterface as LocaleFormat; use Magento\Framework\UrlInterface; @@ -159,6 +161,11 @@ class DefaultConfigProvider implements ConfigProviderInterface */ protected $urlBuilder; + /** + * @var AddressMetadataInterface + */ + private $addressMetadata; + /** * @param CheckoutHelper $checkoutHelper * @param Session $checkoutSession @@ -186,6 +193,7 @@ class DefaultConfigProvider implements ConfigProviderInterface * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Quote\Api\PaymentMethodManagementInterface $paymentMethodManagement * @param UrlInterface $urlBuilder + * @param AddressMetadataInterface $addressMetadata * @codeCoverageIgnore * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -215,7 +223,8 @@ public function __construct( \Magento\Shipping\Model\Config $shippingMethodConfig, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Quote\Api\PaymentMethodManagementInterface $paymentMethodManagement, - UrlInterface $urlBuilder + UrlInterface $urlBuilder, + AddressMetadataInterface $addressMetadata = null ) { $this->checkoutHelper = $checkoutHelper; $this->checkoutSession = $checkoutSession; @@ -243,6 +252,7 @@ public function __construct( $this->storeManager = $storeManager; $this->paymentMethodManagement = $paymentMethodManagement; $this->urlBuilder = $urlBuilder; + $this->addressMetadata = $addressMetadata ?: ObjectManager::getInstance()->get(AddressMetadataInterface::class); } /** @@ -323,11 +333,34 @@ private function getCustomerData() $customerData = $customer->__toArray(); foreach ($customer->getAddresses() as $key => $address) { $customerData['addresses'][$key]['inline'] = $this->getCustomerAddressInline($address); + if ($address->getCustomAttributes()) { + $customerData['addresses'][$key]['custom_attributes'] = $this->filterNotVisibleAttributes( + $customerData['addresses'][$key]['custom_attributes'] + ); + } } } return $customerData; } + /** + * Filter not visible on storefront custom attributes. + * + * @param array $attributes + * @return array + */ + private function filterNotVisibleAttributes(array $attributes) + { + $attributesMetadata = $this->addressMetadata->getAllAttributesMetadata(); + foreach ($attributesMetadata as $attributeMetadata) { + if (!$attributeMetadata->isVisible()) { + unset($attributes[$attributeMetadata->getAttributeCode()]); + } + } + + return $attributes; + } + /** * Set additional customer address data * From 4952d50030bc8821eb9a85a0c8d6bb5e77e80cce Mon Sep 17 00:00:00 2001 From: Alexander Kras'ko <0m3r.mail@gmail.com> Date: Mon, 18 Jun 2018 16:02:37 +0300 Subject: [PATCH 166/206] Fix for #8222 --- lib/web/mage/collapsible.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/web/mage/collapsible.js b/lib/web/mage/collapsible.js index 267734605f141..656afc8f89e25 100644 --- a/lib/web/mage/collapsible.js +++ b/lib/web/mage/collapsible.js @@ -110,7 +110,7 @@ define([ _processState: function () { var anchor = window.location.hash, isValid = $.mage.isValidSelector(anchor), - urlPath = window.location.pathname.replace('.', ''), + urlPath = window.location.pathname.replace(/\./g, ''), state; this.stateKey = encodeURIComponent(urlPath + this.element.attr('id')); From a8948ecc61f9bbbfd19c84fb1c06767ca12ad9fa Mon Sep 17 00:00:00 2001 From: NazarKlovanych <nazar.klovanich@transoftgroup.com> Date: Mon, 18 Jun 2018 17:11:50 +0300 Subject: [PATCH 167/206] Change Wrong input --- .../Customer/view/frontend/templates/form/register.phtml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/code/Magento/Customer/view/frontend/templates/form/register.phtml b/app/code/Magento/Customer/view/frontend/templates/form/register.phtml index 0f7648265ef8b..8e06b970ef5a7 100644 --- a/app/code/Magento/Customer/view/frontend/templates/form/register.phtml +++ b/app/code/Magento/Customer/view/frontend/templates/form/register.phtml @@ -131,7 +131,7 @@ <div class="field required"> <label for="email_address" class="label"><span><?= $block->escapeHtml(__('Email')) ?></span></label> <div class="control"> - <input type="email" name="email" autocomplete="email" id="email_address" value="<?= $block->escapeHtmlAttr($block->getFormData()->getEmail()) ?>" title="<?= $block->escapeHtmlAttr(__('Email')) ?>" class="input-text" data-validate="{required:true, 'validate-email':true}"> + <input type="email" name="email" autocomplete="email" id="email_address" value="<?= $block->escapeHtmlAttr($block->getFormData()->getEmail()) ?>" title="<?= $block->escapeHtmlAttr(__('Email')) ?>" data-mage-init='{"mage/trim-input":{}}' class="input-text" data-validate="{required:true, 'validate-email':true}"> </div> </div> <div class="field password required"> @@ -142,7 +142,6 @@ class="input-text" data-password-min-length="<?= $block->escapeHtmlAttr($block->getMinimumPasswordLength()) ?>" data-password-min-character-sets="<?= $block->escapeHtmlAttr($block->getRequiredCharacterClassesNumber()) ?>" - data-mage-init='{"mage/trim-input":{}}' data-validate="{required:true, 'validate-customer-password':true}" autocomplete="off"> <div id="password-strength-meter-container" data-role="password-strength-meter" aria-live="polite"> From 0e9ed86353874d6fa8c9c5bbec2612bfeba5583c Mon Sep 17 00:00:00 2001 From: Leandro Ferraz Luvisotto <l.luvisotto@youwe.nl> Date: Mon, 18 Jun 2018 16:36:54 +0200 Subject: [PATCH 168/206] PHPDoc --- .../System/Message/CacheOutdatedTest.php | 6 +++ .../Media/Synchronization/ErrorTest.php | 3 ++ .../Model/System/Message/SecurityTest.php | 3 ++ .../Validator/TierPriceTest.php | 6 +++ .../AdvancedPricing/Validator/WebsiteTest.php | 3 ++ .../Import/AdvancedPricing/ValidatorTest.php | 3 ++ .../Unit/Model/Import/AdvancedPricingTest.php | 9 +++++ .../Test/Unit/Model/Acl/AclRetrieverTest.php | 3 ++ .../Unit/Model/Directpost/ResponseTest.php | 11 ++++++ .../App/Action/Plugin/AuthenticationTest.php | 3 ++ .../App/Action/Plugin/MassactionKeyTest.php | 3 ++ .../Test/Unit/App/Action/Stub/ActionStub.php | 3 ++ .../Unit/App/Area/FrontNameResolverTest.php | 3 ++ .../Backend/Test/Unit/App/ConfigTest.php | 3 ++ .../Test/Unit/Block/AnchorRendererTest.php | 3 ++ .../Test/Unit/Block/Cache/AdditionalTest.php | 3 ++ .../Test/Unit/Block/GlobalSearchTest.php | 3 ++ .../Test/Unit/Block/MenuItemCheckerTest.php | 3 ++ .../Test/Unit/Block/Widget/ButtonTest.php | 3 ++ .../Column/Renderer/Radio/ExtendedTest.php | 3 ++ .../Widget/Grid/Column/Renderer/RadioTest.php | 3 ++ .../Unit/Block/Widget/Grid/ColumnTest.php | 6 +++ .../Widget/Grid/Massaction/ExtendedTest.php | 3 ++ .../Unit/Block/Widget/Grid/MassactionTest.php | 3 ++ .../Test/Unit/Block/Widget/TabTest.php | 3 ++ .../Backend/Test/Unit/Helper/DataTest.php | 3 ++ .../Test/Unit/Model/Auth/SessionTest.php | 9 +++++ .../SessionLifetime/BackendModelTest.php | 3 ++ .../Test/Unit/Model/Menu/ConfigTest.php | 3 ++ .../Unit/Model/Menu/Item/ValidatorTest.php | 6 +++ .../Test/Unit/Model/MenuBuilderTest.php | 3 ++ .../Unit/Model/Session/AdminConfigTest.php | 3 ++ .../Unit/Model/Widget/Grid/ParserTest.php | 3 ++ .../Sales/Order/Items/RendererTest.php | 21 ++++++++++ .../Sales/Order/View/Items/RendererTest.php | 18 +++++++++ .../Catalog/Product/View/Type/BundleTest.php | 10 +++++ .../Block/Sales/Order/Items/RendererTest.php | 21 ++++++++++ .../Order/Pdf/Items/AbstractItemsTest.php | 24 ++++++++++++ .../Pricing/Adjustment/CalculatorTest.php | 3 ++ .../Unit/Pricing/Price/BundleOptionsTest.php | 3 ++ .../Price/BundleSelectionPriceTest.php | 6 +++ .../Product/BundleDataProviderTest.php | 3 ++ .../Test/Unit/Model/PurgeCacheTest.php | 3 ++ .../Captcha/Test/Unit/Model/DefaultTest.php | 3 ++ .../Adminhtml/Product/Edit/Tab/AlertsTest.php | 3 ++ .../Product/Helper/Form/CategoryTest.php | 3 ++ .../Test/Unit/Block/Category/Rss/LinkTest.php | 6 +++ .../Block/Product/ProductList/RelatedTest.php | 3 ++ .../Block/Product/ProductList/ToolbarTest.php | 3 ++ .../Unit/Block/Product/View/GalleryTest.php | 3 ++ .../Block/Rss/Product/NewProductsTest.php | 6 +++ .../Unit/Block/Rss/Product/SpecialTest.php | 3 ++ .../Adminhtml/Category/Image/UploadTest.php | 3 ++ .../Product/Attribute/ValidateTest.php | 3 ++ .../Unit/Model/Attribute/Config/XsdTest.php | 3 ++ .../Category/Attribute/Backend/ImageTest.php | 3 ++ .../Category/Attribute/Backend/SortbyTest.php | 15 ++++++++ .../Unit/Model/CategoryRepositoryTest.php | 3 ++ .../Catalog/Test/Unit/Model/CategoryTest.php | 9 +++++ .../Flat/Plugin/IndexerConfigDataTest.php | 3 ++ .../Model/Indexer/Category/Flat/StateTest.php | 3 ++ .../Category/Flat/System/Config/ModeTest.php | 9 +++++ .../Product/Plugin/StoreGroupTest.php | 3 ++ .../Product/Eav/AbstractActionTest.php | 3 ++ .../Indexer/Product/Flat/ProcessorTest.php | 6 +++ .../Product/Flat/System/Config/ModeTest.php | 9 +++++ .../Filter/DataProvider/CategoryTest.php | 3 ++ .../Layer/Filter/DataProvider/PriceTest.php | 3 ++ .../Test/Unit/Model/Product/ActionTest.php | 3 ++ .../Model/Product/CartConfigurationTest.php | 3 ++ .../Model/Product/Gallery/ProcessorTest.php | 3 ++ .../Model/Product/LinkTypeProviderTest.php | 3 ++ .../Product/Option/Validator/SelectTest.php | 6 +++ .../Model/Product/ProductList/ToolbarTest.php | 6 +++ .../Product/ReservedAttributeListTest.php | 3 ++ .../Model/Product/TierPriceManagementTest.php | 6 +++ .../Model/Product/Type/AbstractTypeTest.php | 3 ++ .../Test/Unit/Model/Product/UrlTest.php | 3 ++ .../Test/Unit/Model/ProductRepositoryTest.php | 6 +++ .../Catalog/Test/Unit/Model/ProductTest.php | 6 +++ .../Unit/Model/ProductTypes/ConfigTest.php | 3 ++ .../Test/Unit/Model/View/Asset/ImageTest.php | 3 ++ .../Unit/Model/View/Asset/PlaceholderTest.php | 3 ++ .../Test/Unit/Pricing/Price/BasePriceTest.php | 3 ++ .../Pricing/Price/CustomOptionPriceTest.php | 10 +++++ .../Price/MinimalTierPriceCalculatorTest.php | 3 ++ .../Test/Unit/Pricing/Price/TierPriceTest.php | 3 ++ .../Unit/Pricing/Render/FinalPriceBoxTest.php | 3 ++ .../Test/Unit/Pricing/Render/PriceBoxTest.php | 3 ++ .../CatalogEavValidationRulesTest.php | 3 ++ .../Import/Product/CategoryProcessorTest.php | 3 ++ .../Import/Product/Type/AbstractTypeTest.php | 3 ++ .../Product/Validator/TierPriceTest.php | 5 +++ .../Test/Unit/Model/Import/ProductTest.php | 15 ++++++++ .../Test/Unit/Model/Import/UploaderTest.php | 6 +++ .../Test/Unit/Helper/StockTest.php | 3 ++ .../Unit/Model/Plugin/ProductLinksTest.php | 3 ++ .../Initializer/QuantityValidatorTest.php | 7 ++++ .../Unit/Model/Spi/StockStateProviderTest.php | 32 ++++++++++++++++ .../Test/Unit/Model/Stock/ItemTest.php | 3 ++ .../Test/Unit/Model/StockTest.php | 5 ++- .../Form/Element/UseConfigSettingsTest.php | 3 ++ .../Unit/Model/Product/PriceModifierTest.php | 3 ++ .../MappableConditionProcessorTest.php | 11 ++++++ .../Adapter/Mysql/Filter/PreprocessorTest.php | 3 ++ .../Test/Unit/Model/AdvancedTest.php | 11 ++++++ .../Model/Autocomplete/DataProviderTest.php | 3 ++ .../ResourceModel/Fulltext/CollectionTest.php | 9 +++++ .../BaseSelectStrategy/StrategyMapperTest.php | 3 ++ .../Search/CustomAttributeFilterCheckTest.php | 3 ++ .../Search/Indexer/IndexStructureTest.php | 13 +++++++ .../QueryChecker/FullTextSearchCheckTest.php | 15 ++++++++ .../Model/Search/RequestGeneratorTest.php | 5 +++ .../SelectContainerBuilderTest.php | 6 +++ .../Unit/Model/Search/TableMapperTest.php | 15 ++++++++ .../Form/Modifier/ProductUrlRewriteTest.php | 3 ++ .../Unit/Block/Product/ProductsListTest.php | 3 ++ .../Test/Unit/Block/Cart/AbstractCartTest.php | 3 ++ .../Test/Unit/Block/Cart/LinkTest.php | 3 ++ .../Checkout/Test/Unit/Block/LinkTest.php | 3 ++ .../Test/Unit/Block/Onepage/SuccessTest.php | 3 ++ .../Test/Unit/Controller/Stub/OnepageStub.php | 3 ++ .../Checkout/Test/Unit/Model/CartTest.php | 3 ++ .../Model/Session/SuccessValidatorTest.php | 5 +++ .../Checkout/Test/Unit/Model/SidebarTest.php | 3 ++ .../Test/Unit/Model/Type/OnepageTest.php | 6 +++ .../Adminhtml/Block/Widget/ChooserTest.php | 3 ++ .../Adminhtml/Page/Widget/ChooserTest.php | 3 ++ .../Magento/Cms/Test/Unit/Helper/PageTest.php | 6 +++ .../Test/Unit/Helper/Wysiwyg/ImagesTest.php | 9 +++++ .../ResourceModel/Block/CollectionTest.php | 3 ++ .../ResourceModel/Page/CollectionTest.php | 3 ++ .../Test/Unit/Model/Wysiwyg/ConfigTest.php | 3 ++ .../Unit/Observer/NoCookiesObserverTest.php | 3 ++ .../Unit/Block/System/Config/DwstreeTest.php | 3 ++ .../Form/Field/Select/AllowspecificTest.php | 3 ++ .../Fieldset/Modules/DisableOutputTest.php | 3 ++ .../Unit/Block/System/Config/FormTest.php | 6 +++ .../Config/Backend/Email/AddressTest.php | 3 ++ .../Model/Config/Backend/Email/SenderTest.php | 3 ++ .../Model/Config/Backend/SerializedTest.php | 6 +++ .../Config/Structure/AbstractElementTest.php | 6 +++ .../Element/Dependency/FieldTest.php | 9 +++++ .../Element/Dependency/MapperTest.php | 3 ++ .../Config/Structure/Element/IteratorTest.php | 3 ++ .../Config/Structure/Mapper/ExtendsTest.php | 15 ++++++++ .../Helper/RelativePathConverterTest.php | 6 +++ .../Test/Unit/Model/Config/StructureTest.php | 6 +++ .../Model/Placeholder/EnvironmentTest.php | 3 ++ .../Import/Product/Type/ConfigurableTest.php | 3 ++ .../Product/Steps/SelectAttributesTest.php | 3 ++ .../Model/Attribute/LockValidatorTest.php | 5 +++ .../Test/Unit/Model/OptionRepositoryTest.php | 3 ++ .../HideUnsupportedAttributeTypesTest.php | 21 ++++++++++ .../Test/Unit/Controller/Index/PostTest.php | 3 ++ .../Test/Unit/Controller/Stub/IndexStub.php | 3 ++ .../Cookie/Test/Unit/Helper/CookieTest.php | 3 ++ .../Unit/Model/System/CurrencysymbolTest.php | 3 ++ .../Block/Account/AuthenticationPopupTest.php | 3 ++ .../Test/Unit/Block/Account/CustomerTest.php | 3 ++ .../Unit/Block/Account/Dashboard/InfoTest.php | 3 ++ .../Edit/Tab/View/Grid/Renderer/ItemTest.php | 7 ++++ .../Test/Unit/Block/Widget/NameTest.php | 3 ++ .../Controller/Account/CreatePostTest.php | 3 ++ .../Unit/Controller/Address/FormPostTest.php | 3 ++ .../Adminhtml/Index/InlineEditTest.php | 3 ++ .../Test/Unit/Controller/Section/LoadTest.php | 3 ++ .../Plugin/SessionCheckerTest.php | 3 ++ .../Customer/Test/Unit/Helper/AddressTest.php | 15 ++++++++ .../Unit/Model/Address/Config/XsdTest.php | 3 ++ .../Test/Unit/Model/AttributeCheckerTest.php | 3 ++ .../Test/Unit/Model/AuthenticationTest.php | 3 ++ .../Attribute/Backend/PasswordTest.php | 3 ++ .../Unit/Model/Customer/DataProviderTest.php | 3 ++ .../Test/Unit/Model/FileProcessorTest.php | 6 +++ .../Model/Metadata/Form/AbstractDataTest.php | 15 ++++++++ .../Unit/Model/Metadata/Form/BooleanTest.php | 3 ++ .../Unit/Model/Metadata/Form/DateTest.php | 6 +++ .../Unit/Model/Metadata/Form/FileTest.php | 15 ++++++++ .../Model/Metadata/Form/MultilineTest.php | 6 +++ .../Unit/Model/Metadata/Form/SelectTest.php | 9 +++++ .../Unit/Model/Metadata/Form/TextTest.php | 9 +++++ .../Unit/Model/Metadata/ValidatorTest.php | 3 ++ .../Test/Unit/Model/Renderer/RegionTest.php | 3 ++ .../Unit/Model/ResourceModel/AddressTest.php | 14 +++++++ .../Group/Grid/ServiceCollectionTest.php | 3 ++ .../Observer/AfterAddressSaveObserverTest.php | 6 +++ .../Command/App/ConfigStatusCommandTest.php | 3 ++ .../Unit/Service/DeployStaticContentTest.php | 3 ++ .../Developer/Test/Unit/Helper/DataTest.php | 3 ++ .../Decorator/DebugHintsTest.php | 3 ++ .../Unit/Model/Currency/Import/ConfigTest.php | 9 +++++ .../Test/Unit/Model/PriceCurrencyTest.php | 15 ++++++++ .../Unit/Block/Catalog/Product/LinksTest.php | 6 +++ .../Helper/Plugin/DownloadableTest.php | 3 ++ .../Test/Unit/Helper/DownloadTest.php | 13 +++++++ .../Test/Unit/Model/LinkRepositoryTest.php | 4 ++ .../Observer/SetLinkStatusObserverTest.php | 3 ++ .../Test/Unit/_files/download_mock.php | 6 +++ .../Test/Unit/Model/AttributeFactoryTest.php | 6 +++ .../Unit/Model/CustomAttributesMapperTest.php | 3 ++ .../Unit/Model/Entity/AbstractEntityTest.php | 6 +++ .../Attribute/Backend/ArrayBackendTest.php | 3 ++ .../Entity/Attribute/Source/TableTest.php | 6 +++ .../Test/Unit/Model/Entity/AttributeTest.php | 6 +++ .../Collection/AbstractCollectionTest.php | 6 +++ .../VersionControl/AbstractCollectionTest.php | 3 ++ .../Model/Entity/Increment/AlphanumTest.php | 3 ++ .../Model/Entity/Increment/NumericTest.php | 3 ++ .../Attribute/CollectionTest.php | 3 ++ .../ResourceModel/AttributeLoaderTest.php | 3 ++ .../Model/ResourceModel/ReadHandlerTest.php | 3 ++ .../Test/Unit/Model/AbstractTemplateTest.php | 3 ++ .../Unit/Model/Template/Config/XsdTest.php | 3 ++ .../Test/Unit/Model/Template/ConfigTest.php | 9 +++++ .../Email/Test/Unit/Model/TemplateTest.php | 15 ++++++++ .../Renderer/Actions/ItemIdProcessorTest.php | 3 ++ .../Test/Unit/Helper/DataTest.php | 3 ++ .../Unit/Model/Filter/UppercaseTitleTest.php | 3 ++ .../SetConversionValueObserverTest.php | 6 +++ .../Import/Product/Type/Grouped/LinksTest.php | 12 ++++++ .../Block/Product/View/Type/GroupedTest.php | 3 ++ .../ProductLinks/Plugin/GroupedTest.php | 6 +++ .../Unit/Pricing/Price/FinalPriceTest.php | 5 +++ .../GroupedProductDataProviderTest.php | 3 ++ .../Test/Unit/Model/Export/ConfigTest.php | 9 +++++ .../Test/Unit/Model/Import/ConfigTest.php | 6 +++ .../Test/Unit/Model/Import/Source/ZipTest.php | 3 ++ .../Indexer/Test/Unit/App/IndexerTest.php | 3 ++ .../Grid/Column/Renderer/ScheduledTest.php | 3 ++ .../Grid/Column/Renderer/StatusTest.php | 3 ++ .../Grid/Column/Renderer/UpdatedTest.php | 3 ++ .../Indexer/Test/Unit/Model/IndexerTest.php | 3 ++ .../ResourceModel/AbstractResourceTest.php | 3 ++ .../DataProvider/Indexer/DataCollection.php | 7 ++++ .../Controller/Button/PlaceOrder.php | 12 ++++++ .../DeferredShippingMethodChooserPool.php | 10 +++++ .../Integration/Edit/Tab/WebapiTest.php | 6 +++ .../Widget/Grid/Column/Renderer/NameTest.php | 3 ++ .../Integration/Test/Unit/Helper/DataTest.php | 3 ++ .../Test/Unit/Helper/Oauth/ConsumerTest.php | 5 +++ .../Integration/Test/Unit/Oauth/OauthTest.php | 38 +++++++++++++++++++ .../Test/Unit/Block/NavigationTest.php | 3 ++ .../MediaStorage/Test/Unit/App/MediaTest.php | 3 ++ .../Test/Unit/Helper/File/MediaTest.php | 3 ++ .../Unit/Helper/File/Storage/DatabaseTest.php | 18 +++++++++ .../Test/Unit/Helper/File/StorageTest.php | 6 +++ .../Block/Checkout/Address/SelectTest.php | 3 ++ .../Checkout/Address/NewShippingTest.php | 3 ++ .../NewRelicReporting/Plugin/StatePlugin.php | 9 +++++ .../Test/Unit/Model/Apm/DeploymentsTest.php | 3 ++ .../Test/Unit/Model/Module/CollectTest.php | 3 ++ .../ReportProductSavedToNewRelicTest.php | 3 ++ .../Test/Unit/Model/SubscriberTest.php | 3 ++ .../Test/Unit/Model/TemplateTest.php | 3 ++ .../Unit/Model/CheckmoConfigProviderTest.php | 3 ++ .../Model/InstructionsConfigProviderTest.php | 3 ++ .../Checkout/Block/Cart/ShippingTest.php | 3 ++ .../Carrier/Tablerate/CSV/RowParserTest.php | 3 ++ .../Unit/Model/SalesRule/CalculatorTest.php | 3 ++ .../Test/Unit/Block/JavascriptTest.php | 6 +++ .../Test/Unit/Controller/Block/EsiTest.php | 3 ++ .../App/FrontController/BuiltinPluginTest.php | 3 ++ .../Unit/Model/App/PageCachePluginTest.php | 3 ++ .../Model/App/Response/HttpPluginTest.php | 3 ++ .../Test/Unit/Model/Cache/ServerTest.php | 3 ++ .../Unit/Model/Layout/LayoutPluginTest.php | 6 +++ .../Unit/Observer/FlushCacheByTagsTest.php | 3 ++ .../Payment/Test/Unit/Block/InfoTest.php | 3 ++ .../Gateway/Data/Order/AddressAdapterTest.php | 6 +++ .../Gateway/Data/Quote/AddressAdapterTest.php | 6 +++ .../Validator/CountryValidatorTest.php | 6 +++ .../Unit/Gateway/Validator/ResultTest.php | 3 ++ .../Payment/Test/Unit/Helper/DataTest.php | 3 ++ .../Model/Cart/SalesModel/FactoryTest.php | 3 ++ .../Unit/Model/Cart/SalesModel/OrderTest.php | 3 ++ .../Unit/Model/Cart/SalesModel/QuoteTest.php | 6 +++ .../Payment/Test/Unit/Model/ConfigTest.php | 3 ++ .../System/Config/Field/CountryTest.php | 3 ++ .../System/Config/Fieldset/GroupTest.php | 3 ++ .../System/Config/Fieldset/PaymentTest.php | 3 ++ .../Test/Unit/Block/Express/ReviewTest.php | 3 ++ .../Controller/Express/PlaceOrderTest.php | 6 +++ .../Controller/Express/ReturnActionTest.php | 3 ++ .../Unit/Controller/Express/StartTest.php | 3 ++ .../Paypal/Test/Unit/Helper/BackendTest.php | 6 +++ .../Test/Unit/Model/AbstractConfigTest.php | 3 ++ .../Paypal/Test/Unit/Model/Api/NvpTest.php | 3 ++ .../Paypal/Test/Unit/Model/CartTest.php | 9 +++++ .../Structure/PaymentSectionModifierTest.php | 3 ++ .../Test/Unit/Model/Hostedpro/RequestTest.php | 3 ++ .../Paypal/Test/Unit/Model/PayflowproTest.php | 3 ++ ...dBillingAgreementToSessionObserverTest.php | 3 ++ ...AdminBillingAgreementUsageObserverTest.php | 3 ++ .../Unit/Observer/RefreshCustomerDataTest.php | 3 ++ .../Test/Unit/Block/Email/StockTest.php | 3 ++ .../Unit/Block/Product/View/StockTest.php | 3 ++ .../Model/Cart/CartTotalManagementTest.php | 3 ++ .../Model/Cart/CartTotalRepositoryTest.php | 3 ++ .../Product/Plugin/UpdateQuoteItemsTest.php | 3 ++ .../Quote/Address/Total/SubtotalTest.php | 3 ++ .../Unit/Model/Quote/Address/TotalTest.php | 12 ++++++ .../Model/Quote/Item/RelatedProductsTest.php | 3 ++ .../Unit/Model/Quote/Item/UpdaterTest.php | 6 +++ .../Quote/Test/Unit/Model/Quote/ItemTest.php | 6 +++ .../Quote/Test/Unit/Model/QuoteTest.php | 12 ++++++ .../Backend/CustomerQuoteObserverTest.php | 3 ++ .../Notification/MarkUserNotified.php | 3 ++ .../Condition/CanViewNotificationTest.php | 3 ++ .../Review/Test/Unit/Block/FormTest.php | 3 ++ .../Test/Unit/Block/Product/ReviewTest.php | 3 ++ .../ResourceModel/Review/CollectionTest.php | 3 ++ .../Model/Condition/AbstractConditionTest.php | 6 +++ .../Collection/AbstractCollectionTest.php | 3 ++ .../Adminhtml/Order/Create/Items/GridTest.php | 3 ++ .../Create/Sidebar/AbstractSidebarTest.php | 3 ++ .../Adminhtml/Order/Invoice/ViewTest.php | 3 ++ .../Test/Unit/Block/Order/TotalsTest.php | 4 ++ .../Order/Create/ProcessDataTest.php | 3 ++ .../Download/DownloadCustomOptionTest.php | 3 ++ .../Test/Unit/Cron/CleanExpiredQuotesTest.php | 3 ++ .../CustomerData/LastOrderedItemsTest.php | 3 ++ .../Sales/Test/Unit/Helper/AdminTest.php | 6 +++ .../Test/Unit/Model/InvoiceOrderTest.php | 3 ++ .../Test/Unit/Model/Order/AddressTest.php | 3 ++ .../CreateQuantityValidatorTest.php | 3 ++ .../Order/Creditmemo/RefundOperationTest.php | 6 +++ .../Order/Email/Sender/AbstractSenderTest.php | 11 ++++++ .../Order/InvoiceQuantityValidatorTest.php | 13 +++++++ .../Test/Unit/Model/Order/InvoiceTest.php | 6 +++ .../Sales/Test/Unit/Model/Order/ItemTest.php | 3 ++ .../Model/Order/Payment/RepositoryTest.php | 5 +++ .../Order/Payment/Transaction/BuilderTest.php | 3 ++ .../Order/Payment/Transaction/ManagerTest.php | 6 +++ .../Test/Unit/Model/Order/PaymentTest.php | 25 ++++++++++++ .../Unit/Model/Order/StatusResolverTest.php | 3 ++ .../Sales/Test/Unit/Model/OrderTest.php | 12 ++++++ .../Test/Unit/Model/RefundInvoiceTest.php | 3 ++ .../Sales/Test/Unit/Model/RefundOrderTest.php | 3 ++ .../AddVatRequestParamsOrderCommentTest.php | 3 ++ .../Frontend/RestoreCustomerGroupIdTest.php | 3 ++ .../Unit/Model/Order/ReturnValidatorTest.php | 3 ++ .../InvoiceRefundCreationArgumentsTest.php | 3 ++ .../RefundOrderInventoryObserverTest.php | 5 +++ .../Plugin/CouponUsagesDecrement.php | 5 +++ .../Plugin/CouponUsagesIncrement.php | 5 +++ .../Test/Unit/Block/Rss/DiscountsTest.php | 3 ++ .../Unit/Model/Converter/ToDataModelTest.php | 3 ++ .../Test/Unit/Model/Converter/ToModelTest.php | 3 ++ .../Test/Unit/Model/CouponRepositoryTest.php | 3 ++ .../Test/Unit/Model/Quote/DiscountTest.php | 3 ++ .../SalesRule/Test/Unit/Model/RuleTest.php | 6 +++ .../Test/Unit/Model/RulesApplierTest.php | 7 ++++ .../SalesRule/Test/Unit/Model/UtilityTest.php | 3 ++ .../Test/Unit/Model/ValidatorTest.php | 3 ++ .../Search/Test/Unit/Helper/DataTest.php | 3 ++ .../CollectionFactoryTest.php | 3 ++ .../Block/Plugin/Catalog/Product/ViewTest.php | 3 ++ .../Adminhtml/Order/Shipment/ViewTest.php | 8 ++++ .../Guarantee/CreateGuaranteeAbilityTest.php | 3 ++ .../Model/Guarantee/CreationServiceTest.php | 12 ++++++ .../Client/ResponseHandlerTest.php | 3 ++ .../Model/SignifydGateway/GatewayTest.php | 3 ++ .../Config/Importer/Processor/UpdateTest.php | 3 ++ .../Model/Service/StoreConfigManagerTest.php | 8 ++++ .../Test/Unit/Model/StoreManagerTest.php | 3 ++ .../Store/Test/Unit/Model/StoreTest.php | 9 +++++ .../Test/Unit/Model/System/StoreTest.php | 6 +++ .../Store/Test/Unit/Setup/UpgradeDataTest.php | 3 ++ .../Edit/Options/AbstractSwatchTest.php | 3 ++ .../Product/Attribute/Edit/FormTest.php | 3 ++ .../Controller/Adminhtml/Iframe/ShowTest.php | 3 ++ .../Product/Attribute/Plugin/SaveTest.php | 3 ++ .../Swatches/Test/Unit/Helper/DataTest.php | 28 ++++++++++++++ .../Swatches/Test/Unit/Helper/MediaTest.php | 9 +++++ .../Unit/Model/Plugin/EavAttributeTest.php | 3 ++ .../Unit/Model/Plugin/ProductImageTest.php | 3 ++ .../Test/Unit/Model/Plugin/ProductTest.php | 3 ++ .../AddFieldsToAttributeObserverTest.php | 3 ++ .../AddSwatchAttributeTypeObserverTest.php | 3 ++ .../Test/Unit/Block/Checkout/ShippingTest.php | 3 ++ .../Unit/Block/Item/Price/RendererTest.php | 9 +++++ .../Model/Calculation/RateRepositoryTest.php | 3 ++ .../Test/Unit/Model/Plugin/OrderSaveTest.php | 12 ++++++ .../Quote/GrandTotalDetailsPluginTest.php | 15 ++++++++ .../Unit/Model/Quote/ToOrderConverterTest.php | 3 ++ .../Total/Quote/CommonTaxCollectorTest.php | 3 ++ .../Unit/Model/Sales/Total/Quote/TaxTest.php | 3 ++ .../ApplyDiscountOnPricesTest.php | 3 ++ .../System/Message/NotificationsTest.php | 3 ++ .../Test/Unit/Model/TaxAddressManagerTest.php | 6 +++ .../Test/Unit/Model/TaxClass/FactoryTest.php | 3 ++ .../Test/Unit/Model/TaxRuleRepositoryTest.php | 3 ++ .../Observer/AfterAddressSaveObserverTest.php | 3 ++ .../Tax/Test/Unit/Pricing/AdjustmentTest.php | 9 +++++ .../Test/Unit/Block/Html/TopmenuTest.php | 3 ++ .../Unit/Model/Design/Backend/ThemeTest.php | 6 +++ .../Test/Unit/Model/Theme/ValidationTest.php | 3 ++ .../Theme/Test/Unit/Model/ThemeTest.php | 6 +++ .../Test/Unit/Model/Wysiwyg/StorageTest.php | 6 +++ .../Listing/Column/EditActionTest.php | 3 ++ .../Form/Element/AbstractElementTest.php | 3 ++ .../Form/Element/ActionDeleteTest.php | 3 ++ .../Form/Element/CheckboxSetTest.php | 3 ++ .../Form/Element/MultiSelectTest.php | 3 ++ .../Component/Form/Element/RadioSetTest.php | 3 ++ .../Component/Form/Element/SelectTest.php | 3 ++ .../Component/Form/Element/WysiwygTest.php | 6 +++ .../Ui/Test/Unit/Component/MassActionTest.php | 3 ++ .../Unit/Config/Converter/ActionsTest.php | 3 ++ .../Unit/Config/Converter/OptionsTest.php | 3 ++ .../Ui/Test/Unit/Model/ManagerTest.php | 6 +++ .../Test/Unit/Helper/UrlRewriteTest.php | 6 +++ .../Variable/Test/Unit/Model/VariableTest.php | 6 +++ .../Observer/AfterPaymentSaveObserverTest.php | 3 ++ .../Unit/Controller/PathProcessorTest.php | 3 ++ .../Authorization/TokenUserContextTest.php | 3 ++ .../Unit/Model/Rest/Swagger/GeneratorTest.php | 6 +++ .../Unit/Block/Item/Price/RendererTest.php | 9 +++++ .../Unit/Model/Total/Invoice/WeeeTest.php | 3 ++ .../Unit/Observer/AfterAddressSaveTest.php | 3 ++ .../Weee/Test/Unit/Pricing/AdjustmentTest.php | 6 +++ .../Customer/Wishlist/Item/OptionsTest.php | 3 ++ .../Unit/Controller/Index/AllcartTest.php | 3 ++ .../Test/Unit/Controller/Index/IndexTest.php | 3 ++ .../Test/Unit/Controller/Index/PluginTest.php | 3 ++ .../Test/Unit/Controller/Index/RemoveTest.php | 3 ++ .../Wishlist/Test/Unit/Model/ItemTest.php | 3 ++ .../Model/LocaleQuantityProcessorTest.php | 3 ++ .../Acl/Test/Unit/Role/RegistryTest.php | 7 ++++ .../Generator/EntityChildTestAbstract.php | 12 ++++++ .../Api/Test/Unit/DataObjectHelperTest.php | 3 ++ .../Framework/Api/Test/Unit/SortOrderTest.php | 6 +++ .../App/Test/Unit/Action/Stub/ActionStub.php | 3 ++ .../Framework/App/Test/Unit/AreaTest.php | 3 ++ .../Framework/App/Test/Unit/BootstrapTest.php | 3 ++ .../App/Test/Unit/Cache/Frontend/PoolTest.php | 3 ++ .../App/Test/Unit/Cache/Type/ConfigTest.php | 3 ++ .../Test/Unit/Cache/Type/FrontendPoolTest.php | 3 ++ .../Framework/App/Test/Unit/CacheTest.php | 6 +++ .../Unit/Config/ConfigPathResolverTest.php | 3 ++ .../App/Test/Unit/Config/DataTest.php | 3 ++ .../App/Test/Unit/Config/InitialTest.php | 3 ++ .../App/Test/Unit/Config/ValueTest.php | 3 ++ .../Framework/App/Test/Unit/ConfigTest.php | 3 ++ .../Console/MaintenanceModeEnablerTest.php | 11 ++++++ .../App/Test/Unit/Console/ResponseTest.php | 3 ++ .../Framework/App/Test/Unit/CronTest.php | 3 ++ .../App/Test/Unit/DeploymentConfigTest.php | 3 ++ .../App/Test/Unit/DocRootLocatorTest.php | 3 ++ .../App/Test/Unit/ErrorHandlerTest.php | 6 +++ .../Test/Unit/PageCache/IdentifierTest.php | 3 ++ .../App/Test/Unit/PageCache/KernelTest.php | 3 ++ .../App/Test/Unit/ProductMetadataTest.php | 3 ++ .../App/Test/Unit/Request/HttpTest.php | 18 +++++++++ .../App/Test/Unit/Router/ActionListTest.php | 3 ++ .../App/Test/Unit/ScopeResolverPoolTest.php | 3 ++ .../Framework/App/Test/Unit/SetupInfoTest.php | 3 ++ .../Framework/App/Test/Unit/StateTest.php | 4 ++ .../Backend/Decorator/CompressionTest.php | 11 ++++++ .../Decorator/DecoratorAbstractTest.php | 6 +++ .../Cache/Test/Unit/Backend/MongoDbTest.php | 18 +++++++++ .../Framework/Cache/Test/Unit/CoreTest.php | 3 ++ .../Test/Unit/Frontend/Adapter/ZendTest.php | 3 ++ .../Unit/Frontend/Decorator/TagScopeTest.php | 3 ++ .../Unit/Generator/DefinedClassesTest.php | 5 +++ .../Unit/Generator/InterfaceGeneratorTest.php | 3 ++ .../Code/Test/Unit/Generator/IoTest.php | 6 +++ .../Code/Test/Unit/GeneratorTest.php | 3 ++ .../Code/Test/Unit/NameBuilderTest.php | 3 ++ .../Test/Unit/Reader/ArgumentsReaderTest.php | 3 ++ .../Unit/Validator/TypeDuplicationTest.php | 3 ++ .../_files/ClassesForArgumentSequence.php | 10 +++++ .../_files/ClassesForConstructorIntegrity.php | 9 +++++ .../Magento/SomeModule/Model/Five/Test.php | 5 +++ .../Magento/SomeModule/Model/Four/Test.php | 6 +++ .../Magento/SomeModule/Model/One/Test.php | 5 +++ .../SomeModule/Model/SevenInterface.php | 3 ++ .../Magento/SomeModule/Model/Six/Test.php | 6 +++ .../Magento/SomeModule/Model/Three/Test.php | 6 +++ .../Magento/SomeModule/Model/Two/Test.php | 6 +++ .../Test/Unit/ComposerInformationTest.php | 3 ++ .../Config/Test/Unit/Converter/DomTest.php | 3 ++ .../Config/Test/Unit/Data/ConfigDataTest.php | 3 ++ .../Config/Test/Unit/Data/ScopedTest.php | 3 ++ .../Test/Unit/Dom/NodePathMatcherTest.php | 3 ++ .../Test/Unit/GenericSchemaLocatorTest.php | 8 ++++ .../Test/Unit/Result/RedirectTest.php | 3 ++ .../Framework/Convert/Test/Unit/XmlTest.php | 3 ++ .../DB/Test/Unit/Adapter/Pdo/MysqlTest.php | 3 ++ .../DB/Test/Unit/Ddl/SequenceTest.php | 3 ++ .../DB/Test/Unit/ExpressionConverterTest.php | 3 ++ .../Test/Unit/Helper/Mysql/FulltextTest.php | 3 ++ .../Test/Unit/Select/ColumnsRendererTest.php | 3 ++ .../Argument/Interpreter/ArrayTypeTest.php | 6 +++ .../Argument/Interpreter/CompositeTest.php | 3 ++ .../Unit/Argument/Interpreter/NumberTest.php | 6 +++ .../Data/Test/Unit/Collection/DbTest.php | 9 +++++ .../Data/Test/Unit/Form/Element/DateTest.php | 8 ++++ .../Test/Unit/Form/FormKey/ValidatorTest.php | 3 ++ .../Encryption/Test/Unit/CryptTest.php | 26 +++++++++++++ .../Encryption/Test/Unit/EncryptorTest.php | 12 ++++++ .../Test/Unit/Helper/SecurityTest.php | 3 ++ .../Test/Unit/Observer/CollectionTest.php | 3 ++ .../Event/Test/Unit/Observer/CronTest.php | 9 +++++ .../Event/Test/Unit/Observer/RegexTest.php | 3 ++ .../Filesystem/Test/Unit/Driver/FileTest.php | 6 +++ .../Filesystem/Test/Unit/Driver/HttpTest.php | 6 +++ .../Test/Unit/File/ExcludeFilterTest.php | 3 ++ .../Test/Unit/Input/MaliciousCodeTest.php | 3 ++ .../Unit/Template/Tokenizer/ParameterTest.php | 6 +++ .../Unit/Template/Tokenizer/VariableTest.php | 3 ++ .../Filter/Test/Unit/TemplateTest.php | 3 ++ .../HTTP/Test/Unit/Adapter/CurlTest.php | 3 ++ .../Test/Unit/PhpEnvironment/RequestTest.php | 5 +++ .../Image/Test/Unit/Adapter/AbstractTest.php | 3 ++ .../Image/Test/Unit/Adapter/Gd2Test.php | 3 ++ .../Indexer/Test/Unit/IndexStructureTest.php | 19 ++++++++++ .../Unit/Code/Generator/_files/Sample.php | 3 ++ .../Unit/Code/Generator/_files/TSample.php | 6 +++ .../Test/Unit/Config/ConfigTest.php | 3 ++ .../Framework/Lock/Backend/Database.php | 7 ++++ .../Framework/Math/Test/Unit/RandomTest.php | 6 +++ .../Message/Test/Unit/ManagerTest.php | 9 +++++ .../Unit/ResourceModel/Db/AbstractDbTest.php | 9 +++++ .../Db/Collection/AbstractCollectionTest.php | 18 +++++++++ .../Unit/ResourceModel/Db/Collection/Uut.php | 15 ++++++++ .../Unit/Declaration/Converter/DomTest.php | 3 ++ .../Test/Unit/Dir/ReverseResolverTest.php | 3 ++ .../Module/Test/Unit/ManagerTest.php | 6 +++ .../Mview/Test/Unit/View/ChangelogTest.php | 4 ++ .../Framework/Mview/Test/Unit/ViewTest.php | 18 +++++++++ .../Unit/Code/Generator/RepositoryTest.php | 12 ++++++ .../_files/SampleRepositoryInterface.php | 20 ++++++++++ .../_files/TSampleRepositoryInterface.php | 15 ++++++++ .../Config/Reader/_files/ConfigDomMock.php | 3 ++ .../Test/Unit/Relations/RuntimeTest.php | 3 ++ .../Unit/_files/Aggregate/AggregateParent.php | 9 +++++ .../Test/Unit/_files/Aggregate/Child.php | 11 ++++++ .../Unit/_files/Aggregate/WithOptional.php | 6 +++ .../Test/Unit/Adjustment/CollectionTest.php | 6 +++ .../Pricing/Test/Unit/Adjustment/PoolTest.php | 3 ++ .../Pricing/Test/Unit/Helper/DataTest.php | 6 +++ .../Test/Unit/PriceInfo/FactoryTest.php | 3 ++ .../Pricing/Test/Unit/Render/AmountTest.php | 7 ++++ .../Pricing/Test/Unit/Render/PriceBoxTest.php | 6 +++ .../Test/Unit/DataObjectProcessorTest.php | 3 ++ .../Unit/ExtensionAttributesProcessorTest.php | 3 ++ .../Reflection/Test/Unit/TestDataObject.php | 20 ++++++++++ .../Test/Unit/TypeProcessorTest.php | 3 ++ .../Search/Test/Unit/Request/MapperTest.php | 9 +++++ .../Test/Unit/Serializer/Base64JsonTest.php | 6 +++ .../Test/Unit/Serializer/JsonTest.php | 9 +++++ .../Test/Unit/Serializer/SerializeTest.php | 9 +++++ .../Session/Test/Unit/ConfigTest.php | 6 +++ .../Unit/SaveHandler/Redis/LoggerTest.php | 3 ++ .../Shell/Test/Unit/CommandRendererTest.php | 3 ++ .../Simplexml/Test/Unit/ElementTest.php | 3 ++ .../Stdlib/Test/Unit/BooleanUtilsTest.php | 6 +++ .../Test/Unit/Cookie/PhpCookieManagerTest.php | 8 ++++ .../Cookie/SensitiveCookieMetadataTest.php | 9 +++++ .../Framework/Test/Unit/ArchiveTest.php | 12 ++++++ .../Unit/Data/Form/Element/HiddenTest.php | 3 ++ .../Framework/Test/Unit/DataObjectTest.php | 3 ++ .../Framework/Test/Unit/EscaperTest.php | 3 ++ .../Framework/Test/Unit/FlagManagerTest.php | 3 ++ .../Test/Unit/Message/PhraseFactoryTest.php | 3 ++ .../Module/Plugin/DbStatusValidatorTest.php | 3 ++ .../Magento/Framework/Test/Unit/ShellTest.php | 3 ++ .../Framework/Test/Unit/TranslateTest.php | 9 +++++ .../Magento/Framework/Test/Unit/UrlTest.php | 18 +++++++++ .../Translate/Test/Unit/InlineTest.php | 12 ++++++ .../Unserialize/Test/Unit/UnserializeTest.php | 3 ++ .../Url/Test/Unit/Helper/DataTest.php | 9 +++++ .../Url/Test/Unit/SecurityInfoTest.php | 3 ++ .../Validator/Test/Unit/ObjectTest.php | 3 ++ .../Unit/Asset/File/FallbackContextTest.php | 3 ++ .../View/Test/Unit/Asset/FileTest.php | 3 ++ .../View/Test/Unit/Asset/MergeServiceTest.php | 3 ++ .../Framework/View/Test/Unit/ContextTest.php | 3 ++ .../View/Test/Unit/DataSourcePoolTest.php | 5 +++ .../View/Test/Unit/Element/Html/LinkTest.php | 3 ++ .../View/Test/Unit/Element/Js/CookieTest.php | 3 ++ .../Unit/Element/Text/TextList/ItemTest.php | 3 ++ .../Unit/Element/Text/TextList/LinkTest.php | 3 ++ .../Decorator/ModuleDependencyTest.php | 3 ++ .../Argument/Interpreter/HelperMethodTest.php | 8 ++++ .../Argument/Interpreter/NamedParamsTest.php | 3 ++ .../Argument/Interpreter/OptionsTest.php | 3 ++ .../Test/Unit/Layout/BuilderFactoryTest.php | 3 ++ .../View/Test/Unit/Layout/ElementTest.php | 6 +++ .../Unit/Layout/Reader/UiComponentTest.php | 3 ++ .../Unit/Page/Config/Generator/HeadTest.php | 3 ++ .../View/Test/Unit/Page/ConfigTest.php | 21 ++++++++++ .../Webapi/Test/Unit/RequestTest.php | 3 ++ .../Test/Unit/ServiceInputProcessorTest.php | 3 ++ .../Command/GenerateFixturesCommand.php | 4 ++ .../Setup/Console/Style/MagentoStyle.php | 5 +++ .../Console/Command/DbStatusCommandTest.php | 3 ++ .../DeployStaticContentCommandTest.php | 3 ++ .../Console/Command/UninstallCommandTest.php | 3 ++ .../Test/Unit/Console/Style/TestOutput.php | 4 ++ .../Model/ConfigOptionsList/SessionTest.php | 6 +++ .../Test/Unit/Model/ConfigOptionsListTest.php | 3 ++ .../Model/Cron/JobComponentUninstallTest.php | 3 ++ .../Test/Unit/Model/Cron/JobFactoryTest.php | 9 +++++ .../Unit/Model/Cron/ReadinessCheckTest.php | 3 ++ .../Description/Mixin/BrakeMixinTest.php | 3 ++ .../Description/Mixin/HeaderMixinTest.php | 3 ++ .../Mixin/Helper/RandomWordSelectorTest.php | 3 ++ .../Mixin/Helper/WordWrapperTest.php | 3 ++ .../Description/Mixin/ParagraphMixinTest.php | 3 ++ .../Test/Unit/Model/Grid/TypeMapperTest.php | 3 ++ .../Unit/Model/ObjectManagerProviderTest.php | 3 ++ .../Test/Unit/Model/PayloadValidatorTest.php | 6 +++ .../Test/Unit/Model/PhpReadinessCheckTest.php | 5 +++ .../Setup/Test/Unit/Model/WebLoggerTest.php | 6 +++ .../Code/Reader/ClassReaderDecoratorTest.php | 3 ++ .../code/Magento/SomeModule/Helper/Test.php | 7 ++++ .../Module/I18n/Parser/AbstractParserTest.php | 3 ++ .../Test/Unit/Module/Setup/SetupCacheTest.php | 3 ++ .../Mvc/Bootstrap/InitParamListenerTest.php | 3 ++ 622 files changed, 3217 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/CacheOutdatedTest.php b/app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/CacheOutdatedTest.php index 2fbfc43aa8775..f49911c3e7a93 100644 --- a/app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/CacheOutdatedTest.php +++ b/app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/CacheOutdatedTest.php @@ -62,6 +62,9 @@ public function testGetIdentity($expectedSum, $cacheTypes) $this->assertEquals($expectedSum, $this->_messageModel->getIdentity()); } + /** + * @return array + */ public function getIdentityDataProvider() { $cacheTypeMock1 = $this->createPartialMock(\stdClass::class, ['getCacheType']); @@ -95,6 +98,9 @@ public function testIsDisplayed($expected, $allowed, $cacheTypes) $this->assertEquals($expected, $this->_messageModel->isDisplayed()); } + /** + * @return array + */ public function isDisplayedDataProvider() { $cacheTypesMock = $this->createPartialMock(\stdClass::class, ['getCacheType']); diff --git a/app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/Media/Synchronization/ErrorTest.php b/app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/Media/Synchronization/ErrorTest.php index 2c259db868851..b490efd8e9683 100644 --- a/app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/Media/Synchronization/ErrorTest.php +++ b/app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/Media/Synchronization/ErrorTest.php @@ -72,6 +72,9 @@ public function testIsDisplayed($expectedFirstRun, $data) $this->assertEquals($expectedFirstRun, $model->isDisplayed()); } + /** + * @return array + */ public function isDisplayedDataProvider() { return [ diff --git a/app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/SecurityTest.php b/app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/SecurityTest.php index 1e71570a5e30b..c6f61fee862ba 100644 --- a/app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/SecurityTest.php +++ b/app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/SecurityTest.php @@ -76,6 +76,9 @@ public function testIsDisplayed($expectedResult, $cached, $response) $this->assertEquals($expectedResult, $this->_messageModel->isDisplayed()); } + /** + * @return array + */ public function isDisplayedDataProvider() { return [ diff --git a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/TierPriceTest.php b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/TierPriceTest.php index bb64acb558320..7a81ccae6f0d0 100644 --- a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/TierPriceTest.php +++ b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/TierPriceTest.php @@ -181,6 +181,9 @@ public function testIsValidAddMessagesCall($value, $hasEmptyColumns, $customerGr $this->tierPrice->isValid($value); } + /** + * @return array + */ public function isValidResultFalseDataProvider() { return [ @@ -286,6 +289,9 @@ public function isValidResultFalseDataProvider() ]; } + /** + * @return array + */ public function isValidAddMessagesCallDataProvider() { return [ diff --git a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/WebsiteTest.php b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/WebsiteTest.php index 9a380ff75da24..b46e286e75007 100644 --- a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/WebsiteTest.php +++ b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/WebsiteTest.php @@ -114,6 +114,9 @@ public function testGetAllWebsitesValue() $this->assertEquals($expectedResult, $result); } + /** + * @return array + */ public function isValidReturnDataProvider() { return [ diff --git a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/ValidatorTest.php b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/ValidatorTest.php index d9fce98826105..5ca534284a48d 100644 --- a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/ValidatorTest.php +++ b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/ValidatorTest.php @@ -77,6 +77,9 @@ public function testInit() $this->validator->init(null); } + /** + * @return array + */ public function isValidDataProvider() { return [ diff --git a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricingTest.php b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricingTest.php index 6d130d93ee6a5..08743b9fa7f2c 100644 --- a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricingTest.php +++ b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricingTest.php @@ -768,6 +768,9 @@ public function testSaveProductPrices($priceData, $oldSkus, $priceIn, $callNum) $this->invokeMethod($this->advancedPricing, 'saveProductPrices', [$priceData, 'table']); } + /** + * @return array + */ public function saveProductPricesDataProvider() { return [ @@ -839,6 +842,9 @@ public function testDeleteProductTierPrices( ); } + /** + * @return array + */ public function deleteProductTierPricesDataProvider() { return [ @@ -921,6 +927,9 @@ public function testProcessCountExistingPrices( $this->invokeMethod($this->advancedPricing, 'processCountExistingPrices', [$prices, 'table']); } + /** + * @return array + */ public function processCountExistingPricesDataProvider() { return [ diff --git a/app/code/Magento/Authorization/Test/Unit/Model/Acl/AclRetrieverTest.php b/app/code/Magento/Authorization/Test/Unit/Model/Acl/AclRetrieverTest.php index bd1a3616a746e..58720ad9c9f5c 100644 --- a/app/code/Magento/Authorization/Test/Unit/Model/Acl/AclRetrieverTest.php +++ b/app/code/Magento/Authorization/Test/Unit/Model/Acl/AclRetrieverTest.php @@ -78,6 +78,9 @@ public function testGetAllowedResourcesByUser() ); } + /** + * @return AclRetriever + */ protected function createAclRetriever() { $this->roleMock = $this->createPartialMock(\Magento\Authorization\Model\Role::class, ['getId', '__wakeup']); diff --git a/app/code/Magento/Authorizenet/Test/Unit/Model/Directpost/ResponseTest.php b/app/code/Magento/Authorizenet/Test/Unit/Model/Directpost/ResponseTest.php index 6e5d55e52675e..b4274e87401ca 100644 --- a/app/code/Magento/Authorizenet/Test/Unit/Model/Directpost/ResponseTest.php +++ b/app/code/Magento/Authorizenet/Test/Unit/Model/Directpost/ResponseTest.php @@ -37,6 +37,9 @@ public function testGenerateHash($merchantMd5, $merchantApiLogin, $amount, $amou ); } + /** + * @return array + */ public function generateHashDataProvider() { return [ @@ -57,6 +60,14 @@ public function generateHashDataProvider() ]; } + /** + * @param $merchantMd5 + * @param $merchantApiLogin + * @param $amount + * @param $transactionId + * + * @return string + */ protected function generateHash($merchantMd5, $merchantApiLogin, $amount, $transactionId) { return strtoupper(md5($merchantMd5 . $merchantApiLogin . $transactionId . $amount)); diff --git a/app/code/Magento/Backend/Test/Unit/App/Action/Plugin/AuthenticationTest.php b/app/code/Magento/Backend/Test/Unit/App/Action/Plugin/AuthenticationTest.php index 7e4c426de9452..88b994a6b93b7 100644 --- a/app/code/Magento/Backend/Test/Unit/App/Action/Plugin/AuthenticationTest.php +++ b/app/code/Magento/Backend/Test/Unit/App/Action/Plugin/AuthenticationTest.php @@ -146,6 +146,9 @@ public function testProcessNotLoggedInUser($isIFrameParam, $isAjaxParam, $isForw $this->assertEquals($expectedResult, $this->plugin->aroundDispatch($subject, $proceed, $request)); } + /** + * @return array + */ public function processNotLoggedInUserDataProvider() { return [ diff --git a/app/code/Magento/Backend/Test/Unit/App/Action/Plugin/MassactionKeyTest.php b/app/code/Magento/Backend/Test/Unit/App/Action/Plugin/MassactionKeyTest.php index 2f808eaf2d1b8..d793a80cdeacf 100644 --- a/app/code/Magento/Backend/Test/Unit/App/Action/Plugin/MassactionKeyTest.php +++ b/app/code/Magento/Backend/Test/Unit/App/Action/Plugin/MassactionKeyTest.php @@ -74,6 +74,9 @@ public function testBeforeDispatchWhenMassactionPrepareKeyRequestExists($postDat $this->plugin->beforeDispatch($this->subjectMock, $this->requestMock); } + /** + * @return array + */ public function beforeDispatchDataProvider() { return [ diff --git a/app/code/Magento/Backend/Test/Unit/App/Action/Stub/ActionStub.php b/app/code/Magento/Backend/Test/Unit/App/Action/Stub/ActionStub.php index 4eff6218961af..2d60bef3f3e8c 100644 --- a/app/code/Magento/Backend/Test/Unit/App/Action/Stub/ActionStub.php +++ b/app/code/Magento/Backend/Test/Unit/App/Action/Stub/ActionStub.php @@ -8,6 +8,9 @@ class ActionStub extends \Magento\Backend\App\Action { + /** + * @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface|void + */ public function execute() { // Empty method stub for test diff --git a/app/code/Magento/Backend/Test/Unit/App/Area/FrontNameResolverTest.php b/app/code/Magento/Backend/Test/Unit/App/Area/FrontNameResolverTest.php index bc7dce6f20bac..642c6283decae 100644 --- a/app/code/Magento/Backend/Test/Unit/App/Area/FrontNameResolverTest.php +++ b/app/code/Magento/Backend/Test/Unit/App/Area/FrontNameResolverTest.php @@ -118,6 +118,9 @@ public function testIsHostBackend($url, $host, $useCustomAdminUrl, $customAdminU $this->assertEquals($this->model->isHostBackend(), $expectedValue); } + /** + * @return array + */ public function hostsDataProvider() { return [ diff --git a/app/code/Magento/Backend/Test/Unit/App/ConfigTest.php b/app/code/Magento/Backend/Test/Unit/App/ConfigTest.php index 114c57867badf..53640a81e722f 100644 --- a/app/code/Magento/Backend/Test/Unit/App/ConfigTest.php +++ b/app/code/Magento/Backend/Test/Unit/App/ConfigTest.php @@ -70,6 +70,9 @@ public function testIsSetFlag($configPath, $configValue, $expectedResult) $this->assertEquals($expectedResult, $this->model->isSetFlag($configPath)); } + /** + * @return array + */ public function isSetFlagDataProvider() { return [ diff --git a/app/code/Magento/Backend/Test/Unit/Block/AnchorRendererTest.php b/app/code/Magento/Backend/Test/Unit/Block/AnchorRendererTest.php index f52f4ab337712..eccb08e788a95 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/AnchorRendererTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/AnchorRendererTest.php @@ -141,6 +141,9 @@ public function testRenderAnchorLevelIsNotOne($hasTarget) ); } + /** + * @return array + */ public function targetDataProvider() { return [ diff --git a/app/code/Magento/Backend/Test/Unit/Block/Cache/AdditionalTest.php b/app/code/Magento/Backend/Test/Unit/Block/Cache/AdditionalTest.php index 160cfe609f85f..7a56536eaef44 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/Cache/AdditionalTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/Cache/AdditionalTest.php @@ -88,6 +88,9 @@ public function testIsInProductionMode($mode, $expected) $this->assertEquals($expected, $this->additonalBlock->isInProductionMode()); } + /** + * @return array + */ public function isInProductionModeDataProvider() { return [ diff --git a/app/code/Magento/Backend/Test/Unit/Block/GlobalSearchTest.php b/app/code/Magento/Backend/Test/Unit/Block/GlobalSearchTest.php index 0010ffad87524..f08a0098578b9 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/GlobalSearchTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/GlobalSearchTest.php @@ -103,6 +103,9 @@ public function testGetEntitiesToShow(array $results, int $expectedEntitiesQty) $this->assertSame($expectedEntitiesQty, count($this->globalSearch->getEntitiesToShow())); } + /** + * @return array + */ public function getEntitiesToShowDataProvider() { return [ diff --git a/app/code/Magento/Backend/Test/Unit/Block/MenuItemCheckerTest.php b/app/code/Magento/Backend/Test/Unit/Block/MenuItemCheckerTest.php index a79050faeb84a..aca719b2e65e9 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/MenuItemCheckerTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/MenuItemCheckerTest.php @@ -74,6 +74,9 @@ public function testIsItemActiveLevelNotZero() ); } + /** + * @return array + */ public function dataProvider() { return [ diff --git a/app/code/Magento/Backend/Test/Unit/Block/Widget/ButtonTest.php b/app/code/Magento/Backend/Test/Unit/Block/Widget/ButtonTest.php index bcf5d1adbc12b..e64d1a97af4ae 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/Widget/ButtonTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/Widget/ButtonTest.php @@ -61,6 +61,9 @@ public function testGetAttributesHtml($data, $expect) $this->assertRegExp($expect, $attributes); } + /** + * @return array + */ public function getAttributesHtmlDataProvider() { return [ diff --git a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Renderer/Radio/ExtendedTest.php b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Renderer/Radio/ExtendedTest.php index 35e21d7d194aa..81f104dbb636b 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Renderer/Radio/ExtendedTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Renderer/Radio/ExtendedTest.php @@ -54,6 +54,9 @@ public function testRender(array $rowData, $expectedResult) $this->assertEquals($expectedResult, $this->_object->render(new \Magento\Framework\DataObject($rowData))); } + /** + * @return array + */ public function renderDataProvider() { return [ diff --git a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Renderer/RadioTest.php b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Renderer/RadioTest.php index 67ead0ddd8f35..6f838634c6bed 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Renderer/RadioTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Renderer/RadioTest.php @@ -63,6 +63,9 @@ public function testRender(array $rowData, $expectedResult) $this->assertEquals($expectedResult, $this->_object->render(new \Magento\Framework\DataObject($rowData))); } + /** + * @return array + */ public function renderDataProvider() { return [ diff --git a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/ColumnTest.php b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/ColumnTest.php index c5c56fd75fbe7..2e6bed4783e7f 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/ColumnTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/ColumnTest.php @@ -86,6 +86,9 @@ public function testGetSortable($value) $this->assertFalse($this->_block->getSortable()); } + /** + * @return array + */ public function getSortableDataProvider() { return ['zero' => ['0'], 'false' => [false], 'null' => [null]]; @@ -374,6 +377,9 @@ public function testColumnIsGrouped($groupedData, $expected) $this->assertEquals($expected, $block->isGrouped()); } + /** + * @return array + */ public function columnGroupedDataProvider() { return [[[], false], [['grouped' => 0], false], [['grouped' => 1], true]]; diff --git a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Massaction/ExtendedTest.php b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Massaction/ExtendedTest.php index 4525de1fee542..f81928c4540ba 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Massaction/ExtendedTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Massaction/ExtendedTest.php @@ -152,6 +152,9 @@ public function testGetGridIdsJsonWithUseSelectAll(array $items, $result) $this->assertEquals($result, $this->_block->getGridIdsJson()); } + /** + * @return array + */ public function dataProviderGetGridIdsJsonWithUseSelectAll() { return [ diff --git a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/MassactionTest.php b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/MassactionTest.php index 29ce448a04ecb..e8143b5f6b43a 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/MassactionTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/MassactionTest.php @@ -243,6 +243,9 @@ public function testSelected($param, $expectedJson, $expected) $this->assertEquals($expected, $this->_block->getSelected()); } + /** + * @return array + */ public function selectedDataProvider() { return [ diff --git a/app/code/Magento/Backend/Test/Unit/Block/Widget/TabTest.php b/app/code/Magento/Backend/Test/Unit/Block/Widget/TabTest.php index 1670233324f8e..ad7c6fa99afd2 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/Widget/TabTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/Widget/TabTest.php @@ -34,6 +34,9 @@ public function testGetters($method, $field, $value, $expected) $this->assertEquals($expected, $object->{$method}()); } + /** + * @return array + */ public function dataProvider() { return [ diff --git a/app/code/Magento/Backend/Test/Unit/Helper/DataTest.php b/app/code/Magento/Backend/Test/Unit/Helper/DataTest.php index b7a33ab883b69..50c3a8571b48f 100644 --- a/app/code/Magento/Backend/Test/Unit/Helper/DataTest.php +++ b/app/code/Magento/Backend/Test/Unit/Helper/DataTest.php @@ -60,6 +60,9 @@ public function testPrepareFilterStringValues(array $inputString, array $expecte $this->assertEquals($expected, $actual); } + /** + * @return array + */ public function getPrepareFilterStringValuesDataProvider() { return [ diff --git a/app/code/Magento/Backend/Test/Unit/Model/Auth/SessionTest.php b/app/code/Magento/Backend/Test/Unit/Model/Auth/SessionTest.php index 391deac5a1f4e..f1a4bc355b08e 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/Auth/SessionTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Auth/SessionTest.php @@ -120,6 +120,9 @@ public function testRefreshAcl($isUserPassedViaParams) $this->assertSame($aclMock, $this->session->getAcl()); } + /** + * @return array + */ public function refreshAclDataProvider() { return [ @@ -234,6 +237,9 @@ public function testIsAllowed($isUserDefined, $isAclDefined, $isAllowed, $expect $this->assertEquals($expectedResult, $this->session->isAllowed('resource')); } + /** + * @return array + */ public function isAllowedDataProvider() { return [ @@ -254,6 +260,9 @@ public function testFirstPageAfterLogin($isFirstPageAfterLogin) $this->assertEquals($isFirstPageAfterLogin, $this->session->isFirstPageAfterLogin()); } + /** + * @return array + */ public function firstPageAfterLoginDataProvider() { return [ diff --git a/app/code/Magento/Backend/Test/Unit/Model/Config/SessionLifetime/BackendModelTest.php b/app/code/Magento/Backend/Test/Unit/Model/Config/SessionLifetime/BackendModelTest.php index 2f0102ffd410d..4695ef00d5d05 100755 --- a/app/code/Magento/Backend/Test/Unit/Model/Config/SessionLifetime/BackendModelTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Config/SessionLifetime/BackendModelTest.php @@ -28,6 +28,9 @@ public function testBeforeSave($value, $errorMessage = null) $this->assertEquals($model, $object); } + /** + * @return array + */ public function adminSessionLifetimeDataProvider() { return [ diff --git a/app/code/Magento/Backend/Test/Unit/Model/Menu/ConfigTest.php b/app/code/Magento/Backend/Test/Unit/Model/Menu/ConfigTest.php index bc18bd44f4be4..a6b728ceb392f 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/Menu/ConfigTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Menu/ConfigTest.php @@ -140,6 +140,9 @@ public function testGetMenuExceptionLogged($expectedException) $this->model->getMenu(); } + /** + * @return array + */ public function getMenuExceptionLoggedDataProvider() { return [ diff --git a/app/code/Magento/Backend/Test/Unit/Model/Menu/Item/ValidatorTest.php b/app/code/Magento/Backend/Test/Unit/Model/Menu/Item/ValidatorTest.php index 3c1f1e43900be..dec85f4b98e3d 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/Menu/Item/ValidatorTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Menu/Item/ValidatorTest.php @@ -79,6 +79,9 @@ public function testValidateWithMissingRequiredParamThrowsException($requiredPar } } + /** + * @return array + */ public function requiredParamsProvider() { return [['id'], ['title'], ['resource']]; @@ -102,6 +105,9 @@ public function testValidateWithNonValidPrimitivesThrowsException($param, $inval } } + /** + * @return array + */ public function invalidParamsProvider() { return [ diff --git a/app/code/Magento/Backend/Test/Unit/Model/MenuBuilderTest.php b/app/code/Magento/Backend/Test/Unit/Model/MenuBuilderTest.php index 23d1ed5da1425..5d026a2b1fc32 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/MenuBuilderTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/MenuBuilderTest.php @@ -35,6 +35,9 @@ public function testAfterGetResult($isPub, $times) ); } + /** + * @return array + */ public function afterGetResultDataProvider() { return [[true, 1], [false, 0],]; diff --git a/app/code/Magento/Backend/Test/Unit/Model/Session/AdminConfigTest.php b/app/code/Magento/Backend/Test/Unit/Model/Session/AdminConfigTest.php index 49fcdf4fc8770..00ae8c2f44a69 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/Session/AdminConfigTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Session/AdminConfigTest.php @@ -136,6 +136,9 @@ public function testSetSessionSettingsByConstructor($secureRequest) $this->assertSame($secureRequest, $adminConfig->getCookieSecure()); } + /** + * @return array + */ public function requestSecureDataProvider() { return [[true], [false]]; diff --git a/app/code/Magento/Backend/Test/Unit/Model/Widget/Grid/ParserTest.php b/app/code/Magento/Backend/Test/Unit/Model/Widget/Grid/ParserTest.php index 569c5ffc16c9c..98f1965477b2c 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/Widget/Grid/ParserTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Widget/Grid/ParserTest.php @@ -58,6 +58,9 @@ public function testIsOperation($operation, $expected) $this->assertEquals($expected, $this->_model->isOperation($operation)); } + /** + * @return array + */ public function isOperationDataProvider() { return [ diff --git a/app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Sales/Order/Items/RendererTest.php b/app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Sales/Order/Items/RendererTest.php index 414b460a1b81d..473fbbd035b00 100644 --- a/app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Sales/Order/Items/RendererTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Sales/Order/Items/RendererTest.php @@ -46,6 +46,9 @@ public function testGetChildrenEmptyItems($class, $method, $returnClass) $this->assertSame(null, $this->model->getChildren($item)); } + /** + * @return array + */ public function getChildrenEmptyItemsDataProvider() { return [ @@ -97,6 +100,9 @@ public function testGetChildren($parentItem) $this->assertSame([2 => $this->orderItem], $this->model->getChildren($item)); } + /** + * @return array + */ public function getChildrenDataProvider() { return [ @@ -116,6 +122,9 @@ public function testIsShipmentSeparatelyWithoutItem($productOptions, $result) $this->assertSame($result, $this->model->isShipmentSeparately()); } + /** + * @return array + */ public function isShipmentSeparatelyWithoutItemDataProvider() { return [ @@ -145,6 +154,9 @@ public function testIsShipmentSeparatelyWithItem($productOptions, $result, $pare $this->assertSame($result, $this->model->isShipmentSeparately($this->orderItem)); } + /** + * @return array + */ public function isShipmentSeparatelyWithItemDataProvider() { return [ @@ -166,6 +178,9 @@ public function testIsChildCalculatedWithoutItem($productOptions, $result) $this->assertSame($result, $this->model->isChildCalculated()); } + /** + * @return array + */ public function isChildCalculatedWithoutItemDataProvider() { return [ @@ -195,6 +210,9 @@ public function testIsChildCalculatedWithItem($productOptions, $result, $parentI $this->assertSame($result, $this->model->isChildCalculated($this->orderItem)); } + /** + * @return array + */ public function isChildCalculatedWithItemDataProvider() { return [ @@ -257,6 +275,9 @@ public function testCanShowPriceInfo($parentItem, $productOptions, $result) $this->assertSame($result, $this->model->canShowPriceInfo($this->orderItem)); } + /** + * @return array + */ public function canShowPriceInfoDataProvider() { return [ diff --git a/app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Sales/Order/View/Items/RendererTest.php b/app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Sales/Order/View/Items/RendererTest.php index 95dcb48f84be1..5d8cabdd8c1b9 100644 --- a/app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Sales/Order/View/Items/RendererTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Sales/Order/View/Items/RendererTest.php @@ -41,6 +41,9 @@ public function testIsShipmentSeparatelyWithoutItem($productOptions, $result) $this->assertSame($result, $this->model->isShipmentSeparately()); } + /** + * @return array + */ public function isShipmentSeparatelyWithoutItemDataProvider() { return [ @@ -70,6 +73,9 @@ public function testIsShipmentSeparatelyWithItem($productOptions, $result, $pare $this->assertSame($result, $this->model->isShipmentSeparately($this->orderItem)); } + /** + * @return array + */ public function isShipmentSeparatelyWithItemDataProvider() { return [ @@ -91,6 +97,9 @@ public function testIsChildCalculatedWithoutItem($productOptions, $result) $this->assertSame($result, $this->model->isChildCalculated()); } + /** + * @return array + */ public function isChildCalculatedWithoutItemDataProvider() { return [ @@ -120,6 +129,9 @@ public function testIsChildCalculatedWithItem($productOptions, $result, $parentI $this->assertSame($result, $this->model->isChildCalculated($this->orderItem)); } + /** + * @return array + */ public function isChildCalculatedWithItemDataProvider() { return [ @@ -151,6 +163,9 @@ public function testGetSelectionAttributesWithBundle() $this->assertEquals($unserializedResult, $this->model->getSelectionAttributes($this->orderItem)); } + /** + * @return array + */ public function getSelectionAttributesDataProvider() { return [ @@ -184,6 +199,9 @@ public function testCanShowPriceInfo($parentItem, $productOptions, $result) $this->assertSame($result, $this->model->canShowPriceInfo($this->orderItem)); } + /** + * @return array + */ public function canShowPriceInfoDataProvider() { return [ diff --git a/app/code/Magento/Bundle/Test/Unit/Block/Catalog/Product/View/Type/BundleTest.php b/app/code/Magento/Bundle/Test/Unit/Block/Catalog/Product/View/Type/BundleTest.php index 2353dc8251b6a..0f36049a86cac 100644 --- a/app/code/Magento/Bundle/Test/Unit/Block/Catalog/Product/View/Type/BundleTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Block/Catalog/Product/View/Type/BundleTest.php @@ -330,6 +330,11 @@ private function updateBundleBlock($options, $priceInfo, $priceType) ->will($this->returnArgument(0)); } + /** + * @param $price + * + * @return \PHPUnit_Framework_MockObject_MockObject + */ private function getPriceInfoMock($price) { $priceInfoMock = $this->getMockBuilder(\Magento\Framework\Pricing\PriceInfo\Base::class) @@ -354,6 +359,11 @@ private function getPriceInfoMock($price) return $priceInfoMock; } + /** + * @param $prices + * + * @return \PHPUnit_Framework_MockObject_MockObject + */ private function getPriceMock($prices) { $methods = []; diff --git a/app/code/Magento/Bundle/Test/Unit/Block/Sales/Order/Items/RendererTest.php b/app/code/Magento/Bundle/Test/Unit/Block/Sales/Order/Items/RendererTest.php index d79afdddfb7ae..2f5dcef391063 100644 --- a/app/code/Magento/Bundle/Test/Unit/Block/Sales/Order/Items/RendererTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Block/Sales/Order/Items/RendererTest.php @@ -47,6 +47,9 @@ public function testGetChildrenEmptyItems($class, $method, $returnClass) $this->assertSame(null, $this->model->getChildren($item)); } + /** + * @return array + */ public function getChildrenEmptyItemsDataProvider() { return [ @@ -96,6 +99,9 @@ public function testGetChildren($parentItem) $this->assertSame([2 => $this->orderItem], $this->model->getChildren($item)); } + /** + * @return array + */ public function getChildrenDataProvider() { return [ @@ -115,6 +121,9 @@ public function testIsShipmentSeparatelyWithoutItem($productOptions, $result) $this->assertSame($result, $this->model->isShipmentSeparately()); } + /** + * @return array + */ public function isShipmentSeparatelyWithoutItemDataProvider() { return [ @@ -144,6 +153,9 @@ public function testIsShipmentSeparatelyWithItem($productOptions, $result, $pare $this->assertSame($result, $this->model->isShipmentSeparately($this->orderItem)); } + /** + * @return array + */ public function isShipmentSeparatelyWithItemDataProvider() { return [ @@ -165,6 +177,9 @@ public function testIsChildCalculatedWithoutItem($productOptions, $result) $this->assertSame($result, $this->model->isChildCalculated()); } + /** + * @return array + */ public function isChildCalculatedWithoutItemDataProvider() { return [ @@ -194,6 +209,9 @@ public function testIsChildCalculatedWithItem($productOptions, $result, $parentI $this->assertSame($result, $this->model->isChildCalculated($this->orderItem)); } + /** + * @return array + */ public function isChildCalculatedWithItemDataProvider() { return [ @@ -238,6 +256,9 @@ public function testCanShowPriceInfo($parentItem, $productOptions, $result) $this->assertSame($result, $this->model->canShowPriceInfo($this->orderItem)); } + /** + * @return array + */ public function canShowPriceInfoDataProvider() { return [ diff --git a/app/code/Magento/Bundle/Test/Unit/Model/Sales/Order/Pdf/Items/AbstractItemsTest.php b/app/code/Magento/Bundle/Test/Unit/Model/Sales/Order/Pdf/Items/AbstractItemsTest.php index ecce34363819e..3e9aeaed5c5b4 100644 --- a/app/code/Magento/Bundle/Test/Unit/Model/Sales/Order/Pdf/Items/AbstractItemsTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Model/Sales/Order/Pdf/Items/AbstractItemsTest.php @@ -49,6 +49,9 @@ public function testGetChildrenEmptyItems($class, $method, $returnClass) $this->assertSame(null, $this->model->getChildren($item)); } + /** + * @return array + */ public function getChildrenEmptyItemsDataProvider() { return [ @@ -97,6 +100,9 @@ public function testGetChildren($parentItem) $this->assertSame([2 => $this->orderItem], $this->model->getChildren($item)); } + /** + * @return array + */ public function getChildrenDataProvider() { return [ @@ -116,6 +122,9 @@ public function testIsShipmentSeparatelyWithoutItem($productOptions, $result) $this->assertSame($result, $this->model->isShipmentSeparately()); } + /** + * @return array + */ public function isShipmentSeparatelyWithoutItemDataProvider() { return [ @@ -146,6 +155,9 @@ public function testIsShipmentSeparatelyWithItem($productOptions, $result, $pare $this->assertSame($result, $this->model->isShipmentSeparately($this->orderItem)); } + /** + * @return array + */ public function isShipmentSeparatelyWithItemDataProvider() { return [ @@ -167,6 +179,9 @@ public function testIsChildCalculatedWithoutItem($productOptions, $result) $this->assertSame($result, $this->model->isChildCalculated()); } + /** + * @return array + */ public function isChildCalculatedWithoutItemDataProvider() { return [ @@ -197,6 +212,9 @@ public function testIsChildCalculatedWithItem($productOptions, $result, $parentI $this->assertSame($result, $this->model->isChildCalculated($this->orderItem)); } + /** + * @return array + */ public function isChildCalculatedWithItemDataProvider() { return [ @@ -217,6 +235,9 @@ public function testGetBundleOptions($productOptions, $result) $this->assertSame($result, $this->model->getBundleOptions()); } + /** + * @return array + */ public function getBundleOptionsDataProvider() { return [ @@ -277,6 +298,9 @@ public function testCanShowPriceInfo($parentItem, $productOptions, $result) $this->assertSame($result, $this->model->canShowPriceInfo($this->orderItem)); } + /** + * @return array + */ public function canShowPriceInfoDataProvider() { return [ diff --git a/app/code/Magento/Bundle/Test/Unit/Pricing/Adjustment/CalculatorTest.php b/app/code/Magento/Bundle/Test/Unit/Pricing/Adjustment/CalculatorTest.php index f7f6b30daa300..8d29908b75280 100644 --- a/app/code/Magento/Bundle/Test/Unit/Pricing/Adjustment/CalculatorTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Pricing/Adjustment/CalculatorTest.php @@ -585,6 +585,9 @@ public function testGetOptionsAmount($searchMin, $useRegularPrice) $this->assertEquals($expectedResult, $result, 'Incorrect result'); } + /** + * @return array + */ public function getOptionsAmountDataProvider() { return [ diff --git a/app/code/Magento/Bundle/Test/Unit/Pricing/Price/BundleOptionsTest.php b/app/code/Magento/Bundle/Test/Unit/Pricing/Price/BundleOptionsTest.php index 26a7b46683330..2d8a73164008b 100644 --- a/app/code/Magento/Bundle/Test/Unit/Pricing/Price/BundleOptionsTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Pricing/Price/BundleOptionsTest.php @@ -145,6 +145,9 @@ private function prepareOptionMocks($selectionCollection) ->will($this->returnValue($priceTypeMock)); } + /** + * @return array + */ public function getOptionsDataProvider() { return [ diff --git a/app/code/Magento/Bundle/Test/Unit/Pricing/Price/BundleSelectionPriceTest.php b/app/code/Magento/Bundle/Test/Unit/Pricing/Price/BundleSelectionPriceTest.php index 700bfd4f3c084..cbcfb1b85fc97 100644 --- a/app/code/Magento/Bundle/Test/Unit/Pricing/Price/BundleSelectionPriceTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Pricing/Price/BundleSelectionPriceTest.php @@ -103,6 +103,9 @@ protected function setUp() $this->setupSelectionPrice(); } + /** + * @param bool $useRegularPrice + */ protected function setupSelectionPrice($useRegularPrice = false) { $this->selectionPrice = new \Magento\Bundle\Pricing\Price\BundleSelectionPrice( @@ -339,6 +342,9 @@ public function testFixedPriceWithMultipleQty($useRegularPrice) $this->assertEquals($expectedPrice, $selectionPrice->getValue()); } + /** + * @return array + */ public function useRegularPriceDataProvider() { return [ diff --git a/app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/BundleDataProviderTest.php b/app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/BundleDataProviderTest.php index 7b4d42568f686..1c3cf33cbf73b 100644 --- a/app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/BundleDataProviderTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/BundleDataProviderTest.php @@ -76,6 +76,9 @@ protected function setUp() ->getMock(); } + /** + * @return object + */ protected function getModel() { return $this->objectManager->getObject(BundleDataProvider::class, [ diff --git a/app/code/Magento/CacheInvalidate/Test/Unit/Model/PurgeCacheTest.php b/app/code/Magento/CacheInvalidate/Test/Unit/Model/PurgeCacheTest.php index 013ec3a467104..c66e27ea41025 100644 --- a/app/code/Magento/CacheInvalidate/Test/Unit/Model/PurgeCacheTest.php +++ b/app/code/Magento/CacheInvalidate/Test/Unit/Model/PurgeCacheTest.php @@ -84,6 +84,9 @@ public function testSendPurgeRequest($hosts) $this->assertTrue($this->model->sendPurgeRequest('tags')); } + /** + * @return array + */ public function sendPurgeRequestDataProvider() { return [ diff --git a/app/code/Magento/Captcha/Test/Unit/Model/DefaultTest.php b/app/code/Magento/Captcha/Test/Unit/Model/DefaultTest.php index 429c13e802a87..0500b29f787c2 100644 --- a/app/code/Magento/Captcha/Test/Unit/Model/DefaultTest.php +++ b/app/code/Magento/Captcha/Test/Unit/Model/DefaultTest.php @@ -354,6 +354,9 @@ public function testIsShownToLoggedInUser($expectedResult, $formId) $this->assertEquals($expectedResult, $captcha->isShownToLoggedInUser()); } + /** + * @return array + */ public function isShownToLoggedInUserDataProvider() { return [ diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Tab/AlertsTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Tab/AlertsTest.php index b45df0380dcc6..5d8db5d5ba589 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Tab/AlertsTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Tab/AlertsTest.php @@ -55,6 +55,9 @@ public function testCanShowTab($priceAllow, $stockAllow, $canShowTab) $this->assertEquals($canShowTab, $this->alerts->canShowTab()); } + /** + * @return array + */ public function canShowTabDataProvider() { return [ diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/CategoryTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/CategoryTest.php index 5e899263519da..1fc105686011f 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/CategoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/CategoryTest.php @@ -50,6 +50,9 @@ public function testIsAllowed($isAllowed) } } + /** + * @return array + */ public function isAllowedDataProvider() { return [ diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Category/Rss/LinkTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Category/Rss/LinkTest.php index 8932d77a81247..0cff8b2d0f207 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Category/Rss/LinkTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Category/Rss/LinkTest.php @@ -72,6 +72,9 @@ public function testIsRssAllowed($isAllowed) $this->assertEquals($isAllowed, $this->link->isRssAllowed()); } + /** + * @return array + */ public function isRssAllowedDataProvider() { return [ @@ -98,6 +101,9 @@ public function testIsTopCategory($isTop, $categoryLevel) $this->assertEquals($isTop, $this->link->isTopCategory()); } + /** + * @return array + */ public function isTopCategoryDataProvider() { return [ diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/ProductList/RelatedTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/ProductList/RelatedTest.php index 1d927a6e04ef5..deb84b7b2d3c4 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Product/ProductList/RelatedTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/ProductList/RelatedTest.php @@ -72,6 +72,9 @@ public function testCanItemsAddToCart($isComposite, $isSaleable, $hasRequiredOpt ); } + /** + * @return array + */ public function canItemsAddToCartDataProvider() { return [ diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/ProductList/ToolbarTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/ProductList/ToolbarTest.php index dce0be8e62df3..ac963326dbfa1 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Product/ProductList/ToolbarTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/ProductList/ToolbarTest.php @@ -216,6 +216,9 @@ public function testSetModes($mode, $expected) $this->assertEquals($expected, $block->getModes()); } + /** + * @return array + */ public function setModesDataProvider() { return [ diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/View/GalleryTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/View/GalleryTest.php index e0ba6531c8ab2..ae5176e78df7b 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Product/View/GalleryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/View/GalleryTest.php @@ -100,6 +100,9 @@ public function testGetGalleryImagesJsonWithoutLabel() $this->assertEquals('test_product_name', $decodedJson[0]['caption']); } + /** + * @param bool $hasLabel + */ private function prepareGetGalleryImagesJsonMocks($hasLabel = true) { $storeMock = $this->getMockBuilder(\Magento\Store\Model\Store::class) diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Rss/Product/NewProductsTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Rss/Product/NewProductsTest.php index e2e0fa2f27667..129dea37b185e 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Rss/Product/NewProductsTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Rss/Product/NewProductsTest.php @@ -91,6 +91,9 @@ protected function setUp() ); } + /** + * @return array + */ public function isAllowedDataProvider() { return [ @@ -108,6 +111,9 @@ public function testIsAllowed($configValue, $expectedResult) $this->assertEquals($expectedResult, $this->block->isAllowed()); } + /** + * @return \PHPUnit_Framework_MockObject_MockObject + */ protected function getItemMock() { $methods = [ diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Rss/Product/SpecialTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Rss/Product/SpecialTest.php index 6509aa138802e..3c9f19d61d16a 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Rss/Product/SpecialTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Rss/Product/SpecialTest.php @@ -167,6 +167,9 @@ public function testGetRssData() ); } + /** + * @return \PHPUnit_Framework_MockObject_MockObject + */ protected function getItemMock() { $item = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/Image/UploadTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/Image/UploadTest.php index 07dacae7298cf..e2cd01fd1c23a 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/Image/UploadTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/Image/UploadTest.php @@ -23,6 +23,9 @@ protected function setUp() $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); } + /** + * @return array + */ public function executeDataProvider() { return [ diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Attribute/ValidateTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Attribute/ValidateTest.php index 450cf4663c99c..9c747393cc72a 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Attribute/ValidateTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Attribute/ValidateTest.php @@ -195,6 +195,9 @@ public function testUniqueValidation(array $options, $isError) $this->assertInstanceOf(ResultJson::class, $this->getModel()->execute()); } + /** + * @return array + */ public function provideUniqueData() { return [ diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/XsdTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/XsdTest.php index a0a563e1e070e..779630b9559c6 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/XsdTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/XsdTest.php @@ -39,6 +39,9 @@ public function testExemplarXml($fixtureXml, array $expectedErrors) $this->assertEquals($expectedErrors, $actualErrors); } + /** + * @return array + */ public function exemplarXmlDataProvider() { return [ diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Backend/ImageTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Backend/ImageTest.php index d4e09714d0522..49e6a58b52032 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Backend/ImageTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Backend/ImageTest.php @@ -205,6 +205,9 @@ private function setUpModelForAfterSave() return $model->setAttribute($this->attribute); } + /** + * @return array + */ public function attributeValueDataProvider() { return [ diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Backend/SortbyTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Backend/SortbyTest.php index 3b99f2697f6b8..073a07818b52e 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Backend/SortbyTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Backend/SortbyTest.php @@ -70,6 +70,9 @@ public function testBeforeSave($attributeCode, $data, $expected) $this->assertSame($expected, $object->getData($attributeCode)); } + /** + * @return array + */ public function beforeSaveDataProvider() { return [ @@ -116,6 +119,9 @@ public function testAfterLoad($attributeCode, $data, $expected) $this->assertSame($expected, $object->getData($attributeCode)); } + /** + * @return array + */ public function afterLoadDataProvider() { return [ @@ -158,6 +164,9 @@ public function testValidate($attributeData, $data, $expected) $this->assertSame($expected, $this->_model->validate($object)); } + /** + * @return array + */ public function validateDataProvider() { return [ @@ -250,6 +259,9 @@ public function testValidateDefaultSort($attributeCode, $data) $this->assertTrue($this->_model->validate($object)); } + /** + * @return array + */ public function validateDefaultSortDataProvider() { return [ @@ -293,6 +305,9 @@ public function testValidateDefaultSortException($attributeCode, $data) $this->_model->validate($object); } + /** + * @return array + */ public function validateDefaultSortException() { return [ diff --git a/app/code/Magento/Catalog/Test/Unit/Model/CategoryRepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/CategoryRepositoryTest.php index f77a6fec283a5..7d448302666cc 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/CategoryRepositoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/CategoryRepositoryTest.php @@ -280,6 +280,9 @@ public function testSaveWithValidateCategoryException($error, $expectedException $this->model->save($categoryMock); } + /** + * @return array + */ public function saveWithValidateCategoryExceptionDataProvider() { return [ diff --git a/app/code/Magento/Catalog/Test/Unit/Model/CategoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/CategoryTest.php index b989cba2927d6..a53b87dcf1567 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/CategoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/CategoryTest.php @@ -259,6 +259,9 @@ public function testGetUseFlatResourceTrue() $this->assertEquals(true, $category->getUseFlatResource()); } + /** + * @return object + */ protected function getCategoryModel() { return $this->objectManager->getObject( @@ -287,6 +290,9 @@ protected function getCategoryModel() ); } + /** + * @return array + */ public function reindexFlatEnabledTestDataProvider() { return [ @@ -336,6 +342,9 @@ public function testReindexFlatEnabled($flatScheduled, $productScheduled, $expec $this->category->reindex(); } + /** + * @return array + */ public function reindexFlatDisabledTestDataProvider() { return [ diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/Plugin/IndexerConfigDataTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/Plugin/IndexerConfigDataTest.php index 56bd04594018c..f69cbeb91631f 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/Plugin/IndexerConfigDataTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/Plugin/IndexerConfigDataTest.php @@ -48,6 +48,9 @@ public function testAroundGet($isFlat, $path, $default, $inputData, $outputData) $this->assertEquals($outputData, $this->model->afterGet($this->subjectMock, $inputData, $path, $default)); } + /** + * @return array + */ public function aroundGetDataProvider() { $flatIndexerData = [ diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/StateTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/StateTest.php index 3beb9a3ffb773..6916cef2dfa61 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/StateTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/StateTest.php @@ -102,6 +102,9 @@ public function testIsAvailable($isAvailable, $isFlatEnabled, $isValid, $result) $this->assertEquals($result, $this->model->isAvailable()); } + /** + * @return array + */ public function isAvailableDataProvider() { return [ diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/System/Config/ModeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/System/Config/ModeTest.php index 3b3941d116fde..fb02b80a60175 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/System/Config/ModeTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/System/Config/ModeTest.php @@ -57,6 +57,9 @@ protected function setUp() ); } + /** + * @return array + */ public function dataProviderProcessValueEqual() { return [['0', '0'], ['', '0'], ['0', ''], ['1', '1']]; @@ -92,6 +95,9 @@ public function testProcessValueEqual($oldValue, $value) $this->model->processValue(); } + /** + * @return array + */ public function dataProviderProcessValueOn() { return [['0', '1'], ['', '1']]; @@ -143,6 +149,9 @@ public function testProcessValueOn($oldValue, $value) $this->model->processValue(); } + /** + * @return array + */ public function dataProviderProcessValueOff() { return [['1', '0'], ['1', '']]; diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/StoreGroupTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/StoreGroupTest.php index 8310f3692d966..e134407d547ac 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/StoreGroupTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/StoreGroupTest.php @@ -89,6 +89,9 @@ public function testBeforeAndAfterSaveNotNew($valueMap) $this->assertSame($this->subject, $this->model->afterSave($this->subject, $this->subject, $this->groupMock)); } + /** + * @return array + */ public function changedDataProvider() { return [ diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/AbstractActionTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/AbstractActionTest.php index 52bbff6eb5597..a2ca4ef616926 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/AbstractActionTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/AbstractActionTest.php @@ -177,6 +177,9 @@ public function testReindexWithNotNullArgumentExecutesReindexEntities( $this->_model->reindex($ids); } + /** + * @return array + */ public function reindexEntitiesDataProvider() { return [ diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/ProcessorTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/ProcessorTest.php index 8c63d77b74f53..d30a8da0e77a2 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/ProcessorTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/ProcessorTest.php @@ -129,6 +129,9 @@ public function testReindexRow( $this->_model->reindexRow(1, $forceReindex); } + /** + * @return array + */ public function dataProviderReindexRow() { return [ @@ -198,6 +201,9 @@ public function testReindexList( $this->_model->reindexList([1], $forceReindex); } + /** + * @return array + */ public function dataProviderReindexList() { return [ diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/System/Config/ModeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/System/Config/ModeTest.php index ca67185203738..34cc5c70418b9 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/System/Config/ModeTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/System/Config/ModeTest.php @@ -50,6 +50,9 @@ protected function setUp() ); } + /** + * @return array + */ public function dataProviderProcessValueEqual() { return [['0', '0'], ['', '0'], ['0', ''], ['1', '1']]; @@ -84,6 +87,9 @@ public function testProcessValueEqual($oldValue, $value) $this->model->processValue(); } + /** + * @return array + */ public function dataProviderProcessValueOn() { return [['0', '1'], ['', '1']]; @@ -134,6 +140,9 @@ public function testProcessValueOn($oldValue, $value) $this->model->processValue(); } + /** + * @return array + */ public function dataProviderProcessValueOff() { return [['1', '0'], ['1', '']]; diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/DataProvider/CategoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/DataProvider/CategoryTest.php index 3e5daf1a98a9c..257a84e50248d 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/DataProvider/CategoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/DataProvider/CategoryTest.php @@ -77,6 +77,9 @@ protected function setUp() ); } + /** + * @return \Magento\Catalog\Model\Layer\Filter\DataProvider\Category + */ public function testGetCategoryWithAppliedId() { $storeId = 1234; diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/DataProvider/PriceTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/DataProvider/PriceTest.php index 3a23ebcdf4518..f2c77627e38d0 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/DataProvider/PriceTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Layer/Filter/DataProvider/PriceTest.php @@ -165,6 +165,9 @@ public function testValidateFilter($filter, $expectedResult) $this->assertSame($expectedResult, $this->target->validateFilter($filter)); } + /** + * @return array + */ public function validateFilterDataProvider() { return [ diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/ActionTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/ActionTest.php index 8cf075f4d8504..a97e4650b49bd 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/ActionTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/ActionTest.php @@ -164,6 +164,9 @@ public function testUpdateWebsites($type, $methodName) $this->assertEquals($this->model->getDataByKey('action_type'), $type); } + /** + * @return array + */ public function updateWebsitesDataProvider() { return [ diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/CartConfigurationTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/CartConfigurationTest.php index 6f1f5e120b100..2144cf34c2a09 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/CartConfigurationTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/CartConfigurationTest.php @@ -21,6 +21,9 @@ public function testIsProductConfigured($productType, $config, $expected) $this->assertEquals($expected, $cartConfiguration->isProductConfigured($productMock, $config)); } + /** + * @return array + */ public function isProductConfiguredDataProvider() { return [ diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/ProcessorTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/ProcessorTest.php index d52aad50f05f3..15f003282dc04 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/ProcessorTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/ProcessorTest.php @@ -151,6 +151,9 @@ public function testValidate($value) $this->assertEquals(!$value, $this->model->validate($this->dataObject)); } + /** + * @return array + */ public function validateDataProvider() { return [ diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/LinkTypeProviderTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/LinkTypeProviderTest.php index 0e29aeab697af..c1e5559dbfd66 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/LinkTypeProviderTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/LinkTypeProviderTest.php @@ -111,6 +111,9 @@ public function testGetItemAttributes($type, $typeId) $this->assertEquals($expectedResult, $this->model->getItemAttributes($type)); } + /** + * @return array + */ public function getItemAttributesDataProvider() { return [ diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/SelectTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/SelectTest.php index 046ee703c850e..95a9b961c8d81 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/SelectTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/SelectTest.php @@ -69,6 +69,9 @@ public function testIsValidSuccess($expectedResult, array $value) $this->assertEquals($expectedResult, $this->validator->isValid($this->valueMock)); } + /** + * @return array + */ public function isValidSuccessDataProvider() { return [ @@ -154,6 +157,9 @@ public function testIsValidateWithInvalidData($priceType, $price, $title) $this->assertEquals($messages, $this->validator->getMessages()); } + /** + * @return array + */ public function isValidateWithInvalidDataDataProvider() { return [ diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/ProductList/ToolbarTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/ProductList/ToolbarTest.php index 84a9e9ded094b..3789ba4ee126d 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/ProductList/ToolbarTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/ProductList/ToolbarTest.php @@ -112,6 +112,9 @@ public function testGetCurrentPageNoParam() $this->assertEquals(1, $this->toolbarModel->getCurrentPage()); } + /** + * @return array + */ public function stringParamProvider() { return [ @@ -119,6 +122,9 @@ public function stringParamProvider() ]; } + /** + * @return array + */ public function intParamProvider() { return [ diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/ReservedAttributeListTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/ReservedAttributeListTest.php index 7506b4adc1d3a..5080e64f46e27 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/ReservedAttributeListTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/ReservedAttributeListTest.php @@ -40,6 +40,9 @@ public function testIsReservedAttribute($isUserDefined, $attributeCode, $expecte $this->assertEquals($expected, $this->model->isReservedAttribute($attribute)); } + /** + * @return array + */ public function dataProvider() { return [ diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/TierPriceManagementTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/TierPriceManagementTest.php index 6d42a33d1fc73..bbd0886442fd3 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/TierPriceManagementTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/TierPriceManagementTest.php @@ -147,6 +147,9 @@ public function testGetList($configValue, $customerGroupId, $groupData, $expecte } } + /** + * @return array + */ public function getListDataProvider() { return [ @@ -399,6 +402,9 @@ public function testAddWithInvalidData($price, $qty) $this->service->add('product_sku', 1, $price, $qty); } + /** + * @return array + */ public function addDataProvider() { return [ diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Type/AbstractTypeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Type/AbstractTypeTest.php index dcddab60fb0b9..b34375256a959 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Type/AbstractTypeTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Type/AbstractTypeTest.php @@ -96,6 +96,9 @@ public function testAttributesCompare($attr1, $attr2, $expectedResult) $this->assertEquals($expectedResult, $this->model->attributesCompare($attribute, $attribute2)); } + /** + * @return array + */ public function attributeCompareProvider() { return [ diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/UrlTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/UrlTest.php index 9fa820d64bae1..ef7aad2cbb802 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/UrlTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/UrlTest.php @@ -169,6 +169,9 @@ public function testGetUrl( } } + /** + * @return array + */ public function getUrlDataProvider() { return [ diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php index a9760d81bbac4..1460b8348c827 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php @@ -1112,6 +1112,9 @@ public function testSaveWithLinks(array $newLinks, array $existingLinks, array $ $this->assertEquals($this->initializedProductMock, $results); } + /** + * @return mixed + */ public function saveWithLinksDataProvider() { // Scenario 1 @@ -1264,6 +1267,9 @@ public function testSaveExistingWithNewMediaGalleryEntries() $this->model->save($this->product); } + /** + * @return array + */ public function websitesProvider() { return [ diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php index 26199eb3fabbe..a2e9a8e5060cc 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php @@ -513,6 +513,9 @@ public function testGetCategoryCollectionCollectionNull($initCategoryCollection, $this->assertEquals($initCategoryCollection, $result); } + /** + * @return array + */ public function getCategoryCollectionCollectionNullDataProvider() { return [ @@ -623,6 +626,9 @@ public function testReindex($productChanged, $isScheduled, $productFlatCount, $c $this->model->reindex(); } + /** + * @return array + */ public function getProductReindexProvider() { return array( diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/ConfigTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/ConfigTest.php index e6de1d33e564d..fb289c7beaac6 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/ConfigTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/ConfigTest.php @@ -68,6 +68,9 @@ public function testGetType($value, $expected) $this->assertEquals($expected, $this->config->getType('global')); } + /** + * @return array + */ public function getTypeDataProvider() { return [ diff --git a/app/code/Magento/Catalog/Test/Unit/Model/View/Asset/ImageTest.php b/app/code/Magento/Catalog/Test/Unit/Model/View/Asset/ImageTest.php index 517b5949ee8ea..405c1ced44ba3 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/View/Asset/ImageTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/View/Asset/ImageTest.php @@ -145,6 +145,9 @@ public function testGetUrl($filePath, $miscParams) ); } + /** + * @return array + */ public function getPathDataProvider() { return [ diff --git a/app/code/Magento/Catalog/Test/Unit/Model/View/Asset/PlaceholderTest.php b/app/code/Magento/Catalog/Test/Unit/Model/View/Asset/PlaceholderTest.php index 96a6c15e35651..58007145d21a4 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/View/Asset/PlaceholderTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/View/Asset/PlaceholderTest.php @@ -147,6 +147,9 @@ public function testGetUrl($imageType, $placeholderPath) $this->assertEquals($expectedResult, $imageModel->getUrl()); } + /** + * @return array + */ public function getPathDataProvider() { return [ diff --git a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/BasePriceTest.php b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/BasePriceTest.php index 25c3c3ab24ad8..78cc028b51de7 100644 --- a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/BasePriceTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/BasePriceTest.php @@ -108,6 +108,9 @@ public function testGetValue($specialPriceValue, $expectedResult) $this->assertSame($expectedResult, $this->basePrice->getValue()); } + /** + * @return array + */ public function getValueDataProvider() { return [[77, 77], [0, 0], [false, 99]]; diff --git a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/CustomOptionPriceTest.php b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/CustomOptionPriceTest.php index 9225a37c3e5b4..4a206d023ec16 100644 --- a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/CustomOptionPriceTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/CustomOptionPriceTest.php @@ -77,6 +77,11 @@ protected function setUp() ); } + /** + * @param array $optionsData + * + * @return array + */ protected function setupOptions(array $optionsData) { $options = []; @@ -105,6 +110,11 @@ protected function setupOptions(array $optionsData) return $options; } + /** + * @param $optionsData + * + * @return array + */ protected function setupSingleValueOptions($optionsData) { $options = []; diff --git a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/MinimalTierPriceCalculatorTest.php b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/MinimalTierPriceCalculatorTest.php index d04bb4c681e67..1c50271976d15 100644 --- a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/MinimalTierPriceCalculatorTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/MinimalTierPriceCalculatorTest.php @@ -61,6 +61,9 @@ public function setUp() ); } + /** + * @return int + */ private function getValueTierPricesExistShouldReturnMinTierPrice() { $minPrice = 5; diff --git a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/TierPriceTest.php b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/TierPriceTest.php index fd13439d7d34c..64a6324a35620 100644 --- a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/TierPriceTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/TierPriceTest.php @@ -411,6 +411,9 @@ public function testGetQuantity($quantity, $expectedValue) $this->assertEquals($expectedValue, $tierPrice->getQuantity()); } + /** + * @return array + */ public function getQuantityDataProvider() { return [ diff --git a/app/code/Magento/Catalog/Test/Unit/Pricing/Render/FinalPriceBoxTest.php b/app/code/Magento/Catalog/Test/Unit/Pricing/Render/FinalPriceBoxTest.php index 6322fc76ff442..42f537228ddf8 100644 --- a/app/code/Magento/Catalog/Test/Unit/Pricing/Render/FinalPriceBoxTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Pricing/Render/FinalPriceBoxTest.php @@ -347,6 +347,9 @@ public function testHasSpecialPrice($regularPrice, $finalPrice, $expectedResult) $this->assertEquals($expectedResult, $this->object->hasSpecialPrice()); } + /** + * @return array + */ public function hasSpecialPriceProvider() { return [ diff --git a/app/code/Magento/Catalog/Test/Unit/Pricing/Render/PriceBoxTest.php b/app/code/Magento/Catalog/Test/Unit/Pricing/Render/PriceBoxTest.php index 986a1f7710919..e4d531e91fa07 100644 --- a/app/code/Magento/Catalog/Test/Unit/Pricing/Render/PriceBoxTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Pricing/Render/PriceBoxTest.php @@ -88,6 +88,9 @@ public function testGetCanDisplayQty($typeCode, $expected) $this->assertEquals($expected, $this->object->getCanDisplayQty($product)); } + /** + * @return array + */ public function getCanDisplayQtyDataProvider() { return [ diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/CatalogEavValidationRulesTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/CatalogEavValidationRulesTest.php index 9b0ade2b1288f..57b277a786ea3 100644 --- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/CatalogEavValidationRulesTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/CatalogEavValidationRulesTest.php @@ -53,6 +53,9 @@ public function testBuild($frontendInput, $frontendClass, array $eavConfig, arra $this->assertEquals($expectedResult, $this->catalogEavValidationRules->build($attribute, $eavConfig)); } + /** + * @return array + */ public function buildDataProvider() { $data['required'] = true; diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/CategoryProcessorTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/CategoryProcessorTest.php index bf47ec4f9da13..e56cb62e042bb 100644 --- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/CategoryProcessorTest.php +++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/CategoryProcessorTest.php @@ -135,6 +135,9 @@ public function testGetCategoryById($categoriesCache, $expectedResult) $this->assertEquals($expectedResult, $actualResult); } + /** + * @return array + */ public function getCategoryByIdDataProvider() { return [ diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/AbstractTypeTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/AbstractTypeTest.php index e24b4e1948149..70ac3a4fa2e97 100644 --- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/AbstractTypeTest.php +++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/AbstractTypeTest.php @@ -269,6 +269,9 @@ public function testIsRowValidError() $this->assertFalse($this->simpleType->isRowValid($rowData, $rowNum)); } + /** + * @return array + */ public function addAttributeOptionDataProvider() { return [ diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/TierPriceTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/TierPriceTest.php index 4e902024769f7..f1965e3063217 100644 --- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/TierPriceTest.php +++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/TierPriceTest.php @@ -48,6 +48,11 @@ protected function setUp() ); } + /** + * @param $groupId + * + * @return \Magento\CatalogImportExport\Model\Import\Product\Validator\TierPrice + */ protected function processInit($groupId) { $searchResult = $this->createMock(\Magento\Customer\Api\Data\GroupSearchResultsInterface::class); diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/ProductTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/ProductTest.php index 6d183fc8e6e20..1cd19852f393c 100644 --- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/ProductTest.php +++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/ProductTest.php @@ -790,6 +790,9 @@ public function testGetCategoryProcessor() $this->assertEquals($expectedResult, $actualResult); } + /** + * @return array + */ public function getStoreIdByCodeDataProvider() { return [ @@ -1239,6 +1242,9 @@ public function uploadMediaFilesDataProvider() ]; } + /** + * @return array + */ public function getImagesFromRowDataProvider() { return [ @@ -1265,6 +1271,9 @@ public function getImagesFromRowDataProvider() ]; } + /** + * @return array + */ public function validateRowValidateNewProductTypeAddRowErrorCallDataProvider() { return [ @@ -1299,6 +1308,9 @@ public function validateRowValidateNewProductTypeAddRowErrorCallDataProvider() ]; } + /** + * @return array + */ public function validateRowCheckSpecifiedSkuDataProvider() { return [ @@ -1317,6 +1329,9 @@ public function validateRowCheckSpecifiedSkuDataProvider() ]; } + /** + * @return array + */ public function validateRowDataProvider() { return [ diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/UploaderTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/UploaderTest.php index e28c2e1f3c01d..0c21538889498 100644 --- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/UploaderTest.php +++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/UploaderTest.php @@ -193,6 +193,9 @@ public function testMoveFileUrlDrivePool($fileUrl, $expectedHost, $expectedDrive $this->assertNull($result); } + /** + * @return array + */ public function moveFileUrlDriverPoolDataProvider() { return [ @@ -211,6 +214,9 @@ public function moveFileUrlDriverPoolDataProvider() ]; } + /** + * @return array + */ public function moveFileUrlDataProvider() { return [ diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Helper/StockTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Helper/StockTest.php index 2fe40c118b06a..bd04df0da0a4a 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Helper/StockTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Helper/StockTest.php @@ -167,6 +167,9 @@ public function testAddInStockFilterToCollection($configMock) $this->assertNull($this->stock->addInStockFilterToCollection($collectionMock)); } + /** + * @return array + */ public function filterProvider() { $configMock = $this->getMockBuilder(\Magento\Framework\App\Config::class) diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/Plugin/ProductLinksTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/Plugin/ProductLinksTest.php index ea562da2f01c0..3788b1bc401fe 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/Plugin/ProductLinksTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/Plugin/ProductLinksTest.php @@ -48,6 +48,9 @@ public function testAfterGetProductCollectionShow($status, $callCount) $this->assertEquals($collectionMock, $this->model->afterGetProductCollection($subjectMock, $collectionMock)); } + /** + * @return array + */ private function buildMocks() { /** @var \Magento\Catalog\Model\ResourceModel\Product\Link\Product\Collection $collectionMock */ diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/Quote/Item/QuantityValidator/Initializer/QuantityValidatorTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/Quote/Item/QuantityValidator/Initializer/QuantityValidatorTest.php index 11a04d26994ae..7e2bad0b96354 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/Quote/Item/QuantityValidator/Initializer/QuantityValidatorTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/Quote/Item/QuantityValidator/Initializer/QuantityValidatorTest.php @@ -450,6 +450,10 @@ public function testException() $this->quantityValidator->validate($this->observerMock); } + /** + * @param $qty + * @param $hasError + */ private function setUpStubForQuantity($qty, $hasError) { $this->productMock->expects($this->any()) @@ -480,6 +484,9 @@ private function setUpStubForQuantity($qty, $hasError) ->willReturn(''); } + /** + * @param $qty + */ private function createInitialStub($qty) { $this->storeMock->expects($this->any()) diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/Spi/StockStateProviderTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/Spi/StockStateProviderTest.php index 5c75249b7cbf8..b542dd219af1d 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/Spi/StockStateProviderTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/Spi/StockStateProviderTest.php @@ -243,41 +243,67 @@ public function testCheckQuoteItemQty(StockItemInterface $stockItem, $expectedRe ); } + /** + * @return array + */ public function verifyStockDataProvider() { return $this->prepareDataForMethod('verifyStock'); } + /** + * @return array + */ public function verifyNotificationDataProvider() { return $this->prepareDataForMethod('verifyNotification'); } + /** + * @return array + */ public function checkQtyDataProvider() { return $this->prepareDataForMethod('checkQty'); } + /** + * @return array + */ public function suggestQtyDataProvider() { return $this->prepareDataForMethod('suggestQty'); } + /** + * @return array + */ public function getStockQtyDataProvider() { return $this->prepareDataForMethod('getStockQty'); } + /** + * @return array + */ public function checkQtyIncrementsDataProvider() { return $this->prepareDataForMethod('checkQtyIncrements'); } + /** + * @return array + */ public function checkQuoteItemQtyDataProvider() { return $this->prepareDataForMethod('checkQuoteItemQty'); } + /** + * @param $methodName + * + * @return array + */ protected function prepareDataForMethod($methodName) { $variations = []; @@ -318,6 +344,9 @@ protected function prepareDataForMethod($methodName) return $variations; } + /** + * @return array + */ protected function getVariations() { $stockQty = 100; @@ -430,6 +459,9 @@ public function testCheckQtyIncrementsMsg($isChildItem, $expectedMsg) $this->assertEquals($expectedMsg, $result->getMessage()->render()); } + /** + * @return array + */ public function checkQtyIncrementsMsgDataProvider() { return [ diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/ItemTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/ItemTest.php index d1d8e171bea16..359b0e80f1b74 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/ItemTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/ItemTest.php @@ -482,6 +482,9 @@ public function testDispatchEvents($eventName, $methodName, $objectName) ); } + /** + * @return array + */ public function eventsDataProvider() { return [ diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/StockTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/StockTest.php index c3abad50ef9f4..9ecab4dca77e3 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/StockTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/StockTest.php @@ -125,7 +125,10 @@ public function testDispatchEvents($eventName, $methodName, $objectName) sprintf('Event "%s" with object name "%s" doesn\'t dispatched properly', $eventName, $objectName) ); } - + + /** + * @return array + */ public function eventsDataProvider() { return [ diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Ui/Component/Product/Form/Element/UseConfigSettingsTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Ui/Component/Product/Form/Element/UseConfigSettingsTest.php index db183ae5c0da0..0ce62133d6f9b 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Ui/Component/Product/Form/Element/UseConfigSettingsTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Ui/Component/Product/Form/Element/UseConfigSettingsTest.php @@ -106,6 +106,9 @@ public function testPrepareSource( $this->assertEquals($expectedResult, $this->useConfigSettings->getData('config')); } + /** + * @return array + */ public function prepareSourceDataProvider() { return [ diff --git a/app/code/Magento/CatalogRule/Test/Unit/Model/Product/PriceModifierTest.php b/app/code/Magento/CatalogRule/Test/Unit/Model/Product/PriceModifierTest.php index b1e27bf973404..ccc86920a7e74 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Model/Product/PriceModifierTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Model/Product/PriceModifierTest.php @@ -56,6 +56,9 @@ public function testModifyPriceIfPriceExists($resultPrice, $expectedPrice) $this->assertEquals($expectedPrice, $this->priceModifier->modifyPrice(100, $this->productMock)); } + /** + * @return array + */ public function modifyPriceDataProvider() { return ['resulted_price_exists' => [150, 150], 'resulted_price_not_exists' => [null, 100]]; diff --git a/app/code/Magento/CatalogRule/Test/Unit/Model/Rule/Condition/MappableConditionProcessorTest.php b/app/code/Magento/CatalogRule/Test/Unit/Model/Rule/Condition/MappableConditionProcessorTest.php index 1643b3473ae27..59c0322678759 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Model/Rule/Condition/MappableConditionProcessorTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Model/Rule/Condition/MappableConditionProcessorTest.php @@ -1006,6 +1006,12 @@ public function testException() $this->mappableConditionProcessor->rebuildConditionsTree($inputCondition); } + /** + * @param $subConditions + * @param $aggregator + * + * @return \PHPUnit_Framework_MockObject_MockObject + */ protected function getMockForCombinedCondition($subConditions, $aggregator) { $mock = $this->getMockBuilder(CombinedCondition::class) @@ -1020,6 +1026,11 @@ protected function getMockForCombinedCondition($subConditions, $aggregator) return $mock; } + /** + * @param $attribute + * + * @return \PHPUnit_Framework_MockObject_MockObject + */ protected function getMockForSimpleCondition($attribute) { $mock = $this->getMockBuilder(SimpleCondition::class) diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Filter/PreprocessorTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Filter/PreprocessorTest.php index f4c512916465f..01108358da2e0 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Filter/PreprocessorTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Filter/PreprocessorTest.php @@ -314,6 +314,9 @@ public function testProcessTermFilter($frontendInput, $fieldValue, $isNegation, $this->assertSame($expected, $this->removeWhitespaces($actualResult)); } + /** + * @return array + */ public function testTermFilterDataProvider() { return [ diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/AdvancedTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/AdvancedTest.php index ac3e84a5c8fef..a04affcf810c1 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/AdvancedTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/AdvancedTest.php @@ -99,6 +99,9 @@ protected function setUp() ->willReturn($this->store); } + /** + * @return array + */ public function addFiltersDataProvider() { return array_merge( @@ -269,6 +272,11 @@ private function createBackend($table) return $backend; } + /** + * @param string $optionText + * + * @return \PHPUnit_Framework_MockObject_MockObject + */ private function createSource($optionText = 'optionText') { $source = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\Source\AbstractSource::class) @@ -281,6 +289,9 @@ private function createSource($optionText = 'optionText') return $source; } + /** + * @return array + */ private function addFiltersPriceDataProvider() { return [ diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Autocomplete/DataProviderTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Autocomplete/DataProviderTest.php index 75daf438f7bf2..b54a02ffb3cf9 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/Autocomplete/DataProviderTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Autocomplete/DataProviderTest.php @@ -107,6 +107,9 @@ public function testGetItems() $this->assertEquals($expected, $result[0]->toArray()); } + /** + * @param array $data + */ private function buildCollection(array $data) { $collectionData = []; diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/ResourceModel/Fulltext/CollectionTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/ResourceModel/Fulltext/CollectionTest.php index c0f1f3fcaa5e6..ffdb849c81d65 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/ResourceModel/Fulltext/CollectionTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/ResourceModel/Fulltext/CollectionTest.php @@ -206,6 +206,12 @@ protected function getFilterBuilder() return $filterBuilder; } + /** + * @param MockObject $filterBuilder + * @param array $filters + * + * @return MockObject + */ protected function addFiltersToFilterBuilder(MockObject $filterBuilder, array $filters) { $i = 1; @@ -222,6 +228,9 @@ protected function addFiltersToFilterBuilder(MockObject $filterBuilder, array $f return $filterBuilder; } + /** + * @return MockObject + */ protected function createFilter() { $filter = $this->getMockBuilder(\Magento\Framework\Api\Filter::class) diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/BaseSelectStrategy/StrategyMapperTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/BaseSelectStrategy/StrategyMapperTest.php index 1ff1131e5f002..5fa5b0333c6ba 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/BaseSelectStrategy/StrategyMapperTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/BaseSelectStrategy/StrategyMapperTest.php @@ -91,6 +91,9 @@ public function testBaseSelectFullTextSearchStrategy( ); } + /** + * @return array + */ public function dataProvider() { return [ diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/CustomAttributeFilterCheckTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/CustomAttributeFilterCheckTest.php index 2022492ed1c86..175407bda677f 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/CustomAttributeFilterCheckTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/CustomAttributeFilterCheckTest.php @@ -78,6 +78,9 @@ public function testIsCustomPositive($attributeFrontEndType) ); } + /** + * @return array + */ public function dataProviderForIsCustomPositive() { return [ diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/Indexer/IndexStructureTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/Indexer/IndexStructureTest.php index c393f91f21fe1..02d6bec162c56 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/Indexer/IndexStructureTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/Indexer/IndexStructureTest.php @@ -120,6 +120,13 @@ private function createDimensionMock($name, $value) return $dimension; } + /** + * @param $callNumber + * @param $tableName + * @param $isTableExist + * + * @return mixed + */ private function mockDropTable($callNumber, $tableName, $isTableExist) { $this->connection->expects($this->at($callNumber++)) @@ -135,6 +142,12 @@ private function mockDropTable($callNumber, $tableName, $isTableExist) return $callNumber; } + /** + * @param $callNumber + * @param $tableName + * + * @return mixed + */ private function mockFulltextTable($callNumber, $tableName) { $table = $this->getMockBuilder(\Magento\Framework\DB\Ddl\Table::class) diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/QueryChecker/FullTextSearchCheckTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/QueryChecker/FullTextSearchCheckTest.php index bb6e4ab8b4281..d13dcc11628f2 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/QueryChecker/FullTextSearchCheckTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/QueryChecker/FullTextSearchCheckTest.php @@ -78,6 +78,9 @@ public function testInvalidArgumentException2() $this->fullTextSearchCheck->isRequiredForQuery($filterMock); } + /** + * @return array + */ public function positiveDataProvider() { $boolQueryMock = $this->getBoolQueryMock(); @@ -114,6 +117,9 @@ public function positiveDataProvider() ]; } + /** + * @return array + */ public function negativeDataProvider() { $emptyBoolQueryMock = $this->getBoolQueryMock(); @@ -147,6 +153,9 @@ public function negativeDataProvider() ]; } + /** + * @return \PHPUnit_Framework_MockObject_MockObject + */ private function getMatchQueryMock() { $matchQueryMock = $this->getMockBuilder(\Magento\Framework\Search\Request\QueryInterface::class) @@ -161,6 +170,9 @@ private function getMatchQueryMock() return $matchQueryMock; } + /** + * @return \PHPUnit_Framework_MockObject_MockObject + */ private function getBoolQueryMock() { $boolQueryMock = $this->getMockBuilder(\Magento\Framework\Search\Request\Query\BoolExpression::class) @@ -175,6 +187,9 @@ private function getBoolQueryMock() return $boolQueryMock; } + /** + * @return \PHPUnit_Framework_MockObject_MockObject + */ private function getFilterQueryMock() { $filterQueryMock = $this->getMockBuilder(\Magento\Framework\Search\Request\Query\Filter::class) diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/RequestGeneratorTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/RequestGeneratorTest.php index 259c8e5d7f897..560de27ccdbc7 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/RequestGeneratorTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/RequestGeneratorTest.php @@ -239,6 +239,11 @@ private function createAttributeMock($attributeOptions) return $attribute; } + /** + * @param $value + * + * @return int|void + */ private function countVal(&$value) { return !empty($value) ? count($value) : 0; diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/SelectContainer/SelectContainerBuilderTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/SelectContainer/SelectContainerBuilderTest.php index ef4d8d314825b..374d0390f937c 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/SelectContainer/SelectContainerBuilderTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/SelectContainer/SelectContainerBuilderTest.php @@ -190,6 +190,9 @@ public function testBuildByRequest() ); } + /** + * @return \PHPUnit_Framework_MockObject_MockObject + */ private function mockQuery() { return $this->getMockBuilder(QueryInterface::class) @@ -197,6 +200,9 @@ private function mockQuery() ->getMockForAbstractClass(); } + /** + * @return array + */ private function mockFilters() { $visibilityFilter = $this->getMockBuilder(Term::class) diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/TableMapperTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/TableMapperTest.php index 1521b38d8c298..cfddc07bceecc 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/TableMapperTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/TableMapperTest.php @@ -275,6 +275,9 @@ function (FilterInterface $filter) { $this->tableMapper->addTables($select, $request); } + /** + * @return \PHPUnit_Framework_MockObject_MockObject + */ private function getSelectMock() { return $this->getMockBuilder(\Magento\Framework\DB\Select::class) @@ -282,6 +285,9 @@ private function getSelectMock() ->getMock(); } + /** + * @return \PHPUnit_Framework_MockObject_MockObject + */ private function getRequestMock() { return $this->getMockBuilder(\Magento\Framework\Search\RequestInterface::class) @@ -289,6 +295,9 @@ private function getRequestMock() ->getMock(); } + /** + * @return \PHPUnit_Framework_MockObject_MockObject + */ private function getQueryMock() { return $this->getMockBuilder(QueryInterface::class) @@ -296,6 +305,9 @@ private function getQueryMock() ->getMockForAbstractClass(); } + /** + * @return array + */ private function getDifferentFiltersMock() { $visibilityFilter = $this->getMockBuilder(Term::class) @@ -316,6 +328,9 @@ private function getDifferentFiltersMock() return [$visibilityFilter, $customFilter, $nonCustomFilter]; } + /** + * @return array + */ private function getSameFiltersMock() { $visibilityFilter1 = $this->getMockBuilder(Term::class) diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Ui/DataProvider/Product/Form/Modifier/ProductUrlRewriteTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Ui/DataProvider/Product/Form/Modifier/ProductUrlRewriteTest.php index 763f78ac1fea6..40f7642f35383 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Ui/DataProvider/Product/Form/Modifier/ProductUrlRewriteTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Ui/DataProvider/Product/Form/Modifier/ProductUrlRewriteTest.php @@ -27,6 +27,9 @@ protected function setUp() ->getMockForAbstractClass(); } + /** + * @return \Magento\Ui\DataProvider\Modifier\ModifierInterface|object + */ protected function createModel() { return $this->objectManager->getObject(ProductUrlRewrite::class, [ diff --git a/app/code/Magento/CatalogWidget/Test/Unit/Block/Product/ProductsListTest.php b/app/code/Magento/CatalogWidget/Test/Unit/Block/Product/ProductsListTest.php index 3039066ad1388..5de8b9d9632fc 100644 --- a/app/code/Magento/CatalogWidget/Test/Unit/Block/Product/ProductsListTest.php +++ b/app/code/Magento/CatalogWidget/Test/Unit/Block/Product/ProductsListTest.php @@ -316,6 +316,9 @@ public function testCreateCollection($pagerEnable, $productsCount, $productsPerP $this->assertSame($collection, $this->productsList->createCollection()); } + /** + * @return array + */ public function createCollectionDataProvider() { return [ diff --git a/app/code/Magento/Checkout/Test/Unit/Block/Cart/AbstractCartTest.php b/app/code/Magento/Checkout/Test/Unit/Block/Cart/AbstractCartTest.php index aecaf0ec9f039..1a9c5555c91c0 100644 --- a/app/code/Magento/Checkout/Test/Unit/Block/Cart/AbstractCartTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Block/Cart/AbstractCartTest.php @@ -124,6 +124,9 @@ public function testGetTotalsCache($expectedResult, $isVirtual) $this->assertEquals($expectedResult, $model->getTotalsCache()); } + /** + * @return array + */ public function getTotalsCacheDataProvider() { return [ diff --git a/app/code/Magento/Checkout/Test/Unit/Block/Cart/LinkTest.php b/app/code/Magento/Checkout/Test/Unit/Block/Cart/LinkTest.php index 2478270e0aec6..417c1e4295ea1 100644 --- a/app/code/Magento/Checkout/Test/Unit/Block/Cart/LinkTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Block/Cart/LinkTest.php @@ -82,6 +82,9 @@ public function testGetLabel($productCount, $label) $this->assertSame($label, (string)$block->getLabel()); } + /** + * @return array + */ public function getLabelDataProvider() { return [[1, 'My Cart (1 item)'], [2, 'My Cart (2 items)'], [0, 'My Cart']]; diff --git a/app/code/Magento/Checkout/Test/Unit/Block/LinkTest.php b/app/code/Magento/Checkout/Test/Unit/Block/LinkTest.php index 24065c1f54eb3..7db5d7ecb19fd 100644 --- a/app/code/Magento/Checkout/Test/Unit/Block/LinkTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Block/LinkTest.php @@ -68,6 +68,9 @@ public function testToHtml($canOnepageCheckout, $isOutputEnabled) $this->assertEquals('', $block->toHtml()); } + /** + * @return array + */ public function toHtmlDataProvider() { return [[false, true], [true, false], [false, false]]; diff --git a/app/code/Magento/Checkout/Test/Unit/Block/Onepage/SuccessTest.php b/app/code/Magento/Checkout/Test/Unit/Block/Onepage/SuccessTest.php index 18281494029b6..36d37d07ef752 100644 --- a/app/code/Magento/Checkout/Test/Unit/Block/Onepage/SuccessTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Block/Onepage/SuccessTest.php @@ -153,6 +153,9 @@ public function testToHtmlOrderVisibleOnFront(array $invisibleStatuses, $expecte $this->assertEquals($expectedResult, $this->block->getIsOrderVisible()); } + /** + * @return array + */ public function invisibleStatusesProvider() { return [ diff --git a/app/code/Magento/Checkout/Test/Unit/Controller/Stub/OnepageStub.php b/app/code/Magento/Checkout/Test/Unit/Controller/Stub/OnepageStub.php index 26771c1531267..1a8fecd8356bb 100644 --- a/app/code/Magento/Checkout/Test/Unit/Controller/Stub/OnepageStub.php +++ b/app/code/Magento/Checkout/Test/Unit/Controller/Stub/OnepageStub.php @@ -8,6 +8,9 @@ class OnepageStub extends \Magento\Checkout\Controller\Onepage { + /** + * @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface|void + */ public function execute() { // Empty method stub for test diff --git a/app/code/Magento/Checkout/Test/Unit/Model/CartTest.php b/app/code/Magento/Checkout/Test/Unit/Model/CartTest.php index 40de71e28c05e..6bd0bdf258a0a 100644 --- a/app/code/Magento/Checkout/Test/Unit/Model/CartTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Model/CartTest.php @@ -279,6 +279,9 @@ public function testGetSummaryQty($useQty) $this->assertEquals($itemsCount, $this->cart->getSummaryQty()); } + /** + * @return array + */ public function useQtyDataProvider() { return [ diff --git a/app/code/Magento/Checkout/Test/Unit/Model/Session/SuccessValidatorTest.php b/app/code/Magento/Checkout/Test/Unit/Model/Session/SuccessValidatorTest.php index fec1d6d4d003f..2751a54d2d2fe 100644 --- a/app/code/Magento/Checkout/Test/Unit/Model/Session/SuccessValidatorTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Model/Session/SuccessValidatorTest.php @@ -90,6 +90,11 @@ public function testIsValidTrue() $this->assertTrue($this->createSuccessValidator($checkoutSession)->isValid($checkoutSession)); } + /** + * @param \PHPUnit_Framework_MockObject_MockObject $checkoutSession + * + * @return object + */ protected function createSuccessValidator(\PHPUnit_Framework_MockObject_MockObject $checkoutSession) { return $this->objectManagerHelper->getObject( diff --git a/app/code/Magento/Checkout/Test/Unit/Model/SidebarTest.php b/app/code/Magento/Checkout/Test/Unit/Model/SidebarTest.php index 29537e8ec0526..77b9469285b96 100644 --- a/app/code/Magento/Checkout/Test/Unit/Model/SidebarTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Model/SidebarTest.php @@ -45,6 +45,9 @@ public function testGetResponseData($error, $result) $this->assertEquals($result, $this->sidebar->getResponseData($error)); } + /** + * @return array + */ public function dataProviderGetResponseData() { return [ diff --git a/app/code/Magento/Checkout/Test/Unit/Model/Type/OnepageTest.php b/app/code/Magento/Checkout/Test/Unit/Model/Type/OnepageTest.php index 684ad9264f77c..1733aff33228d 100644 --- a/app/code/Magento/Checkout/Test/Unit/Model/Type/OnepageTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Model/Type/OnepageTest.php @@ -264,6 +264,9 @@ public function testInitCheckout($stepData, $isLoggedIn, $isSetStepDataCalled) $this->onepage->initCheckout(); } + /** + * @return array + */ public function initCheckoutDataProvider() { return [ @@ -296,6 +299,9 @@ public function testGetCheckoutMethod($isLoggedIn, $quoteCheckoutMethod, $isAllo $this->assertEquals($expected, $this->onepage->getCheckoutMethod()); } + /** + * @return array + */ public function getCheckoutMethodDataProvider() { return [ diff --git a/app/code/Magento/Cms/Test/Unit/Block/Adminhtml/Block/Widget/ChooserTest.php b/app/code/Magento/Cms/Test/Unit/Block/Adminhtml/Block/Widget/ChooserTest.php index 97988a5676842..a27110ca96b6d 100644 --- a/app/code/Magento/Cms/Test/Unit/Block/Adminhtml/Block/Widget/ChooserTest.php +++ b/app/code/Magento/Cms/Test/Unit/Block/Adminhtml/Block/Widget/ChooserTest.php @@ -233,6 +233,9 @@ public function testPrepareElementHtml($elementValue, $modelBlockId) $this->assertEquals($this->elementMock, $this->this->prepareElementHtml($this->elementMock)); } + /** + * @return array + */ public function prepareElementHtmlDataProvider() { return [ diff --git a/app/code/Magento/Cms/Test/Unit/Block/Adminhtml/Page/Widget/ChooserTest.php b/app/code/Magento/Cms/Test/Unit/Block/Adminhtml/Page/Widget/ChooserTest.php index 174e3a68b7c66..7b91d54ec3aa1 100644 --- a/app/code/Magento/Cms/Test/Unit/Block/Adminhtml/Page/Widget/ChooserTest.php +++ b/app/code/Magento/Cms/Test/Unit/Block/Adminhtml/Page/Widget/ChooserTest.php @@ -236,6 +236,9 @@ public function testPrepareElementHtml($elementValue, $cmsPageId) $this->assertEquals($this->elementMock, $this->this->prepareElementHtml($this->elementMock)); } + /** + * @return array + */ public function prepareElementHtmlDataProvider() { return [ diff --git a/app/code/Magento/Cms/Test/Unit/Helper/PageTest.php b/app/code/Magento/Cms/Test/Unit/Helper/PageTest.php index 8b41f0e3ac0d4..c50f33caa6bc2 100644 --- a/app/code/Magento/Cms/Test/Unit/Helper/PageTest.php +++ b/app/code/Magento/Cms/Test/Unit/Helper/PageTest.php @@ -367,6 +367,9 @@ public function testPrepareResultPage( ); } + /** + * @return array + */ public function renderPageExtendedDataProvider() { return [ @@ -467,6 +470,9 @@ public function testGetPageUrl( $this->assertEquals($expectedResult, $this->object->getPageUrl($pageId)); } + /** + * @return array + */ public function getPageUrlDataProvider() { return [ diff --git a/app/code/Magento/Cms/Test/Unit/Helper/Wysiwyg/ImagesTest.php b/app/code/Magento/Cms/Test/Unit/Helper/Wysiwyg/ImagesTest.php index 3fba04cd5604d..ba32f41c62f24 100644 --- a/app/code/Magento/Cms/Test/Unit/Helper/Wysiwyg/ImagesTest.php +++ b/app/code/Magento/Cms/Test/Unit/Helper/Wysiwyg/ImagesTest.php @@ -384,6 +384,9 @@ public function testGetCurrentPathThrowException() $this->fail('An expected exception has not been raised.'); } + /** + * @return array + */ public function providerGetCurrentPath() { return [ @@ -431,6 +434,9 @@ public function testGetImageHtmlDeclarationRenderingAsTag($baseUrl, $fileName, $ $this->assertEquals($expectedHtml, $this->imagesHelper->getImageHtmlDeclaration($fileName, true)); } + /** + * @return array + */ public function providerGetImageHtmlDeclarationRenderingAsTag() { return [ @@ -465,6 +471,9 @@ public function testGetImageHtmlDeclaration($baseUrl, $fileName, $isUsingStaticU $this->assertEquals($expectedHtml, $this->imagesHelper->getImageHtmlDeclaration($fileName)); } + /** + * @return array + */ public function providerGetImageHtmlDeclaration() { return [ diff --git a/app/code/Magento/Cms/Test/Unit/Model/ResourceModel/Block/CollectionTest.php b/app/code/Magento/Cms/Test/Unit/Model/ResourceModel/Block/CollectionTest.php index b9b0d6f772c62..26b5d74ffb961 100644 --- a/app/code/Magento/Cms/Test/Unit/Model/ResourceModel/Block/CollectionTest.php +++ b/app/code/Magento/Cms/Test/Unit/Model/ResourceModel/Block/CollectionTest.php @@ -119,6 +119,9 @@ public function testAfterLoad($item, $storesData) $this->assertEquals($expectedResult[$item->getId()], $item->getStoreId()); } + /** + * @return array + */ public function getItemsDataProvider() { return [ diff --git a/app/code/Magento/Cms/Test/Unit/Model/ResourceModel/Page/CollectionTest.php b/app/code/Magento/Cms/Test/Unit/Model/ResourceModel/Page/CollectionTest.php index dd31650cb3a3a..6d45e7bf6ab1d 100644 --- a/app/code/Magento/Cms/Test/Unit/Model/ResourceModel/Page/CollectionTest.php +++ b/app/code/Magento/Cms/Test/Unit/Model/ResourceModel/Page/CollectionTest.php @@ -119,6 +119,9 @@ public function testAfterLoad($item, $storesData) $this->assertEquals($expectedResult[$item->getId()], $item->getStoreId()); } + /** + * @return array + */ public function getItemsDataProvider() { return [ diff --git a/app/code/Magento/Cms/Test/Unit/Model/Wysiwyg/ConfigTest.php b/app/code/Magento/Cms/Test/Unit/Model/Wysiwyg/ConfigTest.php index d633c5a21fe32..7a5a6fe7b0c8c 100644 --- a/app/code/Magento/Cms/Test/Unit/Model/Wysiwyg/ConfigTest.php +++ b/app/code/Magento/Cms/Test/Unit/Model/Wysiwyg/ConfigTest.php @@ -187,6 +187,9 @@ public function testGetConfig($data, $isAuthorizationAllowed, $expectedResults) $this->assertEquals('localhost/pub/static/', $config->getData('baseStaticDefaultUrl')); } + /** + * @return array + */ public function getConfigDataProvider() { return [ diff --git a/app/code/Magento/Cms/Test/Unit/Observer/NoCookiesObserverTest.php b/app/code/Magento/Cms/Test/Unit/Observer/NoCookiesObserverTest.php index 8c09d42ec556e..cbb13c6f254eb 100644 --- a/app/code/Magento/Cms/Test/Unit/Observer/NoCookiesObserverTest.php +++ b/app/code/Magento/Cms/Test/Unit/Observer/NoCookiesObserverTest.php @@ -139,6 +139,9 @@ public function testNoCookies($pageUrl) $this->assertEquals($this->noCookiesObserver, $this->noCookiesObserver->execute($this->observerMock)); } + /** + * @return array + */ public function noCookiesDataProvider() { return [ diff --git a/app/code/Magento/Config/Test/Unit/Block/System/Config/DwstreeTest.php b/app/code/Magento/Config/Test/Unit/Block/System/Config/DwstreeTest.php index d3750022d93de..1cb393b212199 100644 --- a/app/code/Magento/Config/Test/Unit/Block/System/Config/DwstreeTest.php +++ b/app/code/Magento/Config/Test/Unit/Block/System/Config/DwstreeTest.php @@ -121,6 +121,9 @@ public function testInitTabs($section, $website, $store) ); } + /** + * @return array + */ public function initTabsDataProvider() { return [ diff --git a/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Field/Select/AllowspecificTest.php b/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Field/Select/AllowspecificTest.php index be3b8e2ead0c1..f5c65e848b3bf 100644 --- a/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Field/Select/AllowspecificTest.php +++ b/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Field/Select/AllowspecificTest.php @@ -85,6 +85,9 @@ public function testGetHtmlWhenValueIsEmpty($value) $this->assertNotEmpty($this->_object->getHtml()); } + /** + * @return array + */ public function getHtmlWhenValueIsEmptyDataProvider() { return [ diff --git a/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Fieldset/Modules/DisableOutputTest.php b/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Fieldset/Modules/DisableOutputTest.php index 9d76363213d0b..bb109bcb25f06 100644 --- a/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Fieldset/Modules/DisableOutputTest.php +++ b/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Fieldset/Modules/DisableOutputTest.php @@ -224,6 +224,9 @@ public function testRender($expanded, $nested, $extra) } } + /** + * @return array + */ public function renderDataProvider() { return [ diff --git a/app/code/Magento/Config/Test/Unit/Block/System/Config/FormTest.php b/app/code/Magento/Config/Test/Unit/Block/System/Config/FormTest.php index 72e8386bddaf6..83b7bd5fda42e 100644 --- a/app/code/Magento/Config/Test/Unit/Block/System/Config/FormTest.php +++ b/app/code/Magento/Config/Test/Unit/Block/System/Config/FormTest.php @@ -224,6 +224,9 @@ public function testInitForm($sectionIsVisible) $this->assertEquals($this->_formMock, $object->getForm()); } + /** + * @return array + */ public function initFormDataProvider() { return [ @@ -337,6 +340,9 @@ public function testInitGroup($shouldCloneFields, $prefixes, $callNum) $object->initForm(); } + /** + * @return array + */ public function initGroupDataProvider() { return [ diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Backend/Email/AddressTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Backend/Email/AddressTest.php index bacbda537fb1d..e6b774db041c3 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Backend/Email/AddressTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Backend/Email/AddressTest.php @@ -40,6 +40,9 @@ public function testBeforeSave($value, $expectedValue) $this->assertEquals($expectedValue, $this->model->getValue()); } + /** + * @return array + */ public function beforeSaveDataProvider() { return [ diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Backend/Email/SenderTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Backend/Email/SenderTest.php index 8e559ff8284ed..e38c247c3861a 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Backend/Email/SenderTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Backend/Email/SenderTest.php @@ -41,6 +41,9 @@ public function testBeforeSave($value, $expectedValue) $this->assertEquals($expectedValue, $this->model->getValue()); } + /** + * @return array + */ public function beforeSaveDataProvider() { return [ diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Backend/SerializedTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Backend/SerializedTest.php index 493fdf9505c4c..bb1e0e0225901 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Backend/SerializedTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Backend/SerializedTest.php @@ -52,6 +52,9 @@ public function testAfterLoad($expected, $value, $numCalls, $unserializedValue = $this->assertEquals($expected, $this->serializedConfig->getValue()); } + /** + * @return array + */ public function afterLoadDataProvider() { return [ @@ -87,6 +90,9 @@ public function testBeforeSave($expected, $value, $numCalls, $serializedValue = $this->assertEquals($expected, $this->serializedConfig->getValue()); } + /** + * @return array + */ public function beforeSaveDataProvider() { return [ diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/AbstractElementTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/AbstractElementTest.php index 51432366bb441..e602e0407feff 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/AbstractElementTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/AbstractElementTest.php @@ -141,6 +141,9 @@ public function testIsVisibleReturnsTrueForProperScopes($settings, $scope) $this->assertTrue($this->_model->isVisible()); } + /** + * @return array + */ public function isVisibleReturnsTrueForProperScopesDataProvider() { return [ @@ -170,6 +173,9 @@ public function testIsVisibleReturnsFalseForNonProperScopes($settings, $scope) $this->assertFalse($this->_model->isVisible()); } + /** + * @return array + */ public function isVisibleReturnsFalseForNonProperScopesDataProvider() { return [ diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/Dependency/FieldTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/Dependency/FieldTest.php index 30c567fb490e6..750a829eef7ec 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/Dependency/FieldTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/Dependency/FieldTest.php @@ -88,6 +88,9 @@ public function testIsNegative($data, $isNegative) $this->assertEquals($isNegative, $this->_getFieldObject($data, $isNegative)->isNegative()); } + /** + * @return array + */ public function dataProvider() { return [ @@ -110,6 +113,9 @@ public function testIsValueSatisfy($data, $isNegative, $value, $expected) $this->assertEquals($expected, $this->_getFieldObject($data, $isNegative)->isValueSatisfy($value)); } + /** + * @return array + */ public function isValueSatisfyDataProvider() { return [ @@ -135,6 +141,9 @@ public function testGetValues($data, $isNegative, $expected) $this->assertEquals($expected, $this->_getFieldObject($data, $isNegative)->getValues()); } + /** + * @return array + */ public function getValuesDataProvider() { $complexDataValues = [self::COMPLEX_VALUE1, self::COMPLEX_VALUE2, self::COMPLEX_VALUE3]; diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/Dependency/MapperTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/Dependency/MapperTest.php index 2f081ea4285b9..c6cd03cf8f35b 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/Dependency/MapperTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/Dependency/MapperTest.php @@ -150,6 +150,9 @@ public function testGetDependenciesWhenDependentIsInvisible($isValueSatisfy) $this->assertEquals($expected, $actual); } + /** + * @return array + */ public function getDependenciesDataProvider() { return [[true], [false]]; diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/IteratorTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/IteratorTest.php index 1a0f3d03b060c..dcb7a90e55290 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/IteratorTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/IteratorTest.php @@ -68,6 +68,9 @@ public function testIsLast($elementId, $result) $this->assertEquals($result, $this->_model->isLast($elementMock)); } + /** + * @return array + */ public function isLastDataProvider() { return [[1, false], [2, false], [3, true]]; diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Mapper/ExtendsTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Mapper/ExtendsTest.php index 95e8246c6a3d3..7762c8993b24b 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Mapper/ExtendsTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Mapper/ExtendsTest.php @@ -44,6 +44,9 @@ public function testMapWithBadPath() $this->_sut->map($sourceData); } + /** + * @return array + */ public function mapDataProvider() { return [ @@ -55,6 +58,9 @@ public function mapDataProvider() ]; } + /** + * @return array + */ protected function _emptySectionsNodeData() { $data = ['config' => ['system' => ['sections' => 'some_non_array']]]; @@ -62,6 +68,9 @@ protected function _emptySectionsNodeData() return [$data, $data]; } + /** + * @return array + */ protected function _extendFromASiblingData() { $source = $result = [ @@ -81,6 +90,9 @@ protected function _extendFromASiblingData() return [$source, $result]; } + /** + * @return array + */ protected function _extendFromNodeOnHigherLevelData() { $source = $result = [ @@ -114,6 +126,9 @@ protected function _extendFromNodeOnHigherLevelData() return [$source, $result]; } + /** + * @return array + */ protected function _extendWithMerge() { $source = $result = [ diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Mapper/Helper/RelativePathConverterTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Mapper/Helper/RelativePathConverterTest.php index 058f9a380a27d..dd95574ffa62d 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Mapper/Helper/RelativePathConverterTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Mapper/Helper/RelativePathConverterTest.php @@ -52,11 +52,17 @@ public function testConvert($nodePath, $relativePath, $result) $this->assertEquals($result, $this->_sut->convert($nodePath, $relativePath)); } + /** + * @return array + */ public function convertWithInvalidArgumentsDataProvider() { return [['', ''], ['some/node', ''], ['', 'some/node']]; } + /** + * @return array + */ public function convertDataProvider() { return [ diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/StructureTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/StructureTest.php index e67ea6ec0fba1..6c059f4b69b70 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/StructureTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/StructureTest.php @@ -221,6 +221,9 @@ private function getElementReturnsEmptyElementIfNotExistingElementIsRequested( return $elementMock; } + /** + * @return array + */ public function emptyElementDataProvider() { return [ @@ -389,6 +392,9 @@ public function testGetFieldPathsByAttribute($attributeName, $attributeValue, $p $this->assertEquals($paths, $this->_model->getFieldPathsByAttribute($attributeName, $attributeValue)); } + /** + * @return array + */ public function getFieldPathsByAttributeDataProvider() { return [ diff --git a/app/code/Magento/Config/Test/Unit/Model/Placeholder/EnvironmentTest.php b/app/code/Magento/Config/Test/Unit/Model/Placeholder/EnvironmentTest.php index 8217ff09c0541..e4c01e794fb0f 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Placeholder/EnvironmentTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Placeholder/EnvironmentTest.php @@ -52,6 +52,9 @@ public function testGenerate($path, $scope, $scopeId, $expected) ); } + /** + * @return array + */ public function getGenerateDataProvider() { return [ diff --git a/app/code/Magento/ConfigurableImportExport/Test/Unit/Model/Import/Product/Type/ConfigurableTest.php b/app/code/Magento/ConfigurableImportExport/Test/Unit/Model/Import/Product/Type/ConfigurableTest.php index 54552364de13b..1ff78ed89709a 100644 --- a/app/code/Magento/ConfigurableImportExport/Test/Unit/Model/Import/Product/Type/ConfigurableTest.php +++ b/app/code/Magento/ConfigurableImportExport/Test/Unit/Model/Import/Product/Type/ConfigurableTest.php @@ -392,6 +392,9 @@ protected function _getBunch() ]; } + /** + * @return array + */ protected function _getSuperAttributes() { return [ diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Adminhtml/Product/Steps/SelectAttributesTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Adminhtml/Product/Steps/SelectAttributesTest.php index 040329dbb3d87..33b87467950fd 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Adminhtml/Product/Steps/SelectAttributesTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Adminhtml/Product/Steps/SelectAttributesTest.php @@ -114,6 +114,9 @@ public function testGetAddNewAttributeButton($isAllowed, $result) $this->assertEquals($result, $this->selectAttributes->getAddNewAttributeButton()); } + /** + * @return array + */ public function attributesDataProvider() { return [ diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Attribute/LockValidatorTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Attribute/LockValidatorTest.php index 090c464d49307..3565aba66427c 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Attribute/LockValidatorTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Attribute/LockValidatorTest.php @@ -108,6 +108,11 @@ public function testValidateException() $this->validate(true); } + /** + * @param $exception + * + * @throws \Magento\Framework\Exception\LocalizedException + */ public function validate($exception) { $attrTable = 'someAttributeTable'; diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/OptionRepositoryTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/OptionRepositoryTest.php index ab3fd33322aa5..7991d8fececb4 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/OptionRepositoryTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/OptionRepositoryTest.php @@ -389,6 +389,9 @@ public function testValidateNewOptionData($attributeId, $label, $optionValues, $ $this->model->validateNewOptionData($optionMock); } + /** + * @return array + */ public function validateOptionDataProvider() { return [ diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Observer/HideUnsupportedAttributeTypesTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Observer/HideUnsupportedAttributeTypesTest.php index 3bad81126f510..114fb7168ab33 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Observer/HideUnsupportedAttributeTypesTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Observer/HideUnsupportedAttributeTypesTest.php @@ -59,6 +59,12 @@ private function createTarget(\PHPUnit_Framework_MockObject_MockObject $request, ); } + /** + * @param $popup + * @param string $productTab + * + * @return MockObject + */ private function createRequestMock($popup, $productTab = 'variations') { $request = $this->getMockBuilder(RequestInterface::class) @@ -107,6 +113,9 @@ public function testExecuteWithDefaultTypes(array $supportedTypes, array $origin $this->assertEquals(null, $target->execute($event)); } + /** + * @return array + */ public function executeDataProvider() { return [ @@ -143,11 +152,23 @@ public function executeDataProvider() ]; } + /** + * @param $value + * @param $label + * + * @return array + */ private function createFrontendInputValue($value, $label) { return ['value' => $value, 'label' => $label]; } + /** + * @param array $originalValues + * @param array $expectedValues + * + * @return MockObject + */ private function createForm(array $originalValues = [], array $expectedValues = []) { $form = $this->getMockBuilder(\Magento\Framework\Data\Form::class) diff --git a/app/code/Magento/Contact/Test/Unit/Controller/Index/PostTest.php b/app/code/Magento/Contact/Test/Unit/Controller/Index/PostTest.php index 0213173737b9b..f01922f42f40c 100644 --- a/app/code/Magento/Contact/Test/Unit/Controller/Index/PostTest.php +++ b/app/code/Magento/Contact/Test/Unit/Controller/Index/PostTest.php @@ -144,6 +144,9 @@ public function testExecutePostValidation($postData, $exceptionExpected) $this->controller->execute(); } + /** + * @return array + */ public function postDataProvider() { return [ diff --git a/app/code/Magento/Contact/Test/Unit/Controller/Stub/IndexStub.php b/app/code/Magento/Contact/Test/Unit/Controller/Stub/IndexStub.php index a238daafaafaf..cabcebda061f9 100644 --- a/app/code/Magento/Contact/Test/Unit/Controller/Stub/IndexStub.php +++ b/app/code/Magento/Contact/Test/Unit/Controller/Stub/IndexStub.php @@ -8,6 +8,9 @@ class IndexStub extends \Magento\Contact\Controller\Index { + /** + * @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface|void + */ public function execute() { // Empty method stub for test diff --git a/app/code/Magento/Cookie/Test/Unit/Helper/CookieTest.php b/app/code/Magento/Cookie/Test/Unit/Helper/CookieTest.php index 5694f3f3cab56..62ce6baf6c101 100644 --- a/app/code/Magento/Cookie/Test/Unit/Helper/CookieTest.php +++ b/app/code/Magento/Cookie/Test/Unit/Helper/CookieTest.php @@ -79,6 +79,9 @@ public function testGetCookieRestrictionLifetime() $this->assertEquals($this->_object->getCookieRestrictionLifetime(), 60 * 60 * 24 * 365); } + /** + * @return $this + */ protected function _initMock() { $scopeConfig = $this->_getConfigStub(); diff --git a/app/code/Magento/CurrencySymbol/Test/Unit/Model/System/CurrencysymbolTest.php b/app/code/Magento/CurrencySymbol/Test/Unit/Model/System/CurrencysymbolTest.php index 453a06651f354..0ae099fd78edc 100644 --- a/app/code/Magento/CurrencySymbol/Test/Unit/Model/System/CurrencysymbolTest.php +++ b/app/code/Magento/CurrencySymbol/Test/Unit/Model/System/CurrencysymbolTest.php @@ -236,6 +236,9 @@ public function testGetCurrencySymbol( $this->assertEquals($expectedSymbol, $currencySymbol); } + /** + * @return array + */ public function getCurrencySymbolDataProvider() { return [ diff --git a/app/code/Magento/Customer/Test/Unit/Block/Account/AuthenticationPopupTest.php b/app/code/Magento/Customer/Test/Unit/Block/Account/AuthenticationPopupTest.php index b43b1d1aa39a9..618173e886e66 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Account/AuthenticationPopupTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Account/AuthenticationPopupTest.php @@ -128,6 +128,9 @@ public function testGetConfig($isAutocomplete, $baseUrl, $registerUrl, $forgotUr $this->assertEquals($result, $this->model->getConfig()); } + /** + * @return array + */ public function dataProviderGetConfig() { return [ diff --git a/app/code/Magento/Customer/Test/Unit/Block/Account/CustomerTest.php b/app/code/Magento/Customer/Test/Unit/Block/Account/CustomerTest.php index 6489fea91e43e..793975c0b3191 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Account/CustomerTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Account/CustomerTest.php @@ -22,6 +22,9 @@ protected function setUp() ->getObject(\Magento\Customer\Block\Account\Customer::class, ['httpContext' => $this->httpContext]); } + /** + * @return array + */ public function customerLoggedInDataProvider() { return [ diff --git a/app/code/Magento/Customer/Test/Unit/Block/Account/Dashboard/InfoTest.php b/app/code/Magento/Customer/Test/Unit/Block/Account/Dashboard/InfoTest.php index 02d31d69e73df..ec84f53b7584e 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Account/Dashboard/InfoTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Account/Dashboard/InfoTest.php @@ -204,6 +204,9 @@ public function testIsNewsletterEnabled($isNewsletterEnabled, $expectedValue) $this->assertEquals($expectedValue, $this->_block->isNewsletterEnabled()); } + /** + * @return array + */ public function isNewsletterEnabledProvider() { return [[true, true], [false, false]]; diff --git a/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/View/Grid/Renderer/ItemTest.php b/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/View/Grid/Renderer/ItemTest.php index c12da66cdc616..92c2bcfeb8e59 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/View/Grid/Renderer/ItemTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/View/Grid/Renderer/ItemTest.php @@ -14,6 +14,10 @@ class ItemTest extends \PHPUnit\Framework\TestCase /** @var \Magento\Customer\Block\Adminhtml\Edit\Tab\View\Grid\Renderer\Item */ protected $itemBlock; + /** + * @param $amountOption + * @param bool $withoutOptions + */ public function configure($amountOption, $withoutOptions = false) { $options = []; @@ -95,6 +99,9 @@ public function testRender($amountOption, $expectedHtml) $this->assertXmlStringEqualsXmlString($expectedHtml, $realHtml); } + /** + * @return array + */ public function optionHtmlProvider() { return [ diff --git a/app/code/Magento/Customer/Test/Unit/Block/Widget/NameTest.php b/app/code/Magento/Customer/Test/Unit/Block/Widget/NameTest.php index 3f174484df3e1..6ffe0da0c663e 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Widget/NameTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Widget/NameTest.php @@ -159,6 +159,9 @@ public function testMethodWithNoSuchEntityException($method) $this->assertFalse($this->_block->{$method}()); } + /** + * @return array + */ public function methodDataProvider() { return [ diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Account/CreatePostTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Account/CreatePostTest.php index 759d5f661c509..d9bf6a435ac15 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Account/CreatePostTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Account/CreatePostTest.php @@ -529,6 +529,9 @@ public function testSuccessRedirect( $this->model->execute(); } + /** + * @return array + */ public function getSuccessRedirectDataProvider() { return [ diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Address/FormPostTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Address/FormPostTest.php index 2b5438991b113..4ad1b5cbc96bd 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Address/FormPostTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Address/FormPostTest.php @@ -578,6 +578,9 @@ public function testExecute( $this->assertEquals($this->resultRedirect, $this->model->execute()); } + /** + * @return array + */ public function dataProviderTestExecute() { return [ diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/InlineEditTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/InlineEditTest.php index 22c5003544bed..913c41070856e 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/InlineEditTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/InlineEditTest.php @@ -164,6 +164,9 @@ protected function setUp() ]; } + /** + * @param int $populateSequence + */ protected function prepareMocksForTesting($populateSequence = 0) { $this->resultJsonFactory->expects($this->once()) diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Section/LoadTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Section/LoadTest.php index 2552beeca463d..8fc4df1515b94 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Section/LoadTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Section/LoadTest.php @@ -123,6 +123,9 @@ public function testExecute($sectionNames, $updateSectionID, $sectionNamesAsArra $this->loadAction->execute(); } + /** + * @return array + */ public function executeDataProvider() { return [ diff --git a/app/code/Magento/Customer/Test/Unit/CustomerData/Plugin/SessionCheckerTest.php b/app/code/Magento/Customer/Test/Unit/CustomerData/Plugin/SessionCheckerTest.php index a4246b6398fd1..5beea22bda3d7 100644 --- a/app/code/Magento/Customer/Test/Unit/CustomerData/Plugin/SessionCheckerTest.php +++ b/app/code/Magento/Customer/Test/Unit/CustomerData/Plugin/SessionCheckerTest.php @@ -86,6 +86,9 @@ public function testBeforeStart($result, $callCount) $this->plugin->beforeStart($this->sessionManager); } + /** + * @return array + */ public function beforeStartDataProvider() { return [ diff --git a/app/code/Magento/Customer/Test/Unit/Helper/AddressTest.php b/app/code/Magento/Customer/Test/Unit/Helper/AddressTest.php index 50785247d7965..b2aa3161b36bf 100644 --- a/app/code/Magento/Customer/Test/Unit/Helper/AddressTest.php +++ b/app/code/Magento/Customer/Test/Unit/Helper/AddressTest.php @@ -78,6 +78,9 @@ public function testGetStreetLines($numLines, $expectedNumLines) $this->assertEquals($expectedNumLines, $this->helper->getStreetLines()); } + /** + * @return array + */ public function providerGetStreetLines() { return [ @@ -190,6 +193,9 @@ public function testConvertStreetLines($origStreets, $toCount, $result) $this->assertEquals($result, $this->helper->convertStreetLines($origStreets, $toCount)); } + /** + * @return array + */ public function getConvertStreetLinesDataProvider() { return [ @@ -330,6 +336,9 @@ public function testGetFormatTypeRenderer($code, $result) $this->assertEquals($result, $this->helper->getFormatTypeRenderer($code)); } + /** + * @return array + */ public function getFormatTypeRendererDataProvider() { $renderer = $this->getMockBuilder(\Magento\Customer\Block\Address\Renderer\RendererInterface::class) @@ -366,6 +375,9 @@ public function testGetFormat($code, $result) $this->assertEquals($result, $this->helper->getFormat($code)); } + /** + * @return array + */ public function getFormatDataProvider() { return [ @@ -396,6 +408,9 @@ public function testIsAttributeVisible($attributeCode, $isMetadataExists) $this->assertEquals($isMetadataExists, $this->helper->isAttributeVisible($attributeCode)); } + /** + * @return array + */ public function isAttributeVisibleDataProvider() { return [ diff --git a/app/code/Magento/Customer/Test/Unit/Model/Address/Config/XsdTest.php b/app/code/Magento/Customer/Test/Unit/Model/Address/Config/XsdTest.php index 1b013a913b9f8..c64f7aca96fe6 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Address/Config/XsdTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Address/Config/XsdTest.php @@ -39,6 +39,9 @@ public function testExemplarXml($fixtureXml, array $expectedErrors) $this->assertEquals($expectedErrors, $actualErrors); } + /** + * @return array + */ public function exemplarXmlDataProvider() { return [ diff --git a/app/code/Magento/Customer/Test/Unit/Model/AttributeCheckerTest.php b/app/code/Magento/Customer/Test/Unit/Model/AttributeCheckerTest.php index 480f5be96e318..8454b793cf5ff 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/AttributeCheckerTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/AttributeCheckerTest.php @@ -75,6 +75,9 @@ public function testIsAttributeAllowedOnForm( $this->assertEquals($isAllowed, $this->model->isAttributeAllowedOnForm($attributeCode, $formName)); } + /** + * @return array + */ public function attributeOnFormDataProvider() { return [ diff --git a/app/code/Magento/Customer/Test/Unit/Model/AuthenticationTest.php b/app/code/Magento/Customer/Test/Unit/Model/AuthenticationTest.php index ee788913373e5..14adc7bcf8795 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/AuthenticationTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/AuthenticationTest.php @@ -196,6 +196,9 @@ public function testProcessAuthenticationFailureFirstAttempt( $this->authentication->processAuthenticationFailure($customerId); } + /** + * @return array + */ public function processAuthenticationFailureDataProvider() { return [ diff --git a/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/PasswordTest.php b/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/PasswordTest.php index 9a9449a64ecbd..368e7cfd47f2f 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/PasswordTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/PasswordTest.php @@ -39,6 +39,9 @@ public function testValidatePositive() $this->assertTrue($this->testable->validate($object)); } + /** + * @return array + */ public function passwordNegativeDataProvider() { return [ diff --git a/app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php b/app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php index 029949c5f35b0..f3070c46ebb7b 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php @@ -493,6 +493,9 @@ private function attributeGetUsingMethodCallback() }; } + /** + * @return \PHPUnit_Framework_MockObject_MockObject + */ private function getCountryAttrMock() { $countryByWebsiteMock = $this->getMockBuilder(CountryWithWebsites::class) diff --git a/app/code/Magento/Customer/Test/Unit/Model/FileProcessorTest.php b/app/code/Magento/Customer/Test/Unit/Model/FileProcessorTest.php index f2db8c6cab6be..dc7cfbef3fa03 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/FileProcessorTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/FileProcessorTest.php @@ -71,6 +71,12 @@ protected function setUp() ->getMock(); } + /** + * @param $entityTypeCode + * @param array $allowedExtensions + * + * @return FileProcessor + */ private function getModel($entityTypeCode, array $allowedExtensions = []) { $model = new FileProcessor( diff --git a/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/AbstractDataTest.php b/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/AbstractDataTest.php index b9f8564d3616a..e4dc22ba40e31 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/AbstractDataTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/AbstractDataTest.php @@ -94,6 +94,9 @@ public function testSetRequestScopeOnly($bool) $this->assertSame($bool, $this->_model->isRequestScopeOnly()); } + /** + * @return array + */ public function trueFalseDataProvider() { return [[true], [false]]; @@ -122,6 +125,9 @@ public function testApplyInputFilter($input, $output, $filter) $this->assertEquals($output, $this->_model->applyInputFilter($input)); } + /** + * @return array + */ public function applyInputFilterProvider() { return [ @@ -160,6 +166,9 @@ public function testDateFilterFormat($format, $output) $this->assertEquals($output, $actual); } + /** + * @return array + */ public function dateFilterFormatProvider() { return [[null, 'Whatever I put'], [false, self::MODEL], ['something else', self::MODEL]]; @@ -231,6 +240,9 @@ public function testValidateInputRule($value, $label, $inputValidation, $expecte $this->assertEquals($expectedOutput, $this->_model->validateInputRule($value)); } + /** + * @return array + */ public function validateInputRuleDataProvider() { return [ @@ -319,6 +331,9 @@ public function testGetRequestValue($request, $attributeCode, $requestScope, $re $this->assertEquals($expectedValue, $this->_model->getRequestValue($request)); } + /** + * @return array + */ public function getRequestValueDataProvider() { $expectedValue = 'EXPECTED_VALUE'; diff --git a/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/BooleanTest.php b/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/BooleanTest.php index 4315340d65bff..d9f101b922cc8 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/BooleanTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/BooleanTest.php @@ -28,6 +28,9 @@ public function testGetOptionText($value, $expected) $this->assertSame($expected, (string)$boolean->outputValue()); } + /** + * @return array + */ public function getOptionTextDataProvider() { return [ diff --git a/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/DateTest.php b/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/DateTest.php index 2c09555374aef..6329970e0ca9c 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/DateTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/DateTest.php @@ -112,6 +112,9 @@ public function testValidateValue($value, $validation, $required, $expected) $this->assertEquals($expected, $actual); } + /** + * @return array + */ public function validateValueDataProvider() { return [ @@ -163,6 +166,9 @@ public function testCompactValue($value, $expected) $this->assertSame($expected, $this->date->compactValue($value)); } + /** + * @return array + */ public function compactAndRestoreValueDataProvider() { return [ diff --git a/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/FileTest.php b/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/FileTest.php index 97452b995ba0b..1cffaa6fe0379 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/FileTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/FileTest.php @@ -118,6 +118,9 @@ public function testExtractValueNoRequestScope($expected, $attributeCode = '', $ } } + /** + * @return array + */ public function extractValueNoRequestScopeDataProvider() { return [ @@ -178,6 +181,9 @@ public function testExtractValueWithRequestScope($expected, $requestScope, $main } } + /** + * @return array + */ public function extractValueWithRequestScopeDataProvider() { return [ @@ -228,6 +234,9 @@ public function testValidateValueNotToUpload($expected, $value, $isAjax = false, $this->assertEquals($expected, $model->validateValue($value)); } + /** + * @return array + */ public function validateValueNotToUploadDataProvider() { return [ @@ -285,6 +294,9 @@ public function testValidateValueToUpload($expected, $value, $parameters = []) $this->assertEquals($expected, $model->validateValue($value)); } + /** + * @return array + */ public function validateValueToUploadDataProvider() { return [ @@ -429,6 +441,9 @@ public function testOutputValueNonJson($format) $this->assertSame('', $model->outputValue($format)); } + /** + * @return array + */ public function outputValueDataProvider() { return [ diff --git a/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/MultilineTest.php b/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/MultilineTest.php index 25f10d7bb93c6..e74ddebdb597b 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/MultilineTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/MultilineTest.php @@ -42,6 +42,9 @@ public function testValidateValueRequired($value, $expected) parent::testValidateValueRequired($value, $expected); } + /** + * @return array + */ public function validateValueRequiredDataProvider() { return array_merge( @@ -66,6 +69,9 @@ public function testValidateValueLength($value, $expected) parent::testValidateValueLength($value, $expected); } + /** + * @return array + */ public function validateValueLengthDataProvider() { return array_merge( diff --git a/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/SelectTest.php b/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/SelectTest.php index c8564df6b086f..5861ef1f93784 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/SelectTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/SelectTest.php @@ -42,6 +42,9 @@ public function testValidateValue($value, $expected) $this->assertEquals($expected, $actual); } + /** + * @return array + */ public function validateValueDataProvider() { return [ @@ -74,6 +77,9 @@ public function testValidateValueRequired($value, $expected) } } + /** + * @return array + */ public function validateValueRequiredDataProvider() { return [ @@ -145,6 +151,9 @@ public function testOutputValue($value, $expected) $this->assertEquals($expected, $actual); } + /** + * @return array + */ public function outputValueDataProvider() { return [ diff --git a/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/TextTest.php b/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/TextTest.php index 9a3e1c1d8a7cb..b95987cba1dcf 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/TextTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/TextTest.php @@ -52,6 +52,9 @@ public function testValidateValue($value, $expected) $this->assertEquals($expected, $actual); } + /** + * @return array + */ public function validateValueDataProvider() { return [ @@ -84,6 +87,9 @@ public function testValidateValueRequired($value, $expected) } } + /** + * @return array + */ public function validateValueRequiredDataProvider() { return [ @@ -150,6 +156,9 @@ public function testValidateValueLength($value, $expected) } } + /** + * @return array + */ public function validateValueLengthDataProvider() { return [ diff --git a/app/code/Magento/Customer/Test/Unit/Model/Metadata/ValidatorTest.php b/app/code/Magento/Customer/Test/Unit/Model/Metadata/ValidatorTest.php index bef2db9bf2694..354932b0ede0b 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Metadata/ValidatorTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Metadata/ValidatorTest.php @@ -79,6 +79,9 @@ public function testIsValid($isValid) $this->assertEquals($isValid, $this->validator->isValid(new \Magento\Framework\DataObject($data))); } + /** + * @return array + */ public function trueFalseDataProvider() { return [[true], [false]]; diff --git a/app/code/Magento/Customer/Test/Unit/Model/Renderer/RegionTest.php b/app/code/Magento/Customer/Test/Unit/Model/Renderer/RegionTest.php index 759c823eec7f9..c655ff7056ed6 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Renderer/RegionTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Renderer/RegionTest.php @@ -90,6 +90,9 @@ public function testRender($regionCollection) $this->assertContains('required-entry', $html); } + /** + * @return array + */ public function renderDataProvider() { return [ diff --git a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/AddressTest.php b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/AddressTest.php index 723ce6fa1826a..466d44c58ca3f 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/AddressTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/AddressTest.php @@ -227,6 +227,9 @@ protected function prepareValidatorFactory() return $validatorFactory; } + /** + * @return \Magento\Customer\Model\CustomerFactory|\PHPUnit_Framework_MockObject_MockObject + */ protected function prepareCustomerFactory() { $this->customerFactory = $this->createPartialMock(\Magento\Customer\Model\CustomerFactory::class, ['create']); @@ -248,16 +251,27 @@ class SubResourceModelAddress extends \Magento\Customer\Model\ResourceModel\Addr { protected $attributeLoader; + /** + * @param null $object + * + * @return \Magento\Customer\Model\ResourceModel\Address|\Magento\Eav\Model\Entity\AbstractEntity + */ public function loadAllAttributes($object = null) { return $this->getAttributeLoader()->loadAllAttributes($this, $object); } + /** + * @param $attributeLoader + */ public function setAttributeLoader($attributeLoader) { $this->attributeLoader = $attributeLoader; } + /** + * @return \Magento\Eav\Model\Entity\AttributeLoaderInterface + */ protected function getAttributeLoader() { return $this->attributeLoader; diff --git a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Group/Grid/ServiceCollectionTest.php b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Group/Grid/ServiceCollectionTest.php index 61081e1aaf224..76651f9f07589 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Group/Grid/ServiceCollectionTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Group/Grid/ServiceCollectionTest.php @@ -227,6 +227,9 @@ public function testAddFieldToFilterInconsistentArrays($fields, $conditions) $this->serviceCollection->addFieldToFilter($fields, $conditions); } + /** + * @return array + */ public function addFieldToFilterInconsistentArraysDataProvider() { return [ diff --git a/app/code/Magento/Customer/Test/Unit/Observer/AfterAddressSaveObserverTest.php b/app/code/Magento/Customer/Test/Unit/Observer/AfterAddressSaveObserverTest.php index 939e2856f5eaa..8592d1bda66c1 100644 --- a/app/code/Magento/Customer/Test/Unit/Observer/AfterAddressSaveObserverTest.php +++ b/app/code/Magento/Customer/Test/Unit/Observer/AfterAddressSaveObserverTest.php @@ -411,6 +411,9 @@ public function testAfterAddressSaveDefaultGroup( $this->model->execute($observer); } + /** + * @return array + */ public function dataProviderAfterAddressSaveDefaultGroup() { return [ @@ -600,6 +603,9 @@ public function testAfterAddressSaveNewGroup( $this->model->execute($observer); } + /** + * @return array + */ public function dataProviderAfterAddressSaveNewGroup() { return [ diff --git a/app/code/Magento/Deploy/Test/Unit/Console/Command/App/ConfigStatusCommandTest.php b/app/code/Magento/Deploy/Test/Unit/Console/Command/App/ConfigStatusCommandTest.php index 7822e75930eba..737ad55d5e09b 100644 --- a/app/code/Magento/Deploy/Test/Unit/Console/Command/App/ConfigStatusCommandTest.php +++ b/app/code/Magento/Deploy/Test/Unit/Console/Command/App/ConfigStatusCommandTest.php @@ -57,6 +57,9 @@ public function testExecute(bool $hasChanges, $expectedMessage, $expectedCode) $this->assertSame($expectedCode, $tester->getStatusCode()); } + /** + * @return array + */ public function executeDataProvider() { return [ diff --git a/app/code/Magento/Deploy/Test/Unit/Service/DeployStaticContentTest.php b/app/code/Magento/Deploy/Test/Unit/Service/DeployStaticContentTest.php index 3fe1c9800a730..75edc8cb4f6ee 100644 --- a/app/code/Magento/Deploy/Test/Unit/Service/DeployStaticContentTest.php +++ b/app/code/Magento/Deploy/Test/Unit/Service/DeployStaticContentTest.php @@ -187,6 +187,9 @@ public function testDeploy($options, $expectedContentVersion) $this->assertEquals(null, $this->service->deploy($options)); } + /** + * @return array + */ public function deployDataProvider() { return [ diff --git a/app/code/Magento/Developer/Test/Unit/Helper/DataTest.php b/app/code/Magento/Developer/Test/Unit/Helper/DataTest.php index 94d7cd250adda..9b964566f6093 100644 --- a/app/code/Magento/Developer/Test/Unit/Helper/DataTest.php +++ b/app/code/Magento/Developer/Test/Unit/Helper/DataTest.php @@ -68,6 +68,9 @@ public function testIsDevAllowed($allowedIps, $expected, $callNum = 1) $this->assertEquals($expected, $this->helper->isDevAllowed($storeId)); } + /** + * @return array + */ public function isDevAllowedDataProvider() { return [ diff --git a/app/code/Magento/Developer/Test/Unit/Model/TemplateEngine/Decorator/DebugHintsTest.php b/app/code/Magento/Developer/Test/Unit/Model/TemplateEngine/Decorator/DebugHintsTest.php index d23fc89acc1b3..fd2475320261a 100644 --- a/app/code/Magento/Developer/Test/Unit/Model/TemplateEngine/Decorator/DebugHintsTest.php +++ b/app/code/Magento/Developer/Test/Unit/Model/TemplateEngine/Decorator/DebugHintsTest.php @@ -33,6 +33,9 @@ public function testRender($showBlockHints) $this->assertNotNull($actualResult); } + /** + * @return array + */ public function renderDataProvider() { return ['block hints disabled' => [false], 'block hints enabled' => [true]]; diff --git a/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/ConfigTest.php b/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/ConfigTest.php index 76b23e4e79ec2..7ec34f609a29f 100644 --- a/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/ConfigTest.php +++ b/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/ConfigTest.php @@ -34,6 +34,9 @@ public function testConstructorException(array $configData, $expectedException) new \Magento\Directory\Model\Currency\Import\Config($configData); } + /** + * @return array + */ public function constructorExceptionDataProvider() { return [ @@ -79,6 +82,9 @@ public function testGetServiceClass($serviceName, $expectedResult) $this->assertEquals($expectedResult, $this->_model->getServiceClass($serviceName)); } + /** + * @return array + */ public function getServiceClassDataProvider() { return ['known' => ['service_one', 'Service_One'], 'unknown' => ['unknown', null]]; @@ -94,6 +100,9 @@ public function testGetServiceLabel($serviceName, $expectedResult) $this->assertEquals($expectedResult, $this->_model->getServiceLabel($serviceName)); } + /** + * @return array + */ public function getServiceLabelDataProvider() { return ['known' => ['service_one', 'Service One'], 'unknown' => ['unknown', null]]; diff --git a/app/code/Magento/Directory/Test/Unit/Model/PriceCurrencyTest.php b/app/code/Magento/Directory/Test/Unit/Model/PriceCurrencyTest.php index 915c11fe1b787..67dbe573b32d5 100644 --- a/app/code/Magento/Directory/Test/Unit/Model/PriceCurrencyTest.php +++ b/app/code/Magento/Directory/Test/Unit/Model/PriceCurrencyTest.php @@ -183,6 +183,9 @@ public function testGetCurrencySymbol() $this->assertEquals($currencySymbol, $this->priceCurrency->getCurrencySymbol($storeId, $currencyMock)); } + /** + * @return \PHPUnit_Framework_MockObject_MockObject + */ protected function getCurrentCurrencyMock() { $currency = $this->getMockBuilder(\Magento\Directory\Model\Currency::class) @@ -192,6 +195,11 @@ protected function getCurrentCurrencyMock() return $currency; } + /** + * @param $baseCurrency + * + * @return \PHPUnit_Framework_MockObject_MockObject + */ protected function getStoreMock($baseCurrency) { $store = $this->getMockBuilder(\Magento\Store\Model\Store::class) @@ -205,6 +213,13 @@ protected function getStoreMock($baseCurrency) return $store; } + /** + * @param $amount + * @param $convertedAmount + * @param $currency + * + * @return \PHPUnit_Framework_MockObject_MockObject + */ protected function getBaseCurrencyMock($amount, $convertedAmount, $currency) { $baseCurrency = $this->getMockBuilder(\Magento\Directory\Model\Currency::class) diff --git a/app/code/Magento/Downloadable/Test/Unit/Block/Catalog/Product/LinksTest.php b/app/code/Magento/Downloadable/Test/Unit/Block/Catalog/Product/LinksTest.php index 13f474e5f0bf8..be0ebeabee62c 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Block/Catalog/Product/LinksTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Block/Catalog/Product/LinksTest.php @@ -156,6 +156,12 @@ public function testGetJsonConfig() $this->assertEquals(json_encode($config), $encodedJsonConfig); } + /** + * @param $linkPrice + * @param $linkId + * + * @return \PHPUnit_Framework_MockObject_MockObject + */ protected function getLinkMock($linkPrice, $linkId) { $linkMock = $this->createPartialMock(\Magento\Downloadable\Model\Link::class, ['getPrice', diff --git a/app/code/Magento/Downloadable/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/DownloadableTest.php b/app/code/Magento/Downloadable/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/DownloadableTest.php index 3b3683c6af3e7..25a5d86b0385c 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/DownloadableTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/DownloadableTest.php @@ -99,6 +99,9 @@ public function testAfterInitializeWithNoDataToSave($downloadable) $this->downloadablePlugin->afterInitialize($this->subjectMock, $this->productMock); } + /** + * @return array + */ public function afterInitializeWithEmptyDataDataProvider() { return [ diff --git a/app/code/Magento/Downloadable/Test/Unit/Helper/DownloadTest.php b/app/code/Magento/Downloadable/Test/Unit/Helper/DownloadTest.php index 3142900613296..7749c5980c864 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Helper/DownloadTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Helper/DownloadTest.php @@ -155,6 +155,9 @@ public function testGetContentTypeThroughHelper($functionExistsResult, $mimeCont $this->assertEquals(self::MIME_TYPE, $this->_helper->getContentType()); } + /** + * @return array + */ public function dataProviderForTestGetContentTypeThroughHelper() { return [[false, ''], [true, false]]; @@ -187,6 +190,11 @@ public function testGetFileNameUrlWithContentDisposition() $this->assertEquals($fileName, $this->_helper->getFilename()); } + /** + * @param bool $doesExist + * @param int $size + * @param string $path + */ protected function _setupFileMocks($doesExist = true, $size = self::FILE_SIZE, $path = self::FILE_PATH) { $this->_handleMock->expects($this->any())->method('stat')->will($this->returnValue(['size' => $size])); @@ -199,6 +207,11 @@ protected function _setupFileMocks($doesExist = true, $size = self::FILE_SIZE, $ $this->_helper->setResource($path, DownloadHelper::LINK_TYPE_FILE); } + /** + * @param int $size + * @param string $url + * @param array $additionalStatData + */ protected function _setupUrlMocks($size = self::FILE_SIZE, $url = self::URL, $additionalStatData = []) { $this->_handleMock->expects( diff --git a/app/code/Magento/Downloadable/Test/Unit/Model/LinkRepositoryTest.php b/app/code/Magento/Downloadable/Test/Unit/Model/LinkRepositoryTest.php index d835f25523353..9ce917433ff1f 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Model/LinkRepositoryTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Model/LinkRepositoryTest.php @@ -539,6 +539,10 @@ public function testGetList() $this->assertEquals([$linkInterfaceMock], $this->service->getList($productSku)); } + /** + * @param $resource + * @param $inputData + */ protected function setLinkAssertions($resource, $inputData) { $resource->expects($this->any())->method('getId')->will($this->returnValue($inputData['id'])); diff --git a/app/code/Magento/Downloadable/Test/Unit/Observer/SetLinkStatusObserverTest.php b/app/code/Magento/Downloadable/Test/Unit/Observer/SetLinkStatusObserverTest.php index 5a138d83d2673..e63ce2437035b 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Observer/SetLinkStatusObserverTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Observer/SetLinkStatusObserverTest.php @@ -104,6 +104,9 @@ protected function setUp() ); } + /** + * @return array + */ public function setLinkStatusPendingDataProvider() { return [ diff --git a/app/code/Magento/Downloadable/Test/Unit/_files/download_mock.php b/app/code/Magento/Downloadable/Test/Unit/_files/download_mock.php index 467e1f428206b..e634f0ffa341d 100644 --- a/app/code/Magento/Downloadable/Test/Unit/_files/download_mock.php +++ b/app/code/Magento/Downloadable/Test/Unit/_files/download_mock.php @@ -7,11 +7,17 @@ use Magento\Downloadable\Test\Unit\Helper\DownloadTest; +/** + * @return bool + */ function function_exists() { return DownloadTest::$functionExists; } +/** + * @return string + */ function mime_content_type() { return DownloadTest::$mimeContentType; diff --git a/app/code/Magento/Eav/Test/Unit/Model/AttributeFactoryTest.php b/app/code/Magento/Eav/Test/Unit/Model/AttributeFactoryTest.php index 572e7192d810e..3699851f6b0e6 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/AttributeFactoryTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/AttributeFactoryTest.php @@ -50,6 +50,12 @@ public function testCreateAttribute() $this->assertEquals($this->_className, $this->_factory->createAttribute($this->_className, $this->_arguments)); } + /** + * @param $className + * @param $arguments + * + * @return mixed + */ public function getModelInstance($className, $arguments) { $this->assertInternalType('array', $arguments); diff --git a/app/code/Magento/Eav/Test/Unit/Model/CustomAttributesMapperTest.php b/app/code/Magento/Eav/Test/Unit/Model/CustomAttributesMapperTest.php index d2067bccef0bb..67cb65c21443e 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/CustomAttributesMapperTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/CustomAttributesMapperTest.php @@ -198,6 +198,9 @@ public function testDatabaseToEntity() $this->assertEquals($expected, $actual); } + /** + * @return array + */ private function getAttributes() { /* Attribute with the code we want to copy */ diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/AbstractEntityTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/AbstractEntityTest.php index 67899dc3902eb..1203e2cecb477 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Entity/AbstractEntityTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/AbstractEntityTest.php @@ -61,6 +61,9 @@ public function testCompareAttributes($attribute1Sort, $attribute2Sort, $expecte $this->assertEquals($expected, $this->_model->attributesCompare($attribute1, $attribute2)); } + /** + * @return array + */ public static function compareAttributesDataProvider() { return [ @@ -313,6 +316,9 @@ function ($entityType, $attributeCode) use ($attributes) { $model->save($object); } + /** + * @return array + */ public function productAttributesDataProvider() { $attributeSetId = 10; diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Backend/ArrayBackendTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Backend/ArrayBackendTest.php index 3c0e304dbf628..475ffea98e90e 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Backend/ArrayBackendTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Backend/ArrayBackendTest.php @@ -40,6 +40,9 @@ public function testValidate($data) $this->assertEquals(null, $product->getEmpty()); } + /** + * @return array + */ public static function attributeValueDataProvider() { return [[[1, 2, 3]], ['1,2,3']]; diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Source/TableTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Source/TableTest.php index 31bf623b4bbdd..e309248168e89 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Source/TableTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Source/TableTest.php @@ -207,6 +207,9 @@ public function testGetSpecificOptions($optionIds, $withEmpty) $this->assertEquals($options, $this->model->getSpecificOptions($optionIds, $withEmpty)); } + /** + * @return array + */ public function specificOptionsProvider() { return [ @@ -266,6 +269,9 @@ public function testGetOptionText($optionsIds, $value, $options, $expectedResult $this->assertEquals($expectedResult, $this->model->getOptionText($value)); } + /** + * @return array + */ public function getOptionTextProvider() { return [ diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/AttributeTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/AttributeTest.php index 27957e8090d3e..911aecf8e7cfb 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Entity/AttributeTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/AttributeTest.php @@ -33,6 +33,9 @@ public function testGetBackendTypeByInput($givenFrontendInput, $expectedBackendT $this->assertEquals($expectedBackendType, $this->_model->getBackendTypeByInput($givenFrontendInput)); } + /** + * @return array + */ public static function dataGetBackendTypeByInput() { return [ @@ -61,6 +64,9 @@ public function testGetDefaultValueByInput($givenFrontendInput, $expectedDefault $this->assertEquals($expectedDefaultValue, $this->_model->getDefaultValueByInput($givenFrontendInput)); } + /** + * @return array + */ public static function dataGetDefaultValueByInput() { return [ diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/Collection/AbstractCollectionTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/Collection/AbstractCollectionTest.php index 88185387ed398..13c07740eb203 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Entity/Collection/AbstractCollectionTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/Collection/AbstractCollectionTest.php @@ -178,6 +178,9 @@ public function testRemoveItemByKey($values, $count) $this->assertNull($this->model->getItemById($testId)); } + /** + * @return array + */ public function getItemsDataProvider() { return [ @@ -187,6 +190,9 @@ public function getItemsDataProvider() ]; } + /** + * @return \Magento\Framework\DataObject + */ public function getMagentoObject() { return new \Magento\Framework\DataObject(); diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/Collection/VersionControl/AbstractCollectionTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/Collection/VersionControl/AbstractCollectionTest.php index d281b8d1095f4..cce7b43786a76 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Entity/Collection/VersionControl/AbstractCollectionTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/Collection/VersionControl/AbstractCollectionTest.php @@ -68,6 +68,9 @@ public function testFetchItem(array $data) } } + /** + * @return array + */ public static function fetchItemDataProvider() { return [ diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/Increment/AlphanumTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/Increment/AlphanumTest.php index 16ba85f4905ea..50e7f185a24e5 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Entity/Increment/AlphanumTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/Increment/AlphanumTest.php @@ -37,6 +37,9 @@ public function testGetNextId($lastId, $prefix, $expectedResult) $this->assertEquals($expectedResult, $this->model->getNextId()); } + /** + * @return array + */ public function getLastIdDataProvider() { return [ diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/Increment/NumericTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/Increment/NumericTest.php index a976fc1f3e654..16767fb633028 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Entity/Increment/NumericTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/Increment/NumericTest.php @@ -32,6 +32,9 @@ public function testGetNextId($lastId, $prefix, $expectedResult) $this->assertEquals($expectedResult, $this->model->getNextId()); } + /** + * @return array + */ public function getLastIdDataProvider() { return [ diff --git a/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Attribute/CollectionTest.php b/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Attribute/CollectionTest.php index 823f32f46b9a5..f1e776de265da 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Attribute/CollectionTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Attribute/CollectionTest.php @@ -174,6 +174,9 @@ public function testInitSelect($column, $value) $this->model->getSelectCountSql()->assemble(); } + /** + * @return array + */ public function initSelectDataProvider() { return [ diff --git a/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/AttributeLoaderTest.php b/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/AttributeLoaderTest.php index 8e6fa3afd15b9..ea02ec71a7bbd 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/AttributeLoaderTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/AttributeLoaderTest.php @@ -90,6 +90,9 @@ public function testGetAttributes($entityType, $attributeSetId, $expectedConditi $this->assertEquals([$attributeMock], $this->attributeLoader->getAttributes($entityType, $attributeSetId)); } + /** + * @return array + */ public function getAttributesDataProvider() { return [ diff --git a/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/ReadHandlerTest.php b/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/ReadHandlerTest.php index 4565b75e5f415..82e9033496b78 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/ReadHandlerTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/ReadHandlerTest.php @@ -115,6 +115,9 @@ public function testExecute($eavEntityType, $callNum, array $expected, $isStatic $this->assertEquals($expected, $this->readHandler->execute('entity_type', $entityData)); } + /** + * @return array + */ public function executeDataProvider() { return [ diff --git a/app/code/Magento/Email/Test/Unit/Model/AbstractTemplateTest.php b/app/code/Magento/Email/Test/Unit/Model/AbstractTemplateTest.php index 76bbba7406609..e26df4f6d1197 100644 --- a/app/code/Magento/Email/Test/Unit/Model/AbstractTemplateTest.php +++ b/app/code/Magento/Email/Test/Unit/Model/AbstractTemplateTest.php @@ -383,6 +383,9 @@ public function testSetDesignConfigWithValidInputParametersReturnsSuccess() $this->assertEquals($config, $model->getDesignConfig()->getData()); } + /** + * @return array + */ public function invalidInputParametersDataProvider() { return [[[]], [['area' => 'some_area']], [['store' => 'any_store']]]; diff --git a/app/code/Magento/Email/Test/Unit/Model/Template/Config/XsdTest.php b/app/code/Magento/Email/Test/Unit/Model/Template/Config/XsdTest.php index f7ba4b7424cc6..5f8bef5c0c489 100644 --- a/app/code/Magento/Email/Test/Unit/Model/Template/Config/XsdTest.php +++ b/app/code/Magento/Email/Test/Unit/Model/Template/Config/XsdTest.php @@ -29,6 +29,9 @@ public function testMergedXml($fixtureXml, array $expectedErrors) $this->_testXmlAgainstXsd($fixtureXml, $schemaFile, $expectedErrors); } + /** + * @return array + */ public function mergedXmlDataProvider() { return [ diff --git a/app/code/Magento/Email/Test/Unit/Model/Template/ConfigTest.php b/app/code/Magento/Email/Test/Unit/Model/Template/ConfigTest.php index 6a565ca08eb9b..ac14d07d4fa58 100644 --- a/app/code/Magento/Email/Test/Unit/Model/Template/ConfigTest.php +++ b/app/code/Magento/Email/Test/Unit/Model/Template/ConfigTest.php @@ -190,6 +190,9 @@ public function testParseTemplateIdParts($input, $expectedOutput) $this->assertEquals($this->model->parseTemplateIdParts($input), $expectedOutput); } + /** + * @return array + */ public function parseTemplateCodePartsDataProvider() { return [ @@ -301,6 +304,9 @@ public function testGetterMethodUnknownTemplate($getterMethod, $argument = null) } } + /** + * @return array + */ public function getterMethodUnknownTemplateDataProvider() { return [ @@ -348,6 +354,9 @@ public function testGetterMethodUnknownField( } } + /** + * @return array + */ public function getterMethodUnknownFieldDataProvider() { return [ diff --git a/app/code/Magento/Email/Test/Unit/Model/TemplateTest.php b/app/code/Magento/Email/Test/Unit/Model/TemplateTest.php index 3e6661816945a..6750fc3d3f49d 100644 --- a/app/code/Magento/Email/Test/Unit/Model/TemplateTest.php +++ b/app/code/Magento/Email/Test/Unit/Model/TemplateTest.php @@ -298,6 +298,9 @@ public function testLoadDefault( $this->assertEquals($expectedTemplateStyles, $model->getTemplateStyles()); } + /** + * @return array + */ public function loadDefaultDataProvider() { return [ @@ -453,6 +456,9 @@ public function testIsValidForSend($senderName, $senderEmail, $templateSubject, $this->assertEquals($expectedValue, $model->isValidForSend()); } + /** + * @return array + */ public function isValidForSendDataProvider() { return [ @@ -548,6 +554,9 @@ public function testGetVariablesOptionArray($withGroup, $templateVariables, $exp $this->assertEquals($expectedResult, $model->getVariablesOptionArray($withGroup)); } + /** + * @return array + */ public function getVariablesOptionArrayDataProvider() { return [ @@ -648,6 +657,9 @@ public function testProcessTemplate($templateId, $expectedResult) $this->assertTrue($model->getUseAbsoluteLinks()); } + /** + * @return array + */ public function processTemplateVariable() { return [ @@ -744,6 +756,9 @@ public function testGetType($templateType, $expectedResult) $this->assertEquals($expectedResult, $model->getType()); } + /** + * @return array + */ public function getTypeDataProvider() { return [['text', 1], ['html', 2]]; diff --git a/app/code/Magento/GiftMessage/Test/Unit/Block/Cart/Item/Renderer/Actions/ItemIdProcessorTest.php b/app/code/Magento/GiftMessage/Test/Unit/Block/Cart/Item/Renderer/Actions/ItemIdProcessorTest.php index 35759f4d3f44a..f83f2304143a1 100644 --- a/app/code/Magento/GiftMessage/Test/Unit/Block/Cart/Item/Renderer/Actions/ItemIdProcessorTest.php +++ b/app/code/Magento/GiftMessage/Test/Unit/Block/Cart/Item/Renderer/Actions/ItemIdProcessorTest.php @@ -39,6 +39,9 @@ public function testProcess($itemId, array $jsLayout, array $result) $this->assertEquals($result, $this->model->process($jsLayout, $itemMock)); } + /** + * @return array + */ public function dataProviderProcess() { return [ diff --git a/app/code/Magento/GoogleAdwords/Test/Unit/Helper/DataTest.php b/app/code/Magento/GoogleAdwords/Test/Unit/Helper/DataTest.php index faa28603af62e..794837f9d6e74 100644 --- a/app/code/Magento/GoogleAdwords/Test/Unit/Helper/DataTest.php +++ b/app/code/Magento/GoogleAdwords/Test/Unit/Helper/DataTest.php @@ -91,6 +91,9 @@ public function testGetLanguageCodes() $this->assertEquals($languages, $this->_helper->getLanguageCodes()); } + /** + * @return array + */ public function dataProviderForTestConvertLanguage() { return [ diff --git a/app/code/Magento/GoogleAdwords/Test/Unit/Model/Filter/UppercaseTitleTest.php b/app/code/Magento/GoogleAdwords/Test/Unit/Model/Filter/UppercaseTitleTest.php index cf013780105a7..76a746ea77b92 100644 --- a/app/code/Magento/GoogleAdwords/Test/Unit/Model/Filter/UppercaseTitleTest.php +++ b/app/code/Magento/GoogleAdwords/Test/Unit/Model/Filter/UppercaseTitleTest.php @@ -17,6 +17,9 @@ protected function setUp() $this->_model = new \Magento\GoogleAdwords\Model\Filter\UppercaseTitle(); } + /** + * @return array + */ public function dataProviderForFilterValues() { return [['some name', 'Some Name'], ['test', 'Test']]; diff --git a/app/code/Magento/GoogleAdwords/Test/Unit/Observer/SetConversionValueObserverTest.php b/app/code/Magento/GoogleAdwords/Test/Unit/Observer/SetConversionValueObserverTest.php index ccda04d052fc9..ab8e4f7f8dca8 100644 --- a/app/code/Magento/GoogleAdwords/Test/Unit/Observer/SetConversionValueObserverTest.php +++ b/app/code/Magento/GoogleAdwords/Test/Unit/Observer/SetConversionValueObserverTest.php @@ -56,6 +56,9 @@ protected function setUp() ); } + /** + * @return array + */ public function dataProviderForDisabled() { return [[false, false], [false, true], [true, false]]; @@ -88,6 +91,9 @@ function () use ($isDynamic) { $this->assertSame($this->_model, $this->_model->execute($this->_eventObserverMock)); } + /** + * @return array + */ public function dataProviderForOrdersIds() { return [[[]], ['']]; diff --git a/app/code/Magento/GroupedImportExport/Test/Unit/Model/Import/Product/Type/Grouped/LinksTest.php b/app/code/Magento/GroupedImportExport/Test/Unit/Model/Import/Product/Type/Grouped/LinksTest.php index ffcfa5c0a90d7..9a4ddeb4f55f5 100644 --- a/app/code/Magento/GroupedImportExport/Test/Unit/Model/Import/Product/Type/Grouped/LinksTest.php +++ b/app/code/Magento/GroupedImportExport/Test/Unit/Model/Import/Product/Type/Grouped/LinksTest.php @@ -57,6 +57,9 @@ protected function setUp() ); } + /** + * @return array + */ public function linksDataProvider() { return [ @@ -107,6 +110,9 @@ public function testSaveLinksDataWithProductsAttrs($linksData) $this->links->saveLinksData($linksData); } + /** + * @return array + */ public function attributesDataProvider() { return [ @@ -135,6 +141,9 @@ public function attributesDataProvider() ]; } + /** + * @param $dbAttributes + */ protected function processAttributeGetter($dbAttributes) { $select = $this->createMock(\Magento\Framework\DB\Select::class); @@ -162,6 +171,9 @@ public function testGetAttributes($dbAttributes, $returnedAttributes) $this->assertEquals($returnedAttributes, $actualAttributes); } + /** + * @param $behavior + */ protected function processBehaviorGetter($behavior) { $dataSource = $this->createMock(\Magento\ImportExport\Model\ResourceModel\Import\Data::class); diff --git a/app/code/Magento/GroupedProduct/Test/Unit/Block/Product/View/Type/GroupedTest.php b/app/code/Magento/GroupedProduct/Test/Unit/Block/Product/View/Type/GroupedTest.php index 77ffb200f84e0..e8ed2e5d6f880 100644 --- a/app/code/Magento/GroupedProduct/Test/Unit/Block/Product/View/Type/GroupedTest.php +++ b/app/code/Magento/GroupedProduct/Test/Unit/Block/Product/View/Type/GroupedTest.php @@ -111,6 +111,9 @@ public function testSetPreconfiguredValue($id) $this->groupedView->setPreconfiguredValue(); } + /** + * @return array + */ public function setPreconfiguredValueDataProvider() { return ['item_id_exist_in_config' => ['id_one'], 'item_id_not_exist_in_config' => ['id_two']]; diff --git a/app/code/Magento/GroupedProduct/Test/Unit/Model/Product/Initialization/Helper/ProductLinks/Plugin/GroupedTest.php b/app/code/Magento/GroupedProduct/Test/Unit/Model/Product/Initialization/Helper/ProductLinks/Plugin/GroupedTest.php index 309794a6cc37d..2dbdbb551f97a 100644 --- a/app/code/Magento/GroupedProduct/Test/Unit/Model/Product/Initialization/Helper/ProductLinks/Plugin/GroupedTest.php +++ b/app/code/Magento/GroupedProduct/Test/Unit/Model/Product/Initialization/Helper/ProductLinks/Plugin/GroupedTest.php @@ -92,6 +92,9 @@ public function testBeforeInitializeLinksRequestDoesNotHaveGrouped($productType) $this->model->beforeInitializeLinks($this->subjectMock, $this->productMock, []); } + /** + * @return array + */ public function productTypeDataProvider() { return [ @@ -141,6 +144,9 @@ public function testBeforeInitializeLinksRequestHasGrouped($linksData) $this->model->beforeInitializeLinks($this->subjectMock, $this->productMock, ['associated' => $linksData]); } + /** + * @return array + */ public function linksDataProvider() { return [ diff --git a/app/code/Magento/GroupedProduct/Test/Unit/Pricing/Price/FinalPriceTest.php b/app/code/Magento/GroupedProduct/Test/Unit/Pricing/Price/FinalPriceTest.php index 13e1dde0c526c..dd640579ca65e 100644 --- a/app/code/Magento/GroupedProduct/Test/Unit/Pricing/Price/FinalPriceTest.php +++ b/app/code/Magento/GroupedProduct/Test/Unit/Pricing/Price/FinalPriceTest.php @@ -102,6 +102,11 @@ public function testGetValueWithoutMinProduct() $this->assertEquals(0.00, $this->finalPrice->getValue()); } + /** + * @param $price + * + * @return \PHPUnit_Framework_MockObject_MockObject + */ protected function getProductMock($price) { $priceTypeMock = $this->createMock(\Magento\Catalog\Pricing\Price\FinalPrice::class); diff --git a/app/code/Magento/GroupedProduct/Test/Unit/Ui/DataProvider/Product/GroupedProductDataProviderTest.php b/app/code/Magento/GroupedProduct/Test/Unit/Ui/DataProvider/Product/GroupedProductDataProviderTest.php index 8dc8fc0483d41..9a4662ffa42cc 100644 --- a/app/code/Magento/GroupedProduct/Test/Unit/Ui/DataProvider/Product/GroupedProductDataProviderTest.php +++ b/app/code/Magento/GroupedProduct/Test/Unit/Ui/DataProvider/Product/GroupedProductDataProviderTest.php @@ -75,6 +75,9 @@ protected function setUp() ->getMockForAbstractClass(); } + /** + * @return object + */ protected function getModel() { return $this->objectManager->getObject(GroupedProductDataProvider::class, [ diff --git a/app/code/Magento/ImportExport/Test/Unit/Model/Export/ConfigTest.php b/app/code/Magento/ImportExport/Test/Unit/Model/Export/ConfigTest.php index 953f76f6cf702..f9d0cf11179dc 100644 --- a/app/code/Magento/ImportExport/Test/Unit/Model/Export/ConfigTest.php +++ b/app/code/Magento/ImportExport/Test/Unit/Model/Export/ConfigTest.php @@ -65,6 +65,9 @@ public function testGetEntities($value, $expected) $this->assertEquals($expected, $this->model->getEntities('entities')); } + /** + * @return array + */ public function getEntitiesDataProvider() { return [ @@ -100,6 +103,9 @@ public function testGetEntityTypes($configData, $entity, $expectedResult) $this->assertEquals($expectedResult, $this->model->getEntityTypes($entity)); } + /** + * @return array + */ public function getEntityTypesDataProvider() { return [ @@ -154,6 +160,9 @@ public function testGetFileFormats($value, $expected) $this->assertEquals($expected, $this->model->getFileFormats('fileFormats')); } + /** + * @return array + */ public function getFileFormatsDataProvider() { return [ diff --git a/app/code/Magento/ImportExport/Test/Unit/Model/Import/ConfigTest.php b/app/code/Magento/ImportExport/Test/Unit/Model/Import/ConfigTest.php index 688e3a2659c6d..aa37551034a25 100644 --- a/app/code/Magento/ImportExport/Test/Unit/Model/Import/ConfigTest.php +++ b/app/code/Magento/ImportExport/Test/Unit/Model/Import/ConfigTest.php @@ -65,6 +65,9 @@ public function testGetEntities($value, $expected) $this->assertEquals($expected, $this->model->getEntities('entities')); } + /** + * @return array + */ public function getEntitiesDataProvider() { return [ @@ -100,6 +103,9 @@ public function testGetEntityTypes($configData, $entity, $expectedResult) $this->assertEquals($expectedResult, $this->model->getEntityTypes($entity)); } + /** + * @return array + */ public function getEntityTypesDataProvider() { return [ diff --git a/app/code/Magento/ImportExport/Test/Unit/Model/Import/Source/ZipTest.php b/app/code/Magento/ImportExport/Test/Unit/Model/Import/Source/ZipTest.php index 6ef2ef02865f1..7fb9457c2d704 100644 --- a/app/code/Magento/ImportExport/Test/Unit/Model/Import/Source/ZipTest.php +++ b/app/code/Magento/ImportExport/Test/Unit/Model/Import/Source/ZipTest.php @@ -39,6 +39,9 @@ public function testConstructorFileDestinationMatch($fileName, $expectedfileName $this->_invokeConstructor($fileName); } + /** + * @return array + */ public function constructorFileDestinationMatchDataProvider() { return [ diff --git a/app/code/Magento/Indexer/Test/Unit/App/IndexerTest.php b/app/code/Magento/Indexer/Test/Unit/App/IndexerTest.php index 5bc20e0633191..490d9437941f6 100644 --- a/app/code/Magento/Indexer/Test/Unit/App/IndexerTest.php +++ b/app/code/Magento/Indexer/Test/Unit/App/IndexerTest.php @@ -62,6 +62,9 @@ public function testExecute($isExist, $callCount) $this->assertEquals(0, $this->entryPoint->launch()->getCode()); } + /** + * @return array + */ public function executeProvider() { return [ diff --git a/app/code/Magento/Indexer/Test/Unit/Block/Backend/Grid/Column/Renderer/ScheduledTest.php b/app/code/Magento/Indexer/Test/Unit/Block/Backend/Grid/Column/Renderer/ScheduledTest.php index 6ae005efa0550..1a226e073ca5e 100644 --- a/app/code/Magento/Indexer/Test/Unit/Block/Backend/Grid/Column/Renderer/ScheduledTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Block/Backend/Grid/Column/Renderer/ScheduledTest.php @@ -31,6 +31,9 @@ public function testRender($rowValue, $class, $text) $this->assertEquals($result, $html); } + /** + * @return array + */ public function typeProvider() { return [ diff --git a/app/code/Magento/Indexer/Test/Unit/Block/Backend/Grid/Column/Renderer/StatusTest.php b/app/code/Magento/Indexer/Test/Unit/Block/Backend/Grid/Column/Renderer/StatusTest.php index e419a010ad96d..705a9e3998ae8 100644 --- a/app/code/Magento/Indexer/Test/Unit/Block/Backend/Grid/Column/Renderer/StatusTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Block/Backend/Grid/Column/Renderer/StatusTest.php @@ -33,6 +33,9 @@ public function testRender($indexValues, $expectedResult) ); } + /** + * @return array + */ public function renderDataProvider() { return [ diff --git a/app/code/Magento/Indexer/Test/Unit/Block/Backend/Grid/Column/Renderer/UpdatedTest.php b/app/code/Magento/Indexer/Test/Unit/Block/Backend/Grid/Column/Renderer/UpdatedTest.php index e1ad5c50f3c91..369a4d46abf49 100644 --- a/app/code/Magento/Indexer/Test/Unit/Block/Backend/Grid/Column/Renderer/UpdatedTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Block/Backend/Grid/Column/Renderer/UpdatedTest.php @@ -27,6 +27,9 @@ public function testRender($defaultValue, $assert) $this->assertEquals($result, $assert); } + /** + * @return array + */ public function renderProvider() { return [ diff --git a/app/code/Magento/Indexer/Test/Unit/Model/IndexerTest.php b/app/code/Magento/Indexer/Test/Unit/Model/IndexerTest.php index e9c82906121cc..6b7cc12218990 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/IndexerTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Model/IndexerTest.php @@ -323,6 +323,9 @@ function () { $this->model->reindexAll(); } + /** + * @return array + */ protected function getIndexerData() { return [ diff --git a/app/code/Magento/Indexer/Test/Unit/Model/ResourceModel/AbstractResourceTest.php b/app/code/Magento/Indexer/Test/Unit/Model/ResourceModel/AbstractResourceTest.php index f7b99fdb8d23f..46ae79fc92f4a 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/ResourceModel/AbstractResourceTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Model/ResourceModel/AbstractResourceTest.php @@ -165,6 +165,9 @@ public function testInsertFromTable($readToIndex) ); } + /** + * @return array + */ public function insertFromTableData() { return [[false], [true]]; diff --git a/app/code/Magento/Indexer/Ui/DataProvider/Indexer/DataCollection.php b/app/code/Magento/Indexer/Ui/DataProvider/Indexer/DataCollection.php index 5ba4521791c50..0b6477e550c7e 100644 --- a/app/code/Magento/Indexer/Ui/DataProvider/Indexer/DataCollection.php +++ b/app/code/Magento/Indexer/Ui/DataProvider/Indexer/DataCollection.php @@ -23,6 +23,13 @@ class DataCollection extends Collection */ private $indexerRegistry; + /** + * DataCollection constructor. + * + * @param EntityFactoryInterface $entityFactory + * @param ConfigInterface $config + * @param IndexerRegistry $indexerRegistry + */ public function __construct( EntityFactoryInterface $entityFactory, ConfigInterface $config, diff --git a/app/code/Magento/InstantPurchase/Controller/Button/PlaceOrder.php b/app/code/Magento/InstantPurchase/Controller/Button/PlaceOrder.php index 56ed9ca583a2b..3d46e1ef7466e 100644 --- a/app/code/Magento/InstantPurchase/Controller/Button/PlaceOrder.php +++ b/app/code/Magento/InstantPurchase/Controller/Button/PlaceOrder.php @@ -76,6 +76,18 @@ class PlaceOrder extends Action */ private $orderRepository; + /** + * PlaceOrder constructor. + * + * @param Context $context + * @param StoreManagerInterface $storeManager + * @param Session $customerSession + * @param FormKeyValidator $formKeyValidator + * @param InstantPurchaseOptionLoadingFactory $instantPurchaseOptionLoadingFactory + * @param ProductRepositoryInterface $productRepository + * @param PlaceOrderModel $placeOrder + * @param OrderRepositoryInterface $orderRepository + */ public function __construct( Context $context, StoreManagerInterface $storeManager, diff --git a/app/code/Magento/InstantPurchase/Model/ShippingMethodChoose/DeferredShippingMethodChooserPool.php b/app/code/Magento/InstantPurchase/Model/ShippingMethodChoose/DeferredShippingMethodChooserPool.php index 5a43783ceea6a..a5bb2e2a834a8 100644 --- a/app/code/Magento/InstantPurchase/Model/ShippingMethodChoose/DeferredShippingMethodChooserPool.php +++ b/app/code/Magento/InstantPurchase/Model/ShippingMethodChoose/DeferredShippingMethodChooserPool.php @@ -15,6 +15,11 @@ class DeferredShippingMethodChooserPool { private $choosers; + /** + * DeferredShippingMethodChooserPool constructor. + * + * @param array $choosers + */ public function __construct(array $choosers) { foreach ($choosers as $chooser) { @@ -28,6 +33,11 @@ public function __construct(array $choosers) $this->choosers = $choosers; } + /** + * @param $type + * + * @return DeferredShippingMethodChooserInterface + */ public function get($type) : DeferredShippingMethodChooserInterface { if (!isset($this->choosers[$type])) { diff --git a/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Integration/Edit/Tab/WebapiTest.php b/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Integration/Edit/Tab/WebapiTest.php index b5f2b22186187..7738e9939fcdd 100644 --- a/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Integration/Edit/Tab/WebapiTest.php +++ b/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Integration/Edit/Tab/WebapiTest.php @@ -83,6 +83,9 @@ public function testCanShowTab($integrationData, $expectedValue) $this->assertEquals($expectedValue, $this->webapiBlock->canShowTab()); } + /** + * @return array + */ public function canShowTabProvider() { return [ @@ -127,6 +130,9 @@ public function testIsEverythingAllowed($rootResourceId, $integrationData, $sele $this->assertEquals($expectedValue, $this->webapiBlock->isEverythingAllowed()); } + /** + * @return array + */ public function isEverythingAllowedProvider() { return [ diff --git a/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Widget/Grid/Column/Renderer/NameTest.php b/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Widget/Grid/Column/Renderer/NameTest.php index 91f56279a89e5..30f1dc1d90bdc 100644 --- a/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Widget/Grid/Column/Renderer/NameTest.php +++ b/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Widget/Grid/Column/Renderer/NameTest.php @@ -87,6 +87,9 @@ public function testRender($endpoint, $name, $expectedResult) $this->assertEquals($expectedResult, $actualResult); } + /** + * @return array + */ public function endpointDataProvider() { return [ diff --git a/app/code/Magento/Integration/Test/Unit/Helper/DataTest.php b/app/code/Magento/Integration/Test/Unit/Helper/DataTest.php index ca79393efb113..0cb550913ba60 100644 --- a/app/code/Magento/Integration/Test/Unit/Helper/DataTest.php +++ b/app/code/Magento/Integration/Test/Unit/Helper/DataTest.php @@ -33,6 +33,9 @@ public function testIsConfigType($integrationsData, $expectedResult) $this->assertEquals($expectedResult, $this->dataHelper->isConfigType($integrationsData)); } + /** + * @return array + */ public function integrationDataProvider() { return [ diff --git a/app/code/Magento/Integration/Test/Unit/Helper/Oauth/ConsumerTest.php b/app/code/Magento/Integration/Test/Unit/Helper/Oauth/ConsumerTest.php index ebdac167d257c..19734c535a101 100644 --- a/app/code/Magento/Integration/Test/Unit/Helper/Oauth/ConsumerTest.php +++ b/app/code/Magento/Integration/Test/Unit/Helper/Oauth/ConsumerTest.php @@ -197,6 +197,11 @@ public function testPostToConsumer() $this->assertEquals($oauthVerifier, $verifier, 'Checking Oauth Verifier'); } + /** + * @param $length + * + * @return bool|string + */ private function _generateRandomString($length) { return substr( diff --git a/app/code/Magento/Integration/Test/Unit/Oauth/OauthTest.php b/app/code/Magento/Integration/Test/Unit/Oauth/OauthTest.php index 529703500d4f0..76ce7d211691d 100644 --- a/app/code/Magento/Integration/Test/Unit/Oauth/OauthTest.php +++ b/app/code/Magento/Integration/Test/Unit/Oauth/OauthTest.php @@ -156,6 +156,11 @@ public function tearDown() unset($this->_oauth); } + /** + * @param array $amendments + * + * @return array + */ protected function _getRequestTokenParams($amendments = []) { $requiredParams = [ @@ -233,6 +238,9 @@ public function testGetRequestTokenOutdatedConsumerKey() $this->_oauth->getRequestToken($this->_getRequestTokenParams(), self::REQUEST_URL); } + /** + * @param bool $isLoadable + */ protected function _setupConsumer($isLoadable = true) { $this->_consumerMock->expects($this->any())->method('loadByKey')->will($this->returnSelf()); @@ -293,6 +301,9 @@ public function testGetRequestTokenOauthTimestampRefused($timestamp) ); } + /** + * @return array + */ public function dataProviderForGetRequestTokenNonceTimestampRefusedTest() { return [ @@ -302,6 +313,10 @@ public function dataProviderForGetRequestTokenNonceTimestampRefusedTest() ]; } + /** + * @param bool $isUsed + * @param int $timestamp + */ protected function _setupNonce($isUsed = false, $timestamp = 0) { $nonceMock = $this->getMockBuilder( @@ -361,6 +376,13 @@ public function testGetRequestTokenNoConsumer() $this->_oauth->getRequestToken($this->_getRequestTokenParams(), self::REQUEST_URL); } + /** + * @param bool $doesExist + * @param string $type + * @param int $consumerId + * @param null $verifier + * @param bool $isRevoked + */ protected function _setupToken( $doesExist = true, $type = \Magento\Integration\Model\Oauth\Token::TYPE_VERIFIER, @@ -604,6 +626,9 @@ public function testGetAccessTokenVerifierInvalid($verifier, $verifierFromToken) ); } + /** + * @return array + */ public function dataProviderForGetAccessTokenVerifierInvalidTest() { // Verifier is not a string @@ -789,6 +814,9 @@ public function testMissingParamForBuildAuthorizationHeader($expectedMessage, $r $this->_oauth->buildAuthorizationHeader($request, $requestUrl); } + /** + * @return array + */ public function dataProviderMissingParamForBuildAuthorizationHeaderTest() { return [ @@ -838,6 +866,11 @@ public function dataProviderMissingParamForBuildAuthorizationHeaderTest() ]; } + /** + * @param array $amendments + * + * @return array + */ protected function _getAccessTokenRequiredParams($amendments = []) { $requiredParams = [ @@ -855,6 +888,11 @@ protected function _getAccessTokenRequiredParams($amendments = []) return array_merge($requiredParams, $amendments); } + /** + * @param $length + * + * @return bool|string + */ private function _generateRandomString($length) { return substr( diff --git a/app/code/Magento/LayeredNavigation/Test/Unit/Block/NavigationTest.php b/app/code/Magento/LayeredNavigation/Test/Unit/Block/NavigationTest.php index 52a711fad2b60..74e42e38ee6b4 100644 --- a/app/code/Magento/LayeredNavigation/Test/Unit/Block/NavigationTest.php +++ b/app/code/Magento/LayeredNavigation/Test/Unit/Block/NavigationTest.php @@ -138,6 +138,9 @@ public function testCanShowBlockWithDifferentDisplayModes(string $mode, bool $re $this->assertEquals($result, $this->model->canShowBlock()); } + /** + * @return array + */ public function canShowBlockDataProvider() { return [ diff --git a/app/code/Magento/MediaStorage/Test/Unit/App/MediaTest.php b/app/code/Magento/MediaStorage/Test/Unit/App/MediaTest.php index 46becd82343e9..48c7c0eda03d6 100644 --- a/app/code/Magento/MediaStorage/Test/Unit/App/MediaTest.php +++ b/app/code/Magento/MediaStorage/Test/Unit/App/MediaTest.php @@ -229,6 +229,9 @@ public function testCatchException($isDeveloper, $setBodyCalls) $this->model->catchException($bootstrap, $exception); } + /** + * @return array + */ public function catchExceptionDataProvider() { return [ diff --git a/app/code/Magento/MediaStorage/Test/Unit/Helper/File/MediaTest.php b/app/code/Magento/MediaStorage/Test/Unit/Helper/File/MediaTest.php index 0c50b6e130484..88f368fbbe077 100644 --- a/app/code/Magento/MediaStorage/Test/Unit/Helper/File/MediaTest.php +++ b/app/code/Magento/MediaStorage/Test/Unit/Helper/File/MediaTest.php @@ -87,6 +87,9 @@ public function testCollectFileInfo($path, $expectedDir, $expectedFile) $this->assertEquals($expected, $this->helper->collectFileInfo($mediaDirectory, $path)); } + /** + * @return array + */ public function pathDataProvider() { return [ diff --git a/app/code/Magento/MediaStorage/Test/Unit/Helper/File/Storage/DatabaseTest.php b/app/code/Magento/MediaStorage/Test/Unit/Helper/File/Storage/DatabaseTest.php index 6ff2397f543fa..56f57a9d32c1f 100644 --- a/app/code/Magento/MediaStorage/Test/Unit/Helper/File/Storage/DatabaseTest.php +++ b/app/code/Magento/MediaStorage/Test/Unit/Helper/File/Storage/DatabaseTest.php @@ -75,6 +75,9 @@ public function testCheckDbUsage($storage, $expected) $this->assertEquals($expected, $this->helper->checkDbUsage()); } + /** + * @return array + */ public function checkDbUsageDataProvider() { return [ @@ -144,6 +147,9 @@ public function testSaveFile($storage, $callNum) $this->helper->saveFile('media-dir/filename'); } + /** + * @return array + */ public function updateFileDataProvider() { return [ @@ -226,6 +232,9 @@ public function testFileExists($storage, $callNum, $expected) $this->assertEquals($expected, $this->helper->fileExists('media-dir/file')); } + /** + * @return array + */ public function fileExistsDataProvider() { return [ @@ -264,6 +273,9 @@ public function testGetUniqueFilename($storage, $callNum, $expected) $this->assertSame($expected, $this->helper->getUniqueFilename('media-dir/directory/', 'filename.ext')); } + /** + * @return array + */ public function getUniqueFilenameDataProvider() { return [ @@ -308,6 +320,9 @@ public function testSaveFileToFileSystem($expected, $storage, $callNum, $id = 0, $this->assertEquals($expected, $this->helper->saveFileToFilesystem('media-dir/filename')); } + /** + * @return array + */ public function saveFileToFileSystemDataProvider() { return [ @@ -430,6 +445,9 @@ public function testSaveUploadedFile($result, $expected, $expectedFullPath, $sto $this->assertEquals($expected, $this->helper->saveUploadedFile($result)); } + /** + * @return array + */ public function saveUploadedFileDataProvider() { return [ diff --git a/app/code/Magento/MediaStorage/Test/Unit/Helper/File/StorageTest.php b/app/code/Magento/MediaStorage/Test/Unit/Helper/File/StorageTest.php index 8725bf1f0f02f..d1ae631a351c3 100644 --- a/app/code/Magento/MediaStorage/Test/Unit/Helper/File/StorageTest.php +++ b/app/code/Magento/MediaStorage/Test/Unit/Helper/File/StorageTest.php @@ -77,6 +77,9 @@ public function testIsInternalStorage($storage, $callNum, $expected) $this->assertEquals($expected, $this->helper->isInternalStorage($storage)); } + /** + * @return array + */ public function isInternalStorageDataProvider() { return [ @@ -146,6 +149,9 @@ public function testProcessStorageFile($expected, $storage, $callNum, $callSaveF $this->assertEquals($expected, $this->helper->processStorageFile($filename)); } + /** + * @return array + */ public function processStorageFileDataProvider() { return [ diff --git a/app/code/Magento/Multishipping/Test/Unit/Block/Checkout/Address/SelectTest.php b/app/code/Magento/Multishipping/Test/Unit/Block/Checkout/Address/SelectTest.php index c2bfe2137c72e..080c26dea4834 100644 --- a/app/code/Magento/Multishipping/Test/Unit/Block/Checkout/Address/SelectTest.php +++ b/app/code/Magento/Multishipping/Test/Unit/Block/Checkout/Address/SelectTest.php @@ -115,6 +115,9 @@ public function testIsAddressDefaultShipping($id, $expectedValue) $this->assertEquals($expectedValue, $this->block->isAddressDefaultShipping($this->addressMock)); } + /** + * @return array + */ public function isDefaultAddressDataProvider() { return [ diff --git a/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/Address/NewShippingTest.php b/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/Address/NewShippingTest.php index 7628fcf6270c7..6a5cd7ab6e21c 100644 --- a/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/Address/NewShippingTest.php +++ b/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/Address/NewShippingTest.php @@ -164,6 +164,9 @@ public function testExecute($backUrl, $shippingAddress, $url) $this->controller->execute(); } + /** + * @return array + */ public function executeDataProvider() { return [ diff --git a/app/code/Magento/NewRelicReporting/Plugin/StatePlugin.php b/app/code/Magento/NewRelicReporting/Plugin/StatePlugin.php index 0be7c72689e7f..d84f278bb1c68 100644 --- a/app/code/Magento/NewRelicReporting/Plugin/StatePlugin.php +++ b/app/code/Magento/NewRelicReporting/Plugin/StatePlugin.php @@ -65,6 +65,12 @@ public function afterSetAreaCode(State $state, $result) } } + /** + * @param State $state + * + * @return string + * @throws LocalizedException + */ private function appName(State $state) { $code = $state->getAreaCode(); @@ -73,6 +79,9 @@ private function appName(State $state) return $current . ';' . $current . '_' . $code; } + /** + * @return bool + */ private function shouldSetAppName() { if (!$this->config->isNewRelicEnabled()) { diff --git a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Apm/DeploymentsTest.php b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Apm/DeploymentsTest.php index eb665773d5f4b..1193ac088633f 100644 --- a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Apm/DeploymentsTest.php +++ b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Apm/DeploymentsTest.php @@ -252,6 +252,9 @@ public function testSetDeploymentRequestFail() ); } + /** + * @return array + */ private function getDataVariables() { $description = 'Event description'; diff --git a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Module/CollectTest.php b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Module/CollectTest.php index a9dbacdfb0405..71f818407f9e1 100644 --- a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Module/CollectTest.php +++ b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Module/CollectTest.php @@ -346,6 +346,9 @@ public function testGetModuleDataRefreshOrStatement($data) ); } + /** + * @return array + */ public function itemDataProvider() { return [ diff --git a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportProductSavedToNewRelicTest.php b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportProductSavedToNewRelicTest.php index 20791511324bf..ba5f13d247fe0 100644 --- a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportProductSavedToNewRelicTest.php +++ b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Observer/ReportProductSavedToNewRelicTest.php @@ -140,6 +140,9 @@ public function testReportProductUpdatedToNewRelic($isNewObject) $this->model->execute($eventObserver); } + /** + * @return array + */ public function actionDataProvider() { return [[true], [false]]; diff --git a/app/code/Magento/Newsletter/Test/Unit/Model/SubscriberTest.php b/app/code/Magento/Newsletter/Test/Unit/Model/SubscriberTest.php index 7dd96be11bcbe..18721382ae872 100644 --- a/app/code/Magento/Newsletter/Test/Unit/Model/SubscriberTest.php +++ b/app/code/Magento/Newsletter/Test/Unit/Model/SubscriberTest.php @@ -378,6 +378,9 @@ public function testReceived() $this->assertEquals($this->subscriber, $this->subscriber->received($queue)); } + /** + * @return $this + */ protected function sendEmailCheck() { $storeModel = $this->getMockBuilder(\Magento\Store\Model\Store::class) diff --git a/app/code/Magento/Newsletter/Test/Unit/Model/TemplateTest.php b/app/code/Magento/Newsletter/Test/Unit/Model/TemplateTest.php index 5773c77c5f7f9..52bb803dd377f 100644 --- a/app/code/Magento/Newsletter/Test/Unit/Model/TemplateTest.php +++ b/app/code/Magento/Newsletter/Test/Unit/Model/TemplateTest.php @@ -401,6 +401,9 @@ public function testIsValidForSend($senderName, $senderEmail, $templateSubject, $this->assertEquals($expectedValue, $model->isValidForSend()); } + /** + * @return array + */ public function isValidForSendDataProvider() { return [ diff --git a/app/code/Magento/OfflinePayments/Test/Unit/Model/CheckmoConfigProviderTest.php b/app/code/Magento/OfflinePayments/Test/Unit/Model/CheckmoConfigProviderTest.php index 7509ff03c3780..8d65146ec102b 100644 --- a/app/code/Magento/OfflinePayments/Test/Unit/Model/CheckmoConfigProviderTest.php +++ b/app/code/Magento/OfflinePayments/Test/Unit/Model/CheckmoConfigProviderTest.php @@ -63,6 +63,9 @@ public function testGetConfig($isAvailable, $mailingAddress, $payableTo, $result $this->assertEquals($result, $this->model->getConfig()); } + /** + * @return array + */ public function dataProviderGetConfig() { $checkmoCode = Checkmo::PAYMENT_METHOD_CHECKMO_CODE; diff --git a/app/code/Magento/OfflinePayments/Test/Unit/Model/InstructionsConfigProviderTest.php b/app/code/Magento/OfflinePayments/Test/Unit/Model/InstructionsConfigProviderTest.php index 120a7eb6ed88f..97a64d8ab59b9 100644 --- a/app/code/Magento/OfflinePayments/Test/Unit/Model/InstructionsConfigProviderTest.php +++ b/app/code/Magento/OfflinePayments/Test/Unit/Model/InstructionsConfigProviderTest.php @@ -82,6 +82,9 @@ public function testGetConfig($isOneAvailable, $instructionsOne, $isTwoAvailable $this->assertEquals($result, $this->model->getConfig()); } + /** + * @return array + */ public function dataProviderGetConfig() { $oneCode = Banktransfer::PAYMENT_METHOD_BANKTRANSFER_CODE; diff --git a/app/code/Magento/OfflineShipping/Test/Unit/Model/Plugin/Checkout/Block/Cart/ShippingTest.php b/app/code/Magento/OfflineShipping/Test/Unit/Model/Plugin/Checkout/Block/Cart/ShippingTest.php index 185f393ad4d0b..5f0894874ca3c 100644 --- a/app/code/Magento/OfflineShipping/Test/Unit/Model/Plugin/Checkout/Block/Cart/ShippingTest.php +++ b/app/code/Magento/OfflineShipping/Test/Unit/Model/Plugin/Checkout/Block/Cart/ShippingTest.php @@ -52,6 +52,9 @@ public function testAfterGetStateActive($scopeConfigMockReturnValue, $result, $a $this->assertEquals($assertResult, $this->model->afterIsStateActive($subjectMock, $result)); } + /** + * @return array + */ public function afterGetStateActiveDataProvider() { return [ diff --git a/app/code/Magento/OfflineShipping/Test/Unit/Model/ResourceModel/Carrier/Tablerate/CSV/RowParserTest.php b/app/code/Magento/OfflineShipping/Test/Unit/Model/ResourceModel/Carrier/Tablerate/CSV/RowParserTest.php index 2f6c5ca600bd3..661120c7b7c5f 100644 --- a/app/code/Magento/OfflineShipping/Test/Unit/Model/ResourceModel/Carrier/Tablerate/CSV/RowParserTest.php +++ b/app/code/Magento/OfflineShipping/Test/Unit/Model/ResourceModel/Carrier/Tablerate/CSV/RowParserTest.php @@ -128,6 +128,9 @@ public function testParseWithException(array $rowData, $conditionFullName, array throw $exception; } + /** + * @return array + */ public function parseWithExceptionDataProvider() { $rowData = ['a', 'b', 'c', 'd', 'e']; diff --git a/app/code/Magento/OfflineShipping/Test/Unit/Model/SalesRule/CalculatorTest.php b/app/code/Magento/OfflineShipping/Test/Unit/Model/SalesRule/CalculatorTest.php index b13a46a8fcdf0..2a886f20c42a7 100644 --- a/app/code/Magento/OfflineShipping/Test/Unit/Model/SalesRule/CalculatorTest.php +++ b/app/code/Magento/OfflineShipping/Test/Unit/Model/SalesRule/CalculatorTest.php @@ -20,6 +20,9 @@ protected function setUp() ); } + /** + * @return bool + */ public function testProcessFreeShipping() { $addressMock = $this->getMockBuilder(\Magento\Quote\Model\Quote\Address::class) diff --git a/app/code/Magento/PageCache/Test/Unit/Block/JavascriptTest.php b/app/code/Magento/PageCache/Test/Unit/Block/JavascriptTest.php index a1c66c67b5524..42a9086daa442 100644 --- a/app/code/Magento/PageCache/Test/Unit/Block/JavascriptTest.php +++ b/app/code/Magento/PageCache/Test/Unit/Block/JavascriptTest.php @@ -130,6 +130,9 @@ public function testGetScriptOptions($isSecure, $url, $expectedResult) $this->assertRegExp($expectedResult, $this->blockJavascript->getScriptOptions()); } + /** + * @return array + */ public function getScriptOptionsDataProvider() { return [ @@ -193,6 +196,9 @@ public function testGetScriptOptionsPrivateContent($url, $route, $controller, $a $this->assertRegExp($expectedResult, $this->blockJavascript->getScriptOptions()); } + /** + * @return array + */ public function getScriptOptionsPrivateContentDataProvider() { // @codingStandardsIgnoreStart diff --git a/app/code/Magento/PageCache/Test/Unit/Controller/Block/EsiTest.php b/app/code/Magento/PageCache/Test/Unit/Controller/Block/EsiTest.php index 4a7628c7ad839..9c7d55eb8550f 100644 --- a/app/code/Magento/PageCache/Test/Unit/Controller/Block/EsiTest.php +++ b/app/code/Magento/PageCache/Test/Unit/Controller/Block/EsiTest.php @@ -130,6 +130,9 @@ public function testExecute($blockClass, $shouldSetHeaders) $this->action->execute(); } + /** + * @return array + */ public function executeDataProvider() { return [ diff --git a/app/code/Magento/PageCache/Test/Unit/Model/App/FrontController/BuiltinPluginTest.php b/app/code/Magento/PageCache/Test/Unit/Model/App/FrontController/BuiltinPluginTest.php index 2811cb5316dc6..db0edfa6bd779 100644 --- a/app/code/Magento/PageCache/Test/Unit/Model/App/FrontController/BuiltinPluginTest.php +++ b/app/code/Magento/PageCache/Test/Unit/Model/App/FrontController/BuiltinPluginTest.php @@ -226,6 +226,9 @@ public function testAroundDispatchDisabled($state) ); } + /** + * @return array + */ public function dataProvider() { return [ diff --git a/app/code/Magento/PageCache/Test/Unit/Model/App/PageCachePluginTest.php b/app/code/Magento/PageCache/Test/Unit/Model/App/PageCachePluginTest.php index 033eb2501865b..2e69fdaf47910 100644 --- a/app/code/Magento/PageCache/Test/Unit/Model/App/PageCachePluginTest.php +++ b/app/code/Magento/PageCache/Test/Unit/Model/App/PageCachePluginTest.php @@ -57,6 +57,9 @@ public function testAfterSaveDecompression($data, $initResult) $this->assertSame($data, $this->plugin->afterLoad($this->subjectMock, $initResult)); } + /** + * @return array + */ public function afterSaveDataProvider() { return [ diff --git a/app/code/Magento/PageCache/Test/Unit/Model/App/Response/HttpPluginTest.php b/app/code/Magento/PageCache/Test/Unit/Model/App/Response/HttpPluginTest.php index c9231f118fc75..59591c8ee957f 100644 --- a/app/code/Magento/PageCache/Test/Unit/Model/App/Response/HttpPluginTest.php +++ b/app/code/Magento/PageCache/Test/Unit/Model/App/Response/HttpPluginTest.php @@ -26,6 +26,9 @@ public function testBeforeSendResponse($responseInstanceClass, $sendVaryCalled) $plugin->beforeSendResponse($responseMock); } + /** + * @return array + */ public function beforeSendResponseDataProvider() { return [ diff --git a/app/code/Magento/PageCache/Test/Unit/Model/Cache/ServerTest.php b/app/code/Magento/PageCache/Test/Unit/Model/Cache/ServerTest.php index 2321a951aafe8..a57effe1f31ad 100644 --- a/app/code/Magento/PageCache/Test/Unit/Model/Cache/ServerTest.php +++ b/app/code/Magento/PageCache/Test/Unit/Model/Cache/ServerTest.php @@ -90,6 +90,9 @@ public function testGetUris( $this->assertEquals($uris, $this->model->getUris()); } + /** + * @return array + */ public function getUrisDataProvider() { return [ diff --git a/app/code/Magento/PageCache/Test/Unit/Model/Layout/LayoutPluginTest.php b/app/code/Magento/PageCache/Test/Unit/Model/Layout/LayoutPluginTest.php index 8c04db7cb8390..6c39fe1e7979c 100644 --- a/app/code/Magento/PageCache/Test/Unit/Model/Layout/LayoutPluginTest.php +++ b/app/code/Magento/PageCache/Test/Unit/Model/Layout/LayoutPluginTest.php @@ -70,6 +70,9 @@ public function testAfterGenerateXml($cacheState, $layoutIsCacheable) $this->assertSame($result, $output); } + /** + * @return array + */ public function afterGenerateXmlDataProvider() { return [ @@ -112,6 +115,9 @@ public function testAfterGetOutput($cacheState, $layoutIsCacheable, $expectedTag $this->assertSame($output, $html); } + /** + * @return array + */ public function afterGetOutputDataProvider() { $tags = 'identity1,identity2'; diff --git a/app/code/Magento/PageCache/Test/Unit/Observer/FlushCacheByTagsTest.php b/app/code/Magento/PageCache/Test/Unit/Observer/FlushCacheByTagsTest.php index af5d0d0f95e8f..2cbd005183f7b 100644 --- a/app/code/Magento/PageCache/Test/Unit/Observer/FlushCacheByTagsTest.php +++ b/app/code/Magento/PageCache/Test/Unit/Observer/FlushCacheByTagsTest.php @@ -83,6 +83,9 @@ public function testExecute($cacheState) $this->assertNull($result); } + /** + * @return array + */ public function flushCacheByTagsDataProvider() { return [ diff --git a/app/code/Magento/Payment/Test/Unit/Block/InfoTest.php b/app/code/Magento/Payment/Test/Unit/Block/InfoTest.php index 469d7971e21a9..5f9238ca4360a 100644 --- a/app/code/Magento/Payment/Test/Unit/Block/InfoTest.php +++ b/app/code/Magento/Payment/Test/Unit/Block/InfoTest.php @@ -83,6 +83,9 @@ public function testGetIsSecureMode($isSecureMode, $methodInstance, $store, $sto $this->assertEquals($result, $expectedResult); } + /** + * @return array + */ public function getIsSecureModeDataProvider() { return [ diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Data/Order/AddressAdapterTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Data/Order/AddressAdapterTest.php index 1cf19ff9292e9..faf4818965386 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Data/Order/AddressAdapterTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Data/Order/AddressAdapterTest.php @@ -54,6 +54,9 @@ public function testStreetLine1($street, $expected) $this->assertEquals($expected, $this->model->getStreetLine1()); } + /** + * @return array + */ public function streetLine1DataProvider() { return [ @@ -73,6 +76,9 @@ public function testStreetLine2($street, $expected) $this->assertEquals($expected, $this->model->getStreetLine2()); } + /** + * @return array + */ public function streetLine2DataProvider() { return [ diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Data/Quote/AddressAdapterTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Data/Quote/AddressAdapterTest.php index 751d8c51b4410..1f5b1c2d87053 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Data/Quote/AddressAdapterTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Data/Quote/AddressAdapterTest.php @@ -54,6 +54,9 @@ public function testStreetLine1($street, $expected) $this->assertEquals($expected, $this->model->getStreetLine1()); } + /** + * @return array + */ public function streetLine1DataProvider() { return [ @@ -73,6 +76,9 @@ public function testStreetLine2($street, $expected) $this->assertEquals($expected, $this->model->getStreetLine2()); } + /** + * @return array + */ public function streetLine2DataProvider() { return [ diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Validator/CountryValidatorTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Validator/CountryValidatorTest.php index 0c808cb7c1faa..44d6144200504 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Validator/CountryValidatorTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Validator/CountryValidatorTest.php @@ -68,6 +68,9 @@ public function testValidateAllowspecificTrue($storeId, $country, $allowspecific $this->assertSame($this->resultMock, $this->model->validate($validationSubject)); } + /** + * @return array + */ public function validateAllowspecificTrueDataProvider() { return [ @@ -96,6 +99,9 @@ public function testValidateAllowspecificFalse($storeId, $allowspecific, $isVali $this->assertSame($this->resultMock, $this->model->validate($validationSubject)); } + /** + * @return array + */ public function validateAllowspecificFalseDataProvider() { return [ diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Validator/ResultTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Validator/ResultTest.php index fb81137dea42b..562835e3199f1 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Validator/ResultTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Validator/ResultTest.php @@ -29,6 +29,9 @@ public function testResult($isValid, $failsDescription, $expectedIsValid, $expec $this->assertEquals($expectedFailsDescription, $this->model->getFailsDescription()); } + /** + * @return array + */ public function resultDataProvider() { $phraseMock = $this->getMockBuilder(\Magento\Framework\Phrase::class)->disableOriginalConstructor()->getMock(); diff --git a/app/code/Magento/Payment/Test/Unit/Helper/DataTest.php b/app/code/Magento/Payment/Test/Unit/Helper/DataTest.php index 931c2b5fd93d5..3752e82fd1e5b 100644 --- a/app/code/Magento/Payment/Test/Unit/Helper/DataTest.php +++ b/app/code/Magento/Payment/Test/Unit/Helper/DataTest.php @@ -253,6 +253,9 @@ public function testGetInfoBlockHtml() $this->assertEquals($blockHtml, $this->helper->getInfoBlockHtml($infoMock, $storeId)); } + /** + * @return array + */ public function getSortMethodsDataProvider() { return [ diff --git a/app/code/Magento/Payment/Test/Unit/Model/Cart/SalesModel/FactoryTest.php b/app/code/Magento/Payment/Test/Unit/Model/Cart/SalesModel/FactoryTest.php index c49f3da315908..64069ff4a1941 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/Cart/SalesModel/FactoryTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/Cart/SalesModel/FactoryTest.php @@ -40,6 +40,9 @@ public function testCreate($salesModelClass, $expectedType) $this->assertEquals('some value', $this->_model->create($salesModel)); } + /** + * @return array + */ public function createDataProvider() { return [ diff --git a/app/code/Magento/Payment/Test/Unit/Model/Cart/SalesModel/OrderTest.php b/app/code/Magento/Payment/Test/Unit/Model/Cart/SalesModel/OrderTest.php index 7594d9ce501ac..3e3c4226d4fbe 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/Cart/SalesModel/OrderTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/Cart/SalesModel/OrderTest.php @@ -19,6 +19,9 @@ protected function setUp() $this->_model = new \Magento\Payment\Model\Cart\SalesModel\Order($this->_orderMock); } + /** + * @return array + */ public function gettersDataProvider() { return [ diff --git a/app/code/Magento/Payment/Test/Unit/Model/Cart/SalesModel/QuoteTest.php b/app/code/Magento/Payment/Test/Unit/Model/Cart/SalesModel/QuoteTest.php index 95271569e994e..bdcc89840ac19 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/Cart/SalesModel/QuoteTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/Cart/SalesModel/QuoteTest.php @@ -84,6 +84,9 @@ public function testGetAllItems($pItem, $name, $qty, $price) $this->assertEquals($expected, $this->_model->getAllItems()); } + /** + * @return array + */ public function getAllItemsDataProvider() { return [ @@ -135,6 +138,9 @@ public function testGetter($isVirtual, $getterMethod) $this->assertEquals($getterMethod, $model->{$getterMethod}()); } + /** + * @return array + */ public function getterDataProvider() { return [ diff --git a/app/code/Magento/Payment/Test/Unit/Model/ConfigTest.php b/app/code/Magento/Payment/Test/Unit/Model/ConfigTest.php index cd215e870462c..0e57777368fb7 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/ConfigTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/ConfigTest.php @@ -144,6 +144,9 @@ public function testGetActiveMethods($isActive) static::assertEquals($isActive ? ['active_method' => $adapter] : [], $this->config->getActiveMethods()); } + /** + * @return array + */ public function getActiveMethodsDataProvider() { return [[true], [false]]; diff --git a/app/code/Magento/Paypal/Test/Unit/Block/Adminhtml/System/Config/Field/CountryTest.php b/app/code/Magento/Paypal/Test/Unit/Block/Adminhtml/System/Config/Field/CountryTest.php index 39fc0c2dae5eb..d8487e63c6eca 100644 --- a/app/code/Magento/Paypal/Test/Unit/Block/Adminhtml/System/Config/Field/CountryTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Block/Adminhtml/System/Config/Field/CountryTest.php @@ -114,6 +114,9 @@ public function testRender($requestCountry, $requestDefaultCountry, $canUseDefau $this->_model->render($this->_element); } + /** + * @return array + */ public function renderDataProvider() { return [ diff --git a/app/code/Magento/Paypal/Test/Unit/Block/Adminhtml/System/Config/Fieldset/GroupTest.php b/app/code/Magento/Paypal/Test/Unit/Block/Adminhtml/System/Config/Fieldset/GroupTest.php index baf944dc44041..527aa4b9439ce 100644 --- a/app/code/Magento/Paypal/Test/Unit/Block/Adminhtml/System/Config/Fieldset/GroupTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Block/Adminhtml/System/Config/Fieldset/GroupTest.php @@ -93,6 +93,9 @@ public function testIsCollapseState($expanded, $expected) ); } + /** + * @return array + */ public function isCollapseStateDataProvider() { return [ diff --git a/app/code/Magento/Paypal/Test/Unit/Block/Adminhtml/System/Config/Fieldset/PaymentTest.php b/app/code/Magento/Paypal/Test/Unit/Block/Adminhtml/System/Config/Fieldset/PaymentTest.php index d9ddd277a7df1..df9638ef47135 100644 --- a/app/code/Magento/Paypal/Test/Unit/Block/Adminhtml/System/Config/Fieldset/PaymentTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Block/Adminhtml/System/Config/Fieldset/PaymentTest.php @@ -85,6 +85,9 @@ public function testIsPaymentEnabled($groupConfig, $expected) $this->assertContains($expected, $html); } + /** + * @return array + */ public function isPaymentEnabledDataProvider() { return [ diff --git a/app/code/Magento/Paypal/Test/Unit/Block/Express/ReviewTest.php b/app/code/Magento/Paypal/Test/Unit/Block/Express/ReviewTest.php index 9a7a87b366fcf..27ed799a4adb7 100644 --- a/app/code/Magento/Paypal/Test/Unit/Block/Express/ReviewTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Block/Express/ReviewTest.php @@ -84,6 +84,9 @@ public function testGetViewFileUrl($isSecure) $this->assertEquals('result url', $this->model->getViewFileUrl('some file')); } + /** + * @return array + */ public function getViewFileUrlDataProvider() { return [[true], [false]]; diff --git a/app/code/Magento/Paypal/Test/Unit/Controller/Express/PlaceOrderTest.php b/app/code/Magento/Paypal/Test/Unit/Controller/Express/PlaceOrderTest.php index 54d5acfce9f5f..f915dca23735d 100644 --- a/app/code/Magento/Paypal/Test/Unit/Controller/Express/PlaceOrderTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Controller/Express/PlaceOrderTest.php @@ -36,6 +36,9 @@ protected function _expectRedirect($path = '*/*/review') ->with($this->anything(), $path, []); } + /** + * @return array + */ public function trueFalseDataProvider() { return [[true], [false]]; @@ -79,6 +82,9 @@ public function testExecuteProcessableException($code, $paymentAction = null) $this->model->execute(); } + /** + * @return array + */ public function executeProcessableExceptionDataProvider() { return [ diff --git a/app/code/Magento/Paypal/Test/Unit/Controller/Express/ReturnActionTest.php b/app/code/Magento/Paypal/Test/Unit/Controller/Express/ReturnActionTest.php index fd0182bb88c06..65250ccce08bd 100644 --- a/app/code/Magento/Paypal/Test/Unit/Controller/Express/ReturnActionTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Controller/Express/ReturnActionTest.php @@ -34,6 +34,9 @@ public function testExecuteAuthorizationRetrial() $this->model->execute(); } + /** + * @return array + */ public function trueFalseDataProvider() { return [[true], [false]]; diff --git a/app/code/Magento/Paypal/Test/Unit/Controller/Express/StartTest.php b/app/code/Magento/Paypal/Test/Unit/Controller/Express/StartTest.php index 5ca7156b6f01f..36a9ae3bd5cf9 100644 --- a/app/code/Magento/Paypal/Test/Unit/Controller/Express/StartTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Controller/Express/StartTest.php @@ -37,6 +37,9 @@ public function testStartAction($buttonParam) $this->model->execute(); } + /** + * @return array + */ public function startActionDataProvider() { return [['1'], [null]]; diff --git a/app/code/Magento/Paypal/Test/Unit/Helper/BackendTest.php b/app/code/Magento/Paypal/Test/Unit/Helper/BackendTest.php index fd8a8a3c41f11..ffa1bf027ab57 100644 --- a/app/code/Magento/Paypal/Test/Unit/Helper/BackendTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Helper/BackendTest.php @@ -92,6 +92,9 @@ public function testGetConfigurationCountryCodeFromConfig($request) $this->configurationCountryCodeAssertResult('GB'); } + /** + * @return array + */ public function getConfigurationCountryCodeFromConfigDataProvider() { return [ @@ -116,6 +119,9 @@ public function testGetConfigurationCountryCodeFromDefault($request, $config, $d $this->configurationCountryCodeAssertResult($default); } + /** + * @return array + */ public function getConfigurationCountryCodeFromDefaultDataProvider() { return [ diff --git a/app/code/Magento/Paypal/Test/Unit/Model/AbstractConfigTest.php b/app/code/Magento/Paypal/Test/Unit/Model/AbstractConfigTest.php index bb25bea63a8bc..9ec9318212614 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/AbstractConfigTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/AbstractConfigTest.php @@ -273,6 +273,9 @@ public function testIsMethodAvailable($methodCode, $expectedFlag) $this->config->isMethodAvailable($methodCode); } + /** + * @return array + */ public function isMethodAvailableDataProvider() { return [ diff --git a/app/code/Magento/Paypal/Test/Unit/Model/Api/NvpTest.php b/app/code/Magento/Paypal/Test/Unit/Model/Api/NvpTest.php index c0b2bb4fc1dca..56fe0cc9e5824 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/Api/NvpTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/Api/NvpTest.php @@ -138,6 +138,9 @@ public function testCall($response, $processableErrors, $exception, $exceptionMe $this->model->call('some method', ['data' => 'some data']); } + /** + * @return array + */ public function callDataProvider() { return [ diff --git a/app/code/Magento/Paypal/Test/Unit/Model/CartTest.php b/app/code/Magento/Paypal/Test/Unit/Model/CartTest.php index f9bb74dba5b53..0f787f0f513a1 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/CartTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/CartTest.php @@ -85,6 +85,9 @@ public function testInvalidGetAllItems($items) $this->assertEquals(0.3, $this->_model->getDiscount()); } + /** + * @return array + */ public function invalidGetAllItemsDataProvider() { return [ @@ -150,6 +153,9 @@ public function testInvalidTotalsGetAllItems($values, $transferDiscount) $this->assertEquals($transferDiscount ? 0.0 : $values['base_discount_amount'], $this->_model->getDiscount()); } + /** + * @return array + */ public function invalidTotalsGetAllItemsDataProvider() { return [ @@ -222,6 +228,9 @@ public function testInvalidGetAmounts($values, $transferDiscount, $transferShipp $this->assertEquals([Cart::AMOUNT_SUBTOTAL => $expectedSubtotal], $result); } + /** + * @return array + */ public function invalidGetAmountsDataProvider() { $data = []; diff --git a/app/code/Magento/Paypal/Test/Unit/Model/Config/Structure/PaymentSectionModifierTest.php b/app/code/Magento/Paypal/Test/Unit/Model/Config/Structure/PaymentSectionModifierTest.php index 6a5b2676014cb..57534345f2541 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/Config/Structure/PaymentSectionModifierTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/Config/Structure/PaymentSectionModifierTest.php @@ -175,6 +175,9 @@ private function fetchAllAvailableGroups($structure) return $availableGroups; } + /** + * @return mixed + */ public function caseProvider() { return include __DIR__ . '/_files/payment_section_structure_variations.php'; diff --git a/app/code/Magento/Paypal/Test/Unit/Model/Hostedpro/RequestTest.php b/app/code/Magento/Paypal/Test/Unit/Model/Hostedpro/RequestTest.php index 2a3ac1adbc07a..ed834ae2b9c01 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/Hostedpro/RequestTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/Hostedpro/RequestTest.php @@ -371,6 +371,9 @@ public function amountWithoutTaxDataProvider() ]; } + /** + * @return array + */ public function amountWithoutTaxZeroSubtotalDataProvider() { return [ diff --git a/app/code/Magento/Paypal/Test/Unit/Model/PayflowproTest.php b/app/code/Magento/Paypal/Test/Unit/Model/PayflowproTest.php index c9689c8601a02..3e8af6b2ee766 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/PayflowproTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/PayflowproTest.php @@ -179,6 +179,9 @@ public function testSetTransStatus($response, $paymentExpected) $this->assertEquals($paymentExpected->getData(), $payment->getData()); } + /** + * @return array + */ public function setTransStatusDataProvider() { return [ diff --git a/app/code/Magento/Paypal/Test/Unit/Observer/AddBillingAgreementToSessionObserverTest.php b/app/code/Magento/Paypal/Test/Unit/Observer/AddBillingAgreementToSessionObserverTest.php index c1947c522b118..8e18b680ce9cd 100644 --- a/app/code/Magento/Paypal/Test/Unit/Observer/AddBillingAgreementToSessionObserverTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Observer/AddBillingAgreementToSessionObserverTest.php @@ -166,6 +166,9 @@ public function testAddBillingAgreementToSession($isValid) $this->_model->execute($this->_observer); } + /** + * @return array + */ public function addBillingAgreementToSessionDataProvider() { return [[true], [false]]; diff --git a/app/code/Magento/Paypal/Test/Unit/Observer/RestrictAdminBillingAgreementUsageObserverTest.php b/app/code/Magento/Paypal/Test/Unit/Observer/RestrictAdminBillingAgreementUsageObserverTest.php index abad48e49f261..381a8d971052c 100644 --- a/app/code/Magento/Paypal/Test/Unit/Observer/RestrictAdminBillingAgreementUsageObserverTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Observer/RestrictAdminBillingAgreementUsageObserverTest.php @@ -48,6 +48,9 @@ protected function setUp() $this->_model = new \Magento\Paypal\Observer\RestrictAdminBillingAgreementUsageObserver($this->_authorization); } + /** + * @return array + */ public function restrictAdminBillingAgreementUsageDataProvider() { return [ diff --git a/app/code/Magento/Persistent/Test/Unit/Observer/RefreshCustomerDataTest.php b/app/code/Magento/Persistent/Test/Unit/Observer/RefreshCustomerDataTest.php index da60f8a3162ac..ca415a8fab5b3 100644 --- a/app/code/Magento/Persistent/Test/Unit/Observer/RefreshCustomerDataTest.php +++ b/app/code/Magento/Persistent/Test/Unit/Observer/RefreshCustomerDataTest.php @@ -80,6 +80,9 @@ public function testBeforeStart($result, $callCount) $this->observer->execute($observerMock); } + /** + * @return array + */ public function beforeStartDataProvider() { return [ diff --git a/app/code/Magento/ProductAlert/Test/Unit/Block/Email/StockTest.php b/app/code/Magento/ProductAlert/Test/Unit/Block/Email/StockTest.php index 13bcc2273d93b..815c4f941e683 100644 --- a/app/code/Magento/ProductAlert/Test/Unit/Block/Email/StockTest.php +++ b/app/code/Magento/ProductAlert/Test/Unit/Block/Email/StockTest.php @@ -55,6 +55,9 @@ public function testGetFilteredContent($contentToFilter, $contentFiltered) $this->assertEquals($contentFiltered, $this->_block->getFilteredContent($contentToFilter)); } + /** + * @return array + */ public function getFilteredContentDataProvider() { return [ diff --git a/app/code/Magento/ProductAlert/Test/Unit/Block/Product/View/StockTest.php b/app/code/Magento/ProductAlert/Test/Unit/Block/Product/View/StockTest.php index 886ed6eb3fe27..b9f28bde15d07 100644 --- a/app/code/Magento/ProductAlert/Test/Unit/Block/Product/View/StockTest.php +++ b/app/code/Magento/ProductAlert/Test/Unit/Block/Product/View/StockTest.php @@ -126,6 +126,9 @@ public function testSetTemplateStockUrlNotAllowed($stockAlertAllowed, $productAv $this->assertNull($this->_block->getSignupUrl()); } + /** + * @return array + */ public function setTemplateStockUrlNotAllowedDataProvider() { return [ diff --git a/app/code/Magento/Quote/Test/Unit/Model/Cart/CartTotalManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/Cart/CartTotalManagementTest.php index 287d2b3c8d4f0..d6338eb428657 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Cart/CartTotalManagementTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Cart/CartTotalManagementTest.php @@ -92,6 +92,9 @@ public function testCollectTotalsNoShipping($shippingCarrierCode, $shippingMetho ); } + /** + * @return array + */ public function collectTotalsShippingData() { return [ diff --git a/app/code/Magento/Quote/Test/Unit/Model/Cart/CartTotalRepositoryTest.php b/app/code/Magento/Quote/Test/Unit/Model/Cart/CartTotalRepositoryTest.php index b1cec90e61e01..1e999cb5e523e 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Cart/CartTotalRepositoryTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Cart/CartTotalRepositoryTest.php @@ -163,6 +163,9 @@ public function testGet($isVirtual, $getAddressType) $this->assertEquals($totalsMock, $this->model->get($cartId)); } + /** + * @return array + */ public function getDataProvider() { return [ diff --git a/app/code/Magento/Quote/Test/Unit/Model/Product/Plugin/UpdateQuoteItemsTest.php b/app/code/Magento/Quote/Test/Unit/Model/Product/Plugin/UpdateQuoteItemsTest.php index 38f303dd23582..cd7a54455a994 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Product/Plugin/UpdateQuoteItemsTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Product/Plugin/UpdateQuoteItemsTest.php @@ -49,6 +49,9 @@ public function testAfterUpdate($originalPrice, $newPrice, $callMethod, $tierPri $this->assertEquals($result, $productResourceMock); } + /** + * @return array + */ public function aroundUpdateDataProvider() { return [ diff --git a/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/Total/SubtotalTest.php b/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/Total/SubtotalTest.php index 78a87b59d9f62..c4a8081fbb8fa 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/Total/SubtotalTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/Total/SubtotalTest.php @@ -49,6 +49,9 @@ protected function setUp() ); } + /** + * @return array + */ public function collectDataProvider() { return [ diff --git a/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/TotalTest.php b/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/TotalTest.php index f884981424d65..e1971fa9833a3 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/TotalTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/TotalTest.php @@ -49,6 +49,9 @@ public function testSetTotalAmount($code, $amount, $storedCode) $this->assertSame($this->model, $result); } + /** + * @return array + */ public function setTotalAmountDataProvider() { return [ @@ -80,6 +83,9 @@ public function testSetBaseTotalAmount($code, $amount, $storedCode) $this->assertSame($this->model, $result); } + /** + * @return array + */ public function setBaseTotalAmountDataProvider() { return [ @@ -111,6 +117,9 @@ public function testAddTotalAmount($initialAmount, $delta, $updatedAmount) $this->assertEquals($updatedAmount, $this->model->getTotalAmount($code)); } + /** + * @return array + */ public function addTotalAmountDataProvider() { return [ @@ -142,6 +151,9 @@ public function testAddBaseTotalAmount($initialAmount, $delta, $updatedAmount) $this->assertEquals($updatedAmount, $this->model->getBaseTotalAmount($code)); } + /** + * @return array + */ public function addBaseTotalAmountDataProvider() { return [ diff --git a/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/RelatedProductsTest.php b/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/RelatedProductsTest.php index a73a241922a9c..8be4479598907 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/RelatedProductsTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/RelatedProductsTest.php @@ -61,6 +61,9 @@ public function testGetRelatedProductIds($optionValue, $productId, $expectedResu * * @return array */ + /** + * @return array + */ public function getRelatedProductIdsDataProvider() { return [ diff --git a/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/UpdaterTest.php b/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/UpdaterTest.php index 03c3e32c20cb9..af47f6276705b 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/UpdaterTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/UpdaterTest.php @@ -130,6 +130,9 @@ public function testUpdateNotQtyDecimal($qty, $expectedQty) $this->assertEquals($result, $this->object); } + /** + * @return array + */ public function qtyProvider() { return [ @@ -142,6 +145,9 @@ public function qtyProvider() ]; } + /** + * @return array + */ public function qtyProviderDecimal() { return [ diff --git a/app/code/Magento/Quote/Test/Unit/Model/Quote/ItemTest.php b/app/code/Magento/Quote/Test/Unit/Model/Quote/ItemTest.php index 1da659f6b59b7..abc56d194456d 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Quote/ItemTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Quote/ItemTest.php @@ -846,6 +846,12 @@ public function testSetOptionsWithNull() $this->assertEquals($this->model, $this->model->setOptions(null)); } + /** + * @param $optionCode + * @param array $optionData + * + * @return \PHPUnit_Framework_MockObject_MockObject + */ private function createOptionMock($optionCode, $optionData = []) { $optionMock = $this->getMockBuilder(\Magento\Quote\Model\Quote\Item\Option::class) diff --git a/app/code/Magento/Quote/Test/Unit/Model/QuoteTest.php b/app/code/Magento/Quote/Test/Unit/Model/QuoteTest.php index c0056e2c8338f..6f5e5937a32c8 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/QuoteTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/QuoteTest.php @@ -615,6 +615,9 @@ public function testGetAddressById($addressId, $expected) $this->assertEquals((bool)$expected, (bool)$result); } + /** + * @return array + */ public static function dataProviderGetAddress() { return [ @@ -656,6 +659,9 @@ public function testGetAddressByCustomerAddressId($isDeleted, $customerAddressId $this->assertEquals((bool)$expected, (bool)$result); } + /** + * @return array + */ public static function dataProviderGetAddressByCustomer() { return [ @@ -702,6 +708,9 @@ public function testGetShippingAddressByCustomerAddressId($isDeleted, $addressTy $this->assertEquals($expected, (bool)$result); } + /** + * @return array + */ public static function dataProviderShippingAddress() { return [ @@ -1204,6 +1213,9 @@ public function testReserveOrderId($isReservedOrderIdExist, $reservedOrderId) $this->assertEquals($reservedOrderId, $this->quote->getReservedOrderId()); } + /** + * @return array + */ public function reservedOrderIdDataProvider() { return [ diff --git a/app/code/Magento/Quote/Test/Unit/Observer/Backend/CustomerQuoteObserverTest.php b/app/code/Magento/Quote/Test/Unit/Observer/Backend/CustomerQuoteObserverTest.php index d10e1531d4ec3..7bbf24c2b6ef3 100644 --- a/app/code/Magento/Quote/Test/Unit/Observer/Backend/CustomerQuoteObserverTest.php +++ b/app/code/Magento/Quote/Test/Unit/Observer/Backend/CustomerQuoteObserverTest.php @@ -160,6 +160,9 @@ public function testDispatch($isWebsiteScope, $websites) $this->customerQuote->execute($this->observerMock); } + /** + * @return array + */ public function dispatchDataProvider() { return [ diff --git a/app/code/Magento/ReleaseNotification/Controller/Adminhtml/Notification/MarkUserNotified.php b/app/code/Magento/ReleaseNotification/Controller/Adminhtml/Notification/MarkUserNotified.php index 572fb7695b20f..56f836fff9522 100644 --- a/app/code/Magento/ReleaseNotification/Controller/Adminhtml/Notification/MarkUserNotified.php +++ b/app/code/Magento/ReleaseNotification/Controller/Adminhtml/Notification/MarkUserNotified.php @@ -85,6 +85,9 @@ public function execute() return $resultJson->setData($responseContent); } + /** + * @return bool + */ protected function _isAllowed() { return parent::_isAllowed(); diff --git a/app/code/Magento/ReleaseNotification/Test/Unit/Model/Condition/CanViewNotificationTest.php b/app/code/Magento/ReleaseNotification/Test/Unit/Model/Condition/CanViewNotificationTest.php index 3ec00697507c1..813c5f28bf4d9 100644 --- a/app/code/Magento/ReleaseNotification/Test/Unit/Model/Condition/CanViewNotificationTest.php +++ b/app/code/Magento/ReleaseNotification/Test/Unit/Model/Condition/CanViewNotificationTest.php @@ -113,6 +113,9 @@ public function testIsVisible($expected, $version, $lastViewVersion) $this->assertEquals($expected, $this->canViewNotification->isVisible([])); } + /** + * @return array + */ public function isVisibleProvider() { return [ diff --git a/app/code/Magento/Review/Test/Unit/Block/FormTest.php b/app/code/Magento/Review/Test/Unit/Block/FormTest.php index 2184385035c8d..1fd38551702ab 100644 --- a/app/code/Magento/Review/Test/Unit/Block/FormTest.php +++ b/app/code/Magento/Review/Test/Unit/Block/FormTest.php @@ -136,6 +136,9 @@ public function testGetAction($isSecure, $actionUrl, $productId) $this->assertEquals($actionUrl . '/id/' . $productId, $this->object->getAction()); } + /** + * @return array + */ public function getActionDataProvider() { return [ diff --git a/app/code/Magento/Review/Test/Unit/Block/Product/ReviewTest.php b/app/code/Magento/Review/Test/Unit/Block/Product/ReviewTest.php index 243b4e8389923..01868242d0e0c 100644 --- a/app/code/Magento/Review/Test/Unit/Block/Product/ReviewTest.php +++ b/app/code/Magento/Review/Test/Unit/Block/Product/ReviewTest.php @@ -204,6 +204,9 @@ public function testGetProductReviewUrl($isSecure, $actionUrl, $productId) $this->assertEquals($actionUrl . '/id/' . $productId, $this->block->getProductReviewUrl()); } + /** + * @return array + */ public function getProductReviewUrlDataProvider() { return [ diff --git a/app/code/Magento/Review/Test/Unit/Model/ResourceModel/Review/CollectionTest.php b/app/code/Magento/Review/Test/Unit/Model/ResourceModel/Review/CollectionTest.php index b3d2cec648dc6..36cbe455fa890 100644 --- a/app/code/Magento/Review/Test/Unit/Model/ResourceModel/Review/CollectionTest.php +++ b/app/code/Magento/Review/Test/Unit/Model/ResourceModel/Review/CollectionTest.php @@ -147,6 +147,9 @@ public function testAddEntityFilter( $this->model->addEntityFilter($entity, $pkValue); } + /** + * @return array + */ public function addEntityFilterDataProvider() { return [ diff --git a/app/code/Magento/Rule/Test/Unit/Model/Condition/AbstractConditionTest.php b/app/code/Magento/Rule/Test/Unit/Model/Condition/AbstractConditionTest.php index 1201ba92464d9..52653197e3981 100644 --- a/app/code/Magento/Rule/Test/Unit/Model/Condition/AbstractConditionTest.php +++ b/app/code/Magento/Rule/Test/Unit/Model/Condition/AbstractConditionTest.php @@ -40,6 +40,9 @@ public function testGetMappedSqlField() $this->assertEquals('category_ids', $this->_condition->getMappedSqlField()); } + /** + * @return array + */ public function validateAttributeDataProvider() { return [ @@ -146,6 +149,9 @@ public function testValidate($existingValue, $operator, $valueForValidate, $expe ); } + /** + * @return array + */ public function validateAttributeArrayInputTypeDataProvider() { return [ diff --git a/app/code/Magento/Rule/Test/Unit/Model/ResourceModel/Rule/Collection/AbstractCollectionTest.php b/app/code/Magento/Rule/Test/Unit/Model/ResourceModel/Rule/Collection/AbstractCollectionTest.php index 644d10ad75fe6..c4e7a591212c5 100644 --- a/app/code/Magento/Rule/Test/Unit/Model/ResourceModel/Rule/Collection/AbstractCollectionTest.php +++ b/app/code/Magento/Rule/Test/Unit/Model/ResourceModel/Rule/Collection/AbstractCollectionTest.php @@ -91,6 +91,9 @@ protected function setUp() ); } + /** + * @return array + */ public function addWebsitesToResultDataProvider() { return [ diff --git a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Create/Items/GridTest.php b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Create/Items/GridTest.php index e07fecf4cb116..805cdb045584c 100644 --- a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Create/Items/GridTest.php +++ b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Create/Items/GridTest.php @@ -258,6 +258,9 @@ public function testGetItems() $this->assertEquals(true, $this->block->getQuote()->getIsSuperMode()); } + /** + * @return \Magento\Sales\Block\Adminhtml\Order\Create\Items\Grid + */ protected function getGrid() { /** @var \Magento\Sales\Block\Adminhtml\Order\Create\Items\Grid $grid */ diff --git a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Create/Sidebar/AbstractSidebarTest.php b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Create/Sidebar/AbstractSidebarTest.php index a52d8e1b7f9f9..7b94e769eff9a 100644 --- a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Create/Sidebar/AbstractSidebarTest.php +++ b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Create/Sidebar/AbstractSidebarTest.php @@ -39,6 +39,9 @@ public function testGetItemQty($itemQty, $qty, $expectedValue) $this->assertEquals($expectedValue, $this->abstractSidebar->getItemQty($this->itemMock)); } + /** + * @return array + */ public function getItemQtyDataProvider() { return ['whenQtyIsset' => [2, 10, 10], 'whenQtyNotIsset' => [1, false, 1]]; diff --git a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Invoice/ViewTest.php b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Invoice/ViewTest.php index 773694897291c..8f94ea8982ddf 100644 --- a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Invoice/ViewTest.php +++ b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Invoice/ViewTest.php @@ -54,6 +54,9 @@ public function testIsPaymentReview($canReviewPayment, $canFetchUpdate, $expecte $this->assertEquals($expectedResult, $testMethod->invoke($block)); } + /** + * @return array + */ public function isPaymentReviewDataProvider() { return [ diff --git a/app/code/Magento/Sales/Test/Unit/Block/Order/TotalsTest.php b/app/code/Magento/Sales/Test/Unit/Block/Order/TotalsTest.php index 7ad21f26a8bea..be0ae41347ba8 100644 --- a/app/code/Magento/Sales/Test/Unit/Block/Order/TotalsTest.php +++ b/app/code/Magento/Sales/Test/Unit/Block/Order/TotalsTest.php @@ -51,6 +51,10 @@ public function testApplySortOrder() ); } + /** + * @param array $expected + * @param array $actual + */ private function assertEqualsSorted(array $expected, array $actual) { $this->assertEquals($expected, $actual, 'Array contents should be equal.'); diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Create/ProcessDataTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Create/ProcessDataTest.php index 2b6436395a0cf..ab4bf5fbbe491 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Create/ProcessDataTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Create/ProcessDataTest.php @@ -235,6 +235,9 @@ public function testExecute($noDiscount, $couponCode, $errorMessage, $actualCoup $this->assertInstanceOf(\Magento\Backend\Model\View\Result\Forward::class, $this->processData->execute()); } + /** + * @return array + */ public function isApplyDiscountDataProvider() { return [ diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Download/DownloadCustomOptionTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Download/DownloadCustomOptionTest.php index 19cbec9d1a06b..d0d7e7efa97f7 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Download/DownloadCustomOptionTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Download/DownloadCustomOptionTest.php @@ -216,6 +216,9 @@ public function testExecute($itemOptionValues, $productOptionValues, $noRouteOcc $this->objectMock->execute(); } + /** + * @return array + */ public function executeDataProvider() { return [ diff --git a/app/code/Magento/Sales/Test/Unit/Cron/CleanExpiredQuotesTest.php b/app/code/Magento/Sales/Test/Unit/Cron/CleanExpiredQuotesTest.php index fd20e0cb7d94a..e424cae85f223 100644 --- a/app/code/Magento/Sales/Test/Unit/Cron/CleanExpiredQuotesTest.php +++ b/app/code/Magento/Sales/Test/Unit/Cron/CleanExpiredQuotesTest.php @@ -70,6 +70,9 @@ public function testExecute($lifetimes, $additionalFilterFields) $this->observer->execute(); } + /** + * @return array + */ public function cleanExpiredQuotesDataProvider() { return [ diff --git a/app/code/Magento/Sales/Test/Unit/CustomerData/LastOrderedItemsTest.php b/app/code/Magento/Sales/Test/Unit/CustomerData/LastOrderedItemsTest.php index 4304bf00981e1..e14da1ac1b5ab 100644 --- a/app/code/Magento/Sales/Test/Unit/CustomerData/LastOrderedItemsTest.php +++ b/app/code/Magento/Sales/Test/Unit/CustomerData/LastOrderedItemsTest.php @@ -176,6 +176,9 @@ public function testGetSectionData() $this->assertEquals(['items' => [$expectedItem1, $expectedItem2]], $this->section->getSectionData()); } + /** + * @return \PHPUnit_Framework_MockObject_MockObject + */ private function getLastOrderMock() { $customerId = 1; diff --git a/app/code/Magento/Sales/Test/Unit/Helper/AdminTest.php b/app/code/Magento/Sales/Test/Unit/Helper/AdminTest.php index 180cfca0bc3cb..389064b7274a7 100644 --- a/app/code/Magento/Sales/Test/Unit/Helper/AdminTest.php +++ b/app/code/Magento/Sales/Test/Unit/Helper/AdminTest.php @@ -198,6 +198,9 @@ public function testDisplayPriceAttribute( ); } + /** + * @return array + */ public function displayPricesDataProvider() { return [ @@ -310,6 +313,9 @@ public function testApplySalableProductTypesFilter($itemKey, $type, $calledTimes $this->adminHelper->applySalableProductTypesFilter($collectionMock); } + /** + * @return array + */ public function applySalableProductTypesFilterDataProvider() { return [ diff --git a/app/code/Magento/Sales/Test/Unit/Model/InvoiceOrderTest.php b/app/code/Magento/Sales/Test/Unit/Model/InvoiceOrderTest.php index 014e0e28b49ee..02f855929d9d6 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/InvoiceOrderTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/InvoiceOrderTest.php @@ -428,6 +428,9 @@ public function testCouldNotInvoiceException() ); } + /** + * @return array + */ public function dataProvider() { return [ diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/AddressTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/AddressTest.php index 73838379490fd..93eb56a07955c 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/AddressTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/AddressTest.php @@ -78,6 +78,9 @@ public function testGetRegionCodeRegionIsSet() $this->assertEquals('region', $this->address->getRegionCode()); } + /** + * @return array + */ public function regionProvider() { return [ [1, null], [null, 1]]; diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Item/Validation/CreateQuantityValidatorTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Item/Validation/CreateQuantityValidatorTest.php index c911af3044e5d..24a64c37a5e13 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Item/Validation/CreateQuantityValidatorTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Item/Validation/CreateQuantityValidatorTest.php @@ -97,6 +97,9 @@ public function testValidateCreditMemoProductItems($orderItemId, $expectedResult $this->assertEquals($expectedResult, $this->createQuantityValidator->validate($this->entity)); } + /** + * @return array + */ public function dataProvider() { return [ diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/RefundOperationTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/RefundOperationTest.php index f917d69e69f79..9172a6f45bbcd 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/RefundOperationTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/RefundOperationTest.php @@ -364,6 +364,9 @@ public function baseAmountsDataProvider() ]; } + /** + * @param $amounts + */ private function setBaseAmounts($amounts) { foreach ($amounts as $amountName => $summands) { @@ -403,6 +406,9 @@ private function registerItems() ->willReturn([$item1, $item2, $item3]); } + /** + * @return \PHPUnit_Framework_MockObject_MockObject + */ private function getCreditmemoItemMock() { return $this->getMockBuilder(\Magento\Sales\Api\Data\CreditmemoItemInterface::class) diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/AbstractSenderTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/AbstractSenderTest.php index 97dc973e63437..afb76c982d7c2 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/AbstractSenderTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/AbstractSenderTest.php @@ -120,6 +120,10 @@ public function stepMockSetup() $this->loggerMock = $this->createMock(\Psr\Log\LoggerInterface::class); } + /** + * @param $billingAddress + * @param bool $isVirtual + */ public function stepAddressFormat($billingAddress, $isVirtual = false) { $this->orderMock->expects($this->any()) @@ -145,6 +149,9 @@ public function stepSendWithCallSendCopyTo() $this->stepSend($this->never(), $this->once()); } + /** + * @param $identityMockClassName + */ public function stepIdentityContainerInit($identityMockClassName) { $this->identityContainerMock = $this->createPartialMock( @@ -156,6 +163,10 @@ public function stepIdentityContainerInit($identityMockClassName) ->will($this->returnValue($this->storeMock)); } + /** + * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $sendExpects + * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $sendCopyToExpects + */ protected function stepSend( \PHPUnit_Framework_MockObject_Matcher_InvokedCount $sendExpects, \PHPUnit_Framework_MockObject_Matcher_InvokedCount $sendCopyToExpects diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/InvoiceQuantityValidatorTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/InvoiceQuantityValidatorTest.php index 5d3e9ae22e78b..5a0478dd2e36f 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/InvoiceQuantityValidatorTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/InvoiceQuantityValidatorTest.php @@ -156,6 +156,12 @@ public function testValidateNoInvoiceItems() ); } + /** + * @param $orderItemId + * @param $qty + * + * @return \PHPUnit_Framework_MockObject_MockObject + */ private function getInvoiceItemMock($orderItemId, $qty) { $invoiceItemMock = $this->getMockBuilder(\Magento\Sales\Api\Data\InvoiceItemInterface::class) @@ -167,6 +173,13 @@ private function getInvoiceItemMock($orderItemId, $qty) return $invoiceItemMock; } + /** + * @param $id + * @param $qtyToInvoice + * @param $isDummy + * + * @return \PHPUnit_Framework_MockObject_MockObject + */ private function getOrderItemMock($id, $qtyToInvoice, $isDummy) { $orderItemMock = $this->getMockBuilder(\Magento\Sales\Api\Data\OrderItemInterface::class) diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/InvoiceTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/InvoiceTest.php index 0517da8b85cf0..8c972801c5520 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/InvoiceTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/InvoiceTest.php @@ -138,6 +138,9 @@ public function testDefaultCanVoid($canVoid) $this->assertEquals($canVoid, $this->model->canVoid()); } + /** + * @return array + */ public function canVoidDataProvider() { return [[true], [false]]; @@ -382,6 +385,9 @@ public function testPay( self::assertEquals($expectedTotal, $this->order->getTotalPaid()); } + /** + * @return array + */ public function payDataProvider() { return [ diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/ItemTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/ItemTest.php index 03a388410f335..aea234959cea0 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/ItemTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/ItemTest.php @@ -140,6 +140,9 @@ public function testGetStatusId( $this->assertEquals($expectedStatus, $this->model->getStatusId()); } + /** + * @return array + */ public function getStatusIdDataProvider() { return [ diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/RepositoryTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/RepositoryTest.php index 66ac821006266..8a40fbd20ef48 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/RepositoryTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/RepositoryTest.php @@ -149,6 +149,11 @@ public function testGetList() $this->assertSame($this->collection, $this->repository->getList($this->searchCriteria)); } + /** + * @param bool $id + * + * @return \PHPUnit_Framework_MockObject_MockObject + */ protected function mockPayment($id = false) { $payment = $this->createMock(\Magento\Sales\Model\Order\Payment::class); diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/Transaction/BuilderTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/Transaction/BuilderTest.php index 1ea3aeedea51c..ea11604c53c45 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/Transaction/BuilderTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/Transaction/BuilderTest.php @@ -257,6 +257,9 @@ protected function expectsIsPaymentTransactionClosed($isPaymentTransactionClosed ->willReturn($isPaymentTransactionClosed); } + /** + * @return array + */ public function createDataProvider() { return [ diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/Transaction/ManagerTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/Transaction/ManagerTest.php index 34b874c073a5a..13f6b9c607586 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/Transaction/ManagerTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/Transaction/ManagerTest.php @@ -155,6 +155,9 @@ public function generateTransactionIdDataProvider() ]; } + /** + * @return array + */ public function isTransactionExistsDataProvider() { return [ @@ -165,6 +168,9 @@ public function isTransactionExistsDataProvider() ]; } + /** + * @return array + */ public function getAuthorizationDataProvider() { return [ diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php index ee7e07873da51..52762b0dbf315 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php @@ -600,6 +600,9 @@ public function testAcceptApprovePaymentTrue() self::assertEquals($baseGrandTotal, $this->payment->getBaseAmountPaidOnline()); } + /** + * @return array + */ public function acceptPaymentFalseProvider() { return [ @@ -1532,6 +1535,9 @@ public function testRefund() static::assertEquals($amount, $this->payment->getData('base_amount_refunded')); } + /** + * @return array + */ public function boolProvider() { return [ @@ -1570,6 +1576,9 @@ public function testGetShouldCloseParentTransaction() static::assertFalse($this->payment->getShouldCloseParentTransaction()); } + /** + * @return object + */ protected function initPayment() { return (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject( @@ -1589,6 +1598,12 @@ protected function initPayment() ); } + /** + * @param $state + * @param null $status + * @param null $message + * @param null $isCustomerNotified + */ protected function assertOrderUpdated( $state, $status = null, @@ -1617,6 +1632,11 @@ protected function assertOrderUpdated( ->willReturn($statusHistory); } + /** + * @param $state + * @param $status + * @param array $allStatuses + */ protected function mockGetDefaultStatus($state, $status, $allStatuses = []) { /** @var \Magento\Sales\Model\Order\Config | \PHPUnit_Framework_MockObject_MockObject $orderConfigMock */ @@ -1642,6 +1662,11 @@ protected function mockGetDefaultStatus($state, $status, $allStatuses = []) ->will($this->returnValue($orderConfigMock)); } + /** + * @param $transactionId + * + * @return MockObject + */ protected function getTransactionMock($transactionId) { $transaction = $this->createPartialMock(\Magento\Sales\Model\Order\Payment\Transaction::class, [ diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/StatusResolverTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/StatusResolverTest.php index 28c29cd7a3bdf..57a4d5f40aa36 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/StatusResolverTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/StatusResolverTest.php @@ -27,6 +27,9 @@ public function testGetOrderStatusByState($order, $expectedReturn) self::assertEquals($expectedReturn, $actualReturn); } + /** + * @return array + */ public function statesDataProvider() { return [ diff --git a/app/code/Magento/Sales/Test/Unit/Model/OrderTest.php b/app/code/Magento/Sales/Test/Unit/Model/OrderTest.php index fb1970638753f..7f6363346872c 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/OrderTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/OrderTest.php @@ -845,6 +845,9 @@ protected function prepareItemMock($qtyInvoiced) ->will($this->returnValue($itemCollectionMock)); } + /** + * @return array + */ public function canVoidPaymentDataProvider() { $data = []; @@ -856,6 +859,9 @@ public function canVoidPaymentDataProvider() return $data; } + /** + * @return array + */ public function dataProviderActionFlag() { return [ @@ -1076,6 +1082,9 @@ public function testGetCreatedAtFormattedUsesCorrectLocale() $this->order->getCreatedAtFormatted(\IntlDateFormatter::SHORT); } + /** + * @return array + */ public function notInvoicingStatesProvider() { return [ @@ -1085,6 +1094,9 @@ public function notInvoicingStatesProvider() ]; } + /** + * @return array + */ public function canNotCreditMemoStatesProvider() { return [ diff --git a/app/code/Magento/Sales/Test/Unit/Model/RefundInvoiceTest.php b/app/code/Magento/Sales/Test/Unit/Model/RefundInvoiceTest.php index 5a8c1032cd4fc..5148752e9831a 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/RefundInvoiceTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/RefundInvoiceTest.php @@ -463,6 +463,9 @@ public function testCouldNotCreditmemoException() ); } + /** + * @return array + */ public function dataProvider() { $creditmemoItemCreationMock = $this->getMockBuilder(CreditmemoItemCreationInterface::class) diff --git a/app/code/Magento/Sales/Test/Unit/Model/RefundOrderTest.php b/app/code/Magento/Sales/Test/Unit/Model/RefundOrderTest.php index 8bc3288af04cf..c95b56d81d6f4 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/RefundOrderTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/RefundOrderTest.php @@ -407,6 +407,9 @@ public function testCouldNotCreditmemoException() ); } + /** + * @return array + */ public function dataProvider() { return [ diff --git a/app/code/Magento/Sales/Test/Unit/Observer/Frontend/AddVatRequestParamsOrderCommentTest.php b/app/code/Magento/Sales/Test/Unit/Observer/Frontend/AddVatRequestParamsOrderCommentTest.php index 395b653b0be8d..45cbea7307f4d 100644 --- a/app/code/Magento/Sales/Test/Unit/Observer/Frontend/AddVatRequestParamsOrderCommentTest.php +++ b/app/code/Magento/Sales/Test/Unit/Observer/Frontend/AddVatRequestParamsOrderCommentTest.php @@ -84,6 +84,9 @@ public function testAddVatRequestParamsOrderComment( $this->assertNull($this->observer->execute($observer)); } + /** + * @return array + */ public function addVatRequestParamsOrderCommentDataProvider() { return [ diff --git a/app/code/Magento/Sales/Test/Unit/Observer/Frontend/RestoreCustomerGroupIdTest.php b/app/code/Magento/Sales/Test/Unit/Observer/Frontend/RestoreCustomerGroupIdTest.php index f0738fbcf3129..f0845c67f1a4a 100644 --- a/app/code/Magento/Sales/Test/Unit/Observer/Frontend/RestoreCustomerGroupIdTest.php +++ b/app/code/Magento/Sales/Test/Unit/Observer/Frontend/RestoreCustomerGroupIdTest.php @@ -72,6 +72,9 @@ public function testExecute($configAddressType) $this->quote->execute($observer); } + /** + * @return array + */ public function restoreCustomerGroupIdDataProvider() { return [ diff --git a/app/code/Magento/SalesInventory/Test/Unit/Model/Order/ReturnValidatorTest.php b/app/code/Magento/SalesInventory/Test/Unit/Model/Order/ReturnValidatorTest.php index 3d811363156d7..32eb810c7a16a 100644 --- a/app/code/Magento/SalesInventory/Test/Unit/Model/Order/ReturnValidatorTest.php +++ b/app/code/Magento/SalesInventory/Test/Unit/Model/Order/ReturnValidatorTest.php @@ -121,6 +121,9 @@ public function testValidationWithWrongOrderItems() ); } + /** + * @return array + */ public function dataProvider() { return [ diff --git a/app/code/Magento/SalesInventory/Test/Unit/Model/Plugin/Order/Validation/InvoiceRefundCreationArgumentsTest.php b/app/code/Magento/SalesInventory/Test/Unit/Model/Plugin/Order/Validation/InvoiceRefundCreationArgumentsTest.php index 2ee8f81a2aa88..0fea8f4210f8a 100644 --- a/app/code/Magento/SalesInventory/Test/Unit/Model/Plugin/Order/Validation/InvoiceRefundCreationArgumentsTest.php +++ b/app/code/Magento/SalesInventory/Test/Unit/Model/Plugin/Order/Validation/InvoiceRefundCreationArgumentsTest.php @@ -140,6 +140,9 @@ public function testAfterValidation($erroMessage) ); } + /** + * @return array + */ public function dataProvider() { return [ diff --git a/app/code/Magento/SalesInventory/Test/Unit/Observer/RefundOrderInventoryObserverTest.php b/app/code/Magento/SalesInventory/Test/Unit/Observer/RefundOrderInventoryObserverTest.php index c2e2d4710f96c..759320106ea1b 100644 --- a/app/code/Magento/SalesInventory/Test/Unit/Observer/RefundOrderInventoryObserverTest.php +++ b/app/code/Magento/SalesInventory/Test/Unit/Observer/RefundOrderInventoryObserverTest.php @@ -173,6 +173,11 @@ public function testRefundOrderInventory() $this->observer->execute($this->eventObserver); } + /** + * @param $productId + * + * @return \PHPUnit_Framework_MockObject_MockObject + */ private function getCreditMemoItem($productId) { $backToStock = true; diff --git a/app/code/Magento/SalesRule/Plugin/CouponUsagesDecrement.php b/app/code/Magento/SalesRule/Plugin/CouponUsagesDecrement.php index 88108154b5e71..f62e2e0be4d0c 100644 --- a/app/code/Magento/SalesRule/Plugin/CouponUsagesDecrement.php +++ b/app/code/Magento/SalesRule/Plugin/CouponUsagesDecrement.php @@ -16,6 +16,11 @@ class CouponUsagesDecrement */ private $updateCouponUsages; + /** + * CouponUsagesDecrement constructor. + * + * @param UpdateCouponUsages $updateCouponUsages + */ public function __construct( UpdateCouponUsages $updateCouponUsages ) { diff --git a/app/code/Magento/SalesRule/Plugin/CouponUsagesIncrement.php b/app/code/Magento/SalesRule/Plugin/CouponUsagesIncrement.php index 54ebef2bdf248..8810b4630f51a 100644 --- a/app/code/Magento/SalesRule/Plugin/CouponUsagesIncrement.php +++ b/app/code/Magento/SalesRule/Plugin/CouponUsagesIncrement.php @@ -16,6 +16,11 @@ class CouponUsagesIncrement */ private $updateCouponUsages; + /** + * CouponUsagesIncrement constructor. + * + * @param UpdateCouponUsages $updateCouponUsages + */ public function __construct( UpdateCouponUsages $updateCouponUsages ) { diff --git a/app/code/Magento/SalesRule/Test/Unit/Block/Rss/DiscountsTest.php b/app/code/Magento/SalesRule/Test/Unit/Block/Rss/DiscountsTest.php index cd00562bc4f7a..bd14773ea4923 100644 --- a/app/code/Magento/SalesRule/Test/Unit/Block/Rss/DiscountsTest.php +++ b/app/code/Magento/SalesRule/Test/Unit/Block/Rss/DiscountsTest.php @@ -195,6 +195,9 @@ public function testIsAllowed($isAllowed) $this->assertEquals($isAllowed, $this->block->isAllowed()); } + /** + * @return array + */ public function isAllowedDataProvider() { return [ diff --git a/app/code/Magento/SalesRule/Test/Unit/Model/Converter/ToDataModelTest.php b/app/code/Magento/SalesRule/Test/Unit/Model/Converter/ToDataModelTest.php index 82868b3723c75..1016d14066afc 100644 --- a/app/code/Magento/SalesRule/Test/Unit/Model/Converter/ToDataModelTest.php +++ b/app/code/Magento/SalesRule/Test/Unit/Model/Converter/ToDataModelTest.php @@ -115,6 +115,9 @@ protected function setUp() ); } + /** + * @return array + */ private function getArrayData() { return [ diff --git a/app/code/Magento/SalesRule/Test/Unit/Model/Converter/ToModelTest.php b/app/code/Magento/SalesRule/Test/Unit/Model/Converter/ToModelTest.php index 98e1d7cddee57..5dd67424418b7 100644 --- a/app/code/Magento/SalesRule/Test/Unit/Model/Converter/ToModelTest.php +++ b/app/code/Magento/SalesRule/Test/Unit/Model/Converter/ToModelTest.php @@ -273,6 +273,9 @@ public function testFormattingDate($data) $this->model->toModel($dataModel); } + /** + * @return array + */ public function expectedDatesProvider() { return [ diff --git a/app/code/Magento/SalesRule/Test/Unit/Model/CouponRepositoryTest.php b/app/code/Magento/SalesRule/Test/Unit/Model/CouponRepositoryTest.php index 31536e1be3d2e..e516f817a59d1 100644 --- a/app/code/Magento/SalesRule/Test/Unit/Model/CouponRepositoryTest.php +++ b/app/code/Magento/SalesRule/Test/Unit/Model/CouponRepositoryTest.php @@ -155,6 +155,9 @@ public function testSaveWithExceptions($exceptionObject, $exceptionName, $except $this->model->save($coupon); } + /** + * @return array + */ public function saveExceptionsDataProvider() { $msg = 'kiwis'; diff --git a/app/code/Magento/SalesRule/Test/Unit/Model/Quote/DiscountTest.php b/app/code/Magento/SalesRule/Test/Unit/Model/Quote/DiscountTest.php index 671f20a27a460..090dbd7fe5d6d 100644 --- a/app/code/Magento/SalesRule/Test/Unit/Model/Quote/DiscountTest.php +++ b/app/code/Magento/SalesRule/Test/Unit/Model/Quote/DiscountTest.php @@ -225,6 +225,9 @@ public function testCollectItemHasChildren($childItemData, $parentData, $expecte } } + /** + * @return array + */ public function collectItemHasChildrenDataProvider() { $data = [ diff --git a/app/code/Magento/SalesRule/Test/Unit/Model/RuleTest.php b/app/code/Magento/SalesRule/Test/Unit/Model/RuleTest.php index 89f4e93901c1b..be9e25eb20302 100644 --- a/app/code/Magento/SalesRule/Test/Unit/Model/RuleTest.php +++ b/app/code/Magento/SalesRule/Test/Unit/Model/RuleTest.php @@ -113,6 +113,9 @@ public function testBeforeSaveResetConditionToNull() $this->model->getActions(); } + /** + * @return \PHPUnit_Framework_MockObject_MockObject + */ protected function setupProdConditionMock() { $prodConditionMock = $this->getMockBuilder(\Magento\SalesRule\Model\Rule\Condition\Product\Combine::class) @@ -133,6 +136,9 @@ protected function setupProdConditionMock() return $prodConditionMock; } + /** + * @return \PHPUnit_Framework_MockObject_MockObject + */ protected function setupConditionMock() { $conditionMock = $this->getMockBuilder(\Magento\SalesRule\Model\Rule\Condition\Combine::class) diff --git a/app/code/Magento/SalesRule/Test/Unit/Model/RulesApplierTest.php b/app/code/Magento/SalesRule/Test/Unit/Model/RulesApplierTest.php index 21df8e587667e..ec4e775f1f6b3 100644 --- a/app/code/Magento/SalesRule/Test/Unit/Model/RulesApplierTest.php +++ b/app/code/Magento/SalesRule/Test/Unit/Model/RulesApplierTest.php @@ -140,6 +140,9 @@ public function testApplyRulesWhenRuleWithStopRulesProcessingIsUsed($isChildren, $this->assertEquals($appliedRuleIds, $result); } + /** + * @return array + */ public function dataProviderChildren() { return [ @@ -179,6 +182,10 @@ protected function getPreparedItem() return $item; } + /** + * @param $item + * @param $rule + */ protected function applyRule($item, $rule) { $qty = 2; diff --git a/app/code/Magento/SalesRule/Test/Unit/Model/UtilityTest.php b/app/code/Magento/SalesRule/Test/Unit/Model/UtilityTest.php index 5e48f3110a395..4ce0f2a0564f3 100644 --- a/app/code/Magento/SalesRule/Test/Unit/Model/UtilityTest.php +++ b/app/code/Magento/SalesRule/Test/Unit/Model/UtilityTest.php @@ -362,6 +362,9 @@ public function testMergeIds($a1, $a2, $isSting, $expected) $this->assertEquals($expected, $this->utility->mergeIds($a1, $a2, $isSting)); } + /** + * @return array + */ public function mergeIdsDataProvider() { return [ diff --git a/app/code/Magento/SalesRule/Test/Unit/Model/ValidatorTest.php b/app/code/Magento/SalesRule/Test/Unit/Model/ValidatorTest.php index 2e6a3c3c38af0..42448565791c5 100644 --- a/app/code/Magento/SalesRule/Test/Unit/Model/ValidatorTest.php +++ b/app/code/Magento/SalesRule/Test/Unit/Model/ValidatorTest.php @@ -495,6 +495,9 @@ public function testProcessShippingAmountActions($action) ); } + /** + * @return array + */ public static function dataProviderActions() { return [ diff --git a/app/code/Magento/Search/Test/Unit/Helper/DataTest.php b/app/code/Magento/Search/Test/Unit/Helper/DataTest.php index 291362734feff..1f9aad8d4316d 100644 --- a/app/code/Magento/Search/Test/Unit/Helper/DataTest.php +++ b/app/code/Magento/Search/Test/Unit/Helper/DataTest.php @@ -127,6 +127,9 @@ public function testGetEscapedQueryText($queryText, $maxQueryLength, $expected) $this->assertEquals($expected, $this->model->getEscapedQueryText()); } + /** + * @return array + */ public function queryTextDataProvider() { return [ diff --git a/app/code/Magento/Security/Test/Unit/Model/ResourceModel/PasswordResetRequestEvent/CollectionFactoryTest.php b/app/code/Magento/Security/Test/Unit/Model/ResourceModel/PasswordResetRequestEvent/CollectionFactoryTest.php index 525693631e86f..89bc5c2b85d50 100644 --- a/app/code/Magento/Security/Test/Unit/Model/ResourceModel/PasswordResetRequestEvent/CollectionFactoryTest.php +++ b/app/code/Magento/Security/Test/Unit/Model/ResourceModel/PasswordResetRequestEvent/CollectionFactoryTest.php @@ -86,6 +86,9 @@ public function testCreate( $this->model->create($securityEventType, $accountReference, $longIp); } + /** + * @return array + */ public function createDataProvider() { return [ diff --git a/app/code/Magento/SendFriend/Test/Unit/Block/Plugin/Catalog/Product/ViewTest.php b/app/code/Magento/SendFriend/Test/Unit/Block/Plugin/Catalog/Product/ViewTest.php index 6dbab3a5573a8..2718e1fa44f6e 100644 --- a/app/code/Magento/SendFriend/Test/Unit/Block/Plugin/Catalog/Product/ViewTest.php +++ b/app/code/Magento/SendFriend/Test/Unit/Block/Plugin/Catalog/Product/ViewTest.php @@ -52,6 +52,9 @@ public function testAfterCanEmailToFriend($result, $callSendfriend) $this->assertTrue($this->view->afterCanEmailToFriend($this->productView, $result)); } + /** + * @return array + */ public function afterCanEmailToFriendDataSet() { return [ diff --git a/app/code/Magento/Shipping/Test/Unit/Controller/Adminhtml/Order/Shipment/ViewTest.php b/app/code/Magento/Shipping/Test/Unit/Controller/Adminhtml/Order/Shipment/ViewTest.php index 65460d1a13eea..2db8eabffae61 100644 --- a/app/code/Magento/Shipping/Test/Unit/Controller/Adminhtml/Order/Shipment/ViewTest.php +++ b/app/code/Magento/Shipping/Test/Unit/Controller/Adminhtml/Order/Shipment/ViewTest.php @@ -204,6 +204,14 @@ public function testExecuteNoShipment() $this->assertEquals($this->resultForwardMock, $this->controller->execute()); } + /** + * @param $orderId + * @param $shipmentId + * @param $shipment + * @param $tracking + * @param $comeFrom + * @param $returnShipment + */ protected function loadShipment($orderId, $shipmentId, $shipment, $tracking, $comeFrom, $returnShipment) { $valueMap = [ diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreateGuaranteeAbilityTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreateGuaranteeAbilityTest.php index 7ba3ab3eef4f6..6b7a6112a932e 100644 --- a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreateGuaranteeAbilityTest.php +++ b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreateGuaranteeAbilityTest.php @@ -198,6 +198,9 @@ public function testIsAvailableWithCanceledOrder($state) $this->assertFalse($this->createGuaranteeAbility->isAvailable($orderId)); } + /** + * @return array + */ public function isAvailableWithCanceledOrderDataProvider() { return [ diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreationServiceTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreationServiceTest.php index a22bfe12222a6..f80a9a83e7117 100644 --- a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreationServiceTest.php +++ b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreationServiceTest.php @@ -203,6 +203,12 @@ public function testCreateForOrderWithCaseUpdate() ); } + /** + * @param $orderId + * @param array $caseData + * + * @return MockObject + */ private function withCaseEntityExistsForOrderId($orderId, array $caseData = []) { $this->createGuaranteeAbility->expects(self::once()) @@ -226,6 +232,9 @@ private function withCaseEntityExistsForOrderId($orderId, array $caseData = []) return $dummyCaseEntity; } + /** + * @param $failureMessage + */ private function withGatewayFailure($failureMessage) { $this->gateway @@ -233,6 +242,9 @@ private function withGatewayFailure($failureMessage) ->willThrowException(new GatewayException($failureMessage)); } + /** + * @param $gatewayResult + */ private function withGatewaySuccess($gatewayResult) { $this->gateway diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Client/ResponseHandlerTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Client/ResponseHandlerTest.php index bf0c6ee238d5f..1ee55d7ad150c 100644 --- a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Client/ResponseHandlerTest.php +++ b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Client/ResponseHandlerTest.php @@ -92,6 +92,9 @@ public function testHandleFailureMessage($code, $message) } } + /** + * @return array + */ public function errorsProvider() { return [ diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php index 0039b271a4b0b..ce97a7baaeace 100644 --- a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php +++ b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php @@ -393,6 +393,9 @@ public function testCancelGuaranteeWithUnexpectedDisposition() $this->assertEquals(Gateway::GUARANTEE_CANCELED, $result); } + /** + * @return array + */ public function supportedGuaranteeDispositionsProvider() { return [ diff --git a/app/code/Magento/Store/Test/Unit/Model/Config/Importer/Processor/UpdateTest.php b/app/code/Magento/Store/Test/Unit/Model/Config/Importer/Processor/UpdateTest.php index 3b0b932e31d46..2e5a3b6a65db9 100644 --- a/app/code/Magento/Store/Test/Unit/Model/Config/Importer/Processor/UpdateTest.php +++ b/app/code/Magento/Store/Test/Unit/Model/Config/Importer/Processor/UpdateTest.php @@ -253,6 +253,9 @@ public function testRun() $this->model->run($data); } + /** + * @return array + */ private function getData() { return [ diff --git a/app/code/Magento/Store/Test/Unit/Model/Service/StoreConfigManagerTest.php b/app/code/Magento/Store/Test/Unit/Model/Service/StoreConfigManagerTest.php index 702f4eee8db99..72ee0c196b090 100644 --- a/app/code/Magento/Store/Test/Unit/Model/Service/StoreConfigManagerTest.php +++ b/app/code/Magento/Store/Test/Unit/Model/Service/StoreConfigManagerTest.php @@ -55,6 +55,11 @@ protected function setUp() ); } + /** + * @param array $storeConfig + * + * @return \PHPUnit_Framework_MockObject_MockObject + */ protected function getStoreMock(array $storeConfig) { $storeMock = $this->getMockBuilder(\Magento\Store\Model\Store::class) @@ -88,6 +93,9 @@ protected function getStoreMock(array $storeConfig) return $storeMock; } + /** + * @return \Magento\Store\Model\Data\StoreConfig + */ protected function createStoreConfigDataObject() { /** @var \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactoryMock */ diff --git a/app/code/Magento/Store/Test/Unit/Model/StoreManagerTest.php b/app/code/Magento/Store/Test/Unit/Model/StoreManagerTest.php index ad3b927258717..a48804f02adc0 100644 --- a/app/code/Magento/Store/Test/Unit/Model/StoreManagerTest.php +++ b/app/code/Magento/Store/Test/Unit/Model/StoreManagerTest.php @@ -97,6 +97,9 @@ public function testGetStores($storesList, $withDefault, $codeKey, $expectedStor $this->assertEquals($expectedStores, $this->model->getStores($withDefault, $codeKey)); } + /** + * @return array + */ public function getStoresDataProvider() { $defaultStoreMock = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class) diff --git a/app/code/Magento/Store/Test/Unit/Model/StoreTest.php b/app/code/Magento/Store/Test/Unit/Model/StoreTest.php index c05584c2d8bcb..d371f16458c74 100644 --- a/app/code/Magento/Store/Test/Unit/Model/StoreTest.php +++ b/app/code/Magento/Store/Test/Unit/Model/StoreTest.php @@ -93,6 +93,9 @@ public function testLoad($key, $field) $model->load($key); } + /** + * @return array + */ public function loadDataProvider() { return [ @@ -264,6 +267,9 @@ function ($path, $scope, $scopeCode) use ($secure, $expectedPath) { $this->assertEquals($expectedBaseUrl, $model->getBaseUrl($type, $secure)); } + /** + * @return array + */ public function getBaseUrlDataProvider() { return [ @@ -602,6 +608,9 @@ public function testIsCurrentlySecure( } } + /** + * @return array + */ public function isCurrentlySecureDataProvider() { return [ diff --git a/app/code/Magento/Store/Test/Unit/Model/System/StoreTest.php b/app/code/Magento/Store/Test/Unit/Model/System/StoreTest.php index d70da2ee1ddc6..9cc4bb6ac8e5b 100644 --- a/app/code/Magento/Store/Test/Unit/Model/System/StoreTest.php +++ b/app/code/Magento/Store/Test/Unit/Model/System/StoreTest.php @@ -104,6 +104,9 @@ public function testGetStoresStructure( ); } + /** + * @return array + */ public function getStoresStructureDataProvider() { $websiteName = 'website'; @@ -207,6 +210,9 @@ public function testGetStoreValuesForForm( ); } + /** + * @return array + */ public function getStoreValuesForFormDataProvider() { $websiteName = 'website'; diff --git a/app/code/Magento/Store/Test/Unit/Setup/UpgradeDataTest.php b/app/code/Magento/Store/Test/Unit/Setup/UpgradeDataTest.php index 0dc7de4224c43..210e187b78b47 100644 --- a/app/code/Magento/Store/Test/Unit/Setup/UpgradeDataTest.php +++ b/app/code/Magento/Store/Test/Unit/Setup/UpgradeDataTest.php @@ -102,6 +102,9 @@ public function testUpgradeToVersion210(array $groupList, array $expectedCodes) $this->model->upgrade($this->setupMock, $this->contextMock); } + /** + * @return array + */ public function upgradeDataProvider() { return [ diff --git a/app/code/Magento/Swatches/Test/Unit/Block/Adminhtml/Attribute/Edit/Options/AbstractSwatchTest.php b/app/code/Magento/Swatches/Test/Unit/Block/Adminhtml/Attribute/Edit/Options/AbstractSwatchTest.php index a86c745c7c810..0d0444ddda38b 100644 --- a/app/code/Magento/Swatches/Test/Unit/Block/Adminhtml/Attribute/Edit/Options/AbstractSwatchTest.php +++ b/app/code/Magento/Swatches/Test/Unit/Block/Adminhtml/Attribute/Edit/Options/AbstractSwatchTest.php @@ -160,6 +160,9 @@ public function testGetStoreOptionValues($values) $this->assertEquals($result, $values); } + /** + * @return array + */ public function dataForGetStoreOptionValues() { return [ diff --git a/app/code/Magento/Swatches/Test/Unit/Block/Adminhtml/Product/Attribute/Edit/FormTest.php b/app/code/Magento/Swatches/Test/Unit/Block/Adminhtml/Product/Attribute/Edit/FormTest.php index aad8741735813..168a682961bc6 100644 --- a/app/code/Magento/Swatches/Test/Unit/Block/Adminhtml/Product/Attribute/Edit/FormTest.php +++ b/app/code/Magento/Swatches/Test/Unit/Block/Adminhtml/Product/Attribute/Edit/FormTest.php @@ -21,6 +21,9 @@ public function testAddValues($values) $this->assertEquals($block, $result); } + /** + * @return array + */ public function dataForAddValues() { $additionalData = [ diff --git a/app/code/Magento/Swatches/Test/Unit/Controller/Adminhtml/Iframe/ShowTest.php b/app/code/Magento/Swatches/Test/Unit/Controller/Adminhtml/Iframe/ShowTest.php index 19a05dad151c4..a28f3db8fb392 100644 --- a/app/code/Magento/Swatches/Test/Unit/Controller/Adminhtml/Iframe/ShowTest.php +++ b/app/code/Magento/Swatches/Test/Unit/Controller/Adminhtml/Iframe/ShowTest.php @@ -130,6 +130,9 @@ public function testExecute($fileResult, $expectedResult) $this->controller->execute(); } + /** + * @return array + */ public function dataForExecute() { return [ diff --git a/app/code/Magento/Swatches/Test/Unit/Controller/Adminhtml/Product/Attribute/Plugin/SaveTest.php b/app/code/Magento/Swatches/Test/Unit/Controller/Adminhtml/Product/Attribute/Plugin/SaveTest.php index 66f0d484c9e83..c9c826b3a7831 100644 --- a/app/code/Magento/Swatches/Test/Unit/Controller/Adminhtml/Product/Attribute/Plugin/SaveTest.php +++ b/app/code/Magento/Swatches/Test/Unit/Controller/Adminhtml/Product/Attribute/Plugin/SaveTest.php @@ -39,6 +39,9 @@ public function testBeforeDispatch($dataRequest, $runTimes) $controller->beforeDispatch($subject, $request); } + /** + * @return array + */ public function dataRequest() { return [ diff --git a/app/code/Magento/Swatches/Test/Unit/Helper/DataTest.php b/app/code/Magento/Swatches/Test/Unit/Helper/DataTest.php index 751375813a83a..5732018f7615f 100644 --- a/app/code/Magento/Swatches/Test/Unit/Helper/DataTest.php +++ b/app/code/Magento/Swatches/Test/Unit/Helper/DataTest.php @@ -141,6 +141,9 @@ protected function setUp() ); } + /** + * @return array + */ public function dataForAdditionalData() { $additionalData = [ @@ -192,6 +195,9 @@ public function testAssembleAdditionalDataEavAttribute($dataFromDb, $attributeDa $this->swatchHelperObject->assembleAdditionalDataEavAttribute($this->attributeMock); } + /** + * @return array + */ public function dataForAssembleEavAttribute() { $additionalData = [ @@ -236,6 +242,9 @@ public function testLoadFirstVariationWithSwatchImage($imageTypes, $expected, $r } } + /** + * @return array + */ public function dataForVariationWithSwatchImage() { return [ @@ -299,6 +308,9 @@ public function testLoadFirstVariationWithImage($imageTypes, $expected, $require } } + /** + * @return array + */ public function dataForVariationWithImage() { return [ @@ -405,6 +417,9 @@ public function testGetProductMediaGallery($mediaGallery, $image) } } + /** + * @return array + */ public function dataForMediaGallery() { return [ @@ -442,6 +457,10 @@ protected function getSwatchAttributes() ->willReturn($returnFromProvideMethod); } + /** + * @param array $attributes + * @param array $imageTypes + */ protected function getUsedProducts(array $attributes, array $imageTypes) { $this->productMock @@ -535,6 +554,9 @@ protected function addfilterByParent() $zendDbSelectMock->method('where')->willReturn($zendDbSelectMock); } + /** + * @return array + */ public function dataForCreateSwatchProduct() { $productMock = $this->createMock(\Magento\Catalog\Model\Product::class); @@ -571,6 +593,9 @@ public function dataForCreateSwatchProduct() ]; } + /** + * @return array + */ public function dataForCreateSwatchProductByFallback() { $productMock = $this->createMock(\Magento\Catalog\Model\Product::class); @@ -612,6 +637,9 @@ public function testGetSwatchAttributesAsArray($optionsArray, $attributeData, $e $this->assertEquals($result, $expected); } + /** + * @return array + */ public function dataForGettingSwatchAsArray() { return [ diff --git a/app/code/Magento/Swatches/Test/Unit/Helper/MediaTest.php b/app/code/Magento/Swatches/Test/Unit/Helper/MediaTest.php index ca267278291e3..aed9c1da41289 100644 --- a/app/code/Magento/Swatches/Test/Unit/Helper/MediaTest.php +++ b/app/code/Magento/Swatches/Test/Unit/Helper/MediaTest.php @@ -114,6 +114,9 @@ public function testGetSwatchAttributeImage($swatchType, $expectedResult) $this->assertEquals($result, $expectedResult); } + /** + * @return array + */ public function dataForFullPath() { return [ @@ -202,6 +205,9 @@ public function testGetFolderNameSize($swatchType, $imageConfig, $expectedResult $this->assertEquals($expectedResult, $result); } + /** + * @return array + */ public function dataForFolderName() { return [ @@ -293,6 +299,9 @@ public function testGetSwatchCachePath($swatchType, $expectedResult) $this->assertEquals($expectedResult, $this->mediaHelperObject->getSwatchCachePath($swatchType)); } + /** + * @return array + */ public function getSwatchTypes() { return [ diff --git a/app/code/Magento/Swatches/Test/Unit/Model/Plugin/EavAttributeTest.php b/app/code/Magento/Swatches/Test/Unit/Model/Plugin/EavAttributeTest.php index 31a45ddb2847c..317ea77107222 100644 --- a/app/code/Magento/Swatches/Test/Unit/Model/Plugin/EavAttributeTest.php +++ b/app/code/Magento/Swatches/Test/Unit/Model/Plugin/EavAttributeTest.php @@ -310,6 +310,9 @@ public function testBeforeSaveNotSwatch() $this->eavAttribute->beforeBeforeSave($this->attribute); } + /** + * @return array + */ public function visualSwatchProvider() { return [ diff --git a/app/code/Magento/Swatches/Test/Unit/Model/Plugin/ProductImageTest.php b/app/code/Magento/Swatches/Test/Unit/Model/Plugin/ProductImageTest.php index abec4569c81dc..3f98519ac1806 100644 --- a/app/code/Magento/Swatches/Test/Unit/Model/Plugin/ProductImageTest.php +++ b/app/code/Magento/Swatches/Test/Unit/Model/Plugin/ProductImageTest.php @@ -98,6 +98,9 @@ public function testBeforeGetImage($expected) $this->assertEquals([$this->productMock, $expected['page_handle'], []], $result); } + /** + * @param $expected + */ protected function canReplaceImageWithSwatch($expected) { $this->swatchesHelperMock diff --git a/app/code/Magento/Swatches/Test/Unit/Model/Plugin/ProductTest.php b/app/code/Magento/Swatches/Test/Unit/Model/Plugin/ProductTest.php index 791ba83b374c6..d7422786aec67 100644 --- a/app/code/Magento/Swatches/Test/Unit/Model/Plugin/ProductTest.php +++ b/app/code/Magento/Swatches/Test/Unit/Model/Plugin/ProductTest.php @@ -39,6 +39,9 @@ public function testAfterGetMediaAttributes($productType, $hasKey) } } + /** + * @return array + */ public function dataRoles() { return [ diff --git a/app/code/Magento/Swatches/Test/Unit/Observer/AddFieldsToAttributeObserverTest.php b/app/code/Magento/Swatches/Test/Unit/Observer/AddFieldsToAttributeObserverTest.php index 8292e0c2ed1bb..45c680366264b 100644 --- a/app/code/Magento/Swatches/Test/Unit/Observer/AddFieldsToAttributeObserverTest.php +++ b/app/code/Magento/Swatches/Test/Unit/Observer/AddFieldsToAttributeObserverTest.php @@ -73,6 +73,9 @@ public function testAddFields($expected) $this->observerMock->execute($this->eventObserverMock); } + /** + * @return array + */ public function dataAddFields() { return [ diff --git a/app/code/Magento/Swatches/Test/Unit/Observer/AddSwatchAttributeTypeObserverTest.php b/app/code/Magento/Swatches/Test/Unit/Observer/AddSwatchAttributeTypeObserverTest.php index c24dd820e0144..f78797d93cb0d 100644 --- a/app/code/Magento/Swatches/Test/Unit/Observer/AddSwatchAttributeTypeObserverTest.php +++ b/app/code/Magento/Swatches/Test/Unit/Observer/AddSwatchAttributeTypeObserverTest.php @@ -66,6 +66,9 @@ public function testAddSwatchAttributeType($exp) $this->observerMock->execute($this->eventObserverMock); } + /** + * @return array + */ public function dataAddSwatch() { return [ diff --git a/app/code/Magento/Tax/Test/Unit/Block/Checkout/ShippingTest.php b/app/code/Magento/Tax/Test/Unit/Block/Checkout/ShippingTest.php index c1aa2b0c9900d..e7a11ec45ad3f 100644 --- a/app/code/Magento/Tax/Test/Unit/Block/Checkout/ShippingTest.php +++ b/app/code/Magento/Tax/Test/Unit/Block/Checkout/ShippingTest.php @@ -44,6 +44,9 @@ public function testDisplayShipping($shippingMethod, $expectedResult) $this->assertEquals($expectedResult, $this->model->displayShipping()); } + /** + * @return array + */ public function displayShippingDataProvider() { return [ diff --git a/app/code/Magento/Tax/Test/Unit/Block/Item/Price/RendererTest.php b/app/code/Magento/Tax/Test/Unit/Block/Item/Price/RendererTest.php index 1a16e69724479..90f0f09215889 100644 --- a/app/code/Magento/Tax/Test/Unit/Block/Item/Price/RendererTest.php +++ b/app/code/Magento/Tax/Test/Unit/Block/Item/Price/RendererTest.php @@ -96,6 +96,9 @@ public function testDisplayPriceInclTax($zone, $methodName) $this->assertEquals($flag, $this->renderer->displayPriceInclTax()); } + /** + * @return array + */ public function displayPriceInclTaxDataProvider() { $data = [ @@ -143,6 +146,9 @@ public function testDisplayPriceExclTax($zone, $methodName) $this->assertEquals($flag, $this->renderer->displayPriceExclTax()); } + /** + * @return array + */ public function displayPriceExclTaxDataProvider() { $data = [ @@ -190,6 +196,9 @@ public function testDisplayBothPrices($zone, $methodName) $this->assertEquals($flag, $this->renderer->displayBothPrices()); } + /** + * @return array + */ public function displayBothPricesDataProvider() { $data = [ diff --git a/app/code/Magento/Tax/Test/Unit/Model/Calculation/RateRepositoryTest.php b/app/code/Magento/Tax/Test/Unit/Model/Calculation/RateRepositoryTest.php index e6a29177301dd..47ec0d8732d81 100644 --- a/app/code/Magento/Tax/Test/Unit/Model/Calculation/RateRepositoryTest.php +++ b/app/code/Magento/Tax/Test/Unit/Model/Calculation/RateRepositoryTest.php @@ -312,6 +312,9 @@ public function testSaveThrowsExceptionIfCannotSaveTitles($expectedException, $e $this->model->save($rateMock); } + /** + * @return array + */ public function saveThrowsExceptionIfCannotSaveTitlesDataProvider() { return [ diff --git a/app/code/Magento/Tax/Test/Unit/Model/Plugin/OrderSaveTest.php b/app/code/Magento/Tax/Test/Unit/Model/Plugin/OrderSaveTest.php index 912f42af0d3cd..82a473b42a82e 100644 --- a/app/code/Magento/Tax/Test/Unit/Model/Plugin/OrderSaveTest.php +++ b/app/code/Magento/Tax/Test/Unit/Model/Plugin/OrderSaveTest.php @@ -63,6 +63,9 @@ protected function setUp() ); } + /** + * @return \PHPUnit_Framework_MockObject_MockObject + */ protected function setupOrderMock() { $orderMock = $this->getMockBuilder(\Magento\Sales\Model\Order::class) @@ -80,6 +83,9 @@ protected function setupOrderMock() return $orderMock; } + /** + * @return \PHPUnit_Framework_MockObject_MockObject + */ protected function setupExtensionAttributeMock() { $orderExtensionAttributeMock = $this->getMockBuilder(\Magento\Sales\Api\Data\OrderExtensionInterface::class) @@ -95,6 +101,9 @@ protected function setupExtensionAttributeMock() return $orderExtensionAttributeMock; } + /** + * @param $expectedTaxes + */ protected function verifyOrderTaxes($expectedTaxes) { $index = 0; @@ -125,6 +134,9 @@ protected function verifyOrderTaxes($expectedTaxes) } } + /** + * @param $expectedItemTaxes + */ public function verifyItemTaxes($expectedItemTaxes) { $index = 0; diff --git a/app/code/Magento/Tax/Test/Unit/Model/Quote/GrandTotalDetailsPluginTest.php b/app/code/Magento/Tax/Test/Unit/Model/Quote/GrandTotalDetailsPluginTest.php index e5bd728e180f6..5e806bf36fc53 100644 --- a/app/code/Magento/Tax/Test/Unit/Model/Quote/GrandTotalDetailsPluginTest.php +++ b/app/code/Magento/Tax/Test/Unit/Model/Quote/GrandTotalDetailsPluginTest.php @@ -108,6 +108,11 @@ function ($value) { ); } + /** + * @param array $data + * + * @return \PHPUnit_Framework_MockObject_MockObject + */ protected function setupTaxTotal(array $data) { $taxTotalMock = $this->getMockBuilder(\Magento\Quote\Model\Quote\Address\Total::class) @@ -121,6 +126,11 @@ protected function setupTaxTotal(array $data) return $taxTotalMock; } + /** + * @param array $taxRate + * + * @return \PHPUnit_Framework_MockObject_MockObject + */ protected function setupTaxRateFactoryMock(array $taxRate) { $taxRateMock = $this->getMockBuilder(\Magento\Tax\Api\Data\GrandTotalRatesInterface::class) @@ -142,6 +152,11 @@ protected function setupTaxRateFactoryMock(array $taxRate) return $taxRateMock; } + /** + * @param array $taxDetails + * + * @return \PHPUnit_Framework_MockObject_MockObject + */ protected function setupTaxDetails(array $taxDetails) { $taxDetailsMock = $this->getMockBuilder(\Magento\Tax\Api\Data\GrandTotalDetailsInterface::class) diff --git a/app/code/Magento/Tax/Test/Unit/Model/Quote/ToOrderConverterTest.php b/app/code/Magento/Tax/Test/Unit/Model/Quote/ToOrderConverterTest.php index 23ce032764a8f..09f82b32137b3 100644 --- a/app/code/Magento/Tax/Test/Unit/Model/Quote/ToOrderConverterTest.php +++ b/app/code/Magento/Tax/Test/Unit/Model/Quote/ToOrderConverterTest.php @@ -64,6 +64,9 @@ protected function setUp() ); } + /** + * @return \PHPUnit_Framework_MockObject_MockObject + */ protected function setupOrderExtensionAttributeMock() { $orderExtensionAttributeMock = $this->getMockBuilder(\Magento\Sales\Api\Data\OrderExtensionInterface::class) diff --git a/app/code/Magento/Tax/Test/Unit/Model/Sales/Total/Quote/CommonTaxCollectorTest.php b/app/code/Magento/Tax/Test/Unit/Model/Sales/Total/Quote/CommonTaxCollectorTest.php index 6440751961796..9b963434e321d 100644 --- a/app/code/Magento/Tax/Test/Unit/Model/Sales/Total/Quote/CommonTaxCollectorTest.php +++ b/app/code/Magento/Tax/Test/Unit/Model/Sales/Total/Quote/CommonTaxCollectorTest.php @@ -183,6 +183,9 @@ public function testGetShippingDataObject( } } + /** + * @return array + */ public function getShippingDataObjectDataProvider() { $data = [ diff --git a/app/code/Magento/Tax/Test/Unit/Model/Sales/Total/Quote/TaxTest.php b/app/code/Magento/Tax/Test/Unit/Model/Sales/Total/Quote/TaxTest.php index feee41c342069..3523d2828948c 100644 --- a/app/code/Magento/Tax/Test/Unit/Model/Sales/Total/Quote/TaxTest.php +++ b/app/code/Magento/Tax/Test/Unit/Model/Sales/Total/Quote/TaxTest.php @@ -552,6 +552,9 @@ public function testMapQuoteExtraTaxables($itemData, $addressData) /* * @return array */ + /** + * @return array + */ public function dataProviderMapQuoteExtraTaxablesArray() { $data = [ diff --git a/app/code/Magento/Tax/Test/Unit/Model/System/Message/Notification/ApplyDiscountOnPricesTest.php b/app/code/Magento/Tax/Test/Unit/Model/System/Message/Notification/ApplyDiscountOnPricesTest.php index f8cd3fce693a6..6902a59a2dab4 100644 --- a/app/code/Magento/Tax/Test/Unit/Model/System/Message/Notification/ApplyDiscountOnPricesTest.php +++ b/app/code/Magento/Tax/Test/Unit/Model/System/Message/Notification/ApplyDiscountOnPricesTest.php @@ -95,6 +95,9 @@ public function testIsDisplayed( $this->assertEquals($expectedResult, $this->applyDiscountOnPricesNotification->isDisplayed()); } + /** + * @return array + */ public function dataProviderIsDisplayed() { return [ diff --git a/app/code/Magento/Tax/Test/Unit/Model/System/Message/NotificationsTest.php b/app/code/Magento/Tax/Test/Unit/Model/System/Message/NotificationsTest.php index 3cf1421ebcf37..3fda67669fe86 100644 --- a/app/code/Magento/Tax/Test/Unit/Model/System/Message/NotificationsTest.php +++ b/app/code/Magento/Tax/Test/Unit/Model/System/Message/NotificationsTest.php @@ -73,6 +73,9 @@ public function testIsDisplayed( $this->assertEquals($expectedResult, $this->notifications->isDisplayed()); } + /** + * @return array + */ public function dataProviderIsDisplayed() { return [ diff --git a/app/code/Magento/Tax/Test/Unit/Model/TaxAddressManagerTest.php b/app/code/Magento/Tax/Test/Unit/Model/TaxAddressManagerTest.php index ec640b74f8985..493eebf9e1123 100644 --- a/app/code/Magento/Tax/Test/Unit/Model/TaxAddressManagerTest.php +++ b/app/code/Magento/Tax/Test/Unit/Model/TaxAddressManagerTest.php @@ -109,6 +109,9 @@ public function testSetDefaultAddressAfterSave( $this->manager->setDefaultAddressAfterSave($address); } + /** + * @return array + */ public function setAddressCustomerSessionAddressSaveDataProvider() { return [ @@ -151,6 +154,9 @@ public function testSetDefaultAddressAfterLogIn( $this->manager->setDefaultAddressAfterLogIn([$address]); } + /** + * @return array + */ public function setAddressCustomerSessionLogInDataProvider() { return [ diff --git a/app/code/Magento/Tax/Test/Unit/Model/TaxClass/FactoryTest.php b/app/code/Magento/Tax/Test/Unit/Model/TaxClass/FactoryTest.php index eb107c248880b..d46c9996c390c 100644 --- a/app/code/Magento/Tax/Test/Unit/Model/TaxClass/FactoryTest.php +++ b/app/code/Magento/Tax/Test/Unit/Model/TaxClass/FactoryTest.php @@ -39,6 +39,9 @@ public function testCreate($classType, $className, $classTypeMock) $this->assertEquals($classTypeMock, $taxClassFactory->create($classMock)); } + /** + * @return array + */ public function createDataProvider() { $customerClassMock = $this->createMock(\Magento\Tax\Model\TaxClass\Type\Customer::class); diff --git a/app/code/Magento/Tax/Test/Unit/Model/TaxRuleRepositoryTest.php b/app/code/Magento/Tax/Test/Unit/Model/TaxRuleRepositoryTest.php index f4151cd18ba66..3fddd5da47611 100644 --- a/app/code/Magento/Tax/Test/Unit/Model/TaxRuleRepositoryTest.php +++ b/app/code/Magento/Tax/Test/Unit/Model/TaxRuleRepositoryTest.php @@ -168,6 +168,9 @@ public function testSaveWithExceptions($exceptionObject, $exceptionName, $except $this->model->save($rule); } + /** + * @return array + */ public function saveExceptionsDataProvider() { return [ diff --git a/app/code/Magento/Tax/Test/Unit/Observer/AfterAddressSaveObserverTest.php b/app/code/Magento/Tax/Test/Unit/Observer/AfterAddressSaveObserverTest.php index 14d678d02366b..96b4b81ae2817 100644 --- a/app/code/Magento/Tax/Test/Unit/Observer/AfterAddressSaveObserverTest.php +++ b/app/code/Magento/Tax/Test/Unit/Observer/AfterAddressSaveObserverTest.php @@ -138,6 +138,9 @@ public function testExecute( $this->session->execute($this->observerMock); } + /** + * @return array + */ public function getExecuteDataProvider() { return [ diff --git a/app/code/Magento/Tax/Test/Unit/Pricing/AdjustmentTest.php b/app/code/Magento/Tax/Test/Unit/Pricing/AdjustmentTest.php index a92aa6a0d05eb..e7557e2164ca0 100644 --- a/app/code/Magento/Tax/Test/Unit/Pricing/AdjustmentTest.php +++ b/app/code/Magento/Tax/Test/Unit/Pricing/AdjustmentTest.php @@ -56,6 +56,9 @@ public function testIsIncludedInBasePrice($expectedResult) $this->assertEquals($expectedResult, $this->adjustment->isIncludedInBasePrice()); } + /** + * @return array + */ public function isIncludedInBasePriceDataProvider() { return [[true], [false]]; @@ -113,6 +116,9 @@ public function testExtractAdjustment($isPriceIncludesTax, $amount, $price, $exp $this->assertEquals($expectedResult, $this->adjustment->extractAdjustment($amount, $object)); } + /** + * @return array + */ public function extractAdjustmentDataProvider() { return [ @@ -164,6 +170,9 @@ public function testIsExcludedWith($adjustmentCode, $expectedResult) $this->assertEquals($expectedResult, $this->adjustment->isExcludedWith($adjustmentCode)); } + /** + * @return array + */ public function isExcludedWithDataProvider() { return [ diff --git a/app/code/Magento/Theme/Test/Unit/Block/Html/TopmenuTest.php b/app/code/Magento/Theme/Test/Unit/Block/Html/TopmenuTest.php index 49066e79cb798..91c3ce47fc8b8 100644 --- a/app/code/Magento/Theme/Test/Unit/Block/Html/TopmenuTest.php +++ b/app/code/Magento/Theme/Test/Unit/Block/Html/TopmenuTest.php @@ -109,6 +109,9 @@ protected function setUp() ); } + /** + * @return Topmenu + */ protected function getTopmenu() { return new Topmenu($this->context, $this->nodeFactory, $this->treeFactory); diff --git a/app/code/Magento/Theme/Test/Unit/Model/Design/Backend/ThemeTest.php b/app/code/Magento/Theme/Test/Unit/Model/Design/Backend/ThemeTest.php index d959b95dcb0ca..1725fe158c16c 100644 --- a/app/code/Magento/Theme/Test/Unit/Model/Design/Backend/ThemeTest.php +++ b/app/code/Magento/Theme/Test/Unit/Model/Design/Backend/ThemeTest.php @@ -123,6 +123,9 @@ public function testGetValue($value, $expectedResult) $this->assertEquals($expectedResult, $this->model->getValue()); } + /** + * @return array + */ public function getValueDataProvider() { return [ @@ -131,6 +134,9 @@ public function getValueDataProvider() ]; } + /** + * @return array + */ public function afterSaveDataProvider() { return [ diff --git a/app/code/Magento/Theme/Test/Unit/Model/Theme/ValidationTest.php b/app/code/Magento/Theme/Test/Unit/Model/Theme/ValidationTest.php index 5d1c9f8cf7c3c..e302762c1c783 100644 --- a/app/code/Magento/Theme/Test/Unit/Model/Theme/ValidationTest.php +++ b/app/code/Magento/Theme/Test/Unit/Model/Theme/ValidationTest.php @@ -31,6 +31,9 @@ public function testValidate(array $data, $result, array $messages) $this->assertEquals($messages, $validator->getErrorMessages()); } + /** + * @return array + */ public function dataProviderValidate() { return [ diff --git a/app/code/Magento/Theme/Test/Unit/Model/ThemeTest.php b/app/code/Magento/Theme/Test/Unit/Model/ThemeTest.php index 4ff64e6f694e8..b191a64ac2c21 100644 --- a/app/code/Magento/Theme/Test/Unit/Model/ThemeTest.php +++ b/app/code/Magento/Theme/Test/Unit/Model/ThemeTest.php @@ -481,6 +481,9 @@ public function testToArray(array $themeData, array $expected) $this->assertEquals($expected, $this->_model->toArray()); } + /** + * @return array + */ public function toArrayDataProvider() { $parentTheme = $this->getMockBuilder(\Magento\Theme\Model\Theme::class) @@ -555,6 +558,9 @@ public function testPopulateFromArray(array $value, array $expected, $expectedCa $this->assertEquals($expected, $this->_model->getData()); } + /** + * @return array + */ public function populateFromArrayDataProvider() { return [ diff --git a/app/code/Magento/Theme/Test/Unit/Model/Wysiwyg/StorageTest.php b/app/code/Magento/Theme/Test/Unit/Model/Wysiwyg/StorageTest.php index 62b644042b68d..913561590607a 100644 --- a/app/code/Magento/Theme/Test/Unit/Model/Wysiwyg/StorageTest.php +++ b/app/code/Magento/Theme/Test/Unit/Model/Wysiwyg/StorageTest.php @@ -172,6 +172,9 @@ public function testUploadInvalidFile() $this->_storageModel->uploadFile($this->_storageRoot); } + /** + * @return \PHPUnit_Framework_MockObject_MockObject + */ protected function _prepareUploader() { $uploader = $this->createMock(\Magento\MediaStorage\Model\File\Uploader::class); @@ -538,6 +541,9 @@ public function testDeleteRootDirectory() $this->_storageModel->deleteDirectory($directoryPath); } + /** + * @return array + */ public function booleanCasesDataProvider() { return [[true], [false]]; diff --git a/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/EditActionTest.php b/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/EditActionTest.php index 068738f17c967..2ac959d0a9881 100644 --- a/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/EditActionTest.php +++ b/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/EditActionTest.php @@ -82,6 +82,9 @@ public function testPrepareDataSource($dataSourceItem, $scope, $scopeId) $this->assertEquals($expectedDataSource, $dataSource); } + /** + * @return array + */ public function getPrepareDataSourceDataProvider() { return [ diff --git a/app/code/Magento/Ui/Test/Unit/Component/Form/Element/AbstractElementTest.php b/app/code/Magento/Ui/Test/Unit/Component/Form/Element/AbstractElementTest.php index 54bf0c9e8b37e..d9afe8f16a1a7 100644 --- a/app/code/Magento/Ui/Test/Unit/Component/Form/Element/AbstractElementTest.php +++ b/app/code/Magento/Ui/Test/Unit/Component/Form/Element/AbstractElementTest.php @@ -46,6 +46,9 @@ protected function setUp() */ abstract protected function getModelName(); + /** + * @return mixed + */ abstract public function testGetComponentName(); /** diff --git a/app/code/Magento/Ui/Test/Unit/Component/Form/Element/ActionDeleteTest.php b/app/code/Magento/Ui/Test/Unit/Component/Form/Element/ActionDeleteTest.php index 6f45c192d6c4c..890737965d559 100644 --- a/app/code/Magento/Ui/Test/Unit/Component/Form/Element/ActionDeleteTest.php +++ b/app/code/Magento/Ui/Test/Unit/Component/Form/Element/ActionDeleteTest.php @@ -20,6 +20,9 @@ protected function getModelName() return ActionDelete::class; } + /** + * @return mixed|void + */ public function testGetComponentName() { $this->assertSame(ActionDelete::NAME, $this->getModel()->getComponentName()); diff --git a/app/code/Magento/Ui/Test/Unit/Component/Form/Element/CheckboxSetTest.php b/app/code/Magento/Ui/Test/Unit/Component/Form/Element/CheckboxSetTest.php index 025f4a1582458..968155b92a3b9 100644 --- a/app/code/Magento/Ui/Test/Unit/Component/Form/Element/CheckboxSetTest.php +++ b/app/code/Magento/Ui/Test/Unit/Component/Form/Element/CheckboxSetTest.php @@ -22,6 +22,9 @@ protected function getModelName() return CheckboxSet::class; } + /** + * @return mixed|void + */ public function testGetComponentName() { $this->assertSame(CheckboxSet::NAME, $this->getModel()->getComponentName()); diff --git a/app/code/Magento/Ui/Test/Unit/Component/Form/Element/MultiSelectTest.php b/app/code/Magento/Ui/Test/Unit/Component/Form/Element/MultiSelectTest.php index cb91fbb945bb5..723d6402fe865 100644 --- a/app/code/Magento/Ui/Test/Unit/Component/Form/Element/MultiSelectTest.php +++ b/app/code/Magento/Ui/Test/Unit/Component/Form/Element/MultiSelectTest.php @@ -22,6 +22,9 @@ protected function getModelName() return MultiSelect::class; } + /** + * @return mixed|void + */ public function testGetComponentName() { $this->contextMock->expects($this->never())->method('getProcessor'); diff --git a/app/code/Magento/Ui/Test/Unit/Component/Form/Element/RadioSetTest.php b/app/code/Magento/Ui/Test/Unit/Component/Form/Element/RadioSetTest.php index 0e0fef60df60b..ea4f0f9f94a00 100644 --- a/app/code/Magento/Ui/Test/Unit/Component/Form/Element/RadioSetTest.php +++ b/app/code/Magento/Ui/Test/Unit/Component/Form/Element/RadioSetTest.php @@ -22,6 +22,9 @@ protected function getModelName() return RadioSet::class; } + /** + * @return mixed|void + */ public function testGetComponentName() { $this->assertSame(RadioSet::NAME, $this->getModel()->getComponentName()); diff --git a/app/code/Magento/Ui/Test/Unit/Component/Form/Element/SelectTest.php b/app/code/Magento/Ui/Test/Unit/Component/Form/Element/SelectTest.php index c695262681063..6432f8404eaff 100644 --- a/app/code/Magento/Ui/Test/Unit/Component/Form/Element/SelectTest.php +++ b/app/code/Magento/Ui/Test/Unit/Component/Form/Element/SelectTest.php @@ -22,6 +22,9 @@ protected function getModelName() return Select::class; } + /** + * @return mixed|void + */ public function testGetComponentName() { $this->assertSame(Select::NAME, $this->getModel()->getComponentName()); diff --git a/app/code/Magento/Ui/Test/Unit/Component/Form/Element/WysiwygTest.php b/app/code/Magento/Ui/Test/Unit/Component/Form/Element/WysiwygTest.php index d0e0542a19480..2304883666b74 100644 --- a/app/code/Magento/Ui/Test/Unit/Component/Form/Element/WysiwygTest.php +++ b/app/code/Magento/Ui/Test/Unit/Component/Form/Element/WysiwygTest.php @@ -62,6 +62,9 @@ protected function setUp() ->method('getElementHtml'); } + /** + * @return \Magento\Ui\Component\Form\Element\AbstractElement|object + */ protected function getModel() { return $this->objectManager->getObject(Wysiwyg::class, [ @@ -82,6 +85,9 @@ protected function getModelName() return Wysiwyg::class; } + /** + * @return mixed|void + */ public function testGetComponentName() { $this->assertSame(Wysiwyg::NAME, $this->getModel()->getComponentName()); diff --git a/app/code/Magento/Ui/Test/Unit/Component/MassActionTest.php b/app/code/Magento/Ui/Test/Unit/Component/MassActionTest.php index 123b4cacf71a7..b2f494351597f 100644 --- a/app/code/Magento/Ui/Test/Unit/Component/MassActionTest.php +++ b/app/code/Magento/Ui/Test/Unit/Component/MassActionTest.php @@ -93,6 +93,9 @@ public function testPrepare($componentName, $componentData) $this->assertEquals(['actions' => [$action->getConfiguration()]], $massAction->getConfiguration()); } + /** + * @return array + */ public function getPrepareDataProvider() { return [ diff --git a/app/code/Magento/Ui/Test/Unit/Config/Converter/ActionsTest.php b/app/code/Magento/Ui/Test/Unit/Config/Converter/ActionsTest.php index 8228026dff3d1..d146a18a710c6 100644 --- a/app/code/Magento/Ui/Test/Unit/Config/Converter/ActionsTest.php +++ b/app/code/Magento/Ui/Test/Unit/Config/Converter/ActionsTest.php @@ -61,6 +61,9 @@ public function testConvert(array $expectedResult, $xpath) $this->assertEquals($expectedResult, $this->converter->convert($actions)); } + /** + * @return array + */ public function convertDataProvider() { return [ diff --git a/app/code/Magento/Ui/Test/Unit/Config/Converter/OptionsTest.php b/app/code/Magento/Ui/Test/Unit/Config/Converter/OptionsTest.php index 058e3651bde5c..8f5ab55f7a914 100644 --- a/app/code/Magento/Ui/Test/Unit/Config/Converter/OptionsTest.php +++ b/app/code/Magento/Ui/Test/Unit/Config/Converter/OptionsTest.php @@ -41,6 +41,9 @@ public function testConvert(array $expectedResult, $xpath) $this->assertEquals($expectedResult, $res); } + /** + * @return array + */ public function convertDataProvider() { return [ diff --git a/app/code/Magento/Ui/Test/Unit/Model/ManagerTest.php b/app/code/Magento/Ui/Test/Unit/Model/ManagerTest.php index 96468b63314b4..fde743390816d 100644 --- a/app/code/Magento/Ui/Test/Unit/Model/ManagerTest.php +++ b/app/code/Magento/Ui/Test/Unit/Model/ManagerTest.php @@ -193,6 +193,9 @@ public function testPrepareGetData($componentName, $componentData, $isCached, $r ); } + /** + * @return array + */ public function getComponentData() { $cachedData = new \ArrayObject( @@ -293,6 +296,9 @@ public function testCreateRawComponentData($componentName, $configData, $compone $this->assertEquals($componentData, $this->manager->createRawComponentData($componentName, $needEvaluate)); } + /** + * @return array + */ public function getComponentDataProvider() { return [ diff --git a/app/code/Magento/UrlRewrite/Test/Unit/Helper/UrlRewriteTest.php b/app/code/Magento/UrlRewrite/Test/Unit/Helper/UrlRewriteTest.php index e41a06cb0c9f0..b99c5c48c3de0 100644 --- a/app/code/Magento/UrlRewrite/Test/Unit/Helper/UrlRewriteTest.php +++ b/app/code/Magento/UrlRewrite/Test/Unit/Helper/UrlRewriteTest.php @@ -55,6 +55,9 @@ public function testValidateSuffixException($suffix) $this->_helper->validateSuffix($suffix); } + /** + * @return array + */ public function requestPathDataProvider() { return [ @@ -63,6 +66,9 @@ public function requestPathDataProvider() ]; } + /** + * @return array + */ public function requestPathExceptionDataProvider() { return [ diff --git a/app/code/Magento/Variable/Test/Unit/Model/VariableTest.php b/app/code/Magento/Variable/Test/Unit/Model/VariableTest.php index 54ceffff665ea..0f70753e01fbf 100644 --- a/app/code/Magento/Variable/Test/Unit/Model/VariableTest.php +++ b/app/code/Magento/Variable/Test/Unit/Model/VariableTest.php @@ -111,6 +111,9 @@ public function testValidate($variableArray, $objectId, $expectedResult) $this->assertEquals($expectedResult, $this->model->validate($variableArray)); } + /** + * @return array + */ public function validateDataProvider() { $variable = [ @@ -123,6 +126,9 @@ public function validateDataProvider() ]; } + /** + * @return array + */ public function validateMissingInfoDataProvider() { return [ diff --git a/app/code/Magento/Vault/Test/Unit/Observer/AfterPaymentSaveObserverTest.php b/app/code/Magento/Vault/Test/Unit/Observer/AfterPaymentSaveObserverTest.php index efbe2e9745ef1..09c17d1e58d98 100644 --- a/app/code/Magento/Vault/Test/Unit/Observer/AfterPaymentSaveObserverTest.php +++ b/app/code/Magento/Vault/Test/Unit/Observer/AfterPaymentSaveObserverTest.php @@ -160,6 +160,9 @@ public function testPositiveCase($customerId, $createdAt, $token, $isActive, $me static::assertEquals($createdAt, $paymentToken->getCreatedAt()); } + /** + * @return array + */ public function positiveCaseDataProvider() { return [ diff --git a/app/code/Magento/Webapi/Test/Unit/Controller/PathProcessorTest.php b/app/code/Magento/Webapi/Test/Unit/Controller/PathProcessorTest.php index 7f3fe558a98eb..c213c72b5185a 100644 --- a/app/code/Magento/Webapi/Test/Unit/Controller/PathProcessorTest.php +++ b/app/code/Magento/Webapi/Test/Unit/Controller/PathProcessorTest.php @@ -51,6 +51,9 @@ public function testAllStoreCode($storeCodeInPath, $storeCodeSet, $setCurrentSto $this->assertSame($this->endpointPath, $result); } + /** + * @return array + */ public function processPathDataProvider() { return [ diff --git a/app/code/Magento/Webapi/Test/Unit/Model/Authorization/TokenUserContextTest.php b/app/code/Magento/Webapi/Test/Unit/Model/Authorization/TokenUserContextTest.php index c7272e3e5a2b2..86ef45e95618a 100644 --- a/app/code/Magento/Webapi/Test/Unit/Model/Authorization/TokenUserContextTest.php +++ b/app/code/Magento/Webapi/Test/Unit/Model/Authorization/TokenUserContextTest.php @@ -297,6 +297,9 @@ public function testValidToken($userType, $userId, $expectedUserType, $expectedU $this->assertEquals($expectedUserId, $this->tokenUserContext->getUserId()); } + /** + * @return array + */ public function getValidTokenData() { return [ diff --git a/app/code/Magento/Webapi/Test/Unit/Model/Rest/Swagger/GeneratorTest.php b/app/code/Magento/Webapi/Test/Unit/Model/Rest/Swagger/GeneratorTest.php index 611517df51657..8976ea6845dad 100644 --- a/app/code/Magento/Webapi/Test/Unit/Model/Rest/Swagger/GeneratorTest.php +++ b/app/code/Magento/Webapi/Test/Unit/Model/Rest/Swagger/GeneratorTest.php @@ -295,6 +295,9 @@ public function testGetObjectSchema($typeName, $description, $result) $this->assertSame(json_encode($result), json_encode($actual)); } + /** + * @return array + */ public function getObjectSchemaDataProvider() { return [ @@ -354,6 +357,9 @@ public function testGenerateDefinition($typeData, $expected) $this->assertSame(json_encode($expected), json_encode($actual)); } + /** + * @return array + */ public function generateDefinitionDataProvider() { return [ diff --git a/app/code/Magento/Weee/Test/Unit/Block/Item/Price/RendererTest.php b/app/code/Magento/Weee/Test/Unit/Block/Item/Price/RendererTest.php index b49150fc6fac0..8b770ea763cdd 100644 --- a/app/code/Magento/Weee/Test/Unit/Block/Item/Price/RendererTest.php +++ b/app/code/Magento/Weee/Test/Unit/Block/Item/Price/RendererTest.php @@ -122,6 +122,9 @@ public function testDisplayPriceWithWeeeDetails( $this->assertEquals($expectedValue, $this->renderer->displayPriceWithWeeeDetails()); } + /** + * @return array + */ public function displayPriceWithWeeeDetailsDataProvider() { $data = [ @@ -472,6 +475,9 @@ public function testGetBaseRowDisplayPriceInclTax( $this->assertEquals($expectedValue, $this->renderer->getBaseRowDisplayPriceInclTax()); } + /** + * @return array + */ public function getDisplayPriceDataProvider() { $data = [ @@ -739,6 +745,9 @@ public function testGetBaseFinalRowDisplayPriceInclTax( $this->assertEquals($expectedValue, $this->renderer->getBaseFinalRowDisplayPriceInclTax()); } + /** + * @return array + */ public function getFinalDisplayPriceDataProvider() { $data = [ diff --git a/app/code/Magento/Weee/Test/Unit/Model/Total/Invoice/WeeeTest.php b/app/code/Magento/Weee/Test/Unit/Model/Total/Invoice/WeeeTest.php index 975580945bb3a..22d673e0c8b26 100644 --- a/app/code/Magento/Weee/Test/Unit/Model/Total/Invoice/WeeeTest.php +++ b/app/code/Magento/Weee/Test/Unit/Model/Total/Invoice/WeeeTest.php @@ -78,6 +78,9 @@ protected function setUp() $this->invoice->expects($this->atLeastOnce())->method('getOrder')->will($this->returnValue($this->order)); } + /** + * @param $orderData + */ private function setupOrder($orderData) { //Set up order mock diff --git a/app/code/Magento/Weee/Test/Unit/Observer/AfterAddressSaveTest.php b/app/code/Magento/Weee/Test/Unit/Observer/AfterAddressSaveTest.php index 19f55550bac65..6d363847bf9e6 100644 --- a/app/code/Magento/Weee/Test/Unit/Observer/AfterAddressSaveTest.php +++ b/app/code/Magento/Weee/Test/Unit/Observer/AfterAddressSaveTest.php @@ -130,6 +130,9 @@ public function testExecute( $this->session->execute($this->observerMock); } + /** + * @return array + */ public function getExecuteDataProvider() { return [ diff --git a/app/code/Magento/Weee/Test/Unit/Pricing/AdjustmentTest.php b/app/code/Magento/Weee/Test/Unit/Pricing/AdjustmentTest.php index e0eba358bc892..4c65011c1f69a 100644 --- a/app/code/Magento/Weee/Test/Unit/Pricing/AdjustmentTest.php +++ b/app/code/Magento/Weee/Test/Unit/Pricing/AdjustmentTest.php @@ -134,6 +134,9 @@ public function testIsExcludedWith($adjustmentCode, $expectedResult) $this->assertEquals($expectedResult, $this->adjustment->isExcludedWith($adjustmentCode)); } + /** + * @return array + */ public function isExcludedWithDataProvider() { return [ @@ -157,6 +160,9 @@ public function testGetSortOrder($isTaxable, $expectedResult) $this->assertEquals($expectedResult, $this->adjustment->getSortOrder()); } + /** + * @return array + */ public function getSortOrderProvider() { return [ diff --git a/app/code/Magento/Wishlist/Test/Unit/Block/Customer/Wishlist/Item/OptionsTest.php b/app/code/Magento/Wishlist/Test/Unit/Block/Customer/Wishlist/Item/OptionsTest.php index 4b3ff8b8dd23e..36c51547c5a42 100644 --- a/app/code/Magento/Wishlist/Test/Unit/Block/Customer/Wishlist/Item/OptionsTest.php +++ b/app/code/Magento/Wishlist/Test/Unit/Block/Customer/Wishlist/Item/OptionsTest.php @@ -114,6 +114,9 @@ public function testGetConfiguredOptions($options, $callNum, $expected) $this->assertEquals($expected, $this->block->getConfiguredOptions()); } + /** + * @return array + */ public function getConfiguredOptionsDataProvider() { return [ diff --git a/app/code/Magento/Wishlist/Test/Unit/Controller/Index/AllcartTest.php b/app/code/Magento/Wishlist/Test/Unit/Controller/Index/AllcartTest.php index d7195086850e4..2df44a912a09c 100644 --- a/app/code/Magento/Wishlist/Test/Unit/Controller/Index/AllcartTest.php +++ b/app/code/Magento/Wishlist/Test/Unit/Controller/Index/AllcartTest.php @@ -136,6 +136,9 @@ protected function prepareContext() ->willReturn($this->resultFactoryMock); } + /** + * @return \Magento\Wishlist\Controller\Index\Allcart + */ public function getController() { $this->prepareContext(); diff --git a/app/code/Magento/Wishlist/Test/Unit/Controller/Index/IndexTest.php b/app/code/Magento/Wishlist/Test/Unit/Controller/Index/IndexTest.php index 136d0f7f36c3e..7c6ba740aa18d 100644 --- a/app/code/Magento/Wishlist/Test/Unit/Controller/Index/IndexTest.php +++ b/app/code/Magento/Wishlist/Test/Unit/Controller/Index/IndexTest.php @@ -123,6 +123,9 @@ protected function prepareContext() ->willReturn($this->resultFactoryMock); } + /** + * @return \Magento\Wishlist\Controller\Index\Index + */ public function getController() { $this->prepareContext(); diff --git a/app/code/Magento/Wishlist/Test/Unit/Controller/Index/PluginTest.php b/app/code/Magento/Wishlist/Test/Unit/Controller/Index/PluginTest.php index 82a58df1e579e..79186d29e666d 100644 --- a/app/code/Magento/Wishlist/Test/Unit/Controller/Index/PluginTest.php +++ b/app/code/Magento/Wishlist/Test/Unit/Controller/Index/PluginTest.php @@ -67,6 +67,9 @@ protected function tearDown() ); } + /** + * @return \Magento\Wishlist\Controller\Index\Plugin + */ protected function getPlugin() { return new \Magento\Wishlist\Controller\Index\Plugin( diff --git a/app/code/Magento/Wishlist/Test/Unit/Controller/Index/RemoveTest.php b/app/code/Magento/Wishlist/Test/Unit/Controller/Index/RemoveTest.php index 2a36d3beb8558..6260a1292bee9 100644 --- a/app/code/Magento/Wishlist/Test/Unit/Controller/Index/RemoveTest.php +++ b/app/code/Magento/Wishlist/Test/Unit/Controller/Index/RemoveTest.php @@ -139,6 +139,9 @@ protected function prepareContext() ->willReturn($this->resultFactoryMock); } + /** + * @return \Magento\Wishlist\Controller\Index\Remove + */ public function getController() { $this->prepareContext(); diff --git a/app/code/Magento/Wishlist/Test/Unit/Model/ItemTest.php b/app/code/Magento/Wishlist/Test/Unit/Model/ItemTest.php index 0b1057683de86..9876b3f6bb75e 100644 --- a/app/code/Magento/Wishlist/Test/Unit/Model/ItemTest.php +++ b/app/code/Magento/Wishlist/Test/Unit/Model/ItemTest.php @@ -172,6 +172,9 @@ public function testRemoveOptionByCode($code, $option) $this->assertTrue($actualOption->isDeleted()); } + /** + * @return array + */ public function getOptionsDataProvider() { $optionMock = $this->getMockBuilder(\Magento\Wishlist\Model\Item\Option::class) diff --git a/app/code/Magento/Wishlist/Test/Unit/Model/LocaleQuantityProcessorTest.php b/app/code/Magento/Wishlist/Test/Unit/Model/LocaleQuantityProcessorTest.php index 145d282554634..6cac17aa8c3da 100644 --- a/app/code/Magento/Wishlist/Test/Unit/Model/LocaleQuantityProcessorTest.php +++ b/app/code/Magento/Wishlist/Test/Unit/Model/LocaleQuantityProcessorTest.php @@ -60,6 +60,9 @@ public function testProcess($qtyResult, $expectedResult) $this->assertEquals($expectedResult, $this->processor->process($qty)); } + /** + * @return array + */ public function processDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Acl/Test/Unit/Role/RegistryTest.php b/lib/internal/Magento/Framework/Acl/Test/Unit/Role/RegistryTest.php index 9f7269455555c..d15624637b597 100644 --- a/lib/internal/Magento/Framework/Acl/Test/Unit/Role/RegistryTest.php +++ b/lib/internal/Magento/Framework/Acl/Test/Unit/Role/RegistryTest.php @@ -20,6 +20,13 @@ protected function setUp() $this->model = new Registry(); } + /** + * @param $roleId + * @param $parentRoleId + * + * @return array + * @throws \Zend_Acl_Role_Registry_Exception + */ protected function initRoles($roleId, $parentRoleId) { $parentRole = $this->createMock(\Zend_Acl_Role_Interface::class); diff --git a/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/EntityChildTestAbstract.php b/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/EntityChildTestAbstract.php index 47f520d4ee28a..c1ab91e3ccaa6 100644 --- a/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/EntityChildTestAbstract.php +++ b/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/EntityChildTestAbstract.php @@ -31,12 +31,24 @@ abstract class EntityChildTestAbstract extends \PHPUnit\Framework\TestCase /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\Code\Generator\DefinedClasses */ protected $definedClassesMock; + /** + * @return mixed + */ abstract protected function getSourceClassName(); + /** + * @return mixed + */ abstract protected function getResultClassName(); + /** + * @return mixed + */ abstract protected function getGeneratorClassName(); + /** + * @return mixed + */ abstract protected function getOutputFileName(); protected function setUp() diff --git a/lib/internal/Magento/Framework/Api/Test/Unit/DataObjectHelperTest.php b/lib/internal/Magento/Framework/Api/Test/Unit/DataObjectHelperTest.php index 4946f083004ba..f4855a6f69066 100644 --- a/lib/internal/Magento/Framework/Api/Test/Unit/DataObjectHelperTest.php +++ b/lib/internal/Magento/Framework/Api/Test/Unit/DataObjectHelperTest.php @@ -367,6 +367,9 @@ public function testMergeDataObjects($data1, $data2) $this->assertSame($firstAddressDataObject->getRegion(), $secondAddressDataObject->getRegion()); } + /** + * @return array + */ public function dataProviderForTestMergeDataObjects() { return [ diff --git a/lib/internal/Magento/Framework/Api/Test/Unit/SortOrderTest.php b/lib/internal/Magento/Framework/Api/Test/Unit/SortOrderTest.php index 05ecc0bdbcc61..c2ecf51e8afc4 100644 --- a/lib/internal/Magento/Framework/Api/Test/Unit/SortOrderTest.php +++ b/lib/internal/Magento/Framework/Api/Test/Unit/SortOrderTest.php @@ -37,6 +37,9 @@ public function testItReturnsTheCorrectValuesIfSortOrderIsSet($sortOrder) $this->assertSame($sortOrder, $this->sortOrder->getDirection()); } + /** + * @return array + */ public function sortOrderDirectionProvider() { return [[SortOrder::SORT_ASC], [SortOrder::SORT_DESC]]; @@ -52,6 +55,9 @@ public function testItThrowsAnExceptionIfAnInvalidSortOrderIsSet($invalidDirecti $this->sortOrder->setDirection($invalidDirection); } + /** + * @return array + */ public function invalidSortDirectionProvider() { return [ diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Action/Stub/ActionStub.php b/lib/internal/Magento/Framework/App/Test/Unit/Action/Stub/ActionStub.php index ee45842013f64..c157f818242ef 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Action/Stub/ActionStub.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Action/Stub/ActionStub.php @@ -8,6 +8,9 @@ class ActionStub extends \Magento\Framework\App\Action\Action { + /** + * @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface|void + */ public function execute() { // Empty method stub for test diff --git a/lib/internal/Magento/Framework/App/Test/Unit/AreaTest.php b/lib/internal/Magento/Framework/App/Test/Unit/AreaTest.php index 678bb7a85272f..1813ff147190c 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/AreaTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/AreaTest.php @@ -276,6 +276,9 @@ public function testDetectDesignByRequest($value, $callNum, $callNum2) $this->object->detectDesign($requestMock); } + /** + * @return array + */ public function detectDesignByRequestDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/App/Test/Unit/BootstrapTest.php b/lib/internal/Magento/Framework/App/Test/Unit/BootstrapTest.php index 1e2947084ee6b..bfa96a1702879 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/BootstrapTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/BootstrapTest.php @@ -189,6 +189,9 @@ public function testIsDeveloperMode($modeFromEnvironment, $modeFromDeployment, $ $this->assertEquals($isDeveloper, $bootstrap->isDeveloperMode()); } + /** + * @return array + */ public function testIsDeveloperModeDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Cache/Frontend/PoolTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Cache/Frontend/PoolTest.php index fdb962d7d295e..bfa37311884ba 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Cache/Frontend/PoolTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Cache/Frontend/PoolTest.php @@ -105,6 +105,9 @@ public function testInitializationParams( $model->current(); } + /** + * @return array + */ public function initializationParamsDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Cache/Type/ConfigTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Cache/Type/ConfigTest.php index 74a92d54f1934..380c45e383128 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Cache/Type/ConfigTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Cache/Type/ConfigTest.php @@ -157,6 +157,9 @@ public function testCleanModeMatchingAnyTag($fixtureResultOne, $fixtureResultTwo $this->assertEquals($expectedResult, $actualResult); } + /** + * @return array + */ public function cleanModeMatchingAnyTagDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Cache/Type/FrontendPoolTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Cache/Type/FrontendPoolTest.php index e8c0217b40b2c..bcae099815c98 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Cache/Type/FrontendPoolTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Cache/Type/FrontendPoolTest.php @@ -89,6 +89,9 @@ public function testGet($fixtureConfigData, $inputCacheType, $expectedFrontendId $this->assertSame($accessProxy, $this->_model->get($inputCacheType)); } + /** + * @return array + */ public function getDataProvider() { $configData1 = [ diff --git a/lib/internal/Magento/Framework/App/Test/Unit/CacheTest.php b/lib/internal/Magento/Framework/App/Test/Unit/CacheTest.php index 236a65611422d..bb5748e0759a0 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/CacheTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/CacheTest.php @@ -147,6 +147,9 @@ public function testSave($inputData, $inputId, $inputTags, $expectedData, $expec $this->_model->save($inputData, $inputId, $inputTags); } + /** + * @return array + */ public function saveDataProvider() { $configTag = \Magento\Framework\App\Config::CACHE_TAG; @@ -190,6 +193,9 @@ public function testRemove($result) $this->assertEquals($result, $this->_model->remove('test_id')); } + /** + * @return array + */ public function successFailureDataProvider() { return ['success' => [true], 'failure' => [false]]; diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Config/ConfigPathResolverTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Config/ConfigPathResolverTest.php index 3cf552ae115a5..3adc4bada0665 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Config/ConfigPathResolverTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Config/ConfigPathResolverTest.php @@ -55,6 +55,9 @@ public function testResolve($path, $scope, $scopeCode, $type, $expected) $this->assertSame($expected, $this->model->resolve($path, $scope, $scopeCode, $type)); } + /** + * @return array + */ public function resolveDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Config/DataTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Config/DataTest.php index f106ba6e151fd..6f137ede742ff 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Config/DataTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Config/DataTest.php @@ -35,6 +35,9 @@ public function testSetValue($path, $value) $this->assertEquals($value, $this->_model->getValue($path)); } + /** + * @return array + */ public function setValueDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Config/InitialTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Config/InitialTest.php index 3d1cdf0023cc9..29ccd33d73d3b 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Config/InitialTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Config/InitialTest.php @@ -65,6 +65,9 @@ public function testGetData($scope, $expected) $this->assertEquals($expected, $this->config->getData($scope)); } + /** + * @return array + */ public function getDataDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Config/ValueTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Config/ValueTest.php index ef2b342936cd9..6159e5cac45e8 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Config/ValueTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Config/ValueTest.php @@ -184,6 +184,9 @@ public function testAfterSave($callNumber, $oldValue) $this->assertInstanceOf(get_class($this->model), $this->model->afterSave()); } + /** + * @return array + */ public function afterSaveDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/App/Test/Unit/ConfigTest.php b/lib/internal/Magento/Framework/App/Test/Unit/ConfigTest.php index f94c30b4fa3c8..da9826bfe8c95 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/ConfigTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/ConfigTest.php @@ -73,6 +73,9 @@ public function testGetValue($scope, $scopeCode = null) $this->assertTrue($this->appConfig->getValue($path, $scope, $scopeCode ?: $this->scope)); } + /** + * @return array + */ public function getValueDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Console/MaintenanceModeEnablerTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Console/MaintenanceModeEnablerTest.php index ebd47c0dc8936..784cb8136c3ab 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Console/MaintenanceModeEnablerTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Console/MaintenanceModeEnablerTest.php @@ -88,6 +88,9 @@ public function testFailedTaskWithRestoredModeOnFailure(bool $maintenanceModeEna } } + /** + * @return array + */ public function initialAppStateProvider() { return [ @@ -96,6 +99,11 @@ public function initialAppStateProvider() ]; } + /** + * @param bool $isOn + * + * @return MaintenanceMode + */ private function createMaintenanceMode(bool $isOn): MaintenanceMode { $maintenanceMode = $this->getMockBuilder(MaintenanceMode::class) @@ -113,6 +121,9 @@ private function createMaintenanceMode(bool $isOn): MaintenanceMode return $maintenanceMode; } + /** + * @return OutputInterface + */ private function createOutput(): OutputInterface { $output = $this->getMockBuilder(OutputInterface::class) diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Console/ResponseTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Console/ResponseTest.php index ec678d21a581b..18de140af8428 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Console/ResponseTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Console/ResponseTest.php @@ -34,6 +34,9 @@ public function testSetCode($code, $expectedCode) $this->assertEquals($expectedCode, $result); } + /** + * @return array + */ public static function setCodeProvider() { $largeCode = 256; diff --git a/lib/internal/Magento/Framework/App/Test/Unit/CronTest.php b/lib/internal/Magento/Framework/App/Test/Unit/CronTest.php index e2c77864d8e82..ce1f1661ad827 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/CronTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/CronTest.php @@ -56,6 +56,9 @@ protected function setUp() ); } + /** + * @return \PHPUnit_Framework_MockObject_MockObject + */ protected function prepareAreaListMock() { $areaMock = $this->createMock(\Magento\Framework\App\Area::class); diff --git a/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfigTest.php b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfigTest.php index fa41d717cc521..80ab2302dc91c 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfigTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfigTest.php @@ -127,6 +127,9 @@ public function testKeyCollision(array $data) $object->get(); } + /** + * @return array + */ public function keyCollisionDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/App/Test/Unit/DocRootLocatorTest.php b/lib/internal/Magento/Framework/App/Test/Unit/DocRootLocatorTest.php index 7fda8de6d3216..23afbbc73d2b9 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/DocRootLocatorTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/DocRootLocatorTest.php @@ -29,6 +29,9 @@ public function testIsPub($path, $isExist, $result) $this->assertSame($result, $model->isPub()); } + /** + * @return array + */ public function isPubDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/App/Test/Unit/ErrorHandlerTest.php b/lib/internal/Magento/Framework/App/Test/Unit/ErrorHandlerTest.php index daf3a4bdfab0c..4b904cc2b55bd 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/ErrorHandlerTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/ErrorHandlerTest.php @@ -32,6 +32,9 @@ public function testHandler($errorNo, $errorStr, $errorFile, $expectedResult) $this->assertEquals($expectedResult, $this->object->handler($errorNo, $errorStr, $errorFile, 11)); } + /** + * @return array + */ public function handlerProvider() { return [ @@ -60,6 +63,9 @@ public function testHandlerException($errorNo, $errorPhrase) $this->object->handler($errorNo, $errorStr, $errorFile, $errorLine); } + /** + * @return array + */ public function handlerProviderException() { return [ diff --git a/lib/internal/Magento/Framework/App/Test/Unit/PageCache/IdentifierTest.php b/lib/internal/Magento/Framework/App/Test/Unit/PageCache/IdentifierTest.php index 15f6bed1ac0d3..23906486634ec 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/PageCache/IdentifierTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/PageCache/IdentifierTest.php @@ -144,6 +144,9 @@ public function testVaryStringSource($cookieExists) $this->model->getValue(); } + /** + * @return array + */ public function trueFalseDataProvider() { return [[true], [false]]; diff --git a/lib/internal/Magento/Framework/App/Test/Unit/PageCache/KernelTest.php b/lib/internal/Magento/Framework/App/Test/Unit/PageCache/KernelTest.php index 20ea5d1a3e86f..db200f962f5b5 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/PageCache/KernelTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/PageCache/KernelTest.php @@ -241,6 +241,9 @@ function ($value) { $this->kernel->process($this->responseMock); } + /** + * @return array + */ public function testProcessSaveCacheDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/App/Test/Unit/ProductMetadataTest.php b/lib/internal/Magento/Framework/App/Test/Unit/ProductMetadataTest.php index 74e673c8bfc26..8e1acc89437e2 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/ProductMetadataTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/ProductMetadataTest.php @@ -45,6 +45,9 @@ public function testGetVersion($packageList, $expectedVersion) $this->assertEquals($expectedVersion, $productVersion); } + /** + * @return array + */ public function testGetVersionGitInstallationDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Request/HttpTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Request/HttpTest.php index 66eee671e17d3..62445d4244fb7 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Request/HttpTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Request/HttpTest.php @@ -259,6 +259,9 @@ public function testGetDistroBaseUrlPath($scriptName, $expected) $this->assertEquals($expected, Http::getDistroBaseUrlPath(['SCRIPT_NAME' => $scriptName])); } + /** + * @return array + */ public function getDistroBaseUrlPathDataProvider() { return [ @@ -273,6 +276,9 @@ public function getDistroBaseUrlPathDataProvider() ]; } + /** + * @return array + */ public function serverVariablesProvider() { $returnValue = []; @@ -378,6 +384,9 @@ public function testIsSafeMethodFalse($httpMethod) $this->assertEquals(false, $this->_model->isSafeMethod()); } + /** + * @return array + */ public function httpSafeMethodProvider() { return [ @@ -388,6 +397,9 @@ public function httpSafeMethodProvider() ]; } + /** + * @return array + */ public function httpNotSafeMethodProvider() { return [ @@ -400,6 +412,9 @@ public function httpNotSafeMethodProvider() ]; } + /** + * @return array + */ public function isSecureDataProvider() { /** @@ -442,6 +457,9 @@ public function testSetPathInfo($requestUri, $basePath, $expected) $this->assertEquals($expected, $this->_model->getPathInfo()); } + /** + * @return array + */ public function setPathInfoDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Router/ActionListTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Router/ActionListTest.php index 0bdbcccc40b35..e1a2171d2111a 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Router/ActionListTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Router/ActionListTest.php @@ -93,6 +93,9 @@ public function testGet($module, $area, $namespace, $action, $data, $expected) $this->assertEquals($expected, $this->actionList->get($module, $area, $namespace, $action)); } + /** + * @return array + */ public function getDataProvider() { $mockClassName = 'Mock_Action_Class'; diff --git a/lib/internal/Magento/Framework/App/Test/Unit/ScopeResolverPoolTest.php b/lib/internal/Magento/Framework/App/Test/Unit/ScopeResolverPoolTest.php index 7a54cf17a87e4..0b7e0e00a2df8 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/ScopeResolverPoolTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/ScopeResolverPoolTest.php @@ -49,6 +49,9 @@ public function testGetException($scope) $scopeResolver->get($scope); } + /** + * @return array + */ public function testGetExceptionDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/App/Test/Unit/SetupInfoTest.php b/lib/internal/Magento/Framework/App/Test/Unit/SetupInfoTest.php index 3db75f7ec7fb2..ae8a76f7bbc1f 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/SetupInfoTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/SetupInfoTest.php @@ -29,6 +29,9 @@ public function testConstructorExceptions($server, $expectedError) new SetupInfo($server); } + /** + * @return array + */ public function constructorExceptionsDataProvider() { $docRootErr = 'DOCUMENT_ROOT variable is unavailable.'; diff --git a/lib/internal/Magento/Framework/App/Test/Unit/StateTest.php b/lib/internal/Magento/Framework/App/Test/Unit/StateTest.php index 46eec1e692424..a87322b6e90d9 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/StateTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/StateTest.php @@ -87,6 +87,10 @@ public function testEmulateAreaCode() $this->assertEquals($this->model->getAreaCode(), $areaCode); } + /** + * @return string + * @throws \Magento\Framework\Exception\LocalizedException + */ public function emulateAreaCodeCallback() { return $this->model->getAreaCode(); diff --git a/lib/internal/Magento/Framework/Cache/Test/Unit/Backend/Decorator/CompressionTest.php b/lib/internal/Magento/Framework/Cache/Test/Unit/Backend/Decorator/CompressionTest.php index 172d0e486dc64..cbb7ed9e5ba6a 100644 --- a/lib/internal/Magento/Framework/Cache/Test/Unit/Backend/Decorator/CompressionTest.php +++ b/lib/internal/Magento/Framework/Cache/Test/Unit/Backend/Decorator/CompressionTest.php @@ -129,12 +129,23 @@ public function testSaveLoad() $this->assertEquals($this->_testString, $loadedValue); } + /** + * @param $data + * @param $cacheId + * + * @return bool + */ public static function mockSave($data, $cacheId) { self::$_cacheStorage[$cacheId] = $data; return true; } + /** + * @param $cacheId + * + * @return bool|mixed + */ public static function mockLoad($cacheId) { return array_key_exists($cacheId, self::$_cacheStorage) ? self::$_cacheStorage[$cacheId] : false; diff --git a/lib/internal/Magento/Framework/Cache/Test/Unit/Backend/Decorator/DecoratorAbstractTest.php b/lib/internal/Magento/Framework/Cache/Test/Unit/Backend/Decorator/DecoratorAbstractTest.php index 7a3aec7b66488..ba75b7eed52ca 100644 --- a/lib/internal/Magento/Framework/Cache/Test/Unit/Backend/Decorator/DecoratorAbstractTest.php +++ b/lib/internal/Magento/Framework/Cache/Test/Unit/Backend/Decorator/DecoratorAbstractTest.php @@ -63,6 +63,9 @@ public function testConstructorException($options) $this->getMockForAbstractClass(\Magento\Framework\Cache\Backend\Decorator\AbstractDecorator::class, [$options]); } + /** + * @return array + */ public function constructorExceptionDataProvider() { return [ @@ -86,6 +89,9 @@ public function testAllMethods($methodName) call_user_func([$decorator, $methodName], null, null); } + /** + * @return array + */ public function allMethodsDataProvider() { $return = []; diff --git a/lib/internal/Magento/Framework/Cache/Test/Unit/Backend/MongoDbTest.php b/lib/internal/Magento/Framework/Cache/Test/Unit/Backend/MongoDbTest.php index daa3081a07c35..435fc6535c1a2 100644 --- a/lib/internal/Magento/Framework/Cache/Test/Unit/Backend/MongoDbTest.php +++ b/lib/internal/Magento/Framework/Cache/Test/Unit/Backend/MongoDbTest.php @@ -45,6 +45,9 @@ public function testGetIds(array $ids, array $expected) $this->assertEquals($expected, $actual); } + /** + * @return array + */ public function getIdsDataProvider() { return [ @@ -64,6 +67,9 @@ public function testGetTags(array $tags) $this->assertEquals($tags, $actual); } + /** + * @return array + */ public function getTagsDataProvider() { return ['no tags' => [[]], 'multiple tags' => [['tag1', 'tag2']]]; @@ -92,6 +98,9 @@ public function testGetIdsMatchingTags($method, $tags, $expectedInput) $this->assertEquals($expectedIds, $actualIds); } + /** + * @return array + */ public function getIdsMatchingTagsDataProvider() { return [ @@ -170,6 +179,9 @@ public function testGetMetadatas($cacheId, $expectedInput, $mongoOutput, $expect $this->assertEquals($expected, $actual); } + /** + * @return array + */ public function getMetadatasDataProvider() { $time = time(); @@ -237,6 +249,9 @@ public function testLoad($doNotTestValidity) $this->assertSame($expected, $actual); } + /** + * @return array + */ public function loadDataProvider() { return ['test validity' => [false], 'do not test validity' => [true]]; @@ -322,6 +337,9 @@ public function testClean($mode, $tags, $expectedQuery) $this->_model->clean($mode, $tags); } + /** + * @return array + */ public function cleanDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Cache/Test/Unit/CoreTest.php b/lib/internal/Magento/Framework/Cache/Test/Unit/CoreTest.php index 616c55f600e9e..4b634ae18c7af 100644 --- a/lib/internal/Magento/Framework/Cache/Test/Unit/CoreTest.php +++ b/lib/internal/Magento/Framework/Cache/Test/Unit/CoreTest.php @@ -61,6 +61,9 @@ public function testSetBackendException($decorators) $core->setBackend($this->_mockBackend); } + /** + * @return array + */ public function setBackendExceptionProvider() { return [ diff --git a/lib/internal/Magento/Framework/Cache/Test/Unit/Frontend/Adapter/ZendTest.php b/lib/internal/Magento/Framework/Cache/Test/Unit/Frontend/Adapter/ZendTest.php index cf16c93cd499a..fb646c7f87622 100644 --- a/lib/internal/Magento/Framework/Cache/Test/Unit/Frontend/Adapter/ZendTest.php +++ b/lib/internal/Magento/Framework/Cache/Test/Unit/Frontend/Adapter/ZendTest.php @@ -93,6 +93,9 @@ public function testCleanException($cleaningMode, $expectedErrorMessage) $object->clean($cleaningMode); } + /** + * @return array + */ public function cleanExceptionDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Cache/Test/Unit/Frontend/Decorator/TagScopeTest.php b/lib/internal/Magento/Framework/Cache/Test/Unit/Frontend/Decorator/TagScopeTest.php index 12774f182d6cd..33105ab52150c 100644 --- a/lib/internal/Magento/Framework/Cache/Test/Unit/Frontend/Decorator/TagScopeTest.php +++ b/lib/internal/Magento/Framework/Cache/Test/Unit/Frontend/Decorator/TagScopeTest.php @@ -128,6 +128,9 @@ public function testCleanModeMatchingAnyTag($fixtureResultOne, $fixtureResultTwo $this->assertEquals($expectedResult, $actualResult); } + /** + * @return array + */ public function cleanModeMatchingAnyTagDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/Generator/DefinedClassesTest.php b/lib/internal/Magento/Framework/Code/Test/Unit/Generator/DefinedClassesTest.php index 658b42e4b972d..eeecc6805ee28 100644 --- a/lib/internal/Magento/Framework/Code/Test/Unit/Generator/DefinedClassesTest.php +++ b/lib/internal/Magento/Framework/Code/Test/Unit/Generator/DefinedClassesTest.php @@ -8,6 +8,11 @@ namespace Magento\Framework\Code\Generator { use Magento\Framework\Code\Test\Unit\Generator\DefinedClassesTest; + /** + * @param $className + * + * @return bool + */ function class_exists($className) { return DefinedClassesTest::$definedClassesTestActive diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/Generator/InterfaceGeneratorTest.php b/lib/internal/Magento/Framework/Code/Test/Unit/Generator/InterfaceGeneratorTest.php index 0f3daa46e1ec3..6462b3806647a 100644 --- a/lib/internal/Magento/Framework/Code/Test/Unit/Generator/InterfaceGeneratorTest.php +++ b/lib/internal/Magento/Framework/Code/Test/Unit/Generator/InterfaceGeneratorTest.php @@ -114,6 +114,9 @@ public function testGeneratePredefinedContentNotSet() $this->assertEquals($expectedContent, $generatedContent, "Generated content is invalid."); } + /** + * @return array + */ public function generateDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/Generator/IoTest.php b/lib/internal/Magento/Framework/Code/Test/Unit/Generator/IoTest.php index 9c63de1258d15..bc2ba24a2f9fe 100644 --- a/lib/internal/Magento/Framework/Code/Test/Unit/Generator/IoTest.php +++ b/lib/internal/Magento/Framework/Code/Test/Unit/Generator/IoTest.php @@ -111,6 +111,9 @@ public function testWriteResultFileAlreadyExists($resultFileName, $fileExists, $ $this->assertSame($success, $this->_object->writeResultFile($resultFileName, self::FILE_CONTENT)); } + /** + * @return array + */ public function testWriteResultFileAlreadyExistsDataProvider() { return [ @@ -202,6 +205,9 @@ public function testFileExists($fileName, $exists) $this->assertSame($exists, $this->_object->fileExists($fileName)); } + /** + * @return array + */ public function fileExistsDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/GeneratorTest.php b/lib/internal/Magento/Framework/Code/Test/Unit/GeneratorTest.php index 3052f682d82cb..c175c0fe9be85 100644 --- a/lib/internal/Magento/Framework/Code/Test/Unit/GeneratorTest.php +++ b/lib/internal/Magento/Framework/Code/Test/Unit/GeneratorTest.php @@ -129,6 +129,9 @@ public function testGenerateClassWithExistName($fileExists) ); } + /** + * @return array + */ public function trueFalseDataProvider() { return [[true], [false]]; diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/NameBuilderTest.php b/lib/internal/Magento/Framework/Code/Test/Unit/NameBuilderTest.php index 588cdfa1d4f7f..b8d49f64569f9 100644 --- a/lib/internal/Magento/Framework/Code/Test/Unit/NameBuilderTest.php +++ b/lib/internal/Magento/Framework/Code/Test/Unit/NameBuilderTest.php @@ -29,6 +29,9 @@ public function testBuildClassName($parts, $expected) $this->assertEquals($expected, $this->nameBuilder->buildClassName($parts)); } + /** + * @return array + */ public function buildClassNameDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/Reader/ArgumentsReaderTest.php b/lib/internal/Magento/Framework/Code/Test/Unit/Reader/ArgumentsReaderTest.php index 64bcb8970612e..e465e01916690 100644 --- a/lib/internal/Magento/Framework/Code/Test/Unit/Reader/ArgumentsReaderTest.php +++ b/lib/internal/Magento/Framework/Code/Test/Unit/Reader/ArgumentsReaderTest.php @@ -263,6 +263,9 @@ public function testIsCompatibleType($requiredType, $actualType, $expectedResult $this->assertEquals($expectedResult, $actualResult); } + /** + * @return array + */ public function testIsCompatibleTypeDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/Validator/TypeDuplicationTest.php b/lib/internal/Magento/Framework/Code/Test/Unit/Validator/TypeDuplicationTest.php index a82c88e3e18b1..b17b10106f8a9 100644 --- a/lib/internal/Magento/Framework/Code/Test/Unit/Validator/TypeDuplicationTest.php +++ b/lib/internal/Magento/Framework/Code/Test/Unit/Validator/TypeDuplicationTest.php @@ -34,6 +34,9 @@ public function testValidClasses($className) $this->assertTrue($this->_validator->validate($className)); } + /** + * @return array + */ public function validClassesDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/Validator/_files/ClassesForArgumentSequence.php b/lib/internal/Magento/Framework/Code/Test/Unit/Validator/_files/ClassesForArgumentSequence.php index 98de5aefba7ef..947ff0b435418 100644 --- a/lib/internal/Magento/Framework/Code/Test/Unit/Validator/_files/ClassesForArgumentSequence.php +++ b/lib/internal/Magento/Framework/Code/Test/Unit/Validator/_files/ClassesForArgumentSequence.php @@ -40,6 +40,16 @@ class ParentClass protected $parentOptionalScalar; + /** + * ParentClass constructor. + * + * @param ContextObject $contextObject + * @param ParentRequiredObject $parentRequiredObject + * @param array $parentRequiredScalar + * @param ParentOptionalObject|null $parentOptionalObject + * @param array $data + * @param array $parentOptionalScalar + */ public function __construct( ContextObject $contextObject, ParentRequiredObject $parentRequiredObject, diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/Validator/_files/ClassesForConstructorIntegrity.php b/lib/internal/Magento/Framework/Code/Test/Unit/Validator/_files/ClassesForConstructorIntegrity.php index 3912a3e1cc5dd..6773d599f7fc7 100644 --- a/lib/internal/Magento/Framework/Code/Test/Unit/Validator/_files/ClassesForConstructorIntegrity.php +++ b/lib/internal/Magento/Framework/Code/Test/Unit/Validator/_files/ClassesForConstructorIntegrity.php @@ -57,6 +57,15 @@ class Context implements \Magento\Framework\ObjectManager\ContextInterface */ protected $_implOfBInterface; + /** + * Context constructor. + * + * @param ClassA $exA + * @param ClassB $exB + * @param ClassC $exC + * @param FirstInterface $interfaceA + * @param ImplementationOfSecondInterface $implOfBInterface + */ public function __construct( \ClassA $exA, \ClassB $exB, diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/_files/app/code/Magento/SomeModule/Model/Five/Test.php b/lib/internal/Magento/Framework/Code/Test/Unit/_files/app/code/Magento/SomeModule/Model/Five/Test.php index 8a9d9866126bf..0aa100fda0caf 100644 --- a/lib/internal/Magento/Framework/Code/Test/Unit/_files/app/code/Magento/SomeModule/Model/Five/Test.php +++ b/lib/internal/Magento/Framework/Code/Test/Unit/_files/app/code/Magento/SomeModule/Model/Five/Test.php @@ -14,6 +14,11 @@ class Test extends \Magento\SomeModule\Model\Three\Test */ protected $_proxy; + /** + * Test constructor. + * + * @param \Magento\SomeModule\Model\Proxy $proxy + */ public function __construct(\Magento\SomeModule\Model\Proxy $proxy) { parent::__construct($proxy); diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/_files/app/code/Magento/SomeModule/Model/Four/Test.php b/lib/internal/Magento/Framework/Code/Test/Unit/_files/app/code/Magento/SomeModule/Model/Four/Test.php index 4701e76f08c59..85133aa4ad851 100644 --- a/lib/internal/Magento/Framework/Code/Test/Unit/_files/app/code/Magento/SomeModule/Model/Four/Test.php +++ b/lib/internal/Magento/Framework/Code/Test/Unit/_files/app/code/Magento/SomeModule/Model/Four/Test.php @@ -15,6 +15,12 @@ class Test extends \Magento\SomeModule\Model\One\Test */ protected $_factory; + /** + * Test constructor. + * + * @param \Magento\SomeModule\Model\Proxy $proxy + * @param \Magento\SomeModule\Model\ElementFactory $factory + */ public function __construct( \Magento\SomeModule\Model\Proxy $proxy, \Magento\SomeModule\Model\ElementFactory $factory diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/_files/app/code/Magento/SomeModule/Model/One/Test.php b/lib/internal/Magento/Framework/Code/Test/Unit/_files/app/code/Magento/SomeModule/Model/One/Test.php index 90f5d40ab726d..eeeb557a99a12 100644 --- a/lib/internal/Magento/Framework/Code/Test/Unit/_files/app/code/Magento/SomeModule/Model/One/Test.php +++ b/lib/internal/Magento/Framework/Code/Test/Unit/_files/app/code/Magento/SomeModule/Model/One/Test.php @@ -13,6 +13,11 @@ class Test */ protected $_proxy; + /** + * Test constructor. + * + * @param \Magento\SomeModule\Model\Proxy $proxy + */ public function __construct(\Magento\SomeModule\Model\Proxy $proxy) { $this->_proxy = $proxy; diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/_files/app/code/Magento/SomeModule/Model/SevenInterface.php b/lib/internal/Magento/Framework/Code/Test/Unit/_files/app/code/Magento/SomeModule/Model/SevenInterface.php index 1d7ffa5127f56..efedcb840e973 100644 --- a/lib/internal/Magento/Framework/Code/Test/Unit/_files/app/code/Magento/SomeModule/Model/SevenInterface.php +++ b/lib/internal/Magento/Framework/Code/Test/Unit/_files/app/code/Magento/SomeModule/Model/SevenInterface.php @@ -45,6 +45,9 @@ public static function testMethod1(array &$data = array()); */ public function testMethod2($data = 'test_default', $flag = true); + /** + * @return mixed + */ public function testMethod3(); diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/_files/app/code/Magento/SomeModule/Model/Six/Test.php b/lib/internal/Magento/Framework/Code/Test/Unit/_files/app/code/Magento/SomeModule/Model/Six/Test.php index 0c736710f5c4e..a58d9a0d628bc 100644 --- a/lib/internal/Magento/Framework/Code/Test/Unit/_files/app/code/Magento/SomeModule/Model/Six/Test.php +++ b/lib/internal/Magento/Framework/Code/Test/Unit/_files/app/code/Magento/SomeModule/Model/Six/Test.php @@ -15,6 +15,12 @@ class Test extends \Magento\SomeModule\Model\One\Test */ protected $_factory; + /** + * Test constructor. + * + * @param \Magento\SomeModule\Model\Proxy $proxy + * @param \Magento\SomeModule\Model\ElementFactory $factory + */ public function __construct( \Magento\SomeModule\Model\Proxy $proxy, \Magento\SomeModule\Model\ElementFactory $factory diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/_files/app/code/Magento/SomeModule/Model/Three/Test.php b/lib/internal/Magento/Framework/Code/Test/Unit/_files/app/code/Magento/SomeModule/Model/Three/Test.php index d080034ef978e..5c0013508d00a 100644 --- a/lib/internal/Magento/Framework/Code/Test/Unit/_files/app/code/Magento/SomeModule/Model/Three/Test.php +++ b/lib/internal/Magento/Framework/Code/Test/Unit/_files/app/code/Magento/SomeModule/Model/Three/Test.php @@ -20,6 +20,12 @@ class Test extends \Magento\SomeModule\Model\Two\Test */ protected $_proxy; + /** + * Test constructor. + * + * @param \Magento\SomeModule\Model\Proxy $proxy + * @param \Magento\SomeModule\Model\ElementFactory $factory + */ public function __construct( \Magento\SomeModule\Model\Proxy $proxy, \Magento\SomeModule\Model\ElementFactory $factory diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/_files/app/code/Magento/SomeModule/Model/Two/Test.php b/lib/internal/Magento/Framework/Code/Test/Unit/_files/app/code/Magento/SomeModule/Model/Two/Test.php index dee0b216b7641..9cec10a1cd36f 100644 --- a/lib/internal/Magento/Framework/Code/Test/Unit/_files/app/code/Magento/SomeModule/Model/Two/Test.php +++ b/lib/internal/Magento/Framework/Code/Test/Unit/_files/app/code/Magento/SomeModule/Model/Two/Test.php @@ -14,6 +14,12 @@ class Test extends \Magento\SomeModule\Model\One\Test */ protected $_proxy; + /** + * Test constructor. + * + * @param \Magento\SomeModule\Model\Proxy $proxy + * @param array $data + */ public function __construct(\Magento\SomeModule\Model\Proxy $proxy, $data = []) { $this->_proxy = $proxy; diff --git a/lib/internal/Magento/Framework/Composer/Test/Unit/ComposerInformationTest.php b/lib/internal/Magento/Framework/Composer/Test/Unit/ComposerInformationTest.php index 4ca43591c96ff..74f8c1dcdb875 100644 --- a/lib/internal/Magento/Framework/Composer/Test/Unit/ComposerInformationTest.php +++ b/lib/internal/Magento/Framework/Composer/Test/Unit/ComposerInformationTest.php @@ -92,6 +92,9 @@ public function testIsMagentoRoot($packageName, $expected) $this->assertEquals($expected, $this->composerInformation->isMagentoRoot()); } + /** + * @return array + */ public function isMagentoRootDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Config/Test/Unit/Converter/DomTest.php b/lib/internal/Magento/Framework/Config/Test/Unit/Converter/DomTest.php index 09366c91a73a3..2ef915dc836df 100644 --- a/lib/internal/Magento/Framework/Config/Test/Unit/Converter/DomTest.php +++ b/lib/internal/Magento/Framework/Config/Test/Unit/Converter/DomTest.php @@ -24,6 +24,9 @@ public function testConvert($sourceFile, $resultFile) $this->assertEquals($resultFile, $converterDom->convert($dom)); } + /** + * @return array + */ public function convertDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Config/Test/Unit/Data/ConfigDataTest.php b/lib/internal/Magento/Framework/Config/Test/Unit/Data/ConfigDataTest.php index 619135f9c7038..747560b29dfc1 100644 --- a/lib/internal/Magento/Framework/Config/Test/Unit/Data/ConfigDataTest.php +++ b/lib/internal/Magento/Framework/Config/Test/Unit/Data/ConfigDataTest.php @@ -47,6 +47,9 @@ public function testSetWrongKey($key, $expectedException) $configData->set($key, 'value'); } + /** + * @return array + */ public function setWrongKeyDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Config/Test/Unit/Data/ScopedTest.php b/lib/internal/Magento/Framework/Config/Test/Unit/Data/ScopedTest.php index 380d095d85e64..f8c518d35add7 100644 --- a/lib/internal/Magento/Framework/Config/Test/Unit/Data/ScopedTest.php +++ b/lib/internal/Magento/Framework/Config/Test/Unit/Data/ScopedTest.php @@ -81,6 +81,9 @@ public function testGetConfigByPath($path, $expectedValue, $default) $this->assertEquals($expectedValue, $this->_model->get($path, $default)); } + /** + * @return array + */ public function getConfigByPathDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Config/Test/Unit/Dom/NodePathMatcherTest.php b/lib/internal/Magento/Framework/Config/Test/Unit/Dom/NodePathMatcherTest.php index 94197fe737918..a2fbdce771f94 100644 --- a/lib/internal/Magento/Framework/Config/Test/Unit/Dom/NodePathMatcherTest.php +++ b/lib/internal/Magento/Framework/Config/Test/Unit/Dom/NodePathMatcherTest.php @@ -32,6 +32,9 @@ public function testMatch($pathPattern, $xpathSubject, $expectedResult) $this->assertSame($expectedResult, $actualResult); } + /** + * @return array + */ public function getNodeInfoDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Config/Test/Unit/GenericSchemaLocatorTest.php b/lib/internal/Magento/Framework/Config/Test/Unit/GenericSchemaLocatorTest.php index 77a7f869fb941..27290e1f67e6d 100644 --- a/lib/internal/Magento/Framework/Config/Test/Unit/GenericSchemaLocatorTest.php +++ b/lib/internal/Magento/Framework/Config/Test/Unit/GenericSchemaLocatorTest.php @@ -30,6 +30,14 @@ class GenericSchemaLocatorTest extends \PHPUnit\Framework\TestCase */ private $moduleReaderMock; + /** + * @param ModuleDirReader $reader + * @param $moduleName + * @param $mergeSchema + * @param $perFileSchema + * + * @return GenericSchemaLocator + */ private function createNewSchemaLocatorInstance(ModuleDirReader $reader, $moduleName, $mergeSchema, $perFileSchema) { return new GenericSchemaLocator($reader, $moduleName, $mergeSchema, $perFileSchema); diff --git a/lib/internal/Magento/Framework/Controller/Test/Unit/Result/RedirectTest.php b/lib/internal/Magento/Framework/Controller/Test/Unit/Result/RedirectTest.php index 65e7ee489e84c..881166b3e2218 100644 --- a/lib/internal/Magento/Framework/Controller/Test/Unit/Result/RedirectTest.php +++ b/lib/internal/Magento/Framework/Controller/Test/Unit/Result/RedirectTest.php @@ -75,6 +75,9 @@ public function testSetPath() ); } + /** + * @return array + */ public function httpRedirectResponseStatusCodes() { return [ diff --git a/lib/internal/Magento/Framework/Convert/Test/Unit/XmlTest.php b/lib/internal/Magento/Framework/Convert/Test/Unit/XmlTest.php index 5af254fcdd4dc..4102ece70a1ce 100644 --- a/lib/internal/Magento/Framework/Convert/Test/Unit/XmlTest.php +++ b/lib/internal/Magento/Framework/Convert/Test/Unit/XmlTest.php @@ -31,6 +31,9 @@ public function testXmlToAssoc() ); } + /** + * @return string + */ protected function getXml() { return <<<XML diff --git a/lib/internal/Magento/Framework/DB/Test/Unit/Adapter/Pdo/MysqlTest.php b/lib/internal/Magento/Framework/DB/Test/Unit/Adapter/Pdo/MysqlTest.php index 561d7b66f0483..a95c8fc21f99e 100644 --- a/lib/internal/Magento/Framework/DB/Test/Unit/Adapter/Pdo/MysqlTest.php +++ b/lib/internal/Magento/Framework/DB/Test/Unit/Adapter/Pdo/MysqlTest.php @@ -508,6 +508,9 @@ public function testGetIndexName($name, $fields, $indexType, $expectedName) ); } + /** + * @return array + */ public function getIndexNameDataProvider() { // 65 characters long - will be compressed diff --git a/lib/internal/Magento/Framework/DB/Test/Unit/Ddl/SequenceTest.php b/lib/internal/Magento/Framework/DB/Test/Unit/Ddl/SequenceTest.php index 6410d4258491d..5309a3fd2a426 100644 --- a/lib/internal/Magento/Framework/DB/Test/Unit/Ddl/SequenceTest.php +++ b/lib/internal/Magento/Framework/DB/Test/Unit/Ddl/SequenceTest.php @@ -38,6 +38,9 @@ public function testDropSequence() ); } + /** + * @return array + */ public function createSequenceDdlDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/DB/Test/Unit/ExpressionConverterTest.php b/lib/internal/Magento/Framework/DB/Test/Unit/ExpressionConverterTest.php index 0915abd98d495..19d6ddfb8e527 100644 --- a/lib/internal/Magento/Framework/DB/Test/Unit/ExpressionConverterTest.php +++ b/lib/internal/Magento/Framework/DB/Test/Unit/ExpressionConverterTest.php @@ -22,6 +22,9 @@ public function testShortenEntityName($in, $prefix, $expectedOut) ); } + /** + * @return array + */ public function shortenEntityNameDataProvider() { $length64 = '________________________________________________________________'; diff --git a/lib/internal/Magento/Framework/DB/Test/Unit/Helper/Mysql/FulltextTest.php b/lib/internal/Magento/Framework/DB/Test/Unit/Helper/Mysql/FulltextTest.php index 713f6471ded3c..05ec032e76113 100644 --- a/lib/internal/Magento/Framework/DB/Test/Unit/Helper/Mysql/FulltextTest.php +++ b/lib/internal/Magento/Framework/DB/Test/Unit/Helper/Mysql/FulltextTest.php @@ -64,6 +64,9 @@ public function testMatch($isCondition) $this->assertEquals($select, $result); } + /** + * @return array + */ public function matchProvider() { return [[true], [false]]; diff --git a/lib/internal/Magento/Framework/DB/Test/Unit/Select/ColumnsRendererTest.php b/lib/internal/Magento/Framework/DB/Test/Unit/Select/ColumnsRendererTest.php index 143ee42ebfa51..889ca58f9229d 100644 --- a/lib/internal/Magento/Framework/DB/Test/Unit/Select/ColumnsRendererTest.php +++ b/lib/internal/Magento/Framework/DB/Test/Unit/Select/ColumnsRendererTest.php @@ -77,6 +77,9 @@ public function testRender($columns, $sql, $expectedResult) $this->assertEquals($expectedResult, $this->model->render($this->selectMock, $sql)); } + /** + * @return array + */ public function renderDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Argument/Interpreter/ArrayTypeTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Argument/Interpreter/ArrayTypeTest.php index 20a0b384bad7e..9387ffbfed7a6 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Argument/Interpreter/ArrayTypeTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Argument/Interpreter/ArrayTypeTest.php @@ -38,6 +38,9 @@ public function testEvaluateException($inputData) $this->_model->evaluate($inputData); } + /** + * @return array + */ public function evaluateExceptionDataProvider() { return [ @@ -62,6 +65,9 @@ public function testEvaluate(array $input, array $expected) $this->assertSame($expected, $actual); } + /** + * @return array + */ public function evaluateDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Argument/Interpreter/CompositeTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Argument/Interpreter/CompositeTest.php index bca8bb0d9347f..37d840b40ca47 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Argument/Interpreter/CompositeTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Argument/Interpreter/CompositeTest.php @@ -60,6 +60,9 @@ public function testEvaluateWrongDiscriminator($input, $expectedExceptionMessage $this->_model->evaluate($input); } + /** + * @return array + */ public function evaluateWrongDiscriminatorDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Argument/Interpreter/NumberTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Argument/Interpreter/NumberTest.php index bec2a37545e65..8981f5adb2e1a 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Argument/Interpreter/NumberTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Argument/Interpreter/NumberTest.php @@ -30,6 +30,9 @@ public function testEvaluateException($input) $this->_model->evaluate($input); } + /** + * @return array + */ public function evaluateExceptionDataProvider() { return ['no value' => [[]], 'non-numeric value' => [['value' => 'non-numeric']]]; @@ -47,6 +50,9 @@ public function testEvaluate($input, $expected) $this->assertSame($expected, $actual); } + /** + * @return array + */ public function evaluateDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Collection/DbTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Collection/DbTest.php index 5eea3f8790711..63eccb098bf0d 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Collection/DbTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Collection/DbTest.php @@ -296,6 +296,9 @@ public function testPrintLogQueryPrinting($printQuery, $printFlag, $query, $expe $this->collection->printLogQuery($printQuery, false, $query); } + /** + * @return array + */ public function printLogQueryPrintingDataProvider() { return [ @@ -319,6 +322,9 @@ public function testPrintLogQueryLogging($logQuery, $logFlag, $expectedCalls) $this->collection->printLogQuery(false, $logQuery, 'some_query'); } + /** + * @return array + */ public function printLogQueryLoggingDataProvider() { return [ @@ -527,6 +533,9 @@ public function testDistinct($flag, $expectedFlag) $this->collection->distinct($flag); } + /** + * @return array + */ public function distinctDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/DateTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/DateTest.php index a34fdf21f7ab4..793161dfc5cbb 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/DateTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/DateTest.php @@ -80,6 +80,9 @@ public function testGetElementHtmlDateFormat($fieldName) $this->model->getElementHtml(); } + /** + * @return array + */ public function providerGetElementHtmlDateFormat() { return [ @@ -88,6 +91,11 @@ public function providerGetElementHtmlDateFormat() ]; } + /** + * @param $exactly + * + * @return \PHPUnit_Framework_MockObject_MockObject + */ protected function getFormMock($exactly) { $functions = ['getFieldNameSuffix', 'getHtmlIdPrefix', 'getHtmlIdSuffix']; diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Form/FormKey/ValidatorTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Form/FormKey/ValidatorTest.php index 9e23610b97668..8b9de2c63953f 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Form/FormKey/ValidatorTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Form/FormKey/ValidatorTest.php @@ -50,6 +50,9 @@ public function testValidate($formKey, $expected) $this->assertEquals($expected, $this->_model->validate($this->_requestMock)); } + /** + * @return array + */ public function validateDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Encryption/Test/Unit/CryptTest.php b/lib/internal/Magento/Framework/Encryption/Test/Unit/CryptTest.php index 6dc0d4a1d4628..6a65124b15f4c 100644 --- a/lib/internal/Magento/Framework/Encryption/Test/Unit/CryptTest.php +++ b/lib/internal/Magento/Framework/Encryption/Test/Unit/CryptTest.php @@ -30,6 +30,11 @@ protected function setUp() $this->_key = substr(__CLASS__, -32, 32); } + /** + * @param $length + * + * @return bool|string + */ protected function _getRandomString($length) { $result = ''; @@ -64,18 +69,33 @@ protected function _requireCipherInfo() } } + /** + * @param $cipherName + * @param $modeName + * + * @return mixed + */ protected function _getKeySize($cipherName, $modeName) { $this->_requireCipherInfo(); return self::$_cipherInfo[$cipherName][$modeName]['key_size']; } + /** + * @param $cipherName + * @param $modeName + * + * @return mixed + */ protected function _getInitVectorSize($cipherName, $modeName) { $this->_requireCipherInfo(); return self::$_cipherInfo[$cipherName][$modeName]['iv_size']; } + /** + * @return array + */ public function getCipherModeCombinations() { $result = []; @@ -102,6 +122,9 @@ public function testConstructor($cipher, $mode) $this->assertEquals($initVector, $crypt->getInitVector()); } + /** + * @return array + */ public function getConstructorExceptionData() { $result = []; @@ -137,6 +160,9 @@ public function testConstructorDefaults() $this->assertEquals($cryptExpected->getInitVector(), $cryptActual->getInitVector()); } + /** + * @return mixed + */ public function getCryptData() { $fixturesFilename = __DIR__ . '/Crypt/_files/_crypt_fixtures.php'; diff --git a/lib/internal/Magento/Framework/Encryption/Test/Unit/EncryptorTest.php b/lib/internal/Magento/Framework/Encryption/Test/Unit/EncryptorTest.php index 52a7a98eac312..f4381a42775d7 100644 --- a/lib/internal/Magento/Framework/Encryption/Test/Unit/EncryptorTest.php +++ b/lib/internal/Magento/Framework/Encryption/Test/Unit/EncryptorTest.php @@ -86,6 +86,9 @@ public function testValidateHash($password, $hash, $expected) $this->assertEquals($expected, $actual); } + /** + * @return array + */ public function validateHashDataProvider() { return [ @@ -112,6 +115,9 @@ public function testEncryptWithEmptyKey($key) $this->assertEquals($value, $model->encrypt($value)); } + /** + * @return array + */ public function encryptWithEmptyKeyDataProvider() { return [[null], [0], [''], ['0']]; @@ -134,6 +140,9 @@ public function testDecryptWithEmptyKey($key) $this->assertEquals('', $model->decrypt($value)); } + /** + * @return array + */ public function decryptWithEmptyKeyDataProvider() { return [[null], [0], [''], ['0']]; @@ -208,6 +217,9 @@ public function testValidateKey() $this->assertEquals($crypt->decrypt($expectedEncryptedData), $actual->decrypt($actualEncryptedData)); } + /** + * @return array + */ public function testUseSpecifiedHashingAlgoDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Encryption/Test/Unit/Helper/SecurityTest.php b/lib/internal/Magento/Framework/Encryption/Test/Unit/Helper/SecurityTest.php index a0406cd0ec84b..fc241834c7ecf 100644 --- a/lib/internal/Magento/Framework/Encryption/Test/Unit/Helper/SecurityTest.php +++ b/lib/internal/Magento/Framework/Encryption/Test/Unit/Helper/SecurityTest.php @@ -31,6 +31,9 @@ public function testCompareStrings($expected, $actual, $result) $this->assertEquals($result, Security::compareStrings($expected, $actual)); } + /** + * @return array + */ public function dataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Event/Test/Unit/Observer/CollectionTest.php b/lib/internal/Magento/Framework/Event/Test/Unit/Observer/CollectionTest.php index 91c8afaef5d07..136dd8cc80eef 100644 --- a/lib/internal/Magento/Framework/Event/Test/Unit/Observer/CollectionTest.php +++ b/lib/internal/Magento/Framework/Event/Test/Unit/Observer/CollectionTest.php @@ -81,6 +81,9 @@ public function testGetObserverByName($name) $this->assertEquals($observer, $this->observerCollection->getObserverByName($name)); } + /** + * @return array + */ public function observerNameProvider() { return [ diff --git a/lib/internal/Magento/Framework/Event/Test/Unit/Observer/CronTest.php b/lib/internal/Magento/Framework/Event/Test/Unit/Observer/CronTest.php index 511d547ebed44..1380cc0decf39 100644 --- a/lib/internal/Magento/Framework/Event/Test/Unit/Observer/CronTest.php +++ b/lib/internal/Magento/Framework/Event/Test/Unit/Observer/CronTest.php @@ -37,6 +37,9 @@ public function testGetNumeric($value, $expectedResult) $this->assertEquals($expectedResult, $this->cron->getNumeric($value)); } + /** + * @return array + */ public function numericValueProvider() { return [ @@ -78,6 +81,9 @@ public function testMatchCronExpression($expression, $number, $expectedResult) $this->assertEquals($expectedResult, $this->cron->matchCronExpression($expression, $number)); } + /** + * @return array + */ public function matchCronExpressionProvider() { return [ @@ -107,6 +113,9 @@ public function testIsValidFor($time, $expression, $expectedResult) $this->assertEquals($expectedResult, $this->cron->isValidFor($eventMock)); } + /** + * @return array + */ public function isValidForProvider() { return [ diff --git a/lib/internal/Magento/Framework/Event/Test/Unit/Observer/RegexTest.php b/lib/internal/Magento/Framework/Event/Test/Unit/Observer/RegexTest.php index cfd3602fb030d..80d828930d118 100644 --- a/lib/internal/Magento/Framework/Event/Test/Unit/Observer/RegexTest.php +++ b/lib/internal/Magento/Framework/Event/Test/Unit/Observer/RegexTest.php @@ -44,6 +44,9 @@ public function testIsValidFor($pattern, $name, $expectedResult) $this->assertEquals($expectedResult, $this->regex->isValidFor($eventMock)); } + /** + * @return array + */ public function isValidForProvider() { return [ diff --git a/lib/internal/Magento/Framework/Filesystem/Test/Unit/Driver/FileTest.php b/lib/internal/Magento/Framework/Filesystem/Test/Unit/Driver/FileTest.php index 97a3b8f498491..5d1f9664bde61 100644 --- a/lib/internal/Magento/Framework/Filesystem/Test/Unit/Driver/FileTest.php +++ b/lib/internal/Magento/Framework/Filesystem/Test/Unit/Driver/FileTest.php @@ -31,6 +31,9 @@ public function testGetAbsolutePath($basePath, $path, $expected) $this->assertEquals($expected, $file->getAbsolutePath($basePath, $path)); } + /** + * @return array + */ public function dataProviderForTestGetAbsolutePath() { return [ @@ -50,6 +53,9 @@ public function testGetRelativePath($basePath, $path, $expected) $this->assertEquals($expected, $file->getRelativePath($basePath, $path)); } + /** + * @return array + */ public function dataProviderForTestGetRelativePath() { return [ diff --git a/lib/internal/Magento/Framework/Filesystem/Test/Unit/Driver/HttpTest.php b/lib/internal/Magento/Framework/Filesystem/Test/Unit/Driver/HttpTest.php index 51a994dc73ff5..dabbae8974905 100644 --- a/lib/internal/Magento/Framework/Filesystem/Test/Unit/Driver/HttpTest.php +++ b/lib/internal/Magento/Framework/Filesystem/Test/Unit/Driver/HttpTest.php @@ -40,6 +40,9 @@ public function testIsExists($status, $result) $this->assertEquals($result, (new Http())->isExists('')); } + /** + * @return array + */ public function dataProviderForTestIsExists() { return [['200 OK', true], ['404 Not Found', false]]; @@ -54,6 +57,9 @@ public function testStat($headers, $result) $this->assertEquals($result, (new Http())->stat('')); } + /** + * @return array + */ public function dataProviderForTestStat() { $headers1 = [ diff --git a/lib/internal/Magento/Framework/Filesystem/Test/Unit/File/ExcludeFilterTest.php b/lib/internal/Magento/Framework/Filesystem/Test/Unit/File/ExcludeFilterTest.php index 07524f9c3595f..8dcb4befa6cac 100644 --- a/lib/internal/Magento/Framework/Filesystem/Test/Unit/File/ExcludeFilterTest.php +++ b/lib/internal/Magento/Framework/Filesystem/Test/Unit/File/ExcludeFilterTest.php @@ -39,6 +39,9 @@ public function testExclusion() $this->assertTrue(!in_array(BP . '/var/session/', $result), 'Filtered path should not be in array'); } + /** + * @return \Generator + */ private function getFilesIterator() { $files = [ diff --git a/lib/internal/Magento/Framework/Filter/Test/Unit/Input/MaliciousCodeTest.php b/lib/internal/Magento/Framework/Filter/Test/Unit/Input/MaliciousCodeTest.php index a8cf48eef433f..7c1ae92b10fc2 100644 --- a/lib/internal/Magento/Framework/Filter/Test/Unit/Input/MaliciousCodeTest.php +++ b/lib/internal/Magento/Framework/Filter/Test/Unit/Input/MaliciousCodeTest.php @@ -33,6 +33,9 @@ public function testFilter($input, $expectedOutput) ); } + /** + * @return array + */ public function filterDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Filter/Test/Unit/Template/Tokenizer/ParameterTest.php b/lib/internal/Magento/Framework/Filter/Test/Unit/Template/Tokenizer/ParameterTest.php index 126d3f9f2f691..fdce369ba2946 100644 --- a/lib/internal/Magento/Framework/Filter/Test/Unit/Template/Tokenizer/ParameterTest.php +++ b/lib/internal/Magento/Framework/Filter/Test/Unit/Template/Tokenizer/ParameterTest.php @@ -41,6 +41,9 @@ public function testGetValue($string, $expectedValue) $this->assertEquals($expectedValue, $this->_filter->getValue()); } + /** + * @return array + */ public function sampleTokenizeStringProvider() { return [ @@ -51,6 +54,9 @@ public function sampleTokenizeStringProvider() ]; } + /** + * @return array + */ public function sampleGetValueStringProvider() { return [ diff --git a/lib/internal/Magento/Framework/Filter/Test/Unit/Template/Tokenizer/VariableTest.php b/lib/internal/Magento/Framework/Filter/Test/Unit/Template/Tokenizer/VariableTest.php index 793637203bb0d..4dad75a6bcb5b 100644 --- a/lib/internal/Magento/Framework/Filter/Test/Unit/Template/Tokenizer/VariableTest.php +++ b/lib/internal/Magento/Framework/Filter/Test/Unit/Template/Tokenizer/VariableTest.php @@ -30,6 +30,9 @@ public function testTokenize($string, $expectedValue) $this->assertEquals($expectedValue, $this->_filter->tokenize()); } + /** + * @return array + */ public function sampleTokenizeStringProvider() { return [ diff --git a/lib/internal/Magento/Framework/Filter/Test/Unit/TemplateTest.php b/lib/internal/Magento/Framework/Filter/Test/Unit/TemplateTest.php index 14d84707fb0b4..e7376d9b7d264 100644 --- a/lib/internal/Magento/Framework/Filter/Test/Unit/TemplateTest.php +++ b/lib/internal/Magento/Framework/Filter/Test/Unit/TemplateTest.php @@ -138,6 +138,9 @@ public function testVarDirective($construction, $variables, $expectedResult) $this->assertEquals($expectedResult, $this->templateFilter->filter($construction)); } + /** + * @return array + */ public function varDirectiveDataProvider() { /* @var $dataObjectVariable \Magento\Framework\DataObject|\PHPUnit_Framework_MockObject_MockObject */ diff --git a/lib/internal/Magento/Framework/HTTP/Test/Unit/Adapter/CurlTest.php b/lib/internal/Magento/Framework/HTTP/Test/Unit/Adapter/CurlTest.php index 8fd28e8513d0b..852badb16d219 100644 --- a/lib/internal/Magento/Framework/HTTP/Test/Unit/Adapter/CurlTest.php +++ b/lib/internal/Magento/Framework/HTTP/Test/Unit/Adapter/CurlTest.php @@ -38,6 +38,9 @@ public function testRead($response) $this->assertEquals(file_get_contents(__DIR__ . '/_files/curl_response_expected.txt'), $this->model->read()); } + /** + * @return array + */ public function readDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/HTTP/Test/Unit/PhpEnvironment/RequestTest.php b/lib/internal/Magento/Framework/HTTP/Test/Unit/PhpEnvironment/RequestTest.php index a746b61ad0038..88cc505fbea8e 100644 --- a/lib/internal/Magento/Framework/HTTP/Test/Unit/PhpEnvironment/RequestTest.php +++ b/lib/internal/Magento/Framework/HTTP/Test/Unit/PhpEnvironment/RequestTest.php @@ -50,6 +50,11 @@ public function tearDown() $_SERVER = $this->serverArray; } + /** + * @param null $uri + * + * @return Request + */ private function getModel($uri = null) { return new Request($this->cookieReader, $this->converter, $uri); diff --git a/lib/internal/Magento/Framework/Image/Test/Unit/Adapter/AbstractTest.php b/lib/internal/Magento/Framework/Image/Test/Unit/Adapter/AbstractTest.php index d8e48f278f782..838d85c5fbf20 100644 --- a/lib/internal/Magento/Framework/Image/Test/Unit/Adapter/AbstractTest.php +++ b/lib/internal/Magento/Framework/Image/Test/Unit/Adapter/AbstractTest.php @@ -109,6 +109,9 @@ public function testPrepareDestination($destination, $newName, $expectedResult) $this->assertEquals($expectedResult, $result); } + /** + * @return array + */ public function prepareDestinationDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Image/Test/Unit/Adapter/Gd2Test.php b/lib/internal/Magento/Framework/Image/Test/Unit/Adapter/Gd2Test.php index fe0847f7f69b4..41281c96e1bb4 100644 --- a/lib/internal/Magento/Framework/Image/Test/Unit/Adapter/Gd2Test.php +++ b/lib/internal/Magento/Framework/Image/Test/Unit/Adapter/Gd2Test.php @@ -73,6 +73,9 @@ public function testOpen($fileData, $exception, $limit) $this->adapter->open('file'); } + /** + * @return array + */ public function filesProvider() { $smallFile = [ diff --git a/lib/internal/Magento/Framework/Indexer/Test/Unit/IndexStructureTest.php b/lib/internal/Magento/Framework/Indexer/Test/Unit/IndexStructureTest.php index c68af718473a4..984b09f9a27ab 100644 --- a/lib/internal/Magento/Framework/Indexer/Test/Unit/IndexStructureTest.php +++ b/lib/internal/Magento/Framework/Indexer/Test/Unit/IndexStructureTest.php @@ -186,6 +186,13 @@ private function createDimensionMock($name, $value) return $dimension; } + /** + * @param $callNumber + * @param $tableName + * @param $isTableExist + * + * @return mixed + */ private function mockDropTable($callNumber, $tableName, $isTableExist) { $this->connectionInterface->expects($this->at($callNumber++)) @@ -201,6 +208,12 @@ private function mockDropTable($callNumber, $tableName, $isTableExist) return $callNumber; } + /** + * @param $callNumber + * @param $tableName + * + * @return mixed + */ private function mockFlatTable($callNumber, $tableName) { $table = $this->getMockBuilder(\Magento\Framework\DB\Ddl\Table::class) @@ -223,6 +236,12 @@ private function mockFlatTable($callNumber, $tableName) return $callNumber; } + /** + * @param $callNumber + * @param $tableName + * + * @return mixed + */ private function mockFulltextTable($callNumber, $tableName) { $table = $this->getMockBuilder(\Magento\Framework\DB\Ddl\Table::class) diff --git a/lib/internal/Magento/Framework/Interception/Test/Unit/Code/Generator/_files/Sample.php b/lib/internal/Magento/Framework/Interception/Test/Unit/Code/Generator/_files/Sample.php index 46d9bee5844a7..107f83ad6f378 100644 --- a/lib/internal/Magento/Framework/Interception/Test/Unit/Code/Generator/_files/Sample.php +++ b/lib/internal/Magento/Framework/Interception/Test/Unit/Code/Generator/_files/Sample.php @@ -14,6 +14,9 @@ public function getValue() return $this->attribute; } + /** + * @param $value + */ public function setValue($value) { $this->attribute = $value; diff --git a/lib/internal/Magento/Framework/Interception/Test/Unit/Code/Generator/_files/TSample.php b/lib/internal/Magento/Framework/Interception/Test/Unit/Code/Generator/_files/TSample.php index f751424e59103..5827c1a1b9e13 100644 --- a/lib/internal/Magento/Framework/Interception/Test/Unit/Code/Generator/_files/TSample.php +++ b/lib/internal/Magento/Framework/Interception/Test/Unit/Code/Generator/_files/TSample.php @@ -9,11 +9,17 @@ class TSample { private $value; + /** + * @return string + */ public function getValue() : string { return $this->value; } + /** + * @param string $value + */ public function setValue(string $value) { $this->value = $value; diff --git a/lib/internal/Magento/Framework/Interception/Test/Unit/Config/ConfigTest.php b/lib/internal/Magento/Framework/Interception/Test/Unit/Config/ConfigTest.php index 54dfa8a03b28c..fe8d29bd0d51d 100644 --- a/lib/internal/Magento/Framework/Interception/Test/Unit/Config/ConfigTest.php +++ b/lib/internal/Magento/Framework/Interception/Test/Unit/Config/ConfigTest.php @@ -209,6 +209,9 @@ public function testHasPluginsWhenDataIsCached($expectedResult, $type) $this->assertEquals($expectedResult, $model->hasPlugins($type)); } + /** + * @return array + */ public function hasPluginsDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Lock/Backend/Database.php b/lib/internal/Magento/Framework/Lock/Backend/Database.php index 6d1bf07b5b331..61857685a7bb4 100644 --- a/lib/internal/Magento/Framework/Lock/Backend/Database.php +++ b/lib/internal/Magento/Framework/Lock/Backend/Database.php @@ -28,6 +28,13 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface /** @var string|false Holds current lock name if set, otherwise false */ private $currentLock = false; + /** + * Database constructor. + * + * @param ResourceConnection $resource + * @param DeploymentConfig $deploymentConfig + * @param string|null $prefix + */ public function __construct( ResourceConnection $resource, DeploymentConfig $deploymentConfig, diff --git a/lib/internal/Magento/Framework/Math/Test/Unit/RandomTest.php b/lib/internal/Magento/Framework/Math/Test/Unit/RandomTest.php index cd7f52f95a850..1dcdb0e9ae65d 100644 --- a/lib/internal/Magento/Framework/Math/Test/Unit/RandomTest.php +++ b/lib/internal/Magento/Framework/Math/Test/Unit/RandomTest.php @@ -26,6 +26,9 @@ public function testGetRandomString($length, $chars = null) } } + /** + * @return array + */ public function getRandomStringDataProvider() { return [ @@ -77,6 +80,9 @@ public function testGetRandomNumber($min, $max) $this->assertGreaterThanOrEqual($min, $number); } + /** + * @return array + */ public function testGetRandomNumberProvider() { return [ diff --git a/lib/internal/Magento/Framework/Message/Test/Unit/ManagerTest.php b/lib/internal/Magento/Framework/Message/Test/Unit/ManagerTest.php index f2b496b157c54..ea86985f057bf 100644 --- a/lib/internal/Magento/Framework/Message/Test/Unit/ManagerTest.php +++ b/lib/internal/Magento/Framework/Message/Test/Unit/ManagerTest.php @@ -308,6 +308,9 @@ public function testAddMessage($type, $methodName) $this->assertTrue($this->model->hasMessages()); } + /** + * @return array + */ public function addMessageDataProvider() { return [ @@ -338,6 +341,9 @@ public function testAddUniqueMessagesWhenMessagesImplementMessageInterface($mess $this->model->addUniqueMessages([$messages]); } + /** + * @return array + */ public function addUniqueMessagesWhenMessagesImplementMessageInterfaceDataProvider() { return [ @@ -371,6 +377,9 @@ public function testAddUniqueMessages($messages) $this->model->addUniqueMessages($messages); } + /** + * @return array + */ public function addUniqueMessagesDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/AbstractDbTest.php b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/AbstractDbTest.php index 966c8f9590cd7..8cd2646815551 100644 --- a/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/AbstractDbTest.php +++ b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/AbstractDbTest.php @@ -163,6 +163,9 @@ public function testGetMainTable($tableName, $expectedResult) $this->assertEquals($expectedResult, $this->_model->getMainTable()); } + /** + * @return array + */ public function getTableDataProvider() { return [ @@ -217,6 +220,9 @@ public function testGetChecksum($checksum, $expected) $this->assertEquals($expected, $this->_model->getChecksum($checksum)); } + /** + * @return array + */ public function getChecksumProvider() { return [ @@ -399,6 +405,9 @@ public function testGetDataChanged($getOriginData, $expected) $this->assertEquals($expected, $this->_model->hasDataChanged($abstractModelMock)); } + /** + * @return array + */ public function hasDataChangedDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/Collection/AbstractCollectionTest.php b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/Collection/AbstractCollectionTest.php index bfd9b5a63d21b..147cac47d3829 100644 --- a/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/Collection/AbstractCollectionTest.php +++ b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/Collection/AbstractCollectionTest.php @@ -95,6 +95,9 @@ protected function tearDown() \Magento\Framework\App\ObjectManager::setInstance($objectManagerMock); } + /** + * @return object + */ protected function getUut() { return $this->objectManagerHelper->getObject( @@ -220,6 +223,9 @@ public function testGetSelect($idFieldNameRet, $getPartRet, $expected) $this->assertTrue($this->uut->getSelect() instanceof Select); } + /** + * @return array + */ public function getSelectDataProvider() { $columnMock = $this->createPartialMock(\Zend_Db_Expr::class, ['__toString']); @@ -246,6 +252,9 @@ public function testAddFieldToSelect($field, $alias, $expectedFieldsToSelect) $this->assertTrue($this->uut->wereFieldsToSelectChanged()); } + /** + * @return array + */ public function addFieldToSelectDataProvider() { return [ @@ -265,6 +274,9 @@ public function testAddExpressionFieldToSelect($alias, $expression, $fields, $ex $this->assertTrue($this->uut->addExpressionFieldToSelect($alias, $expression, $fields) instanceof Uut); } + /** + * @return array + */ public function addExpressionFieldToSelectDataProvider() { return [ @@ -289,6 +301,9 @@ public function testRemoveFieldFromSelect( $this->assertEquals($expectedWereFieldsToSelectChanged, $this->uut->wereFieldsToSelectChanged()); } + /** + * @return array + */ public function removeFieldFromSelectDataProvider() { return [ @@ -376,6 +391,9 @@ public function testJoin($table, $cond, $cols, $expected) $this->assertEquals($expected, $this->uut->getJoinedTables()); } + /** + * @return array + */ public function joinDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/Collection/Uut.php b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/Collection/Uut.php index e55dbb3c9c3da..b224dccc83d03 100644 --- a/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/Collection/Uut.php +++ b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/Collection/Uut.php @@ -13,26 +13,41 @@ */ class Uut extends AbstractCollection { + /** + * @return bool + */ public function wereFieldsToSelectChanged() { return $this->_fieldsToSelectChanged; } + /** + * @return array|null + */ public function getFieldsToSelect() { return $this->_fieldsToSelect; } + /** + * @param array $fields + */ public function setFieldsToSelect(array $fields) { $this->_fieldsToSelect = $fields; } + /** + * @param $resource + */ public function setResource($resource) { $this->_resource = $resource; } + /** + * @return array + */ public function getJoinedTables() { return $this->_joinedTables; diff --git a/lib/internal/Magento/Framework/Module/Test/Unit/Declaration/Converter/DomTest.php b/lib/internal/Magento/Framework/Module/Test/Unit/Declaration/Converter/DomTest.php index ec9b41ff1b957..930b1a21cfd26 100644 --- a/lib/internal/Magento/Framework/Module/Test/Unit/Declaration/Converter/DomTest.php +++ b/lib/internal/Magento/Framework/Module/Test/Unit/Declaration/Converter/DomTest.php @@ -42,6 +42,9 @@ public function testConvertWithInvalidDom($xmlString) } } + /** + * @return array + */ public function convertWithInvalidDomDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Module/Test/Unit/Dir/ReverseResolverTest.php b/lib/internal/Magento/Framework/Module/Test/Unit/Dir/ReverseResolverTest.php index f7a20252826ae..eb849fc457ddb 100644 --- a/lib/internal/Magento/Framework/Module/Test/Unit/Dir/ReverseResolverTest.php +++ b/lib/internal/Magento/Framework/Module/Test/Unit/Dir/ReverseResolverTest.php @@ -54,6 +54,9 @@ public function testGetModuleName($path, $expectedResult) $this->assertSame($expectedResult, $this->_model->getModuleName($path)); } + /** + * @return array + */ public function getModuleNameDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Module/Test/Unit/ManagerTest.php b/lib/internal/Magento/Framework/Module/Test/Unit/ManagerTest.php index 44185b52b19a4..12ddfea8c83d1 100644 --- a/lib/internal/Magento/Framework/Module/Test/Unit/ManagerTest.php +++ b/lib/internal/Magento/Framework/Module/Test/Unit/ManagerTest.php @@ -83,6 +83,9 @@ public function testIsOutputEnabledGenericConfigPath($configValue, $expectedResu $this->assertEquals($expectedResult, $this->_model->isOutputEnabled('Module_One')); } + /** + * @return array + */ public function isOutputEnabledGenericConfigPathDataProvider() { return ['output disabled' => [true, false], 'output enabled' => [false, true]]; @@ -103,6 +106,9 @@ public function testIsOutputEnabledCustomConfigPath($configValue, $expectedResul $this->assertEquals($expectedResult, $this->_model->isOutputEnabled('Module_Two')); } + /** + * @return array + */ public function isOutputEnabledCustomConfigPathDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Mview/Test/Unit/View/ChangelogTest.php b/lib/internal/Magento/Framework/Mview/Test/Unit/View/ChangelogTest.php index c91b56560eb75..a7742700acc83 100644 --- a/lib/internal/Magento/Framework/Mview/Test/Unit/View/ChangelogTest.php +++ b/lib/internal/Magento/Framework/Mview/Test/Unit/View/ChangelogTest.php @@ -259,6 +259,10 @@ protected function mockGetTableName() $this->resourceMock->expects($this->once())->method('getTableName')->will($this->returnArgument(0)); } + /** + * @param $changelogTableName + * @param $result + */ protected function mockIsTableExists($changelogTableName, $result) { $this->connectionMock->expects( diff --git a/lib/internal/Magento/Framework/Mview/Test/Unit/ViewTest.php b/lib/internal/Magento/Framework/Mview/Test/Unit/ViewTest.php index 3fd8ea93c9bbe..3f806b319ef48 100644 --- a/lib/internal/Magento/Framework/Mview/Test/Unit/ViewTest.php +++ b/lib/internal/Magento/Framework/Mview/Test/Unit/ViewTest.php @@ -464,6 +464,9 @@ public function testResumeNotSuspended($status) $this->model->resume(); } + /** + * @return array + */ public function dataProviderResumeNotSuspended() { return [ @@ -520,6 +523,9 @@ public function testIsEnabled($mode, $result) $this->assertEquals($result, $this->model->isEnabled()); } + /** + * @return array + */ public function dataProviderIsEnabled() { return [ @@ -541,6 +547,9 @@ public function testIsIdle($status, $result) $this->assertEquals($result, $this->model->isIdle()); } + /** + * @return array + */ public function dataProviderIsIdle() { return [ @@ -563,6 +572,9 @@ public function testIsWorking($status, $result) $this->assertEquals($result, $this->model->isWorking()); } + /** + * @return array + */ public function dataProviderIsWorking() { return [ @@ -585,6 +597,9 @@ public function testIsSuspended($status, $result) $this->assertEquals($result, $this->model->isSuspended()); } + /** + * @return array + */ public function dataProviderIsSuspended() { return [ @@ -617,6 +632,9 @@ protected function loadView() $this->model->load($viewId); } + /** + * @return array + */ protected function getViewData() { return [ diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Code/Generator/RepositoryTest.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Code/Generator/RepositoryTest.php index 1bba19cb16a5a..27ecdff1dcb82 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Code/Generator/RepositoryTest.php +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Code/Generator/RepositoryTest.php @@ -13,21 +13,33 @@ */ class RepositoryTest extends EntityChildTestAbstract { + /** + * @return mixed|string + */ protected function getSourceClassName() { return '\\' . \Magento\Framework\ObjectManager\Code\Generator\Sample::class; } + /** + * @return mixed|string + */ protected function getResultClassName() { return '\\' . \Magento\Framework\ObjectManager\Code\Generator\Sample\Repository::class; } + /** + * @return mixed|string + */ protected function getGeneratorClassName() { return '\\' . \Magento\Framework\ObjectManager\Code\Generator\Repository::class; } + /** + * @return mixed|string + */ protected function getOutputFileName() { return 'SampleConverter.php'; diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Code/Generator/_files/SampleRepositoryInterface.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Code/Generator/_files/SampleRepositoryInterface.php index 0bc899f580071..58e334f0022a7 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Code/Generator/_files/SampleRepositoryInterface.php +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Code/Generator/_files/SampleRepositoryInterface.php @@ -7,11 +7,31 @@ interface SampleRepositoryInterface { + /** + * @param SampleInterface $entity + * + * @return mixed + */ public function save(\Magento\Framework\ObjectManager\Code\Generator\SampleInterface $entity); + /** + * @param $id + * + * @return mixed + */ public function get($id); + /** + * @param $id + * + * @return mixed + */ public function deleteById($id); + /** + * @param SampleInterface $entity + * + * @return mixed + */ public function delete(\Magento\Framework\ObjectManager\Code\Generator\SampleInterface $entity); } diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Code/Generator/_files/TSampleRepositoryInterface.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Code/Generator/_files/TSampleRepositoryInterface.php index 99ab4ecadcd41..b916ab18e2e70 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Code/Generator/_files/TSampleRepositoryInterface.php +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Code/Generator/_files/TSampleRepositoryInterface.php @@ -7,10 +7,25 @@ interface TSampleRepositoryInterface { + /** + * @param int $id + * + * @return TSampleInterface + */ public function get(int $id) : \Magento\Framework\ObjectManager\Code\Generator\TSampleInterface; + /** + * @param TSampleInterface $entity + * + * @return bool + */ public function delete(\Magento\Framework\ObjectManager\Code\Generator\TSampleInterface $entity) : bool; + /** + * @param TSampleInterface $entity + * + * @return TSampleInterface + */ public function save(\Magento\Framework\ObjectManager\Code\Generator\TSampleInterface $entity) : \Magento\Framework\ObjectManager\Code\Generator\TSampleInterface; } diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/Reader/_files/ConfigDomMock.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/Reader/_files/ConfigDomMock.php index 6be8d7ffde874..e885c07b7c298 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/Reader/_files/ConfigDomMock.php +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/Reader/_files/ConfigDomMock.php @@ -32,6 +32,9 @@ public function validate($schemaFile, $errors) return true; } + /** + * @return string + */ public function getDom() { return 'reader dom result'; diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Relations/RuntimeTest.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Relations/RuntimeTest.php index 1c88ab65021c4..0beeeb5e69738 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Relations/RuntimeTest.php +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Relations/RuntimeTest.php @@ -30,6 +30,9 @@ public function testGetParents($type, $parents) $this->assertEquals($parents, $this->model->getParents($type)); } + /** + * @return array + */ public function getParentsDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/_files/Aggregate/AggregateParent.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/_files/Aggregate/AggregateParent.php index 3c494b6abbb94..bee2a7eb6ad98 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/_files/Aggregate/AggregateParent.php +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/_files/Aggregate/AggregateParent.php @@ -17,6 +17,15 @@ class AggregateParent implements \Magento\Test\Di\Aggregate\AggregateInterface public $optionalScalar; + /** + * AggregateParent constructor. + * + * @param \Magento\Test\Di\DiInterface $interface + * @param \Magento\Test\Di\DiParent $parent + * @param \Magento\Test\Di\Child $child + * @param $scalar + * @param int $optionalScalar + */ public function __construct( \Magento\Test\Di\DiInterface $interface, \Magento\Test\Di\DiParent $parent, diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/_files/Aggregate/Child.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/_files/Aggregate/Child.php index b84375e3b5436..3577141ef0284 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/_files/Aggregate/Child.php +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/_files/Aggregate/Child.php @@ -11,6 +11,17 @@ class Child extends \Magento\Test\Di\Aggregate\AggregateParent public $secondOptionalScalar; + /** + * Child constructor. + * + * @param \Magento\Test\Di\DiInterface $interface + * @param \Magento\Test\Di\DiParent $parent + * @param \Magento\Test\Di\Child $child + * @param $scalar + * @param $secondScalar + * @param int $optionalScalar + * @param string $secondOptionalScalar + */ public function __construct( \Magento\Test\Di\DiInterface $interface, \Magento\Test\Di\DiParent $parent, diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/_files/Aggregate/WithOptional.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/_files/Aggregate/WithOptional.php index 1c5ac56e2735c..a68eb2c0fc64f 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/_files/Aggregate/WithOptional.php +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/_files/Aggregate/WithOptional.php @@ -11,6 +11,12 @@ class WithOptional public $child; + /** + * WithOptional constructor. + * + * @param \Magento\Test\Di\DiParent|null $parent + * @param \Magento\Test\Di\Child|null $child + */ public function __construct(\Magento\Test\Di\DiParent $parent = null, \Magento\Test\Di\Child $child = null) { $this->parent = $parent; diff --git a/lib/internal/Magento/Framework/Pricing/Test/Unit/Adjustment/CollectionTest.php b/lib/internal/Magento/Framework/Pricing/Test/Unit/Adjustment/CollectionTest.php index 9c23b38182f91..edcc4a7e56717 100644 --- a/lib/internal/Magento/Framework/Pricing/Test/Unit/Adjustment/CollectionTest.php +++ b/lib/internal/Magento/Framework/Pricing/Test/Unit/Adjustment/CollectionTest.php @@ -79,6 +79,9 @@ public function testGetItems($adjustments, $expectedResult) $this->assertEmpty(array_diff($expectedResult, array_keys($result))); } + /** + * @return array + */ public function getItemsDataProvider() { return [ @@ -104,6 +107,9 @@ public function testGetItemByCode($adjustments, $code, $expectedResult) $this->assertEquals($expectedResult, $item->getAdjustmentCode()); } + /** + * @return array + */ public function getItemByCodeDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Pricing/Test/Unit/Adjustment/PoolTest.php b/lib/internal/Magento/Framework/Pricing/Test/Unit/Adjustment/PoolTest.php index 6fca39b2082fb..adf9ffae16390 100644 --- a/lib/internal/Magento/Framework/Pricing/Test/Unit/Adjustment/PoolTest.php +++ b/lib/internal/Magento/Framework/Pricing/Test/Unit/Adjustment/PoolTest.php @@ -65,6 +65,9 @@ public function testGetAdjustmentByCode($code, $expectedResult) $this->assertEquals($expectedResult, $result); } + /** + * @return array + */ public function getAdjustmentByCodeDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Pricing/Test/Unit/Helper/DataTest.php b/lib/internal/Magento/Framework/Pricing/Test/Unit/Helper/DataTest.php index 2abf26601fbea..42af3268e559b 100644 --- a/lib/internal/Magento/Framework/Pricing/Test/Unit/Helper/DataTest.php +++ b/lib/internal/Magento/Framework/Pricing/Test/Unit/Helper/DataTest.php @@ -50,6 +50,9 @@ public function testCurrency($amount, $format, $includeContainer, $result) $this->assertEquals($result, $helper->currency($amount, $format, $includeContainer)); } + /** + * @return array + */ public function currencyDataProvider() { return [ @@ -84,6 +87,9 @@ public function testCurrencyByStore($amount, $store, $format, $includeContainer, $this->assertEquals($result, $helper->currencyByStore($amount, $store, $format, $includeContainer)); } + /** + * @return array + */ public function currencyByStoreDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Pricing/Test/Unit/PriceInfo/FactoryTest.php b/lib/internal/Magento/Framework/Pricing/Test/Unit/PriceInfo/FactoryTest.php index 5d1ab67e09587..ebe2fb453ca83 100644 --- a/lib/internal/Magento/Framework/Pricing/Test/Unit/PriceInfo/FactoryTest.php +++ b/lib/internal/Magento/Framework/Pricing/Test/Unit/PriceInfo/FactoryTest.php @@ -80,6 +80,9 @@ protected function setUp() $this->factory = new Factory($this->types, $this->objectManagerMock); } + /** + * @return array + */ public function createPriceInfoDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Pricing/Test/Unit/Render/AmountTest.php b/lib/internal/Magento/Framework/Pricing/Test/Unit/Render/AmountTest.php index 009fb8236c4dc..70eef212c6878 100644 --- a/lib/internal/Magento/Framework/Pricing/Test/Unit/Render/AmountTest.php +++ b/lib/internal/Magento/Framework/Pricing/Test/Unit/Render/AmountTest.php @@ -277,6 +277,13 @@ public function testAdjustmentsHtml() $this->assertEquals($adjustmentHtml1 . $adjustmentHtml2, $this->model->getAdjustmentsHtml()); } + /** + * @param array $data + * @param string $html + * @param string $code + * + * @return \PHPUnit_Framework_MockObject_MockObject + */ protected function getAdjustmentRenderMock($data = [], $html = '', $code = 'adjustment_code') { $adjustmentRender = $this->getMockForAbstractClass( diff --git a/lib/internal/Magento/Framework/Pricing/Test/Unit/Render/PriceBoxTest.php b/lib/internal/Magento/Framework/Pricing/Test/Unit/Render/PriceBoxTest.php index 905569936d036..f4588f7d25672 100644 --- a/lib/internal/Magento/Framework/Pricing/Test/Unit/Render/PriceBoxTest.php +++ b/lib/internal/Magento/Framework/Pricing/Test/Unit/Render/PriceBoxTest.php @@ -122,6 +122,9 @@ public function testToHtml($data, $priceCode, $cssClasses) $this->assertEquals($cssClasses, $priceBox->getData('css_classes')); } + /** + * @return array + */ public function toHtmlDataProvider() { return [ @@ -225,6 +228,9 @@ public function testGetPriceId($prefix, $suffix, $defaultPrefix, $defaultSuffix) $this->assertEquals($expectedPriceId, $this->model->getPriceId($defaultPrefix, $defaultSuffix)); } + /** + * @return array + */ public function getPriceIdProvider() { return [ diff --git a/lib/internal/Magento/Framework/Reflection/Test/Unit/DataObjectProcessorTest.php b/lib/internal/Magento/Framework/Reflection/Test/Unit/DataObjectProcessorTest.php index ed26efb5bff64..1977ed3f46456 100644 --- a/lib/internal/Magento/Framework/Reflection/Test/Unit/DataObjectProcessorTest.php +++ b/lib/internal/Magento/Framework/Reflection/Test/Unit/DataObjectProcessorTest.php @@ -86,6 +86,9 @@ public function testBuildOutputDataArray($extensionAttributes, $expectedOutputDa $this->assertEquals($expectedOutputDataArray, $outputData); } + /** + * @return array + */ public function buildOutputDataArrayDataProvider() { $expectedOutputDataArray = [ diff --git a/lib/internal/Magento/Framework/Reflection/Test/Unit/ExtensionAttributesProcessorTest.php b/lib/internal/Magento/Framework/Reflection/Test/Unit/ExtensionAttributesProcessorTest.php index 130c285bd3b08..6aebd99deabb0 100644 --- a/lib/internal/Magento/Framework/Reflection/Test/Unit/ExtensionAttributesProcessorTest.php +++ b/lib/internal/Magento/Framework/Reflection/Test/Unit/ExtensionAttributesProcessorTest.php @@ -154,6 +154,9 @@ public function testBuildOutputDataArrayWithPermission($isPermissionAllowed, $ex ); } + /** + * @return array + */ public function buildOutputDataArrayWithPermissionProvider() { return [ diff --git a/lib/internal/Magento/Framework/Reflection/Test/Unit/TestDataObject.php b/lib/internal/Magento/Framework/Reflection/Test/Unit/TestDataObject.php index 4e40fe6860586..8cc173d6dee2d 100644 --- a/lib/internal/Magento/Framework/Reflection/Test/Unit/TestDataObject.php +++ b/lib/internal/Magento/Framework/Reflection/Test/Unit/TestDataObject.php @@ -9,31 +9,51 @@ class TestDataObject implements TestDataInterface { private $extensionAttributes; + /** + * TestDataObject constructor. + * + * @param null $extensionAttributes + */ public function __construct($extensionAttributes = null) { $this->extensionAttributes = $extensionAttributes; } + /** + * @return string + */ public function getId() { return '1'; } + /** + * @return string + */ public function getAddress() { return 'someAddress'; } + /** + * @return string + */ public function isDefaultShipping() { return 'true'; } + /** + * @return string + */ public function isRequiredBilling() { return 'false'; } + /** + * @return \Magento\Framework\Api\ExtensionAttributesInterface|null + */ public function getExtensionAttributes() { return $this->extensionAttributes; diff --git a/lib/internal/Magento/Framework/Reflection/Test/Unit/TypeProcessorTest.php b/lib/internal/Magento/Framework/Reflection/Test/Unit/TypeProcessorTest.php index 75a31ddcad6fe..999bca8ad3fc4 100644 --- a/lib/internal/Magento/Framework/Reflection/Test/Unit/TypeProcessorTest.php +++ b/lib/internal/Magento/Framework/Reflection/Test/Unit/TypeProcessorTest.php @@ -220,6 +220,9 @@ public function testProcessSimpleTypeException($value, $type) $this->typeProcessor->processSimpleAndAnyType($value, $type); } + /** + * @return array + */ public static function processSimpleTypeExceptionProvider() { return [ diff --git a/lib/internal/Magento/Framework/Search/Test/Unit/Request/MapperTest.php b/lib/internal/Magento/Framework/Search/Test/Unit/Request/MapperTest.php index c5e18423eab07..2a3e46b8887a6 100644 --- a/lib/internal/Magento/Framework/Search/Test/Unit/Request/MapperTest.php +++ b/lib/internal/Magento/Framework/Search/Test/Unit/Request/MapperTest.php @@ -852,6 +852,9 @@ public function testGetFilterException() $this->assertEquals($this->queryBool, $mapper->getRootQuery()); } + /** + * @return array + */ public function getQueryMatchProvider() { return [ @@ -879,6 +882,9 @@ public function getQueryMatchProvider() ]; } + /** + * @return array + */ public function getQueryFilterQueryReferenceProvider() { return [ @@ -926,6 +932,9 @@ public function getQueryFilterQueryReferenceProvider() ]; } + /** + * @return array + */ public function getQueryBoolProvider() { return [ diff --git a/lib/internal/Magento/Framework/Serialize/Test/Unit/Serializer/Base64JsonTest.php b/lib/internal/Magento/Framework/Serialize/Test/Unit/Serializer/Base64JsonTest.php index 8cad058f88466..e93164537f927 100644 --- a/lib/internal/Magento/Framework/Serialize/Test/Unit/Serializer/Base64JsonTest.php +++ b/lib/internal/Magento/Framework/Serialize/Test/Unit/Serializer/Base64JsonTest.php @@ -30,6 +30,9 @@ public function testSerialize($value, $expected) $this->assertEquals($expected, $this->base64json->serialize($value)); } + /** + * @return array + */ public function serializeDataProvider() { $dataObject = new \Magento\Framework\DataObject(['something']); @@ -55,6 +58,9 @@ public function testUnserialize($value, $expected) $this->assertEquals($expected, $this->base64json->unserialize($value)); } + /** + * @return array + */ public function unserializeDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Serialize/Test/Unit/Serializer/JsonTest.php b/lib/internal/Magento/Framework/Serialize/Test/Unit/Serializer/JsonTest.php index d1fddbbdf2778..235567103edf7 100644 --- a/lib/internal/Magento/Framework/Serialize/Test/Unit/Serializer/JsonTest.php +++ b/lib/internal/Magento/Framework/Serialize/Test/Unit/Serializer/JsonTest.php @@ -34,6 +34,9 @@ public function testSerialize($value, $expected) ); } + /** + * @return array + */ public function serializeDataProvider() { $dataObject = new DataObject(['something']); @@ -62,6 +65,9 @@ public function testUnserialize($value, $expected) ); } + /** + * @return array + */ public function unserializeDataProvider() { return [ @@ -95,6 +101,9 @@ public function testUnserializeException($value) $this->json->unserialize($value); } + /** + * @return array + */ public function unserializeExceptionDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Serialize/Test/Unit/Serializer/SerializeTest.php b/lib/internal/Magento/Framework/Serialize/Test/Unit/Serializer/SerializeTest.php index e74de735c1c1e..1f8e7cf9d0bc3 100644 --- a/lib/internal/Magento/Framework/Serialize/Test/Unit/Serializer/SerializeTest.php +++ b/lib/internal/Magento/Framework/Serialize/Test/Unit/Serializer/SerializeTest.php @@ -33,6 +33,9 @@ public function testSerialize($value, $serializedValue) $this->assertEquals($serializedValue, $this->serialize->serialize($value)); } + /** + * @return array + */ public function serializeDataProvider() { return [ @@ -56,6 +59,9 @@ public function testUnserialize($serializedValue, $value) $this->assertEquals($value, $this->serialize->unserialize($serializedValue)); } + /** + * @return array + */ public function unserializeDataProvider() { return [ @@ -88,6 +94,9 @@ public function testUnserializeException($value) $this->serialize->unserialize($value); } + /** + * @return array + */ public function unserializeExceptionDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Session/Test/Unit/ConfigTest.php b/lib/internal/Magento/Framework/Session/Test/Unit/ConfigTest.php index 12e28cdb3970d..3df8f182fe37e 100644 --- a/lib/internal/Magento/Framework/Session/Test/Unit/ConfigTest.php +++ b/lib/internal/Magento/Framework/Session/Test/Unit/ConfigTest.php @@ -82,6 +82,9 @@ public function testSetOptions($option, $getter, $value) $this->assertSame($value, $this->config->{$getter}()); } + /** + * @return array + */ public function optionsProvider() { return [ @@ -343,6 +346,9 @@ public function testConstructor($isValidSame, $isValid, $expected) $this->assertEquals($expected, $this->config->getOptions()); } + /** + * @return array + */ public function constructorDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Session/Test/Unit/SaveHandler/Redis/LoggerTest.php b/lib/internal/Magento/Framework/Session/Test/Unit/SaveHandler/Redis/LoggerTest.php index 18050da435c32..4594a471e008d 100644 --- a/lib/internal/Magento/Framework/Session/Test/Unit/SaveHandler/Redis/LoggerTest.php +++ b/lib/internal/Magento/Framework/Session/Test/Unit/SaveHandler/Redis/LoggerTest.php @@ -70,6 +70,9 @@ public function testLog($logLevel, $method) $this->logger->log($message, $logLevel); } + /** + * @return array + */ public function logDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Shell/Test/Unit/CommandRendererTest.php b/lib/internal/Magento/Framework/Shell/Test/Unit/CommandRendererTest.php index 213e2afa2c655..01964bdced655 100644 --- a/lib/internal/Magento/Framework/Shell/Test/Unit/CommandRendererTest.php +++ b/lib/internal/Magento/Framework/Shell/Test/Unit/CommandRendererTest.php @@ -24,6 +24,9 @@ public function testRender($expectedCommand, $actualCommand, $testArguments) ); } + /** + * @return array + */ public function commandsDataProvider() { $testArgument = 'argument'; diff --git a/lib/internal/Magento/Framework/Simplexml/Test/Unit/ElementTest.php b/lib/internal/Magento/Framework/Simplexml/Test/Unit/ElementTest.php index 2455b8f3cb500..ea2149e6f9e34 100644 --- a/lib/internal/Magento/Framework/Simplexml/Test/Unit/ElementTest.php +++ b/lib/internal/Magento/Framework/Simplexml/Test/Unit/ElementTest.php @@ -108,6 +108,9 @@ public function testSetAttribute($name, $value) $this->assertEquals($xml->getAttribute($name), $value); } + /** + * @return array + */ public function setAttributeDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Stdlib/Test/Unit/BooleanUtilsTest.php b/lib/internal/Magento/Framework/Stdlib/Test/Unit/BooleanUtilsTest.php index 26dcbc81262a2..64eb1e9c4bf39 100644 --- a/lib/internal/Magento/Framework/Stdlib/Test/Unit/BooleanUtilsTest.php +++ b/lib/internal/Magento/Framework/Stdlib/Test/Unit/BooleanUtilsTest.php @@ -38,6 +38,9 @@ public function testToBoolean($input, $expected) $this->assertSame($expected, $actual); } + /** + * @return array + */ public function toBooleanDataProvider() { return [ @@ -64,6 +67,9 @@ public function testToBooleanException($input) $this->object->toBoolean($input); } + /** + * @return array + */ public function toBooleanExceptionDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Stdlib/Test/Unit/Cookie/PhpCookieManagerTest.php b/lib/internal/Magento/Framework/Stdlib/Test/Unit/Cookie/PhpCookieManagerTest.php index f6f6a19c170c8..29e54157ebb22 100644 --- a/lib/internal/Magento/Framework/Stdlib/Test/Unit/Cookie/PhpCookieManagerTest.php +++ b/lib/internal/Magento/Framework/Stdlib/Test/Unit/Cookie/PhpCookieManagerTest.php @@ -274,6 +274,9 @@ public function testSetSensitiveCookieNoMetadata($cookieName, $secure) $this->assertTrue(self::$isSetCookieInvoked); } + /** + * @return array + */ public function isCurrentlySecureDataProvider() { return [ @@ -898,6 +901,11 @@ private static function assertZeroDuration( self::assertEquals('', $path); } + /** + * @param $get + * @param $default + * @param $return + */ protected function stubGetCookie($get, $default, $return) { $this->readerMock->expects($this->atLeastOnce()) diff --git a/lib/internal/Magento/Framework/Stdlib/Test/Unit/Cookie/SensitiveCookieMetadataTest.php b/lib/internal/Magento/Framework/Stdlib/Test/Unit/Cookie/SensitiveCookieMetadataTest.php index 9015968cee85c..d409a89c2cc91 100644 --- a/lib/internal/Magento/Framework/Stdlib/Test/Unit/Cookie/SensitiveCookieMetadataTest.php +++ b/lib/internal/Magento/Framework/Stdlib/Test/Unit/Cookie/SensitiveCookieMetadataTest.php @@ -59,6 +59,9 @@ public function testConstructorAndGetHttpOnly($metadata, $httpOnly) $this->assertEquals('path', $object->getPath()); } + /** + * @return array + */ public function constructorAndGetHttpOnlyTestDataProvider() { return [ @@ -104,6 +107,9 @@ public function testGetSecure($isSecure, $metadata, $expected, $callNum = 1) $this->assertEquals($expected, $object->getSecure()); } + /** + * @return array + */ public function getSecureDataProvider() { return [ @@ -160,6 +166,9 @@ public function testToArray($isSecure, $metadata, $expected, $callNum = 1) $this->assertEquals($expected, $object->__toArray()); } + /** + * @return array + */ public function toArrayDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Test/Unit/ArchiveTest.php b/lib/internal/Magento/Framework/Test/Unit/ArchiveTest.php index 68be50810d44f..d4a19428c61a0 100644 --- a/lib/internal/Magento/Framework/Test/Unit/ArchiveTest.php +++ b/lib/internal/Magento/Framework/Test/Unit/ArchiveTest.php @@ -64,6 +64,9 @@ public function testIsArchive($file, $isArchive) $this->assertEquals($isArchive, $this->archive->isArchive($file)); } + /** + * @return array + */ public function isArchiveProvider() { return [ @@ -98,6 +101,9 @@ public function testIsTar($file, $isArchive) $this->assertEquals($isArchive, $this->archive->isTar($file)); } + /** + * @return array + */ public function isTarProvider() { return [ @@ -143,6 +149,9 @@ public function testPackUnpackGzBz($destinationFile, $extensionRequired) $this->assertStringStartsWith($this->destinationDir, $this->unpacked); } + /** + * @return array + */ public function destinationProvider() { return [ @@ -200,6 +209,9 @@ public function testExtract($destinationFile, $extensionRequired) $this->assertStringStartsWith($this->destinationDir, $this->unpacked); } + /** + * @return array + */ public function tarProvider() { return [ diff --git a/lib/internal/Magento/Framework/Test/Unit/Data/Form/Element/HiddenTest.php b/lib/internal/Magento/Framework/Test/Unit/Data/Form/Element/HiddenTest.php index 0fc537fbe832a..b57cb7ac8f0b2 100644 --- a/lib/internal/Magento/Framework/Test/Unit/Data/Form/Element/HiddenTest.php +++ b/lib/internal/Magento/Framework/Test/Unit/Data/Form/Element/HiddenTest.php @@ -45,6 +45,9 @@ public function testGetElementHtml($value) } } + /** + * @return array + */ public function getElementHtmlDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Test/Unit/DataObjectTest.php b/lib/internal/Magento/Framework/Test/Unit/DataObjectTest.php index d937dc10e4d4c..67a689b714e24 100644 --- a/lib/internal/Magento/Framework/Test/Unit/DataObjectTest.php +++ b/lib/internal/Magento/Framework/Test/Unit/DataObjectTest.php @@ -380,6 +380,9 @@ public function testUnderscore($input, $expectedOutput) $this->assertEquals($expectedOutput, $output); } + /** + * @return array + */ public function underscoreDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Test/Unit/EscaperTest.php b/lib/internal/Magento/Framework/Test/Unit/EscaperTest.php index c728fdecfeaab..ec05478b90db9 100644 --- a/lib/internal/Magento/Framework/Test/Unit/EscaperTest.php +++ b/lib/internal/Magento/Framework/Test/Unit/EscaperTest.php @@ -103,6 +103,9 @@ public function testEscapeJs($data, $expected) $this->assertEquals($expected, $this->escaper->escapeJs($data)); } + /** + * @return array + */ public function escapeJsDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Test/Unit/FlagManagerTest.php b/lib/internal/Magento/Framework/Test/Unit/FlagManagerTest.php index 955f16d4241c2..ea6ddf56414ff 100644 --- a/lib/internal/Magento/Framework/Test/Unit/FlagManagerTest.php +++ b/lib/internal/Magento/Framework/Test/Unit/FlagManagerTest.php @@ -112,6 +112,9 @@ public function testDeleteFlag($isFlagExist) ); } + /** + * @param $flagCode + */ private function setupFlagObject($flagCode) { $this->flagFactoryMock->expects($this->once()) diff --git a/lib/internal/Magento/Framework/Test/Unit/Message/PhraseFactoryTest.php b/lib/internal/Magento/Framework/Test/Unit/Message/PhraseFactoryTest.php index d5243cacb1616..805bd8fe4510a 100644 --- a/lib/internal/Magento/Framework/Test/Unit/Message/PhraseFactoryTest.php +++ b/lib/internal/Magento/Framework/Test/Unit/Message/PhraseFactoryTest.php @@ -33,6 +33,9 @@ public function testCreate($mainMessage, $subMessages, $separator, $expectedResu $this->assertEquals($expectedResult, $result); } + /** + * @return array + */ public function dataProvider() { $subMessage1 = new Error('go jogging'); diff --git a/lib/internal/Magento/Framework/Test/Unit/Module/Plugin/DbStatusValidatorTest.php b/lib/internal/Magento/Framework/Test/Unit/Module/Plugin/DbStatusValidatorTest.php index 1516f65479771..c41918e051452 100644 --- a/lib/internal/Magento/Framework/Test/Unit/Module/Plugin/DbStatusValidatorTest.php +++ b/lib/internal/Magento/Framework/Test/Unit/Module/Plugin/DbStatusValidatorTest.php @@ -119,6 +119,9 @@ public function testBeforeDispatchOutOfDateWithErrors(array $errors, string $exp $this->plugin->beforeDispatch($this->frontControllerMock, $this->requestMock); } + /** + * @return array + */ public static function beforeDispatchOutOfDateWithErrorsDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Test/Unit/ShellTest.php b/lib/internal/Magento/Framework/Test/Unit/ShellTest.php index 913fd883eaad2..9f223f916b97a 100644 --- a/lib/internal/Magento/Framework/Test/Unit/ShellTest.php +++ b/lib/internal/Magento/Framework/Test/Unit/ShellTest.php @@ -83,6 +83,9 @@ public function testExecuteLog($command, $commandArgs, $expectedResult, $expecte ); } + /** + * @return array + */ public function executeDataProvider() { // backtick symbol (`) has to be replaced with environment-dependent quote character diff --git a/lib/internal/Magento/Framework/Test/Unit/TranslateTest.php b/lib/internal/Magento/Framework/Test/Unit/TranslateTest.php index cca8d564d3199..5c634a1bca078 100644 --- a/lib/internal/Magento/Framework/Test/Unit/TranslateTest.php +++ b/lib/internal/Magento/Framework/Test/Unit/TranslateTest.php @@ -139,6 +139,9 @@ public function testLoadDataCachedTranslation($area, $forceReload, $cachedData) $this->assertEquals($cachedData, $this->translate->getData()); } + /** + * @return array + */ public function dataProviderLoadDataCachedTranslation() { $cachedData = ['cached 1' => 'translated 1', 'cached 2' => 'translated 2']; @@ -236,6 +239,9 @@ public function testLoadData($area, $forceReload) $this->assertEquals($expected, $this->translate->getData()); } + /** + * @return array + */ public function dataProviderForTestLoadData() { return [ @@ -263,6 +269,9 @@ public function testGetData($data, $result) $this->assertEquals($result, $this->translate->getData()); } + /** + * @return array + */ public function dataProviderForTestGetData() { $data = ['original 1' => 'translated 1', 'original 2' => 'translated 2']; diff --git a/lib/internal/Magento/Framework/Test/Unit/UrlTest.php b/lib/internal/Magento/Framework/Test/Unit/UrlTest.php index 5c5df5b462b70..3713978d0f74e 100644 --- a/lib/internal/Magento/Framework/Test/Unit/UrlTest.php +++ b/lib/internal/Magento/Framework/Test/Unit/UrlTest.php @@ -163,6 +163,9 @@ public function testGetCurrentUrl($httpHost, $url) $this->assertEquals($url, $model->getCurrentUrl()); } + /** + * @return array + */ public function getCurrentUrlProvider() { return [ @@ -337,6 +340,9 @@ public function testGetUrlRouteUseRewrite() $this->assertEquals('/catalog/product/view/', $model->getUrl('catalog', ['_use_rewrite' => 1])); } + /** + * @return array + */ public function getUrlDataProvider() { return [ @@ -497,6 +503,9 @@ public function testGetRedirectUrlWithSessionId() $this->assertEquals('http://example.com/?foo=bar', $model->getRedirectUrl('http://example.com/')); } + /** + * @return array + */ public function getRebuiltUrlDataProvider() { return [ @@ -558,6 +567,9 @@ public function testIsOwnOriginUrl($result, $referrer) $this->assertEquals($result, $model->isOwnOriginUrl()); } + /** + * @return array + */ public function isOwnOriginUrlDataProvider() { return [ @@ -607,6 +619,9 @@ public function testGetConfigData($urlType, $configPath, $isSecure, $isSecureCal $this->assertEquals('http://localhost/', $model->getConfigData($key)); } + /** + * @return array + */ public function getConfigDataDataProvider() { return [ @@ -712,6 +727,9 @@ public function testSessionUrlVarWithoutMatchedHostsAndBaseUrl() ); } + /** + * @return array + */ public function sessionUrlVarWithMatchedHostsAndBaseUrlDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Translate/Test/Unit/InlineTest.php b/lib/internal/Magento/Framework/Translate/Test/Unit/InlineTest.php index 6e222ba90da8e..b1ef51f010c5b 100644 --- a/lib/internal/Magento/Framework/Translate/Test/Unit/InlineTest.php +++ b/lib/internal/Magento/Framework/Translate/Test/Unit/InlineTest.php @@ -74,6 +74,9 @@ public function testIsAllowed($isEnabled, $isActive, $isDevAllowed, $result) $this->assertEquals($result, $model->isAllowed()); } + /** + * @return array + */ public function isAllowedDataProvider() { return [ @@ -126,6 +129,9 @@ public function testProcessResponseBodyStripInline($body, $expected) $this->assertEquals($body, $expected); } + /** + * @return array + */ public function processResponseBodyStripInlineDataProvider() { return [ @@ -192,6 +198,9 @@ public function testProcessResponseBody($scope, $body, $expected) $this->assertEquals($body, $expected); } + /** + * @return array + */ public function processResponseBodyDataProvider() { return [ @@ -254,6 +263,9 @@ public function testProcessResponseBodyGetInlineScript($scope, $body, $expected) $this->assertEquals($body, $expected); } + /** + * @return array + */ public function processResponseBodyGetInlineScriptDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Unserialize/Test/Unit/UnserializeTest.php b/lib/internal/Magento/Framework/Unserialize/Test/Unit/UnserializeTest.php index 4888077104728..f053a9afff74d 100644 --- a/lib/internal/Magento/Framework/Unserialize/Test/Unit/UnserializeTest.php +++ b/lib/internal/Magento/Framework/Unserialize/Test/Unit/UnserializeTest.php @@ -55,6 +55,9 @@ public function testUnserializeObject($serialized) $this->assertFalse($this->unserialize->unserialize($serialized)); } + /** + * @return array + */ public function unserializeObjectDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Url/Test/Unit/Helper/DataTest.php b/lib/internal/Magento/Framework/Url/Test/Unit/Helper/DataTest.php index 5bb4f54b84a5c..016208d0920aa 100644 --- a/lib/internal/Magento/Framework/Url/Test/Unit/Helper/DataTest.php +++ b/lib/internal/Magento/Framework/Url/Test/Unit/Helper/DataTest.php @@ -79,6 +79,9 @@ public function testGetEncodedUrl($url, $callNum) $this->assertEquals($encodedUrl, $helper->getEncodedUrl($url)); } + /** + * @return array + */ public function getEncodedUrlDataProvider() { return [ @@ -98,6 +101,9 @@ public function testAddRequestParam($param, $expected) $this->assertEquals($expected, $helper->addRequestParam('http://example.com', $param)); } + /** + * @return array + */ public function addRequestParamDataProvider() { return [ @@ -145,6 +151,9 @@ public function testRemoveRequestParam($paramKey, $expected) $this->assertEquals($expected, $helper->removeRequestParam($url, $paramKey)); } + /** + * @return array + */ public function removeRequestParamDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Url/Test/Unit/SecurityInfoTest.php b/lib/internal/Magento/Framework/Url/Test/Unit/SecurityInfoTest.php index fbda5e36c9934..3fc332aa1af52 100644 --- a/lib/internal/Magento/Framework/Url/Test/Unit/SecurityInfoTest.php +++ b/lib/internal/Magento/Framework/Url/Test/Unit/SecurityInfoTest.php @@ -32,6 +32,9 @@ public function testIsSecureChecksIfUrlIsInSecureList($url, $expected) $this->assertEquals($expected, $this->_model->isSecure($url)); } + /** + * @return array + */ public function secureUrlDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Validator/Test/Unit/ObjectTest.php b/lib/internal/Magento/Framework/Validator/Test/Unit/ObjectTest.php index a06297a382f57..0fd70b5bc5f1d 100644 --- a/lib/internal/Magento/Framework/Validator/Test/Unit/ObjectTest.php +++ b/lib/internal/Magento/Framework/Validator/Test/Unit/ObjectTest.php @@ -92,6 +92,9 @@ public function testIsValid(array $inputEntityData, array $expectedErrors) } } + /** + * @return array + */ public function validateDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Asset/File/FallbackContextTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Asset/File/FallbackContextTest.php index 68b5f4bf3a20d..2d6ea2efe4958 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Asset/File/FallbackContextTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Asset/File/FallbackContextTest.php @@ -53,6 +53,9 @@ public function testGetConfigPath( $this->assertEquals($expectedResult, $this->fallbackContext->getConfigPath()); } + /** + * @return array + */ public function getConfigPathDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Asset/FileTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Asset/FileTest.php index b2953bc24e131..64d0419e070d0 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Asset/FileTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Asset/FileTest.php @@ -134,6 +134,9 @@ public function testGetContent($content) $this->assertEquals($content, $this->object->getContent()); // no in-memory caching for content } + /** + * @return array + */ public function getContentDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Asset/MergeServiceTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Asset/MergeServiceTest.php index c4b7cefcfa7c2..4c17a2c0b35f4 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Asset/MergeServiceTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Asset/MergeServiceTest.php @@ -118,6 +118,9 @@ public function testGetMergedAssets(array $assets, $contentType, $appMode, $merg $this->assertSame($mergedAsset, $this->object->getMergedAssets($assets, $contentType)); } + /** + * @return array + */ public static function getMergedAssetsDataProvider() { $jsAssets = [ diff --git a/lib/internal/Magento/Framework/View/Test/Unit/ContextTest.php b/lib/internal/Magento/Framework/View/Test/Unit/ContextTest.php index 923ec2ff322b5..7e672d58d18e0 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/ContextTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/ContextTest.php @@ -234,6 +234,9 @@ public function testGetAcceptType($headerAccept, $acceptType) $this->assertEquals($acceptType, $this->context->getAcceptType()); } + /** + * @return array + */ public function getAcceptTypeDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/View/Test/Unit/DataSourcePoolTest.php b/lib/internal/Magento/Framework/View/Test/Unit/DataSourcePoolTest.php index 52e055f11b8a2..fbb521d2c21b8 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/DataSourcePoolTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/DataSourcePoolTest.php @@ -47,6 +47,11 @@ public function testAddWithException() $this->dataSourcePool->add('DataSourcePoolTestBlock', 'NotExistingBlockClass'); } + /** + * @param $blockClass + * + * @return \PHPUnit_Framework_MockObject_MockObject + */ protected function createBlock($blockClass) { $block = $this->createMock(\Magento\Framework\View\Element\BlockInterface::class); diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/LinkTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/LinkTest.php index 692dcb54d1447..b911a38dbb488 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/LinkTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/LinkTest.php @@ -35,6 +35,9 @@ public function testGetLinkAttributes($link, $expected) $this->assertEquals($expected, $link->getLinkAttributes()); } + /** + * @return array + */ public function getLinkAttributesDataProvider() { $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/Js/CookieTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/Js/CookieTest.php index 10e21763ba802..fefbdf0ed5111 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/Js/CookieTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/Js/CookieTest.php @@ -83,6 +83,9 @@ public function testGetDomain($domain, $isIp, $expectedResult) $this->assertEquals($expectedResult, $result); } + /** + * @return array + */ public static function domainDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/Text/TextList/ItemTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/Text/TextList/ItemTest.php index b2b1db44d6a0b..6ac8355fe7371 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/Text/TextList/ItemTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/Text/TextList/ItemTest.php @@ -51,6 +51,9 @@ public function testToHtml($liParams, $innerText, $expectedHtml) $this->assertEquals($expectedHtml, $this->item->toHtml()); } + /** + * @return array + */ public function toHtmlDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/Text/TextList/LinkTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/Text/TextList/LinkTest.php index 785c41c1d6e2f..a16b1ca80c49e 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/Text/TextList/LinkTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/Text/TextList/LinkTest.php @@ -54,6 +54,9 @@ public function testToHtml($liParams, $aParams, $innerText, $afterText, $expecte $this->assertEquals($expectedHtml, $this->link->toHtml()); } + /** + * @return array + */ public function toHtmlDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/View/Test/Unit/File/Collector/Decorator/ModuleDependencyTest.php b/lib/internal/Magento/Framework/View/Test/Unit/File/Collector/Decorator/ModuleDependencyTest.php index ffe3d3a173e47..a76dca703fedb 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/File/Collector/Decorator/ModuleDependencyTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/File/Collector/Decorator/ModuleDependencyTest.php @@ -54,6 +54,9 @@ public function testGetFiles(array $fixtureFiles, array $expectedFiles, $message $this->assertSame($expectedFiles, $this->_model->getFiles($theme, '*.xml'), $message); } + /** + * @return array + */ public function getFilesDataProvider() { $fileOne = new \Magento\Framework\View\File('b.xml', 'Fixture_ModuleB'); diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/HelperMethodTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/HelperMethodTest.php index 458b23a4b15eb..3d9166fc87f00 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/HelperMethodTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/HelperMethodTest.php @@ -53,6 +53,11 @@ public function testEvaluate() $this->assertSame($expected, $actual); } + /** + * @param $input + * + * @return string + */ public function help($input) { $this->assertSame('some text (evaluated)', $input); @@ -73,6 +78,9 @@ public function testEvaluateException($helperMethod, $expectedExceptionMessage) $this->_model->evaluate($input); } + /** + * @return array + */ public function evaluateExceptionDataProvider() { $nonExistingHelper = __CLASS__ . '::non_existing'; diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/NamedParamsTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/NamedParamsTest.php index 5ae0b0332f28a..c4fff297b4ec1 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/NamedParamsTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/NamedParamsTest.php @@ -67,6 +67,9 @@ public function testEvaluateWrongParam($input, $expectedExceptionMessage) $this->_model->evaluate($input); } + /** + * @return array + */ public function evaluateWrongParamDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/OptionsTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/OptionsTest.php index d3e91cb7c2b7e..24fd9f98d7112 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/OptionsTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/OptionsTest.php @@ -72,6 +72,9 @@ public function testEvaluateWrongModel($input, $expectedException, $expectedExce $this->_model->evaluate($input); } + /** + * @return array + */ public function evaluateWrongModelDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/BuilderFactoryTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/BuilderFactoryTest.php index 45754d0618d05..427e15d901d6d 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/BuilderFactoryTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/BuilderFactoryTest.php @@ -65,6 +65,9 @@ public function testCreate($type, $arguments, $layoutBuilderClass) $this->buildFactory->create($type, $arguments); } + /** + * @return array + */ public function createDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/ElementTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/ElementTest.php index ab5c908cb16af..a663b65561345 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/ElementTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/ElementTest.php @@ -20,6 +20,9 @@ public function testGetElementName($xml, $name) $this->assertEquals($name, $model->getElementName()); } + /** + * @return array + */ public function elementNameDataProvider() { return [ @@ -31,6 +34,9 @@ public function elementNameDataProvider() ]; } + /** + * @return array + */ public function cacheableDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/UiComponentTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/UiComponentTest.php index 1568c381226e2..158718587ad60 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/UiComponentTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/UiComponentTest.php @@ -158,6 +158,9 @@ public function testInterpret($element) $this->model->interpret($this->context, $element); } + /** + * @return array + */ public function interpretDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Page/Config/Generator/HeadTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Page/Config/Generator/HeadTest.php index 4b000f09663b8..30dead438951a 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Page/Config/Generator/HeadTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Page/Config/Generator/HeadTest.php @@ -140,6 +140,9 @@ public function testProcess($assets) $this->assertEquals($this->headGenerator, $result); } + /** + * @return array + */ public function testProcessAssetDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Page/ConfigTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Page/ConfigTest.php index 400e9cf3d1ed7..935154a75026e 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Page/ConfigTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Page/ConfigTest.php @@ -287,6 +287,9 @@ public function testAddPageAsset($file, $properties, $name, $expectedName) ); } + /** + * @return array + */ public function pageAssetDataProvider() { return [ @@ -326,6 +329,9 @@ public function testAddRemotePageAsset($url, $contentType, $properties, $name, $ ); } + /** + * @return array + */ public function remotePageAssetDataProvider() { return [ @@ -382,6 +388,9 @@ public function testElementAttribute($elementType, $attribute, $value) $this->assertEquals($value, $this->model->getElementAttribute($elementType, $attribute)); } + /** + * @return array + */ public function elementAttributeDataProvider() { return [ @@ -419,6 +428,9 @@ public function testElementAttributeException($elementType, $attribute, $value) $this->model->setElementAttribute($elementType, $attribute, $value); } + /** + * @return array + */ public function elementAttributeExceptionDataProvider() { return [ @@ -454,6 +466,9 @@ public function testElementAttributes($elementType, $attributes) $this->assertEquals($attributes, $this->model->getElementAttributes($elementType)); } + /** + * @return array + */ public function elementAttributesDataProvider() { return [ @@ -478,6 +493,9 @@ public function testPageLayout($handle) $this->assertEquals($handle, $this->model->getPageLayout()); } + /** + * @return array + */ public function pageLayoutDataProvider() { return [ @@ -538,6 +556,9 @@ public function testGetIncludes($isAvailable, $result) $this->assertEquals($result, $model->getIncludes()); } + /** + * @return array + */ public function getIncludesDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Webapi/Test/Unit/RequestTest.php b/lib/internal/Magento/Framework/Webapi/Test/Unit/RequestTest.php index d30df5d76b75b..1fc6e92f87aa8 100644 --- a/lib/internal/Magento/Framework/Webapi/Test/Unit/RequestTest.php +++ b/lib/internal/Magento/Framework/Webapi/Test/Unit/RequestTest.php @@ -38,6 +38,9 @@ public function testGetRequestedServicesSuccess($requestParamServices, $expected $this->assertEquals($expectedResult, $this->request->getRequestedServices()); } + /** + * @return array + */ public function providerTestGetRequestedServicesSuccess() { $testModuleA = 'testModule1AllSoapAndRestV1'; diff --git a/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessorTest.php b/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessorTest.php index fe85e59221847..fd470f9d0c9c8 100644 --- a/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessorTest.php +++ b/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessorTest.php @@ -533,6 +533,9 @@ public function testCustomAttributesExceptions($inputData) ); } + /** + * @return array + */ public function invalidCustomAttributesDataProvider() { return [ diff --git a/setup/src/Magento/Setup/Console/Command/GenerateFixturesCommand.php b/setup/src/Magento/Setup/Console/Command/GenerateFixturesCommand.php index e084cd8ff6cad..03b74f637a7da 100644 --- a/setup/src/Magento/Setup/Console/Command/GenerateFixturesCommand.php +++ b/setup/src/Magento/Setup/Console/Command/GenerateFixturesCommand.php @@ -157,6 +157,10 @@ private function clearChangelog() } } + /** + * @param \Magento\Setup\Fixtures\Fixture $fixture + * @param OutputInterface $output + */ private function executeFixture(\Magento\Setup\Fixtures\Fixture $fixture, OutputInterface $output) { $output->write('<info>' . $fixture->getActionTitle() . '... </info>'); diff --git a/setup/src/Magento/Setup/Console/Style/MagentoStyle.php b/setup/src/Magento/Setup/Console/Style/MagentoStyle.php index 4dec01f9497e1..614014a233657 100755 --- a/setup/src/Magento/Setup/Console/Style/MagentoStyle.php +++ b/setup/src/Magento/Setup/Console/Style/MagentoStyle.php @@ -518,6 +518,11 @@ private function autoPrependText() } } + /** + * @param $messages + * + * @return array + */ private function reduceBuffer($messages) { // We need to know if the two last chars are PHP_EOL diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/DbStatusCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/DbStatusCommandTest.php index 9c28c2be04262..2824b043a2743 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/DbStatusCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/DbStatusCommandTest.php @@ -85,6 +85,9 @@ public function testExecute(array $outdatedInfo, $expectedMessage, $expectedCode $this->assertSame($expectedCode, $tester->getStatusCode()); } + /** + * @return array + */ public function executeDataProvider() { return [ diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/DeployStaticContentCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/DeployStaticContentCommandTest.php index a5dc0d24feb7c..c3f79d92ec560 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/DeployStaticContentCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/DeployStaticContentCommandTest.php @@ -111,6 +111,9 @@ public function testExecute($input) $tester->execute($input); } + /** + * @return array + */ public function executeDataProvider() { return [ diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/UninstallCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/UninstallCommandTest.php index 8bcee84d049b3..1ef3830636657 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/UninstallCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/UninstallCommandTest.php @@ -51,6 +51,9 @@ public function testExecuteInteractionNo() $this->checkInteraction(false); } + /** + * @param $answer + */ public function checkInteraction($answer) { $question = $this->createMock(\Symfony\Component\Console\Helper\QuestionHelper::class); diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Style/TestOutput.php b/setup/src/Magento/Setup/Test/Unit/Console/Style/TestOutput.php index 1407e5ed183e4..183f659c42f23 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Style/TestOutput.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Style/TestOutput.php @@ -20,6 +20,10 @@ public function clear() $this->output = ''; } + /** + * @param string $message + * @param bool $newline + */ protected function doWrite($message, $newline) { $this->output .= $message . ($newline ? "\n" : ''); diff --git a/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsList/SessionTest.php b/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsList/SessionTest.php index d37c07e715482..3893181d0c7f7 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsList/SessionTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsList/SessionTest.php @@ -262,6 +262,9 @@ public function testValidationWithInvalidOptions($option, $invalidInput, $errorM $this->assertSame($errorMessage, $errors[0]); } + /** + * @return array + */ public function redisOptionProvider() { return [ @@ -286,6 +289,9 @@ public function redisOptionProvider() ]; } + /** + * @return array + */ public function invalidOptionsProvider() { return [ diff --git a/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsListTest.php b/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsListTest.php index 1bb60517d5e67..f342a11493498 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsListTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsListTest.php @@ -178,6 +178,9 @@ public function testValidateCacheHosts($hosts, $expectedError) } } + /** + * @return array + */ public function validateCacheHostsDataProvider() { return [ diff --git a/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobComponentUninstallTest.php b/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobComponentUninstallTest.php index b3e88272d13e8..59210df4f7bcf 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobComponentUninstallTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobComponentUninstallTest.php @@ -264,6 +264,9 @@ public function testExecuteWrongFormat(array $params) $this->job->execute(); } + /** + * @return array + */ public function executeWrongFormatDataProvider() { return [ diff --git a/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobFactoryTest.php b/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobFactoryTest.php index f96882c30136a..1f8a3fea16da2 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobFactoryTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobFactoryTest.php @@ -206,16 +206,25 @@ public function testMaintenanceModeDisable() // functions to override native php functions namespace Magento\Setup\Model\Cron; +/** + * @return string + */ function fopen() { return 'filestream'; } +/** + * @return bool + */ function is_resource() { return true; } +/** + * @return string + */ function get_resource_type() { return 'stream'; diff --git a/setup/src/Magento/Setup/Test/Unit/Model/Cron/ReadinessCheckTest.php b/setup/src/Magento/Setup/Test/Unit/Model/Cron/ReadinessCheckTest.php index f8f1d8542c38c..4a4ff2cb81e8d 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/Cron/ReadinessCheckTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/Cron/ReadinessCheckTest.php @@ -201,6 +201,9 @@ public function testRunReadinessCheckLastTimestamp() namespace Magento\Setup\Model\Cron; +/** + * @return int + */ function time() { return 100; diff --git a/setup/src/Magento/Setup/Test/Unit/Model/Description/Mixin/BrakeMixinTest.php b/setup/src/Magento/Setup/Test/Unit/Model/Description/Mixin/BrakeMixinTest.php index e6c7b420b661d..dfa001f44bc66 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/Description/Mixin/BrakeMixinTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/Description/Mixin/BrakeMixinTest.php @@ -25,6 +25,9 @@ public function testApply($subject, $expectedResult) $this->assertEquals($expectedResult, $this->mixin->apply($subject)); } + /** + * @return array + */ public function getTestData() { return [ diff --git a/setup/src/Magento/Setup/Test/Unit/Model/Description/Mixin/HeaderMixinTest.php b/setup/src/Magento/Setup/Test/Unit/Model/Description/Mixin/HeaderMixinTest.php index 48280e9c6f543..bf915fecf4701 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/Description/Mixin/HeaderMixinTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/Description/Mixin/HeaderMixinTest.php @@ -25,6 +25,9 @@ public function testApply($subject, $expectedResult) $this->assertEquals($expectedResult, $this->mixin->apply($subject)); } + /** + * @return array + */ public function getTestData() { return [ diff --git a/setup/src/Magento/Setup/Test/Unit/Model/Description/Mixin/Helper/RandomWordSelectorTest.php b/setup/src/Magento/Setup/Test/Unit/Model/Description/Mixin/Helper/RandomWordSelectorTest.php index b21c687a30960..c24fa49fcac24 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/Description/Mixin/Helper/RandomWordSelectorTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/Description/Mixin/Helper/RandomWordSelectorTest.php @@ -34,6 +34,9 @@ public function testRandomSelector($fixtureSource, $fixtureCount) } } + /** + * @return array + */ public function getTestData() { return [ diff --git a/setup/src/Magento/Setup/Test/Unit/Model/Description/Mixin/Helper/WordWrapperTest.php b/setup/src/Magento/Setup/Test/Unit/Model/Description/Mixin/Helper/WordWrapperTest.php index 58e07df7391fc..7d3cbcdd00c71 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/Description/Mixin/Helper/WordWrapperTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/Description/Mixin/Helper/WordWrapperTest.php @@ -30,6 +30,9 @@ public function testWrapping($inputData, $expectedResult) ); } + /** + * @return array + */ public function getTestData() { return [ diff --git a/setup/src/Magento/Setup/Test/Unit/Model/Description/Mixin/ParagraphMixinTest.php b/setup/src/Magento/Setup/Test/Unit/Model/Description/Mixin/ParagraphMixinTest.php index a522963d212ef..4fdb3090992bb 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/Description/Mixin/ParagraphMixinTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/Description/Mixin/ParagraphMixinTest.php @@ -25,6 +25,9 @@ public function testApply($subject, $expectedResult) $this->assertEquals($expectedResult, $this->mixin->apply($subject)); } + /** + * @return array + */ public function getTestData() { return [ diff --git a/setup/src/Magento/Setup/Test/Unit/Model/Grid/TypeMapperTest.php b/setup/src/Magento/Setup/Test/Unit/Model/Grid/TypeMapperTest.php index 90c26b5632d21..11dca34763a05 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/Grid/TypeMapperTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/Grid/TypeMapperTest.php @@ -39,6 +39,9 @@ public function testMap($packageType, $expected) ); } + /** + * @return array + */ public function mapDataProvider() { return [ diff --git a/setup/src/Magento/Setup/Test/Unit/Model/ObjectManagerProviderTest.php b/setup/src/Magento/Setup/Test/Unit/Model/ObjectManagerProviderTest.php index 9f59479ef0f0d..9d40b053e394e 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/ObjectManagerProviderTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/ObjectManagerProviderTest.php @@ -83,6 +83,9 @@ public function testGet() $this->assertInstanceOf(ObjectManagerInterface::class, $this->model->get()); } + /** + * @return \PHPUnit_Framework_MockObject_MockObject + */ private function getCommandListMock() { $commandMock = $this->getMockBuilder(Command::class)->disableOriginalConstructor()->getMock(); diff --git a/setup/src/Magento/Setup/Test/Unit/Model/PayloadValidatorTest.php b/setup/src/Magento/Setup/Test/Unit/Model/PayloadValidatorTest.php index 192717e1d319b..2d7685c2021cc 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/PayloadValidatorTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/PayloadValidatorTest.php @@ -38,6 +38,9 @@ public function testValidatePayLoad($type, $has, $moduleExists) $this->assertEquals('', $this->model->validatePayload($type)); } + /** + * @return array + */ public function validatePayLoadDataProvider() { return [ @@ -61,6 +64,9 @@ public function testValidatePayLoadNegativeCases($type, $has, $moduleExists, $er $this->assertStringStartsWith($errorMessage, $this->model->validatePayload($type)); } + /** + * @return array + */ public function validatePayLoadNegativeCasesDataProvider() { return [ diff --git a/setup/src/Magento/Setup/Test/Unit/Model/PhpReadinessCheckTest.php b/setup/src/Magento/Setup/Test/Unit/Model/PhpReadinessCheckTest.php index f543e77787f9d..13f5b6940d846 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/PhpReadinessCheckTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/PhpReadinessCheckTest.php @@ -411,6 +411,11 @@ protected function isPhp7OrHhvm() namespace Magento\Setup\Model; +/** + * @param $param + * + * @return int|string + */ function ini_get($param) { if ($param === 'xdebug.max_nesting_level') { diff --git a/setup/src/Magento/Setup/Test/Unit/Model/WebLoggerTest.php b/setup/src/Magento/Setup/Test/Unit/Model/WebLoggerTest.php index b3ac6ad286e44..a55c50eeaa736 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/WebLoggerTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/WebLoggerTest.php @@ -184,6 +184,9 @@ public function testClearNotExist() $this->webLogger->clear(); } + /** + * @return string + */ public static function readLog() { return self::$log; @@ -202,6 +205,9 @@ public static function deleteLog() self::$log = ''; } + /** + * @return bool + */ public static function isExist() { return self::$log != ''; diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Reader/ClassReaderDecoratorTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Reader/ClassReaderDecoratorTest.php index 7d8ce3ac564b3..ebb6560f9337d 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Reader/ClassReaderDecoratorTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Reader/ClassReaderDecoratorTest.php @@ -46,6 +46,9 @@ public function testGetConstructor($expectation, $className, $willReturn) ); } + /** + * @return array + */ public function getConstructorDataProvider() { return [ diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/_files/app/code/Magento/SomeModule/Helper/Test.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/_files/app/code/Magento/SomeModule/Helper/Test.php index 68d76980e1057..dcb9a287f787b 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Di/_files/app/code/Magento/SomeModule/Helper/Test.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/_files/app/code/Magento/SomeModule/Helper/Test.php @@ -25,6 +25,13 @@ class Test */ protected $_newElementFactory; + /** + * Test constructor. + * + * @param \Magento\SomeModule\Module\Factory $factory + * @param \Magento\SomeModule\Element\Factory $elementFactory + * @param \Magento\SomeModule\ElementFactory $rightElementFactory + */ public function __construct( \Magento\SomeModule\Module\Factory $factory, \Magento\SomeModule\Element\Factory $elementFactory, diff --git a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/AbstractParserTest.php b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/AbstractParserTest.php index 3c744bb44d32a..c698d4c344df8 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/AbstractParserTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/AbstractParserTest.php @@ -39,6 +39,9 @@ public function testValidateOptions($options, $message) $this->_parserMock->parse($options); } + /** + * @return array + */ public function dataProviderForValidateOptions() { return [ diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Setup/SetupCacheTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Setup/SetupCacheTest.php index 15a55bd23b164..573c8b132ca41 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Setup/SetupCacheTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Setup/SetupCacheTest.php @@ -88,6 +88,9 @@ public function testHas($table, $parentId, $rowId, $field, $expected) $this->assertSame($expected, $this->object->has($table, $parentId, $rowId, $field)); } + /** + * @return array + */ public function hasDataProvider() { return [ diff --git a/setup/src/Magento/Setup/Test/Unit/Mvc/Bootstrap/InitParamListenerTest.php b/setup/src/Magento/Setup/Test/Unit/Mvc/Bootstrap/InitParamListenerTest.php index a35007189a9ca..f0a9d5316b3a6 100644 --- a/setup/src/Magento/Setup/Test/Unit/Mvc/Bootstrap/InitParamListenerTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Mvc/Bootstrap/InitParamListenerTest.php @@ -144,6 +144,9 @@ public function testCreateService($zfAppConfig, $env, $cliParam, $expectedArray) $this->assertEquals($expectedArray, $listener->createService($serviceLocator)); } + /** + * @return array + */ public function createServiceDataProvider() { return [ From 80806f801ad0577453b6ea787a2a6c4a6eb1d741 Mon Sep 17 00:00:00 2001 From: IvanPletnyov <ivan.pletnyov@transoftgroup.com> Date: Mon, 18 Jun 2018 18:06:08 +0300 Subject: [PATCH 169/206] 15863: [Forwardport] Refactored javascript code of admin notification modal popup --- .../templates/system/messages/popup.phtml | 2 +- .../view/adminhtml/web/js/system/messages/popup.js | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/code/Magento/AdminNotification/view/adminhtml/templates/system/messages/popup.phtml b/app/code/Magento/AdminNotification/view/adminhtml/templates/system/messages/popup.phtml index d654504a41e5c..0448daaf17644 100644 --- a/app/code/Magento/AdminNotification/view/adminhtml/templates/system/messages/popup.phtml +++ b/app/code/Magento/AdminNotification/view/adminhtml/templates/system/messages/popup.phtml @@ -23,7 +23,7 @@ { "[data-role=system_messages_list]": { "Magento_AdminNotification/js/system/messages/popup": { - class: 'modal-system-messages ui-popup-message' + "class":"modal-system-messages ui-popup-message" } } } diff --git a/app/code/Magento/AdminNotification/view/adminhtml/web/js/system/messages/popup.js b/app/code/Magento/AdminNotification/view/adminhtml/web/js/system/messages/popup.js index f3f6a5fb1a123..39c61d6e07d29 100644 --- a/app/code/Magento/AdminNotification/view/adminhtml/web/js/system/messages/popup.js +++ b/app/code/Magento/AdminNotification/view/adminhtml/web/js/system/messages/popup.js @@ -1,24 +1,26 @@ /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. -*/ + */ define([ 'jquery', 'Magento_Ui/js/modal/modal' -], function ($) { +], function ($, modal) { 'use strict'; return function (data, element) { - if (this.modal) { - this.modal.html($(element).html()); + + if (modal.modal) { + modal.modal.html($(element).html()); } else { - this.modal = $(element).modal({ + modal.modal = $(element).modal({ modalClass: data.class, type: 'popup', buttons: [] }); } - this.modal.modal('openModal'); + + modal.modal.modal('openModal'); }; }); From e837b8771cd67a27a9651264177031c454449984 Mon Sep 17 00:00:00 2001 From: Michail Slabko <mslabko@magento.com> Date: Mon, 18 Jun 2018 20:16:41 +0300 Subject: [PATCH 170/206] MAGETWO-91820: Stabilize builds - MAGETWO-64467 [Indexer optimizations] Tables sharding / segmentation for price indexer --- .../Price/DimensionCollectionFactory.php | 16 ++++++---------- .../Price/CustomOptionPriceModifier.php | 8 ++------ .../Product/Indexer/Price/DefaultPrice.php | 18 ++++++------------ .../Indexer/Price/SimpleProductPrice.php | 2 -- app/code/Magento/Catalog/etc/di.xml | 10 ++++------ .../ScopeResolver/IndexScopeResolver.php | 6 +++--- 6 files changed, 21 insertions(+), 39 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionCollectionFactory.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionCollectionFactory.php index c5ccff49501b6..62a129f0ff448 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionCollectionFactory.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/DimensionCollectionFactory.php @@ -41,7 +41,8 @@ public function __construct( } /** - * Create MultiDimensionProvider for specified "dimension mode" - which dimensions indexer use for sharding + * Create MultiDimensionProvider for specified "dimension mode". + * By default return multiplication of dimensions by current set mode * * @param string|null $dimensionsMode * @return MultiDimensionProvider @@ -49,20 +50,15 @@ public function __construct( public function create(string $dimensionsMode = null): MultiDimensionProvider { $dimensionConfiguration = $this->dimensionModeConfiguration->getDimensionConfiguration($dimensionsMode); - $dimensionProvidersMap = []; - foreach ($this->dimensionProviders as $dimensionProvider) { - // TODO: fix hac by getDimensionName? - $dimensionProvidersMap[$dimensionProvider::DIMENSION_NAME] = $dimensionProvider; - } $providers = []; foreach ($dimensionConfiguration as $dimensionName) { - if (!isset($dimensionProvidersMap[$dimensionName])) { - throw new \InvalidArgumentException( - sprintf('Missing data provider for Dimension with name "%s".', $dimensionName) + if (!isset($this->dimensionProviders[$dimensionName])) { + throw new \LogicException( + 'Dimension Provider is missing. Cannot handle unknown dimension: ' . $dimensionName ); } - $providers[] = clone $dimensionProvidersMap[$dimensionName]; + $providers[] = clone $this->dimensionProviders[$dimensionName]; } return $this->multiDimensionProviderFactory->create( diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/CustomOptionPriceModifier.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/CustomOptionPriceModifier.php index 8861ab9ed8e80..2ada0eaabaca1 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/CustomOptionPriceModifier.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/CustomOptionPriceModifier.php @@ -208,9 +208,7 @@ private function getSelectForOptionsWithMultipleValues(string $sourceTable): Sel if ($this->isPriceGlobal()) { $optPriceType = 'otpd.price_type'; $optPriceValue = 'otpd.price'; - } - - if (!$this->isPriceGlobal()) { + } else { $select->joinLeft( ['otps' => $this->getTable('catalog_product_option_type_price')], 'otps.option_type_id = otpd.option_type_id AND otpd.store_id = cwd.default_store_id', @@ -307,9 +305,7 @@ private function getSelectForOptionsWithOneValue(string $sourceTable): Select if ($this->isPriceGlobal()) { $optPriceType = 'opd.price_type'; $optPriceValue = 'opd.price'; - } - - if (!$this->isPriceGlobal()) { + } else { $select->joinLeft( ['ops' => $this->getTable('catalog_product_option_price')], 'ops.option_id = opd.option_id AND ops.store_id = cwd.default_store_id', diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php index 0a659180950c4..849c12238db5a 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php @@ -6,7 +6,6 @@ namespace Magento\Catalog\Model\ResourceModel\Product\Indexer\Price; use Magento\Catalog\Model\ResourceModel\Product\Indexer\AbstractIndexer; -use Magento\Framework\App\ObjectManager; use Magento\Framework\Indexer\DimensionalIndexerInterface; /** @@ -66,11 +65,6 @@ class DefaultPrice extends AbstractIndexer implements PriceInterface */ private $priceModifiers = []; - /** - * @var \Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher - */ - private $activeTableSwitcher; - /** * DefaultPrice constructor. * @@ -91,8 +85,7 @@ public function __construct( \Magento\Framework\Module\Manager $moduleManager, $connectionName = null, IndexTableStructureFactory $indexTableStructureFactory = null, - array $priceModifiers = [], - \Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher $activeTableSwitcher = null + array $priceModifiers = [] ) { $this->_eventManager = $eventManager; $this->moduleManager = $moduleManager; @@ -109,9 +102,6 @@ public function __construct( $this->priceModifiers[] = $priceModifier; } - $this->activeTableSwitcher = $activeTableSwitcher ?: ObjectManager::getInstance()->get( - \Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher::class - ); } /** @@ -832,7 +822,11 @@ protected function hasEntity() return $this->hasEntity; } - protected function getTotalTierPriceExpression(\Zend_Db_Expr $priceExpression) + /** + * @param \Zend_Db_Expr $priceExpression + * @return \Zend_Db_Expr + */ + private function getTotalTierPriceExpression(\Zend_Db_Expr $priceExpression) { $maxUnsignedBigint = '~0'; diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/SimpleProductPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/SimpleProductPrice.php index 8a761a0e67fa7..47965c9c9a1d6 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/SimpleProductPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/SimpleProductPrice.php @@ -54,7 +54,6 @@ public function __construct( $productType = \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE, array $priceModifiers = [] ) { - $this->baseFinalPrice = $baseFinalPrice; $this->indexTableStructureFactory = $indexTableStructureFactory; $this->tableMaintainer = $tableMaintainer; @@ -67,7 +66,6 @@ public function __construct( */ public function executeByDimension(array $dimensions, \Traversable $entityIds = null) { - // TODO: hot fix for rows reindex $this->tableMaintainer->createMainTmpTable($dimensions); $temporaryPriceTable = $this->indexTableStructureFactory->create([ diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml index a6b12135fa6e0..8b253c2d99f35 100644 --- a/app/code/Magento/Catalog/etc/di.xml +++ b/app/code/Magento/Catalog/etc/di.xml @@ -1079,12 +1079,10 @@ <type name="Magento\Catalog\Model\Indexer\Product\Price\DimensionCollectionFactory"> <arguments> <argument name="dimensionProviders" xsi:type="array"> - <item name="websites" xsi:type="object"> - Magento\Store\Model\Indexer\WebsiteDimensionProvider - </item> - <item name="customer_groups" xsi:type="object"> - Magento\Customer\Model\Indexer\CustomerGroupDimensionProvider - </item> + <!-- @see \Magento\Store\Model\Indexer\WebsiteDimensionProvider::DIMENSION_NAME --> + <item name="ws" xsi:type="object">Magento\Store\Model\Indexer\WebsiteDimensionProvider</item> + <!-- @see \Magento\Customer\Model\Indexer\CustomerGroupDimensionProvider::DIMENSION_NAME --> + <item name="cg" xsi:type="object">Magento\Customer\Model\Indexer\CustomerGroupDimensionProvider</item> </argument> </arguments> </type> diff --git a/lib/internal/Magento/Framework/Indexer/ScopeResolver/IndexScopeResolver.php b/lib/internal/Magento/Framework/Indexer/ScopeResolver/IndexScopeResolver.php index e0be02cf09546..a68de6ad36f9a 100644 --- a/lib/internal/Magento/Framework/Indexer/ScopeResolver/IndexScopeResolver.php +++ b/lib/internal/Magento/Framework/Indexer/ScopeResolver/IndexScopeResolver.php @@ -42,7 +42,6 @@ public function __construct( */ public function resolve($index, array $dimensions) { - $mainPart = [$index]; $tableNameParts = []; foreach ($dimensions as $dimension) { switch ($dimension->getName()) { @@ -54,8 +53,9 @@ public function resolve($index, array $dimensions) } } ksort($tableNameParts); - $result = array_merge($mainPart, $tableNameParts); - return $this->resource->getTableName(implode('_', $result)); + array_unshift($tableNameParts, $index); + + return $this->resource->getTableName(implode('_', $tableNameParts)); } /** From 0a4380e50e062bafe54304910b6723cecc951b9a Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi <alugovyi@magento.com> Date: Mon, 18 Jun 2018 15:06:51 +0300 Subject: [PATCH 171/206] MAGETWO-64467: [Indexer optimizations] Tables sharding / segmentation for price indexer --- .../Catalog/Model/Indexer/Product/Price/PriceTableResolver.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php index b690d6f871d37..597bc00cc7ae2 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php @@ -10,6 +10,9 @@ use Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver; use Magento\Framework\Search\Request\IndexScopeResolverInterface; +/** + * Class return price table name based on dimension + */ class PriceTableResolver implements IndexScopeResolverInterface { /** From 5c8f0b7a5a22c1805c3934e371298cca71a61260 Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi <alugovyi@magento.com> Date: Mon, 18 Jun 2018 20:55:13 +0300 Subject: [PATCH 172/206] MAGETWO-64467: [Indexer optimizations] Tables sharding / segmentation for price indexer --- .../Catalog/Model/Indexer/Product/Price/PriceTableResolver.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php index 597bc00cc7ae2..043fc4e8cbee3 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php @@ -12,6 +12,7 @@ /** * Class return price table name based on dimension + * use only on the frontend area */ class PriceTableResolver implements IndexScopeResolverInterface { @@ -62,7 +63,7 @@ private function filterDimensions($dimensions): array $currentDimensions = $this->dimensionModeConfiguration->getDimensionConfiguration(); foreach ($dimensions as $dimension) { if ((string)$dimension->getValue() === '') { - throw new \Exception(sprintf('Dimension value of "%s" can not be empty', $dimension->getName())); + throw new \InvalidArgumentException(sprintf('Dimension value of "%s" can not be empty', $dimension->getName())); } if (in_array($dimension->getName(), $currentDimensions, true)) { $existDimensions[] = $dimension; From 75469d46a62f12bc06e7e23e99133b2f105cacdd Mon Sep 17 00:00:00 2001 From: jakhotiya <jakhotiyaabhishek@gmail.com> Date: Mon, 18 Jun 2018 23:45:42 +0530 Subject: [PATCH 173/206] Incorrect value NULL was passed to DataObject constructor. It caused fatal error. Fixed it by passing an empty array instead --- app/code/Magento/Wishlist/Model/Item.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Wishlist/Model/Item.php b/app/code/Magento/Wishlist/Model/Item.php index b0e7c78cae5f4..41e83c7179e10 100644 --- a/app/code/Magento/Wishlist/Model/Item.php +++ b/app/code/Magento/Wishlist/Model/Item.php @@ -473,7 +473,7 @@ public function getProductUrl() public function getBuyRequest() { $option = $this->getOptionByCode('info_buyRequest'); - $initialData = $option ? $this->serializer->unserialize($option->getValue()) : null; + $initialData = $option ? $this->serializer->unserialize($option->getValue()) : []; if ($initialData instanceof \Magento\Framework\DataObject) { $initialData = $initialData->getData(); From 3566a6c2186d8822f0fd52fb333b9a78b8cd811e Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov <slopukhov@magento.com> Date: Tue, 19 Jun 2018 08:03:54 +0300 Subject: [PATCH 174/206] MAGETWO-91820: Stabilize builds --- .../Model/Indexer/Product/Price/PriceTableResolver.php | 4 +++- .../Product/Indexer/Price/Query/JoinAttributeProcessor.php | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php index 043fc4e8cbee3..0e4850d1f9541 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/PriceTableResolver.php @@ -63,7 +63,9 @@ private function filterDimensions($dimensions): array $currentDimensions = $this->dimensionModeConfiguration->getDimensionConfiguration(); foreach ($dimensions as $dimension) { if ((string)$dimension->getValue() === '') { - throw new \InvalidArgumentException(sprintf('Dimension value of "%s" can not be empty', $dimension->getName())); + throw new \InvalidArgumentException( + sprintf('Dimension value of "%s" can not be empty', $dimension->getName()) + ); } if (in_array($dimension->getName(), $currentDimensions, true)) { $existDimensions[] = $dimension; diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/JoinAttributeProcessor.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/JoinAttributeProcessor.php index 7673e57f3f443..888e68a817081 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/JoinAttributeProcessor.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/JoinAttributeProcessor.php @@ -39,14 +39,12 @@ class JoinAttributeProcessor /** * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Framework\EntityManager\MetadataPool $metadataPool - * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Framework\App\ResourceConnection $resource * @param string $connectionName */ public function __construct( \Magento\Eav\Model\Config $eavConfig, \Magento\Framework\EntityManager\MetadataPool $metadataPool, - \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\App\ResourceConnection $resource, $connectionName = 'indexer' ) { From 44075debc5702fe66365b68715ef6b0fa5b081e3 Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov <slopukhov@magento.com> Date: Tue, 19 Jun 2018 08:16:28 +0300 Subject: [PATCH 175/206] MAGETWO-91820: Stabilize builds --- .../ResourceModel/Product/Collection.php | 2 ++ .../Price/CustomOptionPriceModifier.php | 2 +- .../Indexer/Price/Query/BaseFinalPrice.php | 19 ++++++++++++++++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php index 9dc4dce716951..ee5b55905d45c 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php @@ -1882,7 +1882,9 @@ protected function _productLimitationPrice($joinLeft = false) { $filters = $this->_productLimitationFilters; if (!$filters->isUsingPriceIndex() || + !isset($filters['website_id']) || (string)$filters['website_id'] === '' || + !isset($filters['customer_group_id']) || (string)$filters['customer_group_id'] === '' ) { return $this; diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/CustomOptionPriceModifier.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/CustomOptionPriceModifier.php index 2ada0eaabaca1..269d29bf7e26a 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/CustomOptionPriceModifier.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/CustomOptionPriceModifier.php @@ -12,7 +12,7 @@ use Magento\Framework\DB\Sql\ColumnValueExpression; /** - * Class for adding catalog rule prices to price index table. + * Class for modify custom option price. */ class CustomOptionPriceModifier implements PriceModifierInterface { diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php index 668a0c82b8cbf..9b6733608e4bc 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php @@ -215,7 +215,7 @@ public function getQuery(array $dimensions, string $productType, array $entityId ] ); - $select->where(sprintf("e.type_id = '%s'", $productType)); + $select->where("e.type_id = ?", $productType); if ($entityIds !== null) { if (count($entityIds) > 1) { @@ -241,6 +241,12 @@ public function getQuery(array $dimensions, string $productType, array $entityId return $select; } + /** + * Get total tier price expression + * + * @param \Zend_Db_Expr $priceExpression + * @return \Zend_Db_Expr + */ private function getTotalTierPriceExpression(\Zend_Db_Expr $priceExpression) { $maxUnsignedBigint = '~0'; @@ -277,6 +283,13 @@ private function getTotalTierPriceExpression(\Zend_Db_Expr $priceExpression) ); } + /** + * Get tier price expression for table + * + * @param $tableAlias + * @param \Zend_Db_Expr $priceExpression + * @return \Zend_Db_Expr + */ private function getTierPriceExpressionForTable($tableAlias, \Zend_Db_Expr $priceExpression): \Zend_Db_Expr { return $this->getConnection()->getCheckSql( @@ -291,6 +304,8 @@ private function getTierPriceExpressionForTable($tableAlias, \Zend_Db_Expr $pric } /** + * Get connection + * * return \Magento\Framework\DB\Adapter\AdapterInterface * @throws \DomainException */ @@ -304,6 +319,8 @@ private function getConnection(): \Magento\Framework\DB\Adapter\AdapterInterface } /** + * Get table + * * @param string $tableName * @return string */ From 14f36d627de155a824f4b64c2bff43db97620040 Mon Sep 17 00:00:00 2001 From: NamrataChangani <namratavora301@gmail.com> Date: Tue, 19 Jun 2018 12:06:53 +0530 Subject: [PATCH 176/206] Correct spelling mistakes in Model and library files. --- .../Magento/Catalog/Model/Product/Gallery/Processor.php | 6 +++--- lib/internal/Magento/Framework/Code/GeneratedFiles.php | 2 +- lib/web/modernizr/modernizr.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Product/Gallery/Processor.php b/app/code/Magento/Catalog/Model/Product/Gallery/Processor.php index ac2a01f9c5a84..73d0f1fa6795b 100644 --- a/app/code/Magento/Catalog/Model/Product/Gallery/Processor.php +++ b/app/code/Magento/Catalog/Model/Product/Gallery/Processor.php @@ -340,9 +340,9 @@ public function setMediaAttribute(\Magento\Catalog\Model\Product $product, $medi $mediaAttributeCodes = $this->mediaConfig->getMediaAttributeCodes(); if (is_array($mediaAttribute)) { - foreach ($mediaAttribute as $atttribute) { - if (in_array($atttribute, $mediaAttributeCodes)) { - $product->setData($atttribute, $value); + foreach ($mediaAttribute as $attribute) { + if (in_array($attribute, $mediaAttributeCodes)) { + $product->setData($attribute, $value); } } } elseif (in_array($mediaAttribute, $mediaAttributeCodes)) { diff --git a/lib/internal/Magento/Framework/Code/GeneratedFiles.php b/lib/internal/Magento/Framework/Code/GeneratedFiles.php index f660b3d698293..bc44b361c57ea 100644 --- a/lib/internal/Magento/Framework/Code/GeneratedFiles.php +++ b/lib/internal/Magento/Framework/Code/GeneratedFiles.php @@ -180,7 +180,7 @@ private function disableAllCacheTypes() } /** - * Enables apppropriate cache types in app/etc/env.php based on the passed in $cacheTypes array + * Enables appropriate cache types in app/etc/env.php based on the passed in $cacheTypes array * TODO: to be removed in scope of MAGETWO-53476 * * @param string[] $cacheTypes diff --git a/lib/web/modernizr/modernizr.js b/lib/web/modernizr/modernizr.js index 9b4f68aaaaaa9..70443420eeca7 100644 --- a/lib/web/modernizr/modernizr.js +++ b/lib/web/modernizr/modernizr.js @@ -169,7 +169,7 @@ window.Modernizr = (function( window, document, undefined ) { // isEventSupported determines if a given element supports the given event // kangax.github.com/iseventsupported/ // - // The following results are known incorrects: + // The following results are known incorrect: // Modernizr.hasEvent("webkitTransitionEnd", elem) // false negative // Modernizr.hasEvent("textInput") // in Webkit. github.com/Modernizr/Modernizr/issues/333 // ... From 594203c52e82ac26fa86c09d5f3f9ab36ec20492 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov <sidolov@magento.com> Date: Tue, 19 Jun 2018 10:56:46 +0300 Subject: [PATCH 177/206] Fixed according to Backward compatible development guide --- app/code/Magento/Sales/Model/Order.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Sales/Model/Order.php b/app/code/Magento/Sales/Model/Order.php index 4693e0dd74df4..6de0fe4459fa6 100644 --- a/app/code/Magento/Sales/Model/Order.php +++ b/app/code/Magento/Sales/Model/Order.php @@ -1008,8 +1008,24 @@ public function addStatusToHistory($status, $comment = '', $isCustomerNotified = * @param string $comment * @param bool|string $status * @return OrderStatusHistoryInterface + * @deprecated + * @see addCommentToStatusHistory */ - public function addStatusHistoryComment($comment, $status = false, $isVisibleOnFront = false) + public function addStatusHistoryComment($comment, $status = false) + { + return $this->addCommentToStatusHistory($comment, $status, false); + } + + /** + * Add a comment to order status history + * Different or default status may be specified + * + * @param string $comment + * @param bool|string $status + * @param bool $isVisibleOnFront + * @return OrderStatusHistoryInterface + */ + public function addCommentToStatusHistory($comment, $status = false, $isVisibleOnFront = false) { if (false === $status) { $status = $this->getStatus(); From eb3a6d25689e9de5b30503f19a6ce9783494ce69 Mon Sep 17 00:00:00 2001 From: NamrataChangani <namratavora301@gmail.com> Date: Tue, 19 Jun 2018 17:29:03 +0530 Subject: [PATCH 178/206] Removed double occurrence of 'it' from sentences. --- lib/web/tiny_mce/classes/ControlManager.js | 2 +- lib/web/tiny_mce/classes/html/Styles.js | 2 +- lib/web/tiny_mce/tiny_mce_jquery_src.js | 2 +- lib/web/tiny_mce/tiny_mce_prototype_src.js | 2 +- lib/web/tiny_mce/tiny_mce_src.js | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/web/tiny_mce/classes/ControlManager.js b/lib/web/tiny_mce/classes/ControlManager.js index 51fa311525862..784042988c0ef 100644 --- a/lib/web/tiny_mce/classes/ControlManager.js +++ b/lib/web/tiny_mce/classes/ControlManager.js @@ -45,7 +45,7 @@ }, /** - * Returns a control by id or undefined it it wasn't found. + * Returns a control by id or undefined it wasn't found. * * @method get * @param {String} id Control instance name. diff --git a/lib/web/tiny_mce/classes/html/Styles.js b/lib/web/tiny_mce/classes/html/Styles.js index edf1e13a4e3bc..60c5565d72a99 100644 --- a/lib/web/tiny_mce/classes/html/Styles.js +++ b/lib/web/tiny_mce/classes/html/Styles.js @@ -79,7 +79,7 @@ tinymce.html.Styles = function(settings, schema) { function compress(prefix, suffix) { var top, right, bottom, left; - // Get values and check it it needs compressing + // Get values and check it needs compressing top = styles[prefix + '-top' + suffix]; if (!top) return; diff --git a/lib/web/tiny_mce/tiny_mce_jquery_src.js b/lib/web/tiny_mce/tiny_mce_jquery_src.js index b16d0e3ffdbb4..20c0bbd33e5bb 100644 --- a/lib/web/tiny_mce/tiny_mce_jquery_src.js +++ b/lib/web/tiny_mce/tiny_mce_jquery_src.js @@ -1731,7 +1731,7 @@ tinymce.html.Styles = function(settings, schema) { function compress(prefix, suffix) { var top, right, bottom, left; - // Get values and check it it needs compressing + // Get values and check it needs compressing top = styles[prefix + '-top' + suffix]; if (!top) return; diff --git a/lib/web/tiny_mce/tiny_mce_prototype_src.js b/lib/web/tiny_mce/tiny_mce_prototype_src.js index 1c7b76cf75c8b..62ff4b362c18a 100644 --- a/lib/web/tiny_mce/tiny_mce_prototype_src.js +++ b/lib/web/tiny_mce/tiny_mce_prototype_src.js @@ -1483,7 +1483,7 @@ tinymce.html.Styles = function(settings, schema) { function compress(prefix, suffix) { var top, right, bottom, left; - // Get values and check it it needs compressing + // Get values and check it needs compressing top = styles[prefix + '-top' + suffix]; if (!top) return; diff --git a/lib/web/tiny_mce/tiny_mce_src.js b/lib/web/tiny_mce/tiny_mce_src.js index a1ce5c5d8c32f..7deeee9de6a26 100644 --- a/lib/web/tiny_mce/tiny_mce_src.js +++ b/lib/web/tiny_mce/tiny_mce_src.js @@ -1456,7 +1456,7 @@ tinymce.html.Styles = function(settings, schema) { function compress(prefix, suffix) { var top, right, bottom, left; - // Get values and check it it needs compressing + // Get values and check it needs compressing top = styles[prefix + '-top' + suffix]; if (!top) return; From 139c0e14a500c596196f8be1a06012c294be11db Mon Sep 17 00:00:00 2001 From: NamrataChangani <namratavora301@gmail.com> Date: Tue, 19 Jun 2018 17:33:49 +0530 Subject: [PATCH 179/206] Correct grammer mistakes in sentences. --- lib/web/tiny_mce/plugins/autosave/editor_plugin_src.js | 4 ++-- setup/src/Magento/Setup/Fixtures/OrdersFixture.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/web/tiny_mce/plugins/autosave/editor_plugin_src.js b/lib/web/tiny_mce/plugins/autosave/editor_plugin_src.js index 31bcb419fb178..2d369e61810f3 100644 --- a/lib/web/tiny_mce/plugins/autosave/editor_plugin_src.js +++ b/lib/web/tiny_mce/plugins/autosave/editor_plugin_src.js @@ -20,14 +20,14 @@ * 1. localStorage - A new feature of HTML 5, localStorage can store megabytes of data per domain * on the client computer. Data stored in the localStorage area has no expiration date, so we must * manage expiring the data ourselves. localStorage is fully supported by IE8, and it is supposed - * to be working in Firefox 3 and Safari 3.2, but in reality is is flaky in those browsers. As + * to be working in Firefox 3 and Safari 3.2, but in reality it is flaky in those browsers. As * HTML 5 gets wider support, the AutoSave plugin will use it automatically. In Windows Vista/7, * localStorage is stored in the following folder: * C:\Users\[username]\AppData\Local\Microsoft\Internet Explorer\DOMStore\[tempFolder] * * 2. sessionStorage - A new feature of HTML 5, sessionStorage works similarly to localStorage, * except it is designed to expire after a certain amount of time. Because the specification - * around expiration date/time is very loosely-described, it is preferrable to use locaStorage and + * around expiration date/time is very loosely-described, it is preferable to use locaStorage and * manage the expiration ourselves. sessionStorage has similar storage characteristics to * localStorage, although it seems to have better support by Firefox 3 at the moment. (That will * certainly change as Firefox continues getting better at HTML 5 adoption.) diff --git a/setup/src/Magento/Setup/Fixtures/OrdersFixture.php b/setup/src/Magento/Setup/Fixtures/OrdersFixture.php index 1acad6dbc1787..9fbec3b3741b2 100644 --- a/setup/src/Magento/Setup/Fixtures/OrdersFixture.php +++ b/setup/src/Magento/Setup/Fixtures/OrdersFixture.php @@ -14,7 +14,7 @@ * Optionally generates inactive quotes for generated orders. * * Support the following format: - * <!-- Is is nescessary to enable quotes for orders --> + * <!-- It is necessary to enable quotes for orders --> * <order_quotes_enable>{bool}</order_quotes_enable> * * <!-- Min number of simple products per each order --> From 2c28ddca8c8fffd62512a371265e79aa5071efc7 Mon Sep 17 00:00:00 2001 From: NamrataChangani <namratavora301@gmail.com> Date: Tue, 19 Jun 2018 17:41:37 +0530 Subject: [PATCH 180/206] Fixed wrong input string into csv of Magento_Paypal module for en_US locale. --- app/code/Magento/Paypal/i18n/en_US.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Paypal/i18n/en_US.csv b/app/code/Magento/Paypal/i18n/en_US.csv index 797edbf8bfa1e..2a1a6bbb48ef2 100644 --- a/app/code/Magento/Paypal/i18n/en_US.csv +++ b/app/code/Magento/Paypal/i18n/en_US.csv @@ -2,7 +2,7 @@ <a href=""https:/financing.paypal.com/ppfinportal/content/whyUseFinancing"" target=""_blank"">Why Advertise Financing?</a><br/> <strong>Give your sales a boost when you advertise financing.</strong><br/>PayPal helps turn browsers into buyers with financing from PayPal Credit®. Your customers have more time to pay, while you get paid up front – at no additional cost to you. - Use PayPal’ s free banner ads that let you advertise PayPal Credit® financing as a payment option when your customers check out with PayPal. + Use PayPal’s free banner ads that let you advertise PayPal Credit® financing as a payment option when your customers check out with PayPal. The PayPal Advertising Program has been shown to generate additional purchases as well as increase consumer's average purchase sizes by 15% or more. <a href=""https:/financing.paypal.com/ppfinportal/content/forrester"" target=""_blank"">See Details</a>. "," From 3ca26ebc4e759ecb49a7faf48d57992b896c59a4 Mon Sep 17 00:00:00 2001 From: vgelani <vishalgelani99@gmail.com> Date: Tue, 19 Jun 2018 19:10:19 +0530 Subject: [PATCH 181/206] Fixed typo error --- app/code/Magento/Paypal/view/frontend/web/order-review.js | 4 ++-- lib/web/modernizr/modernizr.js | 2 +- lib/web/tiny_mce/classes/Formatter.js | 2 +- lib/web/tiny_mce/classes/dom/DOMUtils.js | 2 +- lib/web/tiny_mce/tiny_mce_jquery_src.js | 2 +- lib/web/tiny_mce/tiny_mce_prototype_src.js | 2 +- lib/web/tiny_mce/tiny_mce_src.js | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/code/Magento/Paypal/view/frontend/web/order-review.js b/app/code/Magento/Paypal/view/frontend/web/order-review.js index 566c9c8da06dc..2155b52f4081b 100644 --- a/app/code/Magento/Paypal/view/frontend/web/order-review.js +++ b/app/code/Magento/Paypal/view/frontend/web/order-review.js @@ -108,7 +108,7 @@ define([ }, /** - * trigger change for the update of shippping methods from server + * trigger change for the update of shipping methods from server */ _updateOrderHandler: function () { $(this.options.shippingSelector).trigger('change'); @@ -297,7 +297,7 @@ define([ this._updateOrderSubmit(true); this._toggleButton(this.options.updateOrderSelector, true); - // form data and callBack updated based on the shippping Form element + // form data and callBack updated based on the shipping Form element if (this.isShippingSubmitForm) { formData = $(this.options.shippingSubmitFormSelector).serialize() + '&isAjax=true'; diff --git a/lib/web/modernizr/modernizr.js b/lib/web/modernizr/modernizr.js index 2de01f8a78126..d7ddc86f63cae 100644 --- a/lib/web/modernizr/modernizr.js +++ b/lib/web/modernizr/modernizr.js @@ -910,7 +910,7 @@ window.Modernizr = (function( window, document, undefined ) { bool = inputElem.checkValidity && inputElem.checkValidity() === false; } else { - // If the upgraded input compontent rejects the :) text, we got a winner + // If the upgraded input component rejects the :) text, we got a winner bool = inputElem.value != smile; } } diff --git a/lib/web/tiny_mce/classes/Formatter.js b/lib/web/tiny_mce/classes/Formatter.js index 0cbca75ec504b..5f05d3f3015ad 100644 --- a/lib/web/tiny_mce/classes/Formatter.js +++ b/lib/web/tiny_mce/classes/Formatter.js @@ -445,7 +445,7 @@ childCount = getChildCount(node); // Remove empty nodes but only if there is multiple wrappers and they are not block - // elements so never remove single <h1></h1> since that would remove the currrent empty block element where the caret is at + // elements so never remove single <h1></h1> since that would remove the current empty block element where the caret is at if ((newWrappers.length > 1 || !isBlock(node)) && childCount === 0) { dom.remove(node, 1); return; diff --git a/lib/web/tiny_mce/classes/dom/DOMUtils.js b/lib/web/tiny_mce/classes/dom/DOMUtils.js index 783dbea1cacb9..eb8b4b7ab5d78 100644 --- a/lib/web/tiny_mce/classes/dom/DOMUtils.js +++ b/lib/web/tiny_mce/classes/dom/DOMUtils.js @@ -1106,7 +1106,7 @@ /** * Returns a unique id. This can be useful when generating elements on the fly. - * This method will not check if the element allready exists. + * This method will not check if the element already exists. * * @method uniqueId * @param {String} p Optional prefix to add infront of all ids defaults to "mce_". diff --git a/lib/web/tiny_mce/tiny_mce_jquery_src.js b/lib/web/tiny_mce/tiny_mce_jquery_src.js index b16d0e3ffdbb4..2daf1620a918e 100644 --- a/lib/web/tiny_mce/tiny_mce_jquery_src.js +++ b/lib/web/tiny_mce/tiny_mce_jquery_src.js @@ -14451,7 +14451,7 @@ tinymce.create('tinymce.ui.Toolbar:tinymce.ui.Container', { childCount = getChildCount(node); // Remove empty nodes but only if there is multiple wrappers and they are not block - // elements so never remove single <h1></h1> since that would remove the currrent empty block element where the caret is at + // elements so never remove single <h1></h1> since that would remove the current empty block element where the caret is at if ((newWrappers.length > 1 || !isBlock(node)) && childCount === 0) { dom.remove(node, 1); return; diff --git a/lib/web/tiny_mce/tiny_mce_prototype_src.js b/lib/web/tiny_mce/tiny_mce_prototype_src.js index 1c7b76cf75c8b..44b3010b0adfd 100644 --- a/lib/web/tiny_mce/tiny_mce_prototype_src.js +++ b/lib/web/tiny_mce/tiny_mce_prototype_src.js @@ -15301,7 +15301,7 @@ tinymce.create('tinymce.ui.Toolbar:tinymce.ui.Container', { childCount = getChildCount(node); // Remove empty nodes but only if there is multiple wrappers and they are not block - // elements so never remove single <h1></h1> since that would remove the currrent empty block element where the caret is at + // elements so never remove single <h1></h1> since that would remove the current empty block element where the caret is at if ((newWrappers.length > 1 || !isBlock(node)) && childCount === 0) { dom.remove(node, 1); return; diff --git a/lib/web/tiny_mce/tiny_mce_src.js b/lib/web/tiny_mce/tiny_mce_src.js index a1ce5c5d8c32f..46ba27e60f419 100644 --- a/lib/web/tiny_mce/tiny_mce_src.js +++ b/lib/web/tiny_mce/tiny_mce_src.js @@ -15275,7 +15275,7 @@ tinymce.create('tinymce.ui.Toolbar:tinymce.ui.Container', { childCount = getChildCount(node); // Remove empty nodes but only if there is multiple wrappers and they are not block - // elements so never remove single <h1></h1> since that would remove the currrent empty block element where the caret is at + // elements so never remove single <h1></h1> since that would remove the current empty block element where the caret is at if ((newWrappers.length > 1 || !isBlock(node)) && childCount === 0) { dom.remove(node, 1); return; From f4994e76f12c49645528a3b504343b29da87b3c3 Mon Sep 17 00:00:00 2001 From: Andrii Voskoboinikov <avoskoboinikov@magento.com> Date: Tue, 19 Jun 2018 14:23:47 +0300 Subject: [PATCH 182/206] MAGETWO-64467: [Indexer optimizations] Tables sharding / segmentation for price indexer --- .../CustomerGroupDimensionProvider.php | 3 +- .../Indexer/WebsiteDimensionProvider.php | 3 +- .../Indexer/MultiDimensionProvider.php | 94 +++++-- .../Test/Unit/MultiDimensionProviderTest.php | 255 ++++++++++++++++++ 4 files changed, 337 insertions(+), 18 deletions(-) create mode 100644 lib/internal/Magento/Framework/Indexer/Test/Unit/MultiDimensionProviderTest.php diff --git a/app/code/Magento/Customer/Model/Indexer/CustomerGroupDimensionProvider.php b/app/code/Magento/Customer/Model/Indexer/CustomerGroupDimensionProvider.php index d1797923a7a33..7c224d29f1dc1 100644 --- a/app/code/Magento/Customer/Model/Indexer/CustomerGroupDimensionProvider.php +++ b/app/code/Magento/Customer/Model/Indexer/CustomerGroupDimensionProvider.php @@ -52,7 +52,8 @@ public function getIterator(): \Traversable private function getCustomerGroups(): array { if ($this->customerGroupsDataIterator === null) { - $this->customerGroupsDataIterator = $this->collectionFactory->create()->getAllIds(); + $customerGroups = $this->collectionFactory->create()->getAllIds(); + $this->customerGroupsDataIterator = is_array($customerGroups) ? $customerGroups : []; } return $this->customerGroupsDataIterator; diff --git a/app/code/Magento/Store/Model/Indexer/WebsiteDimensionProvider.php b/app/code/Magento/Store/Model/Indexer/WebsiteDimensionProvider.php index 4aa0768fbaa98..302c2f828367a 100644 --- a/app/code/Magento/Store/Model/Indexer/WebsiteDimensionProvider.php +++ b/app/code/Magento/Store/Model/Indexer/WebsiteDimensionProvider.php @@ -61,9 +61,10 @@ public function getIterator(): \Traversable private function getWebsites(): array { if ($this->websitesDataIterator === null) { - $this->websitesDataIterator = $this->collectionFactory->create() + $websites = $this->collectionFactory->create() ->addFieldToFilter('code', ['neq' => Store::ADMIN_CODE]) ->getAllIds(); + $this->websitesDataIterator = is_array($websites) ? $websites : []; } return $this->websitesDataIterator; diff --git a/lib/internal/Magento/Framework/Indexer/MultiDimensionProvider.php b/lib/internal/Magento/Framework/Indexer/MultiDimensionProvider.php index 6dee6cd01d8d1..062945760acfa 100644 --- a/lib/internal/Magento/Framework/Indexer/MultiDimensionProvider.php +++ b/lib/internal/Magento/Framework/Indexer/MultiDimensionProvider.php @@ -34,37 +34,47 @@ public function __construct(array $dimensionProviders = []) foreach ($dimensionProviders as $dimensionDataProvider) { $this->addDimensionDataProvider($dimensionDataProvider); } - foreach ($this->dimensionsDataProviders as $dimensionDataProvider) { - $this->dimensionsIterators[] = $dimensionDataProvider->getIterator(); - } } /** + * Returns generator that will return multiplied dimensions on each iteration + * * @return \Traversable|Dimension[][] + * @throws \LogicException */ public function getIterator(): \Traversable { - if (!$this->dimensionsIterators) { + // just return empty array if we have no dimension providers to iterate over + if ($this->dimensionsProvidersCount === 0) { yield []; - } else { - while (true) { - $dimensions = $this->getCurrentDimension(); - if (!$dimensions) { - break; - } - yield $dimensions; - $this->setNextDimension(); - } + return; + } + + // this recreates iterators for dimension so we can iterate over them + $this->rewind(); + + // if at leas one dimension provider has no dimensions to return we can't multiple dimension at all + if (!$this->hasCurrentDimension()) { + throw new \LogicException('Can`t multiple dimensions because some of them are empty.'); + } + + // return dimensions until all iterators become invalid + while ($this->hasCurrentDimension()) { + yield $this->getCurrentDimension(); + $this->setNextDimension(); } } + /** + * Return all dimensions for current state of each dimension provider + * + * @return array + */ private function getCurrentDimension(): array { $dimensions = []; + foreach ($this->dimensionsIterators as $dimensionIterator) { - if (!$dimensionIterator->valid()) { - return []; - } /** @var Dimension $dimension */ $dimension = $dimensionIterator->current(); $dimensions[$dimension->getName()] = $dimension; @@ -73,6 +83,12 @@ private function getCurrentDimension(): array return $dimensions; } + /** + * Iterates over dimension iterators one by one starting from right to left + * This approach emulates iterations over X nested foreach loops e.g.: + * + * @return void + */ private function setNextDimension() { $this->dimensionsIterators[$this->dimensionsProvidersCount - 1]->next(); @@ -85,6 +101,52 @@ private function setNextDimension() } } + /** + * Recreates iterators so all MultiDimensionProvider can be iterated again + * + * @return void + */ + private function rewind() + { + $this->dimensionsIterators = []; + + foreach ($this->dimensionsDataProviders as $dimensionDataProvider) { + $this->dimensionsIterators[] = $dimensionDataProvider->getIterator(); + } + } + + /** + * Check if all dimension iterators are in valid state + * + * If at least one of dimension iterators is invalid before very first iteration - we assume + * that dimension provider has no dimensions at all, which means we can't multiple all dimensions + * + * If all dimension iterators became invalid - we assume that multiplication is already done + * + * @return bool + */ + private function hasCurrentDimension(): bool + { + $valid = true; + + foreach ($this->dimensionsIterators as $dimensionsIterator) { + // if at least one data provider is invalid at this stage - all generator is invalid + if (!$dimensionsIterator->valid()) { + return false; + } + } + + // generator is valid only when all data providers are valid + return $valid; + } + + /** + * Collects dimension data providers + * This was done via separate method to ensure that each provider has required interface + * + * @param DimensionProviderInterface $dimensionDataProvider + * @return void + */ private function addDimensionDataProvider(DimensionProviderInterface $dimensionDataProvider) { $this->dimensionsDataProviders[] = $dimensionDataProvider; diff --git a/lib/internal/Magento/Framework/Indexer/Test/Unit/MultiDimensionProviderTest.php b/lib/internal/Magento/Framework/Indexer/Test/Unit/MultiDimensionProviderTest.php new file mode 100644 index 0000000000000..be4d168b108bc --- /dev/null +++ b/lib/internal/Magento/Framework/Indexer/Test/Unit/MultiDimensionProviderTest.php @@ -0,0 +1,255 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Framework\Indexer\Test\Unit; + +use \Magento\Framework\Indexer\MultiDimensionProvider; +use \Magento\Framework\Indexer\DimensionProviderInterface; +use \Magento\Framework\Indexer\Dimension; + +class MultiDimensionProviderTest extends \PHPUnit\Framework\TestCase +{ + /** + * tests that MultiDimensionProvider will return [[]] in case it has no dimension providers + */ + public function testWithNoDataProviders() + { + // prepare expected dimensions + $expectedDimensions = [[]]; + + // collect actual dimensions + $multiDimensionProvider = new MultiDimensionProvider([]); + + $actualDimensions = []; + foreach ($multiDimensionProvider as $dimension) { + $actualDimensions[] = $dimension; + } + + $this->assertSame($expectedDimensions, $actualDimensions); + } + + /** + * tests multiplication of dimensions from different providers + * + * e.g we have three dimensions: + * - dimension X with values (x1, x2) + * - dimension Y with values (y1, y2, y3) + * - dimension Z with values (z1, z2) + * + * the multiplication result set will be: + * x1-y1-z1 + * x1-y1-z2 + * x1-y2-z1 + * x1-y2-z2 + * x1-y3-z1 + * x1-y3-z2 + * x2-y1-z1 + * x2-y1-z2 + * x2-y2-z1 + * x2-y2-z2 + * x2-y3-z1 + * x2-y3-z2 + */ + public function testWithMultipleDataProviders() + { + // prepare expected dimensions + $dimensionXData = [ + $this->getDimensionMock('x', 1), + $this->getDimensionMock('x', 2), + $this->getDimensionMock('x', 3), + ]; + + $dimensionYData = [ + $this->getDimensionMock('y', 1), + $this->getDimensionMock('y', 2), + $this->getDimensionMock('y', 3), + $this->getDimensionMock('y', 4), + $this->getDimensionMock('y', 5), + ]; + + $dimensionZData = [ + $this->getDimensionMock('z', 1), + $this->getDimensionMock('z', 2), + ]; + + $expectedDimensions = []; + + foreach ($dimensionXData as $dimensionX) { + foreach ($dimensionYData as $dimensionY) { + foreach ($dimensionZData as $dimensionZ) { + $expectedDimensions[] = [ + $dimensionX->getName() => $dimensionX, + $dimensionY->getName() => $dimensionY, + $dimensionZ->getName() => $dimensionZ, + ]; + } + } + } + + // collect actual dimensions + $multiDimensionProvider = new MultiDimensionProvider( + [ + $this->getDimensionProviderMock($dimensionXData), + $this->getDimensionProviderMock($dimensionYData), + $this->getDimensionProviderMock($dimensionZData), + ] + ); + + $actualDimensions = []; + foreach ($multiDimensionProvider as $dimension) { + $actualDimensions[] = $dimension; + } + + $this->assertSame($expectedDimensions, $actualDimensions); + } + + /** + * tests that the same MultiDimensionProvider can be used in foreach multiple times without creating again + */ + public function testMultiDimensionProviderIsReIterable() + { + // prepare expected dimensions + $dimensionXData = [ + $this->getDimensionMock('x', 1), + $this->getDimensionMock('x', 2), + $this->getDimensionMock('x', 3), + ]; + + $dimensionZData = [ + $this->getDimensionMock('z', 1), + $this->getDimensionMock('z', 2), + ]; + + // collect actual dimensions + $multiDimensionProvider = new MultiDimensionProvider( + [ + $this->getDimensionProviderMock($dimensionXData), + $this->getDimensionProviderMock($dimensionZData), + ] + ); + + // first iteration + $actualDimensions1st = []; + foreach ($multiDimensionProvider as $dimension) { + $actualDimensions1st[] = $dimension; + } + + // second iteration + $actualDimensions2nd = []; + foreach ($multiDimensionProvider as $dimension) { + $actualDimensions2nd[] = $dimension; + } + + $this->assertSame($actualDimensions1st, $actualDimensions2nd); + } + + /** + * tests that MultiDimensionProvider will throw exception when all dimension providers has nothing to return + * + * @expectedException \LogicException + * @expectedExceptionMessage Can`t multiple dimensions because some of them are empty. + */ + public function testMultiDimensionProviderWithEmptyDataProvider() + { + // collect actual dimensions + $multiDimensionProvider = new MultiDimensionProvider( + [ + $this->getDimensionProviderMock([]), + $this->getDimensionProviderMock([]), + ] + ); + + $actualDimensions = []; + foreach ($multiDimensionProvider as $dimension) { + $actualDimensions[] = $dimension; + } + } + + /** + * tests that MultiDimensionProvider will throw exception when one dimension providers has nothing to return + * + * @expectedException \LogicException + * @expectedExceptionMessage Can`t multiple dimensions because some of them are empty. + */ + public function testMultiDimensionProviderWithMixedDataProvider() + { + + // prepare expected dimensions + $dimensionXData = [ + $this->getDimensionMock('x', 1), + $this->getDimensionMock('x', 2), + $this->getDimensionMock('x', 3), + ]; + + $dimensionYData = [ + $this->getDimensionMock('y', 1), + $this->getDimensionMock('y', 2), + $this->getDimensionMock('y', 3), + $this->getDimensionMock('y', 4), + $this->getDimensionMock('y', 5), + ]; + + $dimensionZData = []; + + // collect actual dimensions + $multiDimensionProvider = new MultiDimensionProvider( + [ + $this->getDimensionProviderMock($dimensionXData), + $this->getDimensionProviderMock($dimensionYData), + $this->getDimensionProviderMock($dimensionZData), + ] + ); + + $actualDimensions = []; + foreach ($multiDimensionProvider as $dimension) { + $actualDimensions[] = $dimension; + } + } + + private function getDimensionProviderMock($dimensions) + { + $dimensionProviderMock = $this->getMockBuilder(DimensionProviderInterface::class) + ->disableOriginalConstructor() + ->disableOriginalClone() + ->disableArgumentCloning() + ->disallowMockingUnknownTypes() + ->setMethods(['getIterator']) + ->getMockForAbstractClass(); + + $dimensionProviderMock->expects($this->any()) + ->method('getIterator') + ->will( + $this->returnCallback( + function () use ($dimensions) { + return \SplFixedArray::fromArray($dimensions); + } + ) + ); + + return $dimensionProviderMock; + } + + private function getDimensionMock(string $name, string $value) + { + $dimensionMock = $this->getMockBuilder(Dimension::class) + ->disableOriginalConstructor() + ->disableOriginalClone() + ->disableArgumentCloning() + ->disallowMockingUnknownTypes() + ->setMethods(['getName', 'getValue']) + ->getMock(); + + $dimensionMock->expects($this->any()) + ->method('getName') + ->willReturn($name); + + $dimensionMock->expects($this->any()) + ->method('getValue') + ->willReturn($value); + + return $dimensionMock; + } +} From 74ab8c33ae890af47e19a1ef499342f484464904 Mon Sep 17 00:00:00 2001 From: IvanPletnyov <ivan.pletnyov@transoftgroup.com> Date: Tue, 19 Jun 2018 16:58:26 +0300 Subject: [PATCH 183/206] ENGCOM-1703: Move breadcrumb json configuration to viewmodel (fix badly json) --- .../Catalog/ViewModel/Product/Breadcrumbs.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Catalog/ViewModel/Product/Breadcrumbs.php b/app/code/Magento/Catalog/ViewModel/Product/Breadcrumbs.php index 2b5665d20f304..3dc1c14f20034 100644 --- a/app/code/Magento/Catalog/ViewModel/Product/Breadcrumbs.php +++ b/app/code/Magento/Catalog/ViewModel/Product/Breadcrumbs.php @@ -9,6 +9,7 @@ use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\App\ObjectManager; use Magento\Framework\DataObject; +use Magento\Framework\Escaper; use Magento\Framework\Serialize\Serializer\Json; use Magento\Framework\View\Element\Block\ArgumentInterface; @@ -33,22 +34,29 @@ class Breadcrumbs extends DataObject implements ArgumentInterface * @var Json */ private $json; + /** + * @var Escaper + */ + private $escaper; /** * @param Data $catalogData * @param ScopeConfigInterface $scopeConfig * @param Json $json + * @param Escaper $escaper */ public function __construct( Data $catalogData, ScopeConfigInterface $scopeConfig, - Json $json = null + Json $json = null, + Escaper $escaper = null ) { parent::__construct(); $this->catalogData = $catalogData; $this->scopeConfig = $scopeConfig; $this->json = $json ?: ObjectManager::getInstance()->get(Json::class); + $this->escaper = $escaper ?: ObjectManager::getInstance()->get(Escaper::class); } /** @@ -98,9 +106,9 @@ public function getJsonConfiguration() { return $this->json->serialize([ 'breadcrumbs' => [ - 'categoryUrlSuffix' => $this->getCategoryUrlSuffix(), + 'categoryUrlSuffix' => $this->escaper->escapeHtml($this->getCategoryUrlSuffix()), 'userCategoryPathInUrl' => (int)$this->isCategoryUsedInProductUrl(), - 'product' => $this->getProductName() + 'product' => $this->escaper->escapeHtml($this->getProductName()) ] ]); } From 6345bbd5d625b9c4d73da59256d46fd9dfe41ba3 Mon Sep 17 00:00:00 2001 From: itaymesh <itay@studioraz.co.il> Date: Tue, 19 Jun 2018 19:49:31 +0300 Subject: [PATCH 184/206] Update Israeli ZIP code mask, 7 digits instead of 5 ,according to the Israeli postal office --- app/code/Magento/Directory/etc/zip_codes.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Directory/etc/zip_codes.xml b/app/code/Magento/Directory/etc/zip_codes.xml index 59de895927dbe..e45fccd9c3f36 100644 --- a/app/code/Magento/Directory/etc/zip_codes.xml +++ b/app/code/Magento/Directory/etc/zip_codes.xml @@ -196,7 +196,7 @@ </zip> <zip countryCode="IL"> <codes> - <code id="pattern_1" active="true" example="12345">^[0-9]{5}$</code> + <code id="pattern_1" active="true" example="6687865">^[0-9]{7}$</code> </codes> </zip> <zip countryCode="IT"> From 30696ce06ce2951cec614f51611c484a70dd8c41 Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov <slopukhov@magento.com> Date: Wed, 20 Jun 2018 09:14:23 +0300 Subject: [PATCH 185/206] MAGETWO-91820: Stabilize builds --- .../Indexer/Category/Product/TableMaintainer.php | 8 ++++++-- .../Model/Indexer/Product/Price/AbstractAction.php | 11 +++++++++++ .../Model/Indexer/Product/Price/TableMaintainer.php | 8 ++++++-- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Product/TableMaintainer.php b/app/code/Magento/Catalog/Model/Indexer/Category/Product/TableMaintainer.php index 341b84b425fe8..2d8c3ba23d5a2 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Category/Product/TableMaintainer.php +++ b/app/code/Magento/Catalog/Model/Indexer/Category/Product/TableMaintainer.php @@ -91,6 +91,8 @@ private function getTable($table) * @param string $newTableName * * @return void + * + * @throws \Zend_Db_Exception */ private function createTable($mainTableName, $newTableName) { @@ -135,6 +137,8 @@ public function getMainTable(int $storeId) * @param $storeId * * @return void + * + * @throws \Zend_Db_Exception */ public function createTablesForStore(int $storeId) { @@ -206,12 +210,12 @@ public function createMainTmpTable(int $storeId) * * @return string * - * @throws \Exception + * @throws \Magento\Framework\Exception\NoSuchEntityException */ public function getMainTmpTable(int $storeId) { if (!isset($this->mainTmpTable[$storeId])) { - throw new \Exception('Temporary table does not exist'); + throw new \Magento\Framework\Exception\NoSuchEntityException('Temporary table does not exist'); } return $this->mainTmpTable[$storeId]; } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php index ac06041a789cb..d2b7fd2fa7144 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php @@ -183,6 +183,9 @@ protected function _syncData(array $processIds = []) * Prepare website current dates table * * @return \Magento\Catalog\Model\Indexer\Product\Price\AbstractAction + * + * @throws \Magento\Framework\Exception\LocalizedException + * @throws \Magento\Framework\Exception\NoSuchEntityException */ protected function _prepareWebsiteDateTable() { @@ -258,6 +261,8 @@ protected function _prepareTierPriceIndex($entityIds = null) * Retrieve price indexers per product type * * @return \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\PriceInterface[] + * + * @throws \Magento\Framework\Exception\LocalizedException */ public function getTypeIndexers() { @@ -292,7 +297,9 @@ public function getTypeIndexers() * * @param string $productTypeId * @return \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\PriceInterface + * * @throws \Magento\Framework\Exception\InputException + * @throws \Magento\Framework\Exception\LocalizedException */ protected function _getIndexer($productTypeId) { @@ -344,6 +351,10 @@ protected function _emptyTable($table) * * @param array $changedIds * @return array Affected ids + * + * @throws \Magento\Framework\Exception\InputException + * @throws \Magento\Framework\Exception\LocalizedException + * @throws \Magento\Framework\Exception\NoSuchEntityException */ protected function _reindexRows($changedIds = []) { diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php index ef06405af1429..86c63dd8bd7b8 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php @@ -103,6 +103,8 @@ private function getTable(string $table): string * @param string $newTableName * * @return void + * + * @throws \Zend_Db_Exception */ private function createTable(string $mainTableName, string $newTableName) { @@ -175,6 +177,8 @@ public function getMainTable(array $dimensions): string * @param Dimension[] $dimensions * * @return void + * + * @throws \Zend_Db_Exception */ public function createTablesForDimensions(array $dimensions) { @@ -260,12 +264,12 @@ public function createMainTmpTable(array $dimensions) * * @return string * - * @throws \Exception + * @throws \Magento\Framework\Exception\NoSuchEntityException */ public function getMainTmpTable(array $dimensions) { if (!isset($this->mainTmpTable[$this->getArrayKeyForTmpTable($dimensions)])) { - throw new \Exception('Temporary table does not exist'); + throw new \Magento\Framework\Exception\NoSuchEntityException('Temporary table does not exist'); } return $this->mainTmpTable[$this->getArrayKeyForTmpTable($dimensions)]; } From 2ab9a8f672193f3e1b8466d90b2ffb349e1a0697 Mon Sep 17 00:00:00 2001 From: Viktor Sevch <svitja@ukr.net> Date: Wed, 20 Jun 2018 10:04:27 +0300 Subject: [PATCH 186/206] MAGETWO-92504: Products sorting in category is reverted to sort by product ID --- .../FunctionalTest/Catalog/Data/ProductData.xml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Data/ProductData.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Data/ProductData.xml index 6f17670b62556..a67e5620dd735 100644 --- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Data/ProductData.xml +++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Data/ProductData.xml @@ -133,4 +133,18 @@ <data key="status">1</data> <requiredEntity type="product_extension_attribute">EavStockItem</requiredEntity> </entity> + <entity name="SimpleProductWithNewFromDate" type="product"> + <data key="sku" unique="suffix">SimpleProduct</data> + <data key="type_id">simple</data> + <data key="attribute_set_id">4</data> + <data key="name" unique="suffix">SimpleProduct</data> + <data key="price">125.00</data> + <data key="visibility">4</data> + <data key="status">1</data> + <data key="quantity">1000</data> + <data key="urlKey" unique="suffix">simpleproduct</data> + <data key="weight">1</data> + <requiredEntity type="product_extension_attribute">EavStockItem</requiredEntity> + <requiredEntity type="custom_attribute_array">ApiProductNewsFromDate</requiredEntity> + </entity> </entities> From 101cd9a75999bd97d1b8bec113d3cc48001bfe2f Mon Sep 17 00:00:00 2001 From: Volodymyr Zaets <vzaets@magento.com> Date: Wed, 20 Jun 2018 15:27:47 +0300 Subject: [PATCH 187/206] Fix Magento/Framework/Code/Test/Unit/Generator/InterfaceGeneratorTest.php test --- .../app/code/Magento/SomeModule/Model/SevenInterface.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/_files/app/code/Magento/SomeModule/Model/SevenInterface.php b/lib/internal/Magento/Framework/Code/Test/Unit/_files/app/code/Magento/SomeModule/Model/SevenInterface.php index efedcb840e973..1d7ffa5127f56 100644 --- a/lib/internal/Magento/Framework/Code/Test/Unit/_files/app/code/Magento/SomeModule/Model/SevenInterface.php +++ b/lib/internal/Magento/Framework/Code/Test/Unit/_files/app/code/Magento/SomeModule/Model/SevenInterface.php @@ -45,9 +45,6 @@ public static function testMethod1(array &$data = array()); */ public function testMethod2($data = 'test_default', $flag = true); - /** - * @return mixed - */ public function testMethod3(); From 37690d3f75fb9f66dc48be5ccf8182d1444b40b3 Mon Sep 17 00:00:00 2001 From: Michail Slabko <mslabko@magento.com> Date: Wed, 20 Jun 2018 16:01:16 +0300 Subject: [PATCH 188/206] MAGETWO-91820: Stabilize builds - MAGETWO-64467 [Indexer optimizations] Tables sharding / segmentation for price indexer --- .../Model/Indexer/Product/Price/TableMaintainer.php | 12 +++++++----- .../Product/Indexer/Price/Query/BaseFinalPrice.php | 7 +++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php index 86c63dd8bd7b8..6efa987a5e973 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php @@ -264,13 +264,15 @@ public function createMainTmpTable(array $dimensions) * * @return string * - * @throws \Magento\Framework\Exception\NoSuchEntityException + * @throws \LogicException */ - public function getMainTmpTable(array $dimensions) + public function getMainTmpTable(array $dimensions): string { - if (!isset($this->mainTmpTable[$this->getArrayKeyForTmpTable($dimensions)])) { - throw new \Magento\Framework\Exception\NoSuchEntityException('Temporary table does not exist'); + $cacheKey = $this->getArrayKeyForTmpTable($dimensions); + if (!isset($this->mainTmpTable[$cacheKey])) { + throw new \LogicException( + sprintf('Temporary table for provided dimensions "%s" does not exist', $cacheKey)); } - return $this->mainTmpTable[$this->getArrayKeyForTmpTable($dimensions)]; + return $this->mainTmpTable[$cacheKey]; } } diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php index 9b6733608e4bc..8428ff3688b28 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php @@ -11,7 +11,6 @@ use Magento\Customer\Model\Indexer\CustomerGroupDimensionProvider; use Magento\Framework\DB\Select; use Magento\Framework\DB\Sql\ColumnValueExpression; -use Magento\Framework\Exception\InputException; use Magento\Framework\Indexer\Dimension; use Magento\Store\Model\Indexer\WebsiteDimensionProvider; @@ -94,7 +93,7 @@ public function __construct( * @param string $productType * @param array $entityIds * @return Select - * @throws \Magento\Framework\Exception\InputException + * @throws \LogicException * @throws \Magento\Framework\Exception\LocalizedException * @throws \Zend_Db_Select_Exception * @SuppressWarnings(PHPMD.ExcessiveMethodLength) @@ -163,8 +162,8 @@ public function getQuery(array $dimensions, string $productType, array $entityId foreach ($dimensions as $dimension) { if (!isset($this->dimensionToFieldMapper[$dimension->getName()])) { - throw new InputException( - __('Provided dimension %1 is not valid for Price indexer', $dimension->getName()) + throw new \LogicException( + 'Provided dimension is not valid for Price indexer: ' . $dimension->getName() ); } $select->where($this->dimensionToFieldMapper[$dimension->getName()] . ' = ?', $dimension->getValue()); From 14ac1770c0c43b10a6cc450e13057f1736268d7f Mon Sep 17 00:00:00 2001 From: Michail Slabko <mslabko@magento.com> Date: Wed, 20 Jun 2018 17:37:52 +0300 Subject: [PATCH 189/206] MAGETWO-91820: Stabilize builds - MAGETWO-64467 [Indexer optimizations] Tables sharding / segmentation for price indexer --- .../Catalog/Model/Indexer/Product/Price/TableMaintainer.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php index 6efa987a5e973..642804e1c9c89 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/TableMaintainer.php @@ -271,7 +271,8 @@ public function getMainTmpTable(array $dimensions): string $cacheKey = $this->getArrayKeyForTmpTable($dimensions); if (!isset($this->mainTmpTable[$cacheKey])) { throw new \LogicException( - sprintf('Temporary table for provided dimensions "%s" does not exist', $cacheKey)); + sprintf('Temporary table for provided dimensions "%s" does not exist', $cacheKey) + ); } return $this->mainTmpTable[$cacheKey]; } From 40e267223e25b64d93e4e2faeec5ce86767eb7bf Mon Sep 17 00:00:00 2001 From: IvanPletnyov <ivan.pletnyov@transoftgroup.com> Date: Wed, 20 Jun 2018 17:58:51 +0300 Subject: [PATCH 190/206] ENGCOM-1703: Move breadcrumb json configuration to viewmode (fix double quotes) --- app/code/Magento/Catalog/ViewModel/Product/Breadcrumbs.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Catalog/ViewModel/Product/Breadcrumbs.php b/app/code/Magento/Catalog/ViewModel/Product/Breadcrumbs.php index 3dc1c14f20034..e897c330b7e0f 100644 --- a/app/code/Magento/Catalog/ViewModel/Product/Breadcrumbs.php +++ b/app/code/Magento/Catalog/ViewModel/Product/Breadcrumbs.php @@ -104,12 +104,12 @@ public function getProductName() */ public function getJsonConfiguration() { - return $this->json->serialize([ + return $this->escaper->escapeHtml($this->json->serialize([ 'breadcrumbs' => [ 'categoryUrlSuffix' => $this->escaper->escapeHtml($this->getCategoryUrlSuffix()), 'userCategoryPathInUrl' => (int)$this->isCategoryUsedInProductUrl(), - 'product' => $this->escaper->escapeHtml($this->getProductName()) + 'product' => $this->getProductName() ] - ]); + ])); } } From 71c540a3c659ee97d6555b2c7973b42d93a03df2 Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi <alugovyi@magento.com> Date: Thu, 21 Jun 2018 11:02:20 +0300 Subject: [PATCH 191/206] MAGETWO-92693: Some improvements on product create|edit page in admin area --- .../Product/Form/Modifier/EavTest.php | 78 +++++++------------ 1 file changed, 26 insertions(+), 52 deletions(-) diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php index eba68eb993efa..bac75a20ea691 100755 --- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php @@ -386,94 +386,68 @@ public function testModifyData() ] ]; - $this->attributeCollectionFactoryMock->expects($this->once()) - ->method('create') + $this->attributeCollectionFactoryMock->expects($this->once())->method('create') ->willReturn($this->attributeCollectionMock); - $this->attributeCollectionMock->expects($this->any()) - ->method('getItems') + $this->attributeCollectionMock->expects($this->any())->method('getItems') ->willReturn([ $this->eavAttributeMock ]); - $this->locatorMock->expects($this->any()) - ->method('getProduct') + $this->locatorMock->expects($this->any())->method('getProduct') ->willReturn($this->productMock); - $this->productMock->expects($this->any()) - ->method('getId') + $this->productMock->expects($this->any())->method('getId') ->willReturn(1); - $this->productMock->expects($this->once()) - ->method('getAttributeSetId') + $this->productMock->expects($this->once())->method('getAttributeSetId') ->willReturn(4); - $this->productMock->expects($this->once()) - ->method('getData') + $this->productMock->expects($this->once())->method('getData') ->with(ProductAttributeInterface::CODE_PRICE)->willReturn('19.9900'); - $this->searchCriteriaBuilderMock->expects($this->any()) - ->method('addFilter') + $this->searchCriteriaBuilderMock->expects($this->any())->method('addFilter') ->willReturnSelf(); - $this->searchCriteriaBuilderMock->expects($this->any()) - ->method('create') + $this->searchCriteriaBuilderMock->expects($this->any())->method('create') ->willReturn($this->searchCriteriaMock); - $this->attributeGroupRepositoryMock->expects($this->any()) - ->method('getList') + $this->attributeGroupRepositoryMock->expects($this->any())->method('getList') ->willReturn($this->searchCriteriaMock); - $this->searchCriteriaMock->expects($this->once()) - ->method('getItems') + $this->searchCriteriaMock->expects($this->once())->method('getItems') ->willReturn([$this->attributeGroupMock]); - $this->sortOrderBuilderMock->expects($this->once()) - ->method('setField') + $this->sortOrderBuilderMock->expects($this->once())->method('setField') ->willReturnSelf(); - $this->sortOrderBuilderMock->expects($this->once()) - ->method('setAscendingDirection') + $this->sortOrderBuilderMock->expects($this->once())->method('setAscendingDirection') ->willReturnSelf(); $dataObjectMock = $this->createMock(\Magento\Framework\Api\AbstractSimpleObject::class); - $this->sortOrderBuilderMock->expects($this->once()) - ->method('create') + $this->sortOrderBuilderMock->expects($this->once())->method('create') ->willReturn($dataObjectMock); - $this->searchCriteriaBuilderMock->expects($this->any()) - ->method('addFilter') + $this->searchCriteriaBuilderMock->expects($this->any())->method('addFilter') ->willReturnSelf(); - $this->searchCriteriaBuilderMock->expects($this->once()) - ->method('addSortOrder') + $this->searchCriteriaBuilderMock->expects($this->once())->method('addSortOrder') ->willReturnSelf(); - $this->searchCriteriaBuilderMock->expects($this->any()) - ->method('create') + $this->searchCriteriaBuilderMock->expects($this->any())->method('create') ->willReturn($this->searchCriteriaMock); - $this->attributeRepositoryMock->expects($this->once()) - ->method('getList') + $this->attributeRepositoryMock->expects($this->once())->method('getList') ->with($this->searchCriteriaMock) ->willReturn($this->searchResultsMock); - $this->eavAttributeMock->expects($this->any()) - ->method('getAttributeGroupCode') + $this->eavAttributeMock->expects($this->any())->method('getAttributeGroupCode') ->willReturn('product-details'); - $this->eavAttributeMock->expects($this->once()) - ->method('getApplyTo') + $this->eavAttributeMock->expects($this->once())->method('getApplyTo') ->willReturn([]); - $this->eavAttributeMock->expects($this->once()) - ->method('getFrontendInput') + $this->eavAttributeMock->expects($this->once())->method('getFrontendInput') ->willReturn('price'); - $this->eavAttributeMock->expects($this->any()) - ->method('getAttributeCode') + $this->eavAttributeMock->expects($this->any())->method('getAttributeCode') ->willReturn(ProductAttributeInterface::CODE_PRICE); - $this->searchResultsMock->expects($this->once()) - ->method('getItems') + $this->searchResultsMock->expects($this->once())->method('getItems') ->willReturn([$this->eavAttributeMock]); - $this->storeMock->expects(($this->once())) - ->method('getBaseCurrencyCode') + $this->storeMock->expects(($this->once()))->method('getBaseCurrencyCode') ->willReturn('en_US'); - $this->storeManagerMock->expects($this->once()) - ->method('getStore') + $this->storeManagerMock->expects($this->once())->method('getStore') ->willReturn($this->storeMock); - $this->currencyMock->expects($this->once()) - ->method('toCurrency') + $this->currencyMock->expects($this->once())->method('toCurrency') ->willReturn('19.99'); - $this->currencyLocaleMock->expects($this->once()) - ->method('getCurrency') + $this->currencyLocaleMock->expects($this->once())->method('getCurrency') ->willReturn($this->currencyMock); $this->assertEquals($sourceData, $this->eav->modifyData([])); From bceb4a34dd49dec602758d1f4517a59a7c74af53 Mon Sep 17 00:00:00 2001 From: Jeroen <jeroen@reachdigital.nl> Date: Thu, 21 Jun 2018 10:48:46 +0200 Subject: [PATCH 192/206] Add UpdatedAtListProvider to NotSyncedDataProvider for invoice grid Invoice grid isn't updated when state is changed. --- app/code/Magento/Sales/etc/di.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Sales/etc/di.xml b/app/code/Magento/Sales/etc/di.xml index 88f91091f81d5..b7721f7795313 100644 --- a/app/code/Magento/Sales/etc/di.xml +++ b/app/code/Magento/Sales/etc/di.xml @@ -120,6 +120,7 @@ <arguments> <argument name="providers" xsi:type="array"> <item name="default" xsi:type="string">Magento\Sales\Model\ResourceModel\Provider\UpdatedIdListProvider</item> + <item name="updated_at" xsi:type="string">Magento\Sales\Model\ResourceModel\Provider\UpdatedAtListProvider</item> </argument> </arguments> </type> From ab4d1c749668497c9e94944701612e7b202e5601 Mon Sep 17 00:00:00 2001 From: Myroslav Dobra <dmaraptor@gmail.com> Date: Thu, 21 Jun 2018 12:57:19 +0300 Subject: [PATCH 193/206] MAGETWO-87721: Custom Options are corruputed when saving product to a different website (fix create bundle product func test) --- .../ActionGroup/VerifyEntitiesInMagentoAdminActionGroup.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/ActionGroup/VerifyEntitiesInMagentoAdminActionGroup.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/ActionGroup/VerifyEntitiesInMagentoAdminActionGroup.xml index 8f8f9a026033e..0a0c55c0a2166 100644 --- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/ActionGroup/VerifyEntitiesInMagentoAdminActionGroup.xml +++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/ActionGroup/VerifyEntitiesInMagentoAdminActionGroup.xml @@ -14,6 +14,8 @@ </arguments> <amOnPage url="{{AdminProductIndexPage.url}}" stepKey="openProductsGridPage"/> <waitForPageLoad stepKey="waitForPageLoad"/> + <click selector="{{AdminProductFiltersSection.FiltersButton}}" stepKey="openFiltersSectionOnProductsPage"/> + <conditionalClick selector="{{AdminProductFiltersSection.clearFiltersButton}}" dependentSelector="{{AdminProductFiltersSection.clearFiltersButton}}" visible="true" stepKey="cleanFiltersIfTheySet"/> <see userInput="{{product.name}}" selector="{{AdminProductGridSection.productNameInNameColumn}}" stepKey="seeBundleProductInProductNameColumn"/> </actionGroup> </actionGroups> From 54ba40921b653f35dc2c5d4249053c55d7a61199 Mon Sep 17 00:00:00 2001 From: IvanPletnyov <ivan.pletnyov@transoftgroup.com> Date: Thu, 21 Jun 2018 13:31:07 +0300 Subject: [PATCH 194/206] ENGCOM-2073: Update Israeli ZIP code mask: 7 digits instead of 5 #16250 (fix test) --- .../Magento/Directory/Model/Country/Postcode/ValidatorTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/integration/testsuite/Magento/Directory/Model/Country/Postcode/ValidatorTest.php b/dev/tests/integration/testsuite/Magento/Directory/Model/Country/Postcode/ValidatorTest.php index ce2f3ebae5538..9d0634645a4c3 100644 --- a/dev/tests/integration/testsuite/Magento/Directory/Model/Country/Postcode/ValidatorTest.php +++ b/dev/tests/integration/testsuite/Magento/Directory/Model/Country/Postcode/ValidatorTest.php @@ -130,7 +130,7 @@ public function getPostcodesDataProvider() ['countryId' => 'IS', 'postcode' => '123'], ['countryId' => 'IN', 'postcode' => '123456'], ['countryId' => 'ID', 'postcode' => '12345'], - ['countryId' => 'IL', 'postcode' => '12345'], + ['countryId' => 'IL', 'postcode' => '1234567'], ['countryId' => 'IT', 'postcode' => '12345'], ['countryId' => 'JP', 'postcode' => '123-4567'], ['countryId' => 'JP', 'postcode' => '1234567'], From fc0f339d1f49486e964775c2488fd54d4872cda2 Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi <alugovyi@magento.com> Date: Thu, 21 Jun 2018 14:23:15 +0300 Subject: [PATCH 195/206] MAGETWO-64467: [Indexer optimizations] Tables sharding / segmentation for price indexer --- .../FunctionalTest/Customer/Test/AdminCreateCustomerTest.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Customer/Test/AdminCreateCustomerTest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Customer/Test/AdminCreateCustomerTest.xml index 1a994d0bbad1c..a2f179ca70e0e 100644 --- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Customer/Test/AdminCreateCustomerTest.xml +++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Customer/Test/AdminCreateCustomerTest.xml @@ -18,6 +18,7 @@ <testCaseId value="MAGETWO-72095"/> <group value="customer"/> <group value="create"/> + <group value="skip"/> </annotations> <after> <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> From 119e7a8f2b6abb5c866d0629ff6021327bde8181 Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi <alugovyi@magento.com> Date: Thu, 21 Jun 2018 14:57:18 +0300 Subject: [PATCH 196/206] MAGETWO-92693: Some improvements on product create|edit page in admin area --- .../Magento/Catalog/Controller/Adminhtml/Product/Builder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Builder.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Builder.php index 5398f6004ac36..125406061aed7 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Builder.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Builder.php @@ -45,7 +45,7 @@ class Builder /** * @var ProductRepositoryInterface */ - protected $productRepository; + private $productRepository; /** * Constructor From 8982abeac9807bb4bfe069ee8d50b661dbcd57b1 Mon Sep 17 00:00:00 2001 From: Yaroslav Rogoza <enarc@atwix.com> Date: Thu, 21 Jun 2018 16:10:50 +0200 Subject: [PATCH 197/206] Added integration test for checking admin login attempts cleanup --- .../ResetAttemptForBackendObserverTest.php | 59 +++++++++++++++++++ .../Captcha/_files/failed_logins_backend.php | 17 ++++++ .../_files/failed_logins_backend_rollback.php | 17 ++++++ 3 files changed, 93 insertions(+) create mode 100644 dev/tests/integration/testsuite/Magento/Captcha/Observer/ResetAttemptForBackendObserverTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Captcha/_files/failed_logins_backend.php create mode 100644 dev/tests/integration/testsuite/Magento/Captcha/_files/failed_logins_backend_rollback.php diff --git a/dev/tests/integration/testsuite/Magento/Captcha/Observer/ResetAttemptForBackendObserverTest.php b/dev/tests/integration/testsuite/Magento/Captcha/Observer/ResetAttemptForBackendObserverTest.php new file mode 100644 index 0000000000000..e52bd60c45d25 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Captcha/Observer/ResetAttemptForBackendObserverTest.php @@ -0,0 +1,59 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Captcha\Observer; + +use Magento\Captcha\Model\ResourceModel\Log as CaptchaLog; +use Magento\Captcha\Model\ResourceModel\LogFactory; +use Magento\Framework\Event\ManagerInterface; +use Magento\Framework\ObjectManagerInterface; +use Magento\User\Model\User; +use Magento\User\Model\UserFactory; + +/** + * Class ResetAttemptForBackendObserverTest + * + * Test for checking that the admin login attempts are removed after a successful login + */ +class ResetAttemptForBackendObserverTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var ObjectManagerInterface + */ + private $objectManager; + + public function setUp() + { + $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + } + + /** + * @magentoDataFixture Magento/Captcha/_files/failed_logins_backend.php + */ + public function testBackendLoginActionWithInvalidCaptchaReturnsError() + { + $userFactory = $this->objectManager->get(UserFactory::class); + $captchaLogFactory = $this->objectManager->get(LogFactory::class); + $eventManager = $this->objectManager->get(ManagerInterface::class); + + /** @var User $user */ + $user = $userFactory->create(); + $user->setUserName('mageadmin'); + + $eventManager->dispatch( + 'backend_auth_user_login_success', + ['user' => $user] + ); + + /** + * @var CaptchaLog $captchaLog + */ + $captchaLog = $captchaLogFactory->create(); + + self::assertEquals(0, $captchaLog->countAttemptsByUserLogin('mageadmin')); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Captcha/_files/failed_logins_backend.php b/dev/tests/integration/testsuite/Magento/Captcha/_files/failed_logins_backend.php new file mode 100644 index 0000000000000..7130cdfca57d7 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Captcha/_files/failed_logins_backend.php @@ -0,0 +1,17 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\TestFramework\Helper\Bootstrap; +use Magento\Captcha\Model\ResourceModel\LogFactory; +use Magento\Captcha\Model\ResourceModel\Log; + +$objectManager = Bootstrap::getObjectManager(); +$logFactory = $objectManager->get(LogFactory::class); + +/** @var Log $captchaLog */ +$captchaLog = $logFactory->create(); +$captchaLog->logAttempt('mageadmin'); diff --git a/dev/tests/integration/testsuite/Magento/Captcha/_files/failed_logins_backend_rollback.php b/dev/tests/integration/testsuite/Magento/Captcha/_files/failed_logins_backend_rollback.php new file mode 100644 index 0000000000000..12a16027e1e5c --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Captcha/_files/failed_logins_backend_rollback.php @@ -0,0 +1,17 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\TestFramework\Helper\Bootstrap; +use Magento\Captcha\Model\ResourceModel\LogFactory; +use Magento\Captcha\Model\ResourceModel\Log; + +$objectManager = Bootstrap::getObjectManager(); +$logFactory = $objectManager->get(LogFactory::class); + +/** @var Log $captchaLog */ +$captchaLog = $logFactory->create(); +$captchaLog->deleteUserAttempts('mageadmin'); From 6885503de451f98b88906a9c53d81dd11fcf73f0 Mon Sep 17 00:00:00 2001 From: Myroslav Dobra <dmaraptor@gmail.com> Date: Thu, 21 Jun 2018 17:43:56 +0300 Subject: [PATCH 198/206] MAGETWO-87721: Custom Options are corruputed when saving product to a different website (fix endline in files) --- .../Store/ActionGroup/AdminCreateNewStoreGroupActionGroup.xml | 2 +- .../Store/ActionGroup/AdminCreateWebsiteActionGroup.xml | 2 +- .../Store/ActionGroup/AdminDeleteWebsiteActionGroup.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/ActionGroup/AdminCreateNewStoreGroupActionGroup.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/ActionGroup/AdminCreateNewStoreGroupActionGroup.xml index 83aa1a4735935..a4fa6cea19b26 100644 --- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/ActionGroup/AdminCreateNewStoreGroupActionGroup.xml +++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/ActionGroup/AdminCreateNewStoreGroupActionGroup.xml @@ -20,4 +20,4 @@ <waitForElementVisible selector="{{AdminStoresGridSection.storeGrpFilterTextField}}" stepKey="waitForStoreGridReload"/> <see userInput="You saved the store." stepKey="seeSavedMessage" /> </actionGroup> -</actionGroups> \ No newline at end of file +</actionGroups> diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/ActionGroup/AdminCreateWebsiteActionGroup.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/ActionGroup/AdminCreateWebsiteActionGroup.xml index c34e6c0814bb8..c5946f3f22bf5 100644 --- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/ActionGroup/AdminCreateWebsiteActionGroup.xml +++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/ActionGroup/AdminCreateWebsiteActionGroup.xml @@ -18,4 +18,4 @@ <waitForElementVisible selector="{{AdminStoresGridSection.websiteFilterTextField}}" stepKey="waitForStoreGridToReload"/> <see userInput="You saved the website." stepKey="seeSavedMessage" /> </actionGroup> -</actionGroups> \ No newline at end of file +</actionGroups> diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/ActionGroup/AdminDeleteWebsiteActionGroup.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/ActionGroup/AdminDeleteWebsiteActionGroup.xml index 9b61315f0d5b8..ff44598c5b465 100644 --- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/ActionGroup/AdminDeleteWebsiteActionGroup.xml +++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/ActionGroup/AdminDeleteWebsiteActionGroup.xml @@ -21,4 +21,4 @@ <waitForElementVisible selector="{{AdminStoresGridSection.websiteFilterTextField}}" stepKey="waitForStoreGridToReload"/> <see userInput="You deleted the website." stepKey="seeSavedMessage"/> </actionGroup> -</actionGroups> \ No newline at end of file +</actionGroups> From 9c4413b004082b0e09b22e05857c717635c28a73 Mon Sep 17 00:00:00 2001 From: Myroslav Dobra <dmaraptor@gmail.com> Date: Thu, 21 Jun 2018 17:52:58 +0300 Subject: [PATCH 199/206] MAGETWO-87721: Custom Options are corruputed when saving product to a different website (fix endline in files) --- .../Config/ActionGroup/ConfigWebUrlOptionsActionGroup.xml | 2 +- .../FunctionalTest/Store/Page/AdminSystemStoreGroupPage.xml | 2 +- .../FunctionalTest/Store/Page/AdminSystemStoreWebsitePage.xml | 2 +- .../Store/Section/AdminNewWebsiteActionsSection.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Config/ActionGroup/ConfigWebUrlOptionsActionGroup.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Config/ActionGroup/ConfigWebUrlOptionsActionGroup.xml index c7537db3f80cf..a1414da6f08c3 100644 --- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Config/ActionGroup/ConfigWebUrlOptionsActionGroup.xml +++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Config/ActionGroup/ConfigWebUrlOptionsActionGroup.xml @@ -29,4 +29,4 @@ <click selector="{{WebSection.UrlOptionsTab}}" stepKey="collapseUrlOptions"/> <click selector="{{ContentManagementSection.Save}}" stepKey="saveConfig"/> </actionGroup> -</actionGroups> \ No newline at end of file +</actionGroups> diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/Page/AdminSystemStoreGroupPage.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/Page/AdminSystemStoreGroupPage.xml index 9c203241283dc..02fdc6122b37e 100644 --- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/Page/AdminSystemStoreGroupPage.xml +++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/Page/AdminSystemStoreGroupPage.xml @@ -9,4 +9,4 @@ <page name="AdminSystemStoreGroupPage" url="admin/system_store/newGroup" module="Magento_Store" area="admin"> <section name="AdminNewStoreGroupSection"/> </page> -</pages> \ No newline at end of file +</pages> diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/Page/AdminSystemStoreWebsitePage.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/Page/AdminSystemStoreWebsitePage.xml index 6b28b2f04ea09..61c564cb90027 100644 --- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/Page/AdminSystemStoreWebsitePage.xml +++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/Page/AdminSystemStoreWebsitePage.xml @@ -9,4 +9,4 @@ <page name="AdminSystemStoreWebsitePage" url="admin/system_store/newWebsite" module="Magento_Store" area="admin"> <section name="AdminNewWebsiteSection"/> </page> -</pages> \ No newline at end of file +</pages> diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/Section/AdminNewWebsiteActionsSection.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/Section/AdminNewWebsiteActionsSection.xml index 18d1ef2642ef8..def89001ca055 100644 --- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/Section/AdminNewWebsiteActionsSection.xml +++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Store/Section/AdminNewWebsiteActionsSection.xml @@ -9,4 +9,4 @@ <section name="AdminNewWebsiteActionsSection"> <element name="saveWebsite" type="button" selector="#save" timeout="30"/> </section> -</sections> \ No newline at end of file +</sections> From 690b39f11b65dac5fd8ae829e48e8224b9627a88 Mon Sep 17 00:00:00 2001 From: Yaroslav Rogoza <enarc@atwix.com> Date: Thu, 21 Jun 2018 18:54:00 +0200 Subject: [PATCH 200/206] Added integration test for checking customer login attempts captcha cleanup --- .../ResetAttemptForFrontendObserverTest.php | 60 +++++++++++++++++++ .../Captcha/_files/failed_logins_frontend.php | 18 ++++++ .../failed_logins_frontend_rollback.php | 18 ++++++ 3 files changed, 96 insertions(+) create mode 100644 dev/tests/integration/testsuite/Magento/Captcha/Observer/ResetAttemptForFrontendObserverTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Captcha/_files/failed_logins_frontend.php create mode 100644 dev/tests/integration/testsuite/Magento/Captcha/_files/failed_logins_frontend_rollback.php diff --git a/dev/tests/integration/testsuite/Magento/Captcha/Observer/ResetAttemptForFrontendObserverTest.php b/dev/tests/integration/testsuite/Magento/Captcha/Observer/ResetAttemptForFrontendObserverTest.php new file mode 100644 index 0000000000000..bb9f9b25195b5 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Captcha/Observer/ResetAttemptForFrontendObserverTest.php @@ -0,0 +1,60 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Captcha\Observer; + +use Magento\Captcha\Model\ResourceModel\Log as CaptchaLog; +use Magento\Captcha\Model\ResourceModel\LogFactory; +use Magento\Customer\Model\Customer; +use Magento\Customer\Model\CustomerFactory; +use Magento\Framework\Event\ManagerInterface; +use Magento\Framework\ObjectManagerInterface; + +/** + * Class ResetAttemptForBackendObserverTest + * + * Test for checking that the customer login attempts are removed after a successful login + */ +class ResetAttemptForFrontendObserverTest extends \PHPUnit\Framework\TestCase +{ + const USER_EMAIL = 'mageuser@dummy.com'; + /** + * @var ObjectManagerInterface + */ + private $objectManager; + + public function setUp() + { + $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + } + + /** + * @magentoDataFixture Magento/Captcha/_files/failed_logins_frontend.php + */ + public function testSuccesfulLoginRemovesFailedAttempts() + { + $customerFactory = $this->objectManager->get(CustomerFactory::class); + $captchaLogFactory = $this->objectManager->get(LogFactory::class); + $eventManager = $this->objectManager->get(ManagerInterface::class); + + /** @var Customer $customer */ + $customer = $customerFactory->create(); + $customer->setEmail(self::USER_EMAIL); + + $eventManager->dispatch( + 'customer_customer_authenticated', + ['model' => $customer, 'password' => 'some_password'] + ); + + /** + * @var CaptchaLog $captchaLog + */ + $captchaLog = $captchaLogFactory->create(); + + self::assertEquals(0, $captchaLog->countAttemptsByUserLogin(self::USER_EMAIL)); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Captcha/_files/failed_logins_frontend.php b/dev/tests/integration/testsuite/Magento/Captcha/_files/failed_logins_frontend.php new file mode 100644 index 0000000000000..b4fe99f5825e8 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Captcha/_files/failed_logins_frontend.php @@ -0,0 +1,18 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\TestFramework\Helper\Bootstrap; +use Magento\Captcha\Model\ResourceModel\LogFactory; +use Magento\Captcha\Model\ResourceModel\Log; +use Magento\Captcha\Observer\ResetAttemptForFrontendObserverTest; + +$objectManager = Bootstrap::getObjectManager(); +$logFactory = $objectManager->get(LogFactory::class); + +/** @var Log $captchaLog */ +$captchaLog = $logFactory->create(); +$captchaLog->logAttempt(ResetAttemptForFrontendObserverTest::USER_EMAIL); diff --git a/dev/tests/integration/testsuite/Magento/Captcha/_files/failed_logins_frontend_rollback.php b/dev/tests/integration/testsuite/Magento/Captcha/_files/failed_logins_frontend_rollback.php new file mode 100644 index 0000000000000..9948c0f1f89a5 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Captcha/_files/failed_logins_frontend_rollback.php @@ -0,0 +1,18 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\TestFramework\Helper\Bootstrap; +use Magento\Captcha\Model\ResourceModel\LogFactory; +use Magento\Captcha\Model\ResourceModel\Log; +use Magento\Captcha\Observer\ResetAttemptForFrontendObserverTest; + +$objectManager = Bootstrap::getObjectManager(); +$logFactory = $objectManager->get(LogFactory::class); + +/** @var Log $captchaLog */ +$captchaLog = $logFactory->create(); +$captchaLog->deleteUserAttempts(ResetAttemptForFrontendObserverTest::USER_EMAIL); From 1cb9476de048885fd0c1d2fb1665f756a89b40ee Mon Sep 17 00:00:00 2001 From: Yaroslav Rogoza <enarc@atwix.com> Date: Thu, 21 Jun 2018 19:18:07 +0200 Subject: [PATCH 201/206] Added integration test for checking customer login attempts captcha cleanup after account edit --- ...emptForFrontendAccountEditObserverTest.php | 53 +++++++++++++++++++ .../ResetAttemptForFrontendObserverTest.php | 8 +-- .../Captcha/_files/failed_logins_frontend.php | 3 +- .../failed_logins_frontend_rollback.php | 3 +- 4 files changed, 59 insertions(+), 8 deletions(-) create mode 100644 dev/tests/integration/testsuite/Magento/Captcha/Observer/ResetAttemptForFrontendAccountEditObserverTest.php diff --git a/dev/tests/integration/testsuite/Magento/Captcha/Observer/ResetAttemptForFrontendAccountEditObserverTest.php b/dev/tests/integration/testsuite/Magento/Captcha/Observer/ResetAttemptForFrontendAccountEditObserverTest.php new file mode 100644 index 0000000000000..c09211b020b30 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Captcha/Observer/ResetAttemptForFrontendAccountEditObserverTest.php @@ -0,0 +1,53 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Captcha\Observer; + +use Magento\Captcha\Model\ResourceModel\Log as CaptchaLog; +use Magento\Captcha\Model\ResourceModel\LogFactory; +use Magento\Framework\Event\ManagerInterface; +use Magento\Framework\ObjectManagerInterface; + +/** + * Class ResetAttemptForFrontendAccountEditObserverTest + * + * Test for checking that the customer login attempts are removed after account details edit + */ +class ResetAttemptForFrontendAccountEditObserverTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var ObjectManagerInterface + */ + private $objectManager; + + public function setUp() + { + $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + } + + /** + * @magentoDataFixture Magento/Captcha/_files/failed_logins_frontend.php + */ + public function testAccountEditRemovesFailedAttempts() + { + $customerEmail = 'mageuser@dummy.com'; + $captchaLogFactory = $this->objectManager->get(LogFactory::class); + $eventManager = $this->objectManager->get(ManagerInterface::class); + + $eventManager->dispatch( + 'customer_account_edited', + ['email' => $customerEmail] + ); + + /** + * @var CaptchaLog $captchaLog + */ + $captchaLog = $captchaLogFactory->create(); + + self::assertEquals(0, $captchaLog->countAttemptsByUserLogin($customerEmail)); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Captcha/Observer/ResetAttemptForFrontendObserverTest.php b/dev/tests/integration/testsuite/Magento/Captcha/Observer/ResetAttemptForFrontendObserverTest.php index bb9f9b25195b5..f8dd80595f936 100644 --- a/dev/tests/integration/testsuite/Magento/Captcha/Observer/ResetAttemptForFrontendObserverTest.php +++ b/dev/tests/integration/testsuite/Magento/Captcha/Observer/ResetAttemptForFrontendObserverTest.php @@ -15,13 +15,12 @@ use Magento\Framework\ObjectManagerInterface; /** - * Class ResetAttemptForBackendObserverTest + * Class ResetAttemptForFrontendObserverTest * * Test for checking that the customer login attempts are removed after a successful login */ class ResetAttemptForFrontendObserverTest extends \PHPUnit\Framework\TestCase { - const USER_EMAIL = 'mageuser@dummy.com'; /** * @var ObjectManagerInterface */ @@ -37,13 +36,14 @@ public function setUp() */ public function testSuccesfulLoginRemovesFailedAttempts() { + $customerEmail = 'mageuser@dummy.com'; $customerFactory = $this->objectManager->get(CustomerFactory::class); $captchaLogFactory = $this->objectManager->get(LogFactory::class); $eventManager = $this->objectManager->get(ManagerInterface::class); /** @var Customer $customer */ $customer = $customerFactory->create(); - $customer->setEmail(self::USER_EMAIL); + $customer->setEmail($customerEmail); $eventManager->dispatch( 'customer_customer_authenticated', @@ -55,6 +55,6 @@ public function testSuccesfulLoginRemovesFailedAttempts() */ $captchaLog = $captchaLogFactory->create(); - self::assertEquals(0, $captchaLog->countAttemptsByUserLogin(self::USER_EMAIL)); + self::assertEquals(0, $captchaLog->countAttemptsByUserLogin($customerEmail)); } } diff --git a/dev/tests/integration/testsuite/Magento/Captcha/_files/failed_logins_frontend.php b/dev/tests/integration/testsuite/Magento/Captcha/_files/failed_logins_frontend.php index b4fe99f5825e8..4e0db30fa82c1 100644 --- a/dev/tests/integration/testsuite/Magento/Captcha/_files/failed_logins_frontend.php +++ b/dev/tests/integration/testsuite/Magento/Captcha/_files/failed_logins_frontend.php @@ -8,11 +8,10 @@ use Magento\TestFramework\Helper\Bootstrap; use Magento\Captcha\Model\ResourceModel\LogFactory; use Magento\Captcha\Model\ResourceModel\Log; -use Magento\Captcha\Observer\ResetAttemptForFrontendObserverTest; $objectManager = Bootstrap::getObjectManager(); $logFactory = $objectManager->get(LogFactory::class); /** @var Log $captchaLog */ $captchaLog = $logFactory->create(); -$captchaLog->logAttempt(ResetAttemptForFrontendObserverTest::USER_EMAIL); +$captchaLog->logAttempt('mageuser@dummy.com'); diff --git a/dev/tests/integration/testsuite/Magento/Captcha/_files/failed_logins_frontend_rollback.php b/dev/tests/integration/testsuite/Magento/Captcha/_files/failed_logins_frontend_rollback.php index 9948c0f1f89a5..a01edb6d0a219 100644 --- a/dev/tests/integration/testsuite/Magento/Captcha/_files/failed_logins_frontend_rollback.php +++ b/dev/tests/integration/testsuite/Magento/Captcha/_files/failed_logins_frontend_rollback.php @@ -8,11 +8,10 @@ use Magento\TestFramework\Helper\Bootstrap; use Magento\Captcha\Model\ResourceModel\LogFactory; use Magento\Captcha\Model\ResourceModel\Log; -use Magento\Captcha\Observer\ResetAttemptForFrontendObserverTest; $objectManager = Bootstrap::getObjectManager(); $logFactory = $objectManager->get(LogFactory::class); /** @var Log $captchaLog */ $captchaLog = $logFactory->create(); -$captchaLog->deleteUserAttempts(ResetAttemptForFrontendObserverTest::USER_EMAIL); +$captchaLog->deleteUserAttempts('mageuser@dummy.com'); From c2832f360300166c4f37812e29d8913c42aa9d91 Mon Sep 17 00:00:00 2001 From: Yaroslav Rogoza <enarc@atwix.com> Date: Thu, 21 Jun 2018 19:27:32 +0200 Subject: [PATCH 202/206] Minor improvements --- .../Observer/ResetAttemptForBackendObserverTest.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Captcha/Observer/ResetAttemptForBackendObserverTest.php b/dev/tests/integration/testsuite/Magento/Captcha/Observer/ResetAttemptForBackendObserverTest.php index e52bd60c45d25..c0a720229a00d 100644 --- a/dev/tests/integration/testsuite/Magento/Captcha/Observer/ResetAttemptForBackendObserverTest.php +++ b/dev/tests/integration/testsuite/Magento/Captcha/Observer/ResetAttemptForBackendObserverTest.php @@ -34,15 +34,16 @@ public function setUp() /** * @magentoDataFixture Magento/Captcha/_files/failed_logins_backend.php */ - public function testBackendLoginActionWithInvalidCaptchaReturnsError() + public function testLoginAttemptsRemovedAfterSuccessfulLogin() { + $login = 'mageadmin'; $userFactory = $this->objectManager->get(UserFactory::class); $captchaLogFactory = $this->objectManager->get(LogFactory::class); $eventManager = $this->objectManager->get(ManagerInterface::class); /** @var User $user */ $user = $userFactory->create(); - $user->setUserName('mageadmin'); + $user->setUserName($login); $eventManager->dispatch( 'backend_auth_user_login_success', @@ -54,6 +55,6 @@ public function testBackendLoginActionWithInvalidCaptchaReturnsError() */ $captchaLog = $captchaLogFactory->create(); - self::assertEquals(0, $captchaLog->countAttemptsByUserLogin('mageadmin')); + self::assertEquals(0, $captchaLog->countAttemptsByUserLogin($login)); } } From ba07b1fdff05d9a7a132413e46a2fd548c6ae2ed Mon Sep 17 00:00:00 2001 From: Sviatoslav Mankivskyi <smankivskyi@magento.com> Date: Thu, 21 Jun 2018 13:49:29 -0500 Subject: [PATCH 203/206] DEVOPS-2632: Sample Data Builds Migrated from Bamboo --- dev/tests/functional/composer.json | 2 +- .../Magento/Customer/Test/Block/Account/AuthenticationPopup.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/dev/tests/functional/composer.json b/dev/tests/functional/composer.json index 0c9f329f234a8..75c2e2342353e 100644 --- a/dev/tests/functional/composer.json +++ b/dev/tests/functional/composer.json @@ -4,7 +4,7 @@ }, "require": { "php": "7.0.2|~7.0.6|~7.1.0", - "magento/mtf": "1.0.0-rc59", + "magento/mtf": "1.0.0-rc61", "allure-framework/allure-phpunit": "~1.2.0", "doctrine/annotations": "1.4.*", "phpunit/phpunit": "~4.8.0|~5.5.0", diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Account/AuthenticationPopup.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Account/AuthenticationPopup.php index e25a5c1f719d0..1ef9267e73785 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Account/AuthenticationPopup.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Account/AuthenticationPopup.php @@ -69,6 +69,7 @@ public function createAccount() */ public function loginCustomer(Customer $customer) { + sleep(10); $this->fill($customer); $this->_rootElement->find($this->login)->click(); $this->waitForElementNotVisible($this->loadingMask); From b1b7912ea69433f8327350799cc2e4e58ea23a34 Mon Sep 17 00:00:00 2001 From: Sviatoslav Mankivskyi <smankivskyi@magento.com> Date: Thu, 21 Jun 2018 14:04:10 -0500 Subject: [PATCH 204/206] DEVOPS-2632: Sample Data Builds Migrated from Bamboo --- dev/tests/functional/composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/functional/composer.json b/dev/tests/functional/composer.json index 75c2e2342353e..93de6b3363900 100644 --- a/dev/tests/functional/composer.json +++ b/dev/tests/functional/composer.json @@ -4,7 +4,7 @@ }, "require": { "php": "7.0.2|~7.0.6|~7.1.0", - "magento/mtf": "1.0.0-rc61", + "magento/mtf": "2.2.x-dev", "allure-framework/allure-phpunit": "~1.2.0", "doctrine/annotations": "1.4.*", "phpunit/phpunit": "~4.8.0|~5.5.0", From 9c9ac11f383fd9572c846186d6b658611bf4b054 Mon Sep 17 00:00:00 2001 From: Paolo Vecchiocattivi <paolo.vecchiocattivi@magespecialist.it> Date: Sun, 10 Jun 2018 10:56:08 +0200 Subject: [PATCH 205/206] during product import, use correct error message for duplicate error key --- app/code/Magento/CatalogImportExport/Model/Import/Product.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product.php b/app/code/Magento/CatalogImportExport/Model/Import/Product.php index 2199936101357..22e44eae933b0 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Product.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Product.php @@ -2675,7 +2675,8 @@ protected function checkUrlKeyDuplicates() ); foreach ($urlKeyDuplicates as $entityData) { $rowNum = $this->rowNumbers[$entityData['store_id']][$entityData['request_path']]; - $this->addRowError(ValidatorInterface::ERROR_DUPLICATE_URL_KEY, $rowNum); + $message = sprintf($this->retrieveMessageTemplate(ValidatorInterface::ERROR_DUPLICATE_URL_KEY), $entityData['request_path'], $entityData['sku']); + $this->addRowError(ValidatorInterface::ERROR_DUPLICATE_URL_KEY, $rowNum, 'url_key', $message); } } } From fa7801f72d127ebf65d05c2ccd50141e02e2c8c8 Mon Sep 17 00:00:00 2001 From: Eugene Shakhsuvarov <ishakhsuvarov@users.noreply.github.com> Date: Mon, 11 Jun 2018 13:07:53 +0300 Subject: [PATCH 206/206] Updated according to coding style requirements --- .../Magento/CatalogImportExport/Model/Import/Product.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product.php b/app/code/Magento/CatalogImportExport/Model/Import/Product.php index 22e44eae933b0..362433598b7c9 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Product.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Product.php @@ -2675,7 +2675,11 @@ protected function checkUrlKeyDuplicates() ); foreach ($urlKeyDuplicates as $entityData) { $rowNum = $this->rowNumbers[$entityData['store_id']][$entityData['request_path']]; - $message = sprintf($this->retrieveMessageTemplate(ValidatorInterface::ERROR_DUPLICATE_URL_KEY), $entityData['request_path'], $entityData['sku']); + $message = sprintf( + $this->retrieveMessageTemplate(ValidatorInterface::ERROR_DUPLICATE_URL_KEY), + $entityData['request_path'], + $entityData['sku'] + ); $this->addRowError(ValidatorInterface::ERROR_DUPLICATE_URL_KEY, $rowNum, 'url_key', $message); } }