Skip Navigation

Open

Topic Tags: WCML

Overview of the issue

If you have products previously translated with the Classic Translation Editor (CTE) and then update your WPML settings to use ATE (for new translations only), editing those previously translated products will wrongly open them in ATE instead of CTE.

(This specifically affects Products and not other post types.)

Workaround

The problem arises because details of which editor was used are stored wrongly for products.

Part of the solution is to fix that, so that when translating products via CTE it correctly records the translation editor so it will open in the correct editor next time.

But we also have to fix all the existing data that record the wrong editor for products that were already edited with CTE.

Let’s tackle that second part first, for which we need to run this custom SQL query:

UPDATE wp_icl_translate_job AS job
JOIN (
    SELECT job.job_id
    FROM wp_icl_translate_job AS job
    LEFT JOIN wp_icl_translation_status AS status ON job.rid = status.rid
    LEFT JOIN wp_icl_translations AS translations ON status.translation_id = translations.translation_id
    WHERE translations.element_type = 'post_product'
) AS derived
ON job.job_id = derived.job_id
SET job.editor = 'wpml'
WHERE job.editor = 'wp';

If your database uses a different prefix than `wp_` for the tables then these will need adjusting (there are four `wp_icl_` mentions in the above).

You can run such a query using phpMyAdmin or via an Adminer plugin.

Then to ensure editor details are correctly stored going forwards, you need to add the following (via some code snippet plugin or to the theme’s functions.php file):

/**
 * WPMLSUPP-12927: Temporary fix to correctly record CTE editor for products
 */
add_filter( 'wpml_translation_editor_save_job_data', function( $data ){

	if ( $data['job_post_type'] == "post_product" ) {

		add_action( 'wpml_save_job_fields_from_post', function( $job_id ){

			wpml_tm_load_old_jobs_editor()->set( $job_id, 'wpml' );
		});
	}

	return $data;
});

Leave a Reply

Please stay on topic and be respectful to others. If you need help with issues not related to this post, use our Support Forum to start a chat or submit a ticket.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>