diff --git a/Model/Config.php b/Model/Config.php
index 2fa0f13..b36ec18 100644
--- a/Model/Config.php
+++ b/Model/Config.php
@@ -14,6 +14,7 @@ class Config
private const OCS_GENERAL_IS_ENABLED_PATH = 'optimize_cache_size/general/enabled';
private const OCS_GENERAL_PRODUCT_ID_PATH = 'optimize_cache_size/general/product_id';
private const OCS_GENERAL_PRODUCT_SKU_PATH = 'optimize_cache_size/general/product_sku';
+ private const OCS_GENERAL_PRODUCT_ATTRIBUTE_SET_PATH = 'optimize_cache_size/general/product_attribute_set';
private const OCS_GENERAL_CATEGORY_ID_PATH = 'optimize_cache_size/general/category_id';
public function __construct(
@@ -48,6 +49,15 @@ public function isRemoveProductSkuHandlers(int $store = 0): bool
);
}
+ public function isRemoveProductAttributeSetHandlers(int $store = 0): bool
+ {
+ return $this->scopeConfig->isSetFlag(
+ self::OCS_GENERAL_PRODUCT_ATTRIBUTE_SET_PATH,
+ ScopeInterface::SCOPE_STORE,
+ $store
+ );
+ }
+
public function isRemoveCategoryIdHandlers(int $store = 0): bool
{
return $this->scopeConfig->isSetFlag(
diff --git a/Plugin/RemoveHandlersPlugin.php b/Plugin/RemoveHandlersPlugin.php
index 8b7ba02..e3ae543 100644
--- a/Plugin/RemoveHandlersPlugin.php
+++ b/Plugin/RemoveHandlersPlugin.php
@@ -14,6 +14,7 @@ class RemoveHandlersPlugin
private const PRODUCT_ID_HANDLER_STRING = 'catalog_product_view_id_';
private const PRODUCT_SKU_HANDLER_STRING = 'catalog_product_view_sku_';
+ private const PRODUCT_ATTRIBUTE_SET_HANDLER_STRING = 'catalog_product_view_attribute_set_';
private const CATEGORY_ID_HANDLER_STRING = 'catalog_category_view_id_';
public function __construct(
@@ -45,6 +46,10 @@ public function afterAddHandle(
&& str_contains($handler, self::PRODUCT_SKU_HANDLER_STRING)) {
$result->removeHandle($handler);
}
+ if ($this->config->isRemoveProductAttributeSetHandlers()
+ && str_contains($handler, self::PRODUCT_ATTRIBUTE_SET_HANDLER_STRING)) {
+ $result->removeHandle($handler);
+ }
}
return $result;
}
diff --git a/README.md b/README.md
index b64d9d9..cd2b55a 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
# Vendic_OptimizeCacheSize
-Magento 2 extension that reduces the number of cache keys by removing `catalog_product_view_id_`, `catalog_product_view_sku_`, `catalog_category_view_id_`
+Magento 2 extension that reduces the number of cache keys by removing `catalog_product_view_id_`, `catalog_product_view_sku_`, `catalog_product_view_attribute_set_`, `catalog_category_view_id_`
layout handles **by default**,
**This means that you loose the option to have product/category specific layout handles**, unless you re-enable them via the configuration.
@@ -14,7 +14,7 @@ composer require vendic/module-optimize-cache-size
## Related discussions
- [#189 Configuration option to disable product specific layout update handles ](https://github.com/magento/magento2/issues/189#issuecomment-698430804)
- [#102 New handles for the Category, Product and CMS pages](https://github.com/magento/magento2/issues/102)
-- [#36244 Product layout based on attribute set](https://github.com/magento/magento2/pull/36244#issuecomment-2231106962) - We need to adjust this extension for Magento 2.4.8, since it's not possible to create specific layouts per attribute set. See [toonvd's comment](https://github.com/magento/magento2/pull/36244#issuecomment-2265233727)
+- [#36244 Product layout based on attribute set](https://github.com/magento/magento2/pull/36244#issuecomment-2231106962)
## Results
Here's a some real life results from a Magento 2.4 instance with 7k products and 1.5k categories:
diff --git a/composer.json b/composer.json
index 7a49fa2..efe96f1 100644
--- a/composer.json
+++ b/composer.json
@@ -1,6 +1,6 @@
{
"name": "vendic/module-optimize-cache-size",
- "description": "Magento 2 extension that reduces the number of cache keys by removing catalog_product_view_id_, catalog_product_view_sku_, catalog_category_view_id_ layout handles by default",
+ "description": "Magento 2 extension that reduces the number of cache keys by removing catalog_product_view_id_, catalog_product_view_sku_, catalog_product_view_attribute_set_, catalog_category_view_id_ layout handles by default",
"type": "magento2-module",
"require": {
"magento/framework": "*",
diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml
index df5bd7a..fcb6b03 100644
--- a/etc/adminhtml/system.xml
+++ b/etc/adminhtml/system.xml
@@ -39,6 +39,15 @@
1
+
+
+ Magento\Config\Model\Config\Source\Yesno
+ Removes catalog_product_view_attribute_set_ID handlers
+
+ 1
+
+
diff --git a/etc/config.xml b/etc/config.xml
index 7f8a85b..571c1c9 100644
--- a/etc/config.xml
+++ b/etc/config.xml
@@ -10,6 +10,7 @@
1
1
1
+ 1
1