• Resolved nikoweb

    (@nikoweb)


    Good evening
    I want to migrate all my WooCommerce products but have these products keep the same ID when I import them into my new store. So I did a migration, but the IDs are different. And that’s a big problem for me because in my blog posts I add Shortcode with product IDs and suddenly it doesn’t work anymore.
    Can you help me please ?
    Cordially

Viewing 1 replies (of 1 total)
  • Plugin Author WP All Import

    (@wpallimport)

    Hey @nikoweb,

    Unfortunately, there’s no guaranteed way to maintain product IDs when migrating products from 1 site to another, unless you do a complete database migration.

    That said, you can *attempt* to keep the same IDs with custom code and our pmxi_article_data hook: https://www.wpallimport.com/documentation/advanced/action-reference/#pmxi_article_data. The idea would be to set the “import_id” argument to the product ID from your file. For example, if your import file has an element named {id[1]} with the old IDs, you’d need to do this:

    function my_pmxi_article_data( $articleData, $import, $post_to_update, $current_xml_node ) {
        $xml_data = json_decode( json_encode( (array) $current_xml_node ), 1 );
        $articleData['import_id'] = $xml_data['id'];
        return $articleData;
    }
    add_filter('pmxi_article_data', 'my_pmxi_article_data', 10, 4);

    Again, keep in mind that this only attempts to keep the IDs – if something already exists on the new site with an ID you attempt to use, it won’t work.

Viewing 1 replies (of 1 total)

The topic ‘Keep the same product IDs with the migration’ is closed to new replies.