Categories and Attributes in Magento: Part 2

Exclusive offer: get 80% off this eBook here
Magento: Beginner's Guide

Magento: Beginner's Guide — Save 80%

Create a dynamic, fully featured, online store with the most powerful open source e-commerce software

₨739.00    ₨147.80
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.

Magento: Beginner's Guide Create a dynamic, fully featured, online store with the most powerful open source e-commerce software
Published: March 2009
eBook Price: ₨739.00
Book Price: ₨400.00
See more
Select your format and quantity:
  • By default, Magento puts a quick search box in the top right corner of each page in your store.
  • Magento: Beginner's Guide

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

    Magento: Beginner's Guide

    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:

    Magento: Beginner's Guide

    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.

    Magento: Beginner's Guide

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

    Magento: Beginner's Guide

  • By default, Magento enables customers to compare Products in your store. When viewing a Product, the customer sees an Add to Compare link, as shown in the following screenshot:
  • Magento: Beginner's Guide

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

    Magento: Beginner's Guide

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

    Magento: Beginner's Guide

    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.

  • The Use in Layered Navigation setting enables your customers to filter Products based on this Attribute. When this is enabled, your customer sees a filter on the left side of the page, where (s)he can select values for this Attribute. Magento will then display only Products that have a value for the Attribute that falls within the range selected by the customer.
  • 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:

    Magento: Beginner's Guide

    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.

  • If you use this Attribute in the Layered Navigation menu (that is, if you allow your customers to filter by this Attribute), then Position determines the position of the attribute in the Layered Navigation. Entering 1 puts this Attribute at the top of the menu.
  • The setting for Visible on Catalog Pages on Front-end applies only to Simple Attributes. That is, it applies only to Attributes that you create, not to those that are automatically created by Magento.
  • 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:

    Magento: Beginner's Guide

    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.

  • Select the Manage Labels/Options tab:
  • Magento: Beginner's Guide

  • Under Manage Titles in the Admin field, enter the name that you will use for this Attribute in the administrative interface. In the Default Store View field enter the name for this Attribute that your customers will see in your store:
  • Magento: Beginner's Guide

  • If this Attribute type is Dropdown or Multiple Select, then the Manage Options section will ap

    Magento: Beginner's Guide

    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

  • Click on Save Attribute. The Attribute is saved and you are returned to the list of Attributes. You should see the one you just added in the list, along with a success message at the top of the page like this:
  • Magento: Beginner's Guide

    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.

    Magento: Beginner's Guide Create a dynamic, fully featured, online store with the most powerful open source e-commerce software
    Published: March 2009
    eBook Price: ₨739.00
    Book Price: ₨400.00
    See more
    Select your format and quantity:

    Time for action: Creating Attribute Sets

    1. If you haven't already, log in to your site's backend. We call it the Administrative Panel.
    2. Select Catalog | Attributes | Manage Attribute Sets.
    3. 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:

      Magento: Beginner's Guide

    4. Click on Add New Attribute Set. The Edit Set Name page is displayed as follows:
    5. Magento: Beginner's Guide

    6. 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.
    7. 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.

    8. 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.
    9. 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.

    10. Click on Save Attribute Set. The Edit Attribute Set window is displayed:
    11. Magento: Beginner's Guide

    12. 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.
    13. 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.
    14. 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.

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

      In our demo store, we will add caffeine, grind, and roast to the General group.

    17. 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.
    18. To move an Attribute from one Group to another Group, just drag and drop the Attribute.
    19. 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.
    20. To change the order of the Groups, drag and drop them.
    21. 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.

    22. 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.

    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 practicing archery within sight of JFK Airport, and trying to keep up with his sons on the playground.

    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

     

    Drupal 5 Views Recipes
    Drupal 5 Views Recipes

    Choosing an Open Source CMS: Beginner's Guide
    Choosing an Open Source CMS: Beginner's Guide

    Joomla! E-Commerce with VirtueMart
    Joomla! E-Commerce with VirtueMart

    Plone 3 Theming
    Plone 3 Theming

    Mastering phpMyAdmin 3.1 for Effective MySQL Management
    Mastering phpMyAdmin 3.1 for Effective MySQL Management

    Selling Online with Drupal e-Commerce
    Selling Online with Drupal e-Commerce

    jQuery UI 1.6: The User Interface Library for jQuery
    jQuery UI 1.6: The User Interface Library for jQuery

    WordPress Plugin Development (Beginner's Guide)
    WordPress Plugin Development (Beginner's Guide)

     

    Code Download and Errata
    Packt Anytime, Anywhere
    Register Books
    Print Upgrades
    eBook Downloads
    Video Support
    Contact Us
    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