Your message has been sent.
This article has been saved to your account.
Go to my account
This article has been emailed to your Kindle.
Send this article
Complete the form below to send this article, Categories and Attributes in Magento: Part 2, to a friend (or to yourself). We will never share your details (or your friend's) with anyone. For more information, read our Privacy Policy.
In the previous part of the article, we saw how to Create Categories and Add products to our store. In this part by William Rice, we will learn how to create Attributes and Attribute Sets in Magento.
Time for action: Creating Attributes
In this section we will create an Attribute set for our store. First, we will create Attributes. Then, we will create the set.
Before you begin
Because Attributes are the main tool for describing your Products, it is important to make the best use of them. Plan which Attributes you want to use. What aspects or characteristics of your Products will a customer want to search for? Make those Attributes. What aspects of your Products will a customer want to choose? Make these Attributes, too.
Attributes are organized into Attribute Sets. Each set is a collection of Attributes. You should create different sets to describe the different types of Products that you want to sell. In our coffee store, we will create two Attribute Sets: one for Single Origin coffees and one for Blends. They will differ in only one way. For Single Origin coffees, we will have an Attribute showing the country or region where the coffee is grown. We will not have this Attribute for blends because the coffees used in a blend can come from all over the world. Our sets will look like the following:
|
Single Origin Attribute set |
Blended Attribute set |
|
Name |
Name |
|
Description |
Description |
|
Image |
Image |
|
Grind |
Grind |
|
Roast |
Roast |
|
Origin |
SKU |
|
SKU |
Price |
|
Price |
Size |
|
Size |
|
Now, let's create the Attributes and put them into sets.
The result of the following directions will be several new Attributes and two new Attribute Sets:
- If you haven't already, log in to your site's backend, which we call the Administrative Panel:
- Select Catalog | Attributes | Manage Attributes. list of all the Attributes is displayed. These attributes have been created for you. Some of these Attributes (such as color, cost, and description) are visible to your customers. Other Attributes affect the display of a Product, but your customers will never see them. For example, custom_design can be used to specify the name of a custom layout, which will be applied to a Product's page. Your customers will never see the name of the custom layout.
- Click the Add New Attribute button. The New Product Attribute page displays:
- Attribute Code is the name of the Attribute. Your customers will never see this value. You will use it when managing the Attribute.
- After you assign an Attribute set to a Product, you will fill in values for the Attributes. For example, suppose you assign a set that contains the attributes color, description, price, and image. You will then need to enter the color, description, price, and image for that Product.
- If you select Yes for Unique Value, then no two products can have the same value for this Attribute. For example, if I made roast a unique Attribute, that means only one kind of coffee in my store could be a Light roast, only one kind of coffee could be a French roast, only one could be Espresso, and so on. For an Attribute such as roast, this wouldn't make much sense. However, if this Attribute was the SKU of the Product, then I might want to make it unique. That would prevent me from entering the same SKU number for two different Products.
- If you select Yes for Values Required, then you must select or enter a value for this Attribute. You will not be able to save a Product with this Attribute if you leave it blank. In the case of roast, it makes sense to require a value. Our customers would not buy a coffee without knowing what kind of roast the coffee has.
- Input Validation for Store Owner causes Magento to check the value entered for an Attribute, and confirm that it is the right kind of data. When entering a value for this Attribute, if you do not enter the kind of data selected, then Magento gives you a warning message.
- The Apply To field determines which Product Types can have this Attribute applied to them. Remember that the three Product Types in Magento are Simple, Grouped, and Configurable. Recall that in our coffee store, if a type of coffee comes in only one roast, then it would be a Simple Product. And, if the customer gets to choose the roast, it would be a Configurable Product. So we want to select at least Simple Product and Configurable Product for the Apply To field:


We will add our own attributes to this list.

There are two tabs on this page: Properties and Manage Label / Options. You are in the Properties tab. The Attribute Properties section contains settings that only the Magento administrator (you) will see. These settings are values that you will use when working with the Attribute. The Frontend Properties section contains settings that affect how this Attribute will be presented to your shoppers. We will cover each setting on this page.
Refer back to the list of Attributes that appeared in Step 2. The Attribute identifier appears in the first column, labelled Attribute Code. The Attribute Code must contain only lowercase letters, numbers, and the underscore character. And, it must begin with a letter. The Scope of this Attribute can be set as Store View, Website, or Global. For now, you can leave it set to the default—Store View. The other values become useful when you use one Magento installation to create multiple stores or multiple web sites. That is beyond the scope of this quick-start guide.
Notice that each of the Attributes in that set is a different kind of data. For color, you would probably want to use a drop-down list to make selecting the right color quick and easy. This would also avoid using different terms for the same color such as "Red" and "Magenta". For description, you would probably want to use a freeform text field. For price, you would probably want to use a field that accepts only numbers, and that requires you to use two decimal places. And for image, you would want a field that enables you to upload a picture.
The field Catalog Input Type for Store Owner enables you to select the kind of data that this Attribute will hold:

In our example we are creating an Attribute called roast. When we assign this value to a Product, we want to select a single value for this field from a list of choices. So, we will select Dropdown. If you select Dropdown or Multiple Select for this field, then under the Manage Label/Options tab, you will need to enter the list of choices (the list of values) for this field.


But what about Grouped Product? We might sell several different types of coffee in one package, which would make it a Grouped Product. For example, we might sell a Grouped Product that consists of a pound of Hawaiian Kona and a pound of Jamaican Blue Mountain. We could call this group something like "Island Coffees". If we applied the Attribute roast to this Grouped Product, then both types of coffee would be required to have the same roast.
However, if Kona is better with a lighter roast and Blue Mountain is better with a darker roast, then we don't want them to have the same roast. So in our coffee store, we will not apply the Attribute roast to Grouped Products. When we sell coffees in special groupings, we will select the roast for each coffee.
You will need to decide which Product Types each Attribute can be applied to. If you are the store owner and the only one using your site, you will know which Attributes should be applied to which Products. So, you can safely choose All Product Types for this setting.

The quick search box will search only those Attributes for which Use in quick search is set to Y

es. For some examples, let's refer back to our list of Attributes:
Look in the column labelled Searchable. Notice that color and description are searchable. This means that if a customer enters a word into the quick search box that is found in the color or description of a Product, then that Product will be found. Notice that customers cannot search based on a Product's price. In our coffee store, we will make roast a searchable Attribute because we know that some customers prefer only coffees that are roasted a specific way. If you select Yes for Use in advanced search, this attribute will have its own field on the Advanced Search page:

In our coffee store, we will make roast a field on the Advanced Search page. By default, Magento puts an Advanced Search link at the bottom of each page in your store.

Clicking on this link takes you to the Catalog Advanced Search page. Some Attributes get their own field on this search page:


When a customer clicks on this link, the Product is added to the Compare Products block.

Next, when the customer clicks on the Compare Items button, the Compare Products page pops up:

On the Compare Products page, notice that only certain Attributes are compared. In the previous example, Model, SKU, Short Description, Description, Color, and Price appear on the Compare Products page.
If you select Yes for Comparable on Front-end, this attribute will appear on the Compare Products page.
You don't want to crowd the Compare Products page with Attributes, but you want to include all the Attributes that will help your customer to choose between similar Products. This requires you to think like a customer. When your customer is comparing similar Products, which Attributes will help the customer to see a real difference between them?
For example, in our coffee store, customers who are interested in one lightly roasted coffee are probably interested in other light roasts. Any coffees that our customers compare probably have the same roast. Therefore, roast would not be an Attribute that helps our customers to decide between similar Products. So in our coffee store, we will not make roast a field on the Compare Products page. However, if we later add an Attribute called character, that would probably be a good one for theCompare Products page.
In the following screenshot, notice that the customer has selected the Category Electronics from the Navigation Menu at the top of the page. Also, notice that the customer can filter the results by three Attributes on the lefthand side of the page. They are Price, Color, and Manufacturer as shown in the following screenshot:

The customer can now find the Products that (s) he wants, using two criteria. A Category can be selected from the Navigation Menu at the top of the page. And, an Attribute Filter can be selected from the Layered Navigation menu on the left side of the page.
Notice the values for the Attribute Price. The first range covers $100 to $200. Then, the values jump to $300. The Price range $200 to $300 is missing. This is because no Products in this Category fall in that price range.
There are three settings for Use in Layered Navigation. Selecting No excludes this Attribute from the Layered Navigation menu.
Selecting Filterable (with results) will put the Attribute into the Layered Navigation menu, but only for those values that show some Products. That is, it places only those values that produce results when used as a filter. That is what happened in the previous screenshot.
Selecting Filterable (no results) will put the Attribute into the Layered Navigation menu, and all values will be displayed. Even values that don't produce results will be displayed. If that setting were selected in the page we just saw, the Price range $200-$300 would be displayed, even though there are no Products in that range.
You can make an attribute filterable only if the Input Type is Dropdown, Multiple Select, or Price.
Every product page has a section called Additional Information. It displays below the Product Description section. In the following screenshot, you can see this section:

If you select Yes for Visible on Catalog Pages on Front-end, this Attribute will appear in the Additional Information section of each Product that uses the Attribute. In the previous example, the Attributes Model, In Depth, Dimensions, and Activation Information had Visible on Catalog Pages on Front-end set to Yes. If a Product has no Attributes that are Visible on Catalog Pages on Front-end, then the Additional Information section will not display for that Product.



pear:
Recall that when an Attribute is a dropdown or multiple selection, you must select one or more values for that Attribute from a list. The Manage Options section is where you create that list.
In the Admin field, enter the name that you will use for this value in the administrative interface. You will see this name when you are creating a Product, and assigning a value to the Attribute. In the Default Store View field, enter the value that your customers will see in your store.
If this Attribute type is not Dropdown or Multiple Select, then this section will not appear

This concludes the process for creating a new Attribute. Repeat this as needed. In our demonstration store, we will create two more Attributes: grind and caffeine.
What just happened?
In this section you created new Attributes. These Attributes will be used to describe your Products. Your customers will be able to use some of these Attributes to filter Products, helping them to drill down to exactly the merchandise they want. Other Attributes will appear in the Search function, enabling your customers to search your entire site for Products that meet their criteria. Your customers will also be able to use some of these Attributes when they compare products side-by-side, helping them to choose between the Products.
What's next?
Next, we will put our Attributes into Attribute Sets. Recall that you do not apply Attributes individually to Products. Instead, you apply a set of Attributes to each Product.
Time for action: Creating Attribute Sets
- If you haven't already, log in to your site's backend. We call it the Administrative Panel.
- Select Catalog | Attributes | Manage Attribute Sets.
- Click on Add New Attribute Set. The Edit Set Name page is displayed as follows:
- Enter a Name for this set. The shoppers will never see the name of this Attribute set. You will see the name when you create a Product and need to assign a set to that Product. This is why you should use a name that will help you remember the purpose of this set.
- For Based On, select a set that will be the starting point for this set. If this is the first set that you created, then your only choice will be Default.
- Click on Save Attribute Set. The Edit Attribute Set window is displayed:
- The left column contains the name of this set. The middle column contains all of the Attributes that are a part of this set. Right now, those are the same as for the Default set. The right column contains Attributes that are not part of this set. The label Unassigned Attributes might be misleading because these Attributes might have been assigned to other sets.
- Notice that the Attributes in this set are organized into Groups. Each Group in this set will create a tab on the Product page if at least one Attribute in that Group is set to display. If all of the Attributes in a Group are hidden from the shopper, then that Group will not create a tab on the Product page. For example, the group Meta Information contains only Attributes that are hidden, so shoppers will not see a tab called Meta Information.
- To add an Attribute to the set, open a Group and then drag the Attribute into that 7. Group as shown in the following screenshot:
- To remove an Attribute from the set, drag it from the Group that contains it to the Unassigned Attributes column. In our demo store, we will remove manufacturer and color because they do not apply to our coffee product.
- To move an Attribute from one Group to another Group, just drag and drop the Attribute.
- To add a new Group (and possibly create a new tab on the Product page), click on Add New. When prompted, enter the name of the new Group.
- To change the order of the Groups, drag and drop them.
- To delete a group, select it and click on Delete Selected Group. You cannot delete a Group that has System Attributes in it. When you delete a Group, its Attributes become unassigned. When you are finished, click on Save Attribute Set.
The Manage Attribute Sets page is displayed. If this is a new installation, there will be only one Attribute set listed—Default as shown in the following screenshot:


If you will use the set only for a specific kind of merchandise, consider naming the set after that merchandise. In the previous screenshot, I am creating a set that I will apply only to coffee sold by the pound. The name coffee-by-pound reminds me of the purpose for this set. If you will apply this set to several kinds of merchandise, consider using a name that describes the contents of the set. In our demo site, we could create a set that contains those Attributes called grind-roast-origin.
When you create a new set, you must always base it upon an existing set. The first time, this will be Default because that is the only set available.
Default contains all of the system Attributes that are required for each Product, plus a few more Attributes that come with the standard Magento installation.
You can edit the contents of Default, but you should not do this without a compelling reason. Leaving Default intact ensures that you will always have a set that contains the minimum Attributes needed for a Product. When you need to create a set that is very different from any of the others in your store, it is usually easiest to start with a minimum set such as Default and build it up. This is easier than starting with another set, removing the Attributes that you have added, and then building it up. Starting with Default and building up is easier when making new sets that are unlike any others in your store.

The orange circles mark the System Attributes. Recall that every set must contain all of the System Attributes because each Product must have all of the System Attributes applied to it.

In our demo store, we will add caffeine, grind, and roast to the General group.
The tabs that these Groups create on the Product page display left to right. They appear in the order that the Groups are placed here. The topmost Group creates the tab on the left, and the bottom Group creates the rightmost tab.
What just happened?
You have just created at least one Attribute set. Each set contains a collection of Attributes that you will use to describe a product. If you created just one set, every Product in your site will use that set. This is fine if all your Products are similar (for example, if all you sell is coffee). If you created several sets, you probably sell several different kinds of Products (for example, coffee and coffee brewing accessories).
Summary
In this article, we created Attributes and Attribute Sets. Think of Attributes as the qualities that enable us to distinguish one product from another.
About the Author :
William Rice
William Rice is an e-learning professional who lives, works, and plays in New York City. He is the author of books on Moodle, Blackboard, Magento, and software training.
He especially enjoys building e-learning solutions for small and mid-sized businesses. His greatest professional satisfaction is when one of his courses enables students to do something that makes their work easier and more productive.
His indoor hobbies include writing books and spending way too much time reading slashdot.org. His outdoor hobbies include orienteering and practicing archery within sight of JFK Airport.
William is fascinated by the relationship between technology and society: how we create our tools, and how our tools in turn shape us. He is married to an incredible woman who encourages his writing pursuits, and has two amazing sons.
You can reach William through his website at http://williamrice.com.
Books From Packt



Post new comment