在Magento

问题描述 投票:0回答:1

在分层导航中,当我选择特定属性时,它会从左侧选择面板中消失,因此我希望我能够选择不止一次。 如果我从即将到来的收藏中得知,那将是有帮助的。

提前感谢

public function apply(Zend_Controller_Request_Abstract $request, $filterBlock) { $filter = $request->getParam($this->_requestVar); if (is_array($filter)) { $text = array(); foreach ($filter as $f) array_push ($text, $this->_getOptionText($f)); if ($filter && $text) { $this->_getResource()->applyFilterToCollection($this, $filter); $this->getLayer()->getState()->addFilter($this->_createItem($text, $filter)); $this->_items = array(); } return $this; } $text = $this->_getOptionText($filter); if ($filter && $text) { $this->_getResource()->applyFilterToCollection($this, $filter); $this->getLayer()->getState()->addFilter($this->_createItem($text, $filter)); $this->_items = array(); } return $this; } public function applyFilterToCollection($filter, $value) { $collection = $filter->getLayer()->getProductCollection(); $attribute = $filter->getAttributeModel(); $connection = $this->_getReadAdapter(); $tableAlias = $attribute->getAttributeCode() . '_idx'; if (!is_array($value)) { $conditions = array( "{$tableAlias}.entity_id = e.entity_id", $connection->quoteInto("{$tableAlias}.attribute_id = ?", $attribute->getAttributeId()), $connection->quoteInto("{$tableAlias}.store_id = ?", $collection->getStoreId()), $connection->quoteInto("{$tableAlias}.value = ?", $value) ); }else{ $conditions = array( "{$tableAlias}.entity_id = e.entity_id", $connection->quoteInto("{$tableAlias}.attribute_id = ?", $attribute->getAttributeId()), $connection->quoteInto("{$tableAlias}.store_id = ?", $collection->getStoreId()), $connection->quoteInto("{$tableAlias}.value in (?)",$value) ); } $collection->getSelect()->join( array($tableAlias => $this->getMainTable()), implode(' AND ', $conditions), array() ); //echo $collection->getSelect(); return $this; }

	
我做了类似的事情,您必须重写mage_catalog_model_layer_filter_attribute class,它使用方法apply()来过滤结果。
php magento multi-select layered-navigation
1个回答
0
投票

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.