Forums / Templates, Stylesheets, Page Layout / How to Link all products with same model # on prodcut info

How to Link all products with same model # on prodcut info

Locked

Started by vixay on 1 Jun 2006, 4:47 AM · Views: 2,461

Results 1 to 2 of 2
This thread is locked. New replies are disabled.
1 Jun 2006, 4:47 AM
#1
vixay avatar

vixay

New Zenner

Join Date:
Apr 2006
Posts:
17
Plugin Contributions:
0

How to Link all products with same model # on prodcut info

** Objective:** Show links to all products with same Model# in product info page... in a layout similar to "additional images" I suppose.

** How:** Possibly required modification in * tpl_product_info_display.php*

Here's my database setup...

Model#  Product_Name
TE3523 	TE3523 - CITRINE(EARRING 18K)
TE3523 	TE3523 - GREEN AMETHYSTTHYST(EARRING 18K)
TE3523 	TE3523 - LEMON QUARTZ(EARRING 18K)

Basically each model # has various color options... Therefore when I click on a product I want the images & links for all the color options for that particular model....

I know this can be done via attributes somehow, but customers need to see images for each type of color... and pricing is complicated and done externally based on color..etc.
So I already have some VBA code to convert my excel data into SQL (which I can put here for folks interested, though its specific to my test case).
I was wondering there must be an easy way to use PHP and achieve my objective.

When I click on a product ... for e.g. "TE3523 - CITRINE(EARRING 18K)"
I want links to appear on the bottom of the page to all other products with the same model #...

I looked at tpl_product_info_display.php... and i think it would be cool if i could have the other products display like the additional images section, which is shown below

<!--bof Additional Product Images -->
<?php
/**
 * display the products additional images
 */
  require($template->get_template_dir('/tpl_modules_additional_images.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_additional_images.php'); ?>
<!--eof Additional Product Images -->

which in turn calls the tpl_columnar_display.php...

<div id="productAdditionalImages">
<?php
  require($template->get_template_dir('tpl_columnar_display.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_columnar_display.php'); ?>
</div>

which means i have to call the columnar display but with my parameters...

now the question is how to get the list of all products with the same model# as the current product...
If SQL

 
SELECT products_image FROM products where products_model = [currentmodel];

I really don't know PHP and this is all i could figure out... that i probably want to call columnar display and pass it the correct paramters...

now if someone can tell me the correct way to query the database and get the desired records... and then call the template correctly, then i can probably get this working quickly.
Please let me know oh you zen masters!

--
"Drunk on the Nectar of Life" - me

1 Jun 2006, 1:01 PM
#2
vixay avatar

vixay

New Zenner

Join Date:
Apr 2006
Posts:
17
Plugin Contributions:
0

Re: How to Link all products with same model # on prodcut info

** FREAKING AWESOME!!! **

I figured it how to do it!!!

I modified the x-sell code contrib...

i will attach the two files I have modified... so that you can see what i did to get it working.... no error checking so far... so be careful if you don't have a product_model # defined...

plus I only used the modified files, i didn't use the rest of x-sell contrib...

anyway here's what's in the readme.txt, for you lazy ppl

I modified the query in xsell_products.php (line 22) to:
---
  $xsell_query = $db->Execute("select distinct p.products_id, p.products_image, pd.products_name
                                 from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
                                 where p.products_model = '" . $products_model . "'
                                  and p.products_id != '" . $_GET['products_id'] . "' 
                                  and p.products_id = pd.products_id
                                  and pd.language_id = '" . $_SESSION['languages_id'] . "'
                                  and p.products_status = 1
                                 limit " . MAX_DISPLAY_XSELL);
---
above basically i removed the reference to the xsell table, and added a 'products_model = $products_model' to get the relevant results. plus a 'p.products_id != '" . $_GET['products_id'] . "' to avoid showing itself in the x-sell box....

the tpl_modules_xsell_products.php did not need any modifications but since i wasn't using other files (which contained definitions for the filenames...etc.) I Just replaced them with their values....

so if you wanted to try it all you really had to do, was change the query as shown above...

i included the code to call this at the very bottom before the navigation buttions section in the tpl_product_info_display.php ...

enjoy..


Vixay
6/1/2006 7:59PM

It would be cool if Dr. Byte could add it to the contrib as a flag/option to use this query versus the original, that way people get the best of both worlds!!...
The model way is cool, coz you don't need to make any additional changes to the database!

--
"Drunk on the Nectar of Life" - me