Skip to main content
2 of 2
edited tags
Fabian Schmengler
  • 66.1k
  • 25
  • 188
  • 422

Four Random Products on Homepage

I'm trying to get 4 random products on the homepage using PHP within a TPL file I've created. I'd like to be able to format the products in a foreach loop as I'm using some formatting in the code seen below...

<div class="three columns">
  <div class="product_container no_border">
    <div class="product">
      <a href="product_page.html"><img src="<?php echo $this->getSkinUrl('images/products/place_holder.jpg'); ?>" alt=" "></a>
    </div>
    
    <div class="product_title">
      <a href="product_page.html">240 Serving Package</a>
    </div>
        
    <div class="price_hp">$454.99</div>

    <div class="free_shipping">
      <div class="fs"></div>
      Free shipping for this package
    </div>
        
    <div class="shop_btn">
      <a href="#">ADD TO CART</a>
    </div>
  </div>
</div>

I've tried a few things found on Google but no luck yet. Setting categories in an array would certainly work for what I'm trying to do but it'd also work if the categories were random.

Thanks!