Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Sort Products By Dropdown


Recommended Posts

Support forum for Sort Products By Dropdown

 

WHAT THIS CONTRIB DOES:

This contribution allows you to sort the products in a category by multiple methods, by best sellers, products name, and by price. The best sellers are updated daily by cron job and you can set the number of days back to look at sales to base your best sellers on.

 

The way sort by price and name is pretty straightforward, the way best sellers works is each order counts as one sale so if someone orders 50 of item (A) and item ( B ) is ordered 5 times but only 1 each time, item ( B ) will show 5 sales and item (A) will show only 1 so the one that was more popular with multiple people will be ranked higher -- item B. This can be changed by modifying the code in cron_update_bestsellers.php slightly if you wish to count by total number of items sold instead it is noted how to do so in the code.

Edited by homewetbar

Most Valuable OsCommerce Contributions:

Also Purchased (AP) Preselection (cuts this resource hogging query down to nothing) -- Contribution 3294

FedEx Automated Labels -- Contribution 2244

RMA Returns system -- Contribution 1136

Sort Products By Dropdown -- Contribution 4312

Ultimate SEO URLs -- Contribution 2823

Credit Class & Gift Voucher -- Contribution 282

Cross-Sell -- Contribution 5347

Link to comment
Share on other sites

  • Replies 87
  • Created
  • Last Reply

Top Posters In This Topic

Thank you Keith for this great contribution. The sorting works perfect, but there's one problem. In my product listing the price is shown twice, although i've set the sort order of Product Recent Sales to 5 (my last visible column has the sort order of 4). I've also tried setting it to 4 (same value as the last visible column), but then the products name is shown twice.

 

Any idea how to fix that?

Link to comment
Share on other sites

Thank you Keith for this great contribution. The sorting works perfect, but there's one problem. In my product listing the price is shown twice, although i've set the sort order of Product Recent Sales to 5 (my last visible column has the sort order of 4). I've also tried setting it to 4 (same value as the last visible column), but then the products name is shown twice.

 

Any idea how to fix that?

 

 

Strange, try setting it to 6. Also have you installed any contribs specificly any that would have modified includes/modules/product_listing.php or is this a clean oscommerce install ?

Most Valuable OsCommerce Contributions:

Also Purchased (AP) Preselection (cuts this resource hogging query down to nothing) -- Contribution 3294

FedEx Automated Labels -- Contribution 2244

RMA Returns system -- Contribution 1136

Sort Products By Dropdown -- Contribution 4312

Ultimate SEO URLs -- Contribution 2823

Credit Class & Gift Voucher -- Contribution 282

Cross-Sell -- Contribution 5347

Link to comment
Share on other sites

  • 3 weeks later...

Great script, it works great except for the colums. I am having the same problem as gunarbod. My last visible colum is 4 I set recent sales to 5 and I get two buy it now buttons, and two quantity boxes. I also tried six with the same result. Could you tell me of anyway to fix this. I do have a modified product_listing.php page.

Link to comment
Share on other sites

Great script, it works great except for the colums. I am having the same problem as gunarbod. My last visible colum is 4 I set recent sales to 5 and I get two buy it now buttons, and two quantity boxes. I also tried six with the same result. Could you tell me of anyway to fix this. I do have a modified product_listing.php page.

 

Download osCommece and try it with the default product_listing.php page. If it works for you then compare with your changed version and that should allow you to narrow down the problem.

Most Valuable OsCommerce Contributions:

Also Purchased (AP) Preselection (cuts this resource hogging query down to nothing) -- Contribution 3294

FedEx Automated Labels -- Contribution 2244

RMA Returns system -- Contribution 1136

Sort Products By Dropdown -- Contribution 4312

Ultimate SEO URLs -- Contribution 2823

Credit Class & Gift Voucher -- Contribution 282

Cross-Sell -- Contribution 5347

Link to comment
Share on other sites

Do you know how I could get rid of this problem?

 

Set the order number for the drop down to the number after the buy it now button in admin and try that with the default product_listing.php. Let me know if you're still having problems and what they are as I cannot see this on my side...

Most Valuable OsCommerce Contributions:

Also Purchased (AP) Preselection (cuts this resource hogging query down to nothing) -- Contribution 3294

FedEx Automated Labels -- Contribution 2244

