First off, I'm new to nopCommerce but I like what I see so far and have had a lot of success with getting up to this point. Half way through this project I decided to upgrade to the latest 2.1 version and, so far am really impressed by the new syntax.
I'm trying to create a separation of a couple of controls which are used on the Single Variant and Variant in Grid templates. Specifically I am trying to have a different related products control for the single variant and variant in grid templates. It's mostly for aesthetic reasons at this time but there may be other reasons for the separation in the future.
My solution for this problem at this point was very direct but I believe it will cause me problems in the future.
My solution:
in the CatalogController.cs file add the following code for a second razor page;
[ChildActionOnly]
public ActionResult RelatedProductsNEW(int productId)
{
var product = _productService.GetProductById(productId);
if (product == null)
throw new ArgumentException("No product found with the specified id");
var products = _productService.SearchProducts(0,
0, null, null, null, productId, 0, null, false,
0, null, ProductSortingEnum.Position, 0, int.MaxValue);
var model = products.Select(x => PrepareProductOverviewModel(x)).ToList();
return PartialView(model);
}
Then I copied the RelatedProducts.cshtml file in Views/Catalog and named RelatedProductsNEW.cshtml. Point the Variants in Grid template to the RelatedProductsNew control and bingo!!!
Recompiled and it created a new nop.web.dll which ran perfectly.
Only problem. Upgrades...
When a new release comes out I'm now going to have to re-add my code and recompile every time. Also I would like to be able to apply this to other projects in the future without having to re-do it every time.
Is there a way to accomplish the same thing but have it compile a separate dll which I can install using your plugin architecture?
I know it's a rookie question. I am definitely still learning.
I've also added quite a few changes to the existing razor pages which I am unsure if I should have done directly or in new pages. I created a different shared template from _2ColumnRoot.cshtml but other than that I have made my changes directly in the default razor pages. Again I'm concerned about when I upgrade, will I have to re-integrate my changes back in?
I've looked through the forum quite a bit and found some great tutorials, but I'm not sure in this case which direction I should go.
Thank you in advance for your help.