Hybris 2211 B2B and B2C Storefronts

B2B and B2C Storefronts, In Hybris 2211 there is no separate recipe for B2B so we need to customize B2C Storefront to enable B2B Storefront.
B2B and B2C Storefronts

The cx recipe creates a simple B2B storefront extension as an example under the hybris/bin/custom directory based on the yacceleratorstorefront template extension. In contrast, the B2C part runs directly off the templates in hybris/bin/ext-template. For this reason, creating an additional B2C module for a project using ant modulegen would result in an error due to the B2B extension’s presence in the hybris/bin/custom directory.

Please visit here to install custom OOB B2C storefront.

Step 1 to have B2B Storefront with B2C

Under your myprojectstorefront extension, create a new file named extgen.properties.

Now move under cd <HYBRIS_HOME_DIR>\hybris\bin\custom\myproject\myprojectstorefront and execute this command.
touch extgen.properties (Optional Step, do it if you are using git branch)

Step 2 Add the following content to extgen.properties
YEXTNAME_TOKEN=myprojectstorefront
YMODULE_TOKEN=myproject
YMODULE_PACKAGE_ROOT=storefront
YMODULE_CLASS_PREFIX=Storefront
YPACKAGE_TOKEN=de.hybris.mymodule.myprojectstorefront
YMANAGER_TOKEN=MyProjectStorefrontManager
YCLASSPREFIX_TOKEN=MyProjectStorefront
YGENERATED_TOKEN=Generated

Create the B2B storefront extension for your module. Go to the <HYBRIS_BIN_DIR>/platform directory and run ant extgen with the following options.

template: myprojectstorefront
name: myprojectb2bstorefront
package: com.hybris.myb2bproject
Add the new extension to the <HYBRIS_CONFIG_DIR>/localextensions.xml file
<extension dir="${HYBRIS_BIN_DIR}/custom/myprojectb2bstorefront"/>
Add the required dependencies using ant addoninstall
ant addoninstall -Daddonnames="b2bacceleratoraddon" -DaddonStorefront.myprojectstorefront="myprojectb2bstorefront"
ant addoninstall -Daddonnames="commerceorgaddon" -DaddonStorefront.myprojectstorefront="myprojectb2bstorefront"
Provide access to the powertools B2B storefront website

Navigate to <HYBRIS_BIN_DIR>/custom/myprojectb2bstorefront.

Open the myprojectb2bstorefront extension’s project.properties file and remove all existing properties starting with website.* and replace them with the following properties.

website.powertools.http=http://powertools.local:9001/myprojectb2bstorefront
website.powertools.https=https://powertools.local:9002/myprojectb2bstorefront
media.powertools.http=http://powertools.local:9001
media.powertools.https=https://powertools.local:9002

Before and After Screenshots

Change Site Channel Filters

Change the site channel filters so that the extension uses the B2B filters by modifying the myprojectb2bstorefront/web/webroot/WEB-INF/config/spring-filter-config.xml file and replacing this code snippet with the following one.

Existing Code:

<alias name="b2cAcceleratorSiteChannels" alias="acceleratorSiteChannels"/>
<util:set id="b2cAcceleratorSiteChannels" value-type="de.hybris.platform.commerceservices.enums.SiteChannel">
    <ref bean="SiteChannel.B2C"/>
</util:set>

Replace With:

<alias name="b2bAcceleratorSiteChannels" alias="acceleratorSiteChannels"/>
<util:set id="b2bAcceleratorSiteChannels" value-type="de.hybris.platform.commerceservices.enums.SiteChannel">
    <ref bean="SiteChannel.B2B"/>
</util:set>

Navigate to the <HYBRIS_CONFIG_DIR> directory and remove all properties starting with website.* from the local.properties file since they are already provided by your B2C and B2B storefront extensions.

Run ant clean all and ant initialize from the hybris/bin/platform directory

cd %HYBRIS_HOME_DIR%\hybris\bin\platform & ant clean all ant initialize

Start the SAP Commerce Server
  • Windows: hybrisserver.bat
  • Unix/MacOs: ./hybrisserver.sh

Add the following to your hosts file.

127.0.0.1 electronics.local apparel-uk.local apparel-de.local powertools.local

You can access the B2C electronics store and apparel store as well as the B2B powertools store.

You can access all the storefront with the following URLs:

  • https://electronics.local:9002/myprojectstorefront/
  • https://apparel-uk.local:9002/myprojectstorefront/
  • https://apparel-de.local:9002/myprojectstorefront/
  • https://powertools.local:9002/myprojectb2bstorefront/
RSS
Share