On this page
Migrating from Shopify to WooCommerce gives you complete ownership and flexibility over your online store. While many users rely on plugins to handle migrations, developers and technical store owners can take a more hands-on approach using the command line. By using WP-CLI (WordPress Command Line Interface), you can automate and customize the entire migration process efficiently — especially for large stores.
In this guide, we’ll walk you through how to migrate your Shopify store to WooCommerce using CLI, from prerequisites to troubleshooting.

Prerequisites (Local Setup, WP-CLI Installed)
Before you begin, make sure your environment is ready for a command-line-based migration:
- Local or Staging Environment: Set up WordPress + WooCommerce either locally (e.g., using LocalWP, MAMP, XAMPP) or on a staging server.
- WP-CLI Installed: Install WP-CLI on your server. WP-CLI allows you to interact with WordPress via command line commands.
You’ll also need:
- Basic knowledge of Linux/Unix commands.
- Access to your WordPress installation via SSH or terminal.
- Appropriate user permissions to run import commands.
👉 Tip: Always perform your migration on a staging copy of your WooCommerce site first before moving to production.
Export Shopify Data via API or CSV
The first step is to extract your Shopify data.
You have two options:
- CSV Export: Shopify’s built-in export tool lets you download products, customers, and orders as CSV files.
(Admin Panel → Products → Export) - API Export: For full data control, use the Shopify API to export resources (e.g., via Postman, curl, or a custom script).
The CSV method is faster for basic migrations. API export is better if you need custom metafields or app data.
👉 Reminder: If you plan to migrate variants, attributes, or metafields, make sure they’re included in your export.
Formatting Data for Import
WordPress and WooCommerce expect data in a specific format, especially if you are using the wp import or wp post create commands.
Key things to format correctly:
- Products must be imported as post type product.
- Variants should be imported as product variations with a parent product ID.
- Categories must match WooCommerce taxonomies (product_cat).
- Images must be available via public URLs or downloaded into the uploads folder.
If necessary, clean or transform your CSV using tools like:
- Microsoft Excel or Google Sheets.
- Linux command-line tools (awk, sed, csvkit).
- Python or Node.js scripts for large or complex datasets.
Using wp import Commands
Once your data is ready, it’s time to use WP-CLI commands to import it into WooCommerce.
Basic example for products:
wp post create --post_type=product --post_title="Example Product" --post_status=publish --meta_input='{"_regular_price":"29.99", "_sku":"SKU123"}'
For batch imports:
- Prepare an XML or WXR file compatible with WordPress import standards.
- Use:
wp import your-export-file.xml --authors=create
For CSVs, you can also pair WP-CLI with plugins like WP All Import CLI Add-on if you prefer direct CSV ingestion.
👉 Pro Tip: Automate repetitive imports by scripting loops with Bash or Python based on your CSV rows.
Custom Scripts for Complex Migrations
For advanced needs (variants, custom fields, SEO data), you’ll likely need custom scripts.
Some approaches:
- PHP Scripts: Write custom PHP CLI scripts to create products, assign categories, and add images.
- REST API: Use WordPress REST API with WP-CLI’s eval-file command to insert products programmatically.
- MySQL Direct Insert (Advanced): Insert data directly into the WordPress database tables (wp_posts, wp_postmeta, etc.) — requires thorough understanding to avoid corruption.
👉 Warning: Always back up your database before running custom scripts!
Automation Tips and Cron Jobs
Once your CLI migration process is tested, you can automate imports using cron jobs.
For example:
crontab -e
Add a scheduled task:
0 2 * * * cd /path/to/wordpress && wp import latest-products.xml --authors=create >> /var/log/wpcli-import.log 2>&1
This will run your import at 2 AM daily and log the output.
Benefits of automation:
- Keep Shopify and WooCommerce in sync during the transition.
- Reduce manual workload.
- Maintain inventory accuracy if the Shopify store is still active.
Troubleshooting CLI Import Errors
CLI imports can throw errors. Here’s how to handle common issues:
Problem | Solution |
“Missing attachment file” | Ensure image URLs are publicly accessible or pre-uploaded to the Media Library. |
“Invalid post type” | Double-check you’re setting post_type=product when creating products. |
Timeouts on large imports | Split data into smaller chunks or increase server PHP limits (max_execution_time, memory_limit). |
Broken variation relationships | Ensure parent_id and variation data are correctly mapped. |
👉 Pro Tip: Use –skip-delete and –skip-attachment flags carefully during troubleshooting to avoid accidental data loss.
Final Thoughts
Migrating from Shopify to WooCommerce via CLI offers maximum flexibility, speed, and customization, especially for developers and technical users. Although it requires more setup and scripting than plugin-based solutions, it gives you full control over every detail of the migration.
By carefully preparing your export files, writing clean import templates, and automating the process with cron jobs, you can ensure a smooth, scalable migration — without the heavy price tags of third-party services.
Ready to take charge of your migration? With WP-CLI and a bit of scripting, WooCommerce freedom is just a few commands away!
Need help with Migration?
If you need help with the migration, setup, or choosing the right platform for your business
📞 Contact us anytime:
🌐 https://webw.us/contact/
We offer expert WooCommerce and Shopify consulting and can guide you through the migration process from start to finish.