Example #1
0
 /**
  * Validate data row
  *
  * @param array $rowData
  * @param int $rowNumber
  * @return boolean
  */
 public function validateRow(array $rowData, $rowNumber)
 {
     $rowScope = $this->_getRowScope($rowData);
     if ($rowScope == self::SCOPE_DEFAULT) {
         if ($this->_customerEntity->validateRow($rowData, $rowNumber)) {
             $this->_currentWebsiteCode = $rowData[Mage_ImportExport_Model_Import_Entity_Eav_Customer::COLUMN_WEBSITE];
             $this->_currentEmail = strtolower($rowData[Mage_ImportExport_Model_Import_Entity_Eav_Customer::COLUMN_EMAIL]);
             // Add new customer data into customer storage for address entity instance
             $websiteId = $this->_customerEntity->getWebsiteId($this->_currentWebsiteCode);
             if (!$this->_addressEntity->getCustomerStorage()->getCustomerId($this->_currentEmail, $websiteId)) {
                 $customerData = new Varien_Object(array('id' => $this->_nextCustomerId, 'email' => $this->_currentEmail, 'website_id' => $websiteId));
                 $this->_addressEntity->getCustomerStorage()->addCustomer($customerData);
                 $this->_nextCustomerId++;
             }
             return $this->_validateAddressRow($rowData, $rowNumber);
         } else {
             $this->_currentWebsiteCode = null;
             $this->_currentEmail = null;
         }
     } else {
         if (!empty($this->_currentWebsiteCode) && !empty($this->_currentEmail)) {
             return $this->_validateAddressRow($rowData, $rowNumber);
         } else {
             $this->addRowError(self::ERROR_ROW_IS_ORPHAN, $rowNumber);
         }
     }
     return false;
 }
 /**
  * Check customer email validation for delete behavior
  *
  * @covers Mage_ImportExport_Model_Import_Entity_Eav_Customer::validateRow
  */
 public function testValidateEmailForDeleteBehavior()
 {
     $this->_customerData[Mage_ImportExport_Model_Import_Entity_Eav_Customer::COLUMN_EMAIL] = '*****@*****.**';
     $this->_model->setParameters(array('behavior' => Mage_ImportExport_Model_Import::BEHAVIOR_DELETE));
     $this->_model->validateRow($this->_customerData, 0);
     $this->assertGreaterThan(0, $this->_model->getErrorsCount());
     $this->assertArrayHasKey(Mage_ImportExport_Model_Import_Entity_Eav_Customer::ERROR_CUSTOMER_NOT_FOUND, $this->_model->getErrorMessages());
 }