Jump to content
Sign in to follow this  
bruyndoncx

[Contribution] Compare Products Side-By-Side

Recommended Posts

GOT IT!!!      :'(

Found there were some issues with the sql syntax and my version of mysql:

 

Had to change a 'join on' to 'left join'

and

added 'left' infront of a couple of joins

I guess I should update the sql to left join then ...

Is this the only one that needed changing or are there other incompatibilities ?

 

still doesn't work on my VARCHARS products though... >_<

But that's my problem.  Unless anyone has any tips??

I think all you are missing is putting a single quote around the explosion of product ids so that it becomes products_id in ('xx','yy') . There are several cases to change the following implosion line to something like this. Watch out for the mix of single and double quotes!

                     where p.products_id in ('" . implode("','", $columns) . "')";

Awesome contribution Carine!  Thanks!

Glad it is finally (almost) working for you !


KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Share this post


Link to post
Share on other sites
Anyone else having any other ideas about this, or seen similar errors ?

 

 

1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ') and pd.language_id = '1' order by p.products_id asc' at line

select p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from products_description pd join products p using (products_id) left join manufacturers m using (manufacturers_id) left join specials s on p.products_id = s.products_id where p.products_id in () and pd.language_id = '1' order by p.products_id asc

[TEP STOP]

 

 

To: Alex_rus

~/compare.php

 

replace:

from products_description pd join products

with:

from products_description pd left join products

 

replace:

from products p join products_description

with:

from products p left join products_description

 

to mysql base (with use myphpadmin or console client):

alter table products_options add products_options_is_static int(1) not null default '0';

 

Must be work!!

 

 

worked... thanks

 

greetz john

Share this post


Link to post
Share on other sites

I want install this great contribution; first I want see online demo. Please, give me a link where contrib is working. Thank you


Skype: centoasa

Skype: remigioruberto

Share this post


Link to post
Share on other sites

changing join to left join seems to be necessary in some versions of mysql

 

the alter table mentioned above is not necessary with the latest version. The field is only referenced if you have static attributes enabled. So as long as you don't enable it in the admin, you won't get any error about this.

 

Demo is available on http://www.keukenlust.com for instance searching on 'anna' gives products that are available in different colors.


KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Share this post


Link to post
Share on other sites

I use a contribution Product Listing in columns. I listen to have a demo of compare products that work with this contribution.

This is my code in product_listing_col:

<?php

 

DEFINE('PRODUCT_LIST_COL_NUM',2);

 

$listing_split = new splitPageResults($listing_sql, MAX_DISPLAY_SEARCH_RESULTS, 'p.products_id');

 

