Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] Compare Products Side-By-Side


Recommended Posts

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

yes it is always updating upon clicking the checkbox.

as you can flag items on the different pages, need to tag things upon each change, otherwise wasn't able to compare items in the same category but on different pages.

This is one of the current limitations, if I get the time to redesign it and make use of classes (like eg shopping cart or wishlist) then it might not be necessary, but right now it's a bit like necessary evil.

Maybe someone else has a better idea, but that's the solution I came up with at that time ...

I don't see it as a big issue as you typically don't enter anything on this page that you might loosing with the refresh.

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

Link to comment
Share on other sites

Hi Carine,

 

I'm still trying to modify this awesome contribution to meet my needs where we can list the additional features and specs.

 

I've almost got it...i've modified the PEF code to work with my data.

I've changed the design of the features/specs tables where each avail spec will have it's own table.

Here is a desc of one of the tables:

 

Field Type Null Key Default Extra

gpm text

gpm_id varchar(50) PRI 0

gpm_name varchar(50) YES NULL

 

 

Here are the two blocks of code I used to pull the data:

//Gather the info for GPM
if (COMPARE_PRODUCTS_SIDEBYSIDE_PEF == 'true') {	
  	 //List of pef fields
 $gpm_select  = "SELECT p.products_id, p.gpm_id, g.gpm_id, g.gpm_name";
     $gpm_from    = "  FROM products p LEFT  JOIN gpm g USING ( gpm_id ) 
                               WHERE products_id  in ('" . implode("','", $columns) . "')"; 
     //$pef_orderby = " order by gpm_id asc";
     $gpm_query = $gpm_select . $gpm_from /*. $pef_orderby;*/;
     $gpm_result = tep_db_query($gpm_query); 
  
       //matrix with pef details
     $gpm_details_query = $gpm_select . $gpm_from /*. $pef_orderby*/;
     $gpm_details_result = tep_db_query($gpm_details_query);
   
      //fill pef matrix
     $gpm_matrix = array();
     while ($row = tep_db_fetch_array($gpm_details_result)) {
            $gpm_matrix[$row['products_id']][++$matrix[$row['products_id']][cn]] = $row; 
     }
     if (COMPARE_PRODUCTS_SIDEBYSIDE_DEBUG == 'true') print_r($gpm_matrix);
     }
//End GPM gather

- - - - - - - - - -  and - - - - - - - - - - - - - 


//SHOWING THE GPM INFO	

    if (COMPARE_PRODUCTS_SIDEBYSIDE_DESCRIPTION == 'true') {
       $cur_row++;
       $list_box_contents[$cur_row][] = array('align' => $lc_align,
                                       'params' => 'class="compareListing-data"',
                                       'text' => '<b>GPM</b>');
       for ($k = 0; $k < count($columns); $k++) {
           $list_box_contents[$cur_row][] = array('align' => $lc_align,
                                       'params' => 'class="compareListing-data"',
                                       'text' => ' ' . $pd[$columns[$k]]['gpm_id'] . ' ');
       }
   }
//End Gpm Show

 

 

This works GREAT!

My Problem is when I try to duplicate it for PSI it won't pull the data into the fields?

 

Here is a link to my store's sample: Portland Compressor?

 

Any Idea Why???

 

I Figure I would simply replicate the above chunks of code for each of my feature/spec tables...I'm sure there is a better way...but I'm on a deadline.

 

Thanks again!

 

Rob

Link to comment
Share on other sites

Rob,

Is the PSI table exactly the same as the GPM ?

Does it use the same field names ? If not, you have to adapt select clause as well as display section.

The fact that PSI label shows is just because it is hardcoded, I think it will show always, no matter if there is data or not.

You are also checking for the wrong section (first part PEF, second display for description).

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

Link to comment
Share on other sites

Yes...the tables are exactly the same except that psi replaces gpm.

 

The duplicated blocks of code also have 'psi' in place of 'gpm'.

 

