get an array of all a products attributes in magento

前端 未结 3 1647
青春惊慌失措
青春惊慌失措 2021-02-05 15:32

I cannot figure this out!

I am trying to get a list of a products attributes into an array on the list.phtml page. I have tried everything. I have seen a lot of solution

3条回答
  •  隐瞒了意图╮
    2021-02-05 16:35

    According to your question, you should be using Mage::getResourceModel('catalog/product_attribute_collection') instead:

    $productAttrs = Mage::getResourceModel('catalog/product_attribute_collection');
    
    foreach ($productAttrs as $productAttr) { /** @var Mage_Catalog_Model_Resource_Eav_Attribute $productAttr */
        var_dump($productAttr->getAttributeCode());
    }
    

    You don't always have attributes in the _data (getData()) storage and you don't always need to load a product to get its attributes.

提交回复
热议问题