Zen Cart Logo
Forums / General Questions / Sorting function for item display

Sorting function for item display

Locked

Views: 2,370

Results 1 to 20 of 23
This thread is locked. New replies are disabled.
14 Jan 2010, 3:38 PM
#1
steveduncan avatar

steveduncan

New Zenner

Join Date:
Jan 2010
Posts:
52
Plugin Contributions:
0

Sorting function for item display

Hi all,

I am using Zen-cart 1.3.8a. I cannot find a sorting function for item display, e.g. items sorted by price (desc, asc), name (a-z, z-a). Could someone please tell me the availability, or any module available?

Thanks in advance.

Regards

Steve

15 Jan 2010, 7:18 AM
#2
mprough avatar

mprough

Totally Zenned

Join Date:
Nov 2007
Location:
Woodbine, Georgia, United States
Posts:
4,290
Plugin Contributions:
39

Re: Sorting function for item display

Configuration >> Product Listing >>Include Product Listing Alpha Sorter Dropdown

The others are available by clicking the column heads in the product index pages.

~Melanie

18 Jan 2010, 5:34 PM
#3
steveduncan avatar

steveduncan

New Zenner

Join Date:
Jan 2010
Posts:
52
Plugin Contributions:
0

Re: Sorting function for item display

mprough:

Configuration >> Product Listing >>Include Product Listing Alpha Sorter Dropdown

The others are available by clicking the column heads in the product index pages.

~Melanie

Dear mprough,

Thank you for your help. :smile:

I am wondering if there is add-on that dispalys such functions in a dropdown box.

Steve

18 Jan 2010, 5:47 PM
#4
mprough avatar

mprough

Totally Zenned

Join Date:
Nov 2007
Location:
Woodbine, Georgia, United States
Posts:
4,290
Plugin Contributions:
39

Re: Sorting function for item display

You would need to code the options in the dropdown to display the sorted links you desire.

~Melanie

18 Jan 2010, 6:11 PM
#5
steveduncan avatar

steveduncan

New Zenner

Join Date:
Jan 2010
Posts:
52
Plugin Contributions:
0

Re: Sorting function for item display

mprough:

You would need to code the options in the dropdown to display the sorted links you desire.

~Melanie

Dear Melanie,

I noticed that this function has been requested two years ago on this forum. I could not find add-ons for the function.

Steve

18 Jan 2010, 6:16 PM
#6
mprough avatar

mprough

Totally Zenned

Join Date:
Nov 2007
Location:
Woodbine, Georgia, United States
Posts:
4,290
Plugin Contributions:
39

Re: Sorting function for item display

As stated, there is no addon, you simply code the dropdown by hand referencing the urls of the sorted options you require.

<select>
<option value="http://site.com/">Sort Text 1</option>
<option value="http://site.com/1.html">Sort Text 2</option>
<option value="http://site.com/2.html">Sort Text 3</option>
</select>

~Melanie

19 Jan 2010, 12:00 PM
#7
steveduncan avatar

steveduncan

New Zenner

Join Date:
Jan 2010
Posts:
52
Plugin Contributions:
0

Re: Sorting function for item display

mprough:

As stated, there is no addon, you simply code the dropdown by hand referencing the urls of the sorted options you require.

