cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How do we define item relationships in raw, canonical and target extension files

0 Likes
340

How do we define item relationships in raw, canonical and target extension files.

For example I have product to product recipe relationship and I have defined it as follows:

in raw-extension.xml:

 <item>
     <type>VariantProduct</type>
     <description>Raw representation of variant product</description>
     <attributes>
         <attribute>
             <name>PRODUCT_RECIPE</name>
         </attribute>
     </attributes>
 </item>
 <item>
     <type>ProductRecipe</type>
     <description>Raw representation of Product recipe</description>
     <attributes>
         <attribute>
             <name>RECIPE_CODE</name>
         </attribute>
     </attributes>
 </item>


     <item>
         <type>CanonicalVariantProduct</type>
                     <attributes>
                             <attribute>
                 <name>PRODUCT_RECIPE</name>
                 <transformations>
                     <transformation>
                         <rawSource>VariantProduct</rawSource>
                         <expression>PRODUCT_RECIPE</expression>
                     </transformation>
                 </transformations>
             </attribute>
                     </attributes>
              </item>


in canonical-extension.xml:

 <item>
     <type>CanonicalVariantProduct</type>
     <description>Canonical representation of product</description>
     <status>ACTIVE</status>
     <attributes>
         <attribute>
             <name>PRODUCT_CODE</name>
             <model>
                 <localizable>false</localizable>
                 <collection>false</collection>
                 <type>String</type>
                 <primaryKey>true</primaryKey>
             </model>
         </attribute>
         <attribute>
             <name>PRODUCT_RECIPE</name>
             <model>
                 <localizable>false</localizable>
                 <collection>false</collection>
                 <type>CanonicalProductRecipe</type>
                 <primaryKey>false</primaryKey>
             </model>
         </attribute>
     </attributes>
 </item>
 <item>
     <type>CanonicalProductRecipe</type>
     <description>Canonical representation of Product recipe</description>
     <status>ACTIVE</status>
     <attributes>
         <attribute>
             <name>RECIPE_CODE</name>
             <model>
                 <localizable>false</localizable>
                 <collection>false</collection>
                 <type>String</type>
                 <primaryKey>true</primaryKey>
             </model>
         </attribute>
     </attributes>
 </item>


in target-extension.xml:

 <item>
     <type>VariantProduct</type>
     <exportCode>VariantProduct</exportCode>
     <description>Hybris Platform representation of variant product</description>
     <updatable>true</updatable>
     <canonicalItemSource>CanonicalVariantProduct</canonicalItemSource>
     <status>ACTIVE</status>
     <attributes>
         <attribute>
             <name>PRODUCT_CODE</name>
             <localizable>false</localizable>
             <collection>false</collection>
             <transformationExpression>PRODUCT_CODE</transformationExpression>
             <exportCode>code[unique=true]</exportCode>
         </attribute>
         <attribute>
             <name>PRODUCT_RECIPE</name>
             <localizable>false</localizable>
             <collection>false</collection>
             <transformationExpression>PRODUCT_RECIPE</transformationExpression>
             <exportCode>productRecipe</exportCode>
             <mandatoryInHeader>false</mandatoryInHeader>
         </attribute>
     </attributes>
 </item>
 <item>
     <type>productRecipe</type>
     <exportCode>ProductRecipe</exportCode>
     <description>Hybris Platform representation of product recipe</description>
     <updatable>true</updatable>
     <canonicalItemSource>CanonicalProductRecipe</canonicalItemSource>
     <status>ACTIVE</status>
     <attributes> 
         <attribute>
             <name>RECIPE_CODE</name>
             <localizable>false</localizable>
             <collection>false</collection>
             <transformationExpression>RECIPE_CODE</transformationExpression>
             <exportCode>recipeCode[unique=true]</exportCode>
             <mandatoryInHeader>false</mandatoryInHeader>
         </attribute>
     </attributes>
 </item>


above code is not complete, I have just pasted required code.

Can someone help me understand whats wrong with my code.

I am getting following error when I publish it into hybris commerce 6.8:

pk has wrong format

Accepted Solutions (0)

Answers (1)

Answers (1)

Slava
Product and Topic Expert
Product and Topic Expert
0 Likes

Kaushik,

nothing is obviously wrong with the models you pasted. Would you mind pasting the stack trace, if there one, or exact error message as received from the ECP, if you received an error response from ECP for an item.

It's possible the problem is not in the model but in the data you're publishing. For example, make sure the attributes marked as primaryKey contain values. Null is not acceptable for primary keys.