Related Products Issue

So I’m trying to get this related products thing sorted out for my website’s store. I finally got the related products out there, but I want to limit how many related products show up. It’s been showing the exact same 20 related products on every single individual product page. I followed the code that’s supposedly supposed to only show the related products based on price similarities but I guess I did it incorrectly? Additionally, I only want 2 or 3 related products to show up on a product page, not 20! Any ideas?

hi
this is the line you should modify to show only X result:

relatedProducts.splice(3, relatedProducts.length);

here you will get 3 result…