Monday 11 December 2017

Creating Categories Adding Products To The Categories



Requirement:-


*  Create some categories and some products, assign the products to the categories.

*  First we have to create categories after creating products and in product.impex give categories which they belong to.


Check the below Impex to get clear knowledge,

========================================================================

 Step 1:-

              Create an Impex in Categories.impex to create a new category.


# -----------------------------------------------------------------------
# [y] hybris Platform
#
# Copyright (c) 2017 SAP SE or an SAP affiliate company. All rights reserved.
#
# This software is the confidential and proprietary information of SAP
# ("Confidential Information"). You shall not disclose such Confidential
# Information and shall use it only in accordance with the terms of the
# license agreement you entered into with SAP.
# -----------------------------------------------------------------------
# ImpEx for Importing Categories

# Macros / Replacement Parameter definitions
$productCatalog=bajajProductCatalog
$productCatalogName=bajaj product catalog

$catalogVersion=catalogversion(catalog(id[default=$productCatalog]),version[default='Online'])[unique=true,default=$productCatalog:Online]
$supercategories=source(code, $catalogVersion)[unique=true]
$categories=target(code, $catalogVersion)[unique=true]

# Insert Categories
INSERT_UPDATE Category;code[unique=true];allowedPrincipals(uid)[default='customergroup'];$catalogVersion

# Insert Category Structure
INSERT_UPDATE CategoryCategoryRelation;$categories;$supercategories


INSERT_UPDATE Category;code[unique=true];$catalogVersion;supercategories(code,$catalogVersion);allowedPrincipals(uid)[default='customergroup']

;Gadgets;;
;mobile phones;;Gadgets
;nokia;;mobile phones
;samsung;;mobile phones
;redmi;;mobile phones
;htc;;mobile phones
;iphone;;mobile phones
;mobile accesseries;;Gadgets
;earphone;;mobile accesseries
;headphone;;mobile accesseries
;back cover;;mobile accesseries



* This is the Impex file I create a new category with name Gadgets. Under the gadgets, I create two subcategories 1.mobile phones 2.mobile accessories
* Under mobile phone subcategory I create four subcategories 1.nokia 2.samsung 3.redmi 4.htc
* Under mobile accessories subcategory I create three subcategories 1.earphone 2.headphone 3.back cover

Step 2:-


Create Impex for products in Products.impex



# -----------------------------------------------------------------------
# [y] hybris Platform
#
# Copyright (c) 2017 SAP SE or an SAP affiliate company. All rights reserved.
#
# This software is the confidential and proprietary information of SAP
# ("Confidential Information"). You shall not disclose such Confidential
# Information and shall use it only in accordance with the terms of the
# license agreement you entered into with SAP.
# -----------------------------------------------------------------------
# ImpEx for Importing Products

# Macros / Replacement Parameter definitions
$productCatalog=bajajProductCatalog
$productCatalogName=bajaj product catalog

$catalogVersion=catalogversion(catalog(id[default=$productCatalog]),version[default='Online'])[unique=true,default=$productCatalog:Online]
$supercategories=supercategories(code, $catalogVersion)
$baseProduct=baseProduct(code,$catalogVersion)
$approved=approvalstatus(code)[default='check']
$taxGroup=Europe1PriceFactory_PTG(code)[default=eu-vat-full]
$siteResource=jar:com.bajaj.initialdata.setup.InitialDataSystemSetup&/bajajinitialdata/import/sampledata/contentCatalogs
#$contentCV=catalogVersion(CatalogVersion.catalog(Catalog.id[default=$contentCatalog]),CatalogVersion.version[default=Online])[default=$contentCatalog:Online]


# Insert Products
INSERT_UPDATE Product;code[unique=true];$supercategories;manufacturerName;manufacturerAID;unit(code);ean;variantType(code);$catalogVersion;$approved


INSERT_UPDATE ApparelProduct;code[unique=true];$catalogVersion;unit(code);supercategories(code,$catalogVersion);varianttype(code);$approved;$taxGroup;ean;picture(&mediaRef)
;nokia 6;;pieces;nokia;;;;1022436212;mediaimage1
;samsung s8;;pieces;samsung;;;;1022432124;mediaimage2
;redmi 4;;pieces;redmi;;;;1032456642;
;htc 326;;pieces;htc;;;;10982345;
;iphone 7;;pieces;iphone;;;;109876643;
;lg;;pieces;earphone;;;;109876345;
;sony;;pieces;headphone;;;;109872344;
;redmi;;pieces;back cover;;;;109823445;

#for Images
INSERT_UPDATE Media;$catalogVersion[unique=true];code[unique=true];realfilename;@media[translator=de.hybris.platform.impex.jalo.media.MediaDataTranslator];mime[default='image/jpeg'];altText;folder(qualifier)[default='images'];&mediaRef
;;mediaimage1;cam1.jpeg;$siteResource/image/cameras/cam1.jpeg;image/jpeg;hybris Accelerator;;mediaimage1
;;mediaimage2;cam3.jpeg;$siteResource/image/cameras/cam3.jpeg;image/jpeg;hybris Accelerator;;mediaimage2


* This is the Impex for products
* Here Nokia 6 product is giving to the Nokia subcategory under the mobile phones super category.
* samsung s8 product is given to the subcategory Samsung.
* redmi 4 is given to the subcategory redmi.
* lg product is given to the earphone subcategory.
* Sony product is given to the headphone subcategory.
* redmi product is given to the back cover subcategory.

Now we create the category and subcategories and we assigned products to the subcategories.


 Step 3:-


             Open HAC https://bajaj.local:9002/



Goto console=>impex Import






Step 4:-


  Copy the copy the category Impex file and paste in Impex import and click on import content.






   After successfully importing the content again goto eclipse and copy the product.impex file and import in HAC.





Step 5:-
After importing the categories.impex and products.impex Goto HMC.









Login to HMC Password:nimda






Step 6:-

          Goto Catalog=>categories





Search for your category(gadgets). Here we can see our category, subcategories and products.




This is the final output we require.








1 comment: