Skip to content

Commit 1ca61ca

Browse files
author
Volodymyr Kublytskyi
authored
MAGETWO-84652: Category page X-Magento-Tags headers contains product cache identities even which category display mode is set to "Static block only" magento#12466
2 parents 82caf48 + 3216e80 commit 1ca61ca

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

app/code/Magento/Catalog/Block/Product/ListProduct.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,13 +334,21 @@ public function prepareSortableFieldsByCategory($category)
334334
public function getIdentities()
335335
{
336336
$identities = [];
337-
foreach ($this->_getProductCollection() as $item) {
338-
$identities = array_merge($identities, $item->getIdentities());
339-
}
337+
340338
$category = $this->getLayer()->getCurrentCategory();
341339
if ($category) {
342340
$identities[] = Product::CACHE_PRODUCT_CATEGORY_TAG . '_' . $category->getId();
343341
}
342+
343+
//Check if category page shows only static block (No products)
344+
if ($category->getData('display_mode') == Category::DM_PAGE) {
345+
return $identities;
346+
}
347+
348+
foreach ($this->_getProductCollection() as $item) {
349+
$identities = array_merge($identities, $item->getIdentities());
350+
}
351+
344352
return $identities;
345353
}
346354

app/code/Magento/Catalog/Test/Unit/Block/Product/ListProductTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public function testGetIdentities()
192192
->will($this->returnValue($this->toolbarMock));
193193

194194
$this->assertEquals(
195-
[$productTag, $categoryTag],
195+
[$categoryTag, $productTag],
196196
$this->block->getIdentities()
197197
);
198198
$this->assertEquals(

0 commit comments

Comments
 (0)