>Magento 2 Attributes 101 – Know Clearly to Use Properly

Magento 2 Attributes 101 – Know Clearly to Use Properly

Attributes are the materials to build the product characteristics so that customers can buy find and buy your products. On the other hand, attributes are used to manage products in the backend. Mostly, Magento 2 product attributes are to:

  • Define product information
  • Use for filtering and searching
  • Use to compare products in reports
  • Use for promotion settings up

Two Types of Magento Product Attributes

Please navigate to Admin Panel ⇒ Stores ⇒ Attributes ⇒ Product

All attributes are saved in one grid for easy management where you can search and edit any attributes at hand.

If you visit for the first time, you can see many built-in attributes. They are system attributes, which are unchangeable.

Besides, you can create new attributes, called Magento 2 custom attributes, according to your management purposes.

Product attributes grid

Create Custom Attributes

There are 2 ways to add new attributes:

  • When working on a specific product edit page (*)
  • From the Product Attributes page

(*) Let’s discuss the next post about Product workspace. Here we talk about how to add new attributes from the Product Attributes page.

Step 1: Click on “Add New Attributes”

Step 2: Properties tab

Under Attribute properties, describe basic information of the attributes

Product attributes properties

The Catalog Input Type will define the type of data can be entered in the fields. There are 12 Catalog Input Types to define the attributes.

  • Text Field: A single-line field to enter text
  • Text Area: A multiple-line field to enter text directly or using  WYSIWYG Editor
  • Text Editor: Add WYSIWYG Editor to any custom field
  • Date: Date & Time can be picked from the calendar or typed directly into a field
  • Yes/No: A “switch” button between two pre-defined options: Yes or No
  • Dropdown: A drop-down list to choose one option at a time
  • Multiple Select:  Used to create price fields. The currency used is determined in the system configuration
  • Media Image: A media image attribute becomes an additional image type, along with Base, Small, and Thumbnail
  • Fixed Product Tax: Used to define FPT rates based on the locale requirements
  • Visual Swatch: For configurable products, the corresponding image is shown per swatch on visual option (e.g color)
  • Text Swatch: For configurable products, the corresponding image is shown per swatch on text option (e.g size)

Expand Advanced Attribute Properties. You can skip this part since all fields are optional.


  • Attribute code: the unique identifier to manage the attribute: search, import/export, get attribute ID/name/value, etc.
  • Scope: Decide how the attribute value is displayed and edited based on a specific level: Global ⇒ Website ⇒ Store View

+ Global: The value of the attribute is shared by all websites and store views

+ Website: The value varies per website but stays the same for multiple store views under that website.

+ Store View: Tailor different values per store view, primarily based on the languages.

  • Set Unique Value to Yes to prevent duplication. Recommended for ID-number fields like SKU.
  • Attributes used for the configurable products must have Catalog Input Type to be drop-down and the Global scope.

Step 3: Manage Labels of Attributes (Optional)

The label is to identify the attribute in Admin and in the storefront of each store view. It makes sense if the scope of the attribute is “Store View”

Manage Lable of attribute per storeview

Step 4: Set up Storefront Properties (Optional)

You can decide how the attribute can be used in the storefront and in the admin: for search & sorting; in layered navigation; for price rules, or in product comparisons.

Storefront Properties

Magento 2 Attribute Set

When creating a new product, you can use available attributes or create new ones.

However, products under one category often share similar attributes. That time, you had better organize shared attributes into sets and use them as the templates for products. Such templates are attribute sets. To create new attribute set, please follow Stores ⇒ Attributes ⇒ Attribute Sets ⇒ Add Attribute Set

Magento 2 Attribute Sets


  • You should plan a correlative set in advance. Once you assign that set to a product, you can not change
  • Based on: Choose an existing attribute set which has a similar list of attributes
  • You can add or remove the attribute from the set by a drag-and-drop action.

FAQs about Magento 2 Attributes

How to get attribute of product?

There are many cases that you want to get values of Magento 2 custom attributes, but the default reports are not informative enough.

If you are tech-savvy, you can simply use getCustomAttribute()

if (null !== $product->getCustomAttribute('your_custom_attribute')) { echo $product->getCustomAttribute('your_custom_attribute')->getValue(); }

How to import Magento 2 attributes?

For those who are not familiar with PHP code, you can use BSS Commerce built-in Magento 2 Import/Export Product Attributes extension. It allows exporting all or specific attribute sets via CSV file in several clicks.

Export product attributes in Magento 2

How to change the attribute scope?

For some reasons, you want to change the scope of attributes, for example from Global to Websites. Unfortunately, those attributes are not available in Attributes grid. In that case, make changes in the database.

Create an upgrade script with this code:

$setup->updateAttribute(‘catalog_category’, ‘menutopdescription1’, ‘is_global’, Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE);

Thanks Marius in Stackexchange for this solution. We have tested and it work well.

How to add a custom attribute to the customer registration form?

Please make clear of Magento 2 attributes. In fact, they are product attributes – They are used to define product characteristics. If you want to add a custom attribute to the customer registration form, you can’t do it with Magento Community default features.

Instead, take a look at Magento 2 Customer Attribute extension which helps you to do so.

Wrapping Up

We have covered all about Magento 2 attributes in brief for your easy reference. If you have any question, please let us know. Next time, let’s explore about 6 product types!