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

  1. SELECT t.term_id AS id,
  2. t.name AS post_title,
  3. t.slug AS post_url
  4. FROM wp_terms t
  5. LEFT JOIN wp_term_taxonomy tt
  6. ON t.term_id = tt.term_id
  7. LEFT JOIN wp_icl_translations
  8. ON t.term_id = wp_icl_translations.element_id
  9. WHERE tt.taxonomy = 'product_cat' and wp_icl_translations.language_code LIKE 'vi' AND wp_icl_translations.element_type LIKE 'tax_product_cat'
  10. ORDER BY name

 

Lấy sản phẩm có sku

  1. SELECT * FROM
  2. (
  3. SELECT b.ID, b.post_title, b.post_status, b.guid, a.meta_value, c.language_code
  4. FROM wp_postmeta a
  5. right JOIN
  6. wp_posts b ON a.post_id = b.ID
  7. LEFT JOIN wp_icl_translations c ON b.ID = c.element_id
  8. 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
  9. ) a
  10. LEFT JOIN
  11. (
  12. SELECT b.ID as id_en, b.post_title as title_en, b.guid as guid_en, a.meta_value as sku_en
  13. FROM wp_postmeta a
  14. right JOIN
  15. wp_posts b ON a.post_id = b.ID
  16. LEFT JOIN wp_icl_translations c ON b.ID = c.element_id
  17. 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
  18. ) b
  19. ON a.meta_value = b.sku_en

 

 

Leave a Reply

You must be logged in to post a comment.