Skip to content

Commit 76a0829

Browse files
authored
Merge pull request #5829 from magento-tango/MC-35149
MC-35149: Category update clean cache by cat_c tag
2 parents a620729 + 2187b8b commit 76a0829

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

app/code/Magento/Catalog/Model/Category.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements
8787
*
8888
* @var string
8989
*/
90-
protected $_cacheTag = self::CACHE_TAG;
90+
protected $_cacheTag = false;
9191

9292
/**
9393
* URL Model instance
@@ -1109,6 +1109,17 @@ public function afterSave()
11091109
return $result;
11101110
}
11111111

1112+
/**
1113+
* @inheritDoc
1114+
*/
1115+
public function getCacheTags()
1116+
{
1117+
$identities = $this->getIdentities();
1118+
$cacheTags = !empty($identities) ? (array) $identities : parent::getCacheTags();
1119+
1120+
return $cacheTags;
1121+
}
1122+
11121123
/**
11131124
* Init indexing process after category save
11141125
*

app/code/Magento/Catalog/Model/Product.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use Magento\Catalog\Api\Data\ProductInterface;
1111
use Magento\Catalog\Api\ProductLinkRepositoryInterface;
1212
use Magento\Catalog\Model\Product\Attribute\Backend\Media\EntryConverterPool;
13-
use Magento\Catalog\Model\FilterProductCustomAttribute;
1413
use Magento\Framework\Api\AttributeValueFactory;
1514
use Magento\Framework\App\Filesystem\DirectoryList;
1615
use Magento\Framework\App\ObjectManager;
@@ -973,6 +972,17 @@ public function afterSave()
973972
return $result;
974973
}
975974

975+
/**
976+
* @inheritDoc
977+
*/
978+
public function getCacheTags()
979+
{
980+
$identities = $this->getIdentities();
981+
$cacheTags = !empty($identities) ? (array) $identities : parent::getCacheTags();
982+
983+
return $cacheTags;
984+
}
985+
976986
/**
977987
* Set quantity for product
978988
*
@@ -2162,6 +2172,7 @@ public function reset()
21622172
*/
21632173
public function getCacheIdTags()
21642174
{
2175+
// phpstan:ignore "Call to an undefined static method"
21652176
$tags = parent::getCacheIdTags();
21662177
$affectedCategoryIds = $this->getAffectedCategoryIds();
21672178
if (!$affectedCategoryIds) {
@@ -2342,6 +2353,8 @@ public function isDisabled()
23422353
public function getImage()
23432354
{
23442355
$this->getTypeInstance()->setImageFromChildProduct($this);
2356+
2357+
// phpstan:ignore "Call to an undefined static method"
23452358
return parent::getImage();
23462359
}
23472360

@@ -2405,6 +2418,8 @@ public function reloadPriceInfo()
24052418
}
24062419
}
24072420

2421+
//phpcs:disable PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.MethodDoubleUnderscore
2422+
24082423
/**
24092424
* Return Data Object data in array format.
24102425
*
@@ -2432,6 +2447,8 @@ public function __toArray()
24322447
return $data;
24332448
}
24342449

2450+
//phpcs:enable PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.MethodDoubleUnderscore
2451+
24352452
/**
24362453
* Convert Category model into flat array.
24372454
*

app/code/Magento/Catalog/etc/frontend/di.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@
1313
</argument>
1414
</arguments>
1515
</virtualType>
16-
<type name="Magento\Catalog\Model\ResourceModel\Category\Collection">
17-
<arguments>
18-
<argument name="fetchStrategy" xsi:type="object">Magento\Catalog\Model\ResourceModel\Category\Collection\FetchStrategy</argument>
19-
</arguments>
20-
</type>
2116
<type name="Magento\Catalog\Model\Indexer\AbstractFlatState">
2217
<arguments>
2318
<argument name="isAvailable" xsi:type="boolean">true</argument>

0 commit comments

Comments
 (0)