From d82ba2eb04a9eaa12a19dee75c8456f702515d82 Mon Sep 17 00:00:00 2001 From: Anahit Martirosyan Date: Fri, 29 Mar 2019 10:32:46 +0400 Subject: [PATCH 01/23] MAGETWO-51891: Category with invalid data loses new products assignment after validation - Add automated test script --- .../ActionGroup/AdminCategoryActionGroup.xml | 13 ++++ ...ssignmentToCategoryWithInvalidDataTest.xml | 62 +++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 app/code/Magento/Catalog/Test/Mftf/Test/NewProductsAssignmentToCategoryWithInvalidDataTest.xml diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminCategoryActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminCategoryActionGroup.xml index 90d732c9654e1..80e71ef89da90 100644 --- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminCategoryActionGroup.xml +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminCategoryActionGroup.xml @@ -316,4 +316,17 @@ + + + + + + + + + + + + + diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/NewProductsAssignmentToCategoryWithInvalidDataTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/NewProductsAssignmentToCategoryWithInvalidDataTest.xml new file mode 100644 index 0000000000000..3ef8ecfeff304 --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/Test/NewProductsAssignmentToCategoryWithInvalidDataTest.xml @@ -0,0 +1,62 @@ + + + + + + + + + <description value="New products assignment to Category with invalid data after validation"/> + <severity value="MAJOR"/> + <testCaseId value="MAGETWO-98646"/> + <useCaseId value="MAGETWO-51891"/> + <group value="Catalog"/> + </annotations> + <before> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + <!--Create two products and two categories--> + <comment userInput="Create two products and two categories" stepKey="commentCreateProductsAndCategories"/> + <createData entity="SimpleSubCategory" stepKey="categoryFirst"/> + <createData entity="SimpleSubCategory" stepKey="categorySecond"/> + <createData entity="SimpleProduct" stepKey="simpleProduct1"> + <requiredEntity createDataKey="categoryFirst"/> + </createData> + <createData entity="SimpleProduct2" stepKey="simpleProduct2"/> + </before> + <after> + <!--Delete created data--> + <comment userInput="Delete created data" stepKey="commentDeleteData"/> + <deleteData createDataKey="simpleProduct1" stepKey="deleteProduct1"/> + <deleteData createDataKey="categoryFirst" stepKey="deleteCategory1"/> + <deleteData createDataKey="simpleProduct2" stepKey="deleteProduct2"/> + <deleteData createDataKey="categorySecond" stepKey="deleteCategory2"/> + <actionGroup ref="logout" stepKey="logout"/> + </after> + <!--Assign product to category--> + <comment userInput="Assign product to category" stepKey="commentAssignProductToCategory"/> + <amOnPage url="{{AdminCategoryEditPage.url($$categoryFirst.id$$)}}" stepKey="goToProductCategoryPage"/> + <actionGroup ref="AddProductToCategory" stepKey="addProductToCategory"> + <argument name="productSku" value="$$simpleProduct2.sku$$"/> + </actionGroup> + <!-- Open Search Engine Optimization section and change URL key--> + <comment userInput="Open Search Engine Optimization section and change URL key" stepKey="commentChangeUrlKey"/> + <click selector="{{AdminCategorySEOSection.SectionHeader}}" stepKey="clickOnProductHeader"/> + <fillField selector="{{AdminCategorySEOSection.UrlKeyInput}}" userInput="$$categorySecond.custom_attributes[url_key]$$" stepKey="changeUrlKey"/> + <!--Save URL key and see error message--> + <comment userInput="Save URL key and see error message" stepKey="commentSaveUrlKey"/> + <click selector="{{AdminCategoryMainActionsSection.SaveButton}}" stepKey="saveUrlKey"/> + <waitForPageLoad stepKey="waitForSaving"/> + <see userInput="The value specified in the URL Key field would generate a URL that already exists." stepKey="seeErrorMessage"/> + <!--Check product in category grid--> + <comment userInput="Check product in category grid" stepKey="commentCheckProduct"/> + <click selector="{{AdminCategoryProductsSection.sectionHeader}}" stepKey="openProductsInCategorySection"/> + <seeElement selector="{{AdminCategoryProductsGridSection.productGridNameProduct($$simpleProduct1.name$$)}}" stepKey="seeProductInCategoryGrid"/> + <seeElement selector="{{AdminCategoryProductsGridSection.productGridNameProduct($$simpleProduct2.name$$)}}" stepKey="seeProductInCategoryGrid2"/> + </test> +</tests> From 924b6b44f59087ff67be32f22a2c41468234488f Mon Sep 17 00:00:00 2001 From: Lusine Papyan <Lusine_Papyan@epam.com> Date: Tue, 9 Apr 2019 15:44:58 +0400 Subject: [PATCH 02/23] MAGETWO-51891: Category with invalid data loses new products assignment after validation - Update automated test script --- .../NewProductsAssignmentToCategoryWithInvalidDataTest.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/NewProductsAssignmentToCategoryWithInvalidDataTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/NewProductsAssignmentToCategoryWithInvalidDataTest.xml index 3ef8ecfeff304..eb02db8553f6f 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/NewProductsAssignmentToCategoryWithInvalidDataTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/NewProductsAssignmentToCategoryWithInvalidDataTest.xml @@ -40,7 +40,7 @@ </after> <!--Assign product to category--> <comment userInput="Assign product to category" stepKey="commentAssignProductToCategory"/> - <amOnPage url="{{AdminCategoryEditPage.url($$categoryFirst.id$$)}}" stepKey="goToProductCategoryPage"/> + <amOnPage url="{{AdminCategoryEditPage.url($$categoryFirst.id$$)}}" stepKey="goToCategoryPage"/> <actionGroup ref="AddProductToCategory" stepKey="addProductToCategory"> <argument name="productSku" value="$$simpleProduct2.sku$$"/> </actionGroup> @@ -56,7 +56,7 @@ <!--Check product in category grid--> <comment userInput="Check product in category grid" stepKey="commentCheckProduct"/> <click selector="{{AdminCategoryProductsSection.sectionHeader}}" stepKey="openProductsInCategorySection"/> - <seeElement selector="{{AdminCategoryProductsGridSection.productGridNameProduct($$simpleProduct1.name$$)}}" stepKey="seeProductInCategoryGrid"/> - <seeElement selector="{{AdminCategoryProductsGridSection.productGridNameProduct($$simpleProduct2.name$$)}}" stepKey="seeProductInCategoryGrid2"/> + <seeElement selector="{{AdminCategoryProductsGridSection.productGridNameProduct($$simpleProduct1.name$$)}}" stepKey="seeProduct1InCategoryGrid"/> + <seeElement selector="{{AdminCategoryProductsGridSection.productGridNameProduct($$simpleProduct2.name$$)}}" stepKey="seeProduct2InCategoryGrid"/> </test> </tests> From 6e1dc006c6cee0bbb692a2d077414c0ffdab7d48 Mon Sep 17 00:00:00 2001 From: Anahit Martirosyan <anahit_martirosyan@epam.com> Date: Tue, 30 Apr 2019 15:51:27 +0400 Subject: [PATCH 03/23] MAGETWO-51891: Category with invalid data loses new products assignment after validation - Add updated test script --- .../Catalog/Test/Mftf/ActionGroup/AdminCategoryActionGroup.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminCategoryActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminCategoryActionGroup.xml index 80e71ef89da90..57dff7fb2ae90 100644 --- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminCategoryActionGroup.xml +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminCategoryActionGroup.xml @@ -320,7 +320,7 @@ <arguments> <argument name="productSku" type="string"/> </arguments> - <click selector="{{AdminCategoryProductsSection.sectionHeader}}" stepKey="openProductsInCategorySection"/> + <conditionalClick selector="{{AdminCategoryProductsSection.sectionHeader}}" dependentSelector="{{AdminCategoryProductsSection.addProducts}}" visible="false" stepKey="openProductsInCategorySection"/> <click selector="{{AdminCategoryProductsSection.addProducts}}" stepKey="clickAddProductsToCategory"/> <waitForElementVisible selector="{{AdminCategoryAddProductsModalSection.filters}}" stepKey="waitForModalOpen" time="30"/> <click selector="{{AdminCategoryAddProductsModalSection.addProductBySku}}" stepKey="clickAddBySkuTab"/> From 6dfc8184af647e0f515a94e09ebee2f3b2cbf537 Mon Sep 17 00:00:00 2001 From: Evgeny Petrov <evgeny_petrov@epam.com> Date: Sat, 4 May 2019 15:22:27 +0300 Subject: [PATCH 04/23] MAGETWO-51891: Category with invalid data loses new products assignment after validation - Add updated test script --- ...ssignmentToCategoryWithInvalidDataTest.xml | 62 ------------------- 1 file changed, 62 deletions(-) delete mode 100644 app/code/Magento/Catalog/Test/Mftf/Test/NewProductsAssignmentToCategoryWithInvalidDataTest.xml diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/NewProductsAssignmentToCategoryWithInvalidDataTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/NewProductsAssignmentToCategoryWithInvalidDataTest.xml deleted file mode 100644 index eb02db8553f6f..0000000000000 --- a/app/code/Magento/Catalog/Test/Mftf/Test/NewProductsAssignmentToCategoryWithInvalidDataTest.xml +++ /dev/null @@ -1,62 +0,0 @@ -<?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="urn:magento:mftf:Test/etc/testSchema.xsd"> - <test name="NewProductsAssignmentToCategoryWithInvalidDataTest"> - <annotations> - <features value="Catalog"/> - <title value="New products assignment to Category with invalid data after validation"/> - <description value="New products assignment to Category with invalid data after validation"/> - <severity value="MAJOR"/> - <testCaseId value="MAGETWO-98646"/> - <useCaseId value="MAGETWO-51891"/> - <group value="Catalog"/> - </annotations> - <before> - <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> - <!--Create two products and two categories--> - <comment userInput="Create two products and two categories" stepKey="commentCreateProductsAndCategories"/> - <createData entity="SimpleSubCategory" stepKey="categoryFirst"/> - <createData entity="SimpleSubCategory" stepKey="categorySecond"/> - <createData entity="SimpleProduct" stepKey="simpleProduct1"> - <requiredEntity createDataKey="categoryFirst"/> - </createData> - <createData entity="SimpleProduct2" stepKey="simpleProduct2"/> - </before> - <after> - <!--Delete created data--> - <comment userInput="Delete created data" stepKey="commentDeleteData"/> - <deleteData createDataKey="simpleProduct1" stepKey="deleteProduct1"/> - <deleteData createDataKey="categoryFirst" stepKey="deleteCategory1"/> - <deleteData createDataKey="simpleProduct2" stepKey="deleteProduct2"/> - <deleteData createDataKey="categorySecond" stepKey="deleteCategory2"/> - <actionGroup ref="logout" stepKey="logout"/> - </after> - <!--Assign product to category--> - <comment userInput="Assign product to category" stepKey="commentAssignProductToCategory"/> - <amOnPage url="{{AdminCategoryEditPage.url($$categoryFirst.id$$)}}" stepKey="goToCategoryPage"/> - <actionGroup ref="AddProductToCategory" stepKey="addProductToCategory"> - <argument name="productSku" value="$$simpleProduct2.sku$$"/> - </actionGroup> - <!-- Open Search Engine Optimization section and change URL key--> - <comment userInput="Open Search Engine Optimization section and change URL key" stepKey="commentChangeUrlKey"/> - <click selector="{{AdminCategorySEOSection.SectionHeader}}" stepKey="clickOnProductHeader"/> - <fillField selector="{{AdminCategorySEOSection.UrlKeyInput}}" userInput="$$categorySecond.custom_attributes[url_key]$$" stepKey="changeUrlKey"/> - <!--Save URL key and see error message--> - <comment userInput="Save URL key and see error message" stepKey="commentSaveUrlKey"/> - <click selector="{{AdminCategoryMainActionsSection.SaveButton}}" stepKey="saveUrlKey"/> - <waitForPageLoad stepKey="waitForSaving"/> - <see userInput="The value specified in the URL Key field would generate a URL that already exists." stepKey="seeErrorMessage"/> - <!--Check product in category grid--> - <comment userInput="Check product in category grid" stepKey="commentCheckProduct"/> - <click selector="{{AdminCategoryProductsSection.sectionHeader}}" stepKey="openProductsInCategorySection"/> - <seeElement selector="{{AdminCategoryProductsGridSection.productGridNameProduct($$simpleProduct1.name$$)}}" stepKey="seeProduct1InCategoryGrid"/> - <seeElement selector="{{AdminCategoryProductsGridSection.productGridNameProduct($$simpleProduct2.name$$)}}" stepKey="seeProduct2InCategoryGrid"/> - </test> -</tests> From 930ba4028399b15b1a46119d0d53e20157aafd36 Mon Sep 17 00:00:00 2001 From: Evgeny Petrov <evgeny_petrov@epam.com> Date: Sat, 11 May 2019 16:12:28 +0300 Subject: [PATCH 05/23] MAGETWO-51891: Category with invalid data loses new products assignment after validation --- .../Mftf/ActionGroup/AdminCategoryActionGroup.xml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminCategoryActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminCategoryActionGroup.xml index 57dff7fb2ae90..90d732c9654e1 100644 --- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminCategoryActionGroup.xml +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminCategoryActionGroup.xml @@ -316,17 +316,4 @@ <click selector="{{AdminCategoryMainActionsSection.SaveButton}}" stepKey="saveCategory"/> <waitForPageLoad stepKey="waitForPageToLoad1"/> </actionGroup> - <actionGroup name="AddProductToCategory"> - <arguments> - <argument name="productSku" type="string"/> - </arguments> - <conditionalClick selector="{{AdminCategoryProductsSection.sectionHeader}}" dependentSelector="{{AdminCategoryProductsSection.addProducts}}" visible="false" stepKey="openProductsInCategorySection"/> - <click selector="{{AdminCategoryProductsSection.addProducts}}" stepKey="clickAddProductsToCategory"/> - <waitForElementVisible selector="{{AdminCategoryAddProductsModalSection.filters}}" stepKey="waitForModalOpen" time="30"/> - <click selector="{{AdminCategoryAddProductsModalSection.addProductBySku}}" stepKey="clickAddBySkuTab"/> - <fillField selector="{{AdminCategoryAddProductsModalSection.productSkuInput}}" userInput="{{productSku}}" stepKey="enterSku"/> - <click selector="{{AdminCategoryAddProductsModalSection.assign}}" stepKey="assignSku"/> - <waitForAjaxLoad stepKey="waitForAjax"/> - <click selector="{{AdminCategoryAddProductsModalSection.saveClose}}" stepKey="saveCloseModal"/> - </actionGroup> </actionGroups> From ea64edf1b2c274b407312adc8ce8ea3e343d0b91 Mon Sep 17 00:00:00 2001 From: Yuliya Labudova <Yuliya_Labudova@epam.com> Date: Wed, 29 May 2019 14:51:39 +0300 Subject: [PATCH 06/23] MAGETWO-94565: Catalog product collection filters produce errors and cause inconsistent behaviour - Fix visibility and category filters; - Add integration tests. --- .../ResourceModel/Product/Collection.php | 48 ++++++++++- .../ResourceModel/Product/CollectionTest.php | 82 +++++++++++++++++-- 2 files changed, 119 insertions(+), 11 deletions(-) diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php index 384b6ddcefc31..cabbcb67fb5a7 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php @@ -3,6 +3,7 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); namespace Magento\Catalog\Model\ResourceModel\Product; @@ -22,6 +23,7 @@ use Magento\Framework\Indexer\DimensionFactory; use Magento\Store\Model\Indexer\WebsiteDimensionProvider; use Magento\Store\Model\Store; +use Magento\Catalog\Api\CategoryRepositoryInterface; /** * Product collection @@ -302,6 +304,11 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Collection\Abstrac */ private $urlFinder; + /** + * @var CategoryRepositoryInterface + */ + private $categoryRepository; + /** * Collection constructor * @@ -330,6 +337,7 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Collection\Abstrac * @param TableMaintainer|null $tableMaintainer * @param PriceTableResolver|null $priceTableResolver * @param DimensionFactory|null $dimensionFactory + * @param CategoryRepositoryInterface|null $categoryRepository * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -358,7 +366,8 @@ public function __construct( MetadataPool $metadataPool = null, TableMaintainer $tableMaintainer = null, PriceTableResolver $priceTableResolver = null, - DimensionFactory $dimensionFactory = null + DimensionFactory $dimensionFactory = null, + CategoryRepositoryInterface $categoryRepository = null ) { $this->moduleManager = $moduleManager; $this->_catalogProductFlatState = $catalogProductFlatState; @@ -392,6 +401,8 @@ public function __construct( $this->priceTableResolver = $priceTableResolver ?: ObjectManager::getInstance()->get(PriceTableResolver::class); $this->dimensionFactory = $dimensionFactory ?: ObjectManager::getInstance()->get(DimensionFactory::class); + $this->categoryRepository = $categoryRepository ?: ObjectManager::getInstance() + ->get(CategoryRepositoryInterface::class); } /** @@ -1673,7 +1684,11 @@ public function addFilterByRequiredOptions() public function setVisibility($visibility) { $this->_productLimitationFilters['visibility'] = $visibility; - $this->_applyProductLimitations(); + if ($this->getStoreId() == Store::DEFAULT_STORE_ID) { + $this->addAttributeToFilter('visibility', $visibility); + } else { + $this->_applyProductLimitations(); + } return $this; } @@ -2053,12 +2068,14 @@ protected function _applyProductLimitations() protected function _applyZeroStoreProductLimitations() { $filters = $this->_productLimitationFilters; + $categories = []; + $categories = $this->getChildrenCategories((int)$filters['category_id'], $categories); $conditions = [ 'cat_pro.product_id=e.entity_id', $this->getConnection()->quoteInto( - 'cat_pro.category_id=?', - $filters['category_id'] + 'cat_pro.category_id IN (?)', + $categories ), ]; $joinCond = join(' AND ', $conditions); @@ -2079,6 +2096,29 @@ protected function _applyZeroStoreProductLimitations() return $this; } + /** + * Get children categories. + * + * @param int $categoryId + * @param array $categories + * @return array + */ + private function getChildrenCategories(int $categoryId, array $categories): array + { + $category = $this->categoryRepository->get($categoryId); + $categories[] = $category->getId(); + if ($category->getIsAnchor()) { + $categoryChildren = $category->getChildren(); + $categoryChildrenIds = explode(',', $categoryChildren); + foreach ($categoryChildrenIds as $categoryChildrenId) { + if ($categoryChildrenId) { + $categories = $this->getChildrenCategories((int)$categoryChildrenId, $categories); + } + } + } + return $categories; + } + /** * Add category ids to loaded items * diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/Product/CollectionTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/Product/CollectionTest.php index 4cc6265a992fa..80d700c7e54ff 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/Product/CollectionTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/Product/CollectionTest.php @@ -3,8 +3,16 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Catalog\Model\ResourceModel\Product; +use Magento\Catalog\Model\Product\Visibility; +use Magento\Framework\App\Area; +use Magento\Framework\App\State; +use Magento\Store\Model\Store; +use Magento\TestFramework\Helper\Bootstrap; + /** * Collection test */ @@ -31,15 +39,15 @@ class CollectionTest extends \PHPUnit\Framework\TestCase */ protected function setUp() { - $this->collection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + $this->collection = Bootstrap::getObjectManager()->create( \Magento\Catalog\Model\ResourceModel\Product\Collection::class ); - $this->processor = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + $this->processor = Bootstrap::getObjectManager()->create( \Magento\Catalog\Model\Indexer\Product\Price\Processor::class ); - $this->productRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + $this->productRepository = Bootstrap::getObjectManager()->create( \Magento\Catalog\Api\ProductRepositoryInterface::class ); } @@ -54,7 +62,7 @@ public function testAddPriceDataOnSchedule() $this->processor->getIndexer()->setScheduled(true); $this->assertTrue($this->processor->getIndexer()->isScheduled()); - $productRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + $productRepository = Bootstrap::getObjectManager() ->create(\Magento\Catalog\Api\ProductRepositoryInterface::class); /** @var \Magento\Catalog\Api\Data\ProductInterface $product */ $product = $productRepository->get('simple'); @@ -73,7 +81,7 @@ public function testAddPriceDataOnSchedule() //reindexing $this->processor->getIndexer()->reindexList([1]); - $this->collection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + $this->collection = Bootstrap::getObjectManager()->create( \Magento\Catalog\Model\ResourceModel\Product\Collection::class ); $this->collection->addPriceData(0, 1); @@ -89,6 +97,66 @@ public function testAddPriceDataOnSchedule() $this->processor->getIndexer()->setScheduled(false); } + /** + * @magentoDataFixture Magento/Catalog/_files/products.php + * @magentoDbIsolation disabled + */ + public function testSetVisibility() + { + $appState = Bootstrap::getObjectManager() + ->create(State::class); + $appState->setAreaCode(Area::AREA_CRONTAB); + $this->collection->setStoreId(Store::DEFAULT_STORE_ID); + $this->collection->setVisibility([Visibility::VISIBILITY_BOTH]); + $this->collection->load(); + /** @var \Magento\Catalog\Api\Data\ProductInterface[] $product */ + $items = $this->collection->getItems(); + $this->assertCount(2, $items); + } + + /** + * @magentoDataFixture Magento/Catalog/_files/category_product.php + * @magentoDbIsolation disabled + */ + public function testSetCategoryWithStoreFilter() + { + $appState = Bootstrap::getObjectManager() + ->create(State::class); + $appState->setAreaCode(Area::AREA_CRONTAB); + + $category = \Magento\Framework\App\ObjectManager::getInstance()->get( + \Magento\Catalog\Model\Category::class + )->load(333); + $this->collection->addCategoryFilter($category)->addStoreFilter(1); + $this->collection->load(); + + $collectionStoreFilterAfter = Bootstrap::getObjectManager()->create( + \Magento\Catalog\Model\ResourceModel\Product\Collection::class + ); + $collectionStoreFilterAfter->addStoreFilter(1)->addCategoryFilter($category); + $collectionStoreFilterAfter->load(); + $this->assertEquals($this->collection->getItems(), $collectionStoreFilterAfter->getItems()); + $this->assertCount(1, $collectionStoreFilterAfter->getItems()); + } + + /** + * @magentoDataFixture Magento/Catalog/_files/categories.php + * @magentoDbIsolation disabled + */ + public function testSetCategoryFilter() + { + $appState = Bootstrap::getObjectManager() + ->create(State::class); + $appState->setAreaCode(Area::AREA_CRONTAB); + + $category = \Magento\Framework\App\ObjectManager::getInstance()->get( + \Magento\Catalog\Model\Category::class + )->load(3); + $this->collection->addCategoryFilter($category); + $this->collection->load(); + $this->assertEquals($this->collection->getSize(), 3); + } + /** * @magentoDataFixture Magento/Catalog/_files/products.php * @magentoAppIsolation enabled @@ -98,7 +166,7 @@ public function testAddPriceDataOnSave() { $this->processor->getIndexer()->setScheduled(false); $this->assertFalse($this->processor->getIndexer()->isScheduled()); - $productRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + $productRepository = Bootstrap::getObjectManager() ->create(\Magento\Catalog\Api\ProductRepositoryInterface::class); /** @var \Magento\Catalog\Api\Data\ProductInterface $product */ $product = $productRepository->get('simple'); @@ -184,7 +252,7 @@ public function testJoinTable() $productTable = $this->collection->getTable('catalog_product_entity'); $urlRewriteTable = $this->collection->getTable('url_rewrite'); - // phpcs:ignore + // phpcs:ignore Magento2.SQL.RawQuery $expected = 'SELECT `e`.*, `alias`.`request_path` FROM `' . $productTable . '` AS `e`' . ' LEFT JOIN `' . $urlRewriteTable . '` AS `alias` ON (alias.entity_id =e.entity_id)' . ' AND (alias.entity_type = \'product\')'; From 1ed2728a4566dc6cda4ab7d3e99e7eeda34844df Mon Sep 17 00:00:00 2001 From: Yuliya Labudova <Yuliya_Labudova@epam.com> Date: Thu, 13 Jun 2019 18:50:33 +0300 Subject: [PATCH 07/23] MAGETWO-94565: Catalog product collection filters produce errors and cause inconsistent behaviour - Fix CR comment --- .../ResourceModel/Product/Collection.php | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php index 6e790abd5372a..76152250c41df 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php @@ -23,7 +23,7 @@ use Magento\Framework\Indexer\DimensionFactory; use Magento\Store\Model\Indexer\WebsiteDimensionProvider; use Magento\Store\Model\Store; -use Magento\Catalog\Api\CategoryRepositoryInterface; +use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory; /** * Product collection @@ -305,9 +305,9 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Collection\Abstrac private $urlFinder; /** - * @var CategoryRepositoryInterface + * @var CollectionFactory */ - private $categoryRepository; + private $categoryCollectionFactory; /** * Collection constructor @@ -337,7 +337,7 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Collection\Abstrac * @param TableMaintainer|null $tableMaintainer * @param PriceTableResolver|null $priceTableResolver * @param DimensionFactory|null $dimensionFactory - * @param CategoryRepositoryInterface|null $categoryRepository + * @param CollectionFactory|null $categoryCollectionFactory * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -367,7 +367,7 @@ public function __construct( TableMaintainer $tableMaintainer = null, PriceTableResolver $priceTableResolver = null, DimensionFactory $dimensionFactory = null, - CategoryRepositoryInterface $categoryRepository = null + CollectionFactory $categoryCollectionFactory = null ) { $this->moduleManager = $moduleManager; $this->_catalogProductFlatState = $catalogProductFlatState; @@ -401,8 +401,8 @@ public function __construct( $this->priceTableResolver = $priceTableResolver ?: ObjectManager::getInstance()->get(PriceTableResolver::class); $this->dimensionFactory = $dimensionFactory ?: ObjectManager::getInstance()->get(DimensionFactory::class); - $this->categoryRepository = $categoryRepository ?: ObjectManager::getInstance() - ->get(CategoryRepositoryInterface::class); + $this->categoryCollectionFactory = $categoryCollectionFactory ?: ObjectManager::getInstance() + ->get(CollectionFactory::class); } /** @@ -2105,7 +2105,11 @@ protected function _applyZeroStoreProductLimitations() */ private function getChildrenCategories(int $categoryId, array $categories): array { - $category = $this->categoryRepository->get($categoryId); + /** @var \Magento\Catalog\Model\ResourceModel\Category\Collection $categoryCollection */ + $categoryCollection = $this->categoryCollectionFactory->create(); + $category = $categoryCollection + ->addAttributeToSelect('is_anchor')->addIdFilter([$categoryId]) + ->load()->getFirstItem(); $categories[] = $category->getId(); if ($category->getIsAnchor()) { $categoryChildren = $category->getChildren(); From fd3a8ae0e7fb437277e6e0f8fbec088582a49c2d Mon Sep 17 00:00:00 2001 From: Nikita Chubukov <nikita_chubukov@epam.com> Date: Thu, 20 Jun 2019 16:29:25 +0300 Subject: [PATCH 08/23] MC-15256: Exported customer without modification can not be imported - Changed import validation logic for attributes with empty select value --- .../Model/Import/Customer.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/CustomerImportExport/Model/Import/Customer.php b/app/code/Magento/CustomerImportExport/Model/Import/Customer.php index ab940c9e84533..f181119f1acf5 100644 --- a/app/code/Magento/CustomerImportExport/Model/Import/Customer.php +++ b/app/code/Magento/CustomerImportExport/Model/Import/Customer.php @@ -3,6 +3,8 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\CustomerImportExport\Model\Import; use Magento\Customer\Api\Data\CustomerInterface; @@ -288,9 +290,12 @@ private function getCustomerEntityFieldsToUpdate(array $entitiesToUpdate): array { $firstCustomer = reset($entitiesToUpdate); $columnsToUpdate = array_keys($firstCustomer); - $customerFieldsToUpdate = array_filter($this->customerFields, function ($field) use ($columnsToUpdate) { - return in_array($field, $columnsToUpdate); - }); + $customerFieldsToUpdate = array_filter( + $this->customerFields, + function ($field) use ($columnsToUpdate) { + return in_array($field, $columnsToUpdate); + } + ); return $customerFieldsToUpdate; } @@ -606,6 +611,10 @@ protected function _validateRowForUpdate(array $rowData, $rowNumber) } if (isset($rowData[$attributeCode]) && strlen($rowData[$attributeCode])) { + if ($attributeParams['type'] == 'select' && empty($rowData[$attributeCode])) { + continue; + } + $this->isAttributeValid( $attributeCode, $attributeParams, From 62bfe249b9dd0b1b6e2517152364a94b422470fc Mon Sep 17 00:00:00 2001 From: Yuliya Labudova <Yuliya_Labudova@epam.com> Date: Fri, 21 Jun 2019 14:08:24 +0300 Subject: [PATCH 09/23] MAGETWO-94565: Catalog product collection filters produce errors and cause inconsistent behaviour - Fix CR comments. --- .../Model/ResourceModel/Product/Collection.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php index 76152250c41df..7127aa2cb3e77 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php @@ -2068,8 +2068,7 @@ protected function _applyProductLimitations() protected function _applyZeroStoreProductLimitations() { $filters = $this->_productLimitationFilters; - $categories = []; - $categories = $this->getChildrenCategories((int)$filters['category_id'], $categories); + $categories = $this->getChildrenCategories((int)$filters['category_id'], []); $conditions = [ 'cat_pro.product_id=e.entity_id', @@ -2105,13 +2104,16 @@ protected function _applyZeroStoreProductLimitations() */ private function getChildrenCategories(int $categoryId, array $categories): array { + $categories[] = $categoryId; + /** @var \Magento\Catalog\Model\ResourceModel\Category\Collection $categoryCollection */ $categoryCollection = $this->categoryCollectionFactory->create(); $category = $categoryCollection - ->addAttributeToSelect('is_anchor')->addIdFilter([$categoryId]) - ->load()->getFirstItem(); - $categories[] = $category->getId(); - if ($category->getIsAnchor()) { + ->addAttributeToSelect('is_anchor') + ->addAttributeToFilter('is_anchor', 1) + ->addIdFilter([$categoryId]) + ->getFirstItem(); + if ($category) { $categoryChildren = $category->getChildren(); $categoryChildrenIds = explode(',', $categoryChildren); foreach ($categoryChildrenIds as $categoryChildrenId) { From 26816700ad5fd7e9330b8f3dce118d672f7567c6 Mon Sep 17 00:00:00 2001 From: Yuliya Labudova <Yuliya_Labudova@epam.com> Date: Thu, 4 Jul 2019 12:11:38 +0300 Subject: [PATCH 10/23] MAGETWO-94565: Catalog product collection filters produce errors and cause inconsistent behaviour - Fix CR comments. --- .../ResourceModel/Product/Collection.php | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php index 7127aa2cb3e77..b4673412d25b2 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php @@ -2068,7 +2068,7 @@ protected function _applyProductLimitations() protected function _applyZeroStoreProductLimitations() { $filters = $this->_productLimitationFilters; - $categories = $this->getChildrenCategories((int)$filters['category_id'], []); + $categories = $this->getChildrenCategories((int)$filters['category_id']); $conditions = [ 'cat_pro.product_id=e.entity_id', @@ -2099,30 +2099,22 @@ protected function _applyZeroStoreProductLimitations() * Get children categories. * * @param int $categoryId - * @param array $categories * @return array */ - private function getChildrenCategories(int $categoryId, array $categories): array + private function getChildrenCategories(int $categoryId): array { - $categories[] = $categoryId; + $categoryIds[] = $categoryId; /** @var \Magento\Catalog\Model\ResourceModel\Category\Collection $categoryCollection */ $categoryCollection = $this->categoryCollectionFactory->create(); - $category = $categoryCollection - ->addAttributeToSelect('is_anchor') + $categories = $categoryCollection ->addAttributeToFilter('is_anchor', 1) - ->addIdFilter([$categoryId]) - ->getFirstItem(); - if ($category) { + ->addAttributeToFilter('path', ['like' => $categoryId . '/%'])->getItems(); + foreach ($categories as $category) { $categoryChildren = $category->getChildren(); - $categoryChildrenIds = explode(',', $categoryChildren); - foreach ($categoryChildrenIds as $categoryChildrenId) { - if ($categoryChildrenId) { - $categories = $this->getChildrenCategories((int)$categoryChildrenId, $categories); - } - } + $categoryIds = array_merge($categoryIds, explode(',', $categoryChildren)); } - return $categories; + return $categoryIds; } /** From 723bd8d4f3386c6e0372ebac27a62b2c546cd0b4 Mon Sep 17 00:00:00 2001 From: Nikita Chubukov <nikita_chubukov@epam.com> Date: Mon, 8 Jul 2019 13:06:06 +0300 Subject: [PATCH 11/23] MC-15256: Exported customer without modification can not be imported - Integration test --- .../CustomerImportExport/Model/Import/CustomerTest.php | 5 +++++ .../Model/Import/_files/customers_to_import.csv | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Import/CustomerTest.php b/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Import/CustomerTest.php index 05d9c5d3acb1e..54890f7db3a1d 100644 --- a/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Import/CustomerTest.php +++ b/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Import/CustomerTest.php @@ -133,6 +133,11 @@ public function testImportData() $updatedCustomer->getCreatedAt(), 'Creation date must be changed' ); + $this->assertNotEquals( + $existingCustomer->getGender(), + $updatedCustomer->getGender(), + 'Gender must be changed' + ); } /** diff --git a/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Import/_files/customers_to_import.csv b/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Import/_files/customers_to_import.csv index 30a283ce0502f..96c14c67607aa 100644 --- a/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Import/_files/customers_to_import.csv +++ b/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Import/_files/customers_to_import.csv @@ -1,7 +1,7 @@ email,_website,_store,confirmation,created_at,created_in,default_billing,default_shipping,disable_auto_group_change,dob,firstname,gender,group_id,lastname,middlename,password_hash,prefix,rp_token,rp_token_created_at,store_id,suffix,taxvat,website_id,password -AnthonyANealy@magento.com,base,admin,,5/6/2012 15:53,Admin,1,1,0,5/6/2010,Anthony,Male,1,Nealy,A.,6a9c9bfb2ba88a6ad2a64e7402df44a763e0c48cd21d7af9e7e796cd4677ee28:RF,,,,0,,,1, +AnthonyANealy@magento.com,base,admin,,5/6/2012 15:53,Admin,1,1,0,5/6/2010,Anthony,Female,1,Nealy,A.,6a9c9bfb2ba88a6ad2a64e7402df44a763e0c48cd21d7af9e7e796cd4677ee28:RF,,,,0,,,1, LoriBBanks@magento.com,admin,admin,,5/6/2012 15:59,Admin,3,3,0,5/6/2010,Lori,Female,1,Banks,B.,7ad6dbdc83d3e9f598825dc58b84678c7351e4281f6bc2b277a32dcd88b9756b:pz,,,,0,,,0, CharlesTAlston@teleworm.us,base,admin,,5/6/2012 16:13,Admin,4,4,0,,Jhon,Female,1,Doe,T.,145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1,,,,0,,,2, -customer@example.com,base,admin,,5/6/2012 16:15,Admin,4,4,0,,Firstname,Male,1,Lastname,T.,145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1,,,,0,,,2, +customer@example.com,base,admin,,5/6/2012 16:15,Admin,4,4,0,,Firstname,Female,1,Lastname,T.,145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1,,,,0,,,2, julie.worrell@example.com,base,admin,,5/6/2012 16:19,Admin,4,4,0,,Julie,Female,1,Worrell,T.,145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1,,,,0,,,2, david.lamar@example.com,base,admin,,5/6/2012 16:25,Admin,4,4,0,,David,,1,Lamar,T.,145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1,,,,0,,,2, From fc328d923d1e69d46501eef17a831954adcc01a5 Mon Sep 17 00:00:00 2001 From: Yuliya Labudova <Yuliya_Labudova@epam.com> Date: Mon, 8 Jul 2019 18:00:03 +0300 Subject: [PATCH 12/23] MAGETWO-94565: Catalog product collection filters produce errors and cause inconsistent behaviour - Fix CR comments. --- .../Catalog/Model/ResourceModel/Product/Collection.php | 6 ++++-- 1 file changed, 4 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 b4673412d25b2..dffa49d97838c 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php @@ -2108,8 +2108,10 @@ private function getChildrenCategories(int $categoryId): array /** @var \Magento\Catalog\Model\ResourceModel\Category\Collection $categoryCollection */ $categoryCollection = $this->categoryCollectionFactory->create(); $categories = $categoryCollection - ->addAttributeToFilter('is_anchor', 1) - ->addAttributeToFilter('path', ['like' => $categoryId . '/%'])->getItems(); + ->addAttributeToFilter( + ['is_anchor', 'path'], + [1, ['like' => $categoryId . '/%']] + )->getItems(); foreach ($categories as $category) { $categoryChildren = $category->getChildren(); $categoryIds = array_merge($categoryIds, explode(',', $categoryChildren)); From dc8c4d35aa0f55e6ef819a1fb7087372194a4353 Mon Sep 17 00:00:00 2001 From: Nikita Chubukov <nikita_chubukov@epam.com> Date: Thu, 11 Jul 2019 01:10:15 +0300 Subject: [PATCH 13/23] MC-15256: Exported customer without modification can not be imported - Fix integration test --- .../Magento/CustomerImportExport/Model/Import/Customer.php | 4 ++-- .../Magento/Customer/_files/import_export/customer.php | 2 +- .../CustomerImportExport/Model/Import/CustomerTest.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/CustomerImportExport/Model/Import/Customer.php b/app/code/Magento/CustomerImportExport/Model/Import/Customer.php index 991d4f3558adc..33dc7e55228bf 100644 --- a/app/code/Magento/CustomerImportExport/Model/Import/Customer.php +++ b/app/code/Magento/CustomerImportExport/Model/Import/Customer.php @@ -600,14 +600,14 @@ protected function _validateRowForUpdate(array $rowData, $rowNumber) $isFieldNotSetAndCustomerDoesNotExist = !isset($rowData[$attributeCode]) && !$this->_getCustomerId($email, $website); $isFieldSetAndTrimmedValueIsEmpty - = isset($rowData[$attributeCode]) && '' === trim($rowData[$attributeCode]); + = isset($rowData[$attributeCode]) && '' === trim((string)$rowData[$attributeCode]); if ($isFieldRequired && ($isFieldNotSetAndCustomerDoesNotExist || $isFieldSetAndTrimmedValueIsEmpty)) { $this->addRowError(self::ERROR_VALUE_IS_REQUIRED, $rowNumber, $attributeCode); continue; } - if (isset($rowData[$attributeCode]) && strlen($rowData[$attributeCode])) { + if (isset($rowData[$attributeCode]) && strlen((string)$rowData[$attributeCode])) { if ($attributeParams['type'] == 'select' && empty($rowData[$attributeCode])) { continue; } diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/import_export/customer.php b/dev/tests/integration/testsuite/Magento/Customer/_files/import_export/customer.php index 215dd2a709418..3a39e62af0ccb 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/_files/import_export/customer.php +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/import_export/customer.php @@ -30,7 +30,7 @@ )->setLastname( 'Alston' )->setGender( - 2 + '2' ); $customer->isObjectNew(true); diff --git a/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Import/CustomerTest.php b/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Import/CustomerTest.php index 54890f7db3a1d..daab687408749 100644 --- a/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Import/CustomerTest.php +++ b/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Import/CustomerTest.php @@ -133,7 +133,7 @@ public function testImportData() $updatedCustomer->getCreatedAt(), 'Creation date must be changed' ); - $this->assertNotEquals( + $this->assertEquals( $existingCustomer->getGender(), $updatedCustomer->getGender(), 'Gender must be changed' From b92cd06916cb62447fe11501a7dbafb7b866566d Mon Sep 17 00:00:00 2001 From: Nikita Chubukov <nikita_chubukov@epam.com> Date: Tue, 13 Aug 2019 21:52:06 +0300 Subject: [PATCH 14/23] MC-15256: Exported customer without modification can not be imported - Fix CR comments --- app/code/Magento/CustomerImportExport/Model/Import/Customer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/CustomerImportExport/Model/Import/Customer.php b/app/code/Magento/CustomerImportExport/Model/Import/Customer.php index 33dc7e55228bf..914b4fd2a3ca9 100644 --- a/app/code/Magento/CustomerImportExport/Model/Import/Customer.php +++ b/app/code/Magento/CustomerImportExport/Model/Import/Customer.php @@ -608,7 +608,7 @@ protected function _validateRowForUpdate(array $rowData, $rowNumber) } if (isset($rowData[$attributeCode]) && strlen((string)$rowData[$attributeCode])) { - if ($attributeParams['type'] == 'select' && empty($rowData[$attributeCode])) { + if ($attributeParams['type'] == 'select') { continue; } From 5164240b200d05ed496cd8011f5ab7d2907e4fc6 Mon Sep 17 00:00:00 2001 From: Nikita Chubukov <nikita_chubukov@epam.com> Date: Sat, 17 Aug 2019 21:31:39 +0300 Subject: [PATCH 15/23] MC-15256: Exported customer without modification can not be imported - Fix static test --- app/code/Magento/CustomerImportExport/Model/Import/Customer.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/code/Magento/CustomerImportExport/Model/Import/Customer.php b/app/code/Magento/CustomerImportExport/Model/Import/Customer.php index 914b4fd2a3ca9..563bd2cd7f2b9 100644 --- a/app/code/Magento/CustomerImportExport/Model/Import/Customer.php +++ b/app/code/Magento/CustomerImportExport/Model/Import/Customer.php @@ -521,8 +521,10 @@ protected function _importData() ); } elseif ($this->getBehavior($rowData) == \Magento\ImportExport\Model\Import::BEHAVIOR_ADD_UPDATE) { $processedData = $this->_prepareDataForUpdate($rowData); + // phpcs:disable Magento2.Performance.ForeachArrayMerge $entitiesToCreate = array_merge($entitiesToCreate, $processedData[self::ENTITIES_TO_CREATE_KEY]); $entitiesToUpdate = array_merge($entitiesToUpdate, $processedData[self::ENTITIES_TO_UPDATE_KEY]); + // phpcs:enable foreach ($processedData[self::ATTRIBUTES_TO_SAVE_KEY] as $tableName => $customerAttributes) { if (!isset($attributesToSave[$tableName])) { $attributesToSave[$tableName] = []; From 8c33bbd093c9680f2e9d04616818047ec9893203 Mon Sep 17 00:00:00 2001 From: Yuliya Labudova <Yuliya_Labudova@epam.com> Date: Mon, 26 Aug 2019 14:08:52 +0300 Subject: [PATCH 16/23] MAGETWO-94565: Catalog product collection filters produce errors and cause inconsistent behaviour - Replace using category collection to using db. --- .../Catalog/Model/ResourceModel/Category.php | 40 ++++++++++++++++++ .../ResourceModel/Product/Collection.php | 41 +++++++++++-------- 2 files changed, 63 insertions(+), 18 deletions(-) diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Category.php b/app/code/Magento/Catalog/Model/ResourceModel/Category.php index 536fda7e093d3..3794dbf46579f 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Category.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Category.php @@ -9,11 +9,14 @@ * * @author Magento Core Team <core@magentocommerce.com> */ +declare(strict_types=1); + namespace Magento\Catalog\Model\ResourceModel; use Magento\Catalog\Model\Indexer\Category\Product\Processor; use Magento\Framework\DataObject; use Magento\Framework\EntityManager\EntityManager; +use Magento\Catalog\Setup\CategorySetup; /** * Resource model for category entity @@ -1132,4 +1135,41 @@ private function getAggregateCount() } return $this->aggregateCount; } + + /** + * Get category with children. + * + * @param int $categoryId + * @return array + */ + public function getCategoryWithChildren(int $categoryId): array + { + $connection = $this->getConnection(); + + $select = $connection->select() + ->from( + ['eav_attribute' => $this->getTable('eav_attribute')], + ['attribute_id'] + )->where('entity_type_id = ?', CategorySetup::CATEGORY_ENTITY_TYPE_ID) + ->where('attribute_code = ?', 'is_anchor') + ->limit(1); + $attributeId = $connection->fetchRow($select); + + $select = $connection->select() + ->from( + ['cce' => $this->getTable('catalog_category_entity')], + ['entity_id', 'parent_id', 'path'] + )->join( + ['cce_int' => $this->getTable('catalog_category_entity_int')], + 'cce.entity_id = cce_int.entity_id', + ['is_anchor' => 'cce_int.value'] + )->where( + 'cce_int.attribute_id = ?', + $attributeId['attribute_id'] + )->where( + "cce.path LIKE '%/{$categoryId}' OR cce.path LIKE '%/{$categoryId}/%'" + )->order('path'); + + return $connection->fetchAll($select); + } } diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php index dffa49d97838c..71b03620b342b 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php @@ -23,7 +23,7 @@ use Magento\Framework\Indexer\DimensionFactory; use Magento\Store\Model\Indexer\WebsiteDimensionProvider; use Magento\Store\Model\Store; -use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory; +use Magento\Catalog\Model\ResourceModel\Category; /** * Product collection @@ -305,9 +305,9 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Collection\Abstrac private $urlFinder; /** - * @var CollectionFactory + * @var Category */ - private $categoryCollectionFactory; + private $categoryResourceModel; /** * Collection constructor @@ -337,7 +337,7 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Collection\Abstrac * @param TableMaintainer|null $tableMaintainer * @param PriceTableResolver|null $priceTableResolver * @param DimensionFactory|null $dimensionFactory - * @param CollectionFactory|null $categoryCollectionFactory + * @param Category|null $categoryResourceModel * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -367,7 +367,7 @@ public function __construct( TableMaintainer $tableMaintainer = null, PriceTableResolver $priceTableResolver = null, DimensionFactory $dimensionFactory = null, - CollectionFactory $categoryCollectionFactory = null + Category $categoryResourceModel = null ) { $this->moduleManager = $moduleManager; $this->_catalogProductFlatState = $catalogProductFlatState; @@ -401,8 +401,8 @@ public function __construct( $this->priceTableResolver = $priceTableResolver ?: ObjectManager::getInstance()->get(PriceTableResolver::class); $this->dimensionFactory = $dimensionFactory ?: ObjectManager::getInstance()->get(DimensionFactory::class); - $this->categoryCollectionFactory = $categoryCollectionFactory ?: ObjectManager::getInstance() - ->get(CollectionFactory::class); + $this->categoryResourceModel = $categoryResourceModel ?: ObjectManager::getInstance() + ->get(Category::class); } /** @@ -2104,18 +2104,23 @@ protected function _applyZeroStoreProductLimitations() private function getChildrenCategories(int $categoryId): array { $categoryIds[] = $categoryId; - - /** @var \Magento\Catalog\Model\ResourceModel\Category\Collection $categoryCollection */ - $categoryCollection = $this->categoryCollectionFactory->create(); - $categories = $categoryCollection - ->addAttributeToFilter( - ['is_anchor', 'path'], - [1, ['like' => $categoryId . '/%']] - )->getItems(); - foreach ($categories as $category) { - $categoryChildren = $category->getChildren(); - $categoryIds = array_merge($categoryIds, explode(',', $categoryChildren)); + $anchorCategory = []; + + $categories = $this->categoryResourceModel->getCategoryWithChildren($categoryId); + $firstCategory = array_shift($categories); + if ($firstCategory['is_anchor'] == 1) { + $anchorCategory[] = (int)$firstCategory['entity_id']; + foreach ($categories as $category) { + if (in_array($category['parent_id'], $categoryIds) + && in_array($category['parent_id'], $anchorCategory)) { + $categoryIds[] = (int)$category['entity_id']; + if ($category['is_anchor'] == 1) { + $anchorCategory[] = (int)$category['entity_id']; + } + } + } } + return $categoryIds; } From 3ccf1d99d3db16ae2dc9a6ebd97e62b931af6720 Mon Sep 17 00:00:00 2001 From: Yuliya Labudova <Yuliya_Labudova@epam.com> Date: Mon, 26 Aug 2019 17:43:38 +0300 Subject: [PATCH 17/23] MAGETWO-94565: Catalog product collection filters produce errors and cause inconsistent behaviour - Fix magento category installation. --- app/code/Magento/Catalog/Model/ResourceModel/Category.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Category.php b/app/code/Magento/Catalog/Model/ResourceModel/Category.php index cfc82d9b4ae94..d50570930923e 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Category.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Category.php @@ -278,7 +278,7 @@ protected function _beforeSave(\Magento\Framework\DataObject $object) if ($object->getPosition() === null) { $object->setPosition($this->_getMaxPosition($object->getPath()) + 1); } - $path = explode('/', $object->getPath()); + $path = explode('/', (string)$object->getPath()); $level = count($path) - ($object->getId() ? 1 : 0); $toUpdateChild = array_diff($path, [$object->getId()]); @@ -317,7 +317,7 @@ protected function _afterSave(\Magento\Framework\DataObject $object) /** * Add identifier for new category */ - if (substr($object->getPath(), -1) == '/') { + if (substr((string)$object->getPath(), -1) == '/') { $object->setPath($object->getPath() . $object->getId()); $this->_savePath($object); } From 35620e2723c70ee1284682fe4abd2504594e2e6b Mon Sep 17 00:00:00 2001 From: Yuliya Labudova <Yuliya_Labudova@epam.com> Date: Tue, 27 Aug 2019 11:04:42 +0300 Subject: [PATCH 18/23] MAGETWO-94565: Catalog product collection filters produce errors and cause inconsistent behaviour - Fix strict types. --- app/code/Magento/Catalog/Model/ResourceModel/Category.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Category.php b/app/code/Magento/Catalog/Model/ResourceModel/Category.php index d50570930923e..b6f565f5fae4e 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Category.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Category.php @@ -355,7 +355,7 @@ protected function _getMaxPosition($path) { $connection = $this->getConnection(); $positionField = $connection->quoteIdentifier('position'); - $level = count(explode('/', $path)); + $level = count(explode('/', (string)$path)); $bind = ['c_level' => $level, 'c_path' => $path . '/%']; $select = $connection->select()->from( $this->getTable('catalog_category_entity'), @@ -720,7 +720,7 @@ public function getCategories($parent, $recursionLevel = 0, $sorted = false, $as */ public function getParentCategories($category) { - $pathIds = array_reverse(explode(',', $category->getPathInStore())); + $pathIds = array_reverse(explode(',', (string)$category->getPathInStore())); /** @var \Magento\Catalog\Model\ResourceModel\Category\Collection $categories */ $categories = $this->_categoryCollectionFactory->create(); return $categories->setStore( From 882bbaec90da72afbe74ca4540d332146da8536a Mon Sep 17 00:00:00 2001 From: Yuliya Labudova <Yuliya_Labudova@epam.com> Date: Wed, 4 Sep 2019 12:37:12 +0300 Subject: [PATCH 19/23] MAGETWO-94565: Catalog product collection filters produce errors and cause inconsistent behaviour - Change fetchRow to fetchOne. --- app/code/Magento/Catalog/Model/ResourceModel/Category.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Category.php b/app/code/Magento/Catalog/Model/ResourceModel/Category.php index b6f565f5fae4e..fb8c089ed9f9a 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Category.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Category.php @@ -1148,14 +1148,13 @@ public function getCategoryWithChildren(int $categoryId): array { $connection = $this->getConnection(); - $select = $connection->select() + $selectAttributeCode = $connection->select() ->from( ['eav_attribute' => $this->getTable('eav_attribute')], ['attribute_id'] )->where('entity_type_id = ?', CategorySetup::CATEGORY_ENTITY_TYPE_ID) ->where('attribute_code = ?', 'is_anchor') ->limit(1); - $attributeId = $connection->fetchRow($select); $select = $connection->select() ->from( @@ -1167,7 +1166,7 @@ public function getCategoryWithChildren(int $categoryId): array ['is_anchor' => 'cce_int.value'] )->where( 'cce_int.attribute_id = ?', - $attributeId['attribute_id'] + $connection->fetchOne($selectAttributeCode) )->where( "cce.path LIKE '%/{$categoryId}' OR cce.path LIKE '%/{$categoryId}/%'" )->order('path'); From 976bd23483deb6a02c5e2eb2ee8754e834db026e Mon Sep 17 00:00:00 2001 From: Nikita Chubukov <nikita_chubukov@epam.com> Date: Wed, 4 Sep 2019 12:37:37 +0300 Subject: [PATCH 20/23] MC-15256: Exported customer without modification can not be imported - Fix CR comments --- .../CustomerImportExport/Model/Import/CustomerTest.php | 2 +- .../Model/Import/_files/customers_to_import.csv | 4 ++-- .../Import/_files/customers_with_gender_to_import.csv | 7 +++++++ 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Import/_files/customers_with_gender_to_import.csv diff --git a/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Import/CustomerTest.php b/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Import/CustomerTest.php index daab687408749..77ceae27e0774 100644 --- a/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Import/CustomerTest.php +++ b/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Import/CustomerTest.php @@ -78,7 +78,7 @@ public function testImportData() $expectAddedCustomers = 5; $source = new \Magento\ImportExport\Model\Import\Source\Csv( - __DIR__ . '/_files/customers_to_import.csv', + __DIR__ . '/_files/customers_with_gender_to_import.csv', $this->directoryWrite ); diff --git a/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Import/_files/customers_to_import.csv b/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Import/_files/customers_to_import.csv index 96c14c67607aa..30a283ce0502f 100644 --- a/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Import/_files/customers_to_import.csv +++ b/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Import/_files/customers_to_import.csv @@ -1,7 +1,7 @@ email,_website,_store,confirmation,created_at,created_in,default_billing,default_shipping,disable_auto_group_change,dob,firstname,gender,group_id,lastname,middlename,password_hash,prefix,rp_token,rp_token_created_at,store_id,suffix,taxvat,website_id,password -AnthonyANealy@magento.com,base,admin,,5/6/2012 15:53,Admin,1,1,0,5/6/2010,Anthony,Female,1,Nealy,A.,6a9c9bfb2ba88a6ad2a64e7402df44a763e0c48cd21d7af9e7e796cd4677ee28:RF,,,,0,,,1, +AnthonyANealy@magento.com,base,admin,,5/6/2012 15:53,Admin,1,1,0,5/6/2010,Anthony,Male,1,Nealy,A.,6a9c9bfb2ba88a6ad2a64e7402df44a763e0c48cd21d7af9e7e796cd4677ee28:RF,,,,0,,,1, LoriBBanks@magento.com,admin,admin,,5/6/2012 15:59,Admin,3,3,0,5/6/2010,Lori,Female,1,Banks,B.,7ad6dbdc83d3e9f598825dc58b84678c7351e4281f6bc2b277a32dcd88b9756b:pz,,,,0,,,0, CharlesTAlston@teleworm.us,base,admin,,5/6/2012 16:13,Admin,4,4,0,,Jhon,Female,1,Doe,T.,145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1,,,,0,,,2, -customer@example.com,base,admin,,5/6/2012 16:15,Admin,4,4,0,,Firstname,Female,1,Lastname,T.,145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1,,,,0,,,2, +customer@example.com,base,admin,,5/6/2012 16:15,Admin,4,4,0,,Firstname,Male,1,Lastname,T.,145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1,,,,0,,,2, julie.worrell@example.com,base,admin,,5/6/2012 16:19,Admin,4,4,0,,Julie,Female,1,Worrell,T.,145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1,,,,0,,,2, david.lamar@example.com,base,admin,,5/6/2012 16:25,Admin,4,4,0,,David,,1,Lamar,T.,145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1,,,,0,,,2, diff --git a/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Import/_files/customers_with_gender_to_import.csv b/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Import/_files/customers_with_gender_to_import.csv new file mode 100644 index 0000000000000..96c14c67607aa --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Import/_files/customers_with_gender_to_import.csv @@ -0,0 +1,7 @@ +email,_website,_store,confirmation,created_at,created_in,default_billing,default_shipping,disable_auto_group_change,dob,firstname,gender,group_id,lastname,middlename,password_hash,prefix,rp_token,rp_token_created_at,store_id,suffix,taxvat,website_id,password +AnthonyANealy@magento.com,base,admin,,5/6/2012 15:53,Admin,1,1,0,5/6/2010,Anthony,Female,1,Nealy,A.,6a9c9bfb2ba88a6ad2a64e7402df44a763e0c48cd21d7af9e7e796cd4677ee28:RF,,,,0,,,1, +LoriBBanks@magento.com,admin,admin,,5/6/2012 15:59,Admin,3,3,0,5/6/2010,Lori,Female,1,Banks,B.,7ad6dbdc83d3e9f598825dc58b84678c7351e4281f6bc2b277a32dcd88b9756b:pz,,,,0,,,0, +CharlesTAlston@teleworm.us,base,admin,,5/6/2012 16:13,Admin,4,4,0,,Jhon,Female,1,Doe,T.,145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1,,,,0,,,2, +customer@example.com,base,admin,,5/6/2012 16:15,Admin,4,4,0,,Firstname,Female,1,Lastname,T.,145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1,,,,0,,,2, +julie.worrell@example.com,base,admin,,5/6/2012 16:19,Admin,4,4,0,,Julie,Female,1,Worrell,T.,145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1,,,,0,,,2, +david.lamar@example.com,base,admin,,5/6/2012 16:25,Admin,4,4,0,,David,,1,Lamar,T.,145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1,,,,0,,,2, From 2ea7a99f9684597d36cc7422d5d0f6ebf3ea4f4f Mon Sep 17 00:00:00 2001 From: Yuliya Labudova <Yuliya_Labudova@epam.com> Date: Fri, 6 Sep 2019 11:47:56 +0300 Subject: [PATCH 21/23] MAGETWO-94565: Catalog product collection filters produce errors and cause inconsistent behaviour - Fix CR comments. --- app/code/Magento/Catalog/Model/ResourceModel/Category.php | 6 +++++- .../Catalog/Model/ResourceModel/Product/Collection.php | 4 ++++ .../Catalog/Model/ResourceModel/Product/CollectionTest.php | 7 +++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Category.php b/app/code/Magento/Catalog/Model/ResourceModel/Category.php index fb8c089ed9f9a..797ce72ae9b7a 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Category.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Category.php @@ -1155,6 +1155,10 @@ public function getCategoryWithChildren(int $categoryId): array )->where('entity_type_id = ?', CategorySetup::CATEGORY_ENTITY_TYPE_ID) ->where('attribute_code = ?', 'is_anchor') ->limit(1); + $isAnchorAttributeCode = $connection->fetchOne($selectAttributeCode); + if (empty($isAnchorAttributeCode) || (int)$isAnchorAttributeCode <= 0) { + return []; + } $select = $connection->select() ->from( @@ -1166,7 +1170,7 @@ public function getCategoryWithChildren(int $categoryId): array ['is_anchor' => 'cce_int.value'] )->where( 'cce_int.attribute_id = ?', - $connection->fetchOne($selectAttributeCode) + $isAnchorAttributeCode )->where( "cce.path LIKE '%/{$categoryId}' OR cce.path LIKE '%/{$categoryId}/%'" )->order('path'); diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php index 71b03620b342b..42d55892b6ec6 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php @@ -2107,6 +2107,10 @@ private function getChildrenCategories(int $categoryId): array $anchorCategory = []; $categories = $this->categoryResourceModel->getCategoryWithChildren($categoryId); + if (empty($categories)) { + return $categoryIds; + } + $firstCategory = array_shift($categories); if ($firstCategory['is_anchor'] == 1) { $anchorCategory[] = (int)$firstCategory['entity_id']; diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/Product/CollectionTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/Product/CollectionTest.php index 80d700c7e54ff..d3970ad403ffd 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/Product/CollectionTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/Product/CollectionTest.php @@ -99,6 +99,7 @@ public function testAddPriceDataOnSchedule() /** * @magentoDataFixture Magento/Catalog/_files/products.php + * @magentoAppIsolation enabled * @magentoDbIsolation disabled */ public function testSetVisibility() @@ -116,6 +117,7 @@ public function testSetVisibility() /** * @magentoDataFixture Magento/Catalog/_files/category_product.php + * @magentoAppIsolation enabled * @magentoDbIsolation disabled */ public function testSetCategoryWithStoreFilter() @@ -131,8 +133,8 @@ public function testSetCategoryWithStoreFilter() $this->collection->load(); $collectionStoreFilterAfter = Bootstrap::getObjectManager()->create( - \Magento\Catalog\Model\ResourceModel\Product\Collection::class - ); + \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory::class + )->create(); $collectionStoreFilterAfter->addStoreFilter(1)->addCategoryFilter($category); $collectionStoreFilterAfter->load(); $this->assertEquals($this->collection->getItems(), $collectionStoreFilterAfter->getItems()); @@ -141,6 +143,7 @@ public function testSetCategoryWithStoreFilter() /** * @magentoDataFixture Magento/Catalog/_files/categories.php + * @magentoAppIsolation enabled * @magentoDbIsolation disabled */ public function testSetCategoryFilter() From 08e446e28f4f9949eb9a907e74c4d544578ab787 Mon Sep 17 00:00:00 2001 From: Yuliya Labudova <Yuliya_Labudova@epam.com> Date: Mon, 9 Sep 2019 10:31:40 +0300 Subject: [PATCH 22/23] MAGETWO-94565: Catalog product collection filters produce errors and cause inconsistent behaviour - Fix static tests. --- .../Catalog/Model/ResourceModel/Product/CollectionTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/Product/CollectionTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/Product/CollectionTest.php index d3970ad403ffd..de0e881474cf0 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/Product/CollectionTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/Product/CollectionTest.php @@ -15,6 +15,8 @@ /** * Collection test + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class CollectionTest extends \PHPUnit\Framework\TestCase { From 81c3ae3a075507c9e449f70d6d92adbfaca69fd3 Mon Sep 17 00:00:00 2001 From: Nikita Chubukov <nikita_chubukov@epam.com> Date: Mon, 16 Sep 2019 16:38:31 +0300 Subject: [PATCH 23/23] MC-15256: Exported customer without modification can not be imported - Fix static test --- app/code/Magento/CustomerImportExport/Model/Import/Customer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/CustomerImportExport/Model/Import/Customer.php b/app/code/Magento/CustomerImportExport/Model/Import/Customer.php index 563bd2cd7f2b9..f86ebaea69730 100644 --- a/app/code/Magento/CustomerImportExport/Model/Import/Customer.php +++ b/app/code/Magento/CustomerImportExport/Model/Import/Customer.php @@ -23,7 +23,7 @@ class Customer extends AbstractCustomer { /** - * Attribute collection name + * Collection name attribute */ const ATTRIBUTE_COLLECTION_NAME = \Magento\Customer\Model\ResourceModel\Attribute\Collection::class;