Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Sort by price with column display....

Sort by price with column display....

Views: 46,932

Results 61 to 80 of 101
2 Nov 2009, 7:40 PM
#61
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Sort by price with column display....

The default sort order on Prices uses the products_price_sorter field so that the "calculated" price is in order for sorting purposes ...

If you do not have this field completed it can be added from the Tools ... Store Manager ...

NOTE: this utilizes the master_categories_id for calculating prices ...

If you do not have a master_categories_id and do NOT use Linked Products then you can update this with the Tools ... Store Manager ... as well for updating the Master Categories ID ...

NOTE: you should check that you have applied the Known Bug Fixes to v1.3.8 at:
http://www.zen-cart.com/forum/showthread.php?t=82619

and it is also a good time to review the Security Patches at:
http://www.zen-cart.com/forum/showthread.php?t=131115

23 Nov 2009, 4:21 PM
#62
korayp avatar

korayp

New Zenner

Join Date:
Sep 2009
Posts:
5
Plugin Contributions:
0

Re: Sort by price with column display....

yellow1912:

To have a drop down box sorter:

In includes/templates/YOUR_CURRENT_TEMPLATE
Add a file called tpl_modules_additional_listing_display_order.php (actually you can call it however you want) with this content

Good luck

Instead of using statically defined price and product name sorter values I use the configuration keys in the database instead of 2a,2d,3a and 3d.

This way the updated code becomes:

<?php
/**
 * Module Template
 *
 * @package templateSystem
 * @copyright Copyright 2003-2006 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: tpl_modules_additional_listing_display_order.php 3369 2006-04-03 23:09:13Z drbyte $
 */
?>
<?php
// NOTE: to remove a sort order option add an HTML comment around the option to be removed
?>

<div id="sorter">
<label for="disp-order-sorter"><?php echo TEXT_INFO_SORT_BY; ?></label>
<?php
  echo zen_draw_form('sorter_form', zen_href_link($_GET['main_page']), 'get');
  echo zen_draw_hidden_field('main_page', $_GET['main_page']);
  echo zen_draw_hidden_field('cPath', $cPath);
  // draw cPath if known
  if (!$getoption_set)
    echo zen_draw_hidden_field('cPath', $cPath);
  echo zen_hide_session_id();
?>
<select name="sort" onchange="this.form.submit();" id="disp-order-sorter">
	<?php
	if ($_GET['sort'] != PRODUCT_LISTING_DEFAULT_SORT_ORDER) {
	?>
	<option value="<?php echo PRODUCT_LISTING_DEFAULT_SORT_ORDER; ?>" <?php echo ($_GET['sort'] == PRODUCT_LISTING_DEFAULT_SORT_ORDER ? 'selected="selected"' : ''); ?>><?php echo PULL_DOWN_ALL_RESET; ?></option>
	<?php
	} // reset to store default 
	?>
	<option value="<?php print PRODUCT_LIST_NAME?>a" <?php echo ($_GET['sort'] == PRODUCT_LIST_NAME.'a' ? 'selected="selected"' : ''); ?>><?php echo TEXT_INFO_SORT_BY_PRODUCTS_NAME; ?></option>
	<option value="<?php print PRODUCT_LIST_NAME?>d" <?php echo ($_GET['sort'] == PRODUCT_LIST_NAME.'d' ? 'selected="selected"' : ''); ?>><?php echo TEXT_INFO_SORT_BY_PRODUCTS_NAME_DESC; ?></option>
	<option value="<?php print PRODUCT_LIST_PRICE?>a" <?php echo ($_GET['sort'] == PRODUCT_LIST_PRICE.'a' ? 'selected="selected"' : ''); ?>><?php echo TEXT_INFO_SORT_BY_PRODUCTS_PRICE; ?></option>
	<option value="<?php print PRODUCT_LIST_PRICE?>d" <?php echo ($_GET['sort'] == PRODUCT_LIST_PRICE.'d' ? 'selected="selected"' : ''); ?>><?php echo TEXT_INFO_SORT_BY_PRODUCTS_PRICE_DESC; ?></option>
</select>
</form>
</div>
25 Nov 2009, 9:18 PM
#63
llynix avatar

llynix

Zen Follower

Join Date:
Jul 2009
Location:
Texas
Posts:
210
Plugin Contributions:
0

Re: Sort by price with column display....

Had problems with the sort not working on manufacturers pages. The filter worked fine so I stole some code for this and came up with this for my file:

tpl_modules_listing_display_order_sort.php

<?php
/**
 * Module Template
 *
 * @package templateSystem
 * @copyright Copyright 2003-2006 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: tpl_modules_additional_listing_display_order.php 3369 2006-04-03 23:09:13Z drbyte $
 */
?>
<?php
// NOTE: to remove a sort order option add an HTML comment around the option to be removed
?>

