Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Optional Related Products - how to modify?


georgei

Recommended Posts

Hey all,

 

Can someone help me modify this code from the optional related products contribution to display products in 3 rows, instead of horizontally please?

 

// DANIEL: begin - show related products
 if (SHOW_INACTIVE_PRODUCTS=='True') {
$attributes = "select pop_products_id_slave, products_name, products_status, products_price, products_tax_class_id, products_image from " . TABLE_PRODUCTS_OPTIONS_PRODUCTS . ", " . TABLE_PRODUCTS_DESCRIPTION . " pa, ". TABLE_PRODUCTS . " pb WHERE pop_products_id_slave = pa.products_id and pa.products_id=pb.products_id and language_id = '" . (int)$languages_id . "' and pop_products_id_master = '".$HTTP_GET_VARS['products_id']."' order by pop_order_id, pop_id";
 } else {
$attributes = "select pop_products_id_slave, products_name, products_status, products_price, products_tax_class_id, products_image from " . TABLE_PRODUCTS_OPTIONS_PRODUCTS . ", " . TABLE_PRODUCTS_DESCRIPTION . " pa, ". TABLE_PRODUCTS . " pb WHERE pop_products_id_slave = pa.products_id and pa.products_id=pb.products_id and language_id = '" . (int)$languages_id . "' and pop_products_id_master = '".$HTTP_GET_VARS['products_id']."' and products_status=1 order by pop_order_id, pop_id";
 }
 $attribute_query = tep_db_query($attributes);

 if (mysql_num_rows($attribute_query)>0) {

  echo '<tr><td><table class="productlisting" border="0" cellspacing="0" cellpadding="2" width="100%">';
  echo '<tr><td align="center" class="productListing-heading" > '.TEXT_RELATED_PRODUCTS.' </td></tr><tr><td align="center" class="productListing-data">';
  echo '<table border="0" cellspacing="0" cellpadding="2" width="100%" align="center"><Tr>';

while ($attributes_values = tep_db_fetch_array($attribute_query)) {
  $products_name_slave = ($attributes_values['products_name']);
  $products_id_slave = ($attributes_values['pop_products_id_slave']);
  if ($new_price = tep_get_products_special_price($products_id_slave)) {
	$products_price_slave = $currencies->display_price($new_price, tep_get_tax_rate($attributes_values['products_tax_class_id']));
  } else {
	$products_price_slave = $currencies->display_price($attributes_values['products_price'], tep_get_tax_rate($attributes_values['products_tax_class_id']));
  }

// show thumb image if Enabled
echo '<td class="productListing-data" align="center">';
  //if (MODULE_RELATED_PRODUCTS_SHOW_THUMBS!='False') {
  //  echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_id_slave) . '">' . tep_image(DIR_WS_IMAGES . $attributes_values['products_image'], $attributes_values['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"').'</a>';
  //}
  //echo '<Br> <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_id_slave) . '">'.$products_name_slave.'<Br>@ '.$products_price_slave.'</a>';
  //. '/action/buy_now">' .
  echo '<table cellpadding=0 cellspacing=0><tr><td height=36 align=center><a class="greenText" href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_id_slave) . '">' . $products_name_slave . '</a></td></tr></table>';
  if (MODULE_RELATED_PRODUCTS_SHOW_THUMBS!='False') {
  echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_id_slave) . '">' . tep_image(DIR_WS_IMAGES . $attributes_values['products_image'], $products_name_slave, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'style="margin:4px;"') . '</a>';
  }
  echo '<br><span class="priceText">' . $currencies->display_price($attributes_values['products_price'], tep_get_tax_rate($attributes_values['products_tax_class_id'])) . '</span>';
  if ($attributes_values['products_status']==1){
	echo '<br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_id_slave) . '/action/buy_now">' . tep_image_button('button_add_to_cart.gif', IMAGE_BUTTON_ADD_TO_CART) . '</a><br> <a href="http://www.ewish.com/merchants/atr.cfm?storeid=481240&gifttype=blank" target=EwishLogon>'.tep_image_button('button_addtoreg.gif', IMAGE_BUTTON_ADD_TO_CART).'</a>';
  } else {
	echo '<br>' . tep_image('images/line_add_to_cart.gif') . '<br><span class="redText">Out of Stock</span>';
  }
}
echo '</td>';

echo '</tr></table></td></tr></table></td></tr>';
}
//DANIEL: end

Link to comment
Share on other sites

  • 3 weeks later...
  • Replies 105
  • Created
  • Last Reply

Top Posters In This Topic

Hey all,

 

Can someone help me modify this code from the optional related products contribution to display products in 3 rows, instead of horizontally please?

 