RMA Returns system -- Contribution 1136

Sort Products By Dropdown -- Contribution 4312

Ultimate SEO URLs -- Contribution 2823

Credit Class & Gift Voucher -- Contribution 282

Cross-Sell -- Contribution 5347

Link to comment
Share on other sites

That is how I curently have it set up. Here is a screen shot of my settings: settings.

 

I am using the default product_listing.php as well, but I am still getting two buy now buttons. If it would help to see the page for your self I can post a link. Thanks for the help.

Link to comment
Share on other sites

  • 2 weeks later...
That is how I curently have it set up. Here is a screen shot of my settings: settings.

 

I am using the default product_listing.php as well, but I am still getting two buy now buttons. If it would help to see the page for your self I can post a link. Thanks for the help.

 

Ahh I see now, on my modified site I don't have some of this code. This should fix it for the base oscommerce and your modified version:

 

 

includes/modules/product_listing.php

 

FIND

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

 

REPLACE WITH

for ($col=0, $n=sizeof($column_list)-1; $col<$n; $col++) {

 

FIND:

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

 

 

REPLACE WITH:

	  for ($col=0, $n=sizeof($column_list)-1; $col<$n; $col++) {

 

 

Let me know how it works so I can post a fix to the contribution :thumbsup:

Edited by homewetbar

Most Valuable OsCommerce Contributions:

Also Purchased (AP) Preselection (cuts this resource hogging query down to nothing) -- Contribution 3294

FedEx Automated Labels -- Contribution 2244

RMA Returns system -- Contribution 1136

Sort Products By Dropdown -- Contribution 4312

Ultimate SEO URLs -- Contribution 2823

Credit Class & Gift Voucher -- Contribution 282

Cross-Sell -- Contribution 5347

Link to comment
Share on other sites

  • 1 month later...

Hi there,

 

This sounds like a fantastic mod. This site would hugely benefit my site. Has anybody got any live sites they that they could post with this contrib in working order?

Link to comment
Share on other sites

Hi there,

 

This sounds like a fantastic mod. This site would hugely benefit my site. Has anybody got any live sites they that they could post with this contrib in working order?

 

No, but it is an easy install, about 15-30 minutes to add to your site and see it yourself.

Most Valuable OsCommerce Contributions:

Also Purchased (AP) Preselection (cuts this resource hogging query down to nothing) -- Contribution 3294

FedEx Automated Labels -- Contribution 2244

RMA Returns system -- Contribution 1136

Sort Products By Dropdown -- Contribution 4312

Ultimate SEO URLs -- Contribution 2823

Credit Class & Gift Voucher -- Contribution 282

Cross-Sell -- Contribution 5347

Link to comment
Share on other sites

Hi,

 

Thank you for a fabulous contribution!

 

I have 2 questions. My previous default was to have all products sorted by name a to z. When I installed this contribution, my default listing (if the sort by dropdown is not used) is by name z to a. Is there a way to get it back to a to z?

 

Second, if I have Admin ---> Product Listing ---> Display Manufacturer set to display, the fields are next to each other which takes up too much room and reaks havoc on the layout. I'd like to add a <br> to have them show one on top of the other, but I can't seem to figure out how to do that. This is less important, because I don't mind having Display Manufacturer turned off, but it would be nice to know how to do it.

 

Any help is appreciated! :rolleyes:

Adrienne

Link to comment
Share on other sites

Ok, figured out #1 - it was actually sorting by best sellers, but since I hadn't figured out how to manually initiate the cron job, there weren't any bestsellers, and then it went z to a.

 

#2 - Still no idea on this one, any help?

 

Thanks,

Adrienne

Link to comment
Share on other sites

Hi there,

 

This is a great mod, thanks very much! I'm having a bit of a problem with it though and wonder if you could help.

 

The Price lo-hi/hi-lo and best selling sort works fine but when I select "product name a-z/z-a" I get the following error:

 

1064 - You have an error in your SQL syntax near 'limit 0, 20' at line 1

 

select p.products_image, pd.products_name, p.products_recent_sales, p.products_id, p.products_recent_sales, 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, products p left join manufacturers m on p.manufacturers_id = m.manufacturers_id, products_to_categories p2c left join specials s on p.products_id = s.products_id where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '1' and p2c.categories_id = '22' order by limit 0, 20

 

[TEP STOP]

 

Any clues? Pretty sure I followed the instructions word for word. Also do you know of a way to get the category listing and best selling listings to display by price lo-hi by default?

 

Many thanks in advance for any pointers.

 

Cheers

 

Chris

Link to comment
Share on other sites

Durr. My bad. I'd replaced this bit instead of appending to it in index.php:

 

case 'PRODUCT_LIST_NAME':

$listing_sql .= "pd.products_name " . ($sort_order == 'd' ? 'desc' : '');

break;

 

:)

Link to comment
Share on other sites

  • 2 weeks later...
Durr. My bad. I'd replaced this bit instead of appending to it in index.php:

 

case 'PRODUCT_LIST_NAME':

$listing_sql .= "pd.products_name " . ($sort_order == 'd' ? 'desc' : '');

break;

 

:)

 