<div id="sorter">
<label for="disp-order-sorter"><?php echo TEXT_INFO_SORT_BY; ?></label>
<?php
  echo zen_draw_form('sorter_form', zen_href_link($_GET['main_page']), 'get');
  echo zen_draw_hidden_field('main_page', $_GET['main_page']);
  // draw cPath if known
  if (!$getoption_set) {
    echo zen_draw_hidden_field('cPath', $cPath);
  } else {
    // draw manufacturers_id
    echo zen_draw_hidden_field($get_option_variable, $_GET[$get_option_variable]);
  }

  if (isset($_GET['typefilter']) && $_GET['typefilter'] != '') echo zen_draw_hidden_field('typefilter', $_GET['typefilter']);

   // draw manufacturers_id if not already done earlier
  if ($get_option_variable != 'manufacturers_id' && isset($_GET['manufacturers_id']) && $_GET['manufacturers_id'] > 0) {
    echo zen_draw_hidden_field('manufacturers_id', $_GET['manufacturers_id']);
  }

  echo zen_hide_session_id();
?>
    <select name="sort" onchange="this.form.submit();" id="disp-order-sorter">
<?php if ($_GET['sort'] != PRODUCT_LISTING_DEFAULT_SORT_ORDER) { ?>
    <option value="<?php echo PRODUCT_LISTING_DEFAULT_SORT_ORDER; ?>" <?php echo ($_GET['sort'] == PRODUCT_LISTING_DEFAULT_SORT_ORDER ? 'selected="selected"' : ''); ?>>--Choose--</option>
<?php } // reset to store default ?>
    <option value="<?php print PRODUCT_LIST_PRICE?>a" <?php echo ($_GET['sort'] == PRODUCT_LIST_PRICE.'a' ? 'selected="selected"' : ''); ?>><?php echo TEXT_INFO_SORT_BY_PRODUCTS_PRICE; ?></option>
    <option value="<?php print PRODUCT_LIST_PRICE?>d" <?php echo ($_GET['sort'] == PRODUCT_LIST_PRICE.'d' ? 'selected="selected"' : ''); ?>><?php echo TEXT_INFO_SORT_BY_PRODUCTS_PRICE_DESC; ?></option> 
    <option value="<?php print PRODUCT_LIST_NAME?>a" <?php echo ($_GET['sort'] == PRODUCT_LIST_NAME.'a' ? 'selected="selected"' : ''); ?>><?php echo TEXT_INFO_SORT_BY_PRODUCTS_NAME; ?></option>
    <option value="<?php print PRODUCT_LIST_NAME?>d" <?php echo ($_GET['sort'] == PRODUCT_LIST_NAME.'d' ? 'selected="selected"' : ''); ?>><?php echo TEXT_INFO_SORT_BY_PRODUCTS_NAME_DESC; ?></option>
    </select></form></div>

Hope it's helpful

Anthony Taylor
Webmaster
http://buydentalequipment.com

15 Dec 2009, 3:05 PM
#64
sheryll avatar

sheryll

New Zenner

Join Date:
Dec 2009
Location:
New York, NY
Posts:
45
Plugin Contributions:
0

Re: Sort by price with column display....

Thank you yellow for the code. It worked perfectly for me and will be very useful for my projects! =]

16 Jan 2010, 3:01 PM
#65
juneloweelyn avatar

juneloweelyn

New Zenner

Join Date:
Jan 2009
Posts:
70
Plugin Contributions:
0

Re: Sort by price with column display....

Hello all,

Thanks so much for replying :)

I wanna have an additional filter for my website in which i can filter the items based on quantity.

Zen cart 1.3.8a only has
"from old to new"
"new to old"
"price high to low"
etc..

But i wish to add an additional filter that sort the products based on quantity. (product with highest quantity would appear first in the catalog, followed by sold out items) do u have any idea i can do it?

I will open a new thread for this once i have gotten the solution.

I have been asking for help for few times, it seems that noone could help.

Hope u can help me :)

Thank you SO SO MUCH!!!! i really glad that u replied :)

17 Mar 2010, 11:16 PM
#66
owendev avatar

owendev

New Zenner

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

Re: Sort by price with column display....

Still not working.

I've tried adding the code from page 3 but no joy.

I still can't get the sort order working and it's still throwing out alphabetical sorting. I have my sort set at 3a and drop downs look fine on site - just don't do anything. Url looks ok too - no duplication of sort.

website is:

http://www.janddalexander.com/shop

This is driving me crazy and any help would be vastly appreciated.

18 Mar 2010, 1:27 PM
#67
owendev avatar

owendev

New Zenner

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

Re: Sort by price with column display....

Bumping for a reply hopefully...

18 Mar 2010, 2:18 PM
#68
owendev avatar

owendev

New Zenner

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

Re: Sort by price with column display....

Never mind. Sorted it myself.

I removed the drop-down box that didn't work, and changed the + and - options to little arrows. Does the job fine and client happy.

