AbanteCart Community

AbanteCart Development => Customization help => Topic started by: Tristan on January 25, 2018, 05:33:06 PM

Title: Random view of items in custom LISTING BLOCK on the HOME PAGE
Post by: Tristan on January 25, 2018, 05:33:06 PM
We've created a LISTING BLOCK on the HOME PAGE to increase our audience.
In this block a number of favorite items have been selected.
We would like that when buyers return to their home page, they can see random items in this block.
20 articles would be enough to appear in this block!
We need help to solve this problem.
Any suggestions are welcome.
Thank you in advance.
Title: Re: Random view of items in custom LISTING BLOCK on the HOME PAGE
Post by: eCommerce Core on January 26, 2018, 10:10:31 AM
Listing block data is extracted in this controller:
https://github.com/abantecart/abantecart-src/blob/master/public_html/storefront/controller/blocks/listing_block.php#L238

There are 2 types: predefined and custom lists.

If you use custom list manually picked, you can add random sorting with PHP shuffle
https://github.com/abantecart/abantecart-src/blob/master/public_html/storefront/controller/blocks/listing_block.php#L375

http://php.net/manual/en/function.shuffle.php