The DataFlow extension in Magento is a useful tool for exporting and importing products and customer entities and exists since the early days of Magento 1.0.
Although it has been stated as deprecated there is no other extension in a standard Magento community installation that can generate as flexible exports as Dataflow does. The nice thing about Dataflow is that it is configured via XML profiles that can easily be extended by yourself.
Since Magento 1.6 there is also the Mage_ImportExport extension which is much better from a performance point of view, but its main purpose seems to be the export from one Magento instance and import it into another, because of the lack of export field configurations, filters, etc.
There is a Magento forum post which also mentions some differences between these two export extensions.
For the above mentioned reasons we decided to use a customized Dataflow export profile also for the product feed generation in our Recolize Recommendation Engine Extension for Magento.
But we had two major issues with the default Dataflow export behaviour:
- While the product URL can be exported as complete URL via the XML node
<var name="url_field"><![CDATA[1]]></var>
in the mapper, there is no such option for the product image URL. Instead it is exported as e.g. /l/o/logitech-cordless-optical-trackman.jpg - The second problem is that the product categories are exported as ids instead of category names
Both flaws can be solved using a custom Dataflow mapper model that extends from Mage_Dataflow_Model_Convert_Mapper_Abstract
. In there you could declare a class method e.g. map() that iterates over all batch exports and attributes and adds the appropriate transformations.
Then generate a default Dataflow profile in the backend under System > Import/Export > Dataflow – Profiles, copy the Profile Actions XML code, create a new Advanced Dataflow profile under System > Import/Export > Dataflow – Advanced Profiles and copy the XML code there. Then as simple as it is you only have to replace the following default mapper
<action type="dataflow/convert_mapper_column" method="map"></action>
with your new custom mapper model. That’s it.
To see a more complete source code sample please have a look at our Magento extension.