开发者

Any reason why Mage::registry('current_category') would return NULL?

I am using a template which calls a function in block, and inside that block I am trying to pull a current category with Mage::registry('current_category'). However it always returns NULL. I've tried doing this from product page, search page - s开发者_如何学Ctill nothing. Is there any reason why it would return NULL, what are some things I could check?


It's null because it's not set. The registry acts as a system for global variables that don't rely on PHP's built in global support. It is not guaranteed that any particular variable that's been registered will be available on every page. For example, you said you tried this on the search page. What should the current_category be on the search page?

It's null because it's supposed to be.


Try this:

$category = $this->helper('catalog/category')->getCategoryUrl(Mage::registry('current_category'));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