0

I have to develop module and as a part of it, I have to create custom product export profile but I'm not sure how to reach this step.

I find code like this so I could insert this to data-installer but it must be configurable: must have predefined map but it should let admin changes it, change format (csv/xls)

$mageFilename = 'app/Mage.php';
require_once $mageFilename;
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$profile = Mage::getModel('dataflow/profile');
$data = array(

    'name' => "Import affiliate Products Feed",
    'actions_xml' =>   '<action type="dataflow/convert_adapter_io" method="load"><var name="type">file</var>
<var name="path">var/import</var>
<var name="filename"></var>
<var name="format"></var>
</action><action type="dataflow/convert_parser_csv" method="parse"><var name="delimiter"></var>
<var name="enclose"></var>
<var name="fieldnames">true</var>
<var name="store"></var>
<var name="number_of_records">1</var>
<var name="decimal_separator"></var>
<var name="adapter">catalog/convert_adapter_Product</var>
<var name="method">parse</var>
</action>'
);
if (isset($data)) {
   $profile->addData($data);
}
try {
      $profile->save();
} catch (Exception $e){
            die($e->getMessage());
}

Is there any easy way to do this because code I found rather won't work even after rebuilding...

Other idea I have is to create custom link in admin menu and there build block with whole export settings and leave behind above code and standard magento export system but it will consume large amount of time.

Can someone give me some tips or have any idea how to resolve this?

1 Answer 1

0

I did this job so I will answer to myself, maybe someone find this useful: 1. Created my module configuration section where you can choose which attributes should be use to export 2. Below I added button which used my custom admin controller to call method which use above code to create profiles (in $data I just added field map connected with configuration fields) 3. Then when you press button, it remove profiles if there was already created and creates new export profiles

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.