1

I have searched many time for this problem, but I have not found a solution for this feature. I will show all available categories from specific store view as a list on a single page. The feature now, I need a filter for this list like this page e.g. Order by ASC and Order by categories.

Have anyone a answer or a solution for me? Thanks.

0

As Arunendra said with the active filter you can go through them

This would get you all categories with a link to the category

<?php $_helper = Mage::helper('catalog/category') ?>
<?php $_categories = $_helper->getStoreCategories() ?>
<?php $currentCategory = Mage::registry('current_category') ?>
<?php if (count($_categories) > 0): ?>
    <ul>
        <?php foreach($_categories as $_category): ?>
            <li>
                <a href="<?php echo $_helper->getCategoryUrl($_category) ?>">
                    <?php echo $_category->getName() ?>
                </a>
                <?php $_category = Mage::getModel('catalog/category')->load($_category->getId()) ?>
                <?php $_subcategories = $_category->getChildrenCategories() ?>
                <?php if (count($_subcategories) > 0): ?>
                    <ul>
                        <?php foreach($_subcategories as $_subcategory): ?>
                            <li>
                                <a href="<?php echo $_helper->getCategoryUrl($_subcategory) ?>">
                                    <?php echo $_subcategory->getName() ?>
                                </a>
                            </li>
                        <?php endforeach; ?>
                    </ul>
                <?php endif; ?>
            </li>
        <?php endforeach; ?>
    </ul>
<?php endif; ?>
  • Thanks for your reply. I have added this to a page but i became this error: Fatal error: Uncaught Error: Call to a member function load() on unknown in...on line 75 – user3778868 Apr 13 '16 at 12:01
  • Updated it please try again – Klettseb Apr 13 '16 at 12:33
  • Mmh, now i became magento error page and this message: Invalid method Varien_Data_Tree_Node::load(Array ( [0] => 157 ) ) – user3778868 Apr 13 '16 at 12:46
  • ok new try :).. – Klettseb Apr 13 '16 at 13:09
  • Great at least finally it works – Klettseb Apr 13 '16 at 13:14
0

Categories in magento doesn't have to Store relations ( because its used by stores ( store can point to subcategory as its root category for instance ) etc.. ) So any category you create it will be visible in all stores.

But is has attribute is_active ( which is store view scope ).

So to get the categories in specific store ( you need to make sure its not active in other stores )

and Filter with the attribute

->addFieldToFilter('is_active', 1)

Hope this help you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.