How to show products randomly in categories page & related products should load dynamically

2 years ago
Hello,


We are using nopcommerce 3.80 for our store.  Can any one help us to show random products in category list page.

For example: If any customer visits 'SHIRTS'  category page every time it shows the same products. But we have more than 1000 shirts in my store.  We want to show products randomly.  Ex: If the user refresh the same page also it should change products display order with different products.


____________________

about Related Products:

We need to load related products dynamically from the same category.  Instead of adding the static products in admin panel which leads time consumption.  It should fetch 10 products from same category.  Also need to change randomly if we refresh the same page.

Please help us to achieve the above.

Thanks in advance.
2 years ago
prasad1709 wrote:
We are using nopcommerce 3.80 for our store.  Can any one help us to show random products in category list page.

For example: If any customer visits 'SHIRTS'  category page every time it shows the same products. But we have more than 1000 shirts in my store.  We want to show products randomly.  Ex: If the user refresh the same page also it should change products display order with different products.

You'd have to change the ProductLoadAllPaged stored procedure in the database. By default it will use the DisplayOrder field from the ProductCategoryMapping table if no specific sort order is requested:

        --category position (display order)
        IF @CategoryIdsCount > 0 SET @sql_orderby = ' pcm.DisplayOrder ASC'

So to randomise the order you could change that category sorting to:

        --category position (display order)
        IF @CategoryIdsCount > 0 SET @sql_orderby = ' NEWID()'


The problem is that it would break the paging on the category. You can't fetch the next x products if the sort order isn't predictable.
2 years ago
petemitch wrote:
We are using nopcommerce 3.80 for our store.  Can any one help us to show random products in category list page.

For example: If any customer visits 'SHIRTS'  category page every time it shows the same products. But we have more than 1000 shirts in my store.  We want to show products randomly.  Ex: If the user refresh the same page also it should change products display order with different products.
You'd have to change the ProductLoadAllPaged stored procedure in the database. By default it will use the DisplayOrder field from the ProductCategoryMapping table if no specific sort order is requested:

        --category position (display order)
        IF @CategoryIdsCount > 0 SET @sql_orderby = ' pcm.DisplayOrder ASC'

So to randomise the order you could change that category sorting to:

        --category position (display order)
        IF @CategoryIdsCount > 0 SET @sql_orderby = ' NEWID()'


The problem is that it would break the paging on the category. You can't fetch the next x products if the sort order isn't predictable.




Hi,

Thanks for your prompt reply.  


It would be great if you could help us to resolve this issue.  How can we load/show related products dynamically.  Instead of adding static products in admin panel which leads to time consumption.  At a point of time the static products may become out of stock.  If the user clicks on those products and if user noticed all are out of stock.  Then the user will left the store with no purchase.  

So, Please help us to resolve this issue.  What are changes required.

#1. Products load dynamically from the same category.
#2. Only instock products should be load with product attributes stock quantity.
#3. Products should load randomly from the category.