diff --git a/app/code/Magento/Catalog/Model/Product.php b/app/code/Magento/Catalog/Model/Product.php index 8417219424044..07ed224e5daf9 100644 --- a/app/code/Magento/Catalog/Model/Product.php +++ b/app/code/Magento/Catalog/Model/Product.php @@ -13,6 +13,7 @@ use Magento\Catalog\Model\Product\Attribute\Source\Status; use Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface; use Magento\Framework\Api\AttributeValueFactory; +use Magento\Framework\App\Area; use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\App\ObjectManager; use Magento\Framework\DataObject\IdentityInterface; @@ -988,7 +989,6 @@ public function getCacheTags() { $identities = $this->getIdentities(); $cacheTags = !empty($identities) ? (array) $identities : parent::getCacheTags(); - return $cacheTags; } @@ -2405,7 +2405,12 @@ public function getIdentities() } } - if ($this->_appState->getAreaCode() == \Magento\Framework\App\Area::AREA_FRONTEND) { + $this->setAddDefaultCacheTag(true); + if ($this->hasDataChanges()) { + $this->setAddDefaultCacheTag(false); + } + + if ($this->_appState->getAreaCode() == Area::AREA_FRONTEND && $this->getAddDefaultCacheTag()) { $identities[] = self::CACHE_TAG; } @@ -2419,6 +2424,15 @@ public function getIdentities() return array_unique($identities); } + /** + * @inheritdoc + */ + public function afterCommitCallback() + { + $this->setAddDefaultCacheTag(false); + return parent::afterCommitCallback(); + } + /** * Check whether stock status changed *