Many people have described how to import additional images in Magento store. The question often arises as to how export additional images for products in Magento store.Magento’s architecture is module-based, which means that you can easily modify existing and add new functions by creating your own modules.
For this howto, I will create a module that overrides the “unparse()” function, which returns the csv Data for a export products. This module has been written for Magento 1.4 but should work on 1.3 as well.
1. Create directories
First of all, you need to create some directory structure that will hold your module files. Go to /app/code/local and create a directory representing your’s or your company’s name. All your modules will go into that directory. I will use this for the example:
Now we need to create the module directory. The module directory represents the name your module gets. I will use:
/app/code/local/CDL/Export in this example.
Every module needs a configuration file. This file is located under the etc/ subdirectory, so you need to create that directory as well. In my example it is:
The last needed directory is the Model/ subdirectory. I will explain what this is for later.
2. Config File
Now that we have all the directories we need, we can create a new file named config.xml inside the etc/ directory. This file will be used by the Magento module system to know what your module does and where the needed files are located. Here is the config.xml that we will need for our example:
As you can see, we will override the “Convert/Parser/Csv.php” model inside the “Dataflow” Module. Note that the underscores in represent the directory structure the core model is in. This is the same with CDL_Export_Model_Export, which points to CDL/Export/Model/Export.php.
3. Create the Model
Now we need to create the model. As you can see in the config.xml file, we have to create a new file named Export.php in the Model/ subdirectory. Here is the content of the file:
As you can see, we create a new model class which extends the core model class. that means your new class will have all the properties and functions the core class has. all functions you put in your class will be used instead of the core classes functions, and your can also add completely new functions to it. For now we changed the unparse() function, so it will return additional images for products (during Export Products).
4. Load your module
Now we finished our module, but Magento doesn’t know of it’s existence yet. We have to create a file in /app/etc/Modules that loads our module. Name that file CDL_Export.xml and put this in it:
All xml files inside /app/etc/Modules will be loaded automatically. By placing the above file in that directory, Magento will know that is has to look for a config.xml in /app/code/local/CDL/Export/etc and load your module.
Test it out! Please clear cash before. This is how it works: Use the Magento product export functionality (Admin >> System >> Import/Export >> Profiles >> Export All Products). Check your file. You can see, we added a column ”gallery” and pictures are separated with “;”
Just pass a short and simple registration and you will import your products with multiple images to your Magento store in no time!