I have lots of products in each category and it's necessary to allow the user to filter them by manufacturer. I don't think NopCommerce allows this by default, but I was thinking of using a product specification instead of actual manufacturers. Is there a downside to this approach or NopCommerce actually allows filtering by manufactures and I didn't know?
You're right. It'll require some customization. Follow the next steps: 1. Add manufacturer dropdownlist to your category details page (\Templates\Categories\ProductsInGrid.ascx, \Templates\Categories\ProductsInLines1.ascx and \Templates\Categories\ProductsInLines2.ascx controls) 2. Populate it with manufacturers:
var manufacturers = ManufacturerManager.GetAllManufacturers(); rptrManufacturers.DataSource = manufacturers; rptrManufacturers.DataBind();
3. Set manufacturer AutoPostBack property to "true" 4. Subsribe to its SelectedIndexChanged changed event (OnSelectedIndexChanged="ddlManufacturer_OnSelectedIndexChanged") and invoke Bind() method in its handler (ddlManufacturer_OnSelectedIndexChanged) 5. Modify Bind() method to pass selected manufacturer identifier to ProductManager.GetAllProducts(...) method
P.S. And of course you can use a product specification instead of actual manufacturers
Can I push this topic on again. I want to filter by manufacturers too.
I have four manufacturers and I want an image link from the home page to filter all products to the manufacturer selected. So a user is only browsing the site for that one manufacturer.
My C# is OK but not good enough yet for this. I think this is a pretty easy and a useful mod to do.
I understand what Andrei's post is doing but it's still short of a bit of code for me to do yet and I need it from the home page as an image hyperlink not a dropdown from the category.aspx.
You're right. It'll require some customization. Follow the next steps: 1. Add manufacturer dropdownlist to your category details page (\Templates\Categories\ProductsInGrid.ascx, \Templates\Categories\ProductsInLines1.ascx and \Templates\Categories\ProductsInLines2.ascx controls) 2. Populate it with manufacturers:
var manufacturers = ManufacturerManager.GetAllManufacturers(); rptrManufacturers.DataSource = manufacturers; rptrManufacturers.DataBind();
3. Set manufacturer AutoPostBack property to "true" 4. Subsribe to its SelectedIndexChanged changed event (OnSelectedIndexChanged="ddlManufacturer_OnSelectedIndexChanged") and invoke Bind() method in its handler (ddlManufacturer_OnSelectedIndexChanged) 5. Modify Bind() method to pass selected manufacturer identifier to ProductManager.GetAllProducts(...) method
P.S. And of course you can use a product specification instead of actual manufacturers
var manufacturers = ManufacturerManager.GetAllManufacturers(); rptrManufacturers.DataSource = manufacturers; rptrManufacturers.DataBind();
In this code you try to select all manufacturers and transfer it to DataBind of ProductsInLines2, but how i can select all manufacturers by CategoryId, can you make some examples or ready solutions?