Skip to content

Commit

Permalink
MAGETWO-84652: Category page X-Magento-Tags headers contains product …
Browse files Browse the repository at this point in the history
…cache identities even which category display mode is set to "Static block only" #12466
  • Loading branch information
Volodymyr Kublytskyi committed Dec 1, 2017
2 parents 82caf48 + 3216e80 commit 1ca61ca
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 11 additions & 3 deletions app/code/Magento/Catalog/Block/Product/ListProduct.php
Expand Up @@ -334,13 +334,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;
}

Expand Down
Expand Up @@ -192,7 +192,7 @@ public function testGetIdentities()
->will($this->returnValue($this->toolbarMock));

$this->assertEquals(
[$productTag, $categoryTag],
[$categoryTag, $productTag],
$this->block->getIdentities()
);
$this->assertEquals(
Expand Down

0 comments on commit 1ca61ca

Please sign in to comment.