Start a project

Init Variations after WP All Import

When you use automatic product imports via WP All import for example, you have to manually init variations every time. As this is quite annoying please add the following code into your functions.php:

 function after_xml_import( $import_id, $import ) {
    $admin = new WooCommerce_Single_Variations_Admin('plugin', '1.3.19');
    $admin->init();
$admin->update_variations(false, true);
$admin->reset_transients(false);
} add_action( 'pmxi_after_xml_import', 'after_xml_import', 10, 2 );

This will ensure all variations are reinitiated after import.

Questions & answers (6)

  1. EfthimiosSeptember 18, 2023

    I am getting the following error with this hook.

    AH01071: Got error ‘PHP message: PHP Fatal error: Uncaught TypeError: call_user_func_array(): Argument #1 ($callback) must be a valid callback, function “_update_posts_count_on_transition_post_status” not found or invalid function name

    Could you check it?

    Thank you.

  2. petros manisiotisJune 8, 2022

    Same here. Now we see duplicate products on category page.

  3. DanielJune 8, 2022

    Please submit a ticket on our website and we will take a look.

  4. ShoaibDecember 10, 2021

    One more thing is, now i can see the duplicate of the product with same name and sku, on categories pages.

  5. ShoaibDecember 8, 2021

    Currently When I am manually doing the INIT it is stuck at some point and not showing all the products variations on the front, what will be a quick fix for that? cant do the import again.

  6. DanielDecember 8, 2021

    Sometimes there may be some orphaned variations. At least all should show live. Check that.