• Resolved warrior7089

    (@warrior7089)


    My goal is to export woocommerce products and their meta data to sql files using cli for subsequent import to another database used by wordpress installation.

    There’s exporter/importer using ui, but it’s manual.
    What is the best way to do it?
    My attempts are below using bash and mysql, mysqldump utilities:

    1) export products:

    mysqldump --login-path=login_path --single-transaction --no-create-info --skip-opt --databases db --tables posts --where "post_type='product'" > products.sql

    2) export products metadata

        var=$(mysql --login-path=login_path --single-transaction db -N -e "SELECT ID FROM posts where post_type = 'product')
        function join_by { local IFS="$1"; shift; echo "$*"; }!1
        ids=join_by , $var
        mysqldump --login-path=login_path --single-transaction --no-create-info --skip-opt --databases db --tables postmeta  --where "post_id in ($ids)" > meta.sql

    Is there a better way without using plugins, maybe with wp wc cli?

    • This topic was modified 6 years, 4 months ago by warrior7089.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Export woocommerce products with metadata using bash and mysqldump’ is closed to new replies.