CodeIgniter Forums
How can I add a related products menu on my site - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: How can I add a related products menu on my site (/showthread.php?tid=41869)



How can I add a related products menu on my site - El Forum - 05-19-2011

[eluser]Fr334Ever[/eluser]
I manage to make starting script for my shop to get some products from database,and now I want to make this script to get for evry product related products . I have 2 tables named 'product' and 'category' and based on thes tabels I want to get related products and the url for them , when a customer will click on a related product to send him to thet product page !
I will atach my script and i anyone can help please !
10x Big Grin

c_related - controller
m_related - model
v_related - view


How can I add a related products menu on my site - El Forum - 05-19-2011

[eluser]regal2157[/eluser]
Okay, well how about I give you the idea of it, and you try it?

You need something to match the products, i.e. subcategories, name, etc.

You can then do a query upon that. So for example, let's say someone is looking at keyboards in a product page. Related products would be other keyboards, and maybe even accessories - like a mouse, or monitor. So you can do a mysql search on like [$this->db->like();] Or you can query other products with that subcategory.

so in your model, create another function.. let's say get_like_items($item), where the $item is the identifier of the product being viewed. Whether it be a name, or preferably an id. Then query your database and return x products.


How can I add a related products menu on my site - El Forum - 05-20-2011

[eluser]Fr334Ever[/eluser]
[quote author="regal2157" date="1305823982"]Okay, well how about I give you the idea of it, and you try it?

You need something to match the products, i.e. subcategories, name, etc.

You can then do a query upon that. So for example, let's say someone is looking at keyboards in a product page. Related products would be other keyboards, and maybe even accessories - like a mouse, or monitor. So you can do a mysql search on like [$this->db->like();] Or you can query other products with that subcategory.

so in your model, create another function.. let's say get_like_items($item), where the $item is the identifier of the product being viewed. Whether it be a name, or preferably an id. Then query your database and return x products.[/quote]

Can you meke me an example please and I will adapte it to my site !?
Thank you !