From f2cde8fe8e9bf659d4f3afa293e592010b343cc1 Mon Sep 17 00:00:00 2001 From: David Hiendl Date: Mon, 1 Jul 2024 12:09:31 +0200 Subject: [PATCH 1/3] fix regression introduced in #2993 where attributes are not correctly pre-filtered for the layered navigation --- app/code/core/Mage/Catalog/Model/Layer.php | 14 ++++++++++++++ app/code/core/Mage/CatalogSearch/Model/Layer.php | 11 +++++++++++ 2 files changed, 25 insertions(+) diff --git a/app/code/core/Mage/Catalog/Model/Layer.php b/app/code/core/Mage/Catalog/Model/Layer.php index f8c28662773..21a8ab33625 100644 --- a/app/code/core/Mage/Catalog/Model/Layer.php +++ b/app/code/core/Mage/Catalog/Model/Layer.php @@ -212,6 +212,9 @@ public function getFilterableAttributes() foreach ($setAttributeIds as $attributeId) { if (!isset($attributes[$attributeId])) { $attribute = $eavConfig->getAttribute(Mage_Catalog_Model_Product::ENTITY, $attributeId); + if (!$this->_filterFilterableAttributes($attribute)) { + continue; + } if ($attribute instanceof Mage_Catalog_Model_Resource_Eav_Attribute && $attribute->getIsFilterable()) { $attributes[$attributeId] = $attribute; } @@ -249,6 +252,17 @@ protected function _prepareAttributeCollection($collection) return $collection; } + /** + * Filter which attributes are included in getFilterableAttributes + * + * @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute + * @return bool + */ + protected function _filterFilterableAttributes($attribute) + { + return $attribute->getIsFilterable() > 0; + } + /** * Retrieve layer state object * diff --git a/app/code/core/Mage/CatalogSearch/Model/Layer.php b/app/code/core/Mage/CatalogSearch/Model/Layer.php index 4e1621b3eaa..136402d8f0b 100644 --- a/app/code/core/Mage/CatalogSearch/Model/Layer.php +++ b/app/code/core/Mage/CatalogSearch/Model/Layer.php @@ -99,6 +99,17 @@ protected function _prepareAttributeCollection($collection) return $collection; } + /** + * Filter which attributes are included in getFilterableAttributes + * + * @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute + * @return bool + */ + protected function _filterFilterableAttributes($attribute) + { + return $attribute->getIsVisible() && $attribute->getIsFilterableInSearch() > 0; + } + /** * Prepare attribute for use in layered navigation * From c55c1668590ac73276862f65da19efc66d185809 Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Tue, 2 Jul 2024 10:28:00 +0100 Subject: [PATCH 2/3] typing --- app/code/core/Mage/Catalog/Model/Layer.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/code/core/Mage/Catalog/Model/Layer.php b/app/code/core/Mage/Catalog/Model/Layer.php index 21a8ab33625..3d9ba78d9bb 100644 --- a/app/code/core/Mage/Catalog/Model/Layer.php +++ b/app/code/core/Mage/Catalog/Model/Layer.php @@ -255,10 +255,8 @@ protected function _prepareAttributeCollection($collection) /** * Filter which attributes are included in getFilterableAttributes * - * @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute - * @return bool */ - protected function _filterFilterableAttributes($attribute) + protected function _filterFilterableAttributes(Mage_Catalog_Model_Resource_Eav_Attribute $attribute): bool { return $attribute->getIsFilterable() > 0; } From e3f0c97c0f9556d06ce6d59b656e083678b3bae4 Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Tue, 2 Jul 2024 10:28:06 +0100 Subject: [PATCH 3/3] typing --- app/code/core/Mage/CatalogSearch/Model/Layer.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/code/core/Mage/CatalogSearch/Model/Layer.php b/app/code/core/Mage/CatalogSearch/Model/Layer.php index 136402d8f0b..4295ba7b663 100644 --- a/app/code/core/Mage/CatalogSearch/Model/Layer.php +++ b/app/code/core/Mage/CatalogSearch/Model/Layer.php @@ -102,10 +102,8 @@ protected function _prepareAttributeCollection($collection) /** * Filter which attributes are included in getFilterableAttributes * - * @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute - * @return bool */ - protected function _filterFilterableAttributes($attribute) + protected function _filterFilterableAttributes(Mage_Catalog_Model_Resource_Eav_Attribute $attribute): bool { return $attribute->getIsVisible() && $attribute->getIsFilterableInSearch() > 0; }