From e2f29b5539c18fdb808a6ac556b3858ce58d999d Mon Sep 17 00:00:00 2001 From: Stanislav Ilnytskyi Date: Sat, 29 Oct 2022 12:15:32 +0200 Subject: [PATCH 1/7] Use current sore id for category runtime cache --- app/code/Magento/Catalog/Model/CategoryRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/Model/CategoryRepository.php b/app/code/Magento/Catalog/Model/CategoryRepository.php index 7082fa4747fdc..9a6d007c58c08 100644 --- a/app/code/Magento/Catalog/Model/CategoryRepository.php +++ b/app/code/Magento/Catalog/Model/CategoryRepository.php @@ -147,7 +147,7 @@ public function save(CategoryInterface $category) */ public function get($categoryId, $storeId = null) { - $cacheKey = $storeId ?? 'all'; + $cacheKey = $storeId ?? $this->storeManager->getStore()->getId(); if (!isset($this->instances[$categoryId][$cacheKey])) { /** @var Category $category */ $category = $this->categoryFactory->create(); From e492a44aa3ec14cfba20512522d6787349ba0a01 Mon Sep 17 00:00:00 2001 From: Stanislav Ilnytskyi Date: Sat, 3 Dec 2022 09:15:16 +0100 Subject: [PATCH 2/7] fix static test --- app/code/Magento/Catalog/Model/CategoryRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/Model/CategoryRepository.php b/app/code/Magento/Catalog/Model/CategoryRepository.php index 9a6d007c58c08..9c25acdf44fd4 100644 --- a/app/code/Magento/Catalog/Model/CategoryRepository.php +++ b/app/code/Magento/Catalog/Model/CategoryRepository.php @@ -229,7 +229,7 @@ protected function validateCategory(Category $category) * Lazy loader for the converter. * * @return ExtensibleDataObjectConverter - * + * phpcs:disable Magento2.Annotation.MethodAnnotationStructure * @deprecated 101.0.0 */ private function getExtensibleDataObjectConverter() From 27141dadb1acadcb3c4f1780e7c14d512f79c40e Mon Sep 17 00:00:00 2001 From: Stanislav Ilnytskyi Date: Mon, 24 Apr 2023 19:52:43 +0200 Subject: [PATCH 3/7] fix integration tests --- app/code/Magento/Catalog/Model/ResourceModel/Category.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Category.php b/app/code/Magento/Catalog/Model/ResourceModel/Category.php index 35828fc8ec117..cd637e827c8e3 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Category.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Category.php @@ -36,8 +36,6 @@ class Category extends AbstractResource protected $_tree; /** - * Catalog products table name - * * @var string */ protected $_categoryProductTable; @@ -48,15 +46,11 @@ class Category extends AbstractResource private $entitiesWhereAttributesIs; /** - * Id of 'is_active' category attribute - * * @var int */ protected $_isActiveAttributeId = null; /** - * Id of store - * * @var int */ protected $_storeId = null; @@ -454,7 +448,7 @@ protected function _saveCategoryProducts($category) 'position' => (int)$position, ]; } - $connection->insertMultiple($this->getCategoryProductTable(), $data); + $connection->insertOnDuplicate($this->getCategoryProductTable(), $data, ['position']); } /** From ef72911db0407d45b90395ea59b4f1cd8bca99e9 Mon Sep 17 00:00:00 2001 From: engcom-Dash Date: Mon, 21 Oct 2024 22:10:20 +0530 Subject: [PATCH 4/7] 36394: Fix integration tests --- .../Catalog/Controller/Adminhtml/CategoryTest.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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..a796ac5892b60 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php @@ -178,7 +178,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')); } /** @@ -783,10 +783,14 @@ public function testSaveDesign(): void $category->load(2); $this->assertEquals('2columns-left', $category->getData('page_layout')); $this->assertEmpty($category->getData('custom_layout_update_file')); - $this->assertEquals('test', $category->getData('description')); + $this->assertEquals('Custom Description', $category->getData('description')); //No new error messages + $sessionErrorMessages = [ + 'Not allowed to edit the category\'s design attributes', + 'Not allowed to edit the category\'s design attributes' + ]; $this->assertSessionMessages( - self::equalTo($sessionMessages), + self::equalTo($sessionErrorMessages), MessageInterface::TYPE_ERROR ); } From dfd4ac3636c41fa4f61845151aa7d3a812e8bc5c Mon Sep 17 00:00:00 2001 From: engcom-Dash Date: Tue, 22 Oct 2024 12:50:15 +0530 Subject: [PATCH 5/7] 36394: Fix integration and static failures --- .../Adminhtml/Category/Save/UpdateCategoryTest.php | 3 +-- .../Catalog/Controller/Adminhtml/CategoryTest.php | 9 ++------- 2 files changed, 3 insertions(+), 9 deletions(-) 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..8d59193eba066 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 @@ -48,10 +48,9 @@ protected function setUp(): void public function testUpdateCategoryForDefaultStoreView(array $postData): void { $storeId = (int)$this->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 a796ac5892b60..7fc0feb6a68cc 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php @@ -153,7 +153,6 @@ public function testDefaultValueForCategoryUrlPath(): void $categoryId = 3; $category = $this->categoryRepository->get($categoryId); $newUrlPath = 'test_url_path'; - $defaultUrlPath = $category->getData('url_path'); // update url_path and check it $category->setStoreId(1); @@ -783,14 +782,10 @@ public function testSaveDesign(): void $category->load(2); $this->assertEquals('2columns-left', $category->getData('page_layout')); $this->assertEmpty($category->getData('custom_layout_update_file')); - $this->assertEquals('Custom Description', $category->getData('description')); + $this->assertEquals('test', $category->getData('description')); //No new error messages - $sessionErrorMessages = [ - 'Not allowed to edit the category\'s design attributes', - 'Not allowed to edit the category\'s design attributes' - ]; $this->assertSessionMessages( - self::equalTo($sessionErrorMessages), + self::equalTo($sessionMessages), MessageInterface::TYPE_ERROR ); } From 936be8c1ad32a08980e9eda897a9685d1f372357 Mon Sep 17 00:00:00 2001 From: engcom-Dash Date: Wed, 23 Oct 2024 12:25:41 +0530 Subject: [PATCH 6/7] 36394: Fix static failures realted to copyright tag --- app/code/Magento/Catalog/Model/CategoryRepository.php | 5 ++--- app/code/Magento/Catalog/Model/ResourceModel/Category.php | 4 ++-- .../Adminhtml/Category/Save/UpdateCategoryTest.php | 4 ++-- .../Magento/Catalog/Controller/Adminhtml/CategoryTest.php | 4 ++-- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/app/code/Magento/Catalog/Model/CategoryRepository.php b/app/code/Magento/Catalog/Model/CategoryRepository.php index e99be7aaa4d26..c9b8c2027408b 100644 --- a/app/code/Magento/Catalog/Model/CategoryRepository.php +++ b/app/code/Magento/Catalog/Model/CategoryRepository.php @@ -1,8 +1,7 @@ Date: Mon, 28 Oct 2024 14:36:51 +0530 Subject: [PATCH 7/7] 36394: Fix failure integration tests --- .../Observer/CategoryUrlPathAutogeneratorObserverTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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);