if ( ($listing_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3') ) ) {

?>

<table border="0" width="100%" cellspacing="0" cellpadding="2">

<tr><td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>

<td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>

</tr>

</table>

<?php

}

 

$info_box_contents = array();

 

if ($listing_split->number_of_rows > 0) {

 

$row = 0;

$col = 0;

 

$listing = tep_db_query($listing_split->sql_query);

while ($listing_values = tep_db_fetch_array($listing)) {

 

$listing_values['products_name'] = tep_get_products_name($listing_values['products_id']);

 

$lc_text= '<table border="0" widht="120" align="top"><tr><td><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $listing_values['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing_values['products_image'], $listing_values['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a> </td><td valign="middle" class="CarritoCabecera"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $listing_values['products_id']) . '">' . $listing_values['products_name'] . '</a></td>';

if ($col<1) {

$lc_text .= '<td rowspan="2" background="./images/template/h1_vertical.jpg">   </td></tr>'; }

else {

$lc_text .= '</tr>'; }

if ($listing_values['specials_new_products_price']) {

$lc_text .= '<tr><td class="CarritoCabecera" align="center"> <s>' . $currencies->display_price($listing_values['products_price'], tep_get_tax_rate($listing_values['products_tax_class_id'])) . '</s>  <span class="productSpecialPrice">' . $currencies->display_price($listing_values['specials_new_products_price'], tep_get_tax_rate($listing_values['products_tax_class_id'])) . '</span> </td>';

} else {

$lc_text .= '<tr><td class="CarritoCabecera" align="center"> ' . $currencies->display_price($listing_values['products_price'], tep_get_tax_rate($listing_values['products_tax_class_id'])) . ' </td>';

}

 

if (PRODUCT_LIST_BUY_NOW) {

$lc_text .= '<td align="right"><a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing_values['products_id'], 'NONSSL') . '">' . tep_image_button('button_buy_now.gif', TEXT_BUY . $listing_values['products_name'] . TEXT_NOW) . '</a> </td></tr></table>';

}

$lc_text .= '<img src="./images/template/h1_horiz.jpg" align="left"></img>';

$info_box_contents[$row][$col] = array('align' => 'right', 'params' => 'class="smallText" width="50%" valign="top"',

'text' => $lc_text);

 

$col ++;

if ($col > PRODUCT_LIST_COL_NUM-1) {

$col = 0;

$row ++;

}

}

 

new contentBox($info_box_contents);

 

} else {

 

$info_box_contents = array();

 

$info_box_contents[0] = array('params' => 'class="productListing-odd"');

$info_box_contents[0][] = array('params' => 'class="productListing-data"',

'text' => TEXT_NO_PRODUCTS);

 

new contentBox($info_box_contents);

 

}

 

if ( ($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) ) {

?>

<table width="100%">

<tr>

<td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>

<td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>

</tr>

</table>

<?php

}

?>

 

Can someone help me to adapt this contribution

 

Thanks and sorry for my english. I?m spanish.

My web is www.informundo.com

Share this post


Link to post
Share on other sites
Guest
I think all you are missing is putting a single quote around the explosion of product ids so that it becomes products_id in ('xx','yy') . There are several cases to change the following implosion line to something like this. Watch out for the mix of single and double quotes!

 ? ? ? ? ? ? ? ? ? ? where p.products_id in ('" . implode("','", $columns) . "')";

 

That did the Trick! THANKS!!!

 

 

One Final question:

 

Can you give me an idea how to add information from custom tables I've made which contain features and specs? If I could get features and specs to line up below what exists...I'd be all set!

 

Thanks,

 

Rob

Share this post


Link to post
Share on other sites

@informundo

I'm working on this, just got side tracked a bit ...

 

@B1TZM@ST3R

Can you run the mysql command describe on the tables that you use to store features and specs ?

eg describe products;

and paste the output here.

 

Generally speaking there are ample examples in the code, the question is which example is more appropriate as a starting point.


KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Share this post


Link to post
Share on other sites
Guest
@B1TZM@ST3R

Can you run the mysql command describe on the tables that you use to store features and specs ?

eg describe products;

and paste the output here.

 

Generally speaking there are ample examples in the code, the question is which example is more appropriate as a starting point.

 

I hope this works for you?

 

- - - - - - -

products_features TABLE:

Field Type Null Key Default Extra

product_id varchar(30) PRI

feature1 varchar(100) YES NULL

feature2 varchar(100) YES NULL

feature3 varchar(100) YES NULL

feature4 varchar(100) YES NULL

feature5 varchar(100) YES NULL

 

**This actually contains 20 feilds...I figured you didn't need to see a repeat of all 20.

 

- - - - - - -

 

products_specs TABLE:

Field Type Null Key Default Extra

product_id varchar(30) PRI

spec1 varchar(100) YES NULL

spec2 varchar(100) YES NULL

spec3 varchar(100) YES NULL

spec4 varchar(100) YES NULL

 

**Again contains 20 total feilds.

 

- - - - - - - -

 

Did I mention..."YOU ROCK!"?

 

Thanks,

 

Rob

Share this post


Link to post
Share on other sites

Ough,

That's practically hardcoded and there isn't anything like that in the current code.

Need to create some loops to display the data. Or truely hardcode but that's against my principles

 

For the display do you want to have Features in the first column and then all of the features from 1 to 20 in the next cell, or is there a description for what featureN represents ?


KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Share this post


Link to post
Share on other sites

Sample Product listing col.php file with the compare products changes is added to the contribution.

 

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

 

(Live shop) Demo is on http://www.keukenlust.com/index_col.php


KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Share this post


Link to post
Share on other sites
Guest

I guess my goal would be to list any feilds that aren't empty. It will be up to us to make sure the information lines up.

 

I know my partner would like to see something like shopping.com offers...Here's a sample:

shopping.com product comparisons

 

I'm sure it would take a ton more coding to make each row match a specific feature or spec...I'll try to add that at a later date.

 

If you have any ideas...I'd be willing to listen :blush:

Share this post


Link to post
Share on other sites
Guest

I might also mention...

 

another shopping.com feature I need to try to add is the ability to filter by specific features and specs. I'm just now starting to work on this feature.

 

Check out this sample:

Find By Feature

you can sort by price brand or memory...

 

 

This may mean I have to redesign the way things are laid out in the database to allow for filtering this way.

 

I'm not as good at this stuff as I'd like to be :blink:

 

I'll have to think about it some more...just thougth it might affect my above request.

 

Thanks.

Edited by B1TZM@ST3R

Share this post


Link to post
Share on other sites

To me this looks like you'd be better of installing products extra fields contribution and adding a field type to say feature / specification.

 

If you use attributes you have some sample code on how to search in the attribute search contribution. Basically you could create links that mimic specific canned queries.

 

looks there's no point in getting compare to work with your current setup as it doesn't scale to what you want it to do.


KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Share this post


Link to post
Share on other sites
Guest

I'll have to try and rethink how this will work...

 

I've been struggling trying to wrap my mind around 4,000 products and how to keep the database structured to handle all our special needs.

 

Thanks for your help...

Edited by B1TZM@ST3R

Share this post


Link to post
Share on other sites

Hi,

Thanks for this excellent contrib, the version 1.2 seems to work with B2B contrib. But i still have small issue. :huh:

 

For example if have a list of products, say 10 items.

 

If i check item 2,3,4,6,7 (any combination, but NOT including the first item) everything works just fine.

But if i choose the first item the screen refresh and immediately does to compare screen.

this issue, as i understand, due to following code.

 

 ? /* BoF Compare Products side-by-side
? ? ? ? Insert first column to add checkbox to compare products */
?$list_box_contents[0][] = array('align' => "center",
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'params' => 'class="productListing-heading"',
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'text' => TABLE_HEADING_COMPARE . '<br>' . tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '<!--/form-->');
?/* EoF Compare Products side-by-side */

(step 3.2)

the problem is in code <!--form-->. If i change it back to </form>, as stated in install instruction, contrib always write nothing to compare, if i change it to <!--/form--> the contrib starts to work but as described above.

 

Any ideas on how to fix it - where to close <form> tag???

 

Any help will be appreciated.

 

With best regards

Alexander

 

P.S. Any chance you make it compatible with Product properties 2.01??? :-"

Edited by alex_rus

Share this post


Link to post
Share on other sites

Compare with product_listing_col don?t work. I installed the contribution with the product_listing_col_sample and don?t see the button to compare.

I added this of the original contribution:

 

$info_box_contents = array();

/* BoF Compare Products side-by-side

Insert first column to add checkbox to compare products */

$info_box_contents[0][0] = array('align' => "center",

'params' => 'class="productListing-heading"',

'text' => TABLE_HEADING_COMPARE . '<br>' . tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</form>');

/* EoF Compare Products side-by-side */

 

and i see the buttom, but don?t go the link

 

Thanks

Share this post


Link to post
Share on other sites
Compare with product_listing_col don?t work. I installed the contribution with the product_listing_col_sample and don?t see the button to compare.

I added this of the original contribution:

 

  $info_box_contents = array();

/* BoF Compare Products side-by-side

Insert first column to add checkbox to compare products */

$info_box_contents[0][0] = array('align' => "center",

'params' => 'class="productListing-heading"',

'text' => TABLE_HEADING_COMPARE . '<br>' . tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</form>');

/* EoF Compare Products side-by-side */

 

and i see the buttom, but don?t  go the link

 

Thanks

 

Ah, a small bug in product_listing_col.php

 

I tested with a number of products per page setting that didn't fit nicely in the rows/columns.

 

It seems if you have the number of products fitting nice, the row at the bottom didn't show.

 

here's the code to fix it, it's teh last section of code at the bottom:

change

$row++;

to

    if ($col > 0) $row ++;

so it becomes

    /* BoF Compare Products side-by-side
          Add last row with form to compare products */
   if ($col > 0) $row ++;
   $info_box_contents[$row][0] = array('align' => "right",
                                      'params' => 'class="productListing-heading" colspan="' . PRODUCT_LIST_COL_NUM .'"',
                                        'text' => tep_draw_form('compare', tep_href_link("compare.php", tep_get_all_get_params(array('action')))) 
                                                  . TABLE_HEADING_COMPARE . tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</form>');
   /* EoF Compare Products side-by-side */


KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Share this post


Link to post
Share on other sites

@alex_rus,

Sorry, on my site it's all working correctly.

Do you have a url to look at ?

 

Similarly for product properties, are you using that contribution ?

If I write the code for it, can you test it ?

 

Carine


KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Share this post


Link to post
Share on other sites
@alex_rus,

Sorry, on my site it's all working correctly.

Do you have a url to look at ?

 

Similarly for product properties, are you using that contribution ?

If I write the code for it, can you test it ?

 

Carine

 

 

Yes, I use Product Properties and can test it.

 

Currently the access to site is blocked with down for maintains. I'll switch this mod off tonight and post the link.

 

Thanks fo help

 

Alexander

Share this post


Link to post
Share on other sites

Hi, i solved the issue:

the problem was in following:

in readme.txt the step 3.1 is described as following:

? 3.1 Find (~line 22)

 

</table>
<?php
?}

 

? ? ? ?  Replace With

 

</table>
<?php
?}
?/* BoF Compare Products side-by-side */
?echo tep_draw_form('compare', tep_href_link("compare.php", tep_get_all_get_params(array('action'))), 'get'); ?>
<?php
?/* EoF Compare Products side-by-side */

 

but this didn't worked for me,

the code which was ok for me:

 

<?php
?}
?/* BoF Compare Products side-by-side */
?echo tep_draw_form('compare', tep_href_link(basename('compare.php'), tep_get_all_get_params(array('action')) ));?> 
<?php
?/* EoF Compare Products side-by-side */

 

Now it works great.

 

PS. regarding Product Properties 2.01 - I use it and if you have time to add support for this contrib in your Compare Products Side-by-Side contrib, i can test it.

 

With best regards

Alexander

Edited by alex_rus

Share this post


Link to post
Share on other sites

hi all:

 

i'm suffering from a case where all my products extra fields (PEF) are being compared twice. it seemed the comparison looped twice for me. i have about 20 PEFs for each product. it would compare all 20 PEFs and then compare the same 20 PEFs the second time. strange!!!

 

the basic comparisons, i.e. model, price, name, etc ... are working fine.

 

did anyone get the same results i got?

Share this post


Link to post
Share on other sites
hi all:

 

i'm suffering from a case where all my products extra fields (PEF) are being compared twice.  it seemed the comparison looped twice for me.  i have about 20 PEFs for each product. it would compare all 20 PEFs and then compare the same 20 PEFs the second time.  strange!!!

 

the basic comparisons, i.e. model, price, name, etc ... are working fine.

 

did anyone get the same results i got?

ouch! guess what. if i select 3 products, the comparison loops 3 times around the PEFs.

 

can someone advise what i should look for in the compare.php file to debug this?

 

thanks

 

tom

Share this post


Link to post
Share on other sites

ough, a stupid oversight from me

 

Need to add a section to get the unique list of PEF just like is done for options.


KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Share this post


Link to post
Share on other sites
ough, a stupid oversight from me

 

Need to add a section to get the unique list of PEF just like is done for options.

Well the code was already there, but the products_id was in the wrong place.

 

Fixit by making the following 2 changes:

 

Change

   	 $pef_select  = "select distinct p.products_id, pef.products_extra_fields_id, pef.products_extra_fields_name ";

 

To

   	 $pef_select  = "select distinct pef.products_extra_fields_id, pef.products_extra_fields_name ";

 

And

Change

      $pef_details_query = $pef_select . ", p2pef.products_extra_fields_value " . $pef_from . $pef_orderby;

To

      $pef_details_query = $pef_select . ", p.products_id, p2pef.products_extra_fields_value " . $pef_from . $pef_orderby;


KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Share this post


Link to post
Share on other sites
Guest

I tested this and another demo keukenlust.com Demo and is wondering if it is a bug that the page ALWAYS is updated (by it self) each time a product is selected for comparision or if it is the way this compare Products side-by-side contribution works...?

 

Anyway, It looks like a great contribution :)

 

Prince Tom

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
Sign in to follow this  

×