Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Sort Products By Dropdown


Recommended Posts

  • Replies 87
  • Created
  • Last Reply

Top Posters In This Topic

this is really awesome!

 

is there anyway to sort the products by how recently they've been listed (ie, where the newest items would be listed first)?

 

 

You would have to add some logic to sort by the added date, it will not do this as is...

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!

 

Very useful contribution, thanks!

 

I'd like to have the dropdown in different languages.

 

The words in question are Best Sellers, Products Name A to Z, etc.

 

The code snippet is:

 

$sort_list = array('5d' => 'Best Sellers',
	 			'2a' => 'Products Name A to Z',
						'2d' => 'Products Name Z to A',
						'3a' => 'Price Low to High',
						'3d' => 'Price High to Low');

 

How do I accomplish this?

Link to comment
Share on other sites

  • 3 months later...

Awesome contrib.

 

Can this be integrated into the advanced_search_result.php page ? I saw in the installation instructions for this contrib that you can tweak that page to always sort by Best Sellers, but I'd like to have the full-blown dropdown menu above the table.

 

I tried making the same mods from catalog/index.php in the advanced_search_result.php file, as they were essentially the same. I did end up with a dropdown on the page, but when I tried changing the sort order through the dropdown, I ended up either:

 

1) at a product_listing page containing all the products for the manufacturer I had searched for

2) being redirected to index.php if I hadn't specified a manufacturer

 

It seems to have something to do with this code:

 

if (isset($HTTP_GET_VARS['manufacturers_id'])) {
		 echo tep_draw_hidden_field('manufacturers_id', $HTTP_GET_VARS['manufacturers_id']);
	 } else {
		 echo tep_draw_hidden_field('cPath', $cPath);
	 }

 

...but I'm not sure because I sort of suck at PHP and could be totally mistaken. :rolleyes:

 

Any thoughts?

Link to comment
Share on other sites

  • 1 month later...

Hi,

 

I've installed this and all seems well until I try to click on the next page (or any other page numbered) within the results, without resorting from the drop down menu.

 

I get the following error message come up and I have seen that others also receive the same message but havent seen a solution to resolve it. Message reads:

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 'p.products_recent_sales desc, pd.products_name desc' at line 1

 

select count(p.products_id) as total 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 = '14'p.products_recent_sales desc, pd.products_name desc

 

[TEP STOP]

 

 

 

If I sort the products with the dropdown menu and try changing the page it all works great. Any suggestions?

 

Thanks in advance.

 

 

Sorry, I've managed to sort it myself, just incase others get the same problem, this is what I did.

 

On the Installation instructions it states to have the following:

 

FIND:

case 'PRODUCT_LIST_NAME':

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

break;

 

BELOW ADD:

case 'PRODUCT_LIST_30SALES':

$listing_sql .= "p.products_recent_sales desc, pd.products_name desc";

break;

 

And to rectify it I added Order by so the 2 lines in question now looked like this:

 

case 'PRODUCT_LIST_NAME':

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

break;

case 'PRODUCT_LIST_30SALES':

$listing_sql .= " order by p.products_recent_sales desc, pd.products_name desc";

break;

 

Hope this helps if you encounter the same problem.

Edited by zippie76
Link to comment
Share on other sites

  • 3 weeks later...

Hi homewetbar, hi community,

 

Great contribution and very good readme!

 

 

On issue I have - I can switch sorting nicely, but can not go back to Best Selling:

 

0 -

select count(p.products_id) as total 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 = '2' and p2c.categories_id = '90'p.products_recent_sales desc, pd.products_name desc

[TEP STOP]

 

Any ideas?

 

Best regards, xcomm

 

My settings are as posted in the image above http://img480.imageshack.us/img480/9140/settings6dm.gif

Edited by xcomm
Link to comment
Share on other sites

Hi community.

 

sorry, was the same issue as above described from zippie76.

 

There is a error in the readme, which is missing this order by in index.php:

 

		case 'PRODUCT_LIST_30SALES':
	  $listing_sql .= "p.products_recent_sales desc, pd.products_name desc";
	  break;

 

