News:

Looking for documentation? Take a look on our wiki

Main Menu

Ordering custom field variants

Started by bortolani, August 31, 2016, 13:35:19 PM

Previous topic - Next topic

bortolani

Hi,
is there a way to change the order of custom field variants?
Or to add a new variant in the middle of the list of existing variants?
At the moment when you add a variant it is always appended at the end and there's no way to move it up the list.
If you have 100 or more variants and you need to add one in the middle you have to change them all manually: a nightmare that will keep you busy for hours.

Bruno

Jumbo!

There is no straight forward method to achieve this.

First you will have to set your desired ordering (pordering) for the child products in #__virtuemart_products database table.

Open you will have to override components/com_virtuemart/sublayouts/customfield.php in your Joomla! template.

Find the following codes around lines 91 to 95:

$q = 'SELECT `virtuemart_product_id` FROM #__virtuemart_products WHERE product_parent_id = "'.$customfield->virtuemart_product_id.'" and ( published = "0" ';
if($stockhandle == 'disableit'){
$q .= ' AND (`product_in_stock` - `product_ordered`) > "0"';
}
$q .= ');';


Replace above by:

$q = 'SELECT `virtuemart_product_id` FROM #__virtuemart_products WHERE product_parent_id = "'.$customfield->virtuemart_product_id.'" and ( published = "0" ';
if($stockhandle == 'disableit'){
$q .= ' AND (`product_in_stock` - `product_ordered`) > "0"';
}
$q .= ' ORDER BY `pordering` ASC);';


This will ensure that the child products are listed as per your set product ordering.

bortolani

Hi Jumbo,
thanks a lot for your prompt answer.

Yes, what you suggest is quite straight forward.
May be I'll also add a field in the back end to edit the pordering field easily.

Many thanks,
Bruno