I am recreating an ecommerce site and have run into an issue with sorting the products by a custom attribute's value. The existing site is working correctly - the products are ordered within the query arguments -
'meta_key' => 'pa_diameter',
'orderby' => 'meta_value_num',
'order' => 'ASC',
This method is not working on the new site. I checked the databases of both sites and it appears that the way attribute values are stored has changed in the different versions of WooCommerce. (Old site was not updated for a while).
In the old site, the 'pa_diameter' attribute was stored as a meta key/value for each product, whereas on the new site, the value for each attibute exists only within the '_product_attributes' meta_key. Therefore I cant seem to sort by the value from within the WP_Query.
Has anyone successfully sorted by a custom attribute value in the latest version of WooCommerce?