コード例 #1
0
ファイル: Address.php プロジェクト: okite11/frames21
 /**
  * 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;
 }