How to get products from a particular category in magento ecommerce

后端 未结 6 1325
广开言路
广开言路 2020-12-05 11:50

I\'d like to get a list of random products from the same category as the current product for displaying within the product view - so far all I\'ve dug up is

Magento

6条回答
  •  长情又很酷
    2020-12-05 12:47

    You basically load up the category, get the Product Collection and then filter appropriately.

    $products = Mage::getModel('catalog/category')->load($category_id)
     ->getProductCollection()
     ->addAttributeToSelect('*')
     ->addAttributeToFilter('status', 1)
     ->addAttributeToFilter('visibility', 4)
     ->addAttributeToFilter('special_price', array('neq' => ""))
     ->setOrder('price', 'ASC')
     ;
    

提交回复
热议问题