【发布时间】:2011-04-28 23:55:50
【问题描述】:
我一直在像这样从 Magento 获取属性选项:
<?php
if ($attribute->usesSource()) {
$options = $attribute->getSource()->getAllOptions(false);
}
?>
在我尝试获取内置“颜色”属性的选项之前,它一直运行良好——我收到以下错误:
PHP Fatal error: Call to a member function setAttribute() on a non-object in app/code/core/Mage/Eav/Model/Entity/Attribute/Abstract.php on line 374
getSource() 调用似乎失败并导致此错误。有谁知道为什么会发生这种情况以及如何获得颜色选项?
谢谢!
【问题讨论】:
-
您是否能够使用 xdebug 和您的 IDE 对其进行实时调试?您可能可以深入了解 $attribute->getSource() 调用以查看其中的失败之处。我不知道为什么
color应该与其他属性有任何不同。
标签: php attributes magento multi-select