How to get products from a particular category in magento ecommerce

后端 未结 6 1328
广开言路
广开言路 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:27

    $products = Mage::getModel('catalog/category')->load(category_id); //put your category id here
           $productslist = $products->getProductCollection()->addAttributeToSelect('*');
           foreach($productslist as $product)
           {
            echo 'price: ' . $product->getPrice() . '
    '; }

    This is the by far the convenient code in order to fetch product details of perticular category.Hope it helps you.

提交回复
热议问题