bhaveshkrtya wrote:Hi
Need little help in getting right direction.
I want to return/get products filtered by Specification Attribute but not sure how to go about searching product with filtered.
There is a method in ProductService called SearchProduct which take "IList<int> filteredSpecs" as one of its argument but how do I construct this parameter. Tried to debug the code but couldn't find out where its getting that array list.
Any help would be much appreciated.
Thanks
Bhavesh
See the following code >>
//products
IList<int> alreadyFilteredSpecOptionIds = model.PagingFilteringContext.SpecificationFilter.GetAlreadyFilteredSpecOptionIds(_webHelper);
IList<int> filterableSpecificationAttributeOptionIds;
var products = _productService.SearchProducts(out filterableSpecificationAttributeOptionIds,
true,
categoryIds: categoryIds,
storeId: _storeContext.CurrentStore.Id,
visibleIndividuallyOnly: true,
featuredProducts: _catalogSettings.IncludeFeaturedProductsInNormalLists ? null : (bool?)false,
priceMin: minPriceConverted,
priceMax: maxPriceConverted,
filteredSpecs: alreadyFilteredSpecOptionIds,
orderBy: (ProductSortingEnum)command.OrderBy,
pageIndex: command.PageNumber - 1,
pageSize: command.PageSize);
//specs
model.PagingFilteringContext.SpecificationFilter.PrepareSpecsFilters(alreadyFilteredSpecOptionIds,
filterableSpecificationAttributeOptionIds != null ? filterableSpecificationAttributeOptionIds.ToArray() : null,
_specificationAttributeService,
_webHelper,
_workContext,
_cacheManager);
This example from
public ActionResult Category(int categoryId, CatalogPagingFilteringModel command)
..path -->Nop.Web\Controllers\CatalogController.cs
Debug this..Hope it will help you to understand your desired.