NopCommerce V3.8 & Random Homepage Products

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
7 years ago
Hello,

I was wondering if someone can point me in the right direction when it comes to display x amount of home page featured products randomly on the homepage.

I have looked in the source code and am trying to get my head around it at the moment.

Any help would be much appreciated.

Thanks.

Andy
7 years ago
Check this plugin: https://www.nopcommerce.com/p/2546/random-featured-products-on-home-page.aspx
7 years ago
You can run this script, to put into a stopeprocedure and run it at time  interval you like.
The advantage is that it shows only products in stock, so there's no risk a customer enter a product pageand discover it's sold out.


declare @min  int,
    @max  int,
    @iNum  int,
    @ID    int,
    @Group  int;
    
set @inum = 0;
select @min=min(id), @max=max(id) from product;
select @max=@max-@min+1;

declare @tID table(ID int);
set nocount on;

while @inum < 10
  begin
      set @ID = rand() * @max + @min;
      select @ID = case ProductTypeId
        when 5 then ParentGroupedProductId
        when 10 then Id
      end
      from Product where ID=@ID
      if not Exists(select * from @tID where id=@ID)
          begin
              if exists( select * from product where id=@id AND Deleted = 0 AND published = 1)
                if (select SUM(StockQuantity) from Product where Id=@ID)> 0
                  begin
                      insert into @tID Values(@id);
                      set @inum = @inum + 1;
                  end
          end
  end

update product
  set ShowOnHomePage = 0;

update product
  set ShowOnHomePage = 1
from
  product t1
  inner join @tID q on t1.ID = q.id;
7 years ago
Please have a try with our following FREE plugins:

* Top Rated Products - download link
* Top Lowest Price Products - download link
* Top Highest Price Products - download link
* Featured Products - download link
* New Products - download link
* Most Viewed Products - download link

All above plugins supported random display, in additional, you can change its widget zone also.

Hope this help :)
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.