Jump to content
Skittles

Optional Related Products, Version 4.0

Recommended Posts

Hello.

 

First of all thank you for this great contribution.

 

I've got a problem. I installed it and everything was working fine. Until it stopped admin-side.

I am unable to insert, inherit or reciprocate any products. I blanked the database table 'products_related_products' and

I noticed that nothing is being put there by the 'optional_related_products.php' script.

 

I'm going to start looking through the code to figure out what got messed up.

 

Did anyone encounter similar problems? I could use being pointed in the right direction :)

 

Thanks in advance.

 

********EDIT********

 

I figured it out. Sorry :) I mistranslated the .php file because several of its items dont have their translations in the

language file. So I guess... beware of what you are doing and always backup! :)

Edited by kantarou

"There is something enduringly seductive in random, explosive acts of no consequence"

Share this post


Link to post
Share on other sites

Hi Guys,

 

So I am adding a bunch of contributions and modifications to make OSCommerce work as a "Quote" script instead of a "cart" script. Everything was going well until I added this script. I followed instructions thru the text file, and then added the additional files as specified. I am not getting this error

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/thecapt/public_html/dwdwebdesign.comdemo/ecommerce/admin/includes/filenames.php:124) in /home/thecapt/public_html/dwdwebdesign.comdemo/ecommerce/admin/includes/functions/sessions.php on line 102

 

Warning: Cannot modify header information - headers already sent by (output started at /home/thecapt/public_html/dwdwebdesign.comdemo/ecommerce/admin/includes/filenames.php:124) in /home/thecapt/public_html/dwdwebdesign.comdemo/ecommerce/admin/includes/functions/general.php on line 22

 

You can view the site at: http://demo.dwdwebdesign.com/ecommerce/admin/

It is only on the admin side, I am getting SQL errors on the customer side, but I assume that is because I haven't run the SQL Query to add tables etc to my database.

 

Any help would be greatly appreciated, I don't understand what is wrong at those particular lines of code.

return session_start(); ======= LINE 102 SESSIONS.php

header('Location: ' . $url); ======== LINE 22 GENERAL.PHP

define('FILENAME_RELATED_PRODUCTS', 'optional_related_products.php'); ===== LINE 123 FILENAMES.PHP

?> ======== LINE 124 FILENAMES.PHP

 

Thanks in advance for any help you can provide!

 

Regards,

Dan

Share this post


Link to post
Share on other sites

I finally figured it out freaking white space after my closing ?> in about 3 files, new to the PHP thing so won't do that anymore haha!

Share this post


Link to post
Share on other sites

Hello,

As soon as I try to Insert / Reciprocate / Inherit, my osc automatically logs off. Can any one tell me whats the problem ?

Share this post


Link to post
Share on other sites

Hi all,

 

I found out that This addon has some problemes...

 

It log-out if you block the cookies on your browser. The OScommerce uses a workaround to store the sessions data in the URL parameters as osCAdminID=xxxxxxxx, but this script does not respect that and uses <form method="get">.I am currently working on the script to make it work.

A quick fix is to make the Cookies on on your broser.

 

 

I found out also that browsing the pages on Catalog - Related Products is broken.

This mabe fixed by adding on [OScommerce_root_folder/]catalog/admin/optional_related_products.php on line 25 just after the line:

$action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');

 

The folloing line to add like this:

$action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');

 

$attribute_page = (isset($HTTP_GET_VARS['attribute_page']) ? $HTTP_GET_VARS['attribute_page'] : 1);

if (!$attribute_page) $attribute_page = (isset($HTTP_POST_VARS['attribute_page']) ? $HTTP_POST_VARS['attribute_page'] : 1);

 

Kind regards,

 

Claudiu Marginean

Junior PHP Programmer

Edited by claudiu_boonsoft

Share this post


Link to post
Share on other sites

Hi all,

 

I finish working on the script and I made it compatible to OScommerce alternative for writing the sessions ID as GET parameters.

This also fix the log-out redirect and the page navigation bug.

 

This is the code for all the [OScommerce_root_folder/]catalog/admin/optional_related_products.php file:

 

