10021---Creating a Code Base for Your Project

Overview

In this step we are going to create a completely new storefront.

Create the accelerator code base for the project

The accelerator templates are delivered as source code. When you develop a project using the accelerator you actually change this code. 

Instead of changing it directly, the correct way to work is to separate your project code base from that of the accelerator. To do this we replicate

 the yaccelerator* extensions into our project namespace. In this trail we are developing a merchandise shop, so we will adapt the code base

 using modulegen.

Stop the server.  Run 'modulegen' task from your platform build.xml: ant modulegen

<span style="color:#333333;">modulegen:
    [input] 
    [input] Please choose a template for generation.
    [input] Press [Enter] to use the default value ([accelerator], b2baccelerator, telcoaccelerator, commercewebservices)
accelerator
    [input] 
    [input] Please choose the name of your module extension. It has to start with a letter followed by letters and/or numbers.
    [input] Press [Enter] to use the default value [training]
merchandise
    [input] 
    [input] Please choose the base package name of your extensions. It has to fulfill java package name convention. Each extension in the module will add its name to this package.
    [input] Press [Enter] to use the default value [org.training]
de.hybris.merchandise

All steps in this trail assume that you have chosen de.hybris.merchandise package in above step therefore all code snippets 

attached to followingtrail pages have this package included.

If you've chosen different package then it's great! You will learn much more by investigating carefully the attached code snippets but

 at the same time this trail will take you more time.

After this step you should have 7 custom extensions in custom folder, that have been adopted to your project's namespace.

<pre name="code" class="html">/custom/merchandise/merchandisecockpits
/custom/merchandise/merchandisecore
/custom/merchandise/merchandisefacades
/custom/merchandise/merchandisefulfilmentprocess
/custom/merchandise/merchandiseinitialdata
/custom/merchandise/merchandisestorefront


 

But with one exception! Please don't add the merchandisetest extension to localextensions.xml -- in version 5.7.0.3, it contains a large data set for example storefronts (electronics and apparel) which would significantly lengthen the time needed for initialization. So removing it from localextensions.xml will save you a lot of time during the entire commerce trail.

It's more convenient to add extension by name rather than by dir (as instructed in the modulegen output above).

...

        <extension name="merchandisestorefront" />

        <extension name="merchandiseinitialdata" />

        <extension name="merchandisecockpits" />

...

Follow the instructions from the modulegen output about adding the new merchandise extensions:

After the build is complete, your hybris/config/localextensions.xml extension listing would be like this:

config/localextensions.xml

<hybrisconfig xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='../bin/platform/resources/schemas/extensions.xsd'>
  <extensions>
    <path dir='${HYBRIS_BIN_DIR}' autoload='false' />
    <extension name='mcc' />
    <extension name='backoffice' />
    <extension name='commercesearchbackoffice' />
    <extension name='commerceservicesbackoffice' />
    <extension name='solrfacetsearchbackoffice' />
    <extension name='solrserver' />
    <extension name='yacceleratorcockpits' />
    <extension name='yacceleratorinitialdata' />
    <extension name='yacceleratorfulfilmentprocess' />
    <extension name='yacceleratorstorefront' />
    <extension name='yaddon' />
    <extension name='ycommercewebservices' />
    <extension name='electronicsstore' />
    <extension name='apparelstore' />
    <extension name='liveeditaddon' />
    <extension name='acceleratorwebservicesaddon' />
  </extensions>
</hybrisconfig>
Now we will configure localextensions.xml file for this trails needs. We should remove the y extentions

 (except yaddonandycommercewebservices) and add the merchandise extensions (except merchandisetestextension). Edit hybris/config/localextensions.xml and copy over the following content:

config/localextensions.xml

<hybrisconfig xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='../bin/platform/resources/schemas/extensions.xsd'>
  <extensions>
    <path dir='${HYBRIS_BIN_DIR}' autoload='false' />
    <extension name='mcc' />
    <extension name='backoffice' />
    <extension name="btg"/>
    <extension name="btgcockpit"/>
    <extension name='commercesearchbackoffice' />
    <extension name='commerceservicesbackoffice' />
    <extension name='solrfacetsearchbackoffice' />
    <extension name='solrserver' />
    <extension name='yaddon' />
    <extension name='ycommercewebservices' />
    <extension name='liveeditaddon' />
    <extension name='acceleratorwebservicesaddon' />
    <!-- custom-ext -->
    <extension name='merchandisecore'/>
    <extension name='merchandisefacades'/>
    <extension name='merchandisestorefront'/>
    <extension name='merchandisefulfilmentprocess'/>
    <extension name='merchandiseinitialdata'/>
    <extension name='merchandisecockpits'/>
  </extensions>
</hybrisconfig>

We can define a custom webroot for the store, since store is easier to read and type than merchandisestorefront.

Modify this in/merchandisestorefront/extensioninfo.xml.

merchandisestorefront/extensioninfo.xml
<webmodule jspcompile= "false"  webroot= "/store" />
In addition, we have to adjust  local.properties  to override properties defined in merchandisestorefront:
/config/local.properties
merchandisestorefront.webroot=/store
storefrontContextRoot=/store
website.hybris.http=http: //hybris.local:9001/store
website.hybris.https=https: //hybris.local:9002/store

Now rebuild the code base (ant clean all) and restart the hybris server. Navigate to  http://localhost:9001 then Platform -> Update and do a project data update on the merchandise core extension, as shown in the following screenshot:


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值