|
The attached library folder holds the classes that I used to add and update products.
The attached init folder holds the scripts that I used to add products, simple or configurable.
The attached update folder hold the scripts that I used to update product attributes.
As you will notice, I connect to a mysql database (which is a mapped dump from our AS400 business system). All of my init/update calls pull from this mysql database. Many of you will use Dataflow, xml, SOAP, etc… and will have to customize this code.
For updating I simply query every simple product in magento, then update the desired attribute for that simple product by calling for that product in mysql. Same goes for configurable products,but all I update for configurable products is their existence in our business system.
For adding simple products, I query every active/show_online simple product in our business system and run it through the createSimpleProduct function.
For adding configurable products, I query every active/show_online configurable product in our business system and run it through the createConfigurableProduct function.
For updating attributes such as price, special_price, qty… the function looks to see if the business system and magento already match. If the two already match, then I dont’ have to run an update on that product and I can continue on to the next product. This saves an INCREDIBLY ENORMOUS amount of time when updating products.
For updating attributes such as Size or Color, this class is extremely helpful. For example, updateColor queries every simple product in magento and checks to see the color in magento matches the color in our business system. If it does, that product is skipped. If the magento color and the business system color doesn’t match it checks to see if that color exists in magento as an attribute value. If the color already exists in magento the function selects that color’s attribute value and the color is updated. If the color doesn’t already exist in magento the function creates that color, selects that color’s attribute value and the color is updated.
This attachment is by no means ready to plug and play, so please don’t ftp it to your magento installation and post why it doesn’ t magically connect to your business system and update magento accordingly. This class should be a reference tool for how to build update procedures that are custom designed for your business. How to get data from your business system is out of the scope of this thread.
This attachment was customized for this posting so it will need some editing. You will need to set your /app/Mage.php location in the class file Magento.php. I have constructed this in an incredible hurry, so I apologize if there are any spelling mistakes in the functions or classes. If you find a more efficient or dynamic way to code any of these functions please post your findings!
I assume this thread is going to flood with questions and comments. I will try my absolute hardest to respond asap, but I am extremely busy with my job so please bare with me.
File Attachments
|