Assign Catalogs and Categories Using Item Rules
You can define rules that assign items to catalogs and their categories, and rules that validate those assignments.
Catalog and Category Assignment Rules
You can define assignment rules that automatically assign items to one or more catalogs and categories when a condition is satisfied. The condition can be based on attribute values, organization assignments, or other catalog assignments.
The following table summarizes an example of an item rule that:
-
Is defined in a rule set that's associated with an item class for items that represent garments.
-
Tests whether an item has an attribute Size equal to
XS
and an attribute Material equal toWool
-
If the result of the test is true, then assign the item to the category
Winter
in the catalogKidsWear
.
Field |
Value |
---|---|
Name |
Catalog assignment |
Description |
Auto assignment of item to catalog/category based on given attributes. |
Return type |
Catalog category |
Primary If Expression |
True |
Secondary If Expression |
|
Return Value |
|
User Message |
XS, Wool item is assigned to Winter Category under KidsWear Catalog. |
Catalog and Category Reassignment Using Rules
Item rules can reassign items to different categories, depending on the scenario.
-
If a catalog allows multiple item category assignments, then a reassignment rule creates a new item assignment to a category, even if the item is already assigned to a different category.
If a catalog doesn't allow multiple item category assignments, then the reassignment rule:
-
Changes the existing category assignment for the item, if an assignment exists
-
Creates a new category assignment for the item, if an assignment doesn't exist
-
Example: a rule assigns item A100 to an existing Category Y in Catalog A, where A100 is currently assigned to Category X. Catalog A doesn't allow multiple item category assignments. The result is:
-
Item A100 is reassigned to from Category X to Category Y.
-
If Catalog A had allowed multiple item category assignments, then item A100 would have been newly assigned to Category Y and would have also remained assigned to Category X.
-
-
Assign Catalog Categories Using Variables and Expressions as Return Value
SyncCatalogCategory(Expression1, Expression2, Previous())
where:Expression1
- Returns catalog codeExpression2
- Returns category codePrevious()
– Returns the previous category assignment row that must be updated
-
SyncCatalogCategory(Expression1)
: Creates a new catalog category assignment by assigning the item to the default category of the catalog returned byExpression1
. SyncCatalogCategory(Expression1, Expression2)
: Creates a new category assignment by assigning the item to the catalog and category returned byExpression1
andExpression2
, respectively.SyncCatalogCategory(Expression1, Expression2, Previous())
: Re-assigns the category assignment row fromPrevious
toExpression2
. If the expression forPrevious()
evaluates to null, then it creates a new category assignment row.
- Catalog assignment rules won’t delete existing catalog assignments.
- Single row and multi row attributes are also supported
- Example 1: Item is assigned a catalog whose code is derived from A1 and category
whose code is derived from A2. This is a new catalog category
assignment.
SyncCatalogCategory([ITEM].[AG1].[A1], [ITEM].[AG1].[A2])
- Example 2: Use concatenation:
SyncCatalogCategory([ITEM].[AG1].[A1], [ITEM].[AG1].[B1]+"_"+[ITEM].[AG1].[B2])
- Example 3: Use other
functions:
SyncCatalogCategory(getCustomObjectValue("Catalog_obj", "CatalogCode", "Target_Market", [Item].[Market_Spec].[TM]), InvokeWebservice("Cat_API", [Item].[AG].[C]))
SyncCatalogCategory(InvokeRestGet("CAT_REST", toMap("q", "ItemNumber=AS544"), "CATS[0].CLG_CODE", ) , subString( [Item].[AG].[C], 2, 4) )
- Example 4: Update an existing category assignment. The category code returned by
the
Previous()
function is used to identify the existing category assignments that must be updated. If the value returned by thePrevious()
function is Null, then the rule creates a new category assignment.SyncCatalogCategory([ITEM].[Catalog_Details].[Catalog_Code] , [ITEM].[Catalog_Details].[Category_Code], Previous([ITEM].[Catalog_Details].[Category_Code]))
Catalog and Category Validation Rules
You can define validation rules that validate catalog or category assignments based on attribute values, or on an assignment to other catalogs or an organization assignment.
The following table summarizes an example of an item rule that:
-
Is defined in a rule set that's associated with an item class for items that represent garments.
-
Tests whether an item is assigned to the category
Summer
in the catalogLadiesWear
-
If the result of the test is true, and the item is in the specified category then validate that the item isn't also assigned to the category
Summer
in the catalogKids
Field |
Value |
---|---|
Name |
Catalog assignment validation |
Description |
Validate catalog assignments |
Severity |
Reject |
If Expression |
|
Validation Expression |
|
User Message |
Ladies wear products can't be assigned to Kids wear catalog. |
When you create a validation rule to verify a catalog category assignment, you can use variables and expressions for the category argument in the assignedToCatalog( ) function. Using these expressions, the rule derives category codes and validates whether the item is assigned to the category. You can also pass attributes or functions that get values from custom objects or services as category arguments in the function.
For example, assignedToCatalog(Catalog[Channel_Auto], [Item].[Category_Info].[Cat_Code]). This function derives the category code from an attribute dynamically and performs validation.
You can use string functions like Substring, Decode, and so on that can return category codes in the function. You must provide the catalog code in the catalog argument of the function. You can’t use variables for the catalog argument.