<select> <option value="http://site.com/">Sort Text 1</option> <option value="http://site.com/1.html">Sort Text 2</option> <option value="http://site.com/2.html">Sort Text 3</option> </select> ``` > > ~Melanie

Dear Melanie,

Thank you for your help.

Could you please elaborate on this? For example, which file to edit. The value in the code has partly dynamic value, which make it difficult. For example, the number of current page, Furthermore, the same function is also used in the search result. :frusty:

I am wondering, if the function is so simple, why is it not available even in add-ons. :wacko:

Regards

Steve

28 Jan 2010, 9:29 PM
#8
shaunus avatar

shaunus

New Zenner

Join Date:
Jan 2010
Posts:
25
Plugin Contributions:
0

Re: Sorting function for item display

I'm looking for some help with this problem too. I can sort products by a-z, z-a price high-low, low-high etc etc when searing in "New Products" or "All Products" but when I'm in an actual category, for example "Televisions" I'm only able to include an Alpha Sorter which is no use.

Does anyone know which files have to be edited to allow the a-z, z-a, price low-high sorter to be included within the product categories?

I noticed a previous post stated:

*Configuration >> Product Listing >>Include Product Listing Alpha Sorter Dropdown

The others are available by clicking the column heads in the product index pages.*

Could someone please explain what it means by "clicking the column heads in the product index pages"?

Many thanks.

28 Jan 2010, 9:49 PM
#9
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Sorting function for item display

You don't give a link to see what your site looks like, but I will venture that you have the Column Grid mod, or some form of grid display on your product listing. The stock "rows" display has a heading for each element of the product, and most of them are clickable to change the sort order to that element. (These headings obviously are not applicable to the grid layout style.)

You would need to copy that code to your dropdown.

28 Jan 2010, 10:00 PM
#10
shaunus avatar

shaunus

New Zenner

Join Date:
Jan 2010
Posts:
25
Plugin Contributions:
0

Re: Sorting function for item display

Thanks for the quick answer. Sorry to sound dumb, but I couldn't really understand what you meant.

Could you please have a look at my site on the link below and see if you can narrow down what I need to do.

All I want is the sorter that comes up in "New Products" to work in each product category.

Thanks.

http://technics4home.co.uk/

28 Jan 2010, 10:05 PM
#11
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Sorting function for item display

You do have the stock product listing, which means you can click on the headings for sorting:

Product Image Item Name+ Price

You can't sort by image:)

To get the dropdown, you would have to copy and modify the sorter code from New Products.

29 Jan 2010, 1:15 PM
#12
shaunus avatar

shaunus

New Zenner

Join Date:
Jan 2010
Posts:
25
Plugin Contributions:
0

Re: Sorting function for item display

Yes, after I'd read your reply a few more times, it made sense...so thanks for that.

The only problem is, that to a customer, it isn't obvious to click on the column headers to do a sort. I didn't even know it could be done until you said, especially when a sort box is displayed above.

The next question is what file do I copy the code to so that it will appear in the drop down, and can I simply do a View source, and copy/paste the relevant code?

Thanks again!

29 Jan 2010, 2:06 PM
#13
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Sorting function for item display

View source will only get the HTML output, not the PHP processing that actually does the work. It looks like the dropdown is built in /includes/templates/template_default/templates/ tpl_modules_listing_display_order.php, so you would want to add a require() to that from /includes/modules/your_template/product_listing.php.
This is what it looks like in /includes/templates/template_default/templates/tpl_products_new_default.php:```php