19 Apr 2010, 3:19 AM
#69
dhaval avatar

dhaval

New Zenner

Join Date:
Nov 2007
Posts:
13
Plugin Contributions:
0

Re: Sort by price with column display....

thanks... this is just what i need

24 May 2011, 8:53 PM
#70
novastar avatar

novastar

Zen Follower

Join Date:
Jul 2009
Posts:
127
Plugin Contributions:
0

Re: Sort by price with column display....

Thanks for the code, but Is there anyway to get this working with the filter drop down box. Currently if you filter the results and then try to sort that selection, it reloads everything (as in all items that were listed before filtering).

20 Jul 2011, 11:28 AM
#71
briann avatar

briann

New Zenner

Join Date:
Dec 2008
Posts:
28
Plugin Contributions:
0

Re: Sort by price with column display....

Still: thank you very much for the code!
There's only one problem (and I think you all experience the same?).

When you do a search and you try to sort the search results, you'll be noticed that you should fill in at least one of the fields. The keywords aren't in the URL anymore...

Is there any way to solve this problem? I've been looking for hours now, but haven't been able to figure out anything more...

Thanks in advance for the reply. :smile:

23 Aug 2011, 7:34 AM
#72
makehveli avatar

makehveli

New Zenner

Join Date:
Mar 2011
Posts:
33
Plugin Contributions:
0

Re: Sort by price with column display....

seems like this works if we sort by name, but not with price

23 Aug 2011, 1:37 PM
#73
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Sort by price with column display....

Usually the cause of that is that the products_price_sorter is not updated ... this also may mean that the master_categories_id is not up to date on the Products ...

If you do not use Linked Products, you fix both of these in the Tools ... Store Manager ...

Reset ALL Products Master Categories ID
to be used for Linked Products and Pricing: Reset

Update ALL Products Price Sorter
to be able to sort by displayed prices: Update

23 Aug 2011, 9:19 PM
#74
makehveli avatar

makehveli

New Zenner

Join Date:
Mar 2011
Posts:
33
Plugin Contributions:
0

Re: Sort by price with column display....

Adjeh, I have a very large catalog (30,000+ products) and when I Update ALL Products Price Sorter I receive an Internal Server Error.

Side Note:
I receive the same Internal Server Error when I upload my products through Easy Populate at starting around my 10,000th product, but they all go through.

Is their a way to Update ALL Products Price Sorter through php MyAdmin?

24 Aug 2011, 12:10 AM
#75
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Sort by price with column display....

Due to all the calculations there is not a method to do that ...

If you edit the file:
/admin/store_manager.php

You will see the code around line 25 for:

  zen_set_time_limit(600);
  switch($action) {

Try changing that to 1200 ...

24 Aug 2011, 12:25 AM
#76
makehveli avatar

makehveli

New Zenner

Join Date:
Mar 2011
Posts:
33
Plugin Contributions:
0

Re: Sort by price with column display....

I will indeed try your suggestion,

but could I do a rig fix,
in assigning a value to the coulmn "products_price_sorter"

because I can easily arrange lowest to highest price in excel, place a value in products_price_sorter and then import that into php my Admin,

If you think it's worth a shot, could you please tell me how the system would read it?

I mean in a catalog of 30000 products would I give the cheapest product a products_price_sorter value of 1 and the highest a value of 30000?

24 Aug 2011, 12:28 AM
#77
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Sort by price with column display....

If you cannot find a setting that works on the limit you could try replacing the products_price_sorter with the products_price ... but this will only be so accurate based on the Pricing methods you use, as in prices, specials, sales, price by attribute etc.

24 Aug 2011, 1:17 AM
#78
makehveli avatar

makehveli

New Zenner

Join Date:
Mar 2011
Posts:
33
Plugin Contributions:
0

Re: Sort by price with column display....

Ajeh, I moved it up from 600 to 1200 to 2400... no good.

I saw your posts on this thread here:
http://www.zen-cart.com/forum/showthread.php?t=169548

and on post #6 you make mention of bad data from an import.

and I forgot to mention that
I used Easy Populate to import my data,
which was comprised of multiple CSV files containtaing 2000 products each.

Around the 10,000th product I would upload I would receive the same Internal Server Error but I just proceeded in that fashion because it looked to me that all the products were being loaded into the database... hadn't had any problems till now.

So maybe the thing to do is purge my database and start over,
either importing in smaller quantities, or maybe ditching EasyPopulate all together and doing it all from php MyAdmin.

Wanted to get your opinion before I undertake this.

24 Aug 2011, 1:24 AM
#79
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Sort by price with column display....

Do your products have master_categories_id on them?

Do you use Linked Products?

24 Aug 2011, 1:38 AM
#80
makehveli avatar

makehveli

New Zenner

Join Date:
Mar 2011
Posts:
33
Plugin Contributions:
0

Re: Sort by price with column display....

They do have master_categories_id on them.
No I do not use Linked Products.