HCG Web Services Documentation
7 September 2011 • Version 1.0

hcgProducts Documentation

The hcgProduct module simplifies the task of syncronizing the product data on a branded site with the central products database, accessed through the API.

What it does

In some ways, the module is fairly basic. When it is installed, it creates a new content type called "hcgproducts" that uses CCK fields. The content type contains all the fields that are supplied by the API, so all the info will be there. Once installed, you can import data via the API by simply pressing the import button. Product categories are placed into a taxonomy vocabulary and linked to the products as they are imported.

Adminstrating the module

Go to http://example.com/admin/settings/hcgproducts to access the admin settings. You may also want to look at the permissions page; there are permissions there, but I don't think you will need to change anything.

Updating product data

The button at the bottom of the admin page launches the process for importing the product data from the API. That can take a little while depending on how responsive the API is, but it shouldn't take more than 30 seconds or so at most.

When the data import happens, the module creates or updates a taxonomy vocabulary called HCG Product Categories and populates it with the categories from the API, then brings in all the products associated with a category and populates the hcgproducts content type with nodes. And that’s it.

I built the module with a few things in mind: first, I used CCK fields so we have more flexibility with other modules like Views and ImageCache. I added Image fields to the content type, so you should be able to go in and upload images where you need them, and those fields will not be overwritten when you update the data from the API. You should be able to add any fields you need to the hcgproducts content type using CCK. I have not tested that, but I don't see any reason why you couldn't. Those fields should not be touched by API updates either. I made sure that updates to the vocabulary and content type are real updates and should not affect anything you have linked to them. For example, I do not delete the vocabulary and rebuild it so if you use taxonomy images to add category images, they will still be intact after an update; categories and products are only deleted if they are deleted from the source database that supplies the API.

Templates

I have a default node template set up for the content type (node-hcgproducts.tpl.php) and you can override that to create your detail pages. I have just about all the fields displaying in that, so it should be clear how to access the content in your (much better) template.