Best way to develop new ecommerce store using 'shop' as template


#1

A couple of questions regarding the subject;

Using as much as possible from the default ‘shop’ store, what is the optimum way of deploying multiple ecommerce stores?

I’m thinking “create component”, but how exactly would I over-ride a .java or .ftl? Is there a published procedure on this topic? Thanks.


#2

Hi Mike,

The create-component as it exists is still geared toward setting up new backend apps, but you can use the result as a skeleton for anything if you trim it.

For deriving shops from the existing one, usually the best way is to use the Extensibility pattern, which was part of ofbiz documentation and recommendations but which we enhance further in several ways (it has limitations in the original ofbiz). We are already working on things that would provide concrete examples, but basically it is the same procedure as the “ecomclone” component that was in ofbiz:

You start with a skeleton component with a webapp - you can use create-component and remove the excess, but you should base the widget/CommonScreens.xml file on the one in shop, component://shop/widget/CommonScreens.xml, and then substitute within it and trim unnecessary (concrete example to come, but these definitions are important: common-settings, local-settings, webapp-common-actions, ShopDecorator, main-decorator, CommonXxxAppDecorator). You should also copy the web.xml file from component://shop/webapp/shop/WEB-INF/web.xml and modify the locations and names such as mainDecoratorLocation.

The controller should be mostly empty at first and simply do <include location="component://shop/webapp/shop/WEB-INF/controller.xml"/>. From then on any screen you need to modify you simply give the location for the new replacement in controller by adding <view-map/> entries. In turn, to implement those screens Scipio provides many ways to reuse/delegate/enhance the original screens and templates, which answers the part about FTL files. Whether individual FTL files are re-invokable or must be duplicated and modified depends on your needs.

You must also define a new WebSite entity in seed/demo data and set the webSiteId in web.xml. Dpending on what you’re doing you may need a full complement of other data such as ProductStore and catalogs. There can be quirks here because the scopes of WebSite and ProductStore have design issues in the original ofbiz schema.

For Java classes there are various ways to reuse code. Some people have used a static extension pattern to inherit the static event methods from shop/other (e.g. extend ShoppingCartEvents.java statically), and afterward you have to plug your class into controller.xml using <pre/postprocessor>, as well as overriding individual <request-map/> definitions. Sometimes a little duplication of the controller definitions is required to achieve it unfortunately. We try to provide mechanisms to achieve most extensibility without duplication, but in some cases there is no way around it (or not yet).

This sounds like a lot but it takes very little code to get a clone working.

A completely different approach is to duplicate the entire shop component and all files and update all component:// locations in all the files, but by default the patterns in place encourage using extensibility instead (case in point, those absolute locations).

We’ll make a more complete tutorial later, and there may be revisions to create-component. Perhaps some of this will be automated, but there are limitations to that.


[Project Creation] How to create a new shop-override component (2017-12)
#3

Thanks. I appreciate the detailed response. I’m familiar with ecomclone. I wasn’t sure if you guys were doing something completely different. I’m looking forward to the new documentation.