How to Random Products Home Magento

Most of the Magento themes comes with a cool slider or featured products in the home page.

The bad thing is...would not be dinamic.

Today i'll show you How to create a Random Products in your Magento Home page.

Create the Home Products file

In my theme I created a copy of the list.phtml called home_list.phtml


Show the file in the Home Page

Now we need to show our new file in the Home Page.

Go to your Admin panel -> CMS -> Pages

You should have a page called something like Home. Open it and paste the following code:

NOTE: please notice the category_id. It will force to show a certain category. In my case a special one called Home Products.

Shuffle it

The code is quite simple. We need to add the shuffle function after getting all the products.

Look for the getItems() function and past it below.

Break on 3

I added a counter to break the foreach. Something like:

And then at the end:

Full Code

Here's my full code of the home_list.phtml. It will depend on your theme but the suffle part should be the same.


Ask any questions in the comments and we can try to solve it πŸ˜‰


Remember we have a Magento Forum section for any other Magento related questions πŸ˜‰


Leave a Reply

Add <code> Some Code </code> by using this tags.