Я создал модуль для этого.Вот изменения, которые я сделал:
MyName / Navigation / Catalog / Model / Layer.php:
class MyName_Navigation_Catalog_Model_Layer extends Mage_Catalog_Model_Layer {
public function getFilterableAttributes()
{
$setIds = $this->_getSetIds();
if (!$setIds) {
return array();
}
$collection = Mage::getResourceModel('catalog/product_attribute_collection')
->setItemObjectClass('catalog/resource_eav_attribute');
$collection->addSetInfo(true);
$collection->getSelect()->distinct(true);
$collection
->setAttributeSetFilter($setIds)
->addStoreLabel(Mage::app()->getStore()->getId())
->setOrder('position', 'ASC');
$collection = $this->_prepareAttributeCollection($collection);
$collection->load();
return $collection;
}
}
Я просто переписываю переопределенную функцию из Mage_Catalog_Model_Layer с этим добавлением строки:
$collection->addSetInfo(true);
Это гарантирует, что данные группы будут загружены, когда мне это нужно.
Следующие два изменения просто позволят вам получить доступ к данным.
MyName /Навигация / Каталог / Модель / Слой / Attribute.php:
class MyName_Navigation_Catalog_Model_Layer_Filter_Attribute extends Mage_Catalog_Model_Layer_Filter_Attribute {
public function getGroupName($setId = 4) {
$attribute = $this->getAttributeModel();
$group_id = $attribute->getData('attribute_set_info/' . $setId . '/group_id');
$group = Mage::getModel('eav/entity_attribute_group')->load($group_id);
$group_name = $group->getData('attribute_group_name');
return $group_name;
}
}
MyName / Навигация / Каталог / Модель / Слой / Item.php:
class MyName_Navigation_Catalog_Model_Layer_Filter_Item extends Mage_Catalog_Model_Layer_Filter_Item {
public function getGroupName()
{
return $this->getFilter()->getGroupName();
}
}
MyName / Навигация / Каталог /Block / Layer / Filter / Attribute.php:
class MyName_Navigation_Catalog_Block_Layer_Filter_Attribute extends Mage_Catalog_Block_Layer_Filter_Attribute {
public function getGroupName() {
return $this->_filter->getGroupName();
}
}
Скажите magento использовать мой модуль, а не файлы ядра.MyName / Navigation / etc / config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<MyName_Navigation>
<version>0.1.0</version>
</MyName_Navigation>
</modules>
<global>
<blocks>
<catalog>
<rewrite>
<layer_filter_attribute>MyName_Navigation_Catalog_Block_Layer_Filter_Attribute</layer_filter_attribute>
</rewrite>
</catalog>
</blocks>
<models>
<catalog>
<rewrite>
<layer>MyName_Navigation_Catalog_Model_Layer</layer>
<layer_filter_attribute>MyName_Navigation_Catalog_Model_Layer_Filter_Attribute</layer_filter_attribute>
<layer_filter_item>MyName_Navigation_Catalog_Model_Layer_Filter_Item</layer_filter_item>
</rewrite>
</catalog>
</models>
</global>
</config>
Теперь вы можете позвонить
$_item->getGroupName();
из вашего файла шаблона: template / catalog / layer / filter.php или
$ _ фильтр-> getGroupName ();из вашего файла шаблона: template / catalog / layer / view.php и Group / Sort оттуда атрибуты.