Dynamic attributes

Semarchy xDM allows you to model dynamic attributes used in retail.

The goal is to associate attributes to a product while creating this one according to its subfamily.

step by step guide

The following instructions are based on our current Intelligent Data Hub model, specifically the product domain.

  1. Creating 4 entities ( ProductAttribute, AttributeValue, AttributeSubFamily, Attribute) with their relationships, as the model below, are necessary.

 

  • Attribute : All attributes created for product subfamilies.

 

  • AttributeValue: For constrained attributes, values are stored in this table.

 

  • AttributeSubFamily: Associate the attributes to the subfamilies products

 

  • ProductAttribute: Associate the attributes to the products.

 

 

2. Adding your attributes needed for the products

3. For the constrained attributes, add the values

4. Associate the attributes to their subfamilies

 

5. To associate the attributes to the product being created, first you need to declare a PL/pgSQL procedure.

The steps 5 and 6 are optional. It allows to automatically retrieve the attributes according to the product subfamily. However, it is also possible to add the attributes manually.

PL/pgSQL function to associate the attributes to the product by subfamily.

CREATE OR REPLACE FUNCTION usr_create_productattributes(p_loadid numeric) RETURNS void LANGUAGE plpgsql AS $function$ begin insert into sa_product_attribute (b_loadid, b_classname, b_creator, b_credate, product_attribute_id, f_product, f_attribute) select sp.b_loadid, 'ProductAttribute', sp.b_creator, sp.b_credate, nextval('seq_product_attribute'), sp.id, gsf.f_attribute from sa_product sp inner join gd_attribute_sub_family gsf on sp.f_sub_family = gsf.f_sub_family where b_loadid = p_loadid and not exists ( select 1 from sa_product_attribute sa where sa.f_product = sp.id and sa.f_attribute = gsf.f_attribute); end; $function$;

6. Next, set the step triggers with the created PL/SQL on the product’s stepper:

7. You can see the attributes associated to the product as below and set the value :

 

 

 

 

8. Additional attributes can be shown on the product card