{"id":111,"date":"2015-08-04T15:13:49","date_gmt":"2015-08-04T15:13:49","guid":{"rendered":"http:\/\/www.recolize.com\/en\/blog\/?p=111"},"modified":"2018-09-11T18:30:06","modified_gmt":"2018-09-11T16:30:06","slug":"magento-tutorial-export-complete-image-urls-and-category-names-with-a-custom-dataflow-mapper","status":"publish","type":"post","link":"https:\/\/www.recolize.com\/en\/blog\/magento-tutorial-export-complete-image-urls-and-category-names-with-a-custom-dataflow-mapper\/","title":{"rendered":"Magento Tutorial: Export complete image URLs and category names with a custom Dataflow Mapper"},"content":{"rendered":"<section class=\"section  text-normal section-text-no-shadow section-inner-no-shadow section-normal section-opaque\"  >\n    \n    <div class=\"background-overlay grid-overlay-0 \" style=\"background-color: rgba(0,0,0,0);\"><\/div>\n\n    <div class=\"container container-vertical-default\">\n        <div class=\"row vertical-default\">\n            <div class=\"col-md-12     text-default small-screen-default\"  ><div class=\"col-text-1 text-normal  element-top-20 element-bottom-20\" data-os-animation=\"none\" data-os-animation-delay=\"0s\">\n    <p>The<a href=\"http:\/\/merch.docs.magento.com\/ce\/user_guide\/content\/store-operations\/dataflow.html\" target=\"_blank\" rel=\"noopener\"> DataFlow extension in Magento<\/a> is a useful tool for exporting and importing products and customer entities and exists since the early days of Magento 1.0.<!--more--><\/p>\n<p>Although it has been <a href=\"http:\/\/magento.stackexchange.com\/questions\/24756\/what-is-the-difference-between-import-export-vs-dataflow\" target=\"_blank\" rel=\"noopener\">stated as deprecated<\/a>\u00a0there 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.<\/p>\n<p>Since Magento 1.6 there is also the <em>Mage_ImportExport<\/em> 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.<\/p>\n<p><a href=\"http:\/\/community.magento.com\/t5\/Installing-Magento\/Import-Export-vs-Data-Flow\/td-p\/5591\" target=\"_blank\" rel=\"noopener\">There is a Magento forum post<\/a>\u00a0which also mentions some differences between these two export extensions.<\/p>\n<p>For the above mentioned reasons we decided to use a customized Dataflow export profile also for the product feed generation in our <a href=\"https:\/\/www.recolize.com\/en\/magento-extension\/\">Recolize Recommendation Engine Extension for Magento.<\/a><\/p>\n<p>But we had two major issues with the default Dataflow export behaviour:<\/p>\n<ul>\n<li>While the product URL can be exported as complete URL via the XML node <code>&lt;var name=\"url_field\"&gt;&lt;![CDATA[1]]&gt;&lt;\/var&gt;<\/code> in the mapper, there is no such option for the product image URL. Instead it is exported as e.g.\u00a0<em>\/l\/o\/logitech-cordless-optical-trackman.jpg<\/em><\/li>\n<li>The second problem is that the product categories are exported as ids instead of category names<\/li>\n<\/ul>\n<p>Both flaws can be solved using a custom Dataflow mapper model that extends from <code>Mage_Dataflow_Model_Convert_Mapper_Abstract<\/code>. In there you could declare a class method e.g. <em>map()<\/em> that iterates over all batch exports and attributes and adds the appropriate transformations.<\/p>\n<p>Then generate a default Dataflow profile in the backend under <em>System &gt; Import\/Export &gt; Dataflow &#8211; Profiles<\/em>, copy the Profile Actions XML code, create a new Advanced Dataflow profile under <em>System &gt; Import\/Export &gt; Dataflow &#8211; Advanced Profiles<\/em> and copy the XML code there. Then as simple as it is you only have to replace the following default mapper<br \/>\n<code>&lt;action type=\"dataflow\/convert_mapper_column\" method=\"map\"&gt;&lt;\/action&gt;<\/code><br \/>\nwith your new custom mapper model. That&#8217;s it.<\/p>\n<p>To see a more complete source code sample please have a look at our <a href=\"https:\/\/www.recolize.com\/en\/magento-extension\/\">Magento extension.<\/a><\/p>\n<\/div>\n<\/div>        <\/div>\n    <\/div>\n<\/section>\n\n","protected":false},"excerpt":{"rendered":"<p>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.<\/p>\n","protected":false},"author":3,"featured_media":3271,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[146,170,40],"tags":[],"_links":{"self":[{"href":"https:\/\/www.recolize.com\/en\/wp-json\/wp\/v2\/posts\/111"}],"collection":[{"href":"https:\/\/www.recolize.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.recolize.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.recolize.com\/en\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.recolize.com\/en\/wp-json\/wp\/v2\/comments?post=111"}],"version-history":[{"count":4,"href":"https:\/\/www.recolize.com\/en\/wp-json\/wp\/v2\/posts\/111\/revisions"}],"predecessor-version":[{"id":4223,"href":"https:\/\/www.recolize.com\/en\/wp-json\/wp\/v2\/posts\/111\/revisions\/4223"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.recolize.com\/en\/wp-json\/wp\/v2\/media\/3271"}],"wp:attachment":[{"href":"https:\/\/www.recolize.com\/en\/wp-json\/wp\/v2\/media?parent=111"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.recolize.com\/en\/wp-json\/wp\/v2\/categories?post=111"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.recolize.com\/en\/wp-json\/wp\/v2\/tags?post=111"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}