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

后端 未结 2 1379
日久生厌
日久生厌 2020-12-10 07:48

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\'). H

相关标签:
2条回答
  • 2020-12-10 07:55

    Try this:

    $category = $this->helper('catalog/category')->getCategoryUrl(Mage::registry('current_category'));
    
    0 讨论(0)
  • 2020-12-10 07:59

    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.

    0 讨论(0)
提交回复
热议问题