0

如果类别不活跃,我该如何$cat->getProductCollection();退货

已经很久了。我无法让它发挥作用。

这就是我正在做的事情。但没有运气

        private function _getCollection() {

    $category = Mage::getModel('catalog/category')->getCollection()
    ->addAttributeToFilter('is_active',array('eq'=>False))
    ->addAttributeToFilter('entity_id',array('eq'=>'61'))
    ->load();

        foreach($category as $cat){            

        $Prods = $cat->getProductCollection();                     
        $Prods->addWebsiteFilter();            
        $Prods->addAttributeToSelect('*');

        }


           return $Prods;
}
4

1 回答 1

0

试试这个代码

$cat = Mage::getModel('catalog/category')->getCollection()->addAttributeToFilter('is_active', 1);

foreach ($cat as $category){
$cat_id = $category->getId();
$category = new Mage_Catalog_Model_Category();
$category->load($cat_id);
$collection = $category->getProductCollection();
$collection->addAttributeToSelect('*');

foreach ($collection as $_product) {
echo $_product->getName();
}

}

于 2013-05-21T15:25:04.530 回答