2

I want to custom import csv in a model using data flow profile. For that i have followed below steps :

1) Created a customimport.csv under var/import

2) Under admin > system >Import/Export > Dataflow - Advanced Profile, create new profile with Profile Actions XML

<action type="dataflow/convert_adapter_io" method="load">
    <var name="type">file</var>
    <var name="path">var/import</var>
    <var name="filename"><![CDATA[customimport.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">false</var>
    <var name="number_of_records">1</var>
    <var name="adapter">mymodule/convert_adapter_customimport</var>
    <var name="method">saveRow</var>
</action>

3) created a module : app/etc/modules/Bv_Mymodule.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Bv_Mymodule>
            <active>true</active>
            <codePool>local</codePool>
        </Bv_Mymodule>
    </modules>
</config>

4) app/code/local/Bv/Mymodule/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Bv_Mymodule>
            <version>0.1.0</version>
        </Bv_Mymodule>
    </modules>
    <global>
        <helpers>
            <mymodule>
                <class>Bv_Mymodule_Helper</class>
            </mymodule>
        </helpers>
        <models>
            <catalog>
                <rewrite>
                    <convert_adapter_customimport>Bv_Mymodule_Model_Convert_Adapter_Customimport</convert_adapter_customimport>
                </rewrite>
            </catalog>
        </models>
  </global>
</config> 

5) app/code/local/Bv/Mymodule/Helper

<?php
class Bv_Mymodule_Helper_Data extends Mage_Core_Helper_Abstract
{

}

6) app/code/local/Bv/Mymodule/Model/Convert/Adapter/Customimport.php

<?php

class Bv_Mymodule_Model_Convert_Adapter_Customimport extends Mage_Dataflow_Model_Convert_Adapter_Abstract
{
    public function load() {
    }

    public function save() {
    }
     public function parse()
    {
        $batchModel = Mage::getSingleton('dataflow/batch');
        $batchImportModel = $batchModel->getBatchImportModel();
        $importIds = $batchImportModel->getIdCollection();
        foreach ($importIds as $importId){
            $batchImportModel->load($importId);
            $importData = $batchImportModel->getBatchData();
            $this->saveRow($importData);
        }
    }
    public function saveRow(array $importData)
    {
        echo "<pre>";print_r($importData);exit; 
    }
}

7) Now when i run the profile in popup, i get the error :

Method "saveRow" not defined in adapter dataprofile/convert_adapter_customimport.

enter image description here

I dnt understand what i'm missing. If anyone can point out.? TIA.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.