get an array of all a products attributes in magento

前端 未结 3 1655
青春惊慌失措
青春惊慌失措 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:33

    It's rather easy and gives you an array of available product attribute names

    $product = Mage::getModel('catalog/product')->load('product_id');
    $attributeNames = array_keys($product->getData());
    print_r($attributeNames);
    

    If you need a attribute object collection you can call

    $product->getAttributes();
    

    If you need a product collection and after that you can perform the previously mentioned ways on each collection member

    Mage::getModel('catalog/product')->getCollection();
    

提交回复
热议问题