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

  1. Log into the Magento admin panel
  2. Navigate to “Manage Attributes” under Catalog -> Attributes -> Manage Attributes
  3. In the top right, click on “Add New Attribute”
  4. You’re now on the Attribute edit page and Properties tab.  It looks like this:

Properties Tab

image

  • 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.
  • 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, respectively (ie, if i type “100GB” it should return all products with this value saved in the Hard Drive Size field).
  • Comparable on Front-end: If “yes”, this attribute will be displayed in a product comparison, so long as at least one product in the Compare List contains a value for this attribute.
  • Use in Layered Navigation: If “filterable”, this data will be available as a filter in Magento’s layered navigation. Filterable (with results) means that only values that are associated to specific products in a given category page will list in the Layered Navigation menu. Filterable (no results) means that all existing values for an attribute will display in the menu, even if using this as a filter will produce no results. There’s one condition to use attributes in layered navigation - the Input Type has to be Dropdown, Multiple Select, or Price.
  • Position: This 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.

  • Manage Label / Options

    image
    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”:
    image

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

    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:
    image

    Front-end

    Click here to see how the attribute appears in the front-end.
    image

    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.

    RSS: New Article posts

    Explore the Knowledge Base