Get Magento Attribute Name and Value

0

All products in Magento have attributes assigned to them. The default attributes consist of but are not limited to the sku, price, description, url key and so forth. You can also create custom attributes yourself to add extra information to a product. If you want to get the attribute name and value of your Magento product you can use the code below.

The attribute code used in the code below is custom_attribute.

If you want to get the value of a select box attribute you can use the following code. Again, the attribute code used below is custom_attribute.

If you want to load any particular attribute by attribute code use this:

As you can see above, we’ve gotten all the information for our particular attribute. The information is stored in $attributeInfo. Get all the options listed for this particular attribute:

To get all the options for an attribute you can use the following code. The attribute code used here is size.

If you want to get the attribute options of a specific configurable product in Magento use this:

If you have any other code that could be useful to readers of this page, please submit them in the comment section below and I will include them in the article.

Share.

Leave A Reply