访问过滤器 var 属性?
在 Mage_Catalog_Block_Layer_View 中有一个名为 $_filters 的变量,它循环并显示 $_filter 变量中的属性。每当我尝试 var dump 这个变量时,我的服务器就会抛出错误。这种行为完全是神秘的。有谁知道我是否可以返回属性代码?我想做这样的事情:
$_filter->getAttribute()->getAttributeCode();
In Mage_Catalog_Block_Layer_View there is a variable called $_filters, that loops through and displays properties in the $_filter var. Whenever I try to var dump this variable, my server throws an error. This behavior is completely mysterious. Does anyone know if I can get back to the attribute code? I'd like to do something like this:
$_filter->getAttribute()->getAttributeCode();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否尝试过
$_filter->getAttributeModel()->getAttributeCode()
?Have you tried
$_filter->getAttributeModel()->getAttributeCode()
?您可以看到该数组的变量设置发生在何处以及该类中如何使用属性代码。请注意,这是一个包含视图对象的数组,而不是对象本身,转储所有这些只会耗尽您的服务器内存。当然,您不能调用该数组上的方法。
因此,没有实际的方法可以从该数组中获取此代码,并且您可能在模板或子对象级别上取得更大的成功,或者如果您在同一个类中需要此代码,则可以从 $this->_getFilterableAttributes() 方法中获取过滤器或者您可以尝试迭代每个过滤器数组成员及其子成员
you can see where the variable setting to this array takes place and how the attribute code is used in this class. Note that this is an array containing view objects not a object itself and dumping out all this just eats up your server memory. And of course you can't call methods on this array.
So there is no actual way to get this code out of this array and you probably have more success in template or subobject level or if you need this in the same class you can get the filters out of $this->_getFilterableAttributes() method or you can try and iterate over each filters array member and their sub-members