A Python tool for migrating products between Shopify stores, including variants, images, and collections. Built with async support for better performance.
- Full product data migration including variants, images, and metadata
- Preserves SKUs and intelligently updates existing products
- Handles image alt text and collection associations
- Asynchronous operations for improved performance
- Progress tracking and detailed logging
- Validation of store credentials and data integrity
- Python 3.12 or higher
- uv - Fast Python package installer and resolver
- Shopify Admin API access for both source and destination stores
- Source products must have valid and unique SKU values
- Clone the repository:
git clone https://github.com/yourusername/shopify-product-migration.git
cd shopify-product-migration
- Install uv if you haven't already:
curl -LsSf https://astral.sh/uv/install.sh | sh
- Copy
.env.sample
to.env
and configure your Shopify credentials:
cp .env.sample .env
- Install dependencies:
make install
- SKU Requirements:
- Every product in the source store MUST have a valid and unique SKU
- SKUs are used as the primary identifier to match products between stores
- Products without SKUs or with duplicate SKUs will be skipped during migration
- Ensure all your products have SKUs assigned before starting the migration
-
Create private apps for both source and destination stores:
- Go to your Shopify admin panel
- Navigate to Settings > Apps and sales channels > Develop apps
- Click "Create an app"
- Set up the required permissions:
- Products: Read and write
- Collections: Read and write
- Inventory: Read and write
-
Configure your
.env
file with the following credentials:
SOURCE_SHOPIFY_STORE=source-store.myshopify.com
DESTINATION_SHOPIFY_STORE=destination-store.myshopify.com
SOURCE_ADMIN_KEY=your_source_admin_api_access_token
DESTINATION_ADMIN_KEY=your_destination_admin_api_access_token
- Run tests to ensure everything is set up correctly:
make test
- Start the migration:
make migrate
You can also use the package programmatically in your Python code:
import asyncio
from shopify_migration import ShopifyClient, migrate_products
async def main():
# Initialize clients
source_client = ShopifyClient(
store_url="source-store.myshopify.com",
admin_key="your_source_admin_key"
)
dest_client = ShopifyClient(
store_url="destination-store.myshopify.com",
admin_key="your_destination_admin_key"
)
# Start migration
await migrate_products(source_client, dest_client)
if __name__ == "__main__":
asyncio.run(main())
- Validation: The tool first validates the credentials for both stores.
- Product Retrieval: Fetches all products from the source store.
- SKU Matching: For each product:
- Checks if a product with the same SKU exists in the destination store
- Updates existing products or creates new ones as needed
- Collection Migration: After products are migrated:
- Retrieves collection associations from the source store
- Creates missing collections in the destination store
- Associates products with their collections
- The tool includes comprehensive error handling and logging
- Failed operations are logged with detailed error messages
- Progress is tracked and displayed in real-time
- The migration can be safely interrupted and resumed
make test
make clean
Key dependencies used in this project:
- httpx - Async HTTP client
- python-dotenv - Environment variable management
- rich - Terminal formatting and progress display
- Shopify Admin API Reference
- Shopify Admin API: Products
- Shopify Admin API: Collections
- uv Documentation
- httpx Documentation
- rich Documentation
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
If you encounter any issues or have questions:
- Check the issue tracker
- Create a new issue with a detailed description of your problem