Home » Magento2 December 2009

Magento: How to get attribute name and value?

Attribute in Magento is like a property. All Products, Categories, Orders, Customers, etc. have attributes. For example, the attribute of a product is its name, sku, description, image, etc.

This article will show you how to get attribute name and value for any product.

Get attribute’s name, value, type, and other parameters

The attribute code in the case below is my_attribute.

Get value from a select box attribute

The attribute code is supposed to be ‘my_attribute

Load any particular attribute by attribute code

Get all option value list for the particular attribute

You can see above that I got attribute information by attribute code. My attribute information is stored as $attributeInfo. See code above.

Here is the code to get all option values for my attribute $attributeInfo.

Get all options of any attribute

Getting all options of attribute with attribute-code “color“.

Get attribute’s option information by option id

I have my attribute as $attributeInfo.
I have my attribute’s option value array as $attributeOptions.
See code above.

Suppose, I want to get detail information of any option listed in strong>$attributeOptions array. Here is the code to do so:-

Get attribute of particular entity type

Here, I am going to get information about ‘order_id‘ attribute of ‘invoice‘ entity type.

Get attribute options of Configurable product

Hope this helps. Thanks.

php magento mukesh chapagain

Get New Post by Email

Find me on

FacebookTwitterGoogle+LinkedInRSS Feed
  • Israel Pereira

    respeiteiiiii, tava a tarde inteira procurando, valeu

  • Jalaluddeen

    Very Good

  • César MLBW

    hello

    i m trying to display product attribute option image for specific attribute on product page