Wednesday, November 23, 2011

Understanding the Product and the Product Type in Commerce (Part-1 of 2)

Welcome back... the coverage on this blog will include:
  1. Prerequisites for understanding of the Drupal Commerce Product and Product Type.
  2. Drupal Commerce URL paths for the Product and the Product Type.
  3. Setting up / Defining of the Product Type.
  4. One example and a case Study (Part - 2/2).
1). Prerequisites for understanding the Drupal Commerce Product and the Product Type
Entities of Drupal Commerce : Drupal Commerce has its own set of Reference, Fields and Entities. Please read the blog here.

2). Drupal Commerce URL paths for the Product and the Product Type.
  • Creating / Adding new Product Types (admin/commerce/products/types). Navigate as Admin > Store > Products > the Product Types TAB.
  • Creating the Products, you navigate as Admin > Store > Products and start adding products there. Or you could use the path (admin/commerce/products/add/product). You could see all the created Products at admin/commerce/products.
  • When you configure Product Displays ( uses the URL : /node/add/content/product_display)
3). Setting up / Defining of the Product Type :

This is where we define the Product type of the Product we want to sell on our store. As in programing, this is a declaration part, akin to a CLASS. The product can have custom fields such as price, image, size, color, style etc. Depending upon the use case, we can either have one product type for each type of product sold on the store or more than one product of the same type if they have the same fields. Each or all of these fields could be the attributes of the product. When we say ATTRIBUTES of the product, we mean we could use the parameter for selecting the product amongst others on the store.

Let us see how it looks on Drupal 7. The path / navigation to created the product type is mentioned above. Creating / Adding new Product Types (admin/commerce/products/types). Navigate as Admin > Store > Products > the Product Types TAB .
Here we see the list of product types created for you store. We also see the PRODUCT product type that comes with the Drupal Commerce Kickstart Profile. We will explore this default product in this article.

On this page you will notice that there are 3 things we can do :
  1. Edit the Product Type
    1. Here we set the Name , Description and the Explanation/ Submission guidelines for this product. 
  2. Manage Fields of the Product Type - 
    1. Here we see some standard fields that come with Drupal Commerce. This is also where we create new custom fields for our products. 
    2. Also, when we enable other Commerce modules, fields get added to the product when we enable other modules (for example, the STOCK field show up here when we enable the Commerce STOCK module).
  3. Manage Display of the Product Type -
    • This is where we can either set the visibility of fields or rearrange them. 
    • One key thing to note here is that in addition to the Teaser and the Default display, we have the LINE ITEM DISPLAY as well. 
  4. Configuring Custom CCK Fields for Products in Commerce - 
    1. Consider that we are adding a custom field for SIZE; and that there are 3 possible sizes - Small, Medium and Large.
    2. Adding a custom CCK field is a standard drupal process even in Commerce. We go to the " Manage Fields" Tab and ADD the field. We give it a Label ( readable name for humans ), Name ( the machine name), Field (specify the type of field it will be) and the Widget (the type of widget it will use, such as  check box or a drop down and so on); and we save the form.
    3. Next step is the settings for the widget. For a Select List, we enter the values that should appear in the DropDown box. We save the field settings to go to the next page.
    4. Here we do the settings of the Custom CCK field added by us.  This page contains only two settings- the Product Settings and the Size Field Settings
    5. For the PRODUCT SETTINGS :
      1. Notice here the PRODUCT here is the name of the Product Type we used to create the product. Same for the SIZE in the SIZE FIELD SETTINGS above is the LABEL of the field we just added. This could as well be a SUBSCRIPTION product or the COLOR field settings.
      2. The product settings is pretty standard except for Attribute Field Settings. This comes from the Commerce Module.
        • The Attribute Field Setting is used on the product display when we want the customer to select the product by an attribute such as the size, or color, or style or even "free shipping".
        • Using the attribute field, one could buy a large cap or small cap. One could check the colors that are available for the size, say for a large cap and then buy a cap of a particular size and color.
        • Each Attribute combination (L-blue, M-red, M-blue, M-black etc) is a different product on the catalog.
        • In such cases, the CCK field needs to be set as an ATTRIBUTE FIELD in the PRODUCT SETTINGS. 
        • This will make the product display work as attribute selection fields on Add to Cart forms.  Which basically means you are selecting the product by it's attributes.
        • As a result, Product Display can reference multiple products and only one product with the matching attribute combination is selected and displayed in the product display.
    6. The SIZE FIELD SETTINGS :
      1. Notice here the SIZE In the SIZE FIELD SETTINGS above is the LABEL of the field we just added. Just as PRODUCT was the name of the Product Type we are using to define this product.
      2. This field basically says two things:
        • If this field is to be used as the attribute field for selecting products in the product catalog (product display), then,
        • This field must reference only one product out of the multiple products that the product display references to.
      3. Which is why, if you want your field to work as an attribute field, you must make the Number of Values field to ONE. Otherwise you will have to return to this configuration again to make it work for you. :)
    7. These are the two most important things to take note off when setting up your products on your eStore.
With this we can positively say that we have covered all the aspects of Setting up Products for your eStore. Hope this helps. Open for kudos and brickbats !!! Happy learning...