<?php
/*
 $Id: optional_related_products.php, ver 1.0 02/11/2009 Exp $

 Edit page on  2009 Claudiu Marginean (claudiu@boonsoft.net)

 Copyright (c) 2007 Anita Cross (http://www.callofthewildphoto.com/)

 Based on: products_options.php, ver 2.0 05/01/2005
 Copyright (c) 2004-2005 Daniel Bahna (daniel.bahna@gmail.com)

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Released under the GNU General Public License
*/

 require('includes/application_top.php');
 $languages = tep_get_languages();

 $version = tep_db_fetch_array(tep_db_query("select configuration_value as version, configuration_group_id as gID from " . TABLE_CONFIGURATION . " where configuration_key = 'RELATED_PRODUCTS_VERSION_INSTALLED'"));
 if ($version['version'] != TEXT_VERSION_CONTROL){
   tep_redirect(tep_href_link('sql_setup_related_products.php'));
 }
 $gID = $version['gID'];

 $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');
 if (!$action) $action = (isset($HTTP_POST_VARS['action']) ? $HTTP_POST_VARS['action'] : '');
 if ($action == 'add_product_attributes') $action = (isset($HTTP_POST_VARS['action']) ? $HTTP_POST_VARS['action'] : '');
 $attribute_page = (isset($HTTP_GET_VARS['attribute_page']) ? $HTTP_GET_VARS['attribute_page'] : 1);
 //if (!$attribute_page) $attribute_page = (isset($HTTP_POST_VARS['attribute_page']) ? $HTTP_POST_VARS['attribute_page'] : 1);


 $products_id_view = (isset($HTTP_GET_VARS['products_id_view']) ? $HTTP_GET_VARS['products_id_view'] : '');
 if (!$products_id_view) $products_id_view = (isset($HTTP_POST_VARS['products_id_view']) ? $HTTP_POST_VARS['products_id_view'] : '');
 $products_id_master = $HTTP_POST_VARS['products_id_master'];
 if ($products_id_master) { $products_id_view = $products_id_master; }

 if (tep_not_null($action)) {
   $page_info = '';
   if (isset($HTTP_GET_VARS['attribute_page'])) $page_info .= 'attribute_page=' . $HTTP_GET_VARS['attribute_page'] . '&';
   if (tep_not_null($page_info)) {
     $page_info = substr($page_info, 0, -1);
   }

   switch ($action) {
     case 'Insert':
       $products_id_master = tep_db_prepare_input($HTTP_POST_VARS['products_id_master']);
       $products_id_slave = tep_db_prepare_input($HTTP_POST_VARS['products_id_slave']);
       $pop_order_id = tep_db_prepare_input($HTTP_POST_VARS['pop_order_id']);
       if ($products_id_master != $products_id_slave) {
         $check = tep_db_query("select p.pop_id from " . TABLE_PRODUCTS_RELATED_PRODUCTS . " p where p.pop_products_id_master=" . $products_id_master ." and p.pop_products_id_slave=" . $products_id_slave);
         if (!tep_db_fetch_array($check)) {
           tep_db_query("insert into " . TABLE_PRODUCTS_RELATED_PRODUCTS . " values ('', '" . (int)$products_id_master . "', '" . (int)$products_id_slave . "', '". (int)$pop_order_id."')");
         }
       }
       tep_redirect(tep_href_link(FILENAME_RELATED_PRODUCTS, $page_info.'&products_id_master='.$products_id_master.'&products_id_slave='.$products_id_slave.'&products_id_view='.$products_id_view));
       break;

     case 'Reciprocate':
       $products_id_master = tep_db_prepare_input($HTTP_POST_VARS['products_id_master']);
       $products_id_slave = tep_db_prepare_input($HTTP_POST_VARS['products_id_slave']);
       $pop_order_id = tep_db_prepare_input($HTTP_POST_VARS['pop_order_id']);
       if ($products_id_master != $products_id_slave) {
         $check = tep_db_query("select p.pop_id from " . TABLE_PRODUCTS_RELATED_PRODUCTS . " p where p.pop_products_id_master=" . $products_id_master ." and p.pop_products_id_slave=" . $products_id_slave);
         if (!tep_db_fetch_array($check)) {
           tep_db_query("insert into " . TABLE_PRODUCTS_RELATED_PRODUCTS . " values ('', '" . (int)$products_id_master . "', '" . (int)$products_id_slave . "', '". (int)$pop_order_id."')");
         }
         $check = tep_db_query("select p.pop_id from " . TABLE_PRODUCTS_RELATED_PRODUCTS . " p where p.pop_products_id_master=" . $products_id_slave ." and p.pop_products_id_slave=" . $products_id_master );
         if (!tep_db_fetch_array($check)) {
           tep_db_query("insert into " . TABLE_PRODUCTS_RELATED_PRODUCTS . " values ('', '" . (int)$products_id_slave . "', '" . (int)$products_id_master . "', '". (int)$pop_order_id."')");
         }
       }
       tep_redirect(tep_href_link(FILENAME_RELATED_PRODUCTS, $page_info.'&products_id_master='.$products_id_master.'&products_id_slave='.$products_id_slave.'&products_id_view='.$products_id_view));
       break;

     case 'Inherit':
       $products_id_master = tep_db_prepare_input($HTTP_POST_VARS['products_id_master']);
       $products_id_slave = tep_db_prepare_input($HTTP_POST_VARS['products_id_slave']);
       $pop_order_id = tep_db_prepare_input($HTTP_POST_VARS['pop_order_id']);

       if ($products_id_master != $products_id_slave) {
         if (INSERT_AND_INHERIT == 'True') {
           $check = tep_db_query("select p.pop_id from " . TABLE_PRODUCTS_RELATED_PRODUCTS . " p where p.pop_products_id_master=" . $products_id_master." and p.pop_products_id_slave=" . $products_id_slave);
           if (!tep_db_fetch_array($check)) {
              tep_db_query("insert into " . TABLE_PRODUCTS_RELATED_PRODUCTS . " values ('', '" . (int)$products_id_master . "', '" . (int)$products_id_slave . "', '". (int)$pop_order_id."')");
           }
         }
         $products = tep_db_query("select p.pop_products_id_slave from " . TABLE_PRODUCTS_RELATED_PRODUCTS . " p where p.pop_products_id_master=" . $products_id_slave . " order by p.pop_id");
         while ($products_values = tep_db_fetch_array($products)) {
           $products_id_slave2 = $products_values['pop_products_id_slave'];
           if ($products_id_master != $products_id_slave2) {

             $check = tep_db_query("select p.pop_id from " . TABLE_PRODUCTS_RELATED_PRODUCTS . " p where p.pop_products_id_master=" . $products_id_master." and p.pop_products_id_slave=" . $products_id_slave2);
             if (!tep_db_fetch_array($check)) {
               tep_db_query(" insert into " . TABLE_PRODUCTS_RELATED_PRODUCTS . " values ('', '" . (int)$products_id_master . "', '" . (int)$products_id_slave2 . "', '". (int)$pop_order_id."')");
             }
           }
         }
       }
       tep_redirect(tep_href_link(FILENAME_RELATED_PRODUCTS, $page_info.'&products_id_master='.$products_id_master.'&products_id_slave='.$products_id_slave.'&products_id_view='.$products_id_view));
       break;

     case 'update_product_attribute':
       $products_id_master = tep_db_prepare_input($HTTP_POST_VARS['products_id_master']);
       $products_id_slave = tep_db_prepare_input($HTTP_POST_VARS['products_id_slave']);
       $pop_order_id = tep_db_prepare_input($HTTP_POST_VARS['pop_order_id']);
       $pop_id = tep_db_prepare_input($HTTP_POST_VARS['pop_id']);

       tep_db_query("update " . TABLE_PRODUCTS_RELATED_PRODUCTS . " set pop_products_id_master = '" . (int)$products_id_master . "', pop_products_id_slave = '" . (int)$products_id_slave . "', pop_order_id = '".(int)$pop_order_id."' where pop_id = '" . (int)$pop_id . "'");
       tep_redirect(tep_href_link(FILENAME_RELATED_PRODUCTS, $page_info.'&products_id_view='.$products_id_view));
       break;
     case 'delete_attribute':
       $pop_id = tep_db_prepare_input($HTTP_GET_VARS['pop_id']);

       tep_db_query("delete from " . TABLE_PRODUCTS_RELATED_PRODUCTS . " where pop_id = '" . (int)$pop_id . "'");

       tep_redirect(tep_href_link(FILENAME_RELATED_PRODUCTS, $page_info.'&products_id_view='.$products_id_view));
       break;
   }
 }
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<?php require(DIR_WS_INCLUDES . 'header.php'); /* header */?>
<table border="0" width="100%" cellspacing="2" cellpadding="2">
 <tr>
   <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
