Customizing Magento DataFlow – Import of customer-specific data.

  • magento frontend workingbut admin 500
  • payment method magento admin 500 error

The flexibility of Magento DataFlow module lies in the fact you can easily create your own adapters, parsers, mappers, and apply it to your specific needs of data flow.

I have found that this product has made me regular, stopped my IBS, and actually improved my vision. Will definitely purchase again. Viagra from canada! It can help many men who have erectile dysfunction get and keep an erection when they become sexually stimulated.

The fundamental case you may be wondering how to do it, is the import of data for your custom module. Let’s do this by example. Points you need to for you display e-shop list of the stores, you have custom module table in the database and data model creation part, all you need now is this table with data you within a CSV file . fill

My wife and I have nothing but praise for this product. Cheapest online propecia? Many rogue pharmacies are happy to bypass a doctor’s prescription in order to win your business.

Read the file

First, you need to read the file. As you already know (if you can Magento DataFlow – Default Adapter [Read Part 2]) to data flow / convert_adapter_io adapter for this use.

<action type="dataflow/convert_adapter_io" method="load">
<var name="type">file</var>
<var name="path">var/import</var>
<var name="filename"><![CDATA[stores.csv]]></var>
<var name="format"><![CDATA[csv]]></var>
</action>

Parse the file content

Now you have to read the contents of the file, you should parse it with data flow / convert_parser_csv.

<action type="dataflow/convert_parser_csv" method="parse">
<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>
</action>

Process rows of data

Now the custom part of this process. Within your custom module, you need custom adapter, line in creating the database, for each processed row parsed file to create. to create within your module root directory. / Model / convert / adapter / Store.php this content:

class Baobaz_Offer_Model_Convert_Adapter_Offer
extends  Mage_Dataflow_Model_Convert_Adapter_Abstract
{
protected $_storeModel;

public function load() {
//  you have to create this method, enforced by  Mage_Dataflow_Model_Convert_Adapter_Interface
}

public function save() {
//  you have to create this method, enforced by  Mage_Dataflow_Model_Convert_Adapter_Interface
}

public function  getStoreModel()
{
if (is_null($this->_storeModel)) {
$storeModel = Mage::getModel('baobaz_store/store');
$this->_storeModel = Mage::objects()->save($storeModel);
}
return Mage::objects()->load($this->_storeModel);
}

public function saveRow(array $importData)
{
$store = $this->getStoreModel();

if (empty($importData['code'])) {
$message = Mage::helper('catalog')->__('Skip  import row, required field "%s" not defined', 'code');
Mage::throwException($message);
}
else
{
$store->load($importData['code'],'code');
}

$store->setCode($importData['code']);
$store->setName($importData['name']);

$store->save();

return true;

}
}

Well, if you have created this file, modify the declaration can use a little of the parser to add adapter and method variables:

<action type="dataflow/convert_parser_csv" method="parse">
<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">baobaz_store/convert_adapter_store</var>
<var name="method">saveRow</var>
</action>

Once this is done, you should have your XML definition of user profile data flow like this:

<action type="dataflow/convert_adapter_io" method="load">
<var name="type">file</var>
<var name="path">var/import</var>
<var name="filename"><![CDATA[stores.csv]]></var>
<var name="format"><![CDATA[csv]]></var>
</action>
<action type="dataflow/convert_parser_csv"  method="parse">
<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">baobaz_store/convert_adapter_store</var>
<var name="method">saveRow</var>
</action>

Now you can your custom data flow

(Based on baobaz Turtorial)

Comments

Leave a Reply

Your email address will not be published.

18 − 2 =

Security Code: