Tools and Resources for all Your Ecommerce Pain Points
Explore Now

Learn How to Create Magento Attributes

An attribute is the property of a product and can be highly useful for an e-commerce store’s functions. You can use it for multiple purposes like creating different types of products and changing their descriptions, and for better search functionality for your customers.

In this guide, you will learn how to create Magento attributes. I will show you the method for both Magento 1.x and Magento 2.x.

Let’s start!

Create Magento Attributes

To create Magento Attributes, open the admin panel of your Magento store and then navigate to Catalog → Attributes → Manage Attributes:

catalog-manage attributes magento 1

Here you will see the list of Magento Attributes. Click on Add New Attribute:

click on add new attribute Magento 1

First of all, set the Attribute Properties:

attribute properties magento 1

  • Attribute Code: I have entered my_attribute. You can enter the code of your choice.
  • Scope: It consists of three options: Store View, Website, Global. Select any one of your choice.
  • Catalog Input Type for Store Owner: It also consists of multiple options. Choose any one according to your needs.
  • Default value: With this, you can set a default value. When you create a product which has this attribute, it will give a default value for that product.
  • Unique Value: If you select the option, Yes, then it means that each attribute value for product(s) must be different.
  • Values Required: If you select Yes, then the attribute must have any value when you create a product.
  • Input Validation For Store Owner: You can set the validation to the attribute field as a decimal number, integer, e-mail URL, letters, any alphanumeric values.
  • Apply To: You can apply this attribute to all products; or can select any one of your choice.

frontend properties magento attribute

  • Use in Quick Search: If you select Yes, the attribute values will become searchable.
  • Use in Advanced Search: It is same as quick search. By selecting Yes, attribute values will become searchable in advanced search.
  • Comparable on Front-end: If you select Yes, the attribute will become visible on compare box feature.
  • Use in Layered Navigation: If you select Yes, the attribute will become filterable on the left or right side of a category page.
  • Use in Search Results Layered Navigation: If you select Yes, the user can filter their search result by this attribute.
  • Use for Promo Rule Conditions: If you select Yes, you will be able to create promo rule conditions using attributes.
  • Position: It’s used for layered navigation. Here you can set the position of the attribute in the right or left hand side of your category filtering.
  • Allow HTML Tags on Frontend: If you select Yes, you can add attribute values that have HTML tags.
  • Visible on Product View Page on Front-end: If you select Yes, the attribute and its value will display on product pages at Additional Information section
  • Used in Product Listing: If you select Yes, the attribute will display in the category page.

Click the Save Attribute button:

click on save attribute magento

Here, you must enter the labels for your attribute which you will see in your Admin panel and your store’s frontend.

enter label magento attribute

Click on Save Attribute button again:

click on save attribute magento

Here you will see the attribute that you have just created is present in the list of Magento Attributes:

attribute listed magento

Create Magento Attribute Set

To create Magento Attribute Set, navigate to Catalog → Attributes → Manage Attribute Sets:

catalog-manage attributes set magento 1

Then click on Add New Set button:

add new set magento 1

Here enter the name for your attribute set and select Default or any other attribute set from Based On dropdown menu. Hit the Save Attribute Set button:

save attribute set magento 1

Here you will see the assigned attribute groups and unassigned attributes to your set. In unassigned, your created attribute my_attribute is present. You can drag it to any other unassigned attribute or attribute group of your choice.

final attribute set magento 1

To verify that you have successfully created Magento Attribute, go to Catalog → Manage Products and click on Add Product. Here you can see your attribute in Attribute Set field:

attribute added product magento 1

Create Magento 2 Attributes

To create Magento 2 Attributes, navigate go to STORES → Product:

stores-attributes magento 2

Here you will see the list of Magento 2 Attributes. Click on Add New Attribute button in the top right corner:

click on add new attribute Magento 2

Now, navigate to Attribute Properties and Advanced Attribute Properties and set it according to your needs:

attribute properties magento 2

advanced attribute properties magento 2

Now, move to Manage Labels section and enter the label for your attributes that you want to display on store’s front-end:

manage labels magento 2

Navigate to Storefront Properties, and set it according to your needs:

storefront properties magento 2

Click on Save Attribute button:

click on save attribute magento 2

Here you will see your created attribute is present in the list of Magento 2 Attributes:

attribute listed magento 2

Create Magento 2 Attribute Set

To create Magento 2 Attribute Set, navigate to STORES → Attribute Set:

stores-attributes set magento 2

Now create your Magento 2 attribute set following the same process as for Magento 1:

save attribute set magento 2

You can see your created Magento 2 attribute in Unassigned Attributes. You can drag it or any other attributes in the attribute groups of your choice.

final attribute set magento 2

To verify that you have successfully created Magento 2 Attribute Set, go to your product creation page and you will see your attribute:

attribute added product magento 2

Create Magento 2 Attribute and Attribute Set Programmatically

I have seen queries regarding how to create a Magento 2 attribute and attribute set programmatically. Hence, I’ll show you how to create one.

First, let’s configure the module. Create module.xml file in app/code/Magenticians/Mymodule/etc and add this code in it:

Now to register the module create registration.php in app/code/Magenticians/Mymodule and add this code in it:

Create InstallData.php in app/code/Magenticians/Mymodule/Setup and add this code in it:

In the code above, I have created an attribute set, and then created an attribute that I have assigned to the attribute set.

It’s time to connect your e-commerce store with an SSH terminal and then run these commands in the root directory of your store.

Now just check the result by going to STORES → Attribute Set, here you will see the new attribute set MyCustomAttribute:

attribute set result

And then click on MyCustomAttribute, here you will see attribute text_my_custom_attribute:

attribute result

Final Words

I believe that after following this tutorial you should be able to create Magento attributes for both the versions, i.e. Magento 1.x and Magento 2.x.. If you still face any issues related to this guide, use the comment box below to share your suggestions, ideas, and issues. I will get back to you.

Also see: How to Configure Layered Navigation with Filterable Attributes in Magento 2

Frequently Asked Questions

Q1. Why create Magento attribute set based on the default attribute?

Suppose you have to create a few new Magento attributes for your products, and you also want to use default attributes. Creating a Magento attribute set using the default attribute will be a good idea. With it, you can also save your time.

Q2. Is it possible to select dropdown input control for my custom Magento attribute?

Yes, it’s possible! While creating a new Magento attribute, you have the option Catalog Input Type for Store Owner under Magento Attributes Properties section where you can select input type of your choice.

 

About Author

Syed Muneeb Ul Hasan is an expert in PHP and Magento, he prefers to educate users in implementing and learning Magento. When not working, he loves to watch cricket.