Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

family 3.0 problems


sgflowers

Recommended Posts

Could anyone assist me with the function to delete the family produts from the products_family TABLE.. As the products still show in my products info page.. I think it's got to do with the function in that admin/include/functions/database.php

// This deletes a family.
?function tep_remove_family($family_id) {
? ?tep_db_query("delete from " . TABLE_FAMILIES . " where family_id = '" . (int)$family_id . "'");
?}

 

I am no expert in php but i think this line above is just deleting the product family group rather than the product in the products_families table...

 

any help is much appreciate.

thanks

Try this:

 

// This deletes a family.
 function tep_remove_family($family_id) {
   tep_db_query("delete from " . TABLE_FAMILIES . " where family_id = '" . (int)$family_id . "'");

   tep_db_query("delete from " . TABLE_PRODUCTS_FAMILIES . " where family_id = '" . (int)$family_id . "'");

 }

 

HTH,

-Chris

Chris Sullivan

Link to comment
Share on other sites

  • Replies 146
  • Created
  • Last Reply

Top Posters In This Topic

HI Chris.

 

THANK YOU SO MUCH --- PROBLEM SOLVED after i changed to code.

 

Just a couple of questions if i may, Am i Correct in saying.

 

1. you cannot edit an existing Family group interms of adding a product or deleting a product to that family.

 

2. If you edit a family you would not be able to see the products in the list.

 

 

Now one step forward, I have many products and when i view a family group in the view_family.php in the admin section i can see just the product name, if i would like to add a product model number next to it. what files do i ammend, i had a look at the view_family.php file but could not get it to work.

 

also would it be possible to add a buy now button at on the family products.. so instead of going to it directly they can buy it from there.

 

many thanks.

Link to comment
Share on other sites

Chris,

 

I did a little more troubleshooting on my issues listed above. I was able to change the setting from Random to Seperate in the database and this does indeed resolve the error we are all getting. So looks like there is something wrong with that code. I am not sure what the difference between the 3 settings are so can you explain?

 

Since random seems flaky, can we just remove it from the code?

Link to comment
Share on other sites

Choosing the Family Display Type.

I was using the box type and all is well. but when i changed to List

I get this error

 

Fatal error: Cannot instantiate non-existent class: productlistingbox in C:\Inetpub\wwwroot\accweb\catalog\includes\modules\family_products.php on line 406

 

 

and line 406 reads as follows:

new productListingBox($list_box_contents);

 

any help is much apprciated

Link to comment
Share on other sites

Chris,

 

I did a little more troubleshooting on my issues listed above. I was able to change the setting from Random to Seperate in the database and this does indeed resolve the error we are all getting. So looks like there is something wrong with that code. I am not sure what the difference between the 3 settings are so can you explain?

 

Since random seems flaky, can we just remove it from the code?

Yes, the problem is only going to occur when you are using the "random" option. The strange thing is that I have installed this contribution on both "clean" and "modded" versions of osCommerce and I have yet to actually get any errors.

 

I am using the latest stable release of PHP, mySQL, and IIS 5.1 running on Windows XP.

 

If you have to have this issue fixed immediately then the solution is to run in "seperate" display type.

 

I am having a hard time trouble-shooting this error because I cannot get this error.

 

I hope you understand. I will try to take another look.....

-Chris

Chris Sullivan

Link to comment
Share on other sites

Chris,

 

I did a little more troubleshooting on my issues listed above. I was able to change the setting from Random to Seperate in the database and this does indeed resolve the error we are all getting. So looks like there is something wrong with that code. I am not sure what the difference between the 3 settings are so can you explain?

 

Since random seems flaky, can we just remove it from the code?

Yes, the problem is only going to occur when you are using the "random" option. The strange thing is that I have installed this contribution on both "clean" and "modded" versions of osCommerce and I have yet to actually get any errors.

 

I am using the latest stable release of PHP, mySQL, and IIS 5.1 running on Windows XP.

 

If you have to have this issue fixed immediately then the solution is to run in "seperate" display type.

 

I am having a hard time trouble-shooting this error because I cannot get this error.

 

I hope you understand. I will try to take another look.....

-Chris

