VirtueMart Forum

VirtueMart 2 + 3 => Product creation => Topic started by: athree on August 27, 2011, 11:33:27 am

Title: Order of custom fields
Post by: athree on August 27, 2011, 11:33:27 am
How to set the order of custom fields?
Title: Re: Order of custom fields
Post by: jenkinhill on August 27, 2011, 16:31:21 pm
On VM2? See http://forum.virtuemart.net/index.php?topic=79799.msg263721#msg263721
Title: Re: Order of custom fields
Post by: athree on August 27, 2011, 17:33:15 pm
Latest, 1.9.8 RC2E
and RC2F also
Title: Re: Order of custom fields
Post by: athree on August 31, 2011, 15:46:24 pm
I understand the mechanism of sorting of custom fields is not provided at all? Or for now?
Title: Re: Order of custom fields
Post by: Milbo on August 31, 2011, 16:41:41 pm
Ordering is in the db, but maybe it works not as expected.
Title: Re: Order of custom fields
Post by: athree on August 31, 2011, 16:58:14 pm
but worth the wait? Preferably managed through an VM interface...
Title: Re: Order of custom fields
Post by: Milbo on August 31, 2011, 18:21:36 pm
The interface is already there.
Title: Re: Order of custom fields
Post by: athree on August 31, 2011, 19:08:05 pm
I mean that:

(http://img38.imageshack.us/img38/9982/20110901000834.png) (http://imageshack.us/photo/my-images/38/20110901000834.png/)

Sorry for my english :)
Title: Re: Order of custom fields
Post by: cas on September 15, 2011, 05:11:16 am
Hi Milbo,

In v1.9.8.RC2G the user interface does not have the ability to order the Custom Fields.  I see the column is in the database table to hold the row order, but the user interface does not have anything that I can see.  What am I missing?   

Thanks,
Chuck
Title: Re: Order of custom fields
Post by: Milbo on September 15, 2011, 11:03:52 am
Soooorrry,  I got my self mixed up with the userfields/shopperfields. Hmm we have to add it yes, but where
Title: Re: Order of custom fields
Post by: cas on September 15, 2011, 19:56:28 pm
Hi Milbo,

I'm glad I was not going crazy! ;)  I was looking and looking for it! 

As far as where to put it in the user interface, it should be in both the Custom Fields interface so we can set the default order for the Custom Fields, but then when we add the Custom Fields to products, we should be able to change the order of Custom Fields for that product if we desire. 

Cheers,
Chuck
Title: Re: Order of custom fields
Post by: cas on September 27, 2011, 00:34:21 am
Hi Milbo,

Any update status on this topic?

Thanks,
Chuck
Title: Re: Order of custom fields
Post by: Axiom on October 07, 2011, 17:14:35 pm
Hi all, I'm looking for this feature as well..

As a work around I did try to enter then fields in the order that I wanted, but it readjusted on save and this new "automagical" ordering put child items before the parent items and messed up the display...  I'll have to take a peek in the database and make the manual changes, but having an ordering adjustment is a must have for the fields.
Title: Re: Order of custom fields
Post by: cas on October 08, 2011, 07:23:06 am
I was hoping this feature would be in version H, but no such luck.   Can the developers give us an estimate as to when this feature will be included?

Thanks,
Chuck
Title: Re: Order of custom fields
Post by: Studio 42 on October 11, 2011, 00:26:14 am
HI all,
You can now order the product custom fields by simply drag-in it in the edit product form

Patrick
Title: Re: Order of custom fields
Post by: cas on October 11, 2011, 07:41:40 am
Hi Patrick,

I don't see how to drag custom fields to reorder them in the product editor.  What do I select to drag them?  Why isn't there just a simple order number column that can be reordered as shown in athree post above?

Also, I see now that a custom field with a Zero price adjustment displays "FREE" on the website.  Can this FREE be changed in the Admin?  Shouldn't this say "NO ADDITIONAL CHARGE".  The idea that if the customer picks that attribute that the product is FREE could be misleading.

