This module is installed on your SOURCE OpenMage/Magento 1 system to track entity changes for incremental sync.
- Creates the
datasync_change_trackertable - Uses Magento event observers to track entity changes
- Logs create/update/delete actions for all syncable entities
- Provides upsert pattern to handle rapid successive changes
- Includes weekly cron cleanup of old synced records
| Entity | Events |
|---|---|
| Customer | Save, Delete, Address changes |
| Order | Save |
| Invoice | Save |
| Shipment | Save |
| Credit Memo | Save |
| Order Comments | Save |
| Newsletter Subscriber | Save |
| Product | Save, Delete |
| Category | Save, Delete |
| Stock | Save |
Copy the module files to your OpenMage/Magento 1 installation:
# Copy module declaration
cp app/etc/modules/Maho_DataSyncTracker.xml /path/to/magento/app/etc/modules/
# Copy module code
cp -r app/code/community/Maho /path/to/magento/app/code/community/
# Clear cache
rm -rf /path/to/magento/var/cache/*modman clone https://github.com/mageaustralia/maho-datasync
modman deploy maho-datasyncAfter installation, the module will automatically:
- Create the
datasync_change_trackertable on first page load - Start tracking changes to all supported entities
The module creates:
CREATE TABLE datasync_change_tracker (
tracker_id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
entity_type VARCHAR(50) NOT NULL,
entity_id INT UNSIGNED NOT NULL,
action VARCHAR(10) NOT NULL DEFAULT 'update',
created_at DATETIME NOT NULL,
synced_at DATETIME DEFAULT NULL,
sync_completed SMALLINT UNSIGNED NOT NULL DEFAULT 0,
UNIQUE INDEX (entity_type, entity_id, sync_completed),
INDEX (sync_completed, entity_type),
INDEX (entity_type, entity_id),
INDEX (created_at)
);- When an entity is saved/deleted, an observer fires
- The observer inserts a record into
datasync_change_tracker - Uses
ON DUPLICATE KEY UPDATEto avoid duplicates for pending syncs - The
sync_completed=0records are pending sync - After sync, DataSync marks records with
sync_completed=1 - Weekly cron cleans up synced records older than 30 days
The DataSync destination needs these permissions on the source database:
-- Read access for syncing
GRANT SELECT ON your_database.* TO 'datasync_user'@'%';
-- Write access to mark records as synced
GRANT UPDATE, DELETE ON your_database.datasync_change_tracker TO 'datasync_user'@'%';-- Count pending changes by entity type
SELECT entity_type, COUNT(*) as pending
FROM datasync_change_tracker
WHERE sync_completed = 0
GROUP BY entity_type;
-- View recent pending changes
SELECT * FROM datasync_change_tracker
WHERE sync_completed = 0
ORDER BY created_at DESC
LIMIT 20;- Clear cache:
rm -rf var/cache/* - Check module is enabled: Admin > System > Configuration > Advanced > Disable Modules Output
- Check logs:
var/log/system.log
- Verify table exists:
SHOW TABLES LIKE 'datasync_change_tracker' - Check events are firing (add logging to Observer)
- Verify module is loading: check
app/etc/modules/Maho_DataSyncTracker.xml
Grant UPDATE/DELETE permissions on the tracker table to your DataSync database user.