Title: Compatible sync translation with wp cli
Last modified: August 12, 2020

---

# Compatible sync translation with wp cli

 *  [Mostafa Soufi](https://wordpress.org/support/users/mostafas1990/)
 * (@mostafas1990)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/compatible-sync-translation-with-wp-cli/)
 * Hey,
 * It seems the sync translation doesn’t work while you are updating a product through
   wp cli, for support it, please make below changes:
 * **1. classes/class-woocommerce-wpml.php L199**
 *     ```
       if ( is_admin() || wpml_is_rest_request() ) {
   
       }
       ```
   
 * Should changed to:
 *     ```
       if (is_admin() || wpml_is_rest_request() || defined('WP_CLI')) {
   
       }
       ```
   
 * **2. Add a new method in class** `woocommerce_wpml`
 *     ```
       public function get_sync_object()
       {
           return $this->sync_product_data;
       }
       ```
   
 * **3. inc/translation-editor/class-wcml-synchronize-product-data.php L95**
 *     ```
       $trashing   = isset( $_GET['action'] ) && 'trash' === $_GET['action'];
       if (
       	$post_type !== 'product' ||
       	empty( $original_product_id ) ||
       	isset( $_POST['autosave'] ) ||
       	( $pagenow !== 'post.php' && $pagenow !== 'post-new.php' && $pagenow !== 'admin.php' && ! $ajax_call && ! $api_call ) ||
       	$trashing ||
       	$auto_draft
       ) {
       	return;
       }
       ```
   
 * Should changed to:
 *     ```
       $trashing   = isset( $_GET['action'] ) && 'trash' === $_GET['action'];
       if (
               !defined('WP_CLI') and
       	$post_type !== 'product' ||
       	empty( $original_product_id ) ||
       	isset( $_POST['autosave'] ) ||
       	( $pagenow !== 'post.php' && $pagenow !== 'post-new.php' && $pagenow !== 'admin.php' && ! $ajax_call && ! $api_call ) ||
       	$trashing ||
       	$auto_draft
       ) {
       	return;
       }
       ```
   
 * If you have a git repository for your plugin, then let me know, I’ll send a pull
   request.
 * Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [sergey.r](https://wordpress.org/support/users/sergeyr-1/)
 * (@sergeyr-1)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/compatible-sync-translation-with-wp-cli/#post-13248008)
 * Hello Mostafa,
    Thanks for your contribution!
 * I’ll create a ticket in our queue to review and include your changes ( we don’t
   have public repo yet ).
 * Can you please also provide commands which you’re using for updating product 
   so we can complete our testing with your case as well.
 * Regards,
 *  Thread Starter [Mostafa Soufi](https://wordpress.org/support/users/mostafas1990/)
 * (@mostafas1990)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/compatible-sync-translation-with-wp-cli/#post-13268674)
 * The command is:
 * `wp wc product update <id>`
 * [https://github.com/woocommerce/woocommerce/wiki/WC-CLI-Commands#wc-product-update-id](https://github.com/woocommerce/woocommerce/wiki/WC-CLI-Commands#wc-product-update-id)
 * Anyway with that method get_sync_object, we want to run the product sync manually
   something like:
 *     ```
       global $woocommerce_wpml;
       $post      = get_post($productId);
       $woocommerce_wpml->getSyncObject()->synchronize_products($post->ID, $post);
       ```
   
 *  [sergey.r](https://wordpress.org/support/users/sergeyr-1/)
 * (@sergeyr-1)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/compatible-sync-translation-with-wp-cli/#post-13279341)
 * Hello Mostafa,
    thanks for the details!
 * I’ll update you here when will know a version number where it will be included.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Compatible sync translation with wp cli’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce-multilingual/assets/icon-256x256.png?rev=2937122)
 * [WPML Multilingual & Multicurrency for WooCommerce](https://wordpress.org/plugins/woocommerce-multilingual/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce-multilingual/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce-multilingual/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce-multilingual/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce-multilingual/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce-multilingual/reviews/)

## Tags

 * [wpcli](https://wordpress.org/support/topic-tag/wpcli/)

 * 3 replies
 * 2 participants
 * Last reply from: [sergey.r](https://wordpress.org/support/users/sergeyr-1/)
 * Last activity: [5 years, 9 months ago](https://wordpress.org/support/topic/compatible-sync-translation-with-wp-cli/#post-13279341)
 * Status: not resolved