Create Comestri Dynamic Product Rule – Add Categories

Related Videos/Articles

Videos

Product Rules #1 Introduction to Comestri Product Rules

Product Rules #2 Create Comestri Static Product Rule – Add Category

Product Rules #3 Create Comestri Static Product Rule – Remove Category

Product Rules #5 Create Comestri Dynamic Product Rule – Remove Category

Articles

Liquid Template

Video Summary

This video shows you how to create a Dynamic Product Rule in Comestri that will add (i.e. assign) multiple Categories to products automatically. 

Video Transcript

In this video, you’ll be taken through creation of a Dynamic Product Rule in Comestri. 

You’ll see how a Dynamic Product Rule allows you to add multiple Categories to products automatically. 

You’ll also see how Dynamic Product Rules utilise the Liquid template language to generate Category paths. 

Before creating a Product Rule that assigns Categories to products, you’ll need to ensure that:

  • The Categories you are assigning to products have already been created in the Comestri PIM
  • The Attributes used in the Rule’s conditional logic statements have also been created in the Comestri PIM

The Dynamic Product Rule in this example will add Men’s and Women’s shoes, which have a sale price and shoe type, to sale Categories that correspond to the shoes’ gender and shoe type.

Before creating the example Product Rule, you’ll be shown the shoes that will be affected by the Rule, and the Categories they are currently assigned to. 

Welcome to Comestri. To begin, we will sign in to the Comestri application. 

Click Products on the main menu. Then click Manage Products on the expanded menu. 

The Manage Products page opens. 

Here you can see a selection of products. 

The 2 products you’ll use for this Product Rule example are: ‘Edward Dress Shoes Brown’ and ‘Lecinda Glitter Heels Silver’. 

Next, you’ll see the Categories currently assigned to these 2 products before you create the Product Rule. 

These 2 products will have sale Categories assigned to them when the Product Rule is run. 

To see the currently assigned Category for the dress shoes, click the Product Code ‘edward-dress-shoes-brown’. 

The Edit Product page opens showing the General tab for the product. 

Click the Categories tab. 

You’ll see the Category ‘Sample Apparel Shoes: Mens > Dress Shoes’ has been assigned to this product. 

Return to the Manage Products page to check the Categories for your second product. 

Click the Product Code ‘lecinda-glitter-heels-silver’. 

The Edit Product page opens showing the General tab for the product. 

Click the Categories tab. 

You’ll see the Category ‘Sample Apparel Shoes: Womens > Heels’ has been assigned to this product. 

Next, you’ll create the Product Rule. Click Product Rules on the expanded menu. The Product Rules page opens. 

Here you can see 4 existing Product Rules. 

To create your Product Rule, click the New Product Rule button. The New Product Rule dialog box opens. 

This Rule will add to your shoes, which have a sale price, sale Categories that correspond to the shoes’ gender and shoe type. 

To start creating your Rule, select ‘Category assignment’ as the Rule type. 

Next, enter a unique Code to represent this Product Rule. Here you’ll enter ‘Dynamic Assign Sale Categories to Products’. 

Next, enter a descriptive Name for your Product Rule. Here, you’ll enter the same details as the Code. 

In the Option field, you can select to either Add or Remove a Category assignment. 

Here, you’ll select ‘Add’, since you’re adding Categories to each of the products. 

Next, choose a Status for your Product Rule. An Active Rule will run automatically when a product is created or updated. 

An Inactive Rule will not run automatically, but the Rule can still be triggered manually. 

Here, you’ll select ‘Active’. 

Result type can either be Static or Dynamic. You’re creating a Dynamic Product Rule, so select ‘Dynamic’ from the drop-down list. 

For this Rule, leave the ‘Set Primary Category’ checkbox unselected. 

For Classes, select the Product Classes this Rule will be run against. You must select the Class level that Categories are assigned to. 

Here, you’ll select the ‘Colourway_’ Class. 

To create a Rule, click the ‘+’ symbol and select ‘If statement’, as the logic in the Rule is built using IF-THEN-ELSE statements. 

Each IF statement can have multiple conditions which are joined together by an ALL (AND) or ANY (OR) operator. Here, select ALL. 

You can check if the conditions are TRUE or FALSE. Here, you’ll select TRUE. 

Click the ‘+’ symbol to add the first IF condition. 

In this first condition, you’ll check that the ‘AU Sale Price’ of the product is greater than zero, i.e. the product has a Sale Price. 

Select ‘self’ as context to apply this condition to the ‘Colourway_’ Product Class. 

This means the condition will check against values stored on the ‘Colourway_’ Product Class level of the product. 

Next, from the product information drop-down list, select ‘AU Sale Price’.

Then, from the operator drop-down list, select ‘is greater than’. 

Next, enter ‘0’ (zero) as the value. 

Add another IF condition to check that the Attribute ‘Shoe Type’ of the product is not null, i.e. the product has a Shoe Type. 

Select ‘ancestor1’ as context to apply this condition to the ‘Style_’ Product Class, which is the ancestor of the ‘Colourway_’ Class. 

This means the condition will check against values stored on the ‘Style_’ Product Class level of the product. 

Next, from the product information drop-down list, select ‘Shoe Type’. 

Then, from the operator drop-down list, select ‘is not null’.  

Next, add another IF condition to check that the Attribute ‘Gender’ of the product is not null, i.e. the product has a Gender. 

Select ‘ancestor1’ as context to apply this condition to the ‘Style_’ Product Class, which is where the condition will check against a value. 

Next, from the product information drop-down list, select ‘Gender’. 

Then, from the operator drop-down list, select ‘is not null’. 

For the THEN result, you’ll add a ‘Result’ to assign Category paths to the products. You’ll use Liquid to generate the Category paths. 

N.B. For more details on Liquid template, see link to article above. 

Start by clicking ‘+’ symbol and selecting ‘Result’. 

You’ll then enter the Liquid code to define the Category paths that will be assigned to your shoes. 

The Liquid will define 2 Category paths. The first Category path will contain 2 Categories and the second will contain 3 Categories. 

Category paths are generated in the form ‘Category Set: Category1 > Category2’. A comma ‘,’ is used to separate Category paths. 

For the first Category path, start by entering the Category Set followed by a colon ‘:’. For this example enter ‘Sample Apparel Shoes:’ 

Then, add Liquid to generate the first Category using the ‘Gender’ Attribute from the Ancestor1 product level by entering ‘{{ancestor1.gender}}’. 

Finish the first Category path by entering a greater than sign ‘>’ as a Category separator, and then entering the ‘Sale’ Category. 

To assign a second Category path to the products, add a comma ‘,’ to the end of the first Category path. 

Then, start the second Category path by entering the Category Set ‘Sample Apparel Shoes:’. 

Next, add Liquid to generate the first Category using the ‘Gender’ Attribute from the Ancestor1 product level by entering ‘{{ancestor1.gender}}’. 

Then add the second Category, ‘Sale’, placing a greater than sign ‘>’ before and after ‘Sale’ to separate the Categories in the Category path. 

Lastly, generate the final Category using the ‘Shoe Type’ Attribute from the Ancestor1 level by entering ‘{{ancestor1.shoe_type}}’. 

For the ELSE result, click ‘+’ symbol and add an extra ‘Result’. For this ‘Result’ you will not select a value. This closes the IF statement. 

Click Save. 

The Product Rule is now listed on the Product Rules page. 

Next, click the ‘Validate All Rules’ button to validate the Product Rule you have just created. 

A slide-in message appears confirming the Product Rule Validation job is running. 

Click Scheduled Jobs in the main menu to check the validation result. 

The Scheduled Jobs page opens. Your Product Rule Validation job appears at the top of the list. 

The Scheduled Jobs page opens. Your Product Rule Validation job appears at the top of the list. 

You’ll see the job Status is ‘Completed’ and the Result is ‘Success’ with zero Errors. This means your Product Rule will run. 

You’ll see the job Status is ‘Completed’ and the Result is ‘Success’ with zero Errors. This means your Product Rule will run. 

Next, you’ll run your Product Rule. Click Product Rules in the main menu to return to the Product Rules page. 

Click the checkbox next to your Product Rule  and click the ‘Run Selected Rules’ button. 

A dialog box opens warning you that running multiple Product Rules against all products may take several hours. 

To continue running your Product Rule, click OK. 

A slide-in message appears confirming your Product Rule is running in the background. 

Click Scheduled Jobs in the main menu to check your Product Rule has run successfully. 

The Scheduled Jobs page opens. Your Run Product Rules job appears at the top of the list. 

You’ll see the job Status is ‘Completed’ and the Result is ‘Success’ with zero Errors. This means your Product Rule ran without errors. 

Next, to check that your Product Rule generated the expected result, click Manage Products under Products in the main menu. 

The Manage Products page opens. 

Here you can see a selection of products. 

Next, you’ll check that Sale Categories have been assigned to the 2 products as a result of running your Product Rule. 

The 2 products you’ll check for newly assigned Sale Categories are: ‘Edward Dress Shoes Brown’ and ‘Lecinda Glitter Heels Silver’. 

To see the newly assigned Categories for the shoes, click the Product Code ‘edward-dress-shoes-brown’. 

The Edit Product page opens showing the General tab for the product. 

Click the Categories tab. 

Categories ‘Sample Apparel Shoes: Mens > Sale’ and Sample Apparel Shoes: Mens > Sale > Dress Shoes’ have now been assigned. 

Return to the Manage Products page to check the Categories for your second product. 

Click the Product Code ‘lecinda-glitter-heels-silver’. 

The Edit Product page opens showing the General tab for the product. 

Click the Categories tab. 

Categories ‘Sample Apparel Shoes: Womens > Sale’ and ‘Sample Apparel Shoes > Womens > Sale > Heels’ have now been assigned. 

This completes the example of creating a Dynamic Product Rule to add sale Categories to products. 

What you’ve just seen is an advanced Product Rule example. 

Product Rules, however, are a very flexible tool that enable you to automate even more complex ways of adding and removing Categories.  

For example, if you have multiple Product Class Structures, you can select a Product Class from each Structure for a Rule to be run against.