<h1 id="newProductsDefaultHeading"><?php echo HEADING_TITLE; ?></h1> <?php /** * display the product order dropdown */ require($template->get_template_dir('/tpl_modules_listing_display_order.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_listing_display_order.php'); ?>
29 Jan 2010, 2:27 PM
#14
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Sorting function for item display

I don't know that product_listing.php will be able to use the dropdown output. It uses ```php
$listing_split = new splitPageResults($listing_sql, MAX_DISPLAY_PRODUCTS_LISTING, 'p.products_id', 'page');

Finding the file location of the existing alpha sorter call might be useful, as would the file location of the "heading click" sorter.
29 Jan 2010, 3:40 PM
#15
steveduncan avatar

steveduncan

New Zenner

Join Date:
Jan 2010
Posts:
52
Plugin Contributions:
0

Re: Sorting function for item display

Shaunus:

Thanks for the quick answer. Sorry to sound dumb, but I couldn't really understand what you meant.

Could you please have a look at my site on the link below and see if you can narrow down what I need to do.

All I want is the sorter that comes up in "New Products" to work in each product category.

Thanks.

http://technics4home.co.uk/

Dear Shaunus,

You will understand by clicking Item Name or Price above Panasonic Blu-ray Player DMP-BD60.

http://technics4home.co.uk/index.php?main_page=index&cPath=7_19

Steve

29 Jan 2010, 6:15 PM
#16
steveduncan avatar

steveduncan

New Zenner

Join Date:
Jan 2010
Posts:
52
Plugin Contributions:
0

Re: Sorting function for item display

I tried to combine Sort By function and Filter Results By function. However, the Sort By function does NOT work.

Could anyone please shed light on it? Do I miss some settings beforehands, e.g. SQL string settings.

Below is my modification:

Add the code below,

<div id="sorter"> <label for="disp-order-sorter"><?php echo TEXT_INFO_SORT_BY; ?></label>
<select name="disp_order" onchange="this.form.submit();" id="disp-order-sorter">
<?php if ($disp_order != $disp_order_default) { ?>
<option value="<?php echo $disp_order_default; ?>" <?php echo ($disp_order == $disp_order_default ? 'selected="selected"' : ''); ?>><?php echo PULL_DOWN_ALL_RESET; ?></option>
<?php } // reset to store default ?>
<option value="1" <?php echo ($disp_order == '1' ? 'selected="selected"' : ''); ?>><?php echo TEXT_INFO_SORT_BY_PRODUCTS_NAME; ?></option>
<option value="2" <?php echo ($disp_order == '2' ? 'selected="selected"' : ''); ?>><?php echo TEXT_INFO_SORT_BY_PRODUCTS_NAME_DESC; ?></option>
<option value="3" <?php echo ($disp_order == '3' ? 'selected="selected"' : ''); ?>><?php echo TEXT_INFO_SORT_BY_PRODUCTS_PRICE; ?></option>
<option value="4" <?php echo ($disp_order == '4' ? 'selected="selected"' : ''); ?>><?php echo TEXT_INFO_SORT_BY_PRODUCTS_PRICE_DESC; ?></option>
<option value="5" <?php echo ($disp_order == '5' ? 'selected="selected"' : ''); ?>><?php echo TEXT_INFO_SORT_BY_PRODUCTS_MODEL; ?></option>
<option value="6" <?php echo ($disp_order == '6' ? 'selected="selected"' : ''); ?>><?php echo TEXT_INFO_SORT_BY_PRODUCTS_DATE_DESC; ?></option>
<option value="7" <?php echo ($disp_order == '7' ? 'selected="selected"' : ''); ?>><?php echo TEXT_INFO_SORT_BY_PRODUCTS_DATE; ?></option>
</select></div>

to the file below:

/includes/templates/classic/templates/tpl_index_product_list.php

The code is copied from

/includes/templates/classic/templates/tpl_modules_listing_display_order.php

and delete the form and hidden fields:

Regards

Steve

29 Jan 2010, 6:32 PM
#17
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Sorting function for item display

You need the form to process the select inputs - they will do nothing by themselves.

29 Jan 2010, 9:37 PM
#18
steveduncan avatar

steveduncan

New Zenner

Join Date:
Jan 2010
Posts:
52
Plugin Contributions:
0

Re: Sorting function for item display

gjh42:

You need the form to process the select inputs - they will do nothing by themselves.

Thank you for your advice. I know. The /includes/templates/classic/templates/tpl_index_product_list.php already contains a form. That is why I deleted it from the other file.

Steve

30 Jan 2010, 3:31 AM
#19
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Sorting function for item display

Sorry, nevermind...:)

1 Feb 2010, 4:42 PM
#20
shaunus avatar

shaunus

New Zenner

Join Date:
Jan 2010
Posts:
25
Plugin Contributions:
0

Re: Sorting function for item display

I really appreciate your input on this guys, but I'm afraid it's got a bit beyond my understanding.
I've tried other mods in the past when I've not fully understood instructions and ended up getting in a mess, so I think I'll have to bow out gracefully and hope that a future release of ZenCart includes this kind of feature in the admin.

It's pretty strange that a decent sort list is available in 'new' or 'all' products, but only an Alpha Sorter in the actual product categories where most customers would want to perform a search!

Thanks again for your assistance.