News:

Looking for documentation? Take a look on our wiki

Main Menu

Stockable variants: sorting order of child products in dropdown box

Started by roycosoep, September 28, 2012, 09:38:41 AM

Previous topic - Next topic

roycosoep

Hello,

I have a question about the sorting order of child products that belong to a certain parent product. For example:

  • parent product A

    • child product A1 (size S)
    • child product A2 (size M)
    • child product A3 (size L)
In this case, when selecting the parent product in the webshop, I get the three options (S, M, L) to choose from in a drop-down box. However, the order of these options is alphabetically (L, M, S) where I would like it to be (S, M, L). In the custom field options the correct order of possible values is stated (S, M, L).

How can I fix this?

Thanks a lot in advance!

Regards,
Roy

delliott

I need to know the answer to this question too.  I've been diving through code trying to find the correct WHERE clause to force the order and cannot find anything that seems to work.  Order seems to be random at best.  Will someone at Virtuemart please respond to this thread?

delliott

Of course as soon as I post the question, then I stumble on the answer.

Line # 2038 of administrator/com_virtuemart/models/product.php, change the ORDER BY clause to look like below.  The order of the drop-down will now look to the product SKU values for ordering instructions.

         $q .= ' GROUP BY `virtuemart_product_id` ORDER BY virtuemart_product_id, p.product_sku';

bmw2182

I changed line 2038 in /administrator/components/com_virtuemart/models/product.php

to         
$q .= ' GROUP BY `virtuemart_product_id` ORDER BY virtuemart_product_id, p.product_sku';

and commented out the next line
//$q .= ' GROUP BY `virtuemart_product_id` ORDER BY ordering DESC';

however, it didn't seem to work for me.  I'm sure I'm missing something.

I have attached a print screen of how I have it setup on the main product as well as how it shows up.  I want it to be ordered from lowest to highest.......

Any thoughts??? What am I missing?

[attachment cleanup by admin]

onnj

What I did here is I set weight to small, medium and large by .5kg, 1kg and 1.5 kg.

and at the custom field try to select not by product sku but by product weight my problem now is to some product this will work it will show s, m, l ... but to some product still s, l, m.... small is my parent product and m,l are the child product

jike1985

Thanks for the solution on this - you've saved me many hours of googling!!

kovacshazi

VM2.0.26d and J2.5.19

Quote from: delliott on October 23, 2012, 23:14:59 PM
Of course as soon as I post the question, then I stumble on the answer.

Line # 2038 of administrator/com_virtuemart/models/product.php, change the ORDER BY clause to look like below.  The order of the drop-down will now look to the product SKU values for ordering instructions.

         $q .= ' GROUP BY `virtuemart_product_id` ORDER BY virtuemart_product_id, p.product_sku';
I would like to sort the items to stock, but unfortunately this solution does not help. Does anyone have any ideas?
I changed the code to p.product_in_stock