VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: sleepigrl on August 09, 2012, 20:21:04 PM

Title: [bugfix?] Display order for custom fields
Post by: sleepigrl on August 09, 2012, 20:21:04 PM
I posted this yesterday in the Product Creation forum, but I'm reposting here in hopes that this change could be evaluated for inclusion in core.  I changes to administrator/components/com_virtuemart/models/customfields.php and the end result is that the custom fields for the product are be sorted by (1) custom field order then (2) order within the custom field.


See:  http://forum.virtuemart.net/index.php?topic=90362.msg354017#msg354017
Title: Re: [bugfix?] Display order for custom fields
Post by: Milbo on August 12, 2012, 02:11:03 AM
I think openglobal took care of it. Should be already in the svn.
Title: Re: [bugfix?] Display order for custom fields
Post by: sleepigrl on August 12, 2012, 16:11:55 PM
I don't see those changes in the SVN, unless I'm missing it or looking in the wrong place.  I'm looking here:  https://dev.virtuemart.net/svn/virtuemart/trunk/virtuemart/administrator/components/com_virtuemart/models/customfields.php 

Best as I can tell, that one will still sort only by the ordering within each customfield, not by the ordering of the customfields themselves.
Title: Re: [bugfix?] Display order for custom fields
Post by: Milbo on August 13, 2012, 11:55:17 AM
Did you tried it?
Title: Re: [bugfix?] Display order for custom fields
Post by: sleepigrl on August 16, 2012, 15:18:23 PM
I do not have a development environment set up at this point, but I downloaded the customfields.php file from the SVN and replaced mine.  The custom field order that I selected in the admin was ignored.

In customfields.php the join in this query causes the final ordering to be determined by the ordering within the custom field - the multiple values used for rearranging sizes, etc.  For a custom field that doesn't have multiple values, the ordering is always 0.  Other queries use the same logic for ordering, so they have the same results.
$query = 'SELECT C.`virtuemart_custom_id` , `custom_element`, `custom_jplugin_id`, `custom_params`, `custom_parent_id` , `admin_only` , `custom_title` ,
`custom_tip` , C.`custom_value` AS value, `custom_field_desc` , `field_type` , `is_list` , `is_cart_attribute` , `is_hidden` , C.`published` , field.`virtuemart_customfield_id` ,
field.`custom_value`,field.`custom_param`,field.`custom_price`,field.`ordering`
FROM `#__virtuemart_customs` AS C
LEFT JOIN `#__virtuemart_product_customfields` AS field ON C.`virtuemart_custom_id` = field.`virtuemart_custom_id`
Where `virtuemart_product_id` =' . $virtuemart_product_id . ' order by field.`ordering` ASC';



It seems that we really need to have both fields in use for ordering, so that fields are ordered first by their order from the customfield list in the admin and then by their order within the customfield. 

Where `virtuemart_product_id` =' . $virtuemart_product_id . ' order by C.`ordering`, field.`ordering` ASC';

As a side note, I tried to connect to the SVN with tortoise to grab all the files at once, but it tells me a need a username & password. 
Title: Re: [bugfix?] Display order for custom fields
Post by: celticwebs on September 12, 2012, 18:59:08 PM
I think I have just come across this bug too, I'm on the latest release 2.0.10 and a client has just asked me how she adds a custom field to the beginning of a list of products custom fields that already exist on a product.  I can't for the life of me work out ow you reorder them.  there doesn't seem o be anywhere to do it, I di dit in the main custom fields section and it had no effect on the order shown in the product.  The only way I can see to do it would be to delete all the custom fields from the product then add them all back in putting the new one in first, surely this sin't the only way to do it? 

Any help would be greatly appreciated.  Theres quite a few products I would need to spend a lot of time on if this simple feature isn't available in the software.