I have an ecommerce site with about 5 000 products. Each page of the site is dedicated to one product but i want to change that. I have lots of related products on the site and I need a script that can pull 10 relevant products and list them below the main product on a page. For example, if the main product on the page is "nike running shoes" i want script to be able to perform a search for other related products on the site and list them. The related products would be:

Nike running shoes for men
Nike running shoes for women
Nike running shorts

How hard will be to code script that can do this?