New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WooCommerce Unable To Retrieve Terms #311

Open
Kysluss opened this Issue Oct 31, 2018 · 1 comment

Comments

Projects
None yet
1 participant
@Kysluss
Copy link

Kysluss commented Oct 31, 2018

Hi Project Nami team! I hope you are doing well

I am unable to retrieve attributes/terms created for items in WooCommerce. WP version is 4.9.8 and PN version 1.9.8. The error logged shows "incorrect syntax near the keyword as". It looks like PN is adding commas to the CAST statement added by the translations.php on line 586. I'm not 100% certain which function after that is applying the commas.

Below is the output from translate.log

2018-10-31 17:06:18 Error Code: 8120 -- Begin Query translation attempt:
SELECT t., tt., tr.object_id, tm.meta_value FROM wptx_terms AS t INNER JOIN wptx_term_taxonomy AS tt ON t.term_id = tt.term_id INNER JOIN wptx_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id LEFT JOIN wptx_termmeta AS tm ON (t.term_id = tm.term_id AND tm.meta_key = 'order') WHERE tt.taxonomy IN ('product_type', 'product_visibility', 'product_cat', 'product_tag', 'product_shipping_class') AND tr.object_id IN (16319, 16335, 16355, 16367, 16381, 16386) GROUP BY t.term_id, tr.object_id ORDER BY tm.meta_value+0 ASC, t.name ASC

2018-10-31 17:06:18 -- Translation result:
SELECT t., tt., tr.object_id, tm.meta_value FROM wptx_terms AS t INNER JOIN wptx_term_taxonomy AS tt ON t.term_id = tt.term_id INNER JOIN wptx_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id LEFT JOIN wptx_termmeta AS tm ON (t.term_id = tm.term_id AND tm.meta_key = 'order') WHERE tt.taxonomy IN ('product_type', 'product_visibility', 'product_cat', 'product_tag', 'product_shipping_class') AND tr.object_id IN (16319, 16335, 16355, 16367, 16381, 16386) GROUP BY t.term_id, tr.object_id ORDER BY CAST(tm.meta_value, as, numeric) ASC, t.name ASC

I'm not 100% familiar with how WooCommerce generates the queries, but any insight you can provide would be greatly appreciated.

@Kysluss

This comment has been minimized.

Copy link
Author

Kysluss commented Nov 14, 2018

After some digging, I found this is being created by the translate_sort_casting function in translations.php.

It is turning CAST(tm.meta_value as numeric) into CAST(tm.meta_value, as, numeric)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment