Making a simple “similar products” module

By | January 23, 2013

By “similar products” module, I mean s similar products to the product you are already looking at. What do we need to show;

1. products name (linked to it’s own product page).
2. products price

These need to be shown in the product info page. The “similar”ness feature will be simple list of the products in the same category as the product being looked at. We need to exclude the product being looked at from the list.

So, the SQL goes like Pastebin (including comments):

Next up is to take the “upcoming_products.php” module and:

1. Find the line of code (it’s line 13) that starts:

$expected_query = tep_db_query(

Change that full line of code to the $similar_query that I pastebin’d.

2. Change EVERY instance of $expected to $similar throughout the file.

3. Find the line that starts (line 29):

‘ <td align=”right”>

In that line, change tep_date_short($expected[‘date_expected’]) to $currencies->format($expected[‘products_price’],tep_get_tax_rate($product_info[‘products_tax_class_id’]))

Save the file as “link_products.php” in the /includes/modules/ folder.

Open up “product_info.php” file and:

1. Find the line of code like this:

if ($product_info[‘manufacturers_id’] > 0) {

Right above that line of code add:

include(DIR_WS_MODULES . ‘like_products.php’);

Save the file.

Open up “includes/languages/english/product_info.php” file and:

1. Add the following line of code

define(‘TABLE_HEADING_LIKE_PRODUCTS’, ‘Other products you might like’);

Save the file.

Reload the page in your browser. If the product you are looking at has fellow products in its category, you will see a new box that looks like this:


If there is any demand I might package it up as a addon or more likely github it for easy reference.

7 thoughts on “Making a simple “similar products” module

  1. Matt

    It’s a cool feature! On the last version of my site I did the same thing but instead of a new box on the page I used the breadcrumb trail to hold the info. So if the breadcrumb trail was..

    home > category > product

    ..the category link would have a dropdown on hover state that held the other products.

  2. Isa

    Hi Gary

    Very useful! I was looking for something like that for my shop 🙂

    **If there is any demand I might package it up as a addon or more likely github it for easy reference.**

    I’d love it if you could do that 🙂

  3. Isa

    This useful tip works like a charm and installs in just a few minutes 🙂 Thanks Gary

  4. Steve

    Thanks Gary for sharing that. You have a knack for presenting “how to” info that is straightforward and easily understandable.

Leave a Reply

Your email address will not be published.