Rune Grønkjærs Blog
Abonnér på mit feed

Tea Commerce Master product

This blog post will explain how Master products works in Tea Commerce.

What is a Master Product in Tea Commerce?

First and foremost you must understand that Tea Commerce products are just ordinary content nodes in Umbraco. The nodes have a number of custom properties which is the content of the node. Umbraco structures the nodes in xml which makes it possible for nodes to inherit properties from nodes further up the tree.

Product variants

For product nodes, this means that you can make product variants to a product node. This is used in the Tea Commerce Starter Kit, where some products have variants.

As you can see in Figure 1 below there is a red and a blue variant under “Product A1″. It allows you to leave the main product contain the bulk of product information, so the variants just need information about stock condition, product name and possibly other properties that differ on the variants from the main product. The arrow indicates how variants inherit from their main product.

Fig. 1 – Variants in Tea Commerce

Variants in Tea Commerce

Tea Commerce Master Product

With a Tea Commerce Master product we move on and makes a product inherit from a product that is placed somewhere else in the content tree. This type of setup we use in the Tea Commerce Multilanguage Kit.

Figure 2 shows how the inheritance would be if the red variant had a master product attached. In figure 3 you can see how it is done without variants.

Fig. 2 – Master product and variants in Tea Commerce

Master product and variants in Tea Commerce

Fig. 3 – Master product without variants in Tea Commerce

Master product without variants in Tea Commerce

How to setup Tea Commerce Master products

To get your products to use a Master product, you must set up a couple of things in Tea Commerce and Umbraco. To see an example of how it looks when Master products are set up correctly, try to install the Tea Commerce Multilanguage Kit which uses the Master products.

1. The product Document Type

The products must have a Master product property for selecting an Umbraco node. This property we can call “Master Product” and give it the alias “masterProduct.” Its type must be something that can give us the ID of the product master node. The type may well be a plain text field, but a Content Picker or a UComponents Multi Node tree picker would be preferable for the user. The latter is especially good because it can restrict user options.

2. Set up the Tea Commerce section

Now you go to “General Settings” in the Tea Commerce section. Here you write the alias of the property we just created in the field “Master product property alias”. Now Tea Commerce knows what to look for, to find the products Master product.

3. Choose a Master product on one of your products

Now you create a master product and then create a product that is pointing down at the Master product with its “masterProduct” property.

4. Print product info on your product page

Now we just need to write the information of the product on the website’s product page. To retrieve a property from the product the Tea Commerce xslt library have a method called GetProperty that gets the job done for you. GetProperty takes two parameters, the first being the product node itself and the other is the alias of the property you wish to fetch.

How Tea Commerce Master products works

To date Tea Commerce have three scenarios in which Master products are used. One is the before mentioned GetProperty method. The second is another library method called GetStock, which is used to retrieve the stock level for a product. The third scenaro, in which Master products are used, is when a product is added to the cart and Tea Commerce is adding product information to the new order line.

Common to all three is the way Tea Commerce will attempt to retrieve information from the product. Based on the setup in Figure 2 we can explain it this way:
  1. We query after e.g. the property “productPrice” on the product “Red”, with the library method GetProperty.
  2. Tea Commerce will first query the node “Red” itself. If it has a property called “productPrice” and the property is not blank the search stops right here.
  3. If nothing was found the search is continued up through the node tree starting at the node “Red”. Now it will then search through, the node “Product A1″ but also “Category A”, “Products”, etc. The search is done by xpathing the Umbraco cached XML, so performance is kept high.
  4. If Tea Commerce still have not found anything it will find “Red”‘s Master product and based on this will do the same search up through the tree, hopefully finding what it was asked.

What is the use of Tea Commerce Master products?

Language localization of Tea Commerce products

The whole idea with Master products in Tea Commerce, has always been to make it easy to language localize your products. The idea in this situation is to let the Master products contain all the information about the product that is not language specific. That way you will not have to enter this information again and again, in all languages, which could cause big problems with keeping data consistent. At the individual product focus can lie on typing texts in the language you are working on. You may read more about this in this blog post about languages, countries and currencies .

One product in multiple categories

You can also use Master products to position the same product in several categories. You will be able to create all products outside the regular content tree and then create lightweight products that just link down to a master product. The lightweight products does not hold any product information and Tea Commerce will then retrieve all information from their master product.

A concrete example

In the example below, I will get a product name, stock and price from a product. The example uses variants like in Figure 2 and to be sure that I get a variant to start with, I choose the variant that I know is a leaf node. A leaf node is one of the outer nodes of the tree. If I’m already on one of the variants this variant is chosen. If I’m on the main product, the first variant will be selected. If there is no variants, the main product get elected.

Example of the use of Master products


  
  

  
  

  
  

  
  

Tea Commerce links

This post was written in e-commerce, Languages, Tea Commerce, Umbraco, xslt. Ad permalink to favorites. Follow all comments with RSS feed for this posts. Drop a comment or a trackback: Trackback URL. | Læs denne side på dansk dansk version

Drop a comment

Your email is never published nor shared. Required fields are marked *

*
*

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Dansk version