Note that there are some explanatory texts on larger screens.

plurals
  1. POI want to display categories and its products in list.phtml in magento
    primarykey
    data
    text
    <p>I m new in magento and i need to display categories as heading and the list all products under this category. Somehow I got some relevant code while googling but it is not working. Could display categories as heading but cannot display its corresponding products. I will provide the code which i used to display the categories and products. </p> <pre><code>&lt;?php $category = Mage::getModel('catalog/category'); $tree = $category-&gt;getTreeModel(); $tree-&gt;load(); $ids = $tree-&gt;getCollection()-&gt;getAllIds(); $arr = array(); if ($ids){ foreach ($ids as $id){ $cat = Mage::getModel('catalog/category'); $cat-&gt;load($id); if ($cat-&gt;getIsActive()) { $arr[$id] = $cat-&gt;getName(); $arr[$catId] = $cat-&gt;getId(); ?&gt; &lt;div class="right"&gt; &lt;div class="products"&gt; &lt;h2 class="head"&gt;&lt;?php echo $arr[$id]; ?&gt;&lt;/h2&gt; &lt;?php $catagory_model = Mage::getModel('catalog/category')-&gt;load($id); //where $category_id is the id of the category $collection = Mage::getResourceModel('catalog/product_collection'); $collection-&gt;addCategoryFilter($catagory_model); //category filter $collection-&gt;addAttributeToFilter('status',1); //only enabled product $collection-&gt;addAttributeToSelect(array('name','url','small_image')); //add product attribute to be fetched //$collection-&gt;getSelect()-&gt;order('rand()'); //uncomment to get products in random order $collection-&gt;addStoreFilter(); if(!empty($collection)) { foreach ($collection as $_product): ?&gt; &lt;div class="pro-list"&gt; &lt;h5&gt;&lt;?php echo $_product-&gt;getname(); ?&gt;&lt;/h5&gt; &lt;!-- other product details --&gt; &lt;/div&gt; &lt;?php endforeach; }else { echo 'No products exists'; } ?&gt; &lt;/div&gt; &lt;/div&gt; &lt;?php } } } ?&gt; </code></pre> <p>what I am doing wrong? The code is written in template/catalog/product/list.phtml Can someone pls help and explain how to do it. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload