Create Comestri Dynamic Product Rule – Remove 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 #4 Create Comestri Dynamic Product Rule – Add Category

Articles

Liquid Template

Video Summary

This video shows you how to create a Dynamic Product Rule in Comestri that will remove multiple Categories from 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 remove multiple Categories from products automatically. 

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

This Dynamic Product Rule will remove Men’s and Women’s sale Categories from products automatically when their sale price is deleted. The Product Rule will do this by checking whether the sale price has been deleted (i.e. is ‘null’). 

 Sometimes users reduce a sale price to zero in the mistaken belief that this deletes the sale price. To handle this error, the example Product Rule will also check whether the sale price on the product ‘is less than or equal to zero’. 

Before creating the example Product Rule, you’ll be shown a selection of Men’s and Women’s shoes with sale prices and the Categories they are currently assigned to. 

 You’ll then be shown that the Sale Categories for each shoe product are removed by the Rule when the product’s sale price is deleted. 

This Product Rule will be triggered automatically when the sale price of a product is deleted (either manually via the Comestri UI, via CSV upload or by integration) or the sale price becomes inactive (i.e. falls outside an assigned ‘from’ and ‘to’ date). 

 In this example, we’ll be deleting the sale price manually via the Comestri UI, then creating the Product Rule and triggering it. 

In most cases, you would create the Product Rule first. Then later, when the sale price is deleted, the Product Rule will be triggered automatically. 

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 removed from 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. 

Categories ‘Sample Apparel Shoes: Mens > Dress Shoes’, ‘Sample Apparel Shoes: Mens > Sale’ and … 

Sample Apparel Shoes: Mens > Sale > Dress Shoes’ are 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 > Heels’, ‘Sample Apparel Shoes: Womens > Sale’ and … 

‘Sample Apparel Shoes: Womens > Sale > Heels’ are assigned. 

Next, you’ll see the various prices currently assigned to the 2 products and then you’ll delete their sale prices. 

Return to the Manage Products page. 

Then click the Product Code ‘edward-dress-shoes-brown’. 

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

Click the Prices tab to see the current prices listed for the product. 

To delete the AU Sale price manually, click the ellipsis on the right and select ‘Delete’. 

A dialog box opens asking if you are sure you want to delete the price. Click OK. 

You can now see that the AU Sale price has been deleted. Price changes are saved automatically. 

Return to the Manage Products page, click the Product Code ‘lecinda-glitter-heels-silver’. 

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

Click the Prices tab to see the current prices listed for the product. 

To delete the AU Sale price manually, click the ellipsis on the right and select ‘Delete’. 

A dialog box opens asking if you are sure you want to delete the price. Click OK. 

You can now see that the AU Sale price has been deleted. Price changes are saved automatically. 

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

Here you can see 5 existing Product Rules. 

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

This Rule will remove from your shoes, which have a sale price, sale Categories that correspond to the shoes’ gender & 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 Remove Sale Categories from 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 ‘Remove’, since you’re removing Categories from 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 Classes, select the Product Classes this Rule will be run against. You must select the Class that the Categories will be removed from. 

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, the IF conditions will be joined together by an ANY (OR) operator, as you’re checking for products that satisfy either of the conditions. 

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 whether the ‘AU Sale Price’ of the product is ‘null’, i.e. the product doesn’t have a Sale Price. 

Or, whether the ‘AU Sale Price’ of the product is ‘less than or equal to’ 0 (zero). 

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 null’. 

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

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

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

Then, from the operator drop-down list, select ‘is less than or equal to’. 

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

For the THEN result, you’ll add an extra IF statement with 2 conditions. 

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

Start by clicking ‘+’ symbol and selecting ‘If statement’. Then click ‘+’ symbol to add a condition to the If statement. 

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 removed from 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. 

Lastly, click ‘+’ symbol and add a final ‘Result’. For this ‘Result’ you will not select a value either. This closes the Product Rule. 

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. 

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 removed from the 2 products as a result of running your Product Rule. 

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

To see that the Sale Categories have been removed from 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 removed. 

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 removed. 

This completes the example of creating a Dynamic Product Rule to remove multiple sale Categories from 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.