“Customers who bought this also bought” is a rather common requirement for store owners. And while there are many modules out there doing this, it’s surprising to know that this is, in essence, actually a very simple SQL query. Most of the work is just displaying the list on frontend and creating correct structure. First you need to fetch all order ids that have a specific product id in them, then select all product ids from that subset, exclude the product id of current product and sort it by number of times product id appeared in the sales table – and it all fits into a single query. So if someone is trying to sell you a story that this is a huge feature, know that it’s actually only 3-5 hours of work.