Thanks Chris. Looks like there are other problems with the script that I need to look into. Now in the admin panel, the product dropdowns are not getting populated in assign families. no errors nothing. just the header for the drop "please select...". it was working now it stopped. functions are there...really weird. since i will never use different display types, i think i might put the code on a diet and just keep the core of it and see if it works. i wonder if some of the logic around the cases are not working correctly (i.e. variables, etc.)

 

I did have to change some code in the admin scripts to get rid of my javascript error. the "onmouseover" "onmouseout" was causing errors on my console so I rewrote those lines to use the syntax used by all my other admin modules.

Link to comment
Share on other sites

Hi all,

I have just installed the latest Family Products v3.3 and am getting the SQL error mentioned many times here if Family Display Format is set to Random.

 

I have Use Search-Engine Safe URLs set to true. If I replace the / in the URL the SQL error disappears and the Family Products module works as expected...

ie. replace:

product_info.php/products_id/31

with:

product_info.php?products_id=31

and all works well in Random mode.

 

Also, with Search-Engine Safe URLs set to true and Display Format (for family products) set to Seperate, the SQL error disappers but no family products show!

again, if i view the page as if Search-Engine Safe URLs was false, the family shows...

 

So, any idea what I need to do to get this mod working with Search-Engine Safe URLs??

Link to comment
Share on other sites

Ok. So everyone keeps getting this sql query error on pages with no products. I finally did another install and got the same error. I was able to fix it immediately.

 

The fix is this:

 

On both the Random List settings, and the Random Box settings, you must add a check.

 

After:

$family_name_query = tep_db_query('.....

Add:

if (tep_db_num_rows($family_name_query) > '0') {

And at the end of those two functions, add:

 }

 

This will fix the problem. Sorry about the mix up.

 

Hope all get this working now.

 

-Chris

Chris Sullivan

Link to comment
Share on other sites

excellet, thanks for fixing this, but i am a bit lost as to where to place this fix - i presume in includes/modules/family_products.php?

 

any chance you can post the fixed file here?

and also, does this work with both Search Engine Safe on and off?

daithi.

Link to comment
Share on other sites

  • 2 weeks later...

Hey Chris,

 

If I wanted to uninstall the other Family Products mods so I can install yours, what would be the easiest way? I am new to all this and unsure how to uninstall a mod once it is done. :(

 

HELP!! :)

 

Kevin

Link to comment
Share on other sites

Just read the install instructions of the last mod you installed. From there, if you "added" something, then delete it. If you changed something, then use the install instructions to go back to the old code.

 

And undo any changes you made to the database.

 

HTH,

-Chris

Chris Sullivan

Link to comment
Share on other sites

Ok. So everyone keeps getting this sql query error on pages with no products. I finally did another install and got the same error. I was able to fix it immediately.

 

The fix is this:

 

On both the Random List settings, and the Random Box settings, you must add a check.

 

After:

$family_name_query = tep_db_query('.....

Add:

if (tep_db_num_rows($family_name_query) > '0') {

And at the end of those two functions, add:

 }

 

This will fix the problem. Sorry about the mix up.

 

Hope all get this working now.

 

-Chris

can anyone post the corrected file here?

Link to comment
Share on other sites

Just read the install instructions of the last mod you installed. From there, if you "added" something, then delete it. If you changed something, then use the install instructions to go back to the old code.

 

And undo any changes you made to the database.

 

HTH,

-Chris

HI Chris,

 

I got brave and decided to start from scratch. I now am saving a full copy of the catalog every mod I add. :) I figure this way I can revert back to any point in my mods. ;-)

 

I added in your Family Products 3.3 and wanted to know if I was supposed to have an option on the item entry and edit screen to choose a family. I don't and want to make sure I did not forget something. :)

 

So far it works fine with no alterations from the downloaded install. But I did read a few posts back about having to change the Random List settings, and the Random Box settings yet, I have no clue where to find them. :(

 

Help,

Kevin

Link to comment
Share on other sites

Just read the install instructions of the last mod you installed. From there, if you "added" something, then delete it. If you changed something, then use the install instructions to go back to the old code.

 

And undo any changes you made to the database.

 

HTH,

-Chris

HI Chris,

 

I got brave and decided to start from scratch. I now am saving a full copy of the catalog every mod I add. :) I figure this way I can revert back to any point in my mods. ;-)

 

