Categories and Attributes in Magento: Part 2

by William Rice | April 2009 | Beginner's Guides MySQL e-Commerce Open Source PHP

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:

  1. If you haven't already, log in to your site's backend, which we call the Administrative Panel:
  2. Magento: Beginner's Guide

  3. 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.
  4. Magento: Beginner's Guide

    We will add our own attributes to this list.

  5. Click the Add New Attribute button. The New Product Attribute page displays:
  6. Magento: Beginner's Guide

    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.

  7. Attribute Code is the name of the Attribute. Your customers will never see this value. You will use it when managing the Attribute.
  8. 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.

  9. 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.
  10. 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:

    Magento: Beginner's Guide

    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.

  11. 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.
  12. 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.
  13. 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.
  14. Magento: Beginner's Guide

  15. 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:
  16. Magento: Beginner's Guide

    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.

Sign up for a Packt account to see the rest of this article

Now that you've read a few articles, you might want to consider signing up for a Packt account. It takes a matter of seconds, will give you access to all the articles on PacktPub.com, and once you've signed up you'll be returned here to carry on reading your article.

Furthermore, you'll gain access to nine free ebooks, and be offered a free trial of PacktLib, Packt's online library. Simply enter your details here, or log in to your existing account.

Log in

...or register

Atributes by
Hi, Information about adding attribute and attribute set in this article is nice.It is beneficial foe users. I want to remove a attribute which are already assigned. How i remove it. Surya
Magento Attributes by
I have an attribute which is an http:// link to product information. I have enabled it to show in the compare products page, however the full http://text appears and is not in a link form (does not work.) The correct link name and functional link displays and works on the product and product details pages. Any way to get this to work the same way on the compare products page? Thanks for the great tutorials. Bryan.
group of products in front of others by
easy. just create an attribute like "priority" that has integer values and set the default sort direction to "Ascending" or "descending" (however you want). The default value of priority could be "0". For items you want to appear at the top, just set their priority to some number higher than "0" and set the default sort direction to "Ascending".
group of products in front of others by
how can I in E-store in magenta put some group of products in front of others, because when I open on group, i don't get products first that I like ... I would like on label first and then others, Thank you, Jure
few colors by
I have products with few color, so in category "general" only can put one color, I must create one product for each color? thank you
Help by
Hi I m tanveer Abbas. i m new new user in magneto. i want to facing some problems 1- plz help me how i can create new menu and any place of page 2- plz help me how i create catalog and show products in front page. 3- plz help me how i can manage front hand in breadcrum and products i m sure and confident that u will help me in solving this problems and u will teach me and tell me step by step. i shall be thankful your faithful Tanver Abbas my email address is that tanveerabbas123@yahoo.com PLZ REPLY ME AS SOON AS POSSIBLE

Post new comment

Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Resources
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Sort A-Z