Extending *Eabi_Productexport_Model_Parser_Abstract*
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:
- getContentType
return 'text/xml' or any content type you desire to export - getFileExtension
applicable file extension for the specified content type - process
- you receive 2 parameters (Magento product entity and currently generated associative array) and need to return associative array that represents single product entity.
- Returned single product entity will later be used in writeItem function, so the format is important.
- writeHeader
you receive filepointer parameter. This function is called once at the beginning of the export - writeItem
you receive filepointer parameter and data parameter that you returned from generate function. This function is called once per every exportable product - writeFooter
you receive filepointer parameter. This function is called at the end of export procedure. - 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. - 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.