// DANIEL: begin - show related products
 if (SHOW_INACTIVE_PRODUCTS=='True') {
$attributes = "select pop_products_id_slave, products_name, products_status, products_price, products_tax_class_id, products_image from " . TABLE_PRODUCTS_OPTIONS_PRODUCTS . ", " . TABLE_PRODUCTS_DESCRIPTION . " pa, ". TABLE_PRODUCTS . " pb WHERE pop_products_id_slave = pa.products_id and pa.products_id=pb.products_id and language_id = '" . (int)$languages_id . "' and pop_products_id_master = '".$HTTP_GET_VARS['products_id']."' order by pop_order_id, pop_id";
 } else {
$attributes = "select pop_products_id_slave, products_name, products_status, products_price, products_tax_class_id, products_image from " . TABLE_PRODUCTS_OPTIONS_PRODUCTS . ", " . TABLE_PRODUCTS_DESCRIPTION . " pa, ". TABLE_PRODUCTS . " pb WHERE pop_products_id_slave = pa.products_id and pa.products_id=pb.products_id and language_id = '" . (int)$languages_id . "' and pop_products_id_master = '".$HTTP_GET_VARS['products_id']."' and products_status=1 order by pop_order_id, pop_id";
 }
 $attribute_query = tep_db_query($attributes);

 if (mysql_num_rows($attribute_query)>0) {

  echo '<tr><td><table class="productlisting" border="0" cellspacing="0" cellpadding="2" width="100%">';
  echo '<tr><td align="center" class="productListing-heading" > '.TEXT_RELATED_PRODUCTS.' </td></tr><tr><td align="center" class="productListing-data">';
  echo '<table border="0" cellspacing="0" cellpadding="2" width="100%" align="center"><Tr>';

while ($attributes_values = tep_db_fetch_array($attribute_query)) {
  $products_name_slave = ($attributes_values['products_name']);
  $products_id_slave = ($attributes_values['pop_products_id_slave']);
  if ($new_price = tep_get_products_special_price($products_id_slave)) {
	$products_price_slave = $currencies->display_price($new_price, tep_get_tax_rate($attributes_values['products_tax_class_id']));
  } else {
	$products_price_slave = $currencies->display_price($attributes_values['products_price'], tep_get_tax_rate($attributes_values['products_tax_class_id']));
  }

// show thumb image if Enabled
echo '<td class="productListing-data" align="center">';
  //if (MODULE_RELATED_PRODUCTS_SHOW_THUMBS!='False') {
  //  echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_id_slave) . '">' . tep_image(DIR_WS_IMAGES . $attributes_values['products_image'], $attributes_values['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"').'</a>';
  //}
  //echo '<Br> <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_id_slave) . '">'.$products_name_slave.'<Br>@ '.$products_price_slave.'</a>';
  //. '/action/buy_now">' .
  echo '<table cellpadding=0 cellspacing=0><tr><td height=36 align=center><a class="greenText" href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_id_slave) . '">' . $products_name_slave . '</a></td></tr></table>';
  if (MODULE_RELATED_PRODUCTS_SHOW_THUMBS!='False') {
  echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_id_slave) . '">' . tep_image(DIR_WS_IMAGES . $attributes_values['products_image'], $products_name_slave, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'style="margin:4px;"') . '</a>';
  }
  echo '<br><span class="priceText">' . $currencies->display_price($attributes_values['products_price'], tep_get_tax_rate($attributes_values['products_tax_class_id'])) . '</span>';
  if ($attributes_values['products_status']==1){
	echo '<br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_id_slave) . '/action/buy_now">' . tep_image_button('button_add_to_cart.gif', IMAGE_BUTTON_ADD_TO_CART) . '</a><br> <a href="http://www.ewish.com/merchants/atr.cfm?storeid=481240&gifttype=blank" target=EwishLogon>'.tep_image_button('button_addtoreg.gif', IMAGE_BUTTON_ADD_TO_CART).'</a>';
  } else {
	echo '<br>' . tep_image('images/line_add_to_cart.gif') . '<br><span class="redText">Out of Stock</span>';
  }
}
echo '</td>';

echo '</tr></table></td></tr></table></td></tr>';
}
//DANIEL: end

 

I need help with this as well...anyone care to share their knowledge?

 

Thanks!

Link to comment
Share on other sites

  • 1 month later...

I just finished modifying this contrib for a client. I used CSS, and put it in the right column, so what I did is quite a bit different than what you folks are trying to do. However, I may be able to help.

 

Try this:

 

find:

  if (mysql_num_rows($attribute_query)>0) {

 

and add "$count = 0;" in the next line, like this:

  if (mysql_num_rows($attribute_query)>0) {
  $count = 0;

 

Then find:

		echo '<br>' . tep_image('images/line_add_to_cart.gif') . '<br><span class="redText">Out of Stock</span>';
  }

 

and add the following code directly below the bracket:

	$count++
if ($count > 2) && ($count%3 == 0) {
  echo '</tr><tr>';
}

 

The idea is simple. Start a count at zero before the "While" loop. At the end of the "While" loop, increment the count, then divide by 3. Every time the count is evenly divisible by three, the code to create a new table row is included in the string.

 

Because my sites use CSS instead of tables, I really don't have an easy way to test this. But you folks can give it a try and post the results here.

 

Another way to handle it is to limit the number of products displayed. That's actually what I did. I used a random sort order so more than three products can be related and alternately displayed.

 

Here's the query I used:

  $attributes = "select pop_products_id_slave, products_name, products_price, products_tax_class_id, products_image from " . TABLE_PRODUCTS_OPTIONS_PRODUCTS . ", " . TABLE_PRODUCTS_DESCRIPTION . " pa, ". TABLE_PRODUCTS . " pb WHERE pop_products_id_slave = pa.products_id and pa.products_id = pb.products_id and language_id = '" . (int)$languages_id . "' and pop_products_id_master = '".$HTTP_GET_VARS['products_id']."' and products_status=1 order by rand() limit " . MAX_DISPLAY_RELATED_PRODUCTS;[code]

 

(I put MAX_DISPLAY_RELATED_PRODUCTS in the admin configuration, so my client can change the number of products shown, if she wants.)

 

I also made it so new products are displayed when there aren't any related products. (With nearly a thousand designs, it's going to be a while before she gets all the related products set up!)

 

If you'd like to see it in action, you can visit the site, where my client sells t-shirts. Here's a deep link to the Halloween T-shirts category. The "Life's a Witch" kitten design has (only) three products related to it. By comparing the product page with the category index, you'll see they are different. Refresh the category page a couple of times, and you'll see the the products displayed will change.

 

Good luck. I hope this helps.

 

-Skittles

Link to comment
Share on other sites

I just finished modifying this contrib for a client. I used CSS, and put it in the right column, so what I did is quite a bit different than what you folks are trying to do. However, I may be able to help.

 

How would someone (read: customer) know that it's a related product when it's not in an obvious place for related products?

The right column is already filled with info wich is sometimes useless to a costumer.

 

To my own idea it should be directly below the item a customer is lokking at, as it is now.

Edited by i2Paq

Norman in 't Veldt

 

Moderator

osCommerce The Netherlands

Link to comment
Share on other sites

How would someone (read: customer) know that it's a related product when it's not in an obvious place for related products?

The right column is already filled with info wich is sometimes useless to a costumer.

 

To my own idea it should be directly below the item a customer is lokking at, as it is now.

 

Hi i2Paq.

 

I see you are a contributor to this contribution. I appreciate all the work that goes into modifications, and I suspect it was quite a bit of work to consolidate the various updates into one package. Thank you.

 

My client asked me to put the Related Products in the right column, so I did. :rolleyes: (Only time and testing will tell if it was a good move, or not.) Her choice to have them in the right column should not take anything away from your work on the contribution. I'm sorry if you feel it does.

 

I simply hope my previous post helps the folks that were looking for a way to force the Related Products mod to display the results in rows of three.

 

And if they want to work with the query I used, they can limit the total number of products displayed to what works for their store.

 

Nothing in my post was intended to suggest that anyone "should" put their Related Products in the sidebar rather than below the product. The link to the site is so anyone can see for themselves the effect "order by rand()" with a defined limit has on the results. The query will work the same, regardless of how the data is presented on the page.

 

By the way, my client is very pleased with the results. She got what she wanted!

 

Cheers,

-Skittles

Link to comment
Share on other sites

I just finished modifying this contrib for a client. I used CSS, and put it in the right column, so what I did is quite a bit different than what you folks are trying to do. However, I may be able to help.

 

Try this:

 

find:

  if (mysql_num_rows($attribute_query)>0) {

 

and add "$count = 0;" in the next line, like this:

  if (mysql_num_rows($attribute_query)>0) {
  $count = 0;

 

Then find:

		echo '<br>' . tep_image('images/line_add_to_cart.gif') . '<br><span class="redText">Out of Stock</span>';
  }

 

and add the following code directly below the bracket:

	$count++
if ($count > 2) && ($count%3 == 0) {
  echo '</tr><tr>';
}

 

<CLIP>

 

Hello Skittles,

 

Thanks for helping out. It's much appreciated.

 

However, your solution doesn't seem to work for me. I added the first part of the code, but I'm not sure where exactly to add the second part. Your code doesn't match mine. I attempted to place it several different spots at the end of the WHILE loop but I always receive the following error:

Parse error: parse error, unexpected T_IF in...product_info.php on line 245
.

 

Here's a copy of the my code with the first part added and the second omitted. Can you please tell me where to place the second part of your code?

 

// DANIEL: begin - show related products

$attributes = "select pop_products_id_slave, products_name, products_price, products_tax_class_id, products_image from " . TABLE_PRODUCTS_OPTIONS_PRODUCTS . ", " . TABLE_PRODUCTS_DESCRIPTION . " pa, ". TABLE_PRODUCTS . " pb WHERE pop_products_id_slave = pa.products_id and pa.products_id=pb.products_id and language_id = '" . (int)$languages_id . "' and pop_products_id_master = '".$HTTP_GET_VARS['products_id']."' and products_status=1 order by pop_order_id, pop_id";

$attribute_query = tep_db_query($attributes);

 

if (mysql_num_rows($attribute_query)>0) {

$count = 0;

 

echo '<tr><tr><td>?<br></td></tr><td><table class="productlisting" border="0" cellspacing="0" cellpadding="2" width="100%">';

echo '<tr><td align="center" class="productListing-heading" >?'.TEXT_RELATED_PRODUCTS.'?</td></tr><tr><td align="center" class="productListing-data">';

echo '<table border="0" cellspacing="0" cellpadding="2" width="100%" align="center"><Tr>';

 

while ($attributes_values = tep_db_fetch_array($attribute_query)) {

$products_name_slave = ($attributes_values['products_name']);

$products_id_slave = ($attributes_values['pop_products_id_slave']);

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

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

} else {

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

}

 

// show thumb image if Enabled

echo '<td class="productListing-data" align="center">';

if (MODULE_RELATED_PRODUCTS_SHOW_THUMBS!='True') {

echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_id_slave) . '">' . tep_image(DIR_WS_IMAGES . $attributes_values['products_image'], $attributes_values['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"').'</a>';

}

echo '<Br>?<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_id_slave) . '">'.$products_name_slave.'<Br>'.$products_price_slave.'</a>';

}

echo '</td>';

 

echo '</tr></table></td></tr></table></td></tr>';

}

//DANIEL: end

Link to comment
Share on other sites

<CLIP>

Hello Skittles,

 

Thanks for helping out. It's much appreciated.

 

However, your solution doesn't seem to work for me. I added the first part of the code, but I'm not sure where exactly to add the second part. Your code doesn't match mine. I attempted to place it several different spots at the end of the WHILE loop but I always receive the following error: .

 

Here's a copy of the my code with the first part added and the second omitted. Can you please tell me where to place the second part of your code?

Hi eyestuffguy!

 

The code I shared earlier is proof positive that one should come up for air occasionally!

 

With too many files open at the same time, I apparently grabbed the wrong line of code for reference. Then consider a few missing parentheses, semi-colons, and correct html tags, and you have a recipe for frustration... Sorry.

 

I now have a development copy of osCommerce on my computer, and I tested the code. I got it working correctly on a vanilla install.

 

Here is the correct code:

 

Find:

 if (mysql_num_rows($attribute_query)>0) {

 

and add "$count = 0;" in the next line, like this:

  if (mysql_num_rows($attribute_query)>0) {
  $count = 0;

 

Then find:

echo '<Br> <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_id_slave) . '">'.$products_name_slave.'<Br>@ '.$products_price_slave.'</a>';

 

Replace it with this code:

echo '<Br> <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_id_slave) . '">'.$products_name_slave.'<Br>@ '.$products_price_slave.'</a>';
$count++;
if (($count > 2) && ($count%3 == 0)) {
 echo '</td></tr><tr></td>';
}

(I didn't make any changes to the first line, just added my changes afterwards.)

 

Hope this works for you.

 

-Skittles

Link to comment
Share on other sites

Hi all.

 

I spent a bit more time on this, after my last post. I've refined it, added a couple more features, then uploaded it as a contribution:

 

http://www.oscommerce.com/community/contributions,2293

 

For your convenience, this contribution uses configuration options in Admin: Display items in rows, True/False; Set number of items per row, #; Set maximum number of items to display, #; and Use random sort order, True/False.

 

There is a separate Update-Only installation file for folks who already have version 3.2 installed.

 

 

Enjoy.

 

-Skittles

Link to comment
Share on other sites

Hi all.

 

I spent a bit more time on this, after my last post. I've refined it, added a couple more features, then uploaded it as a contribution:

 

http://www.oscommerce.com/community/contributions,2293

 

For your convenience, this contribution uses configuration options in Admin: Display items in rows, True/False; Set number of items per row, #; Set maximum number of items to display, #; and Use random sort order, True/False.

 

There is a separate Update-Only installation file for folks who already have version 3.2 installed.

Enjoy.

 

-Skittles

 

Hi Skittles,

 

Thanks for your help! I want to update my 3.2 contri but i don't understand exactly what you mean by:

 

Before you do, however, you will need to insert the configuration group id into the queries in place of CONFIG_GROUP_ID_NUMBER. The original queries assign the group id automatically, so you need to find it. Open Admin -> Configuration -> Related Products. The configuration id is in the URL immediately following '?gID='.

 

For example, here's the URL on my computer: http://localhost/development/admin/configuration.php?gID=334.

 

Using the id number, replace the CONFIG_GROUP_ID_NUMBER in each of the queries below, and load them in your database.

 

Can you please explain this a littlebit more?

 

Thanks,

Eric

Link to comment
Share on other sites

Hi Skittles,

 

Thanks for your help! I want to update my 3.2 contri but i don't understand exactly what you mean by:

 

Before you do, however, you will need to insert the configuration group id into the queries in place of CONFIG_GROUP_ID_NUMBER. The original queries assign the group id automatically, so you need to find it. Open Admin -> Configuration -> Related Products. The configuration id is in the URL immediately following '?gID='.

 

For example, here's the URL on my computer: http://localhost/development/admin/configuration.php?gID=334.

 

Using the id number, replace the CONFIG_GROUP_ID_NUMBER in each of the queries below, and load them in your database.

 

Can you please explain this a littlebit more?

 

Thanks,

Eric

Hi Eric.

 

I'll try to explain this better...

 

The Related Products contribution is the first I've installed that did not specify either the "configuration_group_id" or the "configuration_id". Because the ID is an auto-increment field, the database assigns the ID automatically.

 

This only becomes an issue when you want to add to an existing installation.

 

In order for the configuration options to show up under Related Products in the Admin configuration, you must specify the configuration_group_id already assigned to Related Products.

 

That group id is part of the configuration file's URL. It is to the right of the "?"

 

Using the example http://localhost/development/admin/configuration.php?gID=334 my configuration_group_id is 334. (Yours is probably something different.)

 

If I were doing this update, I'd use the "search and replace" command of my text editor to find CONFIG_GROUP_ID_NUMBER and replace it with 334.

 

Here is a command before the change:

INSERT INTO `configuration` (`configuration_id`, `configuration_title`, `configuration_key`, `configuration_value`, `configuration_description`, `configuration_group_id`, `sort_order`, `last_modified`, `date_added`, `use_function`, `set_function`)

VALUES ('','Split Display Into Rows','RELATED_PRODUCTS_USE_ROWS','False','Set this option to True to display Related Products in multiple rows.',
CONFIG_GROUP_ID_NUMBER
,2,NULL,'2006-09-26 23:20:20',NULL,'tep_cfg_select_option(array(\'True\', \'False\'),');

And here is the same command after the change:

INSERT INTO `configuration` (`configuration_id`, `configuration_title`, `configuration_key`, `configuration_value`, `configuration_description`, `configuration_group_id`, `sort_order`, `last_modified`, `date_added`, `use_function`, `set_function`)

VALUES ('','Split Display Into Rows','RELATED_PRODUCTS_USE_ROWS','False','Set this option to True to display Related Products in multiple rows.',
334
,2,NULL,'2006-09-26 23:20:20',NULL,'tep_cfg_select_option(array(\'True\', \'False\'),');

Once you've inserted the correct configuration_group_id into the four statements, you need to load them into the database. How you do that will depend on what program you use to access your database.

 

I hope this helps.

-Skittles

Link to comment
Share on other sites

Thanks to jake4u, I found some issues in related_products.sql. :blush: These have been fixed, and the complete package posted as version 3.3-a.

 

The problem only affects new installs. The SQL is/was correct in the Update-Only.txt file.

 

-Skittles

Link to comment
Share on other sites

Hi Eric.

 

I'll try to explain this better...

 

The Related Products contribution is the first I've installed that did not specify either the "configuration_group_id" or the "configuration_id". Because the ID is an auto-increment field, the database assigns the ID automatically.

 

This only becomes an issue when you want to add to an existing installation.

 

In order for the configuration options to show up under Related Products in the Admin configuration, you must specify the configuration_group_id already assigned to Related Products.

 

That group id is part of the configuration file's URL. It is to the right of the "?"

 

Using the example http://localhost/development/admin/configuration.php?gID=334 my configuration_group_id is 334. (Yours is probably something different.)

 

If I were doing this update, I'd use the "search and replace" command of my text editor to find CONFIG_GROUP_ID_NUMBER and replace it with 334.

 

Here is a command before the change:

INSERT INTO `configuration` (`configuration_id`, `configuration_title`, `configuration_key`, `configuration_value`, `configuration_description`, `configuration_group_id`, `sort_order`, `last_modified`, `date_added`, `use_function`, `set_function`)

VALUES ('','Split Display Into Rows','RELATED_PRODUCTS_USE_ROWS','False','Set this option to True to display Related Products in multiple rows.',
CONFIG_GROUP_ID_NUMBER
,2,NULL,'2006-09-26 23:20:20',NULL,'tep_cfg_select_option(array(\'True\', \'False\'),');

And here is the same command after the change:

INSERT INTO `configuration` (`configuration_id`, `configuration_title`, `configuration_key`, `configuration_value`, `configuration_description`, `configuration_group_id`, `sort_order`, `last_modified`, `date_added`, `use_function`, `set_function`)

VALUES ('','Split Display Into Rows','RELATED_PRODUCTS_USE_ROWS','False','Set this option to True to display Related Products in multiple rows.',
334
,2,NULL,'2006-09-26 23:20:20',NULL,'tep_cfg_select_option(array(\'True\', \'False\'),');

Once you've inserted the correct configuration_group_id into the four statements, you need to load them into the database. How you do that will depend on what program you use to access your database.

 

I hope this helps.

-Skittles

 

Hi Skittles,

 

Okay, thanks again for your help!

 

According to the readme-file for updating i opened Admin -> Configuration -> Related Products and then i get this:

http://www.mysite.com/admin/products_options.php

So no gID= number...

 

When i open Admin > Configuration screen i get this:

http://www.mysite.com/admin/configuration....x=configuration

Then i see a gID= number...

 

Which number to use then?

 

Cheers,

Eric

Link to comment
Share on other sites

Not sure if this is the right thread to post in... but i need help with this contribution.

 

When i go to admin and click 'Related Products' this message appears....

 

-----------------------------------------------------------

Access Denied

 

No Right Permission Access

Please contact your Web Administrator to request

more access or if you found any problem.

-----------------------------------------------------------

 

I have installed every as per installation guide... doubled checked...

 

Can anyone help me on this one?

 

Thanks.

Link to comment
Share on other sites

Hi Skittles,

 

Okay, thanks again for your help!

 

According to the readme-file for updating i opened Admin -> Configuration -> Related Products and then i get this:

http://www.mysite.com/admin/products_options.php

So no gID= number...

 

When i open Admin > Configuration screen i get this:

http://www.mysite.com/admin/configuration....x=configuration

Then i see a gID= number...

 

Which number to use then?

 

Cheers,

Eric

 

Eric,

 

The first URL is Related Products under Admin -> Catalog. This is where you go to assign relationships.

 

The second URL is one step away. From this page, you should see Related Products in the left navigation. It should be the last entry under Configuration, just above the link to Catalog.

 

If you don't see Related Products in the Configuration menu, then something isn't set up correctly.

 

Did you have version 3.2 installed? If not, perhaps it would be easiest to restore your database, (you did back up first, right?) and then do a complete install, except make the following change to the SQL code in related_products.sql first.

 

The first two lines are:

DROP TABLE IF EXISTS `products_options_products`;
CREATE TABLE `products_options_products` (

Replace both with this one line:

CREATE TABLE IF NOT EXISTS `products_options_products` (

Then import the file related_products.sql into your database.

 

Good luck. Let us know how you made out.

 

-Skittles

Link to comment
Share on other sites

Not sure if this is the right thread to post in... but i need help with this contribution.

 

When i go to admin and click 'Related Products' this message appears....

 

-----------------------------------------------------------

Access Denied

 

No Right Permission Access

Please contact your Web Administrator to request

more access or if you found any problem.

-----------------------------------------------------------

 

I have installed every as per installation guide... doubled checked...

 

Can anyone help me on this one?

 

Thanks.

rosscosworld,

 

Off the top of my head, I'd say the products_options.php file doesn't have the permissions set correctly.

 

Check the attributes and make sure permissions have been set to allow anyone to read the file.

 

(The numeric value on our linux server for this file is 644, and we've had no problems using it.)

 

If permissions are set correctly and it still won't allow you access, you may need to contact your web host.

 

Good luck,

 

-Skittles

Link to comment
Share on other sites

Eric,

 

The first URL is Related Products under Admin -> Catalog. This is where you go to assign relationships.

 

The second URL is one step away. From this page, you should see Related Products in the left navigation. It should be the last entry under Configuration, just above the link to Catalog.

 

If you don't see Related Products in the Configuration menu, then something isn't set up correctly.

 

Did you have version 3.2 installed? If not, perhaps it would be easiest to restore your database, (you did back up first, right?) and then do a complete install, except make the following change to the SQL code in related_products.sql first.

 

The first two lines are:

DROP TABLE IF EXISTS `products_options_products`;
CREATE TABLE `products_options_products` (

Replace both with this one line:

CREATE TABLE IF NOT EXISTS `products_options_products` (

Then import the file related_products.sql into your database.

 

Good luck. Let us know how you made out.

 

-Skittles

 

 

Hi Skittles,

 

Yep! Works perfect now!

Many thanks!

 

Cheers,

:D Eric :D

Link to comment
Share on other sites

Hi eyestuffguy!

 

The code I shared earlier is proof positive that one should come up for air occasionally!

 

With too many files open at the same time, I apparently grabbed the wrong line of code for reference. Then consider a few missing parentheses, semi-colons, and correct html tags, and you have a recipe for frustration... Sorry.

 

I now have a development copy of osCommerce on my computer, and I tested the code. I got it working correctly on a vanilla install.

 

Here is the correct code:

 

Find:

 if (mysql_num_rows($attribute_query)>0) {

 

and add "$count = 0;" in the next line, like this:

  if (mysql_num_rows($attribute_query)>0) {
  $count = 0;

 

Then find:

echo '<Br> <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_id_slave) . '">'.$products_name_slave.'<Br>@ '.$products_price_slave.'</a>';

 

Replace it with this code:

echo '<Br> <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_id_slave) . '">'.$products_name_slave.'<Br>@ '.$products_price_slave.'</a>';
$count++;
if (($count > 2) && ($count%3 == 0)) {
 echo '</td></tr><tr></td>';
}

(I didn't make any changes to the first line, just added my changes afterwards.)

 

Hope this works for you.

 

-Skittles

 

Good afternoon Skittles.

 

Almost there...

Many thanks to you for helping me out. Although I don't get the same error as before, I am seeing the following error:

 

Parse error: parse error, unexpected $ in ...[CLIP].../product_info.php on line 363

 

That line is actually the last line of the code and it is blank.

 

Is there something you can tell me to fix this new error?

 

Thanks again!

Link to comment
Share on other sites

For your convenience, this contribution uses configuration options in Admin: Display items in rows, True/False; Set number of items per row, #; Set maximum number of items to display, #; and Use random sort order, True/False.

I installed this and love it, but when I look in Admin under Configuration the only option I see is whether or not I want to show thumbnails. I don't see the other options described.

Link to comment
Share on other sites

I installed this and love it, but when I look in Admin under Configuration the only option I see is whether or not I want to show thumbnails. I don't see the other options described.

Baddog,

 

First: Export the products_options_products table, so you don't lose any work you've already done.

 

Second: Restore your database. (You did back up first, right?)

 

Third: load the following SQL code instead of what is in the contrib:

 

DROP TABLE IF EXISTS `products_options_products`;
CREATE TABLE `products_options_products` (
 `pop_id` int(11) NOT NULL auto_increment,
 `pop_products_id_master` int(11) NOT NULL default '0',
 `pop_products_id_slave` int(11) NOT NULL default '0',
 `pop_order_id` smallint(6) NOT NULL default '0',
 PRIMARY KEY  (`pop_id`)
) TYPE=MyISAM AUTO_INCREMENT=18;

INSERT INTO `configuration_group` ( `configuration_group_id` , `configuration_group_title` , `configuration_group_description` , `sort_order` , `visible` ) VALUES ( '', 'Related Products', 'Optional Related Products module', '999', '1' );
SET @groupID = last_insert_id();

INSERT INTO `configuration` (`configuration_id`, `configuration_title`, `configuration_key`, `configuration_value`, `configuration_description`, `configuration_group_id`, `sort_order`, `last_modified`, `date_added`, `use_function`, `set_function`) 
VALUES ('', 'Show Thumbnails', 'MODULE_RELATED_PRODUCTS_SHOW_THUMBS', 'False', 'Show Related Products Thumbnails', @groupID, '1', NULL, '2005-03-29 23:20:20', NULL , 'tep_cfg_select_option(array(\'True\', \'False\'),');

INSERT INTO `configuration` (`configuration_id`, `configuration_title`, `configuration_key`, `configuration_value`, `configuration_description`, `configuration_group_id`, `sort_order`, `last_modified`, `date_added`, `use_function`, `set_function`) 
VALUES ('','Split Display Into Rows','RELATED_PRODUCTS_USE_ROWS','False','Set this option to True to display Related Products in multiple rows.',@groupID,2,NULL,'2006-09-26 23:20:20',NULL,'tep_cfg_select_option(array(\'True\', \'False\'),');

INSERT INTO `configuration` (`configuration_id`, `configuration_title`, `configuration_key`, `configuration_value`, `configuration_description`, `configuration_group_id`, `sort_order`, `last_modified`, `date_added`, `use_function`, `set_function`) 
VALUES ('','Defines 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.',@groupID,3,NULL,'2006-09-26 23:20:20',NULL,'');

INSERT INTO `configuration` (`configuration_id`, `configuration_title`, `configuration_key`, `configuration_value`, `configuration_description`, `configuration_group_id`, `sort_order`, `last_modified`, `date_added`, `use_function`, `set_function`) 
VALUES ('', 'Defines Number of Items to Display', 'RELATED_PRODUCTS_MAX_DISP', '0', 'Maximum number of Related Products to display. 0 is unlimited.', @groupID, 4, NULL,'2006-09-26 23:20:20',NULL,'');

INSERT INTO `configuration` (`configuration_id`, `configuration_title`, `configuration_key`, `configuration_value`, `configuration_description`, `configuration_group_id`, `sort_order`, `last_modified`, `date_added`, `use_function`, `set_function`) 
VALUES ('', 'Adds Random Display Order', 'RELATED_PRODUCTS_RANDOMIZE', 'False', 'Adds random sort order to products displayed. Recommended if maximum number of products is set.', @groupID, 5, NULL,'2006-09-26 23:20:20',NULL,'tep_cfg_select_option(array(\'True\', \'False\'),');

Fourth: Import your data back into the database (only use the INSERT INTO statements from the exported table.)

 

 

I made an assumption, and it came back to bite me! :blush:

 

-Skittles

 

PS. Anyone doing a new install should use this SQL code instead of that packaged with version 3.3-a. I've posted vesion 3.3-b, but it includes some screenshots and is large enough it must be manually approved.

 

The bug does not affect anyone using the Update Only instructions.

Link to comment
Share on other sites

Baddog,

 

First: Export the products_options_products table, so you don't lose any work you've already done.

 

Second: Restore your database. (You did back up first, right?)

 

Third: load the following SQL code instead of what is in the contrib:

 

Fourth: Import your data back into the database (only use the INSERT INTO statements from the exported table.)

Well, here is what I tried thinking it would do the same thing.

1. I renamed the existing table.

2. I ran the SQL (excluding the first line).

3. I copied the data from the renamed (original) table to the new table (data only).

4. I dropped the original table.

 

Now I have two Related Products in Configuration. One shows only the Thumbnail option and seems to control whether or not a thumbnail is displayed. The other one has all of the options but does not seem to control the thumbnail display (have not check the other options yet). Did I screw it up?

Link to comment
Share on other sites

Well, here is what I tried thinking it would do the same thing.

1. I renamed the existing table.

2. I ran the SQL (excluding the first line).

3. I copied the data from the renamed (original) table to the new table (data only).

4. I dropped the original table.

 

Now I have two Related Products in Configuration. One shows only the Thumbnail option and seems to control whether or not a thumbnail is displayed. The other one has all of the options but does not seem to control the thumbnail display (have not check the other options yet). Did I screw it up?

 

Just a little bit...

 

This SQL code assigns values on the fly. The bad code used a function to get the last ID assigned. Problem was, for the second and subsequent configuration options, it was assigning the previous options ID as the group ID.

 

By not reverting to the database prior to attempting the install, the old, useless entries are still in the configuration table, as well as two configuration groups with the same name.

 

However, the fact you were able to rename the existing table suggests you have the ability to delete the offending rows of data.

 

If it were me, I'd go back and follow the first set of instructions to the letter. However, if you didn't backup the database just prior to the first attempt to install, you may need to clean up the tables manually.

 

To do that, go into both the configuration table and the cofiguration_groups table, and remove all the rows created by both installation attempts. They should be the last 10 and last 2 entries, respectively.

 

Then reload just the 6 INSERT INTO SQL statements. (Your products_options_products table should be fine.)

 

As for screwing up, if I'd gotten it right the first time, none of this would be an issue. So I guess we all know who really screwed up. Sorry.

 

-Skittles

Link to comment
Share on other sites

Just a little bit...

 

This SQL code assigns values on the fly. The bad code used a function to get the last ID assigned. Problem was, for the second and subsequent configuration options, it was assigning the previous options ID as the group ID.

 

By not reverting to the database prior to attempting the install, the old, useless entries are still in the configuration table, as well as two configuration groups with the same name.

 

However, the fact you were able to rename the existing table suggests you have the ability to delete the offending rows of data.

 

If it were me, I'd go back and follow the first set of instructions to the letter. However, if you didn't backup the database just prior to the first attempt to install, you may need to clean up the tables manually.

 

To do that, go into both the configuration table and the cofiguration_groups table, and remove all the rows created by both installation attempts. They should be the last 10 and last 2 entries, respectively.

 

Then reload just the 6 INSERT INTO SQL statements. (Your products_options_products table should be fine.)

 

As for screwing up, if I'd gotten it right the first time, none of this would be an issue. So I guess we all know who really screwed up. Sorry.

 

-Skittles

Thanks. I ended up deleting the extra (original) entries from configuration and configuration_groups and everything looks and works fine now. If I had run the "drop table" part of the SQL I think it would have worked the first time. Guess all's well that ends well. Thanks again.

Link to comment
Share on other sites

Thanks. I ended up deleting the extra (original) entries from configuration and configuration_groups and everything looks and works fine now. If I had run the "drop table" part of the SQL I think it would have worked the first time. Guess all's well that ends well. Thanks again.

I take part of that back. Dropping the products_options_products table would not prevent the SQL statement from inserting duplicate rows in the other two tables (configuration and configuration_groups).

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...