本文介绍了Mage::registry('current_category') 会返回 NULL 的任何原因?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个模板,它在块中调用一个函数,在该块中,我试图用 Mage::registry('current_category') 拉出当前类别.但是它总是返回NULL.我已经尝试从产品页面、搜索页面执行此操作 - 仍然没有.是否有任何原因会返回 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 - still nothing. Is there any reason why it would return NULL, what are some things I could check?

推荐答案

它是空的,因为它没有设置.注册表充当全局变量的系统,不依赖于 PHP 的内置全局支持.不能保证已注册的任何特定变量在每个页面上都可用.例如,您说您在搜索页面上尝试过此操作.current_category 在搜索页面上应该是什么?

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.

这篇关于Mage::registry('current_category') 会返回 NULL 的任何原因?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 17:22