to

 

		case 'PRODUCT_LIST_30SALES':
	  $listing_sql .= "order by p.products_recent_sales desc, pd.products_name desc";
	  break;
							^^^^^^

 

 

 

Hi homewetbar, hi community,

 

Great contribution and very good readme!

On issue I have - I can switch sorting nicely, but can not go back to Best Selling:

 

 

 

 

0 -

select count(p.products_id) as total 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 = '2' and p2c.categories_id = '90'p.products_recent_sales desc, pd.products_name desc

[TEP STOP]

 

Any ideas?

 

Best regards, xcomm

 

My settings are as posted in the image above http://img480.imageshack.us/img480/9140/settings6dm.gif

Link to comment
Share on other sites

  • 1 month later...

I've installed this mod but i do not see anywhere the drop down box...

 

I'm presuming (although i could be wrong) that it is in this code somewhere that i am going wrong, since this seems like the only "print to screen" there is:

 

// Additional Products Sort

echo '<td align="center" class="dynamicMain">' . tep_draw_form('sort', FILENAME_DEFAULT, 'get') . '<b>Sort by:</b>  ';

 

 

if (isset($HTTP_GET_VARS['manufacturers_id'])) {

echo tep_draw_hidden_field('manufacturers_id', $HTTP_GET_VARS['manufacturers_id']);

} else {

echo tep_draw_hidden_field('cPath', $cPath);

}

 

$sort_list = array('5d' => 'Best Sellers',

'2a' => 'Products Name A to Z',

'2d' => 'Products Name Z to A',

'3a' => 'Price Low to High',

'3d' => 'Price High to Low');

foreach($sort_list as $id=>$text) {

$sort_range[] = array('id' => $id, 'text' => $text);

}

 

echo tep_draw_pull_down_menu('sort', $sort_range, (isset($HTTP_GET_VARS['sort']) ? $HTTP_GET_VARS['sort'] : ''), 'onchange="this.form.submit()"');

echo tep_draw_hidden_field('filter_id', (isset($HTTP_GET_VARS['filter_id']) ? $HTTP_GET_VARS['filter_id'] : ''));

echo '</form></td>' . "\n";

// End Additional Products Sort

 

Why doesn't it show? I have only one mod installed that i think could cause conflicts which is Product Listing in Columns...

 

Any thought or suggestions? All help is appreciated :)

Link to comment
Share on other sites

I've installed this mod but i do not see anywhere the drop down box...

 

I'm presuming (although i could be wrong) that it is in this code somewhere that i am going wrong, since this seems like the only "print to screen" there is:

 

// Additional Products Sort

echo '<td align="center" class="dynamicMain">' . tep_draw_form('sort', FILENAME_DEFAULT, 'get') . '<b>Sort by:</b>  ';

if (isset($HTTP_GET_VARS['manufacturers_id'])) {

echo tep_draw_hidden_field('manufacturers_id', $HTTP_GET_VARS['manufacturers_id']);

} else {

echo tep_draw_hidden_field('cPath', $cPath);

}

 

$sort_list = array('5d' => 'Best Sellers',

'2a' => 'Products Name A to Z',

'2d' => 'Products Name Z to A',

'3a' => 'Price Low to High',

'3d' => 'Price High to Low');

foreach($sort_list as $id=>$text) {

$sort_range[] = array('id' => $id, 'text' => $text);

}

 

echo tep_draw_pull_down_menu('sort', $sort_range, (isset($HTTP_GET_VARS['sort']) ? $HTTP_GET_VARS['sort'] : ''), 'onchange="this.form.submit()"');

echo tep_draw_hidden_field('filter_id', (isset($HTTP_GET_VARS['filter_id']) ? $HTTP_GET_VARS['filter_id'] : ''));

echo '</form></td>' . "\n";

// End Additional Products Sort

 

Why doesn't it show? I have only one mod installed that i think could cause conflicts which is Product Listing in Columns...

 

Any thought or suggestions? All help is appreciated :)

This problem is solved... Had to have display Manufacturers enabled...

 

Next problem lol... I'm running the cron job and keep getting an error upon return...

 

<br />

<b>Warning</b>: session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cookie - headers already sent in <b>public_html/includes/functions/sessions.php</b> on line <b>97</b><br /> <br />