Thanks,
Chuck
Title: Re: Order of custom fields
Post by: Milbo on October 11, 2011, 11:37:27 am
Why isn't there just a simple order number column that can be reordered as shown in athree post above?
Because it is the stupidest and most boring method. When you want to change the order you often have to change the ordering of all lines. Now you can clickn' drop it, which is afaik the nonplusultra of ordering handling.

Also, I see now that a custom field with a Zero price adjustment displays "FREE" on the website.  Can this FREE be changed in the Admin?
OFC
Shouldn't this say "NO ADDITIONAL CHARGE".  The idea that if the customer picks that attribute that the product is FREE could be misleading.

ahh the 7th suggestion. But you should write it lowercase, in other case you scream http://xfinity.comcast.net/slideshow/finance-10emailhabits/all-caps/
Title: Re: Order of custom fields
Post by: cas on October 11, 2011, 19:40:43 pm
The drag & drop does work for me because there is nothing to grab on to.  What in the product custom fields editor should I select in order to drag it? 

No screaming (yet), just drawing your attention to the main point.  Since you said OFC to my question about changing the word Free, where in the admin editor can I change "Free" to "No Additional Charge"?

Thanks,
Chuck 
Title: Re: Order of custom fields
Post by: jjk on October 11, 2011, 20:34:31 pm
The drag & drop does work for me because there is nothing to grab on to.  What in the product custom fields editor should I select in order to drag it?

On your 'Product Edit' - 'Custom Fields' tab. Just left-click one of your 'Custom Field Type' entries (rows) assigned to your product and move it.
Quote
Since you said OFC to my question about changing the word Free, where in the admin editor can I change "Free" to "No Additional Charge"?
Search for COM_VIRTUEMART_CART_PRICE_FREE="Free" in your frontend and backend language files (en-GB.com_virtuemart.ini)  ;)
Title: Re: Order of custom fields
Post by: Nocktis on October 11, 2011, 22:00:21 pm
Having the same issue.  I can't reorder them.  In fact, clicking the "apply" button, they are reordering themselves in a random order.  I can click the apply button and see a new order each time.
Title: Re: Order of custom fields
Post by: jjk on October 11, 2011, 22:22:35 pm
Note that the drag and drop sorting only works in the SVN version at present (afaik).  It was introduced after the release of RC1.9.8.H.
Title: Re: Order of custom fields
Post by: cas on October 12, 2011, 00:07:53 am
Hi jjk,

Thanks for explaining it's not in version H.  I thought I was doing something wrong.   

Regards,
Chuck
Title: Re: Order of custom fields
Post by: cas on October 15, 2011, 22:44:21 pm
I updated to version i, and I see in the Product admin in the Custom Fields tab there is now ordering capability by dragging & dropping, but on the website the order of the Custom Fields does not change, and the order of the Custom Field values in the drop-down list displays in the opposite order of the admin order, as well as the order of the Custom Fields images displays in the opposite order of the admin order. 

Also, in the Custom Fields admin, I see there is ordering capability added, but it does not work.  I can change the numbers and hit the disk icon to save the order, but the order does not change.  And when I click the little up or down arrow to change the order, the order does not change. 

Help,
Chuck
Title: Re: Order of custom fields
Post by: jjk on October 15, 2011, 23:48:17 pm
Looks like we have to wait until the developers find some time to take care of this.
See here: http://forum.virtuemart.net/index.php?topic=92005.0 (http://forum.virtuemart.net/index.php?topic=92005.0)  ;)
Title: Re: Order of custom fields
Post by: cas on October 21, 2011, 19:51:27 pm
I updated to version J and here is what I found:

On the website the order of the Custom Field values inside the drop-down is now in the correct order.  Thanks!
But when there are more than one Custom Field for the product, the Custom Fields are not in the order I set in the admin.

Also, in the Custom Fields admin, I see there is ordering capability, but it does not work.  I can change the numbers and hit the disk icon to save the order, but the order does not change.  As well as when I click the little up or down arrows to change the order, the order does not change. 

