在Mage_Catalog_Block_Layer_View中有一个名为$ _filters的变量,它循环显示$ _filter var中的属性。每当我尝试var转储这个变量,我的服务器就会抛出一个错误。这种行为是完全神秘的。有谁知道我是否可以回到属性代码?我想要做这样的事情:访问过滤var属性?
$_filter->getAttribute()->getAttributeCode();
在Mage_Catalog_Block_Layer_View中有一个名为$ _filters的变量,它循环显示$ _filter var中的属性。每当我尝试var转储这个变量,我的服务器就会抛出一个错误。这种行为是完全神秘的。有谁知道我是否可以回到属性代码?我想要做这样的事情:访问过滤var属性?
$_filter->getAttribute()->getAttributeCode();
你试过$_filter->getAttributeModel()->getAttributeCode()
?
public function getFilters()
{
$filters = array();
if ($categoryFilter = $this->_getCategoryFilter()) {
$filters[] = $categoryFilter;
}
$filterableAttributes = $this->_getFilterableAttributes();
foreach ($filterableAttributes as $attribute) {
$filters[] = $this->getChild($attribute->getAttributeCode().'_filter');
}
return $filters;
}
您可以看到该数组的变量设置在哪里发生,以及属性代码在此类中的使用方式。请注意,这是一个包含视图对象而不是对象本身的数组,并且抛出所有这些只会耗尽服务器内存。当然,你不能在这个数组上调用方法。
因此,没有实际的方法将此代码从此数组中取出,并且您可能在模板或子对象级别获得更多成功,或者如果您需要在同一个类中获得此过滤器,您可以从$ this获取过滤器 - > _ getFilterableAttributes ()方法,或者您可以尝试遍历每个滤镜阵列成员及其子成员
$filters['0']->getItems()
bingo!像魅力一样工作..谢谢! – Chris 2011-01-26 14:27:53