
Magento's database structure is rather arcane, but the API provides a clean way of retrieving order data. So, I made this little tool to pull Magento's orders from the API and then populate these orders in a second MySQL database. The orders are exported to two tables : mage (the order data, including customer shipping and billing information), and mage_items (which includes info on the items purchased). The tables are linked by the increment_id (which is also the order #), so it makes for a very readable database. This tool was designed for reporting, but could likely be useful for other applications... If anyone has any suggestions or improvements definitely send 'em my way!
Installation
- Create a Magento API username and key (done within the Magento back-end)
- Untar to a protected directory on your webserver ("tar -xvf magesync_v1.00a.tar")
- Edit /etc/cfg.php and define your absolute path, database host, database name, database username, database password, Magento API URL, Magento API username, and Magento API key
- Setup a CRON job and set to run as desired (ex, "cd /path/to/magesync; php -q cron.php")
- Watch and be amazed as Magento's database is demystified!
Download MageSYNC v1.01
Update Log
01/06/2010 - Removed removeMagicQuotes and unregisterGlobals functions since they appeared to be causing problems on some systems (and were also superfluous)












#1 by Izzy at January 4th, 2010
| Quote
Hi. Great just what I was looking for. When I tried to get it to run I got the following error: Warning: Invalid argument supplied for foreach() in /home/pqpharm/public_html/magesync/core/lib/factory.php on line 41
Can you please help.
Thanks
#2 by admin at January 6th, 2010
| Quote
hey Izzy, give it a shot now and lemme know if it works for you..
#3 by vektor at March 4th, 2010
| Quote
Hi there,
I’m a bit of a newbie and am having difficulties with your script.
I’ve installed as per instructions but am getting this on the email.
[ Connecting to Target Database ]
[ Checking Tables ]
[ Connecting to Magento API ]
[ Retrieving Order List ]
Nothing to see here
The tables are there in mysql and this is my crontab line.
*/1 * * * * /usr/bin/php -q /var/www/xxx.co.uk/subdomains/dev/magesync/cron.php
Any help would be greatly appreciated.
Pete