Sort Order for product listing pages
Products shown on a product listing page are sorted in one of two ways:
- Using the per-product sort order set on the product editing page.
- Using the key PRODUCT_LISTING_DEFAULT_SORT_ORDER from the Admin > Configuration > Product Listing page. This key is called “Sort Order Default - Product Listing” in Zen Cart 2.0.0 and above; it was formerly called “Display Product Listing Default Sort Order.”
When PRODUCT_LISTING_DEFAULT_SORT_ORDER
is set to blank, the per-product sort order is used.
Otherwise, the interpretation is different in Zen Cart 2.0.0 and forward, when compared to older versions of Zen Cart.
Zen Cart 2.0.0 and forward
The configuration setting PRODUCT_LISTING_DEFAULT_SORT_ORDER
may have any of these values:
Sort Order Options Table
Value | Text String | Meaning |
---|---|---|
8 | Recommended | ORDER BY p.products_sort_order, pd.products_name (default) |
1 | Product Name | ORDER BY pd.products_name |
2 | Product Name - desc | ORDER BY pd.products_name DESC |
3 | Price - low to high | ORDER BY p.products_price_sorter, pd.products_name |
4 | Price - high to low | ORDER BY p.products_price_sorter DESC, pd.products_name |
5 | Model | ORDER BY p.products_model |
6 | Date Added - New to Old | ORDER BY p.products_date_added DESC, pd.products_name |
7 | Date Added - Old to New | ORDER BY p.products_date_added, pd.products_name |
Note the use of p.products_price_sorter
rather than p.products_price
- see
“Update ALL Products Price Sorter” in Store Manager.
These values correspond to the sort order dropdown shown on the listing page in 2.0.0 and forward. If an older style value such as “4a” is used in PRODUCT_LISTING_DEFAULT_SORT_ORDER
, it is overridden to be “8” (Recommended).
Zen Cart 1.5.8 and prior
When PRODUCT_LISTING_DEFAULT_SORT_ORDER
is non-blank, it is interpreted as follows:
-
There are a list of Display field name settings on the Admin > Configuration > Product Listing page. In 1.5.7, they are:
- Display Product Image
- Display Product Manufacturer Name
- Display Product Model
- Display Product Name
- Display Product Price/Add to Cart
- Display Product Quantity
- Display Product Weight
-
The settings for each of these values (0 or non-zero) determine whether or not this column will be shown on a product listing page. For specifics, see Product Listing Configuration Settings.
-
The configuration settings with non-zero values are ordered according to their setting. Then the sort is done using the field number specified in the first character of
PRODUCT_LISTING_DEFAULT_SORT_ORDER
, in ascending or descending order according to the second character.
This is best illustrated by an example. Consider the following configuration:
This shows that the listing page will display four fields per row, in the following order:
- product image
- product name
- product price / add to cart
- product quantity in stock
If the value of PRODUCT_LISTING_DEFAULT_SORT_ORDER
is blank, the rows will be sorted according to the per product sort order and product name. Since frequently per product sort order is zero, this means the products are shown sorted by name, like this:
But if the PRODUCT_LISTING_DEFAULT_SORT_ORDER
value is 4d, the products are shown sorted by the 4th displayed field (product quantity in stock) in descending order. The result will look like this: