Tutorial: Creating Attributes (custom fields)
So you’re ready to add some custom data to your products? Luckily, this isn’t complicated. Today we’re going to create an attribute called “Hard Drive Size” for the external hard drives we’re about to sell in our store, and also an attribute called “Manufacturer” to use in our layered navigation. Let’s start with the simpler one - Hard Drive Size. In the front-end, this will appear on products like “Hard Drive Size: {whatever options you create and select}” - For example: “Hard Drive Size: 100GB”.
Creating a simple attribute - Hard Drive Size
- Log into the Magento admin panel
- Navigate to “Manage Attributes” under Catalog -> Attributes -> Manage Attributes
- In the top right, click on “Add New Attribute”
- You’re now on the Attribute edit page and Properties tab. It looks like this:
Properties Tab
- Attribute Identifier: This is the name of the attribute used by the system. Spaces can not be used in this field. We’ll type hard_drive_size.
- Scope: This determines the store level at which this attribute will save for all products. If you choose Global, and edit “Hard Drive Size” for product 123 in store A to “50 GB”, product 123’s hard drive size in store B (and any other stores) will also update to “50 GB”. For hard drive size, we’ll make it globally editable - we won’t sell the exact same hard drive in different stores with different sizes… that’s not possible. An example where we might want globally editable: no is “Price.” We might want to sell the Hard drive for $20 more in Store A.
- Catalog Input Type: This describes what kind of data the attribute will store. What’s set here determines how data entry for this attribute will take place. We’ll use Text Field since we want to enter the value for each product manually into a text field.
- Default Value: You can enter a value that will automatically populate for new products. We have many different hard drive sizes, so we will leave this blank.
- Unique Value: If “yes”, the data saved in this attribute has to be unique for each product. In this case, we’ll say “no”, because multiple hard drives can have the same hard drive size.
- Values Required: If “yes”, you will be required to enter data in this attribute field when saving a product that uses it.
- Input Validation: This decides whether the data entered by the store owner is validated when the product is saved. If validation is set to “Digits”, we’ll only be able to enter 0-9 in this field. An error will be thrown if we try to put letters in the field. In the case of Hard Drive Size, we don’t need validation on this field.
- Apply To: This determines for which Product Types this attribute will display. For example, price wouldn’t make sense in a grouped product, as each Simple Product associated to the Grouped Product will have its own price. Therefore, you can set price to not apply to grouped product, and you won’t be scratching your head over what numbers to write in there.
Manage Label / Options
Under this tab, you can enter the label for the attribute in the front-end. If you control stores in multiple languages, you can enter the label in each language under this tab. If a store’s label is blank, this store will look to the default label and use this one. Here we’ll enter “Hard Drive Size” under “Default”.
Frontend Properties
Click here to see how the attribute appears in the front-end.
Creating an attribute with controlled options - Manufacturer
The next attribute we’ll create is going to be “Manufacturer.” Let’s say you carry televisions by 4 manufacturers. Rather than having to type the name of each manufacturer, why not just make it an attribute and assign four possible options to it: Varien, Panasonic, JVC, and Sony.
Attribute Properties
For our “Manufacturer” attribute, we’ll use Catalog Input Type “Dropdown” since we want this attribute to have limited data. Using “Dropdown” also enables us to show the attribute as a layered navigation filter. Below is what the Properties tab looks like for “Manufacturer”:
Manage Label/Options
Since we select Dropdown as the input type, we have the ability to create the possible options for this attribute from this tab. Under “Manage Labels” tab is “Manage Options”. Press “Add Option” to add an option. It functions similarly to labels - any blank fields will look to the “default”. You can also set the positions of each value and select one of the values as the default. See below for how it looks after adding four manufacturers as options.
Applying to a product
Now, to apply this selectable attribute to a product, just add it to an attribute set and create a new product using this set. Below is a simplified example of the General tab of creating a new product in the admin:
Front-end
Click here to see how the attribute appears in the front-end.
Mmm, nice. Now you’ll never have to type these manufacturers again. Also, data entry will be more consistent, since it is impossible to have a typo or spelling error if a drop-down is used.




1tierralogic from planet xenon, zeti cluster|posted December 10 2007
how can i add an upload field for a file, and have the system show a link to it on the front end? this would be for a user manual, etc, like a pdf file.
thanks!
2Ross from Scarborough, North Yorkshire, UK|posted January 14 2008
This is great, but I do agree with the previous comment - it would be nice to be able to have an attribute of type ‘file’ (or similar). There is the ‘image’ type of attribute (which is close), but a more general purpose one would be good.
For example, a shop selling CDs may wish to have a track listing with the track titles linked to preview audio samples. If attributes could do that it would be really great!
3johannes |posted January 15 2008
Yes, it would be great to upload files! In fact, we are working on supporting this type of attribute
4Ross from Scarborough, North Yorkshire, UK|posted January 15 2008
Great to hear! It sounds like not much is being overlooked!
Thanks for the reply.
5DragonZoul |posted January 22 2008
The concept is fine. We’ll see how far “attrbiutes” may be used, especially on the programmatric way in “my own” new classes ...
what other types of attributes are planed?
6tierralogic from planet xenon, zeti cluster|posted January 22 2008
so how does this work? are any of the responding parties part of the magento team?
basicly, if i wanted to try and do this myself, which i think i can do with some effort, should i just go ahead and give it a shot and then what? submit the code to the group or smth?
sorry just a little new to this!
7Ross from Scarborough, North Yorkshire, UK|posted January 22 2008
@tierralogic - the posts that have the blue gradient are the Magento team (eg. johannes).
If you want to try it yourself, go ahead! Although if they are working on it, it might be worth waiting a couple of weeks for the next release (release candidate I think) - and see what changes have been made.
At the moment there is no place to submit code. It has been said that a development community (and ways to contribute code - and sell add-ons and services) will be launched after the production release (when the APIs etc are more stable and documented).