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

Do we need to do any customizations for variant product in hybris 6.6?

mohammed24
Participant
0 Kudos
1,518

Can anyone help me in understanding if variant product information is available out of the box in hybris 6.6 , If not what customization are required to create variant products? Any link from hybris wiki would be helpful?

Accepted Solutions (1)

Accepted Solutions (1)

arvind-kumar_avinash
Active Contributor
0 Kudos

No, you don't need to do any customizations for a variant product in hybris 6.6 as long as you do not need any attributes describing the variant. For this purpose, you can use GenericVariantProduct as shown in the following example from dimension-products.impex of the out-of-the-box electronics store data:

 # Insert Products
 INSERT_UPDATE Product;code[unique=true]; $supercategories; manufacturerName;manufacturerAID;variantType(code);unit(code)[default=pieces];$catalogVersion
 ;1978440_md;576, brand_5, B2C_Color; Sony;DSC-H20;GenericVariantProduct;pieces
                       
 #Updating product information
 INSERT_UPDATE GenericVariantProduct;code[unique=true];$baseProduct;$catalogVersion;ean;$supercategories;$approved                                           
 ;1978440_md_red; 1978440_md;; 4905524593235;B2C_Red; approved  
 ;1978440_md_green; 1978440_md;;4905524593235;B2C_Green; approved  
 ;1978440_md_blue; 1978440_md;; 4905524593235;B2C_Blue; approved

If you need to add new attributes, you will have to extend the VariantProduct itemtype. A good example is the following definition in yacceleratorcore-items.xml:

 <itemtype code="ApparelStyleVariantProduct" extends="VariantProduct"
       autocreate="true" generate="true"
       jaloclass="de.hybris.platform.yacceleratorcore.jalo.ApparelStyleVariantProduct">
 <description>Apparel style variant type that contains additional attribute describing variant style.
 </description>
 <attributes>
     <attribute qualifier="style" type="localized:java.lang.String"
                metatype="VariantAttributeDescriptor">
         <description>Color/Pattern of the product.</description>
         <modifiers/>
         <persistence type="property"/>
     </attribute>
 
     <attribute qualifier="swatchColors" type="SwatchColorSet">
         <description>A normalized color mapping to a standardized front-end navigable name.
         </description>
         <modifiers/>
         <persistence type="property"/>
     </attribute>
 </attributes>

I highly recommend you to go through catalog-items.xml if you are interested to understand more about the data model supporting variant products.

Feel free to post your comment in case there is any further doubt.

mohammed24
Participant
0 Kudos

Thanks!!This is very helpful!!Can you please provide any wiki link to explore more on this?

arvind-kumar_avinash
Active Contributor
0 Kudos

You are most welcome, Mohammed. Please accept the answer and/or upvote it so that others can also refer it confidently in future.

As I have mentioned earlier, please search for the word 'variant' in catalog-items.xml and you will find it very helpful. Additionally, you can go through basecommerce-items.xml to understand GenericVariantProduct.

Answers (1)

Answers (1)

geffchang
Active Contributor
0 Kudos

You can't create an instance of VariantProduct, because it's an abstract class / type. At the minimum, you need to create a concrete subclass of VariantProduct in items.xml. e.g.

 <itemtype code="CustomVariantProduct" extends="VariantProduct"
     autocreate="true" generate="true"
     jaloclass="com.company.CustomVariantProduct">
     <description>Custom Variant Product type</description>
 </itemtype>