Thanks,
Chuck
Title: Re: Order of custom fields
Post by: jjk on October 21, 2011, 20:03:18 pm
As a workaround I added/renamed/deleted custom fields in the custom fields admin list until I got them in the right order and grouped them, so I can now add the group of custom fields to all my product in the order I want them to display under each product.
Title: Re: Order of custom fields
Post by: cas on October 21, 2011, 21:54:23 pm
Thanks jjk.   I know I can force it to work as you noted, but I have thousands of products and each product has dozens of options, so I really need it to work properly before I start the massive data loading effort.  The good news is version J fixed many of the other issues I was having, so we're getting very close! :) 
Title: Re: Order of custom fields
Post by: cas on October 28, 2011, 23:41:25 pm
I updated to version M and have the same problem as reported with previous versions.  Here are the problems:

On the website the order of the Custom Field values inside the drop-down is now in the correct order.  Thanks!
But when there are more than one Custom Field for the product, the Custom Fields are not in the order I set in the admin.

Also, in the Custom Fields admin, I see there is ordering capability, but it does not work.  I can change the numbers and hit the disk icon to save the order, but the order does not change.  As well as when I click the little up or down arrows to change the order, the order does not change.

Thanks,
Chuck
Title: Re: Order of custom fields
Post by: cas on December 18, 2011, 23:25:42 pm
I retested this with version RC3, and it still doesn't work properly:

On the website the order of the Custom Field values inside the drop-down are in the correct order, but when there are more than one Custom Field sets for the product, the Custom Field sets on the website are not in the same order that I set in the product admin custom fields tab.

In the Custom Fields admin, the ordering feature does not work.  I can change the numbers and hit the disk icon to save the order, but the order does not change.  As well as when I click the little up or down arrows to change the order, the order does not change.
Title: Re: Order of custom fields
Post by: Studio 42 on December 27, 2011, 12:14:32 pm
cas,
 we are now virtuemart 2.0 final ;)

No real support for older beta version because we work all with 2.0 final revision only(and subrelase from final)
Title: Re: Order of custom fields
Post by: cas on December 27, 2011, 22:04:23 pm
Hi Electricity,

My post was from Dec 18th when RC3 was the latest version.   Did you check if it works now with VM2.0.0?  I just checked it and unfortunately the problem is still the same as I described in my Dec 18th post.  Any estimate when it will be fixed?   

Thanks,
Chuck
Title: Re: Order of custom fields
Post by: cas on February 05, 2012, 00:47:55 am
Just updated to VM2.0.1.d and it still does not work.
Title: Re: Order of custom fields
Post by: cas on February 16, 2012, 07:22:06 am
Just updated to VM2.0.1.K and it still does not work.
Title: Re: Order of custom fields
Post by: cvoogt on March 20, 2012, 15:22:08 pm
Not sure why this still hasn't been fixed but it's pretty simple;

Edit /administrator/components/models/custom.php

Right after this:
Code: [Select]
if($search){

$search = '"%' . $this->_db->getEscaped( $search, true ) . '%"' ;

$query .= 'AND `custom_title` LIKE '.$search;

}

Insert this (should be around line 191):

Code: [Select]
$query .= ' ORDER BY ordering ASC';
The custom fields list query had no ordering, and it was displaying them willy-nilly.
Title: Re: Order of custom fields
Post by: cas on March 20, 2012, 19:12:55 pm
Thanks cvoogt.

VM team, can you let us know when this fix is implemented?
Title: Re: Order of custom fields
Post by: Actlas on April 26, 2012, 10:08:38 am
Not sure why this still hasn't been fixed but it's pretty simple;

Edit /administrator/components/models/custom.php

Right after this:
Code: [Select]
if($search){

$search = '"%' . $this->_db->getEscaped( $search, true ) . '%"' ;

$query .= 'AND `custom_title` LIKE '.$search;

}

Insert this (should be around line 191):