I added in your Family Products 3.3 and wanted to know if I was supposed to have an option on the item entry and edit screen to choose a family. I don't and want to make sure I did not forget something. :)

 

So far it works fine with no alterations from the downloaded install. But I did read a few posts back about having to change the Random List settings, and the Random Box settings yet, I have no clue where to find them. :(

 

Help,

Kevin

Never Mind. :D

 

I found them and made the change. I no longer get that 1064 error. :-)

 

Thanks!!

Kevin

Link to comment
Share on other sites

  • 2 weeks later...

Hi Guys.

For us not so code-literate, can anyone be more specific as how to fix this sql error.

 

 

Ok. So everyone keeps getting this sql query error on pages with no products. I finally did another install and got the same error. I was able to fix it immediately.

 

The fix is this:

 

On both the Random List settings, and the Random Box settings, you must add a check.

 

After:

CODE 

$family_name_query = tep_db_query('.....

 

 

Add:

CODE 

if (tep_db_num_rows($family_name_query) > '0') {

 

 

And at the end of those two functions, add:

CODE 

 

 

 

This will fix the problem. Sorry about the mix up.

 

Hope all get this working now.

 

-Chris

 

 

DOES ANYONE KNOW WHICH PAGE THIS IS ON. OR A CLEARER METHOD OF WHICH LINES NEED CHANGING SO AS TO FIX THE SQL ERROR.

 

Regards

 

maz

Link to comment
Share on other sites

  • 4 weeks later...
Hi Guys.

For us not so code-literate, can anyone be more specific as how to fix this sql error.

 

 

The fix is this:

 

On both the Random List settings, and the Random Box settings, you must add a check.

 

After:

CODE?

$family_name_query = tep_db_query('.....

 

 

Add:

CODE?

if (tep_db_num_rows($family_name_query) > '0') {

 

 

And at the end of those two functions, add:

CODE?

}?

 

 

DOES ANYONE KNOW WHICH PAGE THIS IS ON. OR A CLEARER METHOD OF WHICH LINES NEED CHANGING SO AS TO FIX THE SQL ERROR.

I am so proud of myself that I managed to figure this one out!

 

The file is catalog/includes/modules/family_products.php.

 

The file is broken down into four main sections, differentiated by the if statements listed below--

 

if ((FAMILY_DISPLAY_TYPE == 'Box') && (FAMILY_DISPLAY_FORMAT == 'Seperate')){

if ((FAMILY_DISPLAY_TYPE == 'Box') && (FAMILY_DISPLAY_FORMAT == 'Random')){

if ((FAMILY_DISPLAY_TYPE == 'List') && (FAMILY_DISPLAY_FORMAT == 'Seperate')){

if ((FAMILY_DISPLAY_TYPE == 'List') && (FAMILY_DISPLAY_FORMAT == 'Random')) {

 

The parts you have to edit are the two sections referencing 'Random'. Within each of those two sections, you find the code Chris named and insert the line he specifies. Then scroll to the end of the section (right before any ?> that may be there, or right before the if statement that marks the next section) and insert a } on a line of its own.

 

Once you put those four lines in the right place, the SQL error will be gone. The code itself checks to see if the query will return any results. By placing the entire section within that 'if' statement, you're basically telling the program that if the check fails, print nothing--no box at all.

 

Hope that helps the other non-coders out there. It took me an hour to get this right. :)

shris

Link to comment
Share on other sites

  • 2 weeks later...

I spoke too soon. Everything seems to be working fine. The admin section looks perfect and I can add families and products. When I check them in admin everything looks fine and even when I click on a product in admin that belongs to a family and it takes me to catalog view, the family products show great. However, when I access my products from the catalog section by typing www.jewelrycabin.com, and then going to the products (let's say the elephant jewelry) that I know I have created family for, no family products are shown underneath. I am not getting any errors. Just nothing at all (no family products). Any help would be appreciated. Thanks.

We will not regret what we have done. We will regret what we didn't do.

Link to comment
Share on other sites

That is because you are using SEF URLs and that is causing problems. If you turn this off you will see that there are no more problems.

 

Also, while I am posting to this topic....here is the proper code to eliminate the empty SQL query error that so many people are getting.

 

Just copy the code below, and overwrite your existing /catalog/includes/modules/family_products.php file with the attached code.

 

<?php
/*
?$Id: family_products.php,v 3.30 2003/09/04 18:04:58 blueline Exp $

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

?Copyright (c) 2003 osCommerce

?Released under the GNU General Public License
*/
?>
<!-- family_products //-->
<?php
//This is where the code for the infoBox starts:
if ((FAMILY_DISPLAY_TYPE == 'Box') && (FAMILY_DISPLAY_FORMAT == 'Seperate')){

$family_name_query = tep_db_query("select pf.family_id, f.family_name from " . TABLE_PRODUCTS_FAMILIES . " pf, " . TABLE_FAMILIES . " f where pf.family_id = f.family_id and pf.products_id = '" . $products_id . "'");
while ($family_results = tep_db_fetch_array($family_name_query)) {

?$info_box_contents = array();
?
?if (FAMILY_HEADER_FORMAT == 'Family Name') {
?$info_box_contents[] = array('text' => $family_results['family_name']);
?} else {
?if (FAMILY_HEADER_TEXT == '') { 
?$info_box_contents[] = array('text' => TABLE_HEADING_FAMILY_PRODUCTS);
?} else {
?$info_box_contents[] = array('text' => FAMILY_HEADER_TEXT);
?}
?}

$family_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS_FAMILIES . " pf, " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and pf.family_id = '" . (int)$family_results['family_id'] . "' and p.products_id = pf.products_id and p.products_id != '" . $products_id . "'" . $where_clause2 . " order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);

?if (tep_db_num_rows($family_query) > 0) {
?new contentBoxHeading($info_box_contents);


?$row = 0;
?$col = 0;
?$info_box_contents = array();
?$where_clause2 = '';
?while ($family = tep_db_fetch_array($family_query)) {
$where_clause2 .= " and p.products_id != '" . $family['products_id'] . "'";
? ?$family['products_name'] = tep_get_products_name($family['products_id']);
$info_box_contents[$row][$col] = array('align' => 'center',
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'params' => 'class="smallText" width="33%" valign="top"',
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $family['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $family['products_image'], $family['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $family['products_id']) . '">' . $family['products_name'] . '</a><br>' . $currencies->display_price($family['products_price'], tep_get_tax_rate($family['products_tax_class_id'])));

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

?new contentBox($info_box_contents);
echo '<p>';
}
}
}


if ((FAMILY_DISPLAY_TYPE == 'Box') && (FAMILY_DISPLAY_FORMAT == 'Random')){

$family_name_query = tep_db_query("select family_id from " . TABLE_PRODUCTS_FAMILIES . " where products_id = '" . $products_id . "'");
if (tep_db_num_rows($family_name_query) > '0') {

?$info_box_contents = array();
?if (FAMILY_HEADER_TEXT == '') { 
?$info_box_contents[] = array('text' => TABLE_HEADING_FAMILY_PRODUCTS);
?} else {
?$info_box_contents[] = array('text' => FAMILY_HEADER_TEXT);
?}
$family_name_num_rows = tep_db_num_rows($family_name_query);
$num_of_rows_less_one = $family_name_num_rows - '1'; 

if (tep_db_num_rows($family_name_query) == '1') {
$family_results = tep_db_fetch_array($family_name_query);
$family_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS_FAMILIES . " pf, " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and pf.family_id = '" . (int)$family_results['family_id'] . "' and p.products_id = pf.products_id and p.products_id != '" . $products_id . "' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);
} else {
$where_clause = '';
for ($i=0; $i < tep_db_num_rows($family_name_query); $i++) {
$family_results = tep_db_fetch_array($family_name_query);
if ($i < $num_of_rows_less_one) {
$where_clause .= "(pf.family_id = '" . $family_results['family_id'] . "') OR ";
} else {
$where_clause .= "(pf.family_id = '" . $family_results['family_id'] . "')";
}
}
$family_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS_FAMILIES . " pf, " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and (" . $where_clause . ") and p.products_id = pf.products_id and p.products_id != '" . $products_id . "' limit " . MAX_DISPLAY_NEW_PRODUCTS);
}

?if (tep_db_num_rows($family_query) > 0) {
?new contentBoxHeading($info_box_contents);


?$row = 0;
?$col = 0;
?$info_box_contents = array();
$where_clause2 = ''; ? ?
? ?for ($i=0, $j=1; ($i < MAX_DISPLAY_NEW_PRODUCTS) && ($i < tep_db_num_rows($family_query)); $i++, $j++) {
?if (tep_db_num_rows($family_name_query) == '1') {
? ?$family = tep_random_select("select distinct p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS_FAMILIES . " pf, " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and p.products_id = pf.products_id and p.products_id != '" . $products_id . "'" . $where_clause2);
?} else {
? ?$family = tep_random_select("select distinct p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS_FAMILIES . " pf, " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and (" . $where_clause . ") and p.products_id = pf.products_id and p.products_id != '" . $products_id . "'" . $where_clause2);
?}
?$where_clause2 .= " and p.products_id != '" . $family['products_id'] . "'";


? ?$family['products_name'] = tep_get_products_name($family['products_id']);
$info_box_contents[$row][$col] = array('align' => 'center',
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'params' => 'class="smallText" width="33%" valign="top"',
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $family['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $family['products_image'], $family['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $family['products_id']) . '">' . $family['products_name'] . '</a><br>' . $currencies->display_price($family['products_price'], tep_get_tax_rate($family['products_tax_class_id'])));

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

?new contentBox($info_box_contents);
echo '<p>';
}
}
}
?>
<?php 

//This is where the code for the list starts:
if ((FAMILY_DISPLAY_TYPE == 'List') && (FAMILY_DISPLAY_FORMAT == 'Seperate')){

$family_name_query = tep_db_query("select pf.family_id, f.family_name from " . TABLE_PRODUCTS_FAMILIES . " pf, " . TABLE_FAMILIES . " f where pf.family_id = f.family_id and pf.products_id = '" . $products_id . "'");
while ($family_results = tep_db_fetch_array($family_name_query)) {

$family_query = tep_db_query("select distinct p.manufacturers_id, p.products_id, p.products_image, p.products_tax_class_id, p.products_price, s.specials_new_products_price from " . TABLE_PRODUCTS_FAMILIES . " pf, " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and pf.family_id = '" . (int)$family_results['family_id'] . "' and p.products_id = pf.products_id and p.products_id != '" . $products_id . "'" . $where_clause2 . " order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);
? ?
? ?$define_list = array('PRODUCT_LIST_NAME' => '2',//PRODUCT_LIST_NAME,
? ? ? ? ? ? ? ? ? ? ? ? 'PRODUCT_LIST_PRICE' => '3',//PRODUCT_LIST_PRICE,
? ? ? ? ? ? ? ? ? ? ? ? 'PRODUCT_LIST_IMAGE' => '1',//PRODUCT_LIST_IMAGE,
? ? ? ? ? ? ? ? ? ? ? ? 'PRODUCT_LIST_BUY_NOW' => '4');//PRODUCT_LIST_BUY_NOW);

? ?asort($define_list);

? ?$column_list = array();
? ?reset($define_list);
? ?while (list($key, $value) = each($define_list)) {
? ? ?if ($value > 0) $column_list[] = $key;
? ?}

$list_box_contents = array();
?if (tep_db_num_rows($family_query) > 0) {

?if (FAMILY_HEADER_FORMAT == 'Family Name') {
? ?$list_box_contents[0][0] = array('align' => 'left',
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'params' => 'class="productListing-heading"',
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'text' => ' ' . $family_results['family_name'] . ' ');
?} else {
?if (FAMILY_HEADER_TEXT == '') { 
? ?$list_box_contents[0][0] = array('align' => 'left',
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'params' => 'class="productListing-heading"',
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'text' => ' ' . TABLE_HEADING_FAMILY_PRODUCTS . ' ');
?} else {
? ? ?$list_box_contents[0][0] = array('align' => 'left',
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'params' => 'class="productListing-heading"',
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'text' => ' ' . FAMILY_HEADER_TEXT . ' ');
?}
?}
?
for($i=1; $i<4; $i++) {
? ?$list_box_contents[0][$i] = array('align' => 'left',
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'params' => 'class="productListing-heading"',
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'text' => ' ');
}
?for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
? ?switch ($column_list[$col]) {
? ? ?case 'PRODUCT_LIST_NAME':
? ? ? ?$lc_text = TABLE_HEADING_PRODUCTS;
? ? ? ?$lc_align = '';
? ? ? ?break;
? ? ?case 'PRODUCT_LIST_PRICE':
? ? ? ?$lc_text = TABLE_HEADING_PRICE;
? ? ? ?$lc_align = 'right';
? ? ? ?break;
? ? ?case 'PRODUCT_LIST_IMAGE':
? ? ? ?$lc_text = TABLE_HEADING_IMAGE;
? ? ? ?$lc_align = 'center';
? ? ? ?break;
? ? ?case 'PRODUCT_LIST_BUY_NOW':
? ? ? ?$lc_text = TABLE_HEADING_BUY_NOW;
? ? ? ?$lc_align = 'center';
? ? ? ?break;
? ?}

? ?if ( ($column_list[$col] != 'PRODUCT_LIST_BUY_NOW') && ($column_list[$col] != 'PRODUCT_LIST_IMAGE') ) {
? ? ?$lc_text = tep_create_sort_heading($HTTP_GET_VARS['sort'], $col+1, $lc_text);
? ?}

? ?$list_box_contents[1][] = array('align' => $lc_align,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'params' => 'class="productListing-heading"',
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'text' => ' ' . $lc_text . ' ');
?}
? ?$rows = 0;

?$where_clause2 = '';
? ?while ($listing = tep_db_fetch_array($family_query)) {
$where_clause2 .= " and p.products_id != '" . $listing['products_id'] . "'";
? ?$listing['products_name'] = tep_get_products_name($listing['products_id']);
? ? ?$rows++;

? ? ?if (($rows/2) == floor($rows/2)) {
? ? ? ?$list_box_contents[] = array('params' => 'class="productListing-even"');
? ? ?} else {
? ? ? ?$list_box_contents[] = array('params' => 'class="productListing-odd"');
? ? ?}

? ? ?$cur_row = sizeof($list_box_contents) - 1;

? ? ?for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
? ? ? ?$lc_align = '';

? ? ? ?switch ($column_list[$col]) {
? ? ? ? ?case 'PRODUCT_LIST_NAME':
? ? ? ? ? ?$lc_align = '';
? ? ? ? ? ?if (isset($HTTP_GET_VARS['manufacturers_id'])) {
? ? ? ? ? ? ?$lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a>';
? ? ? ? ? ?} else {
? ? ? ? ? ? ?$lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a> ';
? ? ? ? ? ?}
? ? ? ? ? ?break;
? ? ? ? ?case 'PRODUCT_LIST_PRICE':
? ? ? ? ? ?$lc_align = 'right';
? ? ? ? ? ?if (tep_not_null($listing['specials_new_products_price'])) {
? ? ? ? ? ? ?$lc_text = ' <s>' . ?$currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</s>  <span class="productSpecialPrice">' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span> ';
? ? ? ? ? ?} else {
? ? ? ? ? ? ?$lc_text = ' ' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . ' ';
? ? ? ? ? ?}
? ? ? ? ? ?break;
? ? ? ? ?case 'PRODUCT_LIST_IMAGE':
? ? ? ? ? ?$lc_align = 'center';
? ? ? ? ? ?if (isset($HTTP_GET_VARS['manufacturers_id'])) {
? ? ? ? ? ? ?$lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>';
? ? ? ? ? ?} else {
? ? ? ? ? ? ?$lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a> ';
? ? ? ? ? ?}
? ? ? ? ? ?break;
? ? ? ? ?case 'PRODUCT_LIST_BUY_NOW':
? ? ? ? ? ?$lc_align = 'center';
? ? ? ? ? ?$lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> ';
? ? ? ? ? ?break;
? ? ? ?}

? ? ? ?$list_box_contents[$cur_row][] = array('align' => $lc_align,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'params' => 'class="productListing-data"',
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'text' ?=> $lc_text);
? ? ?}
? ?}

? ?new productListingBox($list_box_contents);
}
echo '<p>';
}
}


if ((FAMILY_DISPLAY_TYPE == 'List') && (FAMILY_DISPLAY_FORMAT == 'Random')) {
$family_name_query = tep_db_query("select family_id from " . TABLE_PRODUCTS_FAMILIES . " where products_id = '" . $products_id . "'");
if (tep_db_num_rows($family_name_query) > '0') {

$family_name_num_rows = tep_db_num_rows($family_name_query);
$num_of_rows_less_one = $family_name_num_rows - '1'; 

if (tep_db_num_rows($family_name_query) == '1') {
$family_results = tep_db_fetch_array($family_name_query);
$family_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS_FAMILIES . " pf, " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and pf.family_id = '" . (int)$family_results['family_id'] . "' and p.products_id = pf.products_id and p.products_id != '" . $products_id . "' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);
} else {
$where_clause = '';
$where_clause2 = '';
for ($i=0; $i < tep_db_num_rows($family_name_query); $i++) {
$family_results = tep_db_fetch_array($family_name_query);
if ($i < $num_of_rows_less_one) {
$where_clause .= "(pf.family_id = '" . $family_results['family_id'] . "') OR ";
} else {
$where_clause .= "(pf.family_id = '" . $family_results['family_id'] . "')";
}
}
$family_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS_FAMILIES . " pf, " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and (" . $where_clause . ") and p.products_id = pf.products_id and p.products_id != '" . $products_id . "' limit " . MAX_DISPLAY_NEW_PRODUCTS);
}

? ?$define_list = array('PRODUCT_LIST_NAME' => '2',//PRODUCT_LIST_NAME,
? ? ? ? ? ? ? ? ? ? ? ? 'PRODUCT_LIST_PRICE' => '3',//PRODUCT_LIST_PRICE,
? ? ? ? ? ? ? ? ? ? ? ? 'PRODUCT_LIST_IMAGE' => '1',//PRODUCT_LIST_IMAGE,
? ? ? ? ? ? ? ? ? ? ? ? 'PRODUCT_LIST_BUY_NOW' => '4');//PRODUCT_LIST_BUY_NOW);

? ?asort($define_list);

? ?$column_list = array();
? ?reset($define_list);
? ?while (list($key, $value) = each($define_list)) {
? ? ?if ($value > 0) $column_list[] = $key;
? ?}

$list_box_contents = array();
?if (tep_db_num_rows($family_query) > 0) {

?if (FAMILY_HEADER_TEXT == '') { 
? ?$list_box_contents[0][0] = array('align' => 'left',
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'params' => 'class="productListing-heading"',
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'text' => ' ' . TABLE_HEADING_FAMILY_PRODUCTS . ' ');
?} else {
? ? ?$list_box_contents[0][0] = array('align' => 'left',
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'params' => 'class="productListing-heading"',
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'text' => ' ' . FAMILY_HEADER_TEXT . ' ');
?}
?
for($i=1; $i<5; $i++) {
? ?$list_box_contents[0][$i] = array('align' => 'left',
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'params' => 'class="productListing-heading"',
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'text' => ' ');
}
?for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
? ?switch ($column_list[$col]) {
? ? ?case 'PRODUCT_LIST_NAME':
? ? ? ?$lc_text = TABLE_HEADING_PRODUCTS;
? ? ? ?$lc_align = '';
? ? ? ?break;
? ? ?case 'PRODUCT_LIST_PRICE':
? ? ? ?$lc_text = TABLE_HEADING_PRICE;
? ? ? ?$lc_align = 'right';
? ? ? ?break;
? ? ?case 'PRODUCT_LIST_IMAGE':
? ? ? ?$lc_text = TABLE_HEADING_IMAGE;
? ? ? ?$lc_align = 'center';
? ? ? ?break;
? ? ?case 'PRODUCT_LIST_BUY_NOW':
? ? ? ?$lc_text = TABLE_HEADING_BUY_NOW;
? ? ? ?$lc_align = 'center';
? ? ? ?break;
? ?}

? ?if ( ($column_list[$col] != 'PRODUCT_LIST_BUY_NOW') && ($column_list[$col] != 'PRODUCT_LIST_IMAGE') ) {
? ? ?$lc_text = tep_create_sort_heading($HTTP_GET_VARS['sort'], $col+1, $lc_text);
? ?}

? ?$list_box_contents[1][] = array('align' => $lc_align,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'params' => 'class="productListing-heading"',
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'text' => ' ' . $lc_text . ' ');
?}
? ?$rows = 0;

? ?while ($listing = tep_db_fetch_array($family_query)) {
? ?$listing['products_name'] = tep_get_products_name($listing['products_id']);
? ? ?$rows++;

? ? ?if (($rows/2) == floor($rows/2)) {
? ? ? ?$list_box_contents[] = array('params' => 'class="productListing-even"');
? ? ?} else {
? ? ? ?$list_box_contents[] = array('params' => 'class="productListing-odd"');
? ? ?}

? ? ?$cur_row = sizeof($list_box_contents) - 1;

? ? ?for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
? ? ? ?$lc_align = '';

? ? ? ?switch ($column_list[$col]) {
? ? ? ? ?case 'PRODUCT_LIST_NAME':
? ? ? ? ? ?$lc_align = '';
? ? ? ? ? ?if (isset($HTTP_GET_VARS['manufacturers_id'])) {
? ? ? ? ? ? ?$lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a>';
? ? ? ? ? ?} else {
? ? ? ? ? ? ?$lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a> ';
? ? ? ? ? ?}
? ? ? ? ? ?break;
? ? ? ? ?case 'PRODUCT_LIST_PRICE':
? ? ? ? ? ?$lc_align = 'right';
? ? ? ? ? ?if (tep_not_null($listing['specials_new_products_price'])) {
? ? ? ? ? ? ?$lc_text = ' <s>' . ?$currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</s>  <span class="productSpecialPrice">' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span> ';
? ? ? ? ? ?} else {
? ? ? ? ? ? ?$lc_text = ' ' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . ' ';
? ? ? ? ? ?}
? ? ? ? ? ?break;
? ? ? ? ?case 'PRODUCT_LIST_IMAGE':
? ? ? ? ? ?$lc_align = 'center';
? ? ? ? ? ?if (isset($HTTP_GET_VARS['manufacturers_id'])) {
? ? ? ? ? ? ?$lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>';
? ? ? ? ? ?} else {
? ? ? ? ? ? ?$lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a> ';
? ? ? ? ? ?}
? ? ? ? ? ?break;
? ? ? ? ?case 'PRODUCT_LIST_BUY_NOW':
? ? ? ? ? ?$lc_align = 'center';
? ? ? ? ? ?$lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> ';
? ? ? ? ? ?break;
? ? ? ?}

? ? ? ?$list_box_contents[$cur_row][] = array('align' => $lc_align,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'params' => 'class="productListing-data"',
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'text' ?=> $lc_text);
? ? ?}
? ?}

? ?new productListingBox($list_box_contents);
}
}
}
?>
<!-- family_products_eof //-->

 

HTH,

-Chris

Edited by blueline

Chris Sullivan

Link to comment
Share on other sites

  • 3 weeks later...

Hi Chris,

 

I really like your Contrib (3.3), it make?s things easier.

 

There are only two problems:

 

Once I assigned a family I am unable to edit it. The only way is to delete the family and make it again, with additional product.

 

Some families need categories assigned. There are too many matching products. Is there a way to do that?

 

Greetings, Michael

Not because it is difficult we don't dare to do it, but because we don't dare to do it, it is difficult. (Seneca)

Link to comment
Share on other sites

I know that some updates need to be made....I really just don't have the time to make them right now. The answer to both of your questions.....unfortunately.....is no.

 

I will try to make some improvements in the functionality, but I will have to do it as time permits.

 

-Chris

Chris Sullivan

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