Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Help with a little database query -- PLEASE TAKE A LOOK -- NEED URGENT HELP


confusedcart

Recommended Posts

Hi guys,

 

Okay what I have is the XSELL contribution that displays a random number of products that are similar in the product_info.php page.. This pulls out products from the SAME CATEGORY.. What I'd like to do is instead of that I'd like to have products being displayed from the SAME MANUFACTURER.. I tried adjusting the code but I can't get it right. I want a random display of products from the manufacturer and not category.. Please help!!

 

 

 

/* fill the box with all random products from the same category */
    $mtm= rand();
    $xsell_cat_query = tep_db_query("select categories_id
									 from " . TABLE_PRODUCTS_TO_CATEGORIES . "
									 where products_id = '" . $HTTP_GET_VARS['products_id'] . "'");
    $xsell_cat_array = tep_db_fetch_array($xsell_cat_query);
    $xsell_category = $xsell_cat_array['categories_id'];
    $new_limit = MAX_DISPLAY_ALSO_PURCHASED - $num_products_xsell;
    $xsell_prod_query = tep_db_query("select distinct p.products_id,
													  p.products_image,
		    p.products_price,
													  pd.products_name
									  from " . TABLE_PRODUCTS . " p,
										   " . TABLE_PRODUCTS_TO_CATEGORIES . " pc,
										   " . TABLE_PRODUCTS_DESCRIPTION . " pd
									  where pc.categories_id = '" . $xsell_category . "' and
										    pc.products_id = p.products_id and
										    p.products_id != '" . $HTTP_GET_VARS['products_id'] . "' and
										    p.products_id = pd.products_id and
										    pd.language_id = '" . $languages_id . "' and
										    p.products_status = '1'
									  order by rand($mtm) desc
									  limit " . MAX_DISPLAY_ALSO_PURCHASED);

   while ($xsell = tep_db_fetch_array($xsell_prod_query)) {
	 $xsell['products_name'] = tep_get_products_name($xsell['products_id']);

Link to comment
Share on other sites

I am neither a coder nor familar with the contribution but...

 

Have you tried replacing "all" references in the code for categories to reflect manufactures?

- :: Jim :: -

- My Toolbox ~ Adobe Web Bundle, XAMPP & WinMerge | Install ~ osC v2.3.3.4 -

Link to comment
Share on other sites

changed the ''categories_id'' to ''manufacturers_id'' and changed TABLE_PRODUCTS_TO_CATEGORIES to TABLE_PRODUCTS -- it didn't work.. no products displayed then..

 

I have no idea how to code just took a guess..

 

All I need is to get items from the same manufacturer showing instead of category..

 

Please help me.. someone.. anyone!!

Link to comment
Share on other sites

I GOT IT!!! :D THIS WAS THE KEY: p.manufacturers_id

 

 

 

$mtm= rand();

$xsell_cat_query = tep_db_query("select manufacturers_id

from " . TABLE_PRODUCTS . "

where products_id = '" . $HTTP_GET_VARS['products_id'] . "'");

 

$xsell_cat_array = tep_db_fetch_array($xsell_cat_query);

$xsell_category = $xsell_cat_array['manufacturers_id'];

$new_limit = MAX_DISPLAY_ALSO_PURCHASED - $num_products_xsell;

$xsell_prod_query = tep_db_query("select distinct p.products_id,

p.products_image,

p.products_price,

pd.products_name

from " . TABLE_PRODUCTS . " p,

" . TABLE_PRODUCTS_TO_CATEGORIES . " pc,

" . TABLE_PRODUCTS_DESCRIPTION . " pd

where p.manufacturers_id = '" . $xsell_category . "' and

pc.products_id = p.products_id and

p.products_id != '" . $HTTP_GET_VARS['products_id'] . "' and

p.products_id = pd.products_id and

pd.language_id = '" . $languages_id . "' and

p.products_status = '1'

order by rand($mtm) desc

limit " . MAX_DISPLAY_ALSO_PURCHASED);

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...