I tried what Chris said was wrong with his install...I have triple=quadra checked the install it all seems fine...but m getting error ONLY when I move from lets say products z to A...n try going bak to Best sellers..jus to check bugs...n loooo volaa I get:

 

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 'limit 0, 20' at line 1

 

select p.products_image, pd.products_name, m.manufacturers_name, p.products_recent_sales, p.products_id, p.products_recent_sales, 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, products p left join manufacturers m on p.manufacturers_id = m.manufacturers_id left join specials s on p.products_id = s.products_id, products_to_categories p2c where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '1' and p2c.categories_id = '13' order by limit 0, 20

 

[TEP STOP]

 

I do have MSRP changes.

Please advise

Simple Add-ons Please add simple plain tips here for others.
Link to comment
Share on other sites

I tried what Chris said was wrong with his install...I have triple=quadra checked the install it all seems fine...but m getting error ONLY when I move from lets say products z to A...n try going bak to Best sellers..jus to check bugs...n loooo volaa I get:

 

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 'limit 0, 20' at line 1

 

select p.products_image, pd.products_name, m.manufacturers_name, p.products_recent_sales, p.products_id, p.products_recent_sales, 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, products p left join manufacturers m on p.manufacturers_id = m.manufacturers_id left join specials s on p.products_id = s.products_id, products_to_categories p2c where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '1' and p2c.categories_id = '13' order by limit 0, 20

 

[TEP STOP]

 

I do have MSRP changes.

Please advise

 

You missed a bracket or comma or other punctionation or have to many, uninstall and reinstall is normally the quickest since the install is so short...

Most Valuable OsCommerce Contributions:

Also Purchased (AP) Preselection (cuts this resource hogging query down to nothing) -- Contribution 3294

FedEx Automated Labels -- Contribution 2244

RMA Returns system -- Contribution 1136

Sort Products By Dropdown -- Contribution 4312

Ultimate SEO URLs -- Contribution 2823

Credit Class & Gift Voucher -- Contribution 282

Cross-Sell -- Contribution 5347

Link to comment
Share on other sites

  • 3 weeks later...

hi

 

Anyone know how to 'hold' the selected sort order when changing categories. Every time i change into another category the sort order reverts back to the default 'bestsellers' - slightly annoying .

 

Regards

 

Marc

Edited by marcus76
Link to comment
Share on other sites

hi

 

Anyone know how to 'hold' the selected sort order when changing categories. Every time i change into another category the sort order reverts back to the default 'bestsellers' - slightly annoying .

 

Regards

 

Marc

 

 

No possible, you would have to modify your categories box and save the customer's choice of preference then apply it to the new category.

Most Valuable OsCommerce Contributions:

Also Purchased (AP) Preselection (cuts this resource hogging query down to nothing) -- Contribution 3294

FedEx Automated Labels -- Contribution 2244

RMA Returns system -- Contribution 1136

Sort Products By Dropdown -- Contribution 4312

Ultimate SEO URLs -- Contribution 2823

Credit Class & Gift Voucher -- Contribution 282

Cross-Sell -- Contribution 5347

Link to comment
Share on other sites

  • 2 months later...

Thanks for at great contribute!

 

I got this tiny problem that when i sort our products, and go to next page, the sorting dosent continue.

 

Do anybody know have to fixe that, i would appreciate the help a lot.

Link to comment
Share on other sites

  • 3 months later...

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