Code: [Select]
$query .= ' ORDER BY ordering ASC';
The custom fields list query had no ordering, and it was displaying them willy-nilly.

This doesn't work for me? I added this code and I want to change the order of the custom fields of a product in the backend but they don't change in the frontend?!
Is there a workaround for this problem? I am using the latest version of Virtuenet.
This is a huge flaw imo

You can see an example here:
http://dev.actual-laser.be/index.php/e-shop/deurbellen-diepgegraveerd/california-cnc-detail

I also tried renaming the custom fields with aa and bb to check if it works in alfabethical order but it doesn't work either...
Title: Re: Order of custom fields
Post by: ash on May 15, 2012, 12:53:36 pm
I have the same issue, latest version of Joomla and VM  I have a product with 6 custom fields, and regardless of the order in the back end the front end just shows them how ever it wants to, I try to change the order of the fields in the Joomla admin but the sort order or move up and down does not work.

Is there still not a fix for this as it would appear this issue has been around for a while now.
Title: Re: Order of custom fields
Post by: ash on May 15, 2012, 15:27:58 pm
Well the only way to resolve this issue was to go to the database and edit the order numbers to the order i want them in

1 custom attribute
2 custom attribute
3 custom attribute
4 custom attribute
etc etc

In the front end my custom fields for my products are now ordered correctly so the shopper is now able to buy an item without being completely confused about the product asking them for their items colour before actually choosing the product style first.

Not being able to order this list is one of the biggest pitfalls in Virtuemart, i recommend that people with large stores with many attributes use another solution or think and plan very very carefully first.

The only issue i see is that if another attribute becomes available for a product and needs to slot in between two others, then this is going to either be practically impossible or take you a heck of a long time to do.

Serious thinking on this major issue needs to be thought through by the developers.

