News:

Support the VirtueMart project and become a member

Main Menu

Order product by DESC

Started by saiborg, January 26, 2012, 13:24:34 PM

Previous topic - Next topic

guidocx842

Quote from: P2 Peter on December 11, 2012, 23:45:05 PM
I think I know how it can be fixed, but it's above my programmingskills atm.

in the virtuemart administrator backend - > configuration -> article sorting, the two dropdown menus for the standard sorting should need an additional select box with ascending and descending as an option. Then in the product.php file the ASC and DESC should be replaced with the value set in the configuration. But truly... I miss the time currently to solve it :(

Yes... I suppose that this feature is one of the essential things that could be integrated in next versions of virtuemart.

srubard

Hi Peter. Good job, but this solution don't work in Virtuemart 2.0.20b. Can you help me with this, please? Thank you very much. David

Peter Pillen

And what exactly doesn't work? ordering? switching from asc to desc? sef on/off? ... Because I have the same version, but in my case, it still works using the same code.

And also important:
1. is sef on or off?
2. which is the standard sorting setting in your administrator backend of virtuemart?

srubard

Hello. Can you send me your product.php? I have SEF off now, but in the future SEF will be ON. Ordering is working, but switchiching from asc to desc not. I would like default sorting by DESC. Products with more pieces in stock first and products not in stock last.
In VM backend I have Default product sort order: Product in stock.


Peter Pillen

i can't attach the product.php to this post... that type of file is not allowed as attachment  :o (maybe send me your e-mail address by in-forum-message)

the clue for your choice of ordering is searching the following line in product.php
         $q .=  $orderBy . $direction . ' LIMIT 0,' . (int)$max;

i have it set to this (because I only use product id for ordering)
         $q .= ' ORDER BY `l`.`virtuemart_product_id` ' . $direction . ' LIMIT 0,' . (int)$max;

you need to alter the virtuemart_product_id variable to the database field you want the products ordered by

bobchain

#20
Dear Peter,
I made ​​the change that you indicated in your post, but once you have completed your changes, the default is that the button to change the sort order, returns the same order in the results.
I tried changing the type of sorting (the site must be ordered by creation date), by price, by code, but in both cases does not change.
the only difference that I noticed is that the icon that showed the first search result as asc +/- now appears as +/-, in fact now by clicking on the exchange rate arrangement appears in the url: http://www.miodominio.xxx/index.php/publications/.../.../orderAsc while first appeared "orderDesc"

What is wrong in the changes I've made​​?

thanks for your help!

P.S.:  J 2.5.8  +  VM 2.0.20a  + template custom override

Peter Pillen

you will first need to check if your creation dates are saved properly. There has been some issues with creation dates that were wrong in previous versions. An alternative way is to use de article id as sorting field because they also are chronological. Normaly clicking the +/- should change the order from descending to ascending.

bobchain

first of all thanks for your prompt reply.
I tried to change the sort order by using code and price, which in sight are much easier to follow, but the problem I found with those two settings.
the strange thing is that no changes sorting though not as I requested it works: default is "asc", and clicking on the order becomes "desc" (also appears use the orderDesc on the URL)

applying the change to the default that the order click on the button in the same way, even if the url shows "orderAsc" and the small icons appear correctly as described above.

I made ​​the change 2 times, thinking he had something wrong the first time, but the result is the same.

one thing I've noticed over the changes mentioned is that some valuations in my code on product.php strangely were already defined as DESC

where is my problem?

Peter Pillen

it is possible that my initial code is already become to old. It is possible that there already been some changes that effect behaviour of the desc/asc settings.

bobchain

Dear Peter
if so ... which could be the correct changes to my version?


Peter Pillen

I'm having problems understanding where exactly it is going wrong. Because it is strange that the code behaviour would be different in case A and case B. That makes me think there is something wrong in the data.

default sort order is set on "creation date"?
and the sort button and order is not working as expected for the creation date?

please double check your mysql database with php myadmin

table *your database prefix*_virtuemart_products and check if there are correct values in the field "created_on". There should be a date and not 0000-00-00 00:00:00.

It is actually the only problem I can think of in your case.


bobchain

Dear,
for this doubt I ran two more tests as I wrote earlier in the post, setting the "default order" as "the price of the product" and the "sku code" (more easy to check) with both the solution and the problem persisted.

by this test I realized that the problem is not in the information for which I perform sorting.

I rerun the change you indicated before, mistakenly thinking of committing the same error, but always with the same result.

if you give me an address and you have time and want to try it I can send you my file product.php (careful, however, because in the same file I have already made ​​other implementations/customizations: I have able the multiselelected manufacturer for single product)

bobchain

#27
Quote from: bobchain on May 08, 2013, 15:24:15 PM
(careful, however, because in the same file I have already made ​​other implementations/customizations: I have able the multiselelected manufacturer for single product)
SOLVED!!!!

and luckily I have said to make sure that personalization!!
my problem was right there! your edit works perfectly Peter!
Forgive me for making you lose time in analyzing a problem that does not exist!
thank you anyway for your support!

Peter Pillen

No thanks! I was beginning to doubt my coding, but lukily all is fine now.

bobchain

this will be appreciate in the future release...
Quote from: P2 Peter on December 11, 2012, 23:45:05 PM
in the virtuemart administrator backend - > configuration -> article sorting, the two dropdown menus for the standard sorting should need an additional select box with ascending and descending as an option. Then in the product.php file the ASC and DESC should be replaced with the value set in the configuration.
otherwise the standard alphabetical sorting "desc" is not pleasant

Sorry again!