2016-03-07 115 views
0

我創建了自定義產品屬性(testattribute)。我需要通過使用下面的代碼獲得產品集合的值:Magento獲取自定義產品屬性值

$magentoProducts = Mage::getModel('catalog/product')->getCollection() 
        ->addFieldToFilter('type_id','simple') 
        ->addAttributeToSelect('name') 
        ->addAttributeToSelect('description') 
        ->addAttributeToSelect('short_description') 
        ->addAttributeToSelect('sku') 
        ->addAttributeToSelect('price') 
        ->addAttributeToSelect('special_price') 
        ->addAttributeToSelect('status') 
        ->addAttributeToSelect('weight') 
        ->addAttributeToSelect('tax_class_id') 
        ->addAttributeToSelect('updated_at'); 

我試過使用上面的代碼,但它不工作。我需要一個解決方案,無需再次加載產品。

任何人都可以請幫助我。

謝謝。

回答

0

檢查屬性並確保在前端'上可見的屬性設置爲yes。

您還需要您的藏品包括它:

->addAttributeToSelect('testattribute') 
相關問題