Print Page | Close Window

sort by sku

Printed From: ProductCart E-Commerce Solutions
Category: ProductCart
Forum Name: Customizing ProductCart
Forum Description: Exchange messages with other users that are customizing ProductCart.
URL: https://forum.productcart.com/forum_posts.asp?TID=5816
Printed Date: 21-November-2024 at 5:22pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: sort by sku
Posted By: ym
Subject: sort by sku
Date Posted: 07-March-2014 at 9:23am
I'd like to display all featured products by sku, newly added products first and older products in the last row. It looks like by default, it's opposite. Does anybody know the solutions? Thank you.



Replies:
Posted By: Guests
Date Posted: 07-March-2014 at 9:33pm
Are you referring to this display on the home page, the featured products page, or both? And do you really mean "sort by" (a user interface option) or just "order by" (a database query option)?

Just looking for a some clarification to be able to assist you with what you really want here.


Posted By: ym
Date Posted: 07-March-2014 at 10:37pm
Thank you for the reply. I'm reffering to the featured products page. (showfeatured.asp)
And I meant "order by".
 
I'm adding new products frequently and when this page (showfeatured.asp) is loaded, I'd like to show new products first.


Posted By: Guests
Date Posted: 07-March-2014 at 11:43pm
Thanks for the clarification.

This is easy to tweak.

In /pc/showfeatured.asp, find:
Case "0": querySort = " ORDER BY pcprod_OrdInHome asc"
replace that with the following:
'Modified to sort by date entered by default:
'Case "0": querySort = " ORDER BY pcprod_OrdInHome asc"
Case "0": querySort = " ORDER BY pcprod_OrdInHome ASC, products.pcprod_EnteredOn DESC"

Then find:
query="SELECT distinct products.idProduct, products.sku, products.description, products.price, products.listHidden, products.listPrice, products.serviceSpec, products.bToBPrice, products.smallImageUrl, products.noprices, products.stock, products.noStock, products.pcprod_HideBTOPrice, products.pcprod_OrdInHome, products.formQuantity, products.pcProd_BackOrder FROM products, categories_products, categories WHERE products.active=-1 AND products.showInHome=-1 AND products.configOnly=0 AND products.removed=0 " & queryNFS & " AND categories_products.idProduct=products.idProduct AND categories.idCategory=categories_products.idCategory AND categories.iBTOhide=0 " & query1 & querySort
Replace that with the following:
'Modified to include to include products.pcprod_EnteredOn:
'query="SELECT distinct products.idProduct, products.sku, products.description, products.price, products.listHidden, products.listPrice, products.serviceSpec, products.bToBPrice, products.smallImageUrl, products.noprices, products.stock, products.noStock, products.pcprod_HideBTOPrice, products.pcprod_OrdInHome, products.formQuantity, products.pcProd_BackOrder FROM products, categories_products, categories WHERE products.active=-1 AND products.showInHome=-1 AND products.configOnly=0 AND products.removed=0 " & queryNFS & " AND categories_products.idProduct=products.idProduct AND categories.idCategory=categories_products.idCategory AND categories.iBTOhide=0 " & query1 & querySort
query="SELECT distinct products.idProduct, products.sku, products.description, products.price, products.listHidden, products.listPrice, products.serviceSpec, products.bToBPrice, products.smallImageUrl, products.noprices, products.stock, products.noStock, products.pcprod_HideBTOPrice, products.pcprod_OrdInHome, products.formQuantity, products.pcProd_BackOrder, products.pcprod_EnteredOn FROM products, categories_products, categories WHERE products.active=-1 AND products.showInHome=-1 AND products.configOnly=0 AND products.removed=0 " & queryNFS & " AND categories_products.idProduct=products.idProduct AND categories.idCategory=categories_products.idCategory AND categories.iBTOhide=0 " & query1 & querySort

If you actually assign sort order values to your featured products in the Control Panel, those will trump with this query. If you don't, then everything will be ordered by the date added to the database.

You can therefore have the best of both by using the ordering option in the CP if you want to pop certain products to the top, else everything will be ordered by date entered from most recent to oldest.




Posted By: ym
Date Posted: 08-March-2014 at 11:06pm
It worked!!! Thank you so much.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net