1
我正在尝试编写一个脚本来创建可配置的产品。我一直用这个作为指导:http://inchoo.net/magento/programmatically-create-a-configurable-magento-product/Magento getConfigurableAttributesAsArray导致致命错误
当我到了这一行:
$configurableAttributesData = $configProduct->getTypeInstance()->getConfigurableAttributesAsArray();
脚本崩溃,并踢了这个错误:
Fatal error: Call to a member function getId() on a non-object in /home/buyfrom/public_html/app/code/core/Mage/Catalog/Model/Product/Type/Configurable.php on line 283
继a comment on this page,我改变了线到以下:
$possibleAttributes = $product->getTypeInstance(true)->getConfigurableAttributesAsArray($product);
但我仍然得到是错误的。任何人都可以建议如何解决此问题?
这不提供一个问题的答案,应该是一个评论。请参阅[我应该何时评论?](https://stackoverflow.com/help/privileges/comment)。 一旦你有足够的[声望](https://stackoverflow.com/help/whats-reputation),你将可以在任何帖子上[评论](https://stackoverflow.com/help/privileges/comment);相反,[提供不需要提问者澄清的答案](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can- I-DO-代替)。 – Dwhitz