One of major features of e-commerce websites is the possibility to share data with offline sale management systems. Magento made data exchange flexible and quite easy with DataFlow module.
Magento DataFlow is a data exchange framework that use four types of components: adapter, parser, maper and validator. At current state of developement validators are not implemented, but are reserved for future use.
Dataflow of data exchange process is defined as XML structure and called profile. Magento provides simple wizard-like tool for generation of some basic import/export profiles operating on products or customers entities. Advanced profiles manager is also provided for advanced users able to create XML defining profile without wizard tool and with need to use more custom dataflow operations related also to other entities.
Adapters are responsible for pluging into an external data resource and fetching requested and filtered data. It can be used for example to get data from: local or remote file, web services, database and more.
For example to load data from csv file you can put in XML profile the following code:
<var name="type">file</var>
<var name="path">var/import</var>
<var name="filename"><![CDATA[products.csv]]></var>
<var name="format"><![CDATA[csv]]></var>
</action>
To load data from remote FTP server you can use same adapter, but with these parameters:
<var name="type">ftp</var>
<var name="host"><![CDATA[ftp.server.com]]></var>
<var name="passive">true</var>
<var name="user"><![CDATA[user]]></var>
<var name="password"><![CDATA[password]]></var>
<var name="path">var/import</var>
<var name="filename"><![CDATA[products.csv]]></var>
<var name="format"><![CDATA[csv]]></var>
</action>
Parsers are responsible for transforming one data format to another. It can be used for example to convert CSV file content to two-dimmensional array, or opposite.
To parse CSV file content into database product entities you can use this code in your profile:
<var name="delimiter"><![CDATA[,]]></var>
<var name="enclose"><![CDATA["]]></var>
<var name="fieldnames">true</var>
<var name="store"><![CDATA[0]]></var>
<var name="number_of_records">1</var>
<var name="decimal_separator"><![CDATA[.]]></var>
<var name="adapter">catalog/convert_adapter_product</var>
<var name="method">parse</var>
</action>
Adapter defined within parser variables as <var name="adapter"> and adapter's method <var name="method"> are responsible for parsing loaded data. In this particular case parser converts data from CSV file content to two-dimmensional array and calls the adapter's method "parse" to process it.
The simplest way of import customization is creating own adapter given as variable within parser definition. In most cases you will need to overwrite one of existing adapters and modify or write your own parsing method (in most cases it will be overwrited saveRow() method)
Mappers are responsible for altering data values from one to another. These are useful for maping one field to another.
In example below source's 'reference' column is mapped into 'sku' column and variable '_only_specified' is set to true, so imported/exported will be only listed columns:
<var name="map">
<map name="sku"><![CDATA[reference]]></map>
<map name="name"><![CDATA[name]]></map>
<map name="price"><![CDATA[price]]></map>
<map name="qty"><![CDATA[qty]]></map>
</var>
<var name="_only_specified">true</var>
</action>
This is just the tip of the iceberg of possibilities Magento DataFlow module offers. Come back later to read more.






Information on DataFlow currently available is very limited, so thanks for this great post!
Looking forward to the more advanced DataFlow possibilities in the coming posts!
Vinai
Killer article on breaking this down for everyone! I was just curious as to what the following is/does/and if there are any other parameters that can be used for it. Or am I just not seeing the obvious? :)
catalog/convert_adapter_product
Thanks again :)
I like the article. This is probably a dumb question that I could answer if I spent a little time digging into it, but here goes. Can Data Flow be used to import/update items made for a custom module(I assume it can)? If so are there any good examples? I have created a vehicle filter module(for an auto parts store) that allows customers to limit products they see by selecting there vehicle(make, model, options, and year). I would like to use data flow to update the fields for these tables. Is this a feasible idea? Any suggestions are greatly appreciated.
@Mike D
Of course you can use dataflow for custom modules. Basically in the examples above dataflow/convert_adapter_io will read any file, dataflow/convert_parser_csv will parse any data from csv file, and the only part that tells rows of data are going to be used to populate products are the adapter and method variables defined within dataflow/convert_parser_csv. You can create your custom adapter with for example saveRow method and within this method create new objects of whatever class you wish.
More detailed answer on subject of custom modules dataflows: http://blog.baobaz.com/en/blog/customizing-magento-dataflow-import-of-cu...
So Office 2007 Professional here is a fast Download Office 2007 reconsider of the things Microsoft Office 2007 Professional that work in the new Download Office 2010 versions of Office 2010 Download.I love Microsoft Office 2010 Download the alleviate of Windows 7 use of the ribbon Microsoft Windows 7, all the hours of Win 7 client study has Download Windows 7 paid off. They took the Buy Windows 7 choices no one ever Microsoft office 2011 utilised and interred Office 2007 them. Things like Microsoft Office 2007 altering case of Office 2007 Download text is now just one MS Office 2007 bang away. If you find Office 2007 Key certain thing that you buy microsoft office 2007 use on a normal purchase microsoft office 2007 cornerstone, but Office 2010 not in the ribbon Microsoft Office 2010 you can habitually MS Office 2010 customize the fast get Office 2010 Key access to toolbar Office 2010 Professional and add it buy microsoft office 2010 there.
thank u for your article
منتدى بناتى
great with
منتدى تصميم
good for
العاب بنات لها
gianmarco lorenzi shop sales the full range of shose.Whether gianmarco lorenzi boots or gianmarco lorenzi pumps,you can see here.Even if you want to buy gianmarco lorenzi sandals in winter is also possible.
Thank for nice article!
I'm a newbiew. So i don't where is place code ? Can you show me
And i have one question: " I want to save data directly in magento database (data was crawled from some site)". How can i do that?
Thanks !
Ainsi, il ya des lancel imitations d'origine, il sont assez bon marché. Vous pouvez également chercher des ventes aux enchères où les sacs Lancel sont bon marché, même si être flambant neuf ainsi que d'origine. Imitation des sacs à main lancel sacs Lancel concepteur peut difficilement vous rassasier. Certains sacs Lancel traditionnellement ethniques qui sont très artistiques, ainsi que de sac lancel homme style peut être abordable. Il ya beaucoup de compagnies qui vendent des différents modèles de sac lancel premier flirt animation sacs Lancel à partir d'aujourd'hui et il est vraiment, vraiment un grand dilemme de savoir comment et où vous pouvez trouver le bon type de main-ce qui vous convient. Bien lancel soldes sûr, vous ne voudriez pas de porter ou d'utiliser quelque chose qui est laid à regarder.
http://www.ventepriveelancel.com/
Post new comment