Skip to content

39056: Product stock status change does not purge product varnish cache #39118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: 2.4-develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/code/Magento/CatalogInventory/Model/Indexer/Stock.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function __construct(
public function execute($ids)
{
$this->_productStockIndexerRows->execute($ids);
$this->getCacheContext()->registerEntities(ProductModel::CACHE_TAG, $ids);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implementation is cleanup all caches in case on changes to a inventory, not only in. case of inventory status.
As result product page/category page cache will be cleanup after any checkout and significanly reduce cache hit/miss

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the main idea. We need to update product page in case ANY inventory change for product, not only status but also quantity.
ERP updates inventory using API and we need product pages updated accordingly.
Maybe its not suitable for Magento platform itself, in this case just close this.

}

/**
Expand Down Expand Up @@ -82,6 +83,7 @@ public function executeFull()
public function executeList(array $ids)
{
$this->_productStockIndexerRows->execute($ids);
$this->getCacheContext()->registerEntities(ProductModel::CACHE_TAG, $ids);
}

/**
Expand All @@ -94,6 +96,7 @@ public function executeList(array $ids)
public function executeRow($id)
{
$this->_productStockIndexerRow->execute($id);
$this->getCacheContext()->registerEntities(ProductModel::CACHE_TAG, [$id]);
}

/**
Expand Down