Search code examples
sap-commerce-cloudimpex

Impex for creating base product and variant product in Hybris


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?


Solution

  • 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 :