Javatpoint Logo
Javatpoint Logo

How to create Product Attributes in Magento 2?

In this section, we will discuss the product attribute in Magento 2 and how we can set up our products attributes. Attributes are an essential part of our product catalog because each product attribute helps the customers to choose certain products corresponding to their needs. The user will be able to search and compare the products with other products based on their attributes.

Magento 2 store already has some predefined attributes such as Name, Price, and Description. Apart from these, we can also create new custom attributes to enhance the product information, and help the customer with their choice. The additional attributes of any products are like color, size, etc.

The store owner can create the Attribute either during working on a product or from the Product Attribute page. The product attribute can also be created from the Store menu or from the Product Detail Page, where we work on a product. Below some set of instructions are given through which we will learn how to create product attributes in Magento 2.

How to add a product attribute?

Step 1: Login to the Magento 2 Admin Panel. On the left sidebar of the Magento 2 dashboard, click on Stores. Select Product inside the Attribute section, i.e., Stores >> Product.

How to create Product Attributes in Magento 2

Step 2: On the Product attribute dashboard, click on Add New Attribute.

How to create Product Attributes in Magento 2

Step 3: Fill the required information in the given fields.

How to create Product Attributes in Magento 2

There are three sections, in which we need to set up the Product Attribute information. These sections are Properties, Manage Labels, and Storefront Properties.

Properties: This section includes both basic and advanced properties of attributes.

Manage Labels: Label identifies an attribute in the admin as well as in the storefront of each store view. We can enter a different translated label for each language if our store is available in multiple languages.

Storefront Properties: The Storefront properties tab determines how an attribute can be used in our store, its behavior, and appearance. We can specify whether attributes are available for search, product comparisons, layered navigation, rules, price, and sorting. For text attribute, we can enable the WYSIWYG editor, and determine if the HTML tags can be used to format the values.

Now, we will discuss each section individually in detail.

Step 1: Complete the basic and advance properties information

In the Attribute Properties do the following:

  • In the Default Label field, enter a label that identifies the attribute during the data entry.
  • In the Catalog Input Type for Store Owner, choose the type in input control that is to be used for data entry, such as Text field, Text Area, Date, Yes/No, Multiple stores, Drop-down, etc.
  • In the Values Required field, select Yes if we want to require the customers to choose an option before they can buy products.

Note: If you use Multiple Select or Drop-down, you need to configure another section so, do the following

How to create Product Attributes in Magento 2

Click on Add Option button under the Manage Options section, and add the different options to the customer to choose.

How to create Product Attributes in Magento 2

Mark the Is Default checkbox, if you want to use it as a default value.

If we have only one store view, then enter only Admin value, which will be used for the storefront as well.

Advanced Attribute Properties

  • An Attribute Code is a unique identifier for internal use that must be less than 30 characters, excluding space. It must begin with a letter but also can include a combination of lowercase letters (a to z) and numbers (0 to 9).
  • The Scope field limits the use of an attribute to a specific store view or website.
  • Set Yes in the Unique Value field to prevent the duplicate values from being entered.
  • In the Add to Column Options field, set to Yes to add this attribute to the list of column options in the product grid.
  • In the use in Filter Options field, set Yes to add this attribute to the list of filter options in the product grid.
How to create Product Attributes in Magento 2

Step 2: Manage Labels

  • Tap on the Manage Label section to open it and do the following.
  • Insert the Title, which is shown for the Label field. In case if your store supports multiple languages, then insert the translation of the title for each view.
How to create Product Attributes in Magento 2

Step 3: Complete the Storefront Properties

  • Click on the Storefront Properties section to open it and fill the required information in the given fields.
How to create Product Attributes in Magento 2
Use in Search Set Yes if the attribute is to be available for search based on the value of this catalog.
Comparable on Storefront Select Yes if you want to add the attribute in Product compare.
Layered Navigation Set Yes to use the new attribute as a filter in layered navigation.
Use in Search Results Layered Navigation Set Yes to use the attribute in layered navigation on search results pages.
Position It determines the position of the attribute in the layered navigation in relation to other filterable attributes.
Use for Promo Rule Conditions Set Yes in this field to make the attribute available for use in price rules.
Allow HTML Tags on Frontend Choose Yes to allow the text to be formatted with HTML.
Visible on Catalog Pages on Frontend To include the attribute in catalog page listings, set this field to Yes.
Used in Product Listing Set Yes to this field to include the attribute in product listings.
Used for Sorting in Product Listing Set Yes to this field to use the attribute as a sort parameter for product listings.

After completing all the required information, click on Save Attribute to save the details.







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA