JPJULIAO WC Product Migration
A powerful tool to migrate products from one WooCommerce store to another, ensuring a seamless transition with minimal downtime.
by Juan Pablo Juliao · github.com/jpjuliao/jpjuliao-wc-product-migration · website
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/jpjuliao/jpjuliao-wc-product-migration/archive/refs/heads/main.zipReadme
WC Product Migration
A WordPress/WooCommerce plugin for bulk importing products with variations from JSON files.
Features
- Admin Upload Interface: User-friendly admin page under WooCommerce menu
- JSON Import: Upload JSON files containing product data
- Product Variations: Automatically creates variable products with flavor-based variations
- Multi-Taxonomy Support: Handles flavors, tags, brands, and categories
- Term Management: Auto-creates missing taxonomy terms
- Stock Management: Flexible stock control per product with
manage_stockoption - Product Export: Export products to JSON format for data portability
- Progress Tracking: Real-time import progress with detailed logs
- OOP Architecture: Clean, modular code with single-responsibility principle
- Error Resilience: Gracefully handles errors without stopping entire import
Installation
- Place the
jpjuliao-wc-product-migrationfolder in/wp-content/plugins/ - Activate the plugin from WordPress admin
- Navigate to WooCommerce → Product Importer
- Upload your JSON file
JSON Format
[
{
"title": "DOZO BUBBLE HASH",
"flavor": "American Pie, Berry Zurbert, Emperors Glue",
"tags": "THCP, Hash, Premium",
"brand": "DOZO",
"price": 2999,
"description": "Full description text...",
"short_description": "Short version...",
"category": "Concentrates, Extracts",
"manage_stock": true
}
]
Field Descriptions
title(string): Product nameflavor(string): Comma-separated flavor values - creates variations for eachtags(string): Comma-separated product tagsbrand(string): Product brandprice(integer): Price in cents (2999 = $29.99)description(string): Full product descriptionshort_description(string): Brief descriptioncategory(string): Comma-separated product categoriesmanage_stock(boolean, optional): Enable/disable stock management. Defaults totrueif not provided
Taxonomies
- pa_flavor: Product attribute for variations
- product_tag: Product tags
- product_brand: Product brands
- product_cat: Product categories
All taxonomy terms are automatically created if they don't exist.
Plugin Structure
jpjuliao-wc-product-migration/
├── jpjuliao-wc-product-migration.php # Main plugin file
├── includes/
│ ├── class-plugin.php # Main orchestrator (singleton)
│ ├── utilities/
│ │ ├── class-validator.php # JSON validation
│ │ └── class-logger.php # Logging system
│ ├── admin/
│ │ ├── class-admin-page.php # Admin interface
│ │ └── class-upload-handler.php # File upload handler
│ └── import/
│ ├── class-product-importer.php # Import orchestrator
│ ├── class-variation-manager.php # Product/variation creation
│ └── class-term-manager.php # Taxonomy term management
├── implementation-plan.md # Technical documentation
└── README.md # This file
Class Architecture
Core Classes
Plugin (Singleton - JPJULIAO\WC_Product_Migration\Plugin)
- Main entry point and dependency injector
- Manages plugin initialization
- Verifies WooCommerce is active
Validator (JPJULIAO\WC_Product_Migration\Validator)
- Validates JSON structure
- Validates individual product data including manage_stock flag
- Returns detailed error messages
Logger (JPJULIAO\WC_Product_Migration\Logger)
- Tracks import progress
- Logs term operations
- Stores logs in WordPress transients
- Supports multiple log levels (info, warning, error)
Term_Manager (JPJULIAO\WC_Product_Migration\Term_Manager)
- Processes comma-separated taxonomy terms
- Handles term creation and validation
- Deduplicates and trims whitespace
- Supports all four taxonomies
Variation_Manager (JPJULIAO\WC_Product_Migration\Variation_Manager)
- Creates variable products with stock control
- Assigns taxonomies to products
- Creates product variations based on flavors
- Registers product attributes
- Handles stock management settings
Product_Importer (JPJULIAO\WC_Product_Migration\Product_Importer)
- Orchestrates the entire import process
- Validates products before creation
- Handles import errors gracefully
- Returns import summary
Product_Exporter (JPJULIAO\WC_Product_Migration\Product_Exporter)
- Exports all products to JSON format
- Includes all product fields and stock settings
- Provides downloadable JSON files
Admin_Page (JPJULIAO\WC_Product_Migration\Admin_Page)
- Renders admin interface
- Handles menu registration
- Displays import logs and results
Upload_Handler (JPJULIAO\WC_Product_Migration\Upload_Handler)
- Handles AJAX file uploads
- Validates file type and content
- Triggers import process
- Provides error feedback
Usage
- Click "Product Importer" under WooCommerce menu
- Download template JSON using "Download Template" button or create your own
- Select your JSON file and click "Import Products"
- Monitor progress in the admin page
- Check logs for any errors or warnings
Features
Automatic Term Creation
- If a category, brand, or tag doesn't exist, it's automatically created
- Terms are trimmed of whitespace and deduplicated
Flavor Variations
- Each flavor value creates a separate product variation
- Variations inherit pricing from parent product
- Stock is managed per-variation
Stock Management
- Control whether products use stock management via
manage_stockfield - Set to
trueto enable stock tracking (default) - Set to
falseto disable stock management - Stock quantities default to 0 for new products
Product Export
- Export all published products to JSON format
- Includes all product data and current stock settings
- Useful for data backup and migration to other stores
Error Handling
- Invalid products are logged but import continues
- Missing terms are created automatically
- All operations are logged for audit trail
Progress Tracking
- Real-time progress updates
- Detailed logs with timestamps
- Color-coded log levels (info, warning, error)
Dependencies
- WordPress 5.0+
- WooCommerce 3.0+
- PHP 7.0+
Requirements Met
✅ OOP architecture with single-responsibility principle ✅ PHP namespaces for proper code organization ✅ DRY code patterns (reusable Term_Manager for all taxonomies) ✅ Dependency injection throughout ✅ Admin upload interface with progress tracking ✅ Multi-taxonomy support ✅ Automatic term validation and creation ✅ Comprehensive logging ✅ Error resilience ✅ Product variations based on flavor attributes ✅ Stock management control per product ✅ Product export to JSON format
Next Steps (Optional Enhancements)
- Add support for product images
- Add batch processing for large imports
- Add CSV import format
- Add duplicate prevention
- Add product update preview before import
- Add attribute support beyond flavors
- Add bulk product deletion feature