hicare/wordpress-shopify-migrator

Laravel package to migrate WordPress blog posts and comments to Shopify articles and comments

Maintainers

Package info

gitlab.com/bhagyesh_binary/wordpress-shopify-migrator

Issues

pkg:composer/hicare/wordpress-shopify-migrator

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

dev-production 2026-03-25 14:55 UTC

This package is not auto-updated.

Last update: 2026-05-07 08:43:45 UTC


README

A comprehensive Laravel package to migrate WordPress blog posts with comments, featured images, categories, tags, and ACF fields to Shopify blog articles.

Features

Blog Posts - Migrate all WordPress blog posts to Shopify articles
Comments - Migrate approved comments with author information
Featured Images - Include featured images in articles
Tags & Categories - Migrate post tags and categories as Shopify article tags
Author Information - Preserve author names/emails
ACF Fields - Support for Advanced Custom Fields migration
Batch Processing - Efficiently handle large migrations
Progress Tracking - Real-time migration progress with detailed logging
Error Handling - Comprehensive error handling and logging
Resumable - Can resume interrupted migrations

Requirements

  • PHP 8.0 or higher
  • Laravel 9.0 or higher
  • MySQL/MariaDB (for WordPress database access)
  • Shopify account with API access

Installation

1. Install via Composer

composer require hicare/wordpress-shopify-migrator

2. Publish Configuration

php artisan vendor:publish --provider="HiCare\WordPressShopifyMigrator\WordPressShopifyMigratorServiceProvider" --tag="config"

This will create config/wordpress-shopify-migrator.php in your Laravel project.

3. Configure Environment Variables

Add these to your .env file:

# Shopify Configuration
SHOPIFY_STORE_DOMAIN=your-store.myshopify.com
SHOPIFY_ACCESS_TOKEN=your_access_token_here
SHOPIFY_API_VERSION=2024-01

# WordPress Database Configuration
WP_DB_CONNECTION=wordpress
WP_DB_HOST=localhost
WP_DB_PORT=3306
WP_DB_NAME=wordpress_database
WP_DB_USER=wordpress_user
WP_DB_PASSWORD=password
WP_DB_PREFIX=wp_

# Blog Configuration
SHOPIFY_BLOG_TITLE="News"
SHOPIFY_BLOG_HANDLE="news"
WP_BASE_URL=https://your-wordpress-site.com

# Migration Settings
MIGRATION_BATCH_SIZE=50

Getting Shopify Access Token

  1. Go to your Shopify Admin > Apps and integrations > Apps and sales channel settings
  2. Click "Develop apps" (or create a new app)
  3. Create a custom app and select necessary scopes:
    • write_blogs - Write to blog articles
    • read_blogs - Read blog articles
    • write_content - Write article comments
    • read_content - Read article content
  4. Generate admin API credentials and copy your Access Token

Configuration

Edit config/wordpress-shopify-migrator.php to customize:

return [
    // WordPress database connection
    'wordpress' => [
        'connection' => env('WP_DB_CONNECTION', 'wordpress'),
        'database' => env('WP_DB_NAME'),
        'host' => env('WP_DB_HOST', 'localhost'),
        // ... other DB settings
    ],

    // Shopify store configuration
    'shopify' => [
        'store_domain' => env('SHOPIFY_STORE_DOMAIN'),
        'access_token' => env('SHOPIFY_ACCESS_TOKEN'),
        'api_version' => env('SHOPIFY_API_VERSION', '2024-01'),
    ],

    // Which blog to migrate to
    'blog' => [
        'title' => env('SHOPIFY_BLOG_TITLE', 'News'),
        'handle' => env('SHOPIFY_BLOG_HANDLE', 'news'),
    ],

    // Migration behavior
    'migration' => [
        'batch_size' => 50,
        'include_comments' => true,
        'include_featured_image' => true,
        'include_tags' => true,
        'include_categories' => true,
        'include_acf_fields' => true,
        'author_source' => 'email', // or 'name'
        'skip_existing' => true,
    ],

    // Image handling
    'images' => [
        'download' => true,
        'upload_to_shopify' => true,
        'use_external_url' => false,
        'wordpress_base_url' => env('WP_BASE_URL'),
    ],

    'logging' => [
        'enabled' => true,
        'channel' => 'migrations',
        'log_failed_items' => true,
    ],
];

Usage

Basic Migration

Run the migration command:

php artisan wordpress:migrate-to-shopify

The command will:

  1. Validate your configuration
  2. Display migration settings
  3. Ask for confirmation
  4. Migrate posts and comments with progress tracking
  5. Display results summary

Command Options

# Dry run (don't make changes)
php artisan wordpress:migrate-to-shopify --dry-run

# Skip comments
php artisan wordpress:migrate-to-shopify --skip-comments

# Skip featured images
php artisan wordpress:migrate-to-shopify --skip-images

# Custom batch size
php artisan wordpress:migrate-to-shopify --batch-size=100

Programmatic Usage

use HiCare\WordPressShopifyMigrator\Services\Migrator;

// Inject the migrator
$migrator = app('wordpress-shopify-migrator');

