2013-10-02 65 views
0

我在嘗試獲取產品的屬性時遇到問題,但只返回NULL。getAllowAttributes this Returning NULL - Magento

我想以下幾點:

<? 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(); 
   } 

?> 

我不知道,如果是缺乏的東西我的產品,如果你真的不得不在配置產品的東西,請讓我知道你應該有什麼。

謝謝

回答

2

產品型號中沒有這種方法。因此getAllowAttributes將始終返回null,除非您有一個名爲allow_attribtues的屬性,或者在調用您的方法之前調用此屬性:$product->setAllowAttributes('something')
如果你正在尋找一種方式來獲得所允許的建設配置產品這個屬性是你所需要的:

$attributes = $product->getTypeInstance(true)->getConfigurableAttributes($product); 
+0

謝謝你,終於爲我工作 –

相關問題