Sunday, November 20, 2011

Setting up a Categories based Product Catalog ( Drupal Commerce) - the first approach


Setting up a Drupal Commerce Catalog based on Categories is one of the most important things in learning about Drupal Commerce. There are basically two methods or approaches of doing it. In this blog we will discuss the first method. In this method, there are basically three steps to it.
This is all about Drupal 7 so far. Having completed the setup for the Categories based Catalog, all that remains is adding your products to them and tagging them to their categories using the Term Reference in the Product Display. Product types, the Product and the Product Displays is all about Drupal Commerce. And this we will discuss in the other series of blogs.
As we discussed there are two approaches to building a category based catalog. We will discuss the first one here.

In the first method, there are basically three steps to create a category based catalog, these are:
  1. Create the Categories (admin/structure/taxonomy) and have a separate landing page for each category.
  2. Create the Menu links and point them to the Category landing pages.
  3. Place the Menu links Block on the pages you wish them to appear on.
Step One : Creating the Categories

This is more about knowing how to create and work with Categories in Drupal 7. Conceptually , it is not much different from how taxonomy works in Drupal 6 except for the ability to create fields for taxonomy in D7.

Just as a refresher, we create drupal categories by navigating admin>structure>taxonomy> Add Vocabulary. Simple steps would be to create a vocabulary (ADD VOCABULARY) and give it a name; then ADD TERMS to create the sub-categories. LIST TERMS to view the terms that you have created. Once satisfied with our work we can continue to the next step.

It is always good to think through the products you plan to sell on your website and what categories they will fall into. It is good to think of how visitors to your website would like to see your products classified and how they would like to browse your website. This makes it easier to think about the categories as a whole and how your products fit in. It is good to think through this part as early in the process as you can.


When you create your categories, it is important to set the landing pages for each of these categories (admin/structure/taxonomy/<the name of your category>/add ). This step comes when you are ADDING TERMS to the category you have created. It's called, "URL alias ". When you set the URL alias for the term, you basically specify an alternative URL by which this term can be accessed. Use a relative path and don't add a trailing slash or the URL alias won't work. This is important to setup if you want each category to have it's own landing page. For a product catalog it is a must. It is also very useful for navigating back and forth to the category pages from the product pages.


Step Two :  Creating Menu Links and linking them to the Category landing pages...

This is more of a Drupal 7 stuff than the Druapl Commerce stuff. Steps here would include:
Navigate to the Admin > Structure > Menu (admin/structure/menu) on your Drupal 7 site.
Click on "Add Menu", give it a name and some description for admin usage.
Once there, click on  the "Add Link" on the menu page (admin/structure/menu).
When specifying the link (admin/structure/menu/manage/management/add), one needs to specify only the two things, the name of the menu link and the path to which it should point. Here add the same relative path as the landing page of your category(ies). You will have to repeat this step for each of your categories. Attaching a picture of the menu > Add Link page for easy reference.


Step 3 : Enable the Block for the Menu Links just created.

This is pretty simple really. Every time you create Menu links on your Drupal 7 installation, you will automatically get a Block for it. Only it will not be enabled and which you need to do. For this, you navigate to Admin > Structure > Blocks (admin/structure/block), look for the block for the Menu you just created and enable it for the location you want to place it at. And with this you are ready with the structure of having a Category based Catalog. All you need to do no is to create products and product displays tagging them to the category(ies) you have just created. With that, your products will start appearing on the Category landing pages of the Category they are tagged too...


The other approach to setting up the above structure is to use Taxonomy views.  Here we create a "no results" taxonomy view in the block. We will discuss this approach in the second part of this blog. Do feel free to suggest if there could be a third approach as well. These are the only two I can think of right now. Thanks for reading.

No comments:

Post a Comment