Jump to content

Get all categories


Przemysław Suszek

Recommended Posts

Hi,

 

In controller I have:

$root_cat = Category::getRootCategory($this->context->cookie->id_lang);
        $sub_children = $root_cat->getSubCategories($this->context->cookie->id_lang);
        $this->context->smarty->assign(
            array(
                'categories' => $sub_children,
            )
        );

And this is my TPL file:

{foreach from=$categories item=mainCategory}
                    <div class="categoryBox"> <h2>{$mainCategory.name}</h2></div>
                    {foreach from=$mainCategory.children item=subCategory}
                        <div class="categoryBox"> <h3>{$subCategory.name}</h3></div>
                    {/foreach}
                {/foreach}

The problem is that the second foreach is empty. I don't know why. Thanks for help.

 

Kind regards

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...