1

I’m working in showing some more information in my category view, in the left bar, so I manage to find the file that grabs all the sub categories of the main category and display them in the left bar, the file is the left.phtml. So the problem that I have it’s that I want to display a subcategory, brands, but this one needs to have its own block, like in this picture.

left block

Right now I’m just duplicating the first block of the sub categories, but I need to show a category there with all its sub categories, in the second block of the left. Here’s the code I have

<?php if (!Mage::registry('current_category')) return ?>
<?php $_categories = $this->getCurrentChildCategories(); ?>
<?php print_r($_categories); ?>
<?php $_count = is_array($_categories)?count($_categories):$_categories->count(); ?>
<?php if($_count): ?>
<div class="block block-layered-nav">
    <div class="block-title">
        <strong><span><?php echo $this->__('Browse By') ?></span></strong>
    </div>
    <div class="block-content">
        <dl id="narrow-by-list2">
            <dt><?php echo $this->__('Category') ?></dt>
            <dd>
                <ol>
                <?php foreach ($_categories as $_category): ?>
                    <?php if($_category->getIsActive() && $_category->getProductCount()>0): ?>
                    <li>
                        <a href="<?php echo $this->getCategoryUrl($_category) ?>"<?php if ($this->isCategoryActive($_category)): ?> class="current"<?php endif; ?>><?php echo $this->htmlEscape($_category->getName()) ?></a> (<?php echo $_category->getProductCount() ?>)
                    </li>
                    <?php endif; ?>
                <?php endforeach ?>
                </ol>
            </dd>
            <dt>Marcas</dt>
                <dd>
                    <ol>
                    //here it will display the brands of the category
                    </ol>
                </dd>
        </dl>
        <script type="text/javascript">decorateDataList('narrow-by-list2')</script>
    </div>
</div>
<?php endif; ?>

So what I’m trying to obtain it’s the category the user it’s looking when the page displays, so I printed all the array $_categories, and have identify the [parent_id] => 139, it’s the one that have the information of the category that the user it’s watching, so I need a way to save this in a variable so I can validate this and display the category I need in the second part of the left Block.

Hope you guys can help me.

Thanks!

6
  • Sorry, but it's hard to understand from your question what are you trying to achieve.
    – user487772
    Dec 11 '13 at 18:23
  • Hope the corrections made my question more clear.
    – dzuritaa
    Dec 11 '13 at 20:34
  • Depending on the desired functionality the solution could be to create "Brands" attribute and include it into layered navigation?
    – user487772
    Dec 12 '13 at 9:12
  • Well the idea it's that the "Brands" have their own block below the Categories, so I want to use the code having the parent category id and use a foreach so I can put the Brands like the other block
    – dzuritaa
    Dec 12 '13 at 20:25
  • Do you want to list all brands or only brands of the current products collection?
    – user487772
    Dec 12 '13 at 21:53
1

I'm not 100% sure what you're trying to achieve, but it sounds like your main objective is to find the ID of the category the user is viewing. Assuming I'm correct you can probably do something like:

Mage::registry('current_category')->getId();
0

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.