You are also checking for the wrong section (first part PEF, second display for description).

 

Not sure what you mean...I know I have commented out some fo the pef stuff...did I miss something?

 

I understand I hard coded the PSI description...is there a better way?

 

 

 

Thanks!

Link to comment
Share on other sites

The first check is unnecessary as I assume you always want this included in your comparison

The second, the clause "IF (COMPARE_PRUDUCTS ...

should really be checking in your case if the e.g. gpm_matrix is empty or not

so it becomes

if ($gpm_matrix) {

 

 

in the above code there seems to be a bug.

You populate the $gpm_matrix but upon display you refer to $pd which should also by $gpm_matrix

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

Link to comment
Share on other sites

Ok...Almost got it...

One last question and I'm set!

 

I just need to fix that check to see if the matrix is empty so if it is...that spec's row won't show up.

 

I did modify the code like you mentioned yet I must be missing something:

if ($gpm_matrix != '')

 

   
if ($gpm_matrix != '') {
       $cur_row++;
       $list_box_contents[$cur_row][] = array('align' => $lc_align,
                                       'params' => 'class="compareListing-data"',
                                       'text' => '<b>GPM</b>');
       for ($k = 0; $k < count($columns); $k++) {
           $list_box_contents[$cur_row][] = array('align' => $lc_align,
                                       'params' => 'class="compareListing-data"',
                                       'text' => ' ' . $pd[$columns[$k]]['gpm_id'] . ' ');
       }
   }

This still allows the GPM row to show up even if there is no info there.

I can't figure out how to prevent that??

 

- - - - - - - - - - - - - N O T E - - - - - - - - - - - - -

The $pd issue was the key! I did keep it in this function because I added 'gpm_id' to the $pd query.

Turns out...I was missing that when I duplicated those blocks of code...

WORKS PERFECT NOW!

THANKS!

Link to comment
Share on other sites

SCRATCH THAT LAST REQUEST...I GOT IT!

 

 

I just created a string to use in the check:

 

  while ($row = tep_db_fetch_array($gpm_result)) {
	 $gpm_string = ($row['gpm_id']);//HAD TO CREATE A VALUE  TO CHECK FOR TO DETERMINE IF THE ROW WILL SHOW
}

//echo $gpm_string;  //THIS IS FOR TESTING


   if ($gpm_string != '') {
       $cur_row++;
       $list_box_contents[Yadda...Yadda...Yadda....

 

I'm sure there's a better way...As long as it works, I'm happy :rolleyes:

 

Thanks again Carine for this awesome contribution!!!

 

Rob

Link to comment
Share on other sites

ok?, glad you sorted things out.

 

As for the check, I though just if ($x) would do the trick, maybe if (isarray($x)) is needed for arrays to distinguish empty array.

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

Link to comment
Share on other sites

One quick question...and I swear I'll leave you alone :-"

 

Is there a way to modify the checkbox form on the Product Listing page to prevent the page from refreshing each time you select an item to compare.

Can the data be sent only once the 'compare' button has been clicked?

 

Thanks,

 

Rob

Link to comment
Share on other sites

One quick question...and I swear I'll leave you alone  :-"

 

Scratch that...I read the answer a few posts up...Sorry

 

I would be interested in knowing if/when you got the refresh that happens each time you click an item to compare changed.

 

This contribution is going to work GREAT in our site!

Thanks for taking the time to put it together.

 

:thumbsup:

 

Rob

Link to comment
Share on other sites

you'll be the first to know, once I start, I'll start talking about it in my blog on this forum, but for now, I'm pretty tied up with xmas preparations.

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

Link to comment
Share on other sites

Hi guys,

 

I found that the comparison wasn't quite fair - as it didn't show any price addition/reduction reached by means of options (which would be interesting when comparing :)

 

I have just uploaded a modded compare.php that fixes this.

 

simply replace compare.php with this one, and it will show prices for options that has them, and add tax if so selected.

 

NB. I had to bad hack the tax in - the last item in the comparison list, it simply takes the tax_class_id from that, and uses that for all products - ie. comparison of two products, in different tax-groups won't work properly (unless you've selected to show price without tax :)

(that's why the tax var is called mybadtax :)

Link to comment
Share on other sites

excellent, now I don't have the latest version installed ... gotto correct that :D

 

Thanks Klavs for making the effort and sharing 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

Link to comment
Share on other sites

Hi guys,

 

I found that the comparison wasn't quite fair - as it didn't show any price addition/reduction reached by means of options (which would be interesting when comparing :)

 

I have just uploaded a modded compare.php that fixes this.

 

simply replace compare.php with this one, and it will show prices for options that has them, and add tax if so selected.

 

NB. I had to bad hack the tax in - the last item in the comparison list, it simply takes the tax_class_id from that, and uses that for all products - ie. comparison of two products, in different tax-groups won't work properly (unless you've selected to show price without tax :)

(that's why the tax var is called mybadtax :)

 

 

don't work the link

Link to comment
Share on other sites

Klavs has uploaded a version in ZIP format that can be downloaded without problems.

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

Link to comment
Share on other sites

Some suggest about this mod

 

At first it is a good contribution

 

I have install it and can use

 

I want to give some suggest to this mod

 

1. when I select one product to comp the page "index.php?cPath=***" reload once

 

when i want to comparison

it also reload.

 

I have visit a site :

http://product.zol.com.cn/products/product...4&keyword=intel

//it's chinese

 

it use javescript and a layer to comparison

//and the speed is very soon

when select

it only to add a products name to a layer //not recall the file and add array

when select it, it select form the database

 

and to comp

 

all only once

======================

to see the page at:

 

http://product.zol.com.cn/products/product...4&keyword=intel

 

in the left is comparison and in the layer the bottom is to comp

osCommerce

Link to comment
Share on other sites

A Few Install Issues!!

 

What directory does the product_listing_col.php reside in?

 

How do you align the contents of the Comparison? At present all are centred resulting in unusual formatting. We want the contents to be aligned to the left or justifed.

 

In terms of the install file a number of modifcations have been added however you appear to have to keep downloading mutilpe files to complete the install. Is it possible to have one file containig all the changes and up to date instructions. For example how do you install :product_listingMS2 sample? and how is that used with the contribution? Where does product_listing_col.php fit in......

 

Other than that BRILLIANT!!!!!!!

 

Thanks

 

peterb

Link to comment
Share on other sites

Some suggest about this mod

 

At first it is a  good  contribution

 

I have install it  and can  use

 

I want to give some suggest to this mod

 

1.  when I select one product to comp the page "index.php?cPath=***" reload once

 

when i want to comparison 

  it also reload.

 

I have visit a site :

http://product.zol.com.cn/products/product...4&keyword=intel

//it's chinese

 

it use javescript and a layer to comparison

//and the speed is very soon

when select

it only to add a products name to a layer //not recall the file and add array

when  select it,  it select form the database

 

and  to comp

 

all only once

======================

to see the page at:

 

http://product.zol.com.cn/products/product...4&keyword=intel

 

in the left is comparison  and in the layer  the bottom is to comp

 

You are totally correct. The mechanism is not elegant at all, the chinese javascript solution really looks a lot nicer and is quick in adding.

I looked at the page source, but my javascript skills are just slightly better than my chinese and all comments are in chinese, so I gave up trying to understand exactly how it all works.

I did do a test, adding stuff to the compare basket, and then doing another search, and the basket remained.

 

Summary, yes, I like this solution a lot, are you able to re-engineer this into osC and upgrade the contribution with this ?

Or, alternatively, could you provide comments in english on this piece of code ?

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

Link to comment
Share on other sites

What directory does the product_listing_col.php reside in?

in catalog/includes/modules/

see the product listing in columns contribution for installation instructions for this file if you don't have product listing in columns yet.

 

How do you align the contents of the Comparison? At present all are centred resulting in unusual formatting. We want the contents to be aligned to the left or justifed.

To change the default, in compare.php find the following code:

    // Begin table heading
   $lc_align = "center";

change it too

    // Begin table heading
   $lc_align = "left";

or you can change it for specific rows or sections of data by adding HTML style tags eg for the descriptions (not the label) change it to (changed on 7th line):

   if (COMPARE_PRODUCTS_SIDEBYSIDE_DESCRIPTION == 'true') {
       $cur_row++;
       $list_box_contents[$cur_row][] = array('align' => $lc_align,
                                       'params' => 'class="compareListing-data"',
                                       'text' => TABLE_HEADING_DESCRIPTION);
       for ($k = 0; $k < count($columns); $k++) {
           $list_box_contents[$cur_row][] = array('align' => 'left',
                                       'params' => 'class="compareListing-data"',
                                       'text' => ' ' . $pd[$columns[$k]]['products_description'] . ' ');
       }
   }

 

In terms of the install file a number of modifcations have been added however you appear to have to keep downloading mutilpe files to complete the install. Is it possible to have one file containig all the changes and up to date instructions. For example how do you install :product_listingMS2 sample? and how is that used with the contribution? Where does product_listing_col.php fit in......

Both these files are sample files with the compare code included.

If you didn't make any changes to your product listing, you can just save these files in your catalog/includes/modules/ directory.

product_listingMS2sample needs to be renamed to product_listing.php

product_listing_col.php has the correct name (per that contributions naming convention)

 

yes, we try to keep things comprehensive but sometimes when only one file needs to be added, or overwritten, we tend to take the shortcut. Evidently when file updates then go wrong, it becomes messy.

I'll try to get a proper full set back online in a couple of days, I do not want to include Klavs update in the core without tackling the different tax rates.

 

Other than that BRILLIANT!!!!!!!

Glad that in the end it's still a 'shining' contribution :D

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

Link to comment
Share on other sites

  • 1 month later...

Just tested with 2 products on your site, seemed to work fine.

I dont understand what the problem would be.

I compared 2 lacie harddisks.

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

Link to comment
Share on other sites

  • 1 month later...

Hello,

I manually added extra database fields into my database and edited all of the files needed to to get my site to work. However, I haven't figured out how to get this contribution to reconize the fields I added. Anyone know how to do this? Thanks!

 

Adam

Link to comment
Share on other sites

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.

 

I would need this contribution too. If you made it or got it to work, pls drop me an email at [email protected]

 

Here is a like demonstration of this filterin feature and they have a nice compare nodule too: http://www.emag.ro/default.php?cale=48

You have "Filtreaza" by Manufacurer or size. And yes, that is oscommerce.

Link to comment
Share on other sites

Hello,

  I manually added extra database fields into my database and edited all of the files needed to to get my site to work.  However, I haven't figured out how to get this contribution to reconize the fields I added.  Anyone know how to do this?  Thanks!

 

Adam

Can you describe which fields you added to your database to which tables or if complete new tables, please describe the table structure.

Then I can tell you what code to add where

 

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

Link to comment
Share on other sites

I would need this contribution too. If you made it or got it to work, pls drop me an email at [email protected]

 

Here is a like demonstration of this filterin feature and they have a nice compare nodule too: http://www.emag.ro/default.php?cale=48

You have "Filtreaza" by Manufacurer or size. And yes, that is oscommerce.

The filtering by memory etc can be done by building on top of the advanced attributes search contribution.

This ofcourse implies that all of this data is maintained as options possibly setup as static option for product specifications.

I'm not aware of any contribution that implements advanced search for extra fields or for the product properties contribution, but what is not yet done, can still come, one day, when someone has the need and can find the time :)

 

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

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