Using XML Feed and API Together in Magento 2 (Google Shopping)
This guide explains how to use the XML Feed module and the API module together for optimal product synchronization with Google Merchant Center.
Why Use Both?
The XML Feed and API modules serve different purposes and work best when combined:
| Module | Strength | Use Case |
|---|---|---|
| XML Feed | Complete catalog export | Scheduled baseline sync (daily/hourly) |
| API Module | Real-time updates | Immediate price/stock changes |
Together they provide:
- A reliable baseline that ensures all products are in Google
- Fast updates for time-sensitive changes (flash sales, stock depletion)
- Redundancy if one method temporarily fails
How Google Matches Products
The Offer ID
The Offer ID is the unique identifier that links your Magento products to Google Merchant Center listings. It's the key that allows both Feed and API to update the same product.
Format in Magento: Typically your product SKU or entity ID
Example: ABC-12345 or 24-MB01
When you send product data to Google (via Feed or API), the Offer ID tells Google: "This is product ABC-12345, update its data."
How Matching Works
Example: Product with SKU "ABC-12345"
- XML Feed sends product data with
offerId: ABC-12345 - API Module sends product data with
offerId: ABC-12345 - Google sees the same Offer ID and updates the same product
Both methods update the same product in Google because they use the same Offer ID.
Important: The Offer ID configured in the Feed module must match the Offer ID used by the API module. By default, both use the same source (configured in Feed module settings), so this happens automatically.
Data Sources in Merchant Center
Google Merchant Center uses Data Sources to organize incoming product data. Feed and API use different types:
File Data Source (XML Feed)
- Type: Scheduled fetch or SFTP upload
- Contains: Complete product catalog
- Updates: On your configured schedule
Merchant API Data Source (API Module)
- Type: Merchant API
- Contains: Individual product updates
- Updates: Real-time when products change
How Multiple Data Sources Work
Google can combine data from multiple sources for the same product:
- Primary source provides the base product data
- Supplemental sources can add or override specific fields
When using Feed + API together, you have two options:
Option A: Separate Data Sources (Recommended)
- Feed uploads to File data source
- API updates to Merchant API data source
- Google merges both, with most recent data taking precedence
Option B: API as Primary
- API module handles all product data
- Feed serves as backup/verification only
Recommended Setup
For Most Merchants
-
Keep your existing Feed setup (SFTP or scheduled fetch)
- Runs daily or hourly
- Ensures complete catalog is always in Google
-
Add the API module for real-time updates
- Pushes changes immediately when products are saved
- Handles price and stock updates between feed runs
Configuration Checklist
-
Feed Module
- Attribute mapping configured
- Offer ID field set (usually SKU)
- SFTP or scheduled fetch active
-
API Module
- Same store view as Feed
- Merchant API data source created
- Auto Sync enabled
-
Verify Offer ID Match
- The "id" field in Feed module settings
- Should match what API module sends as
offerId - Check a synced product in both to confirm
Offer ID Configuration
Where It's Set
The Offer ID is configured in the Feed module under attribute mapping:
Stores > Configuration > Magmodules > Google Shopping - Feed > Attribute Mapping
Look for the id field mapping. Common options:
- SKU (recommended) - Unique, human-readable
- Entity ID - Magento's internal ID (numeric)
- Custom attribute - If you have a dedicated identifier
Best Practices
- Use SKU if your SKUs are unique and stable
- Never change the Offer ID of existing products - Google treats it as a new product
- Keep it consistent across all stores/feeds for the same product
- Alphanumeric characters only - avoid special characters
What Happens If Offer IDs Don't Match?
If Feed sends offerId: SKU123 and API sends offerId: 456:
- Google sees these as two different products
- You'll have duplicates in Merchant Center
- Changes via API won't affect the Feed product
Timing and Priority
Which Update "Wins"?
When both Feed and API send data for the same product, Google uses the most recent data for each field.
Example scenario:
- 08:00 - Feed runs, sends price: €50
- 10:00 - You change price to €45 in Magento
- 10:01 - API sends price: €45
- Google now shows: €45 (most recent)
Recommended Timing
| Update Type | Method | Why |
|---|---|---|
| Complete catalog refresh | Feed (daily) | Ensures nothing is missed |
| Price changes | API (immediate) | Time-sensitive for ads |
| Stock changes | API (immediate) | Prevents selling out-of-stock |
| New products | Feed or API | Either works |
| Product removal | Both | API for speed, Feed confirms |
Handling Conflicts
Price Discrepancies
If Feed and API show different prices:
- Check timestamp of last Feed run
- Check API sync status for the product
- The most recent update should be in Google
Missing Products
If a product is in Feed but not syncing via API:
- Check if product passes Feed module filters
- Check API module product grid for errors
- Verify product was initialized in API module
Duplicate Products
If you see duplicates in Merchant Center:
- Check Offer ID in Feed export
- Check Offer ID in API sync log
- Ensure both use the same identifier
Monitoring
Feed Module
- Check generated XML for correct Offer IDs
- Monitor SFTP upload logs
- Review Merchant Center processing reports
API Module
- Check Products grid for sync status
- Verify Offer ID matches Feed
- Monitor error rates
Merchant Center
- Products > Diagnostics for issues
- Check "Data sources" for last update times
- Verify product count matches expectations
FAQ
Do I need both data sources?
Yes, if using both modules. Each module needs its own data source type in Merchant Center.
Will I get charged twice for the same product?
No. Google Shopping charges are based on clicks, not on how many times you upload product data.
Can I disable the Feed and use only API?
Technically yes, but not recommended. The Feed serves as a safety net ensuring all products remain in Google even if API sync has issues.
What if I only want API for price/stock?
The API module supports inventory-only sync. Full product data comes from Feed, real-time price/stock from API.
How do I verify products are matched correctly?
- Note a product's SKU in Magento
- Find it in Feed XML export - check the
<g:id>value - Find it in API sync log - check the
offerId - Find it in Merchant Center - check the Offer ID
- All three should match