Magento 2 Google Shopping Merchant API Sync Explained
This guide explains how the Google Shopping API extension synchronizes your Magento products with Google Merchant Center in real-time.
XML Feed vs. API Sync
XML Feed (Google Shopping - Feed module)
- Magento generates an XML file with all product data
- The feed is delivered to Google via scheduled fetch (URL) or SFTP upload
- Batch-based: The entire catalog is sent each time
Ideal for: Stores with stable pricing and inventory that update on a predictable schedule (daily, hourly). Simple setup, reliable, and works great for most merchants.
API Sync (This add-on module)
- Product changes in Magento automatically trigger a sync
- Updates are sent directly to Google via their Merchant API
- Event-driven: Only changed products are synced
Ideal for: Stores with frequent price changes, dynamic inventory, or real-time stock from ERP/PIM systems. Keeps Google in sync without waiting for the next scheduled feed.
Using Both Together
This module is an add-on to the Feed module, not a replacement. Many stores benefit from using both:
- XML Feed: Ensures Google always has a complete, up-to-date baseline of all products
- API Sync: Pushes critical changes (price, stock) to Google immediately
This combination gives you the reliability of scheduled feeds plus the speed of real-time updates.
The Sync Process
Overview
- Product saved in Magento - You update a product in admin or via import
- Flagged for sync - The indexer marks the product as "needs update"
- Added to queue - A cron job picks up flagged products and adds them to the queue
- Synced to Google - The queue consumer sends the data to Google Merchant API
- Visible in Google Shopping - Changes appear in Google within minutes
Step 1: Change Detection
When you save a product in Magento (or stock updates via import), the extension automatically flags it for synchronization. This happens via Magento's indexer system - the same technology that updates your category pages and search results.
What triggers a sync:
- Product save (admin or API)
- Stock quantity change
- Price update
- Any attribute change that affects the feed
What doesn't trigger a sync:
- Products not included in your feed (filtered out by category, attribute, etc.)
- Disabled products
- Out-of-stock products (if configured to exclude)
Step 2: Queue Processing
The extension doesn't sync immediately when you save a product. Instead, it uses Magento's message queue system:
- Cron job runs every few minutes - Picks up flagged products
- Products added to queue - Grouped in batches for efficiency
- Queue consumer processes - Sends data to Google
Why a queue?
- Prevents timeout issues during bulk imports
- Handles rate limits gracefully
- Allows retries on failures
- Doesn't slow down your admin panel
Step 3: Data Comparison
Before sending data to Google, the extension compares your current product data with what was previously synced:
- Fetches fresh product data from Magento
- Calculates a "fingerprint" (hash) of the data
- Compares with the stored fingerprint
- Only syncs if something actually changed
Why this matters:
- Saves API quota - no unnecessary calls to Google
- Faster processing - skips unchanged products
- Accurate tracking - you know exactly what's synced
Step 4: Google API Call
When a product needs syncing, the extension:
- Transforms Magento data to Google's format
- Sends an update request to the Merchant API
- Records the response (success or error)
- Updates the product status in the grid
Sync Types
Full Product Sync
Updates all product attributes: title, description, price, images, shipping, etc.
Used when:
- Product is first added
- Any non-inventory attribute changes
- Manual sync from admin grid
Inventory-Only Sync
Updates only price and availability - faster and with higher API limits.
Used when:
- Only price changes
- Only stock quantity changes
- Scheduled inventory refresh
Product Statuses
In the admin grid (Marketing > Google Shopping API > Products), each product shows a status:
| Status | Meaning |
|---|---|
| Pending | New product, never synced |
| Queued | In queue, waiting to be processed |
| Synced | Successfully synced to Google |
| Error | Sync failed - check error message |
| Pending Delete | Will be removed from Google |
Timing
When do changes appear in Google?
Under normal conditions:
- Indexer flags product: Instant (on save)
- Cron picks up: Within 5 minutes
- Queue processes: Within 1-2 minutes
- Google reflects change: Within 5-30 minutes
Total: Typically under 15 minutes
What can slow things down?
- Large queue backlog (bulk imports)
- Google API rate limits
- Cron not running
- Queue consumers not running
Relationship with Feed Module
This module works alongside the Google Shopping Feed module, not as a replacement:
| Feature | Feed Module | API Module |
|---|---|---|
| Data source | Uses Feed module's product data | Uses Feed module's product data |
| Attribute mapping | Configured in Feed module | Inherited from Feed module |
| Product filters | Configured in Feed module | Inherited from Feed module |
| Delivery method | XML file for Google to fetch | Direct API calls |
| Update speed | Depends on fetch schedule | Near real-time |
Important: Both modules use the same product data configuration. If a product is excluded from your feed (via filters), it won't be synced via API either.
For a detailed guide on using both modules together, including how Offer IDs work and data source configuration, see Using Feed and API Together.
Configuration Impact
What's configured in Feed module (inherited)
- Attribute mapping (which Magento attributes map to Google fields)
- Product filters (which products to include/exclude)
- Category mapping
- Static values (brand, condition, etc.)
What's configured in API module
- Google Cloud credentials (Service Account)
- Merchant ID and Data Source
- Sync intervals and batch sizes
- Error retry settings
Error Handling
Automatic Retries
When a sync fails, the extension:
- Logs the error with details
- Keeps the product in "Error" status
- Retries after a configurable interval (default: 4 hours)
Common Errors
| Error | Cause | Solution |
|---|---|---|
Invalid price |
Price format issue | Check price attribute mapping |
Missing required field |
Required Google field empty | Check attribute mapping for title, description, etc. |
Image not accessible |
Google can't fetch image | Ensure images are publicly accessible |
Product not found |
Product doesn't exist in data source | Verify data source configuration |
Manual Intervention
From the admin grid, you can:
- View error details - Click the status to see the full error
- Retry single product - Use the "Sync" action
- Retry multiple products - Select products and use mass action
Monitoring
Admin Grid
Marketing > Google Shopping API > Products
Shows all products with their sync status, last sync time, and any errors.
CLI Commands
# Check overall sync status
bin/magento googleshopping:api:status --store=1
# Manually sync specific products
bin/magento googleshopping:api:sync --store=1 --product-ids=1,2,3
# Test connection
bin/magento googleshopping:api:test-connection --store=1
Logs
Debug logging (when enabled) writes to:
var/log/googleshopping_api.log
Best Practices
Initial Setup
- Configure the Feed module first (attribute mapping, filters)
- Set up API module credentials
- Test connection
- Use "Initialize Products" to populate the sync table
- Monitor first batch for errors
Ongoing Operations
- Keep cron running reliably
- Monitor the Products grid for errors
- Check Google Merchant Center for disapprovals
- Review logs periodically
Large Catalogs
For stores with 10,000+ products:
- Increase batch size (up to 1000)
- Ensure queue consumers are running
- Consider dedicated cron for queue processing
- Initial sync may take several hours
Troubleshooting
Products not syncing
- Check if cron is running:
bin/magento cron:run - Check if product is in feed: Review Feed module preview
- Check product status in grid: Look for errors
- Check queue:
bin/magento queue:consumers:list
Changes not appearing in Google
- Verify product shows "Synced" status
- Check last sync time in grid
- Wait 15-30 minutes for Google to process
- Check Merchant Center for product disapprovals
High error rate
- Review error messages in grid
- Check attribute mapping in Feed module
- Verify all required fields are mapped
- Test with a single product first
Further Reading
- Service Account Setup - Configure Google Cloud credentials
- Google Merchant Center Help - Official Google documentation
- Merchant API Reference - Technical API details