i havent been able to find the answer for this anywhere but i cant seen to display any of the products on the root categories page from its sub category members. When i click the category from the top navigation i get the sub categories on the left and on the right (main content) “There are no products matching the selection”. Each sub-cat. shows its products though.
In Admin -> Catalog -> Manage Categories each category shows the number of products i.e (4) however its root category displays (0).
Any ideas?
thanks in advance
Solution
Go to Admin -> Catalog -> Manage Categories -> "Select Category" -> Display Settings -> Is Anchor = "Yes"
Then:
Admin -> System -> Index Management -> "Select All" -> "Reindex data" -> "Submit"
Thanks for everyones comments
Make sure you set "Is anchor" to "Yes" for your root category.
Set anchor as YES and then reindex categories in index management.
Every category has associated products.
Just associate these products into the higher-level category too.
They will show up on frontend in that category.
<div class="category-grid-new">
<?php $_columnCount; ?>
<ul>
<?php if($i++%$_columnCount==0): ?>
<?php foreach ($this->getCurrentCategory()->getChildrenCategories() as $_subcat): ?>
<li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0):?> last<?php endif; ?>">
<a href="<?php echo $_subcat->getUrl() ?>">
<div class="category-img"><img src="<?php echo $_category->getImageUrl() ?>" alt="" width="100px" height="100px"/></div>
<div class="category-data"><?php echo Mage::helper('catalog/output')->categoryAttribute($_subcat, $_subcat->getName()) ?></div>
</a>
</li>
<?php endforeach ?>
</ul>
<?php endif; ?>
</div>
First identify the attribute id of the is_anchor attribute:
SELECT * FROM eav_attribute where attribute_code = 'is_anchor';
we Get attribute id 51 in my database. Now run the following query
UPDATE catalog_category_entity_int set value = 1 where attribute_id = 51;
replace 51 with your own attribute id. And just rebuild these indexes
来源:https://stackoverflow.com/questions/8624728/magento-display-sub-category-products-in-root-category