Mage_Dataflow_Model_Convert_Mapper_Column Class Reference

Inheritance diagram for Mage_Dataflow_Model_Convert_Mapper_Column:

Mage_Dataflow_Model_Convert_Mapper_Abstract Mage_Dataflow_Model_Convert_Container_Abstract Mage_Dataflow_Model_Convert_Mapper_Interface Mage_Dataflow_Model_Convert_Container_Interface

List of all members.

Public Member Functions

 getBatchModel ()
 getBatchExportModel ()
 getBatchImportModel ()
 map ()

Protected Attributes

 $_batch
 $_batchExport
 $_batchImport


Detailed Description

Definition at line 35 of file Column.php.


Member Function Documentation

getBatchExportModel (  ) 

Retrieve Batch export model

Returns:
Mage_Dataflow_Model_Batch_Export

Definition at line 76 of file Column.php.

00077     {
00078         if (is_null($this->_batchExport)) {
00079             $object = Mage::getModel('dataflow/batch_export');
00080             $this->_batchExport = Varien_Object_Cache::singleton()->save($object);
00081         }
00082         return Varien_Object_Cache::singleton()->load($this->_batchExport);
00083     }

getBatchImportModel (  ) 

Retrieve Batch import model

Returns:
Mage_Dataflow_Model_Import_Export

Definition at line 90 of file Column.php.

00091     {
00092         if (is_null($this->_batchImport)) {
00093             $object = Mage::getModel('dataflow/batch_import');
00094             $this->_batchImport = Varien_Object_Cache::singleton()->save($object);
00095         }
00096         return Varien_Object_Cache::singleton()->load($this->_batchImport);
00097     }

getBatchModel (  ) 

Retrieve Batch model singleton

Returns:
Mage_Dataflow_Model_Batch

Definition at line 63 of file Column.php.

00064     {
00065         if (is_null($this->_batch)) {
00066             $this->_batch = Mage::getSingleton('dataflow/batch');
00067         }
00068         return $this->_batch;
00069     }

map (  ) 

Implements Mage_Dataflow_Model_Convert_Mapper_Interface.

Definition at line 99 of file Column.php.

00100     {
00101         $batchModel  = $this->getBatchModel();
00102         $batchExport = $this->getBatchExportModel();
00103 
00104         $batchExportIds = $batchExport
00105             ->setBatchId($this->getBatchModel()->getId())
00106             ->getIdCollection();
00107 
00108         $onlySpecified = (bool)$this->getVar('_only_specified') === true;
00109 
00110         if (!$onlySpecified) {
00111             foreach ($batchExportIds as $batchExportId) {
00112                 $batchExport->load($batchExportId);
00113                 $batchModel->parseFieldList($batchExport->getBatchData());
00114             }
00115 
00116             return $this;
00117         }
00118 
00119         if ($this->getVar('map') && is_array($this->getVar('map'))) {
00120             $attributesToSelect = $this->getVar('map');
00121         }
00122         else {
00123             $attributesToSelect = array();
00124         }
00125 
00126         if (!$attributesToSelect) {
00127             $this->getBatchExportModel()
00128                 ->setBatchId($this->getBatchModel()->getId())
00129                 ->deleteCollection();
00130 
00131             throw new Exception(Mage::helper('dataflow')->__('Error field mapping! Fields list for mapping is not defined'));
00132         }
00133 
00134         foreach ($batchExportIds as $batchExportId) {
00135             $batchExport = $this->getBatchExportModel()->load($batchExportId);
00136             $row = $batchExport->getBatchData();
00137 
00138             $newRow = array();
00139             foreach ($attributesToSelect as $field => $mapField) {
00140                 $newRow[$mapField] = isset($row[$field]) ? $row[$field] : null;
00141             }
00142 
00143             $batchExport->setBatchData($newRow)
00144                 ->setStatus(2)
00145                 ->save();
00146             $this->getBatchModel()->parseFieldList($batchExport->getBatchData());
00147         }
00148 
00149         return $this;
00150     }


Member Data Documentation

$_batch [protected]

Definition at line 42 of file Column.php.

$_batchExport [protected]

Definition at line 49 of file Column.php.

$_batchImport [protected]

Definition at line 56 of file Column.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:24:05 2009 for Magento by  doxygen 1.5.8