Gees lets make it a $10 component and get it working right, i would pay that all day long. Even better if it had dynamic attributes like many of the free wordpress stores or magento.
Title: Re: Order of custom fields
Post by: Bigfish on May 16, 2012, 20:43:31 pm
Have the same problem.
I loaded 19 custom fields & tried to sort etc but no luck so started a thread (http://forum.virtuemart.net/index.php?topic=102729.0) then found this one.


Title: Re: Order of custom fields
Post by: cas on July 17, 2012, 01:56:41 am
VM Team,

Can you let us know when this will be fixed?
Title: Re: Order of custom fields
Post by: razor7 on July 17, 2012, 19:23:56 pm
Hi, I have ran into this issue again, solved this way on VM 2.0.8c :
Changed administrator/components/com_virtuemart/models/customfields.php line 818
Quote
      $query .= ' and is_cart_attribute = 1 group by virtuemart_custom_id';
To this
Quote
      $query .= ' and is_cart_attribute = 1 group by virtuemart_custom_id order by C.ordering';

Missing ordering statement!

Also, in custom field administrator, there is no way to get the items ordered by ordering columnb, bacause no matter if you click the orering column title, there is no ordering performed.

Best regards!
Title: Re: Order of custom fields
Post by: sleepigrl on August 07, 2012, 19:24:39 pm
razor7, you and I were on the same track!

I was in the process of modifying some other queries for ordering when I found your post.  I've made some additional changes 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.

I made the changes to administrator/components/com_virtuemart/models/customfields.php @ lines 418, 735, 819 and 854.  The following is a WinMerge generated patch file.

Code: [Select]
418c418
< Where `virtuemart_product_id` =' . $virtuemart_product_id . ' order by field.`ordering` ASC';
---
> Where `virtuemart_product_id` =' . $virtuemart_product_id . ' order by C.`ordering`, field.`ordering` ASC';
735c735
< $query .= ' and is_cart_attribute = 0 order by field.`ordering`,virtuemart_custom_id';
---
> $query .= ' and is_cart_attribute = 0 order by C.`ordering`, field.`ordering`,virtuemart_custom_id';
819c819
< $query .= ' and is_cart_attribute = 1 group by virtuemart_custom_id';
---
> $query .= ' and is_cart_attribute = 1 group by virtuemart_custom_id order by C.ordering';
854c854
< $query .= ' ORDER BY field.`ordering`';
---
> $query .= ' ORDER BY C.`ordering`, field.`ordering` ASC';


In the admin, clicking the ordering button still has no effect, but input into the ordering fields does seem to be saved. 
Title: Re: Order of custom fields
Post by: easy on August 07, 2012, 21:22:21 pm
Thank you sleepgirl & razor7!
Great job - it works well!
Title: Re: Order of custom fields
Post by: cas on August 07, 2012, 22:22:13 pm
VM team,

Any chance to fix this in the base so we don't have to hack the code? 
Title: Re: Order of custom fields
Post by: encreplus on August 24, 2012, 16:15:09 pm
Dont work on 2.0.10 ;(

Stefan
Title: Re: Order of custom fields
Post by: sleepigrl on August 24, 2012, 22:28:43 pm
@encreplus, I made the same changes to my 2.0.10 version just a few minutes ago and the ordering is applied correctly. 

One thing to note, clicking on the Ordering header in the admin (ostensibly to sort by ordering) has no effect.  But making manual changes to the order there does affect the order that the custom fields are displayed in the frontend using the hack I posted above.
Title: Re: Order of custom fields
Post by: cas on August 25, 2012, 01:58:13 am
VM team,

Any chance to fix this in the base so we don't have to hack the code? 
Title: Re: Order of custom fields
Post by: cmb on October 10, 2012, 00:57:59 am
Any chance to fix this in the base so we don't have to hack the code?

The code given by sleepigrl above in this thread works. One hopes that it will find its way into the code soon. I just upgraded to VirtueMart 2.0.12b and, of course, had to dredge up the old \administrator\components\com_virtuemart\models\customfields.php file to get my site working correctly again.

I noticed that Matt Lewis-Garner changed the Status of the bug report (http://dev.virtuemart.net/issues/383) from Assigned to Resolved two months ago. The Issue is still open but marked 100% Done. Can anyone tell us when the repairs will be implemented?
Title: Re: Order of custom fields
Post by: neo314 on November 18, 2012, 06:17:17 am
I'm using 2.0.14 and sleepigirl's code does not seem to work in that and the ordering is still not fixed on my install. Any updates on this issue?
Title: Re: Order of custom fields
Post by: selor on December 16, 2012, 15:13:53 pm
This fix doesnt working on 2.0.14 ..

Grr What the hell about this problem ???
it exist for a longgggggggggggggggggg Time ago and the custom fields always gone me mad with this order that is not considered ..

Pliz someone have a fix for that ???

Title: Re: Order of custom fields
Post by: cas on January 13, 2013, 01:03:25 am
Still broken in VM2.0.18a
Title: Re: Order of custom fields
Post by: Milbo on January 13, 2013, 11:41:21 am
Selor, the fix does not work ,because the fix is already there. How do you add a fix, if there is already the same code. I just checked the code.

Also works for me. So maybe your problems are due an hacked store?
Title: Re: Order of custom fields
Post by: LTCreations on February 04, 2013, 20:06:40 pm
Selor, the fix does not work ,because the fix is already there. How do you add a fix, if there is already the same code. I just checked the code.

Also works for me. So maybe your problems are due an hacked store?

I have not applied "any" hacks, and the sort does not work for me. I keep adding and removing the custom fields because they "do not" sort correctly.

I want "First Flavor 1", "Second Flavor 1", "First Flavor 2", "Second Flavor 2", "Third Flavor 1" and "Third Flavor 2" in that order.
I can't get 16 flavor names in the "Default" custom field, so I have to create the first and second flavor select lists - another issue that should have already been addressed. I don't want to edit the database because the client will need to update flavors, pricing, attributes, etc., over time and won't be aware of the issue(s) every time they update.
These issues are tolerable for developers to work around. But clients who simply "use" the site don't have any idea about how and why these simple annoyances are keeping them from having their site work properly.
So Virtuemart needs to be addressed in order that clients don't have to keep calling and paying developers to "fix" their site.

So, in order to have 16 flavors from which to choose, and allow the user to select 3 of the 16, I have to have 6 select lists each with 8 options (flavors). This "should" be done with 3 select lists.
But every time I add the second list, even only the first half, it appears on the front-end "above" the first list. In the back-end, the ordering column displays the sort number ("Ordering" column) I last applied. But the front-end is not responding to what is shown in the back-end.

My next attempt will be to add the lists in reverse order.
Please. Don't say that this is fixed when it's not.
Having to input everything in reverse order is more than simply an annoyance. And when the client updates something it will be all out of order again and "I" am the one who is going to be in trouble.

I'm using the latest update, to which I just updated my client today - 2.0.18a.

Please don't consider this a complaint - simply stating the facts and asking if, perhaps, I've overlooked something that needs to be addressed, or, instead, if the "fix" is not...
Title: Re: Order of custom fields
Post by: LTCreations on February 04, 2013, 22:54:44 pm
Here is the resolve "I" found to work for my specific project.
So you understand in order to see if it will work for you, I have 1 product that needs to have 3 selections made for the order. Each of the 3 selections must be from the same list of 16 flavors.
So, the customer needs to select 3 flavors from a list of 16.

Here is the working site http://www.superiorvaping.com/vaping-products/sample-packs/34/sample-pack-detail.html (http://www.superiorvaping.com/vaping-products/sample-packs/34/sample-pack-detail.html)

This was my process:

After creating your product:
1 Create a "Custom Field" (New)
   Custom Field Type: Cart Variant
   Title (whatever you wish)
   Published: Yes
   Parent: "Please Select" (which is NONE - leave at default)
   Cart Attribute: Yes
   Description, Default, Tooltip and Layout position are all blank
   Admin only: No
   Is a list? No
   Hidden: No

2 Save and Close that field.

3 Repeat step 1 for each drop-down box you wish to create for your 1 product.

4 Sort the custom fields you have just created.
4a Type in the numbers you wish for the custom fields you want displayed with your product.
The first field should have the lowest number and the last field will have the highest number.
Save the updated sort order.

5 Select Products > "Your Product" > Custom Fields

6 Under "Custom Field Type:" select one of the custom fields you created in step 1.
6a For every option you want added to one drop-down list, repeat step 6, making sure to select the same custom field name. If you want several drop-down selection boxes you'll need to select and add the custom field name as many times as you want options for that 1 drop-down box.

7 Type in the text you want displayed as one of the options in your drop-down list in the blank "Value" box to the right of your custom field name.
7a Repeat this process for each of the blank fields you created.

8 OPTIONAL
If you want to add a fee with each (or some) selection(s), replace the "0" in the "Price" box with the value you wish "added" to your product price.

9 Save the entries you just made and review the new options for your product on the front-end of your site.

I spent a couple of days on this, trying variations of "Group", custom field with "Default" text (which wasn't large enough to fit all the flavors) and other ideas. Nothing worked that would also allow me to sort the boxes in the order I wanted. I read the hacks and possible outcomes of using a hack. Since I'm always dealing with clients who don't want to spend much I'm constantly trying to assure that when I'm finished, the project is going to do what the client needs without my constant attention.
Hacking means I'll have to be back whenever there is an update, and perhaps even when there is just something the client "should not have done".
I don't have that luxury and I'm sure a lot of you don't.
So my goal was to find a solution that may have been a bit more involved than I wanted but no hacking, and the client won't have to worry about messing with anything later.

I hope this helps your situation.
Title: Re: Order of custom fields
Post by: Popandos on April 03, 2013, 11:38:22 am
Hello, i saw that this bug have appeared after 2.0.20b update. There is no Sleepgirl's fix in the customfields.php file, so the custom fields aren't ordering by order field now, only by custom id. The problem had been solved after i made that hack. So, i hope, that this fix will be in the later updates of virtuemart.
Title: Re: Order of custom fields
Post by: Actlas on May 12, 2013, 15:29:09 pm
Thank you so much sleepigirl and all others! This worked for me on vm 2.0.6.
Title: Re: Order of custom fields
Post by: cas on June 13, 2013, 21:45:07 pm
Is this fixed in the base?  In the admin, Custom fields aren't ordering by order field, but only by custom id.
Title: Re: Order of custom fields
Post by: LeonZ on August 03, 2013, 10:53:21 am
After updating to 2.0.22a my custom fields messed up again. thanks to this old post got it on the right track fast and I was able to sort on my custom ordering again. D*mm, I wasn't thinking about dragging and dropping the custom fields ordering by hand for all my products.

TNX

razor7, you and I were on the same track!

I was in the process of modifying some other queries for ordering when I found your post.  I've made some additional changes 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.

I made the changes to administrator/components/com_virtuemart/models/customfields.php @ lines 418, 735, 819 and 854.  The following is a WinMerge generated patch file.

Code: [Select]
418c418
< Where `virtuemart_product_id` =' . $virtuemart_product_id . ' order by field.`ordering` ASC';
---
> Where `virtuemart_product_id` =' . $virtuemart_product_id . ' order by C.`ordering`, field.`ordering` ASC';
735c735
< $query .= ' and is_cart_attribute = 0 order by field.`ordering`,virtuemart_custom_id';
---
> $query .= ' and is_cart_attribute = 0 order by C.`ordering`, field.`ordering`,virtuemart_custom_id';
819c819
< $query .= ' and is_cart_attribute = 1 group by virtuemart_custom_id';
---
> $query .= ' and is_cart_attribute = 1 group by virtuemart_custom_id order by C.ordering';
854c854
< $query .= ' ORDER BY field.`ordering`';
---
> $query .= ' ORDER BY C.`ordering`, field.`ordering` ASC';


In the admin, clicking the ordering button still has no effect, but input into the ordering fields does seem to be saved. 

Title: Re: Order of custom fields
Post by: denvarel on October 08, 2013, 14:46:47 pm
After updating to 2.0.22a my custom fields messed up again. thanks to this old post got it on the right track fast and I was able to sort on my custom ordering again. D*mm, I wasn't thinking about dragging and dropping the custom fields ordering by hand for all my products.

TNX

razor7, you and I were on the same track!

I was in the process of modifying some other queries for ordering when I found your post.  I've made some additional changes 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.

I made the changes to administrator/components/com_virtuemart/models/customfields.php @ lines 418, 735, 819 and 854.  The following is a WinMerge generated patch file.

Code: [Select]
418c418
< Where `virtuemart_product_id` =' . $virtuemart_product_id . ' order by field.`ordering` ASC';
---
> Where `virtuemart_product_id` =' . $virtuemart_product_id . ' order by C.`ordering`, field.`ordering` ASC';
735c735
< $query .= ' and is_cart_attribute = 0 order by field.`ordering`,virtuemart_custom_id';
---
> $query .= ' and is_cart_attribute = 0 order by C.`ordering`, field.`ordering`,virtuemart_custom_id';
819c819
< $query .= ' and is_cart_attribute = 1 group by virtuemart_custom_id';
---
> $query .= ' and is_cart_attribute = 1 group by virtuemart_custom_id order by C.ordering';
854c854
< $query .= ' ORDER BY field.`ordering`';
---
> $query .= ' ORDER BY C.`ordering`, field.`ordering` ASC';


In the admin, clicking the ordering button still has no effect, but input into the ordering fields does seem to be saved. 

Confirmed to work either in Virtuemart 2.0.24 the lines numbers is different and in (previous line 819)now 824 the string
$query .= ' and is_cart_attribute = 1 group by virtuemart_custom_id';
is changed becoming:
$query .= ' and is_cart_attribute = 1 group by virtuemart_custom_id ORDER BY field.`ordering`';
and has to be replaced with
$query .= ' and is_cart_attribute = 1 group by virtuemart_custom_id ORDER BY C.`ordering`';