// Run migration with callback
$stats = $migrator->migrate(function ($status, $post, $data = null) {
    if ($status === 'migrated') {
        echo "Migrated: {$post->post_title}\n";
    } elseif ($status === 'failed') {
        echo "Failed: {$post->post_title}\n";
    }
});

// Get statistics
$results = $migrator->getStats();
echo "Posts migrated: " . $results['posts_migrated'];

Advanced: Custom Data Fetcher

Extend the WordPress fetcher for custom fields:

use HiCare\WordPressShopifyMigrator\Services\WordPressDataFetcher;

class CustomWordPressFetcher extends WordPressDataFetcher
{
    public function getCustomField($postId, $fieldName)
    {
        // Custom logic here
    }
}

// Register in service provider
$this->app->bind(WordPressDataFetcher::class, CustomWordPressFetcher::class);

Migration Flow

┌─────────────────────────────┐
│  Validate Configuration      │
└────────────┬────────────────┘
             │
             ▼
┌─────────────────────────────┐
│  Create/Get Shopify Blog    │
└────────────┬────────────────┘
             │
             ▼
┌─────────────────────────────┐
│  Get WordPress Posts Count  │
└────────────┬────────────────┘
             │
             ▼
┌─────────────────────────────┐
│  Process Posts in Batches   │
├─────────────────────────────┤
│ • Format post content       │
│ • Download images           │
│ • Prepare metadata          │
│ • Create Shopify article    │
└────────────┬────────────────┘
             │
             ▼
┌─────────────────────────────┐
│  Migrate Comments (if enabled)
├─────────────────────────────┤
│ • Get approved comments     │
│ • Format comment data       │
│ • Post to Shopify           │
└────────────┬────────────────┘
             │
             ▼
┌─────────────────────────────┐
│  Report Results & Logging   │
└─────────────────────────────┘

Logging

The package logs to storage/logs/migrations.log by default. Enable/configure in config:

'logging' => [
    'enabled' => true,
    'channel' => 'migrations',
    'log_failed_items' => true,
]

Troubleshooting

"Failed to connect to Shopify API"

  • Verify SHOPIFY_STORE_DOMAIN and SHOPIFY_ACCESS_TOKEN in .env
  • Check API token has correct scopes
  • Ensure network connectivity to Shopify API

"WordPress database connection failed"

  • Verify database credentials in .env
  • Check WordPress database host/port
  • Ensure database user has necessary permissions

Posts not showing featured images

  • Set WP_BASE_URL to your WordPress domain
  • Verify featured images exist in WordPress
  • Check include_featured_image is enabled in config

Comments not migrating

  • Ensure include_comments is enabled in config
  • Check comments are marked as "approved" in WordPress
  • Verify Shopify blog has comments enabled

Slow migration with large number of posts

  • Reduce batch_size in config if memory issues occur
  • Increase batch_size to 100+ if safe for faster processing
  • Consider running during off-peak hours

What Gets Migrated

Post Content

  • ✅ Title
  • ✅ Body/Content
  • ✅ Featured Image
  • ✅ Published Date
  • ✅ Author Name/Email
  • ✅ Excerpt (as metafield)

Comments

  • ✅ Comment text
  • ✅ Author name & email
  • ✅ Published date
  • ✅ Nested replies (thread structure)

Metadata

  • ✅ Tags
  • ✅ Categories
  • ✅ ACF Fields (as custom metafields)

NOT Migrated

  • ❌ Post scheduling (publishes immediately)
  • ❌ Post revisions
  • ❌ Drafts (only publishes posts)
  • ❌ Unapproved comments
  • ❌ Comment spam

API Documentation

Migrator Service

// Main service
$migrator = app('wordpress-shopify-migrator');

// Run full migration
$stats = $migrator->migrate($callback);

// Get statistics
$stats = $migrator->getStats();

// Reset statistics
$migrator->resetStats();

WordPressDataFetcher

// Get posts with pagination
$posts = $fetcher->getPosts($limit, $offset);

// Get single post
$post = $fetcher->getPost($postId);

// Get post comments
$comments = $fetcher->getPostComments($postId);

// Get total post count
$count = $fetcher->getPostCount();

// Get featured image URL
$imageUrl = $fetcher->getFeaturedImage($postId);

// Get ACF fields
$acfData = $fetcher->getAcfFields($postId);

// Get post tags
$tags = $fetcher->getTags($postId);

// Get post categories
$categories = $fetcher->getCategories($postId);

ShopifyApiClient

// Get or create blog
$blogId = $client->getOrCreateBlog($handle, $title);

// Create/update article
$article = $client->createOrUpdateArticle($blogId, $articleData);

// Get article by handle
$article = $client->getArticleByHandle($blogId, $handle);

// Get all articles
$articles = $client->getArticles($blogId, $limit, $offset);

// Create comment
$comment = $client->createComment($blogId, $articleId, $commentData);

// Get article comments
$comments = $client->getArticleComments($blogId, $articleId);

// Test connection
$connected = $client->testConnection();

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a pull request

License

MIT License - see LICENSE file for details

Support

For issues, questions, or feature requests, please open an issue on GitHub.

Changelog

See CHANGELOG.md for release notes and version history.

Made with ❤️ by HiCare Team