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.
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
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
Offline
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
Thanks,
James...
Offline
See correct solution further down thread.
Offline
Hi Rachel, no luck, didn't work.
The products don't display in the categories. I'll put the backup back.
Thanks for trying
James...
Offline
See correct solution further down thread.
Offline
Hi Rachael, no luck, didn't work. Products didn't display again. Any other suggestions?
Thanks for trying!
James...
Offline
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.
Offline
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.
$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
Offline
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.
$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
Offline
Thanks Rachael!
I'm going with the first solution since I don't do pennies.
James...
Offline
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.
Offline
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.
Offline
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.
Offline