As you know, Attributes are pieces of information that might appear as fields in forms, reports, product reviews, layered navigation, and email messages. Some attributes are built into the system, and others can be created to address specific needs. It’s very important because your Magento 2 uses attributes to manage the information associated with products, customers, and product ratings. So today, we will illustrate how you can setup your products’ attributes.
How to create Product Attributes for Magento 2 site?
Step 1: Describe the Basic Properties
Firstly, on the Admin sidebar, navigate to Stores>Product. Then, tap Add New Attribute .
Under Attribute Properties, enter a Default Label to identify the attribute and set Catalog Input Type for Store Owner to the type in input control to be used for data entry. If you want to require the customer to choose an option before the product can be purchasaed, set Values Required to “Yes.”
- Under Manage Options, tap Add Option.
- Enter the first value that you want to appear in 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.
- Tap Add Option and repeat the previous step for each option that you want to include in the list.
- Select Is Default to use the option as the default value.
Step 2: Describe the Advanced Properties (Optional)
Firstly, enter a unique Attribute Code in lowercase characters, and without spaces and set Scope to indicate where in your store hierarchy the attribute can be used. If you want to prevent duplicate values from being entered, set Unique Value to “Yes.”
Besides, to run a validity test of any data entered into a text field, set Input Validation for Store Owner to the type of data that the field should contain. This field is not available for input types with values that are selected. The test can validate any of the following:
- Decimal Number
- Integer Number
- Letters (a-z, A-Z) or Numbers (0-9)
Step 3: Enter the Field Label
To enter the Field Label, expand the Manage titles section then enter a Title to be used as a label for the field. (If your store is available in different languages, you can enter a translated title for each view.)
Step 4: Describe the Storefront Properties
In this step, we choose Storefront Properties, then do the following:
- If the attribute is to be available for search, set Use in Search to “Yes.”
- To include the attribute in Product Compare, set Comparable on Storefront to “Yes.”
- To use the attribute in price rules, set Use for Promo Rule Conditions to “Yes,”
- To allow the text to be formatted with HTML, set Allow HTML Tags on Frontend to “Yes.” This setting makes the WYSIWYG editor
- available for the field. To include the attribute in catalog page listings, set Visible on Catalog Pages on Storefront to “Yes.”
Finally, complete the following settings if supported by your theme:
- To include the attribute on the product detail page, set Visible on Catalog Pages on Storefront to “Yes.”
- To include the attribute in product listings, set Used in Product Listing to “Yes.”
- To use attribute as a sort parameter for product listings, set Used for Sorting in Product Listing to “Yes.”
When complete, tap Save Attribute .
Besides introduce to you how to create Product Attributes in Magento 2, we will help you to work more effective by creating Attribute Sets. The attribute set determines the fields that are available during data entry, and the values that appear to the customer. It are organized into groups that determine where they appear in the product record. If you sell products that require specific types of information, such as cameras, it might be better to create a dedicated attribute set that includes the specific attributes that are needed to describe the product.
To create Attribute Sets, do the following:
Firstly, tap Stores and choose Attribute Set. Then tap Add New Set.
Enter a Name for the attribute set. Then, set Based On to an existing attribute set to be used as a template and Tap Save.
The next page displays the following:
- The left column shows the name of the attribute set. The name is for internal reference, and can be changed as needed.
- The center of the page lists the current selection of attribute groups.
- The right column lists the selection of attributes that are currently not assigned to the attribute set.
- To add a new attribute to the set, drag the attribute from the Unassigned Attributes list to the appropriate folder in the Groups column.
Notice: System attributes are marked with a dot and cannot be removed from the Groups list. They can however, be dragged to another Group in the attribute set.
When complete, tap Save.