Skip to content

Clean eav set cache after Set save or Set delete #38864

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 1 commit 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
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,39 @@ protected function _afterSave(\Magento\Framework\Model\AbstractModel $object)
}
}

if ($this->eavConfig->isCacheEnabled()) {
$this->eavConfig->getCache()->remove($this->getCacheKey());
$this->eavConfig->getCache()->remove($this->getCacheKey($object->getEntityId()));
}

return parent::_afterSave($object);
}

/**
* Perform actions after object delete
*
* @param \Magento\Framework\Model\AbstractModel|\Magento\Framework\DataObject $object
* @return $this
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
protected function _afterDelete(\Magento\Framework\Model\AbstractModel $object)
{
if ($this->eavConfig->isCacheEnabled()) {
$this->eavConfig->getCache()->remove($this->getCacheKey($object->getEntityId()));
}

return parent::_afterDelete($object);
}

/**
* @param null|int|string $setId
* @return string
*/
protected function getCacheKey($setId = null): string
{
return self::ATTRIBUTES_CACHE_ID . $setId;
}

/**
* Perform actions before object delete
*
Expand Down Expand Up @@ -150,7 +180,7 @@ public function validate($object, $attributeSetName)
*/
public function getSetInfo(array $attributeIds, $setId = null)
{
$cacheKey = self::ATTRIBUTES_CACHE_ID . $setId;
$cacheKey = $this->getCacheKey($setId);

if ($this->eavConfig->isCacheEnabled() && ($cache = $this->eavConfig->getCache()->load($cacheKey))) {
$setInfoData = $this->getSerializer()->unserialize($cache);
Expand Down