Customizing the B2C Accelerator to Support both B2B and B2C storefronts

In my previous blog after initialize and build we got ootb b2b and b2c two storefronts yacceleratorstorefront,yb2bacceleratorstorefront but if we want to do any customization we cannot do directly in those extensions its not a good practice
So we need to create our own custom extensions

Step 1: Remove yb2bacceleratorstorefront from localextensions.xml file and custom folder.

Because if we run ant modulegen directly ,build get fails we get below error so to solve this follow step1

Step 2: Run ant modulegen command in platform

Please select the template(default template : accelerator),enter name sample ,enter package com.hybris.sample

Step 3: After Build Sucessful Add the new custom extensions and comment/remove yaccelerator* extensions in the localextensions.xml file as mentioned below

Save it and do ant clean all in platform

Step 4: Build got failed because duplication ConsignmentProcess.done attribute in yacceleratorordermanagement and samplefulfilmentprocess.

Comment or Remove ConsignmentProcess item in samplefulfilmentprocess-items.xml
Do ant clean all again , it will get build sucessful

Step 5: define extgen.properties E:\HybrisSuite\CX2211\hybris\bin\custom\custom\samplestorefront to tell extgen tool to use samplestorefront as Template for creating new extension

extgen.properties consists It consists of Tokens which include naming convention,package structure,class prefixes and other details about extension. Here we are using samplestorefront as template for creating sampleb2bstorefront

Step 6:Run E:\HybrisSuite\CX2211\hybris\bin\platform>ant extgen

select template: samplestorefront ,name: sampleb2bstorefront ,package: com.hybris.sampleb2b
Note: After Build Sucessful ,Add sampleb2bstorefront in localextensions.xml file

Step 7:To enable core functionalites of B2B in sampleb2bstorefront install below addons in platform

ant addoninstall -Daddonnames="b2bacceleratoraddon" -DaddonStorefront.samplestorefront="sampleb2bstorefront"
ant addoninstall -Daddonnames="commerceorgaddon" -DaddonStorefront.samplestorefront="sampleb2bstorefront"

Step 8:Change site channel filters E:\HybrisSuite\CX2211\hybris\bin\custom\sampleb2bstorefront\web\webroot\WEB-INF\config\spring-filter-config.xml

Replace B2C code with B2B configuration in spring-filter-config.xml and Add below properties in in localextensions.xml

website.electronics.http=http://localhost:9001/samplestorefront website.electronics.https=https://localhost:9002/samplestorefront
website.apparel-uk.http=http://localhost:9001/samplestorefront
website.apparel-uk.https=https://localhost:9002/samplestorefront
website.apparel-de.http=http://localhost:9001/samplestorefront
website.apparel-de.https=https://localhost:9002/samplestorefront
website.powertools.http=http://localhost:9001/sampleb2bstorefront
website.powertools.https=https://localhost:9002/sampleb2bstorefront
media.powertools.http=http://localhost:9001
media.powertools.https=https://localhost:9002

Step 9: Do ant clean all and start Hybrisserver (hybrisserver.debug) in platform.

Access the sites
https://localhost:9002/samplestorefront/?site=electronics

https://localhost:9002/sampleb2bstorefront/?site=powertools

https://localhost:9002/samplestorefront/?site=apparel-uk&clear=true
for more infomartion please click on https://help.sap.com/docs/SAP_COMMERCE/4c33bf189ab9409e84e589295c36d96e/6b3c400939a046cd9ff4b80bf6ab6d80.html

Comments

Anonymous said…
Nice
Anonymous said…
Useful information, excellent.
Vijay Gandhari said…
Thanks for your feedback, Request all viewers give their valuable feedback. Thank you 🙏
Anonymous said…
Thank you for this valuable information
Anonymous said…
Thank you bro
Anonymous said…
How to install an new extension using template ycommercewebservices , I tried but it failed while accessing swagger and spartacus .

Please make a document on how to customize OCC controller i.e ProductsController method.
what is your hybris version ? okay i shall make a document .

Popular posts from this blog

Latest SAP Commerce (Hybris) Interview Questions

Steps to Install SAP Commerce Cloud 2211/Install SAP Hybris 2105 to 2211

OCC Webservices in SAP Commerce(hybris) 2211 using YOCC template – Part 1