<?php require(DIR_WS_INCLUDES . 'column_left.php'); /* left navigation */ ?>
   </table></td>
   <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
     <tr>
       <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td class="pageHeading"> <?php echo HEADING_TITLE_ATRIB; ?> </td>
           <td><form method="post" action="<?php echo tep_href_link(FILENAME_RELATED_PRODUCTS, '', 'NONSSL');?>" name="formview"><select name="products_id_view" onChange="this.form.submit();">
<?php

   echo '<option name="Show All Products" value="">Show All Products</option>';
   $products = tep_db_query("select p.products_id, p.products_model, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id = p.products_id and pd.language_id = '" . $languages_id . "' order by pd.products_name");
   while ($products_values = tep_db_fetch_array($products)) {
       $model = (RELATED_PRODUCTS_ADMIN_USE_MODEL == 'True')?$products_values['products_model'] . RELATED_PRODUCTS_ADMIN_MODEL_SEPARATOR:'';
       $name = (RELATED_PRODUCTS_ADMIN_USE_NAME == 'True')?$products_values['products_name']:'';
       if ($products_id_view == $products_values['products_id']) {
             echo '<option name="' . $name . '" value="' . $products_values['products_id'] . '" selected="selected">' . $model . $name . '</option>';
       } else {
             echo '<option name="' . $name . '" value="' . $products_values['products_id'] . '">' . $model . $name . '</option>';
       }
   }
?>
           </select></form> </td>
           <td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '53'); ?> </td>
         </tr>
       </table></td>
     </tr>
     <tr>
<?php
/*
foreach ($HTTP_POST_VARS as $key => $value) {
  echo "Key: $key; Value: $value<br>\n";
}
*/
 if ($action == 'update_attribute') {
   $form_action = 'update_product_attribute';
 } else {
   $form_action = 'add_product_attributes';
 }

 if (!isset($attribute_page)) {
   $attribute_page = 1;
 }
 $prev_attribute_page = $attribute_page - 1;
 $next_attribute_page = $attribute_page + 1;
 $form_params = 'action=' . $form_action . '&attribute_page=' . $attribute_page;
?>
       <td><form name="attributes" action="<?php echo tep_href_link(FILENAME_RELATED_PRODUCTS, $form_params); ?>" method="post"><table border="0" width="100%" cellspacing="0" cellpadding="2">
         <tr>
           <td colspan="5" class="smallText">
