/// <summary> /// Prepare paged related product list model to add to the product /// </summary> /// <param name="searchModel">Related product search model to add to the product</param> /// <returns>Related product list model to add to the product</returns> public virtual AddRelatedProductListModel PrepareAddRelatedProductListModel(AddRelatedProductSearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } //a vendor should have access only to his products if (_workContext.CurrentVendor != null) { searchModel.SearchVendorId = _workContext.CurrentVendor.Id; } //get products var products = _productService.SearchProducts(showHidden: true, categoryIds: new List <int> { searchModel.SearchCategoryId }, storeId: searchModel.SearchStoreId, vendorId: searchModel.SearchVendorId, productType: searchModel.SearchProductTypeId > 0 ? (ProductType?)searchModel.SearchProductTypeId : null, keywords: searchModel.SearchProductName, pageIndex: searchModel.Page - 1, pageSize: searchModel.PageSize); //prepare grid model var model = new AddRelatedProductListModel { //fill in model values from the entity Data = products.Select(product => product.ToModel <ProductModel>()), Total = products.TotalCount }; return(model); }
public virtual IActionResult RelatedProductAddPopupList(AddRelatedProductSearchModel searchModel) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts)) { return(AccessDeniedKendoGridJson()); } //prepare model var model = _productModelFactory.PrepareAddRelatedProductListModel(searchModel); return(Json(model)); }
/// <summary> /// Prepare related product search model to add to the product /// </summary> /// <param name="searchModel">Related product search model to add to the product</param> /// <returns>Related product search model to add to the product</returns> public virtual AddRelatedProductSearchModel PrepareAddRelatedProductSearchModel(AddRelatedProductSearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } searchModel.IsLoggedInAsVendor = _workContext.CurrentVendor != null; //prepare available categories _baseAdminModelFactory.PrepareCategories(searchModel.AvailableCategories); //prepare available stores _baseAdminModelFactory.PrepareStores(searchModel.AvailableStores); //prepare available vendors _baseAdminModelFactory.PrepareVendors(searchModel.AvailableVendors); //prepare available product types _baseAdminModelFactory.PrepareProductTypes(searchModel.AvailableProductTypes); //prepare page parameters searchModel.SetPopupGridPageSize(); return(searchModel); }