photo credit: Jo Jakeman via photopin cc

Magento ‘customers who viewed this also viewed’-query

Ever had the clients’ wish to have a ‘customers who viewed this also viewed’-functionality in your webshop? You might have noticed that this is not a default feature in Magento. And if you (like me) would like to keep your extension count as low as possible, the smallest solution is often preferred. And the smallest solution I could come up with is a single SQL-query that does the magic:

A PHP function for wrap this query could look something like this:

I know, this is not the ‘Magento way’ to do something like this. If you want to be sure it’s fool- and update-proof you should do this by working with the models and helpers of the reports module, but sometimes directly querying the database isn’t all that bad.

Visitors give this article an average rating of 2.0 out of 5.

How would you rate this article?

Leave a Reply