/** * Validate data row. * * @param array $rowData * @param int $rowNum * @return boolean */ public function validateRow(array $rowData, $rowNum) { $rowIsValid = true; if ($this->_isRowWithAddress($rowData)) { foreach ($this->_attributes as $colName => $attrParams) { if (isset($rowData[$colName]) && strlen($rowData[$colName])) { $rowIsValid &= $this->_customer->isAttributeValid($colName, $attrParams, $rowData, $rowNum); } elseif ($attrParams['is_required']) { $this->_customer->addRowError(Mage_ImportExport_Model_Import_Entity_Customer::ERROR_VALUE_IS_REQUIRED, $rowNum, $colName); $rowIsValid = false; } } // validate region for countries with known region list if ($rowIsValid) { $regionColName = self::getColNameForAttrCode('region'); $countryColName = self::getColNameForAttrCode('country_id'); $countryRegions = isset($this->_countryRegions[strtolower($rowData[$countryColName])]) ? $this->_countryRegions[strtolower($rowData[$countryColName])] : array(); if (!empty($rowData[$regionColName]) && !empty($countryRegions) && !isset($countryRegions[strtolower($rowData[$regionColName])])) { $this->_customer->addRowError(self::ERROR_INVALID_REGION, $rowNum); $rowIsValid = false; } } } return $rowIsValid; }
/** * Adds events before and after importing. * * @return boolean */ public function _importData() { Mage::dispatchEvent($this->_eventPrefix . '_before_import', array('data_source_model' => $this->_dataSourceModel, 'entity_model' => $this)); $result = parent::_importData(); Mage::dispatchEvent($this->_eventPrefix . '_after_import', array('entities' => $this->_newCustomers, 'entity_model' => $this)); return $result; }
/** * Constructor */ public function __construct() { $add = array('_wishlist_shared', '_wishlist_updated_at', '_wishlist_sharing_code', '_wishlist_item_sku', '_wishlist_item_added_at', '_wishlist_item_description', '_wishlist_item_qty'); $this->_particularAttributes = array_merge($this->_particularAttributes, $add); $this->_messageTemplates[self::ERROR_INVALID_SKU] = 'SKU not found'; $this->_messageTemplates[self::ERROR_INVALID_QTY] = 'Qty must me numeric'; parent::__construct(); $this->_addressEntity = Mage::getModel('fastsimpleimport/import_entity_customer_address', $this); }
/** * Constructor. * * @return void */ public function __construct() { parent::__construct(); $this->_addressEntity = Mage::getModel('fastsimpleimport/import_entity_customer_address', $this); }