Cron Job for Updating QTY
Hello! My supplier gives my access to a excel file in ftp there they created for me. It has the model number I use and the qty and some more info. They also give me a link to download a tabbed txt file that has the same information. How hard would it be to setup a cron job to update my quantity daily from their info? Where do I even begin? They told me its pretty simple to do, but didnt offer any help :huh:
Re: Cron Job for Updating QTY
Quote:
How hard would it be to setup a cron job to update my quantity daily from their info
Would not be an automated cron
Get the 3rd party module - -easy populate
Review the wiki article on using it
I recommend that you practice on a second install of your cart versus the live site until you have mastered it
Re: Cron Job for Updating QTY
This should be fairly straight forward if you want to automate it.
Lookup the man pages for crontab and have it launch a php script. The script can use cURL to download the txt version and then use built in functions to parse the file if you can get a CSV version. Most places use CSV these days as opposed to TSV but if it is TSV a quick google searched turned up a ready to go class to parse it:
http://enarion.net/programming/php/csv-import/
I assume you have a spot in your products table where you are storing their part #? If so simply run an update query against the part # from the file against the part # in your DB (and their vendor # if you have more than one so you don't get product ID collisions).
As a recommendation you may want to ask them what they do with products once they are phased out - I've ran into vendors who entirely remove them from the file and don't bother notifying the end user so you may want to disable any product who's stock wasn't updated. If you go this route you need to do a lot of error/logic checking to make sure you dont' mass disable their products if their feed isn't available, corrupt, fails to parse, etc.