1

I would like to add a function to the cartController (angular) in the storefront.

I could fork the storefront and then make my change and start loading only "my" storefront.

Is there a way to build my own module with the purpose of extending or overriding the controller so I can still use the base storefront module and just extend with my changes.

Montané Hamilton
  • 547
  • 1
  • 7
  • 17

1 Answers1

0

To extending storefront you should adhere to the following rules to be able to update to the latest storefront version without 'merging hell':

  • Try to avoid direct exist storefront controller changes, create own controllers in separated solution folders with using prefixes for class and file names. e.g

VirtoCommerce.Storefront/MyExtension/myCartController

  • Register new routes and dependencies by modifying Startup.cs (it is exception)
  • All storefront model classes marked as partial and will be easily to split the definition over two or more source files within
    VirtoCommerce.Model and VirtoCommerce.LiquidThemeEngine projects. e.g

VirtoCommerce.Storefront.Model/MyExtension/ShoppingCart.cs

In this article you can see the overall solution development process.

Community
  • 1
  • 1
tatarincev
  • 364
  • 3
  • 5
  • So I'm specifically talking about the Angular controller in this case. I added a function and checked it in. I then rebased my fork with latest to ensure my changes sit on top to enforce the idea that base changes occur first and I build on top of those always. This worked this time but is there a better way to add a function to an Angular controller? – Montané Hamilton May 12 '17 at 02:11
  • If you decided to modify default theme '~/App_Data/Themes/default' you can edit everything there, but you should be aware on merging for not lose your changes, because default theme also can be modified in original repository. I would suggest for you create you own theme as copy of default and place it in own Github repository and make all the changes there. – tatarincev May 12 '17 at 08:34
  • The Angular controller is not in the theme it's in the storefront. I have my theme in my own repo as I explained in the answer to the theme question. That is working great. Are you saying I could place the controller in my theme and override there? – Montané Hamilton May 12 '17 at 15:00
  • Ah I see the theme does have it. Easy enough. but the question should be updated to reflect that this is a theme issue only. – Montané Hamilton May 12 '17 at 15:16