Magento Forum

Get products of topmost category
 
pmeems
Jr. Member
 
Total Posts:  19
Joined:  2011-03-27
 

I use an extension to show the newest products of a category:

$cat_id Mage::getModel('catalog/layer')->getCurrentCategory()->getId(); // set current category id
      
$category Mage::getModel('catalog/category')->load($cat_id);
      
$_productCollection $category->getProductCollection()->addCategoryFilter($category)->addAttributeToSelect('*')->setPageSize($qty);
This works great. On every page I only get the new products of that category.

I have a lot of sub categories. On my topmost category page I also get the new products of my sub categories.
That is even better. I now want to alter my extension to show all new products of all sub categories on the pages of each sub categories.

I’m new to Magento development but I think I just need to get a different $cat_id. But how to get the topmost category ID?

Thanks,

Paul

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