From 960dcca3b1d692438c116ad37d7b1c864cefca3e Mon Sep 17 00:00:00 2001 From: Atish Goswami Date: Sat, 2 Dec 2017 12:18:20 +0530 Subject: [PATCH] Related to PR #12466 [BACKPORT 2.3] --- .../Magento/Catalog/Block/Product/ListProduct.php | 14 +++++++++++--- .../Test/Unit/Block/Product/ListProductTest.php | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Catalog/Block/Product/ListProduct.php b/app/code/Magento/Catalog/Block/Product/ListProduct.php index 7289aa85ea016..4a7d28c383d8b 100644 --- a/app/code/Magento/Catalog/Block/Product/ListProduct.php +++ b/app/code/Magento/Catalog/Block/Product/ListProduct.php @@ -265,13 +265,21 @@ public function prepareSortableFieldsByCategory($category) public function getIdentities() { $identities = []; - foreach ($this->_getProductCollection() as $item) { - $identities = array_merge($identities, $item->getIdentities()); - } + $category = $this->getLayer()->getCurrentCategory(); if ($category) { $identities[] = Product::CACHE_PRODUCT_CATEGORY_TAG . '_' . $category->getId(); } + + //Check if category page shows only static block (No products) + if ($category->getData('display_mode') == Category::DM_PAGE) { + return $identities; + } + + foreach ($this->_getProductCollection() as $item) { + $identities = array_merge($identities, $item->getIdentities()); + } + return $identities; } diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/ListProductTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/ListProductTest.php index b42357db89041..fe07f69e8046f 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Product/ListProductTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/ListProductTest.php @@ -192,7 +192,7 @@ public function testGetIdentities() ->will($this->returnValue($this->toolbarMock)); $this->assertEquals( - [$productTag, $categoryTag], + [$categoryTag, $productTag], $this->block->getIdentities() ); $this->assertEquals(