How to Create Product Attribute in Magento 2

How to Create Product Attribute in Magento 2

A product attribute defines a characteristic of the product, it is a property of the product.

For online stores, the product attributes becomes utmost important to display the product online in as many ways as possible. The product attributes help merchants offer the products in the most detailed way possible. Also, it makes easy for the visitors to browse through the products, filter them and find the exact item as per their need.

By default, Magento 2 provides product attributes but you can also create one!

Magento 2 product attributes can be created while creating a product, or from the product attribute page.

Here, I’ll give the step-wise method to create product attribute in Magento 2 from Stores menu.

The steps are in accordance with the latest Magento 2.3.1

Steps to Create Product Attribute in Magento 2:

  1. Enter the basic properties
  2. Enter the advanced properties
  3. Enter the Field Label
  4. Enter the Store Front properties
  5. Save

Implement each step as shown below:

  1. Enter the basic properties

    1. Log in to Admin Panel
    2. Navigate to Stores > Attributes > Product
    3. Click “Add New Attribute1_Product Attributes Grid
    4. Under Attributes Properties,
      1. Enter a Default Label to identify the attribute.
      2. In the “Catalog Input Type for Store Owner” field, set type in input control to be used for data entry.
        1. If you had selected drop-down or multiple select input types:
          1. Under “Manage Options“, click “Add Options
          2. Enter the first value that you want to appear on the list. You can enter one value for the Admin, and a translation of the value for each store view. If you have only one store view, you can enter only the Admin value and it will be used for the storefront as well.
          3. Repeat the previous step for each option to be included in the list.
          4. For the option to be used as the default value, select “Is Default
    5. Set “Yes” to “Values Required” if you want to require the customer to choose an option before the product can be purchased.2_attribute properties
  2. Enter the advanced properties

    1. Set a unique attribute code. It should be lowercase characters without any spaces.
    2. Select the scope from Store View, Website, or Global to indicate where in the store the attribute s allowed to be used.
    3. Enable the field “Unique Value” to avoid duplicate values.
    4. With “Input Validation for Store Owner” field, you can validate the data entered in the text field.
    5. Set the “Add to Column Option” to “YES” to add this attribute to the list of column options
    6. Set the “Use in Filter Option” to “YES” to add the attribute to the list of filter options.3_Advanced Attribute Properties
  3. Enter the Field Label

    1. Go to “Manage Labels” under Attribute Information
    2. Expand “Manage Titles
    3. Enter a Title to be used as a label for the field. In the case of multi-language support, enter the title for each view.4_Manage Titles
  4. Enter the Store Front properties

    1. Go to “Store Front Properties” under Attribute Information
    2. Enable the “Use in Search” field for the attribute to be available for search.
    3. Enable “Comparable on Storefront” field to include it in product comparison.
    4. For catalog input field to be drop down, multiple select or price:
      1. Set “Use in Layered Navigation” to “YES” to use the attribute as a filter in layered navigation.
      2. Set “Use in Search Results Layered Navigation” to “Yes” to use the attribute in layered navigation on search results pages.
      3. Set the relative position of the attribute in the layered navigation block in “Position“.
    5. Enable Use for Promo Rule Conditions” field to use the attribute in price rules.
    6. Enable “Allow HTML Tags on Storefront” field to allow the text to be formatted with HTML and use WYSIWYG editor
    7. Enable the “Visible on Catalog Pages on Storefront” field to make the attribute visible in catalog page listing.
    8. If Product Listing is supported with your theme, the attribute can be appeared and used as sort parameter by enabling “Used in Product Listing‘ and “Used for Sorting in Product Listing5_Storefront properties
  5. Save

    1. Click the “Save Attribute” button to save the configuration.

That was it!

You can also refer to Create Product Attribute in Magento 2 from our Magento 2 video tutorial series:
How to Create Product Attribute in Magento 2 1

You can see the custom_attribute created and listed in the Product Attribute grid:

6_New attribute created - Products Attribute Grid

The process is easy but you can always ask doubts, if any, in the Comments section below.

If you want to implement the programmatic solution to create product attribute, check here

Thank you.

Get Weekly Updates

Never miss Magento tips, tricks, tutorials, and news.

Thank you for subscribing.

Something went wrong.

5
(based on 21 Reviews)

Sanjay is a co-founder at Meetanshi. He is a Certified Magento Developer who loves creating Magento E-commerce solutions. Owing to his contributions in Magento Forums and posting solutions, he is among the top 50 contributors of the Magento community in 2019. When he is not engrossed with anything related to Magento, he loves to play cricket.

2 comments On How to Create Product Attribute in Magento 2

  • Hi,
    I have created a ‘New Attribute’ into the Product Attributes, it greats your explication but I have a litle problem.
    I find it into the 3 mysql’sw table : eav_attribute and eav_attribute_option catalog_product_entity_int. It’s works.

    When a client buy some article, I can find his order into the this table of mySql, sales_order_item, with some information of product bought, like this information :
    sku, name, product_id, product_type, weight, is_virtual.
    but without my new attribut. What I must do to add this information on the table “sales_order_item” ?

Leave a reply:

Your email address will not be published.