【发布时间】:2014-03-15 11:15:53
【问题描述】:
我如何编码???
当我按属性设计器新建图层过滤器时,我通过.../catalog/category/designer/name/123设置了自定义网址
我有 4 个产品展示列表,但是当我单击图层时选择尺寸 L (2) 我收到 4 个产品(我想要它的显示 2 个产品过滤器尺寸 L) 谁能帮我 ?? 这是我的代码
public function designerAction()
{
$designer = $this -> getRequest() -> getParam('name');
$data_designer=array();
$attributes = Mage::getModel('eav/entity_attribute_option')->getCollection()->setStoreFilter()->join('attribute','attribute.attribute_id=main_table.attribute_id', 'attribute_code');
foreach ($attributes as $attribute) {
if ($attribute->getOptionId()==$designer) {
$data_designer['name']=$attribute->getValue();
$data_designer['desc']=$attribute->getDescription();
$data_designer['image']=$attribute->getImage();
}
}
$collection = Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect('*')
->addFilter('type_id', 'configurable')
->addAttributeToFilter('designer', $designer) ;
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
$this->loadLayout();
$listBlock = $this->getLayout()->createBlock('catalog/product_list')
->setTemplate('catalog/product/designer.phtml')
->setCollection($collection);
$listBlock->setData('data', $data_designer);
$this->getLayout()->getBlock('content')->append($listBlock);
$this->renderLayout();
}
【问题讨论】:
-
问题不清楚...$collection 中返回了多少产品
标签: magento magento-1.8