Add Function to Existing Angular Controller in VirtoCommerce Storefront - virtocommerce

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.

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
About theme customization please read my answer on Starting VirtoCommerce Storefront Theme Development stackoverflow question
How to use new modules API in the storefront described in this article How to generate module API C# client using AutoRest
In this article you can see the overall solution development process.

Related

PrestaShop - calling module methods from Vue.js back office application

I'm working on PrestaShop module. I have Vue.js app which is running in the backoffice, and I want to make an http request to my module class in order to populate some data. How can this be achieved?
I want to be able to simply expose some kind of API, or call php method in some way.
I was able to expose some API endpoints to FrontEnd of module using custom fronts controllers, but I have no idea how to make this work in backoffice. Any help would highly valuable for me, thanks!
Like for the Front office, you can create controllers inside the Back office. Here's a page from the developer documentation:
https://devdocs.prestashop.com/1.7/modules/concepts/controllers/admin-controllers/
Make sure to check some of the examples from the native modules:
https://github.com/PrestaShop/blockwishlist/blob/dev/src/Controller/WishlistConfigurationAdminController.php
https://github.com/PrestaShop/example-modules/tree/master/democontrollertabs

How to inspect asp.net core methods?

I created a new ASP.NET Core MVC application with individual user accounts authentication. I would like to see how they implemented some methods. I suppose I can do it since ASP.NET Core is open source project, but I can't find these methods in github repository.
https://github.com/aspnet/AspNetCore/
I am highly interested in this method.
https://localhost:portnumber/Identity/Account/Login
Q1: How to find this method in my project and is it possible to debug it?
Q2: Why I dont see AccountController file in my new created app?
ANSWER:
It turned out, that from .net core 2.2 version if you want to see or change Identity controllers, you have to scaffold them manually.
https://learn.microsoft.com/en-us/aspnet/core/security/authentication/scaffold-identity?view=aspnetcore-2.2&tabs=visual-studio#scaffold-identity-into-an-empty-project
The methods you are referring to are part of your application. Have a look under the Areas folder. There should be a subfolder called Identity. Under the Identity folder, you should find the AccountController and your Login action method should be inside this controller.
If you really want to look into the source code you need to have a look at the SignInManager.cs class and see how the SignInAsync method is implemented, which is used by the Login action method.
EDIT
Please refer to the screenshot below
EDIT 2
Structure for the newly created app using Web Application template

Where is the documentation for BigCommerce js sdk?

The documentation for building an application for BigCommerce mention
a JavaScript SDK.
A single callback is mentioned, as part of the init method.
Bigcommerce.init({
onLogout: callback
});
Where is the rest of the documentation for this library located at?
Is this library in a repository in the BigCommerce github organization?
The SDK does sit on a private BigCommerce GitHub repo and there's no additional documentation at this time, although we can augment what's there. The SDK exists to provide a single callback that app creators can use to handle control panel logouts-it doesn't do anything else. Probably something we can audit to see if it's possible to make it public, but the project is pretty static (meaning we update for maintenance/security, but no planned functional updates).

Is it feasible to convert an single MVC razor view/page into a SPA?

I currently have an ASP.NET Core MVC application with multiple pages with one particular page having a lot of hand-made javascript code and ajax requests. It's becoming quite hard to manage and I would like to move to a framework like Angular, React etc for this particular page only. It is feasible to convert a single MVC view to a SPA app and still keep the other pages? Does anyone have any references on this? Google is not being too helpful...
The simplest way I have found to do this is to use one of the SPA templates and then add the static pages around that.
Here's an an example project I have made that demonstrates the concept by adding a new Razor Page to the angular SPA template.
To do this for an already existing MVC/Razor Pages app I would suggest copying the following from an SPA template project to the MVC/Razor Pages app:
ClientApp
Controllers (SampleDataController.cs)
Views (Home, Shared)
npm_shrinkwrap.json
package.json
tsconfig.json
webpack.config.json
webpack.config.vendor.json
Startup.cs (copy the SPA things)
This is not an exhaustive list but should get someone most of the way.

How do I create my own API in Yii2?

I want to create API methods which you can access form another platform. Just see the following diagram.
In the above image you can see how to fetch data from Yii2 app using another application, I wanna use same procedure when I going to push data into Yii2 application from the another application. That's means Yii2 just provides api methods to clint to push/pull data.
Give me some suggestion?
Yii2 provides ready to use RESTful Web Service API. http://www.yiiframework.com/doc-2.0/guide-rest-quick-start.html
First of all, you will need separate module for API.
If you use Advanced template (with backend, frontend), you'll need to create api directory in root level of your project. If your project is big, and API will changes in future and your API is for many clients, you should make versioning API. Create directory "modules" in api directory, then create directory "v1" in "modules". In future, if you'll need make a huge changes, create second directory, like "v2".
If you use Basic template, just create modules directory, then create API module.