MAGENTO - Display sub-category products in root category

送分小仙女□ 提交于 2019-12-02 20:22:33

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!