Magento 2 Product Attributes

Introduction

In this article, we are going to understand the purpose of the creation of the attribute. Before we create any type of the product, we should know details about the product attribute. So to understand how to use attribute, lets see the details below:-

Product Attributes

An attribute is a property or characteristic of a product, for example, the product color, the size, or the description. Magento 2 uses attributes to manage the information associated with products. Some attributes are built into the system by default, and others can be created to meet specific needs. You can add, modify, or remove product attributes in Magento 2 to customize your products.

Mostly, Magento 2 product attributes are used to for 4 different purposes:

  • Define product information
  • For filtering and searching of the product
  • To compare products on the site
  • Used for promotion settings up

Types Of Product Attributes Magento 2

To understand these in more details,Β Please navigate toΒ Admin Panel β‡’ Stores β‡’ Attributes β‡’ Product.

Here you will get the list of product attributes. All product attributes in Magento 2 are saved in one grid for easy management where you can search and edit any attributes at hand.

There are two types of product attributes in Magento2:-

  1. System Attributes
  2. Custom Attributes

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 requirement.

 

Create A Custom Product Attributes inΒ Magento2

There are 2 ways to add new product attributes in Magento 2:

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

Step 1: Click On β€œAdd New Attribute” Button

  1. Log inΒ to Admin Panel
  2. Navigate toΒ Stores > Attributes > Product
  3. Click β€œAdd New Attributeβ€œ

Step 2: Properties Tab

UnderΒ Attribute properties, describeΒ basic information of the product attributes Magento 2.

 

  1. Enter aΒ Default Label to identify the attribute. It will be displayed on the admin panel.
  2. The Catalog Input Type For Store Owner will define the type of data that can be entered in the fields. There are 13 Catalog Input Types For Store OwnerΒ to define the product attributes Magento 2.
    • 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 can be picked from the calendar or typed directly into a field
    • Date & Time:Β 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)
  3. Set β€œYes” to β€œValues Required” if you want to the customer to choose this option compulsorily before the product can be purchased or can be created or saved in the admin.

 

ExpandΒ Advanced Attribute Properties.Β 

 

  • Attribute code:Β the unique identifier to manage the attribute: search, import/export, get attribute ID/name/value, etc. It should be lowercase characters without any spaces. If you leave this field empty, the attribute code will automatically be generated from the default label.
  • 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.

  • Default Value: While creating product it will be there. But default value won’t be automatically set to all existing products. It will be added only after the re-saving of the product.
  • Unique Value: Enable this field to β€œYes” to avoid duplicate values. Ex:- ID-number fields like SKU.
  • Input Validation for Store Owner: Before saving a product, we need to validate an attribute value. There are following type of validation as shown below:-

  • Add to Column Options: Set to YesΒ in theΒ Add to Column Options field then this attribute will be available to the list of column options in the product grid.
  • Use in Filter Options: ChooseΒ YesΒ inΒ Use in Filter OptionsΒ field if you want this attribute to be used while filtering products.

Note :- Attributes used for the configurable productsΒ must haveΒ Catalog Input TypeΒ to beΒ drop-downΒ and theΒ Global scope.

Step 3: Manage Labels Of Product AttributesΒ Magento 2

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”. If you have a multilingual site, you can set a label for each language.

 

Step 4: Set Up Storefront Properties

This properties of the attribute helps us to make the product searchable, filterable. We can apply promotions, etc.

Go to β€œStorefront Properties” underΒ Attribute Information

 

  1. β€œUse in Search”: If enabled, this will help us to make product searchable with this attribute value.
  2. β€œComparable on Storefront”:Β  If we enable this option, then we can see comparison of the product in product comparison with its value.
  3. For catalog input field to be drop down, multiple select or price:
  4. Set β€œUse in Layered Navigation” to β€œYES” to use the attribute as a filter in layered navigation.
  5. Set β€œUse in Search Results Layered Navigation” to β€œYes” to use the attribute in layered navigation on search results pages.
  6. Set the relative position of the attribute in the layered navigation block in β€œPositionβ€œ.
  7. Enableβ€œUse for Promo Rule Conditions” field to use the attribute in promotion for marketing purpose.
  8. Enable β€œAllow HTML Tags on Storefront” field to allow the text to be formatted with HTML and use WYSIWYG editor
  9. Enable the β€œVisible on Catalog Pages on Storefront” field to make the attribute visible in catalog page listing.
  10. 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 Listingβ€œ

Step 5: Save Attribute

  1. Click the β€œSave Attribute” button to save the configuration.

 

Summary

This article helps you to understand the functionalities that can be possible to give to the product with the help of the attribute.

Hope you liked the article. Do comment below giving your feedback.

Happy Learning !!

Thank You !!