cancel
Showing results for 
Search instead for 
Did you mean: 

Can we have 2 extension extended from ycommercewebservices template?

0 Kudos

Can we have 2 extension extended from ycommercewebservices template? If yes, how to proceed with it ?

We have a requirement in Hybris 6.7 where we need to keep the webservices from two third party integrations separate in two different extensions.

For example webservices integration for third party A in one extension,say A and webservices integration for third party B in another extension say B. Now I have extended ycommercewebservices for third party A, it is not giving any build issues.

Now when I extended the webservices for third party B, it is giving build issues.

The issue is, when I extend from ycommercewebservices for third party B, it gives rise to conflicts in items and beans autocreated by extending. I have tried removing the items and beans which are conflicting but still it is giving build issue.

Did anyone face such a issue?

Is it even feasible to create separate extensions extending from same ycommercewebservices template.

Accepted Solutions (0)

Answers (3)

Answers (3)

mpern
Employee
Employee

I wouldn't create two extensions using ycommercewebservices, as it's not sensible to have more than one

  • If you need to separate the data, use different BaseSites with different catalog versions or similar mechanisms

  • if you just need to implement a custom REST API, use ywebservices as template.

Documentation for ywebservices (available since 6.0): https://help.hybris.com/1808/hcd/eb5f0e9c20464a488466790333e0e6e2.html

Avinash_Vaidya
Product and Topic Expert
Product and Topic Expert

Yes. We were having similar scenario. I will explain this briefly below and how we could solve it.

Scenario:

  1. B2B Storefront and B2C Storefront on same platform
  2. We already had customer commercewebservices extension created for B2B which was consumed by SCPI for Customer, product, order updates.
  3. We had occ addon created for b2c order updates from SCPI.
  4. Customer had a requirement of enabling B2C commerce OCC services to be consumed by native app.

Challenges:

  1. Beans injected in B2B commercewebservices were for b2b scenarios. For example cartfacade implementation is slightly different for b2b and b2c. So we have, b2bCartFacade and b2cCartFacade.
  2. We started B2C ProductControllers and CartControllers in the existing B2B commercewebservices extension. But the b2b beans were getting injected.
  3. We could override the beans but then b2b controllers had b2c beans injected.

We tried lot of refactoring but of no use. The only option is to have separate commercewebservices extension for b2c commerce functionality.

Solution:

  1. Create one more commercewebservices extension for b2c
  2. Create a common extension, whcih will hold common beans for both b2b and b2c. (This is required because when u create two commercewebservices there are certain beans which are using same name but the classes are from spring or platform). This extsion will not have any web context.
  3. Create addon for b2c beans.
  4. Inject the addon in b2c commercewebservices.
  5. b2bcommercewebservices has /rest as webroot
  6. b2ccommercewebservices has /b2ccommercewebservices as webroot

ycommercewebservices.png

former_member618655
Active Participant
0 Kudos

It is definitely possible, just use Hybris' extendable extension approach.

Create an extension 'A' from ycommercewebservices template. Now create another extension called webservicescommons and copy A-items.xml and all spring configuration xml files into webservicescommons extension. In short your extension A should only have controllers. Move all the facades/services to webservicescommons extension.

Now Create another extension 'B' similarly and delete all items.xml and spring configuration files and facades and services java files.

In extensioninfo.xml file for extension 'A'. Add requires-extension attribute webservicescommons In extensioninfo.xml file for extension 'B'. Add requires-extension attribute webservicescommons

Put all extension in localextension.xml file.

In short, you have made 2 extensions A & B and have moved all beans and all facades/services logic into a common extension. So your common extension is now reusable and your extension 'A' & 'B' will have endpoints for third parties to call.

Hope it helps.