0

I'm having a problem when I try to get the attributes of the product but only returns me NULL.

I'm trying the following:

<? php
require 'app/Mage.php';
$app = Mage::app('default');

  try {
     $id = '4';
     $product = Mage::getModel('catalog/product')->load($id);
     $_attributes = $product->getAllowAttributes();

     var_dump($_attributes);

   } Catch(Exception $e){
     echo $e->getMessage();
   }

?>

I do not know if my product is lacking in something, if you really have to have something in the configurable product, please let me know what you should have.

Thank you

4

1 回答 1

2

产品模型中没有这种方法。所以getAllowAttributes总是返回 null 除非你有一个属性被调用allow_attribtues或者你在调用你的方法之前调用它:$product->setAllowAttributes('something')
如果您正在寻找一种方法来获取构建可配置产品所允许的属性,这就是您所需要的:

$attributes = $product->getTypeInstance(true)->getConfigurableAttributes($product);
于 2013-10-02T20:06:39.173 回答