Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

I need your help!


Guest

Recommended Posts

Hi can anyone help!!

I have downloaded and installed the contribution below and it works fine...

It lists some products my the same manufacture.

 

But what i really what is to show products from the same category.

Can anyone tell if it is possable to change the code to do this, and if so which variables to change.

 

I am new to PHP so any help would be much apreciated.

 

Tony

 

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

 

 

<?php

/*

$Id: matching_products_manufacturers.php,v 1.3 2009/03/13 18:59:00 hpdl Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2009 osCommerce

written by Marcus A. Kaptein for Sylka Books

 

Released under the GNU General Public License

*/

 

if (isset($HTTP_GET_VARS['products_id'])) {

$man_id = $product_info['manufacturers_id'];

 

$manufacturer_query = tep_db_query("select m.manufacturers_id, m.manufacturers_name, p.products_id, p.products_image, p.products_tax_class_id, p.products_price, pd.products_name from " . TABLE_MANUFACTURERS . " m left join " . TABLE_MANUFACTURERS_INFO . " mi on (m.manufacturers_id = mi.manufacturers_id and mi.languages_id = '" . (int)$languages_id . "') left join " . TABLE_PRODUCTS . " p on m.manufacturers_id = p.manufacturers_id left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on pd.products_id = p.products_id where m.manufacturers_id = '" . $man_id . "' order by pd.products_name limit " . MAX_DISPLAY_NEW_PRODUCTS);

$num_products_manufacturer = tep_db_num_rows($manufacturer_query);

?>

<!-- manufacturers_more_products //-->

<?php

$row = 0;

$col = 0;

$info_box_contents = array();

while ($manufacturer = tep_db_fetch_array($manufacturer_query)) {

$info_box_contents[$row][$col] = array('align' => 'left',

'params' => 'class="smallText" width="33%" valign="top"',

'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $manufacturer['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $manufacturer['products_image'], $manufacturer['products_name'], SMALL_IMAGE_WIDTH/2, SMALL_IMAGE_HEIGHT/2, ' align="left"') . '</a><a class="productTitleSmall" href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $manufacturer['products_id']) . '">' . $manufacturer['products_name'] . '</a><br><span class="ProductPrice">' . $currencies->display_price($manufacturer['products_price'], tep_get_tax_rate($manufacturer['products_tax_class_id'])) . '</span><br><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $manufacturer['products_id']) . '">' . tep_image_button('more-info-sml.gif', IMAGE_BUTTON_MORE_INFO) . '</a>');

 

$col ++;

if ($col > 2) {

$col = 0;

$row ++;

}

}

 

new productListingBox($info_box_contents);

?>

<!-- manufacturers_more_products_eof //-->

<?php

}

?>

Link to comment
Share on other sites

This worked for me:

 

<?php
/*
 $Id: matching_products_manufacturers.php,v 1.0 2009/03/07 14:09:00 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 [url="http://www.oscommerce.com"]http://www.oscommerce.com[/url]

 Copyright © 2009 osCommerce
 written by Marcus A. Kaptein for Sylka Books

 Released under the GNU General Public License
*/

 if (isset($HTTP_GET_VARS['products_id'])) {

   $cp2cp = tep_get_product_path($HTTP_GET_VARS['products_id']); // cpath to current product

   $man_id = $product_info['manufacturers_id'];

   $manufacturer_query = tep_db_query("select m.manufacturers_id, m.manufacturers_name, p.products_id, p.products_image, p.products_tax_class_id, p.products_price, pd.products_name from " . TABLE_MANUFACTURERS . " m left join " . TABLE_MANUFACTURERS_INFO . " mi on (m.manufacturers_id = mi.manufacturers_id and mi.languages_id = '" . (int)$languages_id . "') left join " . TABLE_PRODUCTS . " p on m.manufacturers_id = p.manufacturers_id left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on pd.products_id = p.products_id where m.manufacturers_id = '" . $man_id . "' order by pd.products_name");
   $num_products_manufacturer = tep_db_num_rows($manufacturer_query);
?>
<!-- manufacturers_more_products //-->
<?php
     $row = 0;
     $col = 0;
     $info_box_contents = array();
     while ($manufacturer = tep_db_fetch_array($manufacturer_query)) {
       if ( tep_get_product_path($manufacturer['products_id']) == $cp2cp ) { // if same cpath add to infobox

         $info_box_contents[$row][$col] = array('align' => 'left',
                                                'params' => 'class="smallText" width="33%" valign="top"',
                                                'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $manufacturer['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $manufacturer['products_image'], $manufacturer['products_name'], SMALL_IMAGE_WIDTH/2, SMALL_IMAGE_HEIGHT/2, ' align="left"') . '</a><a class="productTitleSmall" href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $manufacturer['products_id']) . '">' . $manufacturer['products_name'] . '</a><br><span class="ProductPrice">' . $currencies->display_price($manufacturer['products_price'], tep_get_tax_rate($manufacturer['products_tax_class_id'])) . '</span><br><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $manufacturer['products_id']) . '" class="productDescr">' . IMAGE_BUTTON_MORE_INFO . '</a>');    

         $col ++;
         if ($col > 2) {
           $col = 0;
           $row ++;
         }
       }
     }

     new productListingBox($info_box_contents);
?>
<!-- manufacturers_more_products_eof //-->
<?php
 }
?>

You might be interested in this thread: click me

 

BACKUP THE FILE BEFORE MAKING ANY EDITS.

 

See my signature - You break it, you buy it.

:blush:

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...