Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

show Manufacturer in product_info


paulm2003

Recommended Posts

Posted

I could not find how to show the manufacturer in the product_info.php pages.

 

So I made this simple hack and it works :) .

/* bof product_manufacturer hack */
// get products_id vs manufacturer_name
$sql = "SELECT manufacturers.*, products.*
       FROM manufacturers, products
       WHERE manufacturers.manufacturers_id = products.manufacturers_id";
$result = mysql_query($sql) or die(mysql_error());

while ($row = mysql_fetch_array($result))
{
$products_id_to_manufacturers_name[$row['products_id']]=$row['manufacturers_name'];
}
/* eof get data from database */

$product_manufacturer_PM = $products_id_to_manufacturers_name[(int)$HTTP_GET_VARS['products_id']];
/* eof product_manufacturer hack */

(above code added to product_info.php)

 

The problem is that I am afraid it is not the best way to do it. I am currently only using one language for example, what will happen if I decide to use more. And what about speed or other (future) problems?

 

Any suggestions welcome!

 

Paul

Posted

This is the code that I used for manufactures images

 

<?php echo tep_image(DIR_WS_IMAGES . $product_info_values['manufacturers_image'], $product_info_values['manufacturers_name']) . '<br>'; ?>

 

Dave

Posted
if (isset($HTTP_GET_VARS['products_id'])) {
               $manufacturer_query = tep_db_query("select m.manufacturers_id, m.manufacturers_name, m.manufacturers_image, mi.manufacturers_url from " . TABLE_MANUFACTURERS . " m left join " . TABLE_MANUFACTURERS_INFO . " mi on (m.manufacturers_id = mi.manufacturers_id and mi.languages_id = '" . $languages_id . "'), " . TABLE_PRODUCTS . " p  where p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and p.manufacturers_id = m.manufacturers_id");
               if (tep_db_num_rows($manufacturer_query)) {
                   $manufacturer = tep_db_fetch_array($manufacturer_query);
                   if (tep_not_null($manufacturer['manufacturers_url'])) {
                       echo '<br>» ' . TEXT_MANUFACTURUR_NAME . ' ' . $manufacturer['manufacturers_name'] . ' - <a href="' . tep_href_link(FILENAME_REDIRECT, 'action=manufacturer&manufacturers_id=' . $manufacturer['manufacturers_id']) . '" target="_blank">' . sprintf(BOX_MANUFACTURER_INFO_HOMEPAGE, $manufacturer['manufacturers_name']) . '</a>';
                   }
               }
           }

Posted

Hi Gary,

 

thanks very much! I tried you code and it works great. I suppose this one is multilangual etc, can't try now but it does look like it (much more complicated query :blink: ).

Only one thing, the code you posted only shows output when the manufacturer's url is set. It is easy to change that to my needs of course, it only suprised me a bit.

 

Hi Dave,

This is the code that I used for manufactures images

<?php echo tep_image(DIR_WS_IMAGES . $product_info_values['manufacturers_image'], $product_info_values['manufacturers_name']) . '<br>'; ?>

Thanks for the reply, it looks simple and I like simple :) , but If I try it it doesn't seems to work. No error message, just no data output. May be I am missing something?

 

Paul

Posted

Paul

 

Have you got this query in product_info?

 

<?php
 $product_info = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_weight, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id, m.manufacturers_image, m.manufacturers_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m where p.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and pd.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and pd.language_id = '" . $languages_id . "' and m.manufacturers_id = p.manufacturers_id"); 
 if (!tep_db_num_rows($product_info)) { // product not found in database
?>

 

If you have then it should work

 

Dave

Posted
Paul

 

Have you got this query in product_info?

 

<?php
 $product_info = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_weight, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id, m.manufacturers_image, m.manufacturers_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m where p.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and pd.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and pd.language_id = '" . $languages_id . "' and m.manufacturers_id = p.manufacturers_id"); 
 if (!tep_db_num_rows($product_info)) { // product not found in database
?>

Hi Dave,

 

Mine is different

 

I don't understand much of these queries yet (trying to learn) but I see you have o.a. manufacturers_name in your query, and that is not in mine, and not in the original osC2.2 MS2 product_info.php query as far as I know. Are you using a different osC version or did you install a contribution which changes the query?

 

Thanks again!

Posted

Just looked its not a stock OS query it was added after :rolleyes:, I've changed so much code i' forget what I've added half the time

 

<?php

$product_info = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_weight, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id, m.manufacturers_image, m.manufacturers_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m where p.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and pd.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and pd.language_id = '" . $languages_id . "' and m.manufacturers_id = p.manufacturers_id");

  if (!tep_db_num_rows($product_info)) {

}

?>

 

I have this line around line 46 just after the <!-- body_text //--> in product info

 

Dave

Posted
I've changed so much code i' forget what I've added half the
sounds familiar :D

 

Strange though that important values like "manufacturers_name" are not available by default in these pages. Wouldn't that be the first things to implement in a cart? :huh:

 

thanks again, I learned enough know to implement it.

 

Paul

Posted
the code you posted only shows output when the manufacturer's url is set. It is easy to change that to my needs of course, it only suprised me a bit.

It is relevant to my needs - I only copy/paste what I use...easy to amend though.

Posted

Gary

 

I have used the manufacturer?s image as a link instead of text

 

Any idea how can I change the alt text to eg "GT Interactive hompage"?

 

At the moment it just displays the manufacturer

 

Dave

Archived

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

×
×
  • Create New...