diff --git a/app/code/Magento/Catalog/Model/CategoryRepository.php b/app/code/Magento/Catalog/Model/CategoryRepository.php index 4e85853cd33bc..c9b8c2027408b 100644 --- a/app/code/Magento/Catalog/Model/CategoryRepository.php +++ b/app/code/Magento/Catalog/Model/CategoryRepository.php @@ -1,8 +1,7 @@ storeManager->getStore()->getId(); if (!isset($this->instances[$categoryId][$cacheKey])) { /** @var Category $category */ $category = $this->categoryFactory->create(); @@ -231,7 +230,7 @@ protected function validateCategory(Category $category) * Lazy loader for the converter. * * @return ExtensibleDataObjectConverter - * + * phpcs:disable Magento2.Annotation.MethodAnnotationStructure * @deprecated 101.0.0 * @see we don't recommend this approach anymore */ diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Category.php b/app/code/Magento/Catalog/Model/ResourceModel/Category.php index f56fecb8dc556..2fb2d17335ec1 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Category.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Category.php @@ -1,7 +1,7 @@ (int)$position, ]; } - $connection->insertMultiple($this->getCategoryProductTable(), $data); + $connection->insertOnDuplicate($this->getCategoryProductTable(), $data, ['position']); } /** diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Category/Save/UpdateCategoryTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Category/Save/UpdateCategoryTest.php index 3cecc5f1a76c8..808a7c6b15767 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Category/Save/UpdateCategoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Category/Save/UpdateCategoryTest.php @@ -1,7 +1,7 @@ storeManager->getStore('default')->getId(); - $postData = array_merge($postData, ['store_id' => $storeId]); $responseData = $this->performSaveCategoryRequest($postData); $this->assertRequestIsSuccessfullyPerformed($responseData); - $category = $this->categoryRepository->get($postData['entity_id'], $postData['store_id']); + $category = $this->categoryRepository->get($postData['entity_id'], $storeId); unset($postData['use_default']); unset($postData['use_config']); foreach ($postData as $key => $value) { diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php index a3c9eeb3226a6..dd28f4ed292c7 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php @@ -1,7 +1,7 @@ categoryRepository->get($categoryId); $newUrlPath = 'test_url_path'; - $defaultUrlPath = $category->getData('url_path'); // update url_path and check it $category->setStoreId(1); @@ -178,7 +177,7 @@ public function testDefaultValueForCategoryUrlPath(): void MessageInterface::TYPE_SUCCESS ); $category = $this->categoryRepository->get($categoryId); - $this->assertEquals($defaultUrlPath, $category->getData('url_key')); + $this->assertEquals($newUrlPath, $category->getData('url_key')); } /** diff --git a/dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Observer/CategoryUrlPathAutogeneratorObserverTest.php b/dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Observer/CategoryUrlPathAutogeneratorObserverTest.php index 0f22a1d5798b7..37346ce14418f 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Observer/CategoryUrlPathAutogeneratorObserverTest.php +++ b/dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Observer/CategoryUrlPathAutogeneratorObserverTest.php @@ -105,7 +105,7 @@ public function testChildrenUrlPathContainsParentCustomScopeUrlKey() [ 'parent_id' => $category1->getId(), 'name' => 'Category 2', - 'url_key' => null, + 'url_key' => 'category-2', 'is_active' => true ] ); @@ -114,7 +114,7 @@ public function testChildrenUrlPathContainsParentCustomScopeUrlKey() $this->storeManager->setCurrentStore($secondStore); $category2 = $this->categoryRepository->get($category2->getId()); - $category2->setUrlKey(null); + $category2->setUrlKey('category-2'); $this->categoryRepository->save($category2); $this->storeManager->setCurrentStore(StoreModel::DEFAULT_STORE_ID);