【发布时间】:2011-07-21 05:02:33
【问题描述】:
我只看到分组产品。在我的特定产品系列中,我过滤了简单的产品。结果显示在 list.phtml 中,但显示为简单的产品。我需要的是与简单产品相关的分组产品,而不是列表视图中显示的简单产品。我无法弄清楚 Magento 的目录是如何处理这个问题的。
php:
public function getMySpecialProducts($maxlength=null,$minlength=null,$maxwidth=null,$minwidth=null,$maxheight=null,$minheight=null){
$products = Mage::getModel('catalog/product');
$_collection = $products->getCollection();
$_collection->addAttributeToSelect('*')
->addAttributeToFilter('size_length', array('lteq' => ''.$maxlength.''))
->addAttributeToFilter('size_length', array('gteq' => ''.$minlength.''))
->addAttributeToFilter('size_width', array('lteq' => ''.$maxwidth.''))
->addAttributeToFilter('size_width', array('gteq' => ''.$minwidth.''))
->addAttributeToFilter('size_height', array('lteq' => ''.$maxheight.''))
->addAttributeToFilter('size_height', array('gteq' => ''.$minheight.''))
->setPage(1, 10)
->addCategoryFilter($this->getMySpecialCategory())
->load();
return $_collection;
}
phtml 输出:
$_productCollection = $this->getMySpecialProducts(
$range["length"]["max"],$range["length"]["min"],
$range["width"]["max"],$range["width"]["min"],
$range["height"]["max"],$range["height"]["min"]
);
$listView = $this->getLayout()->createBlock('catalog/product_list')
->setTemplate('catalog/product/list.phtml')
->setCollection($_productCollection);
$this->getLayout()->getBlock('content')->append($listView);
echo $listView->toHTML();
感谢任何帮助。谢谢。
【问题讨论】:
标签: php collections magento