<?php


 $per_page = RELATED_PRODUCTS_MAX_ROW_LISTS_OPTIONS;
 $attributes = "
        SELECT
               pa.*
          FROM " .
               TABLE_PRODUCTS_RELATED_PRODUCTS . " pa
          LEFT JOIN " .
               TABLE_PRODUCTS_DESCRIPTION . " pd
            ON pa.pop_products_id_master = pd.products_id
           AND pd.language_id = '" . (int)$languages_id . "'";

 if ($products_id_view) { $attributes .= "
         WHERE pd.products_id = '$products_id_view'"; }
 $attributes .= "
      ORDER BY pd.products_name, pa.pop_order_id, pa.pop_id";

 $attribute_query = tep_db_query($attributes);

 $attribute_page_start = ($per_page * $attribute_page) - $per_page;
 $num_rows = tep_db_num_rows($attribute_query);

 if ($num_rows <= $per_page) {
    $num_pages = 1;
 } else if (($num_rows % $per_page) == 0) {
    $num_pages = ($num_rows / $per_page);
 } else {
    $num_pages = ($num_rows / $per_page) + 1;
 }
 $num_pages = (int) $num_pages;

 $attributes = $attributes . " LIMIT $attribute_page_start, $per_page";

 $view_id = '';
 if ($products_id_view) {
   $products_id_view = $products_id_master?$products_id_master:$products_id_view;
   $view_id = '&products_id_view=' . $products_id_view;
 }

 // Previous
 if ($prev_attribute_page) {
   echo '<a href="' . tep_href_link(FILENAME_RELATED_PRODUCTS, 'attribute_page=' . $prev_attribute_page . $view_id) . '"> << </a> | ';
 }

 for ($i = 1; $i <= $num_pages; $i++) {
   if ($i != $attribute_page) {
     echo '<a href="' . tep_href_link(FILENAME_RELATED_PRODUCTS, 'attribute_page=' . $i . $view_id)  . '">' . $i . '</a> | ';
   } else {
     echo '<b><font color="red">' . $i . '</font></b> | ';
   }
 }

 // Next
 if ($attribute_page != $num_pages) {
   echo '<a href="' . tep_href_link(FILENAME_RELATED_PRODUCTS, 'attribute_page=' . $next_attribute_page . $view_id) . '"> >> </a>';
 }
?>
           </td>
         </tr>
         <tr>
           <td colspan="5"><?php echo tep_black_line(); ?></td>
         </tr>
         <tr class="dataTableHeadingRow">
           <td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_ID; ?> </td>
           <td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_PRODUCT; ?>(To) </td>
           <td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_PRODUCT; ?>(From) </td>
           <td class="dataTableHeadingContent" align="center"> <?php echo TABLE_HEADING_ORDER; ?> </td>
           <td class="dataTableHeadingContent" align="center"> <?php echo TABLE_HEADING_ACTION; ?> </td>
         </tr>
         <tr>
           <td colspan="5"><?php echo tep_black_line(); ?></td>
         </tr>
<?php
 $next_id = 1;
 $attributes = tep_db_query($attributes);
 while ($attributes_values = tep_db_fetch_array($attributes)) {
   $products_name_master = tep_get_products_name($attributes_values['pop_products_id_master']);
   $products_name_slave = tep_get_products_name($attributes_values['pop_products_id_slave']);
   if (RELATED_PRODUCTS_ADMIN_USE_MODEL == 'True') {
     $mModel = tep_get_products_model($attributes_values['pop_products_id_master']) . RELATED_PRODUCTS_ADMIN_MODEL_SEPARATOR . ' ';
     $sModel = tep_get_products_model($attributes_values['pop_products_id_slave']) . RELATED_PRODUCTS_ADMIN_MODEL_SEPARATOR . ' ';
   } else {
     $mModel = $sModel = '';
   }
   $pop_order_id = $attributes_values['pop_order_id'];
   $rows++;
?>
         <tr class="<?php echo (floor($rows/2) == ($rows/2) ? 'attributes-even' : 'attributes-odd'); ?>">
<?php
   if (($action == 'update_attribute') && ($HTTP_GET_VARS['pop_id'] == $attributes_values['pop_id'])) {
?>
           <td class="smallText"> <?php echo $attributes_values['pop_id']; ?><input type="hidden" name="pop_id" value="<?php echo $attributes_values['pop_id']; ?>"> </td>
           <td class="smallText"> <select name="products_id_master">
<?php
     $products = tep_db_query("select p.products_id, p.products_model, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id = p.products_id and pd.language_id = '" . $languages_id . "' order by pd.products_name");
     while($products_values = tep_db_fetch_array($products)) {
       $model = (RELATED_PRODUCTS_ADMIN_USE_MODEL == 'True')?$products_values['products_model'] . RELATED_PRODUCTS_ADMIN_MODEL_SEPARATOR:'';
       $name = (RELATED_PRODUCTS_ADMIN_USE_NAME == 'True')?$products_values['products_name']:'';
       $product_name = (RELATED_PRODUCTS_MAX_NAME_LENGTH == '0')?$name:substr($name, 0, RELATED_PRODUCTS_MAX_NAME_LENGTH);
       if ($attributes_values['pop_products_id_master'] == $products_values['products_id']) {
         echo "\n" . '<option name="' . $products_values['products_name'] . '" value="' . $products_values['products_id'] . '" selected="selected">' . $model . $product_name . '</option>';
       } else {
         echo "\n" . '<option name="' . $products_values['products_name'] . '" value="' . $products_values['products_id'] . '">' . $model . $product_name . '</option>';
       }
     }
?>
           </select> </td>
           <td class="smallText"> <select name="products_id_slave">
<?php
     $products = tep_db_query("select p.products_id, p.products_model, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id = p.products_id and pd.language_id = '" . $languages_id . "' order by pd.products_name");
     while($products_values = tep_db_fetch_array($products)) {
       $model = (RELATED_PRODUCTS_ADMIN_USE_MODEL == 'True')?$products_values['products_model'] . RELATED_PRODUCTS_ADMIN_MODEL_SEPARATOR:'';
       $name = (RELATED_PRODUCTS_ADMIN_USE_NAME == 'True')?$products_values['products_name']:'';
       $product_name = (RELATED_PRODUCTS_MAX_NAME_LENGTH == '0')?$name:substr($name, 0, RELATED_PRODUCTS_MAX_NAME_LENGTH);
       if ($attributes_values['pop_products_id_slave'] == $products_values['products_id']) {
         echo "\n" . '<option name="' . $products_values['products_name'] . '" value="' . $products_values['products_id'] . '" selected="selected">' . $model . $product_name . '</option>';
       } else {
         echo "\n" . '<option name="' . $products_values['products_name'] . '" value="' . $products_values['products_id'] . '">' . $model . $product_name . '</option>';
       }
     }
?>
           </select> </td>
           <td align="center" class="smallText"> <input type="text" name="pop_order_id" value="<?php echo $attributes_values['pop_order_id']; ?>" size="6"> </td>
           <td align="center" class="smallText"> <input type="hidden" name="action" value="update_product_attribute"><?php echo tep_image_submit('button_update.gif', IMAGE_UPDATE); ?> <?php echo '<a href="' . tep_href_link(FILENAME_RELATED_PRODUCTS, '&attribute_page=' . $attribute_page . '&products_id_view='.$products_id_view, 'NONSSL') . '">'; ?><?php echo tep_image_button('button_cancel.gif', IMAGE_CANCEL); ?></a> </td>
<?php
   } else {
//  basic browse table list
?>
           <td class="smallText"> <?php echo $attributes_values["pop_id"]; ?> </td>
           <td class="smallText"> <?php echo $mModel ?><?php echo (RELATED_PRODUCTS_MAX_DISPLAY_LENGTH== '0')?$products_name_master:substr($products_name_master, 0, RELATED_PRODUCTS_MAX_DISPLAY_LENGTH); ?> </td>
           <td class="smallText"> <?php echo $sModel ?><?php echo (RELATED_PRODUCTS_MAX_DISPLAY_LENGTH== '0')?$products_name_slave:substr($products_name_slave, 0, RELATED_PRODUCTS_MAX_DISPLAY_LENGTH); ?> </td>
           <td class="smallText" align="center"> <?php echo $pop_order_id; ?> </td>
           <td align="center" class="smallText">

              <?php
                $params = 'action=update_attribute&pop_id='
                         . $attributes_values['pop_id']
                         . '&attribute_page=' . $attribute_page
                         . '&products_id_view=' . $products_id_view;
                    echo '<a href="' . tep_href_link(FILENAME_RELATED_PRODUCTS, $params, 'NONSSL') . '">'; ?>
                    Edit</a>  
              <?php
                $params = 'action=delete_attribute&pop_id='
                         . $attributes_values['pop_id']
                         . '&attribute_page=' . $attribute_page
                         . '&products_id_view=' . $products_id_view;
                    if (RELATED_PRODUCTS_CONFIRM_DELETE == 'False') { ?>
              <a href="<?php echo tep_href_link(FILENAME_RELATED_PRODUCTS, $params, 'NONSSL')?>">Delete</a>
              <?php }else { ?>
              <a href="<?php echo tep_href_link(FILENAME_RELATED_PRODUCTS, $params, 'NONSSL')?>" onclick="return confirm('<?php echo sprintf(TEXT_CONFIRM_DELETE_ATTRIBUTE, addslashes($products_name_slave), addslashes($products_name_master)); ?>');">Delete</a>
              <?php } ?></td>
<?php
   }
   $max_attributes_id_query = tep_db_query("select max(pop_id) + 1 as next_id from " . TABLE_PRODUCTS_RELATED_PRODUCTS);
   $max_attributes_id_values = tep_db_fetch_array($max_attributes_id_query);
   $next_id = $max_attributes_id_values['next_id'];
?>
         </tr>
<?php
 }
 if ($action != 'update_attribute') {
?>
         <tr>
           <td colspan="5"><?php echo tep_black_line(); ?></td>
         </tr>
         <tr class="<?php echo (floor($rows/2) == ($rows/2) ? 'attributes-even' : 'attributes-odd'); ?>">
           <td class="smallText"> <?php echo $next_id; ?> </td>
     	    <td class="smallText"><b>A:</b> <select name="products_id_master">
<?php
   $products = tep_db_query("select p.products_id, p.products_model, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id = p.products_id and pd.language_id = '" . $languages_id . "' order by pd.products_name");
   $products_id_master = $HTTP_POST_VARS['products_id_master'];
   if (!$products_id_master) { $products_id_master = $products_id_view; }
   while ($products_values = tep_db_fetch_array($products)) {
     $model = (RELATED_PRODUCTS_ADMIN_USE_MODEL == 'True')?$products_values['products_model'] . RELATED_PRODUCTS_ADMIN_MODEL_SEPARATOR:'';
     $name = (RELATED_PRODUCTS_ADMIN_USE_NAME == 'True')?$products_values['products_name']:'';
     $product_name = (RELATED_PRODUCTS_MAX_NAME_LENGTH == '0')?$name:substr($name, 0, RELATED_PRODUCTS_MAX_NAME_LENGTH);
     if ($products_id_master == $products_values['products_id']) {
       echo '<option name="' . $products_values['products_name'] . '" value="' . $products_values['products_id'] . '" selected="selected">' . $model . $product_name . '</option>';
     } else {
       echo '<option name="' . $products_values['products_name'] . '" value="' . $products_values['products_id'] . '">' . $model . $product_name . '</option>';
     }
   }
?>
           </select> </td>
           <td class="smallText"><b>B:</b> <select name="products_id_slave">
<?php
   $products = tep_db_query("select p.products_id, p.products_model, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id = p.products_id and pd.language_id = '" . $languages_id . "' order by pd.products_name");
   while ($products_values = tep_db_fetch_array($products)) {
     $model = (RELATED_PRODUCTS_ADMIN_USE_MODEL == 'True')?$products_values['products_model'] . RELATED_PRODUCTS_ADMIN_MODEL_SEPARATOR:'';
     $name = (RELATED_PRODUCTS_ADMIN_USE_NAME == 'True')?$products_values['products_name']:'';
     $product_name = (RELATED_PRODUCTS_MAX_NAME_LENGTH == '0')?$name:substr($name, 0, RELATED_PRODUCTS_MAX_NAME_LENGTH);
     if ($HTTP_POST_VARS['products_id_slave'] == $products_values['products_id']) {
       echo '<option name="' . $products_values['products_name'] . '" value="' . $products_values['products_id'] . '" selected="selected">' . $model . $product_name . '</option>';
     } else {
       echo '<option name="' . $products_values['products_name'] . '" value="' . $products_values['products_id'] . '">' . $model . $product_name . '</option>';
     }
   }
?>
           </select> </td>
           <td class="smallText" align="center"> <input type="text" name="pop_order_id" size="3"> </td>
         </tr>
         <tr><td colspan="5" align="center" class="smallText">
           <input type="submit" name="action" value="Insert">
           <input type="submit" name="action" value="Reciprocate">
           <input type="submit" name="action" value="Inherit">
         </td></tr>
<?php
 }
?>
         <tr>
           <td colspan="5"><?php echo tep_black_line(); ?></td>
         </tr>
       </table>
       <input type="hidden" name="products_id_view" value="<?php echo $products_id_view; ?>">
       </form></td>
     </tr>
   </table></td>
 </tr>
</table>
<?php require(DIR_WS_INCLUDES . 'footer.php'); /* footer */?>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

 

Hope this is useful for all of you…

 

Kind regards,

 

Claudiu Marginean

Junior PHP Programmer

Share this post


Link to post
Share on other sites

PRODUCT SORT

I was having the same problem as Becki from way back in 07, but Skittles fix helped me get my related product in order! Thanks Skittles!

Share this post


Link to post
Share on other sites

I have successfully installed Optional Related Products, and i think this is a great contribution. Cheers!

 

does anyone know how to use Optional Related Products like this website:

 

http://houseracket.com/floor/catalog/product_info.php?products_id=2231

 

i just want to know how to do the checkbox bit and link it to the one add to cart button on product_info page. therefore this will add both the product_info pages' product and the selected related products in one go.

 

Cheers in advance

Share this post


Link to post
Share on other sites

I've installed a new installation, and I've got an error when running SQL Setup Utility

 

The error was "incorrect integer value for column 'configuration_group_id'"

 

I'm using MySQL 5.1.30-community

 

I've resolved the problem by replacing in sql_setup_related_products.php all the empty strings within the INSERT sentences with NULL:

 

    if (!$gid) {
     tep_db_query("INSERT INTO `configuration_group` VALUES ( NULL, 'Related Products', 'Optional Related Products module', '999', '1' )");
     $set_group_id = tep_db_insert_id();
   } else {
     $set_group_id = $gid;
   }
   tep_db_query("INSERT INTO `configuration`
                 VALUES (NULL, 'Current Version', 'RELATED_PRODUCTS_VERSION_INSTALLED', '4.0', 'This key is used by the SQL install to automatically update your database during upgrades. It is read only.', " . $set_group_id . ", '0', NULL, now(), NULL , 'tep_version_readonly('),
                        (NULL, 'Display Thumbnail Images', 'RELATED_PRODUCTS_SHOW_THUMBS', 'True', 'Show Product Image', " . $set_group_id . ", '1', NULL, now(), NULL , 'tep_cfg_select_option(array(\'True\', \'False\'),'),
                        (NULL, 'Display Product Name', 'RELATED_PRODUCTS_SHOW_NAME', 'True', 'Show Product Name', " . $set_group_id . ", 2, NULL, now(),NULL,'tep_cfg_select_option(array(\'True\', \'False\'),'),
                        (NULL, 'Display Product Model', 'RELATED_PRODUCTS_SHOW_MODEL', 'False', 'Show Product Model', " . $set_group_id . ", 3, NULL, now(),NULL,'tep_cfg_select_option(array(\'True\', \'False\'),'),
                        (NULL, 'Display Price', 'RELATED_PRODUCTS_SHOW_PRICE', 'True', 'Show Product Price', " . $set_group_id . ", 4, NULL, now(),NULL,'tep_cfg_select_option(array(\'True\', \'False\'),'),
                        (NULL, 'Display Quantity Available', 'RELATED_PRODUCTS_SHOW_QUANTITY', 'False', 'Show Product Quantity', " . $set_group_id . ", 5, NULL, now(),NULL,'tep_cfg_select_option(array(\'True\', \'False\'),'),
                        (NULL, 'Display Buy Now Button', 'RELATED_PRODUCTS_SHOW_BUY_NOW', 'False', 'Show Buy Now Button', " . $set_group_id . ", 6, NULL, now(),NULL,'tep_cfg_select_option(array(\'True\', \'False\'),'),
                        (NULL, 'Split Display Into Rows','RELATED_PRODUCTS_USE_ROWS','False','Set this option to True to display Related Products in multiple rows.'," . $set_group_id . ", 7,NULL, now(),NULL,'tep_cfg_select_option(array(\'True\', \'False\'),'),
                        (NULL, 'Define Number of Items Per Row','RELATED_PRODUCTS_PER_ROW','3','Maximum number of items to display per row when Split Display Into Rows is set to True.'," . $set_group_id . ", 8,NULL, now(),NULL,''),
                        (NULL, 'Define Number of Items to Display', 'RELATED_PRODUCTS_MAX_DISP', '0', 'Maximum number of Related Products to display. 0 is unlimited.', " . $set_group_id . ", 9, NULL, now(),NULL,''),
                        (NULL, 'Use Random Display Order', 'RELATED_PRODUCTS_RANDOMIZE', 'False', 'Adds random sort order to products displayed. Recommended if maximum number of products is set.', " . $set_group_id . ", 10, NULL, now(),NULL,'tep_cfg_select_option(array(\'True\', \'False\'),'),
                        (NULL, 'Admin Display: Maximum Rows', 'RELATED_PRODUCTS_MAX_ROW_LISTS_OPTIONS', '10', 'Sets the maximum number of rows to display per page.', " . $set_group_id . ", 11, NULL, now(),NULL,''),
                        (NULL, 'Admin Display: Drop-Down List Maximum Length', 'RELATED_PRODUCTS_MAX_NAME_LENGTH', '25', 'Sets the maximum length (in characters) of product name displayed in drop-down lists. Enter \'0\' to set this option to false.', " . $set_group_id . ", 12, NULL, now(),NULL,''),
                        (NULL, 'Admin Display: Display List Maximum Length', 'RELATED_PRODUCTS_MAX_DISPLAY_LENGTH', '0', 'Sets the maximum length (in characters) of product name displayed in list. Enter \'0\' to set this option to false.', " . $set_group_id . ", 13, NULL, now(),NULL,''),
                        (NULL, 'Admin Display: Use Product Model', 'RELATED_PRODUCTS_ADMIN_USE_MODEL', 'False', 'Uses Product Model in lists. When Product Name is also selected, Product Model is displayed first.', " . $set_group_id . ", 14, NULL, now(),NULL,'tep_cfg_select_option(array(\'True\', \'False\'),'),
                        (NULL, 'Admin Display: Use Product Name', 'RELATED_PRODUCTS_ADMIN_USE_NAME', 'True', 'Uses Product Name in lists. When Product Model is also selected, Product Model is displayed first.', " . $set_group_id . ", 15, NULL, now(),NULL,'tep_cfg_select_option(array(\'True\', \'False\'),'),
                        (NULL, 'Admin Display: Combine Model and Name separator', 'RELATED_PRODUCTS_ADMIN_MODEL_SEPARATOR', ': ', 'Enter the characters you would like to separate Model from Name, when using both. Leave empty if only using Model.', " . $set_group_id . ", 16, NULL, now(),NULL,''),
                        (NULL, 'Admin Function: Use Delete Confirmation', 'RELATED_PRODUCTS_CONFIRM_DELETE', 'True', 'When set to True, a confirmation box will pop-up when deleting an association. Set to False to Delete without confirmation.', " . $set_group_id . ", 17, NULL, now(),NULL,'tep_cfg_select_option(array(\'True\', \'False\'),'),
                        (NULL, 'Admin Function: Combine Insert with Inherit', 'RELATED_PRODUCTS_INSERT_AND_INHERIT', 'True', 'When set to True, clicking on Inherit will also Insert the product association. When False, Inherit works as before.', " . $set_group_id . ", 18, NULL, now(),NULL,'tep_cfg_select_option(array(\'True\', \'False\'),')
                       ");
 }

Edited by eromera

Share this post


Link to post
Share on other sites

Hello,

This may be a stupid question but I see that there are two contributions doing the same or similar thing:

 

1. Optional Related Products (this one)

2. X-Sell v2-MS2 - Cross Sell for MS2

 

Can you tell me what the differences are and if this one is better than the other one?

 

Thank you,

Kevin

Share this post


Link to post
Share on other sites

Hi all,

 

I finish working on the script and I made it compatible to OScommerce alternative for writing the sessions ID as GET parameters.

This also fix the log-out redirect and the page navigation bug.

 

This is the code for all the [OScommerce_root_folder/]catalog/admin/optional_related_products.php file:

 

<?php
/*

</table>
<?php require(DIR_WS_INCLUDES . 'footer.php'); /* footer */?>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

 

Hope this is useful for all of you…

 

Kind regards,

 

Claudiu Marginean

Junior PHP Programmer

 

 

Hi Claudiu,

 

Thanks for this update. It works great. I was wondering if you might happen to know offhand what section of which file I edit to make changes to the box that Related Products is in. I want it to match all the boxes in the right and left columns but there's a little gap between the gray stripe at the top of the box and the edge that I can't seem to get rid of. Also, there's a empty row between the product title and the price below it in the Related Products box that I'd like to eliminate. Thanks for your help,

 

Nick

Share this post


Link to post
Share on other sites

Hi I just installed Optional Related Products 4.0_a

 

I get the drop downs

on top I get -Show all Products- but nothing else

 

the other drop downs have nothing at all

 

any Ideas

Share this post


Link to post
Share on other sites

ok my bad. Ignore that had to enable the rows Kinda silly not to have the rows enabled in the first place.

 

Working now but the Define Number of Items Per Row don't seem to do anything.

Share this post


Link to post
Share on other sites

Hi Claudiu,

 

Thanks for this update. It works great. I was wondering if you might happen to know offhand what section of which file I edit to make changes to the box that Related Products is in. I want it to match all the boxes in the right and left columns but there's a little gap between the gray stripe at the top of the box and the edge that I can't seem to get rid of. Also, there's a empty row between the product title and the price below it in the Related Products box that I'd like to eliminate. Thanks for your help,

 

Nick

 

Never mind...I should've read through this forum more carefully. All edits are done in the stylesheet of course.

Share this post


Link to post
Share on other sites

Hi all!!!

 

Great contribution, works fine but I have just one problem, hoping someone could help me to get it through.

 

I can't get appear the right price on products which have a special or discount price. I use B2B contribution and I think the problem is in there. Anyway here's the code I need to fix:

 

if ($new_price = tep_get_products_special_price($products_id_slave)) {

$products_price_slave = $currencies->display_price($new_price['products_id'], $new_price['products_price'], tep_get_tax_rate($attributes_values['products_tax_class_id']));

} else {

$products_price_slave = $currencies->display_price($attributes_values['products_id'], $attributes_values['products_price'], tep_get_tax_rate($attributes_values['products_tax_class_id']));

 

I don't know how to set the "new_price" function, the second part of the code works fine. I guess is a silly and basic thing but I don't know where to start :)

 

Thanks ^__^

Share this post


Link to post
Share on other sites

APPRENTICE WEBM,

 

Take a look at the html User's Guide:

Be sure to click on the first image, titled 'Screenshot: Example Product Info Page', for a full size example of the product info page. Seeing what it does to the page should help you decide if you want this contrib for your store.

 

Have a great weekend,

-Skittles

what PHP version does this contribution need?

Edited by RMD27

Share this post


Link to post
Share on other sites

Hello.

I am reading what the contribution does, and how it works.

I have a question before begin working on it....

I have a 5 thousand articles in the store and I wonder if this contribution will help me or prehaps will make my life more difficult.

 

it is very cualitative, I know, but I want to hear about your experience with this

 

Thank you

Share this post


Link to post
Share on other sites

I just installed ORP and am receiving the following error when I try to install the sql.

 

1366 - Incorrect integer value: '' for column 'configuration_group_id' at row 1

INSERT INTO `configuration_group` VALUES ( '', 'Related Products', 'Optional Related Products module', '999', '1' )

 

This is a new install of ORP. Any help would be really appreciated.

Share this post


Link to post
Share on other sites

Good Afternoon

 

I have installed as it says on new install but I have this error when I try to log into admin

 

Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /homepages/39/d308468606/htdocs/catalog/admin/includes/functions/database.php on line 19

Unable to connect to database server!

 

Does anyone know why?

 

Many Thanks

Share this post


Link to post
Share on other sites

Hi Claudiu.

 

I have been having this same problem with Optional Related Products and some other contributions with the same result. I have tried the above and end up getting the same thing.... Back to the login prompt for admin.

 

I can not for the life of me figure this out. I have installed many contributions with no problems, but forms with the get rather than post has me stumped. Think it has something to do with the osCAdminID also in the URL. My browser is accepting cookies but the admin side does not generate any either for browser to accept. All other functions of the catalog from the store front side work perfectly. Hmmm...

 

Any one have a solution to this rather than rewriting the whole page's form handling?

 

Thanks!

Phil

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×