<b>Warning</b>: session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cache limiter - headers already sent (output started at /home/racebits/public_html/includes/functions/sessions.php:97) in <b>/public_html/includes/functions/sessions.php</b> on line <b>97</b><br />

 

Any ideas?

Link to comment
Share on other sites

  • 2 weeks later...

Hi,

 

Great contrib! Thank You a lot!! :thumbsup:

 

I've a question: I used extrafileds contrib, (a great help for me) and now I need to know:

 

how can I allow my visitors to find customers searching them by extrafields?

 

For Example, I put an extrafiled in account_edit.php so that customers can register putting more informations. Now I need a page in which you can find all customers of the same region, or similar, but not using admin control panel.

The contrib I used is here http://addons.oscommerce.com/info/3737

 

Do someone can help me?

Till now I'm not so good in programming, I just understand "c." is for customers_table...

 

Thank you, this OsCommerse community is really wonderful. :lol:

Edited by western
Link to comment
Share on other sites

  • 2 weeks later...

Hi Kit and all great OsCommerce Community!

 

you have saved my codes ones with OsCOmmerce community (general), a second time with extra fields contrib. Do you like to save me again?

 

I 'm trying to do a search between customers and their extra fields. I thought to use something really similar to advanced search codes, do you have any suggestion for me?

 

i know it's not so difficult, but I have problems in put my simples code in OsCommerce structure...

 

TIA

 

W.

Edited by western
Link to comment
Share on other sites

  • 2 weeks later...

Hello,

 

Need help in integrating Sort Products By Dropdown in advanced_search_result.php

 

I have edited the code it works fine if you are not using the advanced search option of the advanced_search.php But when you are specifiying price, date, etc.. on the criteria fields its not working anymore.

 

Any help is highly appreciated.

 

 

Below is my code:

 

// Additional Products Sort

echo '<tr><td align="right" class="main">' . tep_draw_form('sort', FILENAME_ADVANCED_SEARCH_RESULT, 'get') . '<b>Sort by:</b>  ';

 

 

if (isset($HTTP_GET_VARS['manufacturers_id'])) {

echo tep_draw_hidden_field('manufacturers_id', $HTTP_GET_VARS['manufacturers_id']);

} else {

echo tep_draw_hidden_field('keywords',$keywords);

}

 

$sort_list = array('2a' => 'Products Model A to Z',

'2d' => 'Products Model Z to A',

'4a' => 'Price Low to High',

'4d' => 'Price High to Low');

foreach($sort_list as $id=>$text) {

$sort_range[] = array('id' => $id, 'text' => $text);

}

 

echo tep_draw_pull_down_menu('sort', $sort_range, '', 'onchange="this.form.submit()"');

 

 

 

echo '</form></td></tr>' . "\n";

// End Additional Products Sort

Link to comment
Share on other sites

I have a unique problem because I'm using a modified product_listing.php module to display my products in multiple columns. As a result, the ($col=0, $n=sizeof($column_list); $col<$n; $col++) { isn't there for me to append. Does anyone have any suggestions? If anyone can help and needs me to paste the code of my product_listing.php file let me know. Thanks.

Link to comment
Share on other sites

I am a newbie in this field. How can I add your contribution to my website? I looked through and I don't know where I can download.

 

Thanks in advance for your help!

 

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.

Link to comment
Share on other sites

I am a newbie in this field. How can I add your contribution to my website? I looked through and I don't know where I can download.

 

Thanks in advance for your help!

Hint: Go to the 1st post and look under the author's signature. ;)

Edited by TheJackal

- The Jackal

Link to comment
Share on other sites

Lovely contribution, thank you very much. I have installed the latest (#4312) but I am still having the same problems I see everyone else having. My first is trying to sort by bestseller, I get this error (all others work ok i.e. price & a to z)

 

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 'order by p.products_recent_sales desc, pd.products_name desc limit 0, 21' at line 1

 

select p.products_image, pd.products_name, p.products_model, 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 = '64' order by order by p.products_recent_sales desc, pd.products_name desc limit 0, 21

 

[TEP STOP]

 

I have tried adding "order by" as I see it has worked for some, but it only messes up my other sort such as price and a to z. Has anyone found a solution?

 

I also get whatever my last sort order feature duplicated. For example, when price is listed with the last value it is duplicated, if I change it to model or buy now as last listed, then that is duplicated.

 

Can anyone help with any of these issues as I cant find that anyone has actually found a solution???

Demitra

Link to comment
Share on other sites

Hi everyone,

 

I've got this contribution working great but what I'd like to be able to do is by default have the product listing display product name A to Z and still have the option to list by bestsellers in the drop down.

 

For example:

 

$sort_list = array('2a' => 'Product A to Z',

'2d' => 'Product Z to A',

'6d' => 'Bestselling',

'3a' => 'Price: Low to High',

'3d' => 'Price: High to Low')

 

Does anyone know how to go about doing this?

 

Many thanks,

Luke

 

);

Link to comment
Share on other sites

  • 1 month later...

Hi there, i'm coming over from the german osc forums.

 

Is there a way to combine that great contribution with the ability to sort by

date_added ?

 

I already tried to combine this contribution with Sort by date added, but i miserably failed after spending the whole night with that problem.

I already implemented a lot of community contributions without having a clue :D, but here my intuition ends.

 

I guess, that the community has a demand for this additional feature.

So it would be very, very apprechiated if anyone with php-mysql knowledge could solve that and add it to the contribution.

Of course only if it isnt too complex.

 

kind regards, ABit Mark

Edited by ABit
Link to comment
Share on other sites

  • 2 weeks later...

Maybe someone has initial stage for a solution?

 

I dont want to drop in here and ask for a complete code with this feature implemented.

I'm willing to try it on my own.

So, what do you think? Is it possible to solve it at all and if the answer is 'yes', how generally would you start doing it?

Link to comment
Share on other sites

  • 3 weeks later...

Well,

 

about 160.000 users, 1 month past and still no reply :blink: :-"

 

I dont believe, that i'm the only one using product_listing_in_columns.

This is the contribution, which eliminates the standard given sort options (+ -) on the top of the row.

Therefore i give it another shot.

 

Esp. when you have 2000+ products in your shop, this is a real problem, because in many categories totally crappy products are listed first just cause they have a number or a symbol in the beginning of their name.

 

Showing the newest first and the oldest last in combination with the dropdown menu mentioned above would be the "killerfeature" itself.

Customers tend to be lazy not switching through all p_listing pages. Cmon ppl you know it! ;)

Link to comment
Share on other sites

  • 2 weeks later...
Hi everyone,

 

I've got this contribution working great but what I'd like to be able to do is by default have the product listing display product name A to Z and still have the option to list by bestsellers in the drop down.

 

For example:

 

$sort_list = array('2a' => 'Product A to Z',

'2d' => 'Product Z to A',

'6d' => 'Bestselling',

'3a' => 'Price: Low to High',

'3d' => 'Price: High to Low')

 

Does anyone know how to go about doing this?

 

Many thanks,

Luke

 

);

 

Hi Luke,

 

Just trying to get this working on two of our websites. Did you manage to work out how to sort by Product rather than Bestselling. I want to do the same but I want to order by price.

 

Hope you can help :)

Link to comment
Share on other sites

  • 1 month later...
Well,

 

about 160.000 users, 1 month past and still no reply :blink: :-"

 

I dont believe, that i'm the only one using product_listing_in_columns.

This is the contribution, which eliminates the standard given sort options (+ -) on the top of the row.

Therefore i give it another shot.

 

Esp. when you have 2000+ products in your shop, this is a real problem, because in many categories totally crappy products are listed first just cause they have a number or a symbol in the beginning of their name.

 

Showing the newest first and the oldest last in combination with the dropdown menu mentioned above would be the "killerfeature" itself.

Customers tend to be lazy not switching through all p_listing pages. Cmon ppl you know it! ;)

 

Hey Mark,

 

I am in the same boat as you. I am looking at installing this contrib for a client's site who is after sorting by price, date and title.

 

Any luck combining the two contributions?

 

I am still learning php / sql... I guess I will download the code and poke around.

 

Just wondering if anyone has any luck yet?

 

Thanks!

Lau

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