I want to add a new table in my existing nopCommerce database and call in "AffiliateProducts"
with the following columns ProductId, AffiliateId
The goal is to assign a product(s) to an affiliate(s) as follows
ProductId AffiliateId
--------------------------
101 1
101 2
201 1
301 3
Whenever customers land to my website with the Affiliate URL like http://www.bookstore.com/books/?AffiliateId=1
I want to load my store's products plus the affiliate products in this case products with id (101,102)
How to reach my goal by not touching the core classes?
If I make any changes to the core classes on nopCommerce data structure, there will be a challenge for updating to newer version of nopCommerce.
Should I create a new plug in?
Is there any sample for that?
Even if I create my own classes I will be needed to make changes on CatalogController that is responsible to load the products and categories to use my new plug-in methods and functions.
Like this one.
public ActionResult Category(int categoryId, CatalogPagingFilteringModel command)
{
...
...
var products = _productService.SearchProducts(categoryIds, 0,
_catalogSettings.IncludeFeaturedProductsInNormalLists ? null : (bool?)false,
minPriceConverted, maxPriceConverted,
0, string.Empty, false, false, _workContext.WorkingLanguage.Id, alreadyFilteredSpecOptionIds,
(ProductSortingEnum)command.OrderBy, command.PageNumber - 1, command.PageSize,
true, out filterableSpecificationAttributeOptionIds);
...
...
...
}
I need to change the method for seraching products and pass the AffiliateId and return my products and products related to AffiliateId.