Getting filterable attributes from layered navigation
$category = Mage::registry('current_category');
$products = $category->getProductCollection();
$appliedFilters = Mage::getSingleton('catalog/layer')->getFilterableAttributes();
foreach ($appliedFilters as $filter) {
if ($value = $this->getRequest()->getParam($filter->getAttributeCode())) {
$products->addFieldToFilter($filter->getAttributeCode(), $value);
}
}
Method getFilterableAttributes returns all available attributes for filtering. Then in foreach we check if an attribute has been selected by user, we add it to the filter.
No comments:
Post a Comment