Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Combined list view of several categories on one page
 
claudius.heitz
Jr. Member
 
Total Posts:  6
Joined:  2009-01-22
 

Hi,

I want to show a combined list view of several categories on one page.

As I suppose, Magento cannot do this automatically.

So I tried to write some code that does this.

I load all child categories as objects in the view template (app/design/frontend/default/default/template/catalog/category/view.phtml )

To generate the HTML output I set the current category to the child category and call
echo $this->getProductListHtml();

Unfortunately, it shows only the products of the current category, but several times.

Does anyone know a solution?

Thanks in advance!

Claudius

Here’s my code that I added in
app/design/frontend/default/default/template/catalog/category/view.phtml

<?php 
// get all child categories as IDs
$childrenCategories $_category->getAllChildren(TRUE); 
                        
// iterate over the child categories
foreach ($childrenCategories as $childCategoryID):

                
// get the child category as object
                
$childCategory Mage::getModel('catalog/category')->load($childCategoryID);
                
                
// set the child category as current category
                
$this->setData('current_category'$childCategory);

             
// generate the HTML output of the child category
             
echo $this->getProductListHtml();

endforeach; 
?>
 
Magento Community Magento Community
Magento Community
Magento Community
 
claudius.heitz
Jr. Member
 
Total Posts:  6
Joined:  2009-01-22
 

My question is solved.

I just discovered that Magento does automatically what I wanted. A category is showing also products of its subcategories, so the rendering is recursive.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Lonnytunes
Jr. Member
 
Total Posts:  9
Joined:  2009-03-02
France
 

Hi Claudius,

I am interested to know the solution. If you could specify.

Thanks.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top