It is recommended to extend instead one of the following models instead:

  • Eabi_Productexport_Model_Parser_Csv - if you wish to export in CSV format
  • Eabi_Productexport_Model_Parser_Default - if you wish to export in XML format
  • Eabi_Productexport_Model_Parser_Excel - if you wish to export in Microsoft Excel 2010 format


This way you have to overwrite less methods and you may get away by just overwriting process and getFormFields function.


In custom export processor you need to implement the following functions:

  1. getContentType
    return 'text/xml' or any content type you desire to export
  2. getFileExtension
    applicable file extension for the specified content type
  3. process
    1. you receive 2 parameters (Magento product entity and currently generated associative array) and need to return associative array that represents single product entity.
    2. Returned single product entity will later be used in writeItem function, so the format is important.
  4. writeHeader
    you receive filepointer parameter. This function is called once at the beginning of the export
  5. writeItem
    you receive filepointer parameter and data parameter that you returned from generate function. This function is called once per every exportable product
  6. writeFooter
    you receive filepointer parameter. This function is called at the end of export procedure.
  7. toOutput
    you receive custom assoc array as parameter and you need to convert into the file data that is compatible with your custom file format.
  8. getFormFields - You must return Varien_Data_Form object here if you wish to use custom configuration for the exporter. Otherwise you may return false here.




If you wish to read the data from your custom form, then use getConfigData function.


How to extend getFormFields function by adding one extra field?

   public function getFormFields() {

       $formFields = parent::getFormFields();

//       $dateTimeFormatIso = Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);

       $dateTimeFormatIso = 'yyyy-MM-dd HH:mm:ss';

       $fieldSet = $formFields->getElement(strtolower('Eabi_Productexport_Model_Parser_Excel'));

       $fieldSet->addField('export_from_date', 'date', array(

           'label' => $this->_getImportHelper()->__('Export stock changes from'),

           'class' => '',

           'required' => false,

           'name' => 'export_from_date',

           'time' => true,

           'image'    => Mage::getDesign()->getSkinUrl('images/grid-cal.gif'),

           'format' => $dateTimeFormatIso,

           

       ));

       

       return $formFields;

   }



Use this sample to get you going. Element name 'Eabi_Productexport_Model_Parser_Excel' comes from parent Magento class name.