Can any one share how to create impex for creating base products,variant products and mapping/remaltion between base product and variant product(Style and Size Variant) in Hybris ? Also how to create impex for creating Product Variant Types?
-
Have you checked OOTB product related impexes in either `electronicsstore` or `apparelstore` extension ? – Free-Minded Mar 23 '17 at 08:28
1 Answers
In the accelerators you have example.
Take a look at apparelstore extension, it contains all sample data as impex in resources/apparelstore/import/sampledata
.
Open the file in sampledata/productCatalogs/apparelProductCatalogs/products.impex
You'll find example of creating product take a look at the block starting by INSERT_UPDATE ApparelProduct
Then you have the variant in the black starting by INSERT_UPDATE ApparelStyleVariantProduct
The link between the variant and the base product is done in the variant block. In the header you will see $baseProduct
. it's a macro defined at the top of the file $baseProduct=baseProduct(code, catalogVersion(catalog(id[default='$productCatalog']),version[default='Staged']))
(note : it uses other macros)
The new types are not defined in the impex, it's done in *items.xml files. You can see how the apparel product and variant models are defined in the yaccelerator project in yacceleratorcore/resources/yacceleratorcore-items.xml
.
Search for <itemtype code="ApparelProduct" .../>
, <itemtype code="ApparelStyleVariantProduct" .../>
and <itemtype code="ApparelSizeVariantProduct" .../>
.
Note that you can split the definition of a type between multiple files so you might found some attributes defined in one projects and some in an other project.
Please read :

- 19,951
- 10
- 65
- 112
-
in apparelstore they have created new Item Type ApparelProduct by extending product. What if i want to use directly Product Similarly for variants, in apparelstore they have created new Item Type ApparelStyleVariantProduct & ApparelSizeVariantProduct by extending VariantProduct. Is it madatory to create new Item Type by extending VariantProduct. What if i want to use existing VariantProduct Type. In hmc we have option to create product variant types. Can we create it using impex or it need be created as Item Type Only ? – user18181818 Mar 23 '17 at 10:21
-
No it's not mandatory you can directly add attribute to the existing product and variantproduct model if you want. In the hMC you can create dynamic type yes, but it's the equivalent of what is done by items.xml not impex. Impex are only used to import and export data. – alain.janinm Mar 23 '17 at 10:24
-
Is dis Ryt? #ProuctVariantTypes#created from HMC insert_update VariantType;code[unique=true] ;NikeSizeVariant #Base Product insert_update Product;code[unique=true];catalogVersion(catalog(id),version)[unique=true];approvalStatus(code);supercategories(code);variantType(code) ;X_MENS_SHIRT;NikeProductCatalog:Staged;check;NikeMenApparel;NikeSizeVariant #Product Variants insert_update Product;code[unique=true];catalogVersion(catalog(id),version)[unique=true];approvalStatus(code);baseProduct(code);variantType(code) ;X_MENS_SHIRT_40;NikeProductCatalog:Staged;check;X_MENS_SHIRT;NikeSizeVariant – user18181818 Mar 23 '17 at 10:37
-
Yes but you use a runtime type which is discouraged by hybris. It's mentionned in "The type system". I don't see ay specific attributes in this impex. Just use regular Product and VariantProduct if you do not need any custom fields. If you need custom attributes then create your NikeSizeVariant in items.xml not using a runtime type. – alain.janinm Mar 23 '17 at 11:07
-
Note that you can extends the existing Product and VariantProduct if you want, as I said before. It's not mandatory to have a new object. That mainly depends of what you need for your business. – alain.janinm Mar 23 '17 at 11:08
-
insert_update VariantProduct;code[unique=true];catalogVersion(catalog(id),version)[unique=true,allownull=true];approvalStatus(code);baseProduct(code);variantType(code) ;X_MENS_SHIRT_40;NikeProductCatalog:Staged;check;X_MENS_SHIRT;NikeSizeVariant This Impex gives error saying Please specify the subtype of the item you want to create at the first column of the value line or change the configured type. – user18181818 Mar 23 '17 at 11:15
-
I've seen an error sorry, the last part should be the variant : ` #Product Variants insert_update NikeSizeVariant;code[unique=true];catalogVersion(catalog(id),version)[unique=true];approvalStatus(code);baseProduct(code); ;X_MENS_SHIRT_40;NikeProductCatalog:Staged;check;X_MENS_SHIRT;` – alain.janinm Mar 23 '17 at 11:17
-
Just do that ` #Base Product insert_update Product;code[unique=true];catalogVersion(catalog(id),version)[unique=true];approvalStatus(code);supercategories(code);variantType(code) ;X_MENS_SHIRT;NikeProductCatalog:Staged;check;NikeMenApparel;VariantProduct insert_update VariantProduct;code[unique=true];catalogVersion(catalog(id),version)[unique=true,allownull=true];approvalStatus(code);baseProduct(code) ;X_MENS_SHIRT_40;NikeProductCatalog:Staged;check;X_MENS_SHIRT` – alain.janinm Mar 23 '17 at 11:20
-
-
It worked.Thanks a lot.Now i am clear about this concept.Cheers mate ! Can you suggest me best approach to learn hybris. I want to explore right it till db level how it works core,commerce,wcms concepts etc – user18181818 Mar 23 '17 at 11:28
-
You're welcome. To learn hybris I suggest to start doing the trails https://help.hybris.com/6.3.0/hcd/8958cae4b4d94912aa2a5a449352fb19.html . In the trails try to really understand the code (not just copypaste it) and read the linked documentations. hybris is quite wide, so focus on the most interesting things like core platform, accelerators, backoffice, CMS. You'll see that you'll contruct your expertise mainly on your experiences. Developing a real life project is the best approach to learn, ideally you'll have an hybris expert in your team to help you explain the "black magics" in hybris! – alain.janinm Mar 23 '17 at 12:14