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 to Wool

  • If the result of the test is true, then assign the item to the category Winter in the catalog KidsWear.

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

[Item].[Properties].[Size] == "XS" 
AND [Item].[Properties].[Material] == "Wool"

Return Value

Catalog[KidsWear].Category[Winter]

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

You can create rules that can fetch values from variables and expressions, and assign items to catalog categories using the syncCatalogCategory( ) function. Rules derive catalog and category codes from attributes dynamically and assign items to catalog categories. You can pass attributes or functions that get values from custom objects or services as arguments of the syncCatalogCategory function.
Note: You can use the syncCatalogCategory( ) function only in the Return Value of the category assignment rule.
Use the following syntax for including expressions in the syncCatalogCategory() function:
SyncCatalogCategory(Expression1, Expression2, Previous())
where:
  • Expression1 - Returns catalog code
  • Expression2 - Returns category code
  • Previous() – Returns the previous category assignment row that must be updated
You can specify the expressions in the following ways as the return value of a category assignment rule:
  • SyncCatalogCategory(Expression1): Creates a new catalog category assignment by assigning the item to the default category of the catalog returned by Expression1.
  • SyncCatalogCategory(Expression1, Expression2): Creates a new category assignment by assigning the item to the catalog and category returned by Expression1 and Expression2, respectively.
  • SyncCatalogCategory(Expression1, Expression2, Previous()): Re-assigns the category assignment row from Previous to Expression2. If the expression for Previous() evaluates to null, then it creates a new category assignment row.
Note:
  • Catalog assignment rules won’t delete existing catalog assignments.
  • Single row and multi row attributes are also supported
Examples:
  • 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 the Previous() 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 catalog LadiesWear

  • 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 catalog Kids

Field

Value

Name

Catalog assignment validation

Description

Validate catalog assignments

Severity

Reject

If Expression

assignedtoCatalog(Catalog[LadiesWear].Category[Summer])

Validation Expression

!assignedtoCatalog(Catalog[Kids].Category[Summer])

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.