Skip to content
This repository has been archived by the owner on Mar 17, 2022. It is now read-only.

When creating new variable translation, variations not visible until save #534

Closed
Jon007 opened this issue Feb 7, 2021 · 1 comment
Closed

Comments

@Jon007
Copy link
Contributor

Jon007 commented Feb 7, 2021

commented by @charalampospapadop on #430
"Seems to work fine the only thing is that when i translate the product first time before i publish it , it does not show the variable products, then i publish it but they still wont show, i had to do 1 extra update after the publish, then they showed up. Thanks again."

Root cause is that get_children() no longer works when in new translation because Polylang adds filter for language taxonomy in wp_term_relationships
even though a left join, because the where clause does not allow for no value, items with no taxonomy are filtered out, example WP_Query sql:

SELECT   wp_posts.* FROM wp_posts  
LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) WHERE 1=1  AND wp_posts.post_parent = 644  
 AND ( 
  wp_term_relationships.term_taxonomy_id IN (173)
) 
AND wp_posts.post_type = 'product_variation' AND ((wp_posts.post_status <> 'trash' AND wp_posts.post_status <> 'auto-draft')) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC 

on publishing the new translation, the hyyan synchronisation process re-synchronises so everything is resolved on refresh.

@Jon007
Copy link
Contributor Author

Jon007 commented Feb 7, 2021

root cause of this is that - with latest plugin versions - on save of new variable product, at the time the variation is created, the language of the parent is not set yet, thus although variation.php insert includes:
pll_set_post_language( $ID, pll_get_post_language( $this->to->get_id() ) );
at this stage the post language returned is false so language setting fails and child posts are not picked up by subsequent queries.

@Jon007 Jon007 closed this as completed in e0be02c Feb 7, 2021
@Jon007 Jon007 reopened this Feb 13, 2021
@Jon007 Jon007 closed this as completed in 2d139b2 Feb 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
1 participant