How to Create Attribute in Magento

How to Create Attribute in Magento

30 min read

Send to you:

In Magento, an attribute means any property of a product and you can add as many attributes as you need. They can be grouped into attribute sets, so similar products can be created with the same attributes. In this section, you will learn how to work with attributes, create, add, and change them from the admin store view or programmatically.

Let’s say we want to create an attribute called “Material”.

Step 1. Log into the Magento admin panel. Go to Catalog -> Attributes -> Manage Attributes

There you will see all the attributes used in your system.

Step 2. In the top right, click on “Add New Attribute”

Step 3. In the Properties tab you will need to configure the Attribute Properties:

  • Attribute Identifier: the name of the attribute used by the system. E.g. material.
  • Scope: allows you to declare the attribute value saving scope like Global ( the value of this attribute for a given product must be the same for all websites and stores on this Magento installation), Store View (the value of this attribute for a given product can differ in all Websites and all Store Views), Website (the value of this attribute for a given product can differ in different Websites, however, it cannot differ between Store Views contained under the same Website).
  • Catalog Input Type for Store Owner: describes what kind of data the attribute will store. For instance, if you want to manually enter the value for each product into a text field, select Text Field etc. In our case, we want to use Dropdown.
  • Unique Value: select “yes” if you want the data saved in this attribute to be unique for each product. But we rather use “no”, because different product types may be made of the same material.
  • Values Required: we are using “yes” since all our products are made of some material.
  • Input Validation for Store Owner: decides whether the data entered by the store owner is validated when the product is saved. In our particular case, we don’t need validation on this field, so we’ll choose “None”.
  • Apply To: determines for which Product Types this attribute will display. If you chose “Select product types” in the drop-down menu, you can set “material” to not apply to grouped/simple/configurable etc product or just use “All Product Types.

Step 4. And the settings for Frontend Properties:

  • Use in quick/advanced search: If “yes”, the data saved in this attribute will be searchable in the front-end in the quick search and advanced search.
  • Comparable on Front-end: If “yes”, this attribute will be displayed in a product comparison, if as at least one product in the Compare List contains a value for this attribute.
  • Use in Layered Navigation (can be used only with catalog input type Dropdown, Multiple Select and Price). Since we selected “Dropdown”, this option is active and we can select e.g. Filterable (with results).
  • Position: determines the position of this attribute in the Layered Nav menu.
  • Visible on Catalog Pages on Front-end: If “no”, this attribute will not be displayed in the product info page. The “visibility” only controls whether or not the attribute displays in the front-end. Keep in mind – if you set an attribute to “Visible: No”, and leave it as “Comparable: Yes”, this attribute will still show up in comparison charts.

Step 5. Click on the Manage Label/Options tab. Under this tab, you can name the attribute on the front-end by the attribute label. You can enter different labels for different. If a store’s label is blank, this store will look to the default label and use this one. Here we’ll enter “Material” under “Admin” and under “English”. Then, under the Manage Options (values of your attribute) we’ll enter lycra, nylon, polyester, satin, lace, silk and sheer fabric. Click Add Option each time you need a new line of fields for the attribute values. In the Position row you can enter 1,2,3 enter to position them.

Step 6. When you are ready, click Save Attribute in the top right corner.

Step 7. To apply this selectable attribute to a product, first, add it to an attribute set. Go back to the Catalog tab and select Manage Attribute Sets.

Step 8. There you will see all the attribute sets created in your system. Click Add New Set.

Step 9. Give your new attribute set a name by entering the Name filed. E.g. material. Let it be Based On -> Default. Click Save Attribute Set.

Step 10. On the next page, you will see the attribute set you’ve just created in the third column labeled Unassigned Attributes. You will drag and drop it to one of the groups in the second column. For instance, to General.

Step 11. Click Save Attribute Set in the top right.

Step 12. Now you can create a new product under Catalog -> Manage Products -> Add Product and in the Attribute Set drop-down select the attribute setyou’ve created. Then click Continue.

Step 13. Now you can proceed and create a new product based on the new product attribute group you created (“material”). Since you have added the new attribute to the General section, you will find it there in there under the General tab in the same order it was added. Once your new product is created, you can open it on the frontend to see the new attribute you have added among its details.

Next, we move on to creating an attribute in Magento 2 step-by-step.

How to Create Attribute in Magento 2

Step 1. Complete Basic and Advanced Properties information

  • On the Admin panel, click Stores. In the Attributes section, select Product
  • Click Add New Attribute button
  • In the Attribute Properties section, do the following
1
  • In the Default Label, enter a default label to identify the attribute
  • In the Catalog Input Type for Store Owner field, select the type in input control to be used for data entry
    • Text Field
    • Text Area
    • Date
    • Yes/No
    • Multiple Select
    • Dropdown
    • Price
    • Media Image
    • Fix Product Tax
    • Visual Swatch
    • Text Swatch
2

Note: If you use Dropdown and Multiple Select input types, do the following

  • Under the Manage Options section, click Add Option button
3
  • Select Default if you use the option as the default value
  • If you have only one store view, let enter only the Admin value and it will be used for the storefront as well
  • If you have multi-store views, let enter one value for the Admin and a translation of the value for each store view
  • Click on Add Option to create multi options that you want to include in the list
  • In the Values Required field, select Yes if you want to require the customers to choose an option before they can purchase products
  • In the Advanced Attribute Properties section, complete the following (If needed)
  • In the Attribute Code field, enter a unique Attribute Code in lowercase characters, and without space
  • In the Scope field, select one of the following to indicate where in your store hierarchy the attribute can be used

* Website * Store view * Global

* In the `Unique Value` field, set to `Yes` if you want to prevent 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 to "Yes" to add this attribute to the list of filter options in the product grid.

Step 2. Manage Labels

  • Open the Manage Labels section, do the following
4
  • 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 3. Describe the Storefront Properties

  • Open the Storefront Properties section, do the following
5
  • In the Use in Search field, set to Yes if the attribute is to be available for search
  • In the Comparable on Storefront field, set to Yes to include the attribute in Product Compare
  • In the Use in Layered navigation field, set to Yes if you want to use the attribute as a filter in layered navigation
  • In the Use in Search Results Layered Navigation field, set to Yes if you want to use the attribute in layered navigation on search results pages
  • In the Position field, enter a number to indicate the relative position of the attribute in the layered navigation block
  • In the Use for Promo Rule Conditions field, set to Yesto use the attribute in price rules
  • In the Allow HTML Tags on Frontend field, set to Yes allow the text to be formatted with HTML
  • In the Visible on Catalog Pages on Storefront field, set toYesto include the attribute in log page listings
  • In the Used in Product Listing field, set toYes include the attribute in product listings
  • In the Used for Sorting in Product Listing field, set to Yesto use the attribute as a sort parameter for product listings
  • When complete, click Save Attribute button.

5.0/5.0

Article rating (7 Reviews)

Do you find this article useful? Please, let us know your opinion and rate the post!

  • Not bad
  • Good
  • Very Good
  • Great
  • Awesome