Magento 如果类别未激活,则返回产品
如何制作Magento 如果类别未激活,则返回产品,magento,Magento,如何制作$cat->getProductCollection()在类别未激活时返回产品 已经很久了。我没法让它工作 这就是我正在做的。但是没有运气 private function _getCollection() { $category = Mage::getModel('catalog/category')->getCollection() ->addAttributeToFilter('is_active',array('eq'=>Fal
$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;
}
试试这个代码
$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();
}
}