Kryptronic Software Support Forum

You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.

#26 05-27-2006 18:34:11

celdirect
Member
From: UK
Registered: 04-01-2005
Posts: 782

Re: Order Products By X Field

Hi,

I have a simlair problem with sorted the reports section of page views show highest viewd page first - i think what you need to do here for the products is add the numbers in like


000010
000020
000033
000100
000150
000200

this will sort from lowest to hightest - just use your price range and just put as many o' in front as you heighest price so if it was 1000,000 then you would need a total of 7 digits, so for 10 pounds it would be

0000010

hope this helps

Charlie

Offline

 

#27 06-02-2006 13:33:13

cnyservices
Member
From: Syracuse, NY
Registered: 12-21-2005
Posts: 47
Website

Re: Order Products By X Field

I am trying to order the Catagories displayed on the online store page, is there a mod for that?  This seems to relate only to the products within the catagories...
D


David M. Huntington
CNY Computer Services
wwwcnyservices.com

Offline

 

#28 06-02-2006 13:43:18

Iceit88
Member
From: Fairview, PA
Registered: 11-19-2003
Posts: 549
Website

Re: Order Products By X Field

Here is the mod to organize catergories 


Bryan

Hat Trick Sports, LLC

Offline

 

#29 06-02-2006 17:38:44

wyattea
Member
Registered: 01-07-2006
Posts: 1650

Re: Order Products By X Field

I'd really like a programming fix that can sort my products by lowest to highest price - I'd rather avoid changing my price column and adding 000022, 000023, etc...that's not a clean way and I'd only do that as a last resort.

Maybe Nick can show us a quick mod to his original script smile

Thanks,

James...

Offline

 

#30 06-02-2006 20:38:34

rachaelseven
Member
From: Massachusetts, USA
Registered: 01-23-2006
Posts: 3169
Website

Re: Order Products By X Field

See correct solution further down thread.


Rachael Katz
- Custom Focusing Screens for DSLR Cameras

Offline

 

#31 06-02-2006 22:00:57

wyattea
Member
Registered: 01-07-2006
Posts: 1650

Re: Order Products By X Field

Hi Rachel, no luck, didn't work.

The products don't display in the categories.  I'll put the backup back.

Thanks for trying smile

James...

Offline

 

#32 06-03-2006 16:40:45

rachaelseven
Member
From: Massachusetts, USA
Registered: 01-23-2006
Posts: 3169
Website

Re: Order Products By X Field

See correct solution further down thread.


Rachael Katz
- Custom Focusing Screens for DSLR Cameras

Offline

 

#33 06-03-2006 18:15:37

wyattea
Member
Registered: 01-07-2006
Posts: 1650

Re: Order Products By X Field

Hi Rachael, no luck, didn't work.  Products didn't display again.  Any other suggestions? smile

Thanks for trying!

James...

Offline

 

#34 06-03-2006 18:38:25

rachaelseven
Member
From: Massachusetts, USA
Registered: 01-23-2006
Posts: 3169
Website

Re: Order Products By X Field

Nevermind... just installed the mod on my test site to see what's up and it definitely isn't working with the CAST statement in there.  It works perfectly from a MySQL console, so I think it might be an issue with the DBD module not supporting that syntax.  Let me keep working on it a bit and see if I can find a solution.


Rachael Katz
- Custom Focusing Screens for DSLR Cameras

Offline

 

#35 06-03-2006 19:25:41

rachaelseven
Member
From: Massachusetts, USA
Registered: 01-23-2006
Posts: 3169
Website

Re: Order Products By X Field

Ok, I found it... talk about your picky syntax.  Evidently, when used from within CCP, you can't have a space between CAST and the parenthesis, even though the statement is technically correct in MySQL.  I used the following statement on my site and it seems to work fine.

Code:

$sql_limit_string = "ORDER BY CAST(product_regprice AS SIGNED) $sql_limit_string";

Your product table has to be running in MySQL mode for this to work, though.  It will probabaly work in other alternate database modes, but it definitely won't work in CSV mode.  Let me know how it goes.

Rachael


Rachael Katz
- Custom Focusing Screens for DSLR Cameras

Offline

 

#36 06-03-2006 19:34:42

rachaelseven
Member
From: Massachusetts, USA
Registered: 01-23-2006
Posts: 3169
Website

Re: Order Products By X Field

The previous post definitely gives a working solution, but it might convert the prices to integers (drop the pennies).  So it might not work 100%, depending on your pricing structure.  The following statement should work in all situations, but it still won't work with the product table in CSV mode.

Code:

$sql_limit_string = "ORDER BY (product_regprice*100) $sql_limit_string";

Both solutions seem to work ok, but this one is probably more generic.  Since MySQL has to multiply the price, it implicitly casts it as a number.  And by multiplying by 100, we guarantee that the prices can't be rounded off and not order properly by pennies.  Don't worry, the actual price won't get multipled, only the price as used for the ordering process.

Rachael


Rachael Katz
- Custom Focusing Screens for DSLR Cameras

Offline

 

#37 06-03-2006 19:57:10

wyattea
Member
Registered: 01-07-2006
Posts: 1650

Re: Order Products By X Field

Thanks Rachael!

I'm going with the first solution since I don't do pennies.

James...

Offline

 

#38 07-19-2006 00:55:04

vbsaltydog
Member
From: Florida
Registered: 05-02-2005
Posts: 947
Website

Re: Order Products By X Field

It's sorting numerically but it doing it number by number from left to right:

100
140
250
32
33
35
44

Solution:

ORDER BY (your_sorting_column+0)



This sets the MySQL field for your sorting to an Integer which will be sorted properly.


Latest CCP 7 XMods Available:


Offline

 

#39 07-19-2006 09:08:14

rachaelseven
Member
From: Massachusetts, USA
Registered: 01-23-2006
Posts: 3169
Website

Re: Order Products By X Field

That's pretty much the same as what I posted above; performing any mathmatecal operation inside the ORDER BY statement will cause the variable to be implicitly cast as an integer.


Rachael Katz
- Custom Focusing Screens for DSLR Cameras

Offline

 

#40 03-23-2007 14:35:49

doubledome
Member
Registered: 09-24-2003
Posts: 83
Website

Re: Order Products By X Field

Hi All,

I have the Wholesale mod implemented in my store which has changed code related to this mod. I pointed Matt to this thread to have it done, but it seems that the code he changed gets the products on a page to sort by product name, but not related to a multiple page category. In other words the first page will be a-s and then page 2 will have "h" products in it.

The first two lines of the fix aren't in my ste_prod.pl and then all the others have been modified so I'm thinking he did it a different way. I don't want to break the wholesale mod as this is a wholesale only site.

Any help would be greatly appreciated.


cab713

Offline

 

Board footer