Cấu trúc dịch WPML và 1 số câu query hay dùng
Cấu trúc bản dịch WPML
Lấy ra tất cả category
SELECT t.term_id AS id,
t.name AS post_title,
t.slug AS post_url
FROM wp_terms t
LEFT JOIN wp_term_taxonomy tt
ON t.term_id = tt.term_id
LEFT JOIN wp_icl_translations
ON t.term_id = wp_icl_translations.element_id
WHERE tt.taxonomy = 'product_cat' and wp_icl_translations.language_code LIKE 'vi' AND wp_icl_translations.element_type LIKE 'tax_product_cat'
ORDER BY name
Lấy sản phẩm có sku
SELECT * FROM
(
SELECT b.ID, b.post_title, b.post_status, b.guid, a.meta_value, c.language_code
FROM wp_postmeta a
right JOIN
wp_posts b ON a.post_id = b.ID
LEFT JOIN wp_icl_translations c ON b.ID = c.element_id
WHERE a.meta_key LIkE '_sku' AND b.post_type like 'product' AND b.post_status LIKE 'publish' AND c.language_code LIKE 'vi' ORDER BY b.ID
) a
LEFT JOIN
(
SELECT b.ID as id_en, b.post_title as title_en, b.guid as guid_en, a.meta_value as sku_en
FROM wp_postmeta a
right JOIN
wp_posts b ON a.post_id = b.ID
LEFT JOIN wp_icl_translations c ON b.ID = c.element_id
WHERE a.meta_key LIkE '_sku' AND b.post_type like 'product' AND b.post_status LIKE 'publish' AND c.language_code LIKE 'en' ORDER BY b.ID
) b
ON a.meta_value = b.sku_en