我只将产品分组可见。在我的特定产品集合中,我过滤了简单的产品。结果显示在list.phtml中,但作为简单的产品。我需要的是与简单产品相关的分组产品,而不是listview中显示的简单产品。我无法弄清楚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();
任何帮助appreceated.Thanks。
你好OğuzÇELİKDEMİR,谢谢你的建议。我认为我现在用getParentProductIds()方法正确。在我的情况下,不能过滤type_id,因为分组的产品没有任何属性来过滤,因此我不会得到任何结果。 – Rito 2011-03-23 13:38:10