I have a question about Mage::registry
and categories:
I'm a on a category page, I retrieve current category by Mage::registry('current_category')
. I've noticed that it works only for root categories, in fact if I visit a subcategory page I retrieve always the root category with Mage::registry('current_category')
. So the question is: is something about backend configuration, cache or something else?
Asked
Active
Viewed 2.3k times
0
-
read your post and ask: and what is your question here ? – Anton S Apr 23 '12 at 14:57
3 Answers
7
If you are in a template (e.g. catalog/category/view.phtml
) you can get the current category with
$this->getCurrentCategory();
If you are in a model, controller or else, try this (found here):
Mage::getModel('catalog/layer')->getCurrentCategory();
However, Mage::registry('current_category')
is the normal way to go.
1
For all categories:-
<?php $_helper = Mage::helper('catalog/category') ?>
<?php $_categories = $_helper->getStoreCategories() ?>
For Current Category
<?php $currentCategory = Mage::registry('current_category') ?>
Works for me.

Noor
- 144
- 2
- 5