Thank you very much such kind of answer.
and is it suitable for my following needs:
super admin got category
1. Men Fashion
2. Women Fashion
3. Boy Fashion
4. Girl Fashion
Vendor A only selling Mens shirt wihich is categories to Men Fashion
I want Vendor A only able to see Men Fashion category at the left side categories menu. Vendor A no need to see all others category.
if your answers is yes, can you please me how to get the file location for nopcommerce 4.30
jake1234 wrote:
You will need to modify the ProductController.cs in Nop.Web/Areas/Admin/Controllers/ where it populates the product category
Let say you have SALE and GIFT categories and you don't want your vendors to map their product to these categories then you can perform the following.
Assuming that your vendor that does not have access to "Admin area. Manage Categories" from Access Control List
Add a permissionService as shown in the code below.
I guess in your case, you will need to create a logic wherein if the vendor is selling mobile phones (Mobile Category) then don't load the the other categories.
Hope this will get you going.
Let say you have SALE and GIFT categories and you don't want your vendors to map their product to these categories then you can perform the following.
Assuming that your vendor that does not have access to "Admin area. Manage Categories" from Access Control List
Add a permissionService as shown in the code below.
protected virtual void PrepareCategoryMappingModel(ProductModel model, Product product, bool excludeProperties)
{
if (model == null)
throw new ArgumentNullException(nameof(model));
if (!excludeProperties && product != null)
model.SelectedCategoryIds = _categoryService.GetProductCategoriesByProductId(product.Id, true).Select(c => c.CategoryId).ToList();
var allCategories = SelectListHelper.GetCategoryList(_categoryService, _cacheManager, true);
//check if user has manage categories access. if admin then show sale category, if vendor then don't show sale.
//Vendor will have access to all product categories except SALE and GIFT
if (!this._permissionService.Authorize(StandardPermissionProvider.ManageCategories))
{
foreach (var c in allCategories.Where(x => x.Value != "2127" && x.Value != "2128")) //Where Category SALE = 2127, GIFT = 2128
{
c.Selected = model.SelectedCategoryIds.Contains(int.Parse(c.Value));
model.AvailableCategories.Add(c);
}
}
else
//Admin will have access to all product categories
{
foreach (var c in allCategories)
{
c.Selected = model.SelectedCategoryIds.Contains(int.Parse(c.Value));
model.AvailableCategories.Add(c);
}
}
}
I guess in your case, you will need to create a logic wherein if the vendor is selling mobile phones (Mobile Category) then don't load the the other categories.
Hope this will get you going.