Adding New Table by not touching the core of nopCommerce.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 years ago
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.
11 years ago
Maybe you can do what you want with a fork in Codeplex. Check how this multi-store extension is built
Another way would be to use ACL on categories/products (coming in v2.7 at end of december) creating a customer role for each affiliate ("Affiliate1", ...) and assigning the role when customer gets into the store. Check:
https://www.nopcommerce.com/boards/t/19389/suggestions-for-acl-on-categoriesproductsmanufacturers-and-multi-stores.aspx
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.