17 private $locationDirectory;
25 $this->locationDirectory = $locationDirectory;
64 if (count($rowData) < 5) {
67 'The Table Rates File Format is incorrect in row number "%1". Verify the format and try again.',
73 $countryId = $this->getCountryId($rowData, $rowNumber, $columnResolver);
74 $regionId = $this->getRegionId($rowData, $rowNumber, $columnResolver, $countryId);
75 $zipCode = $this->getZipCode($rowData, $columnResolver);
76 $conditionValue = $this->getConditionValue($rowData, $rowNumber, $conditionFullName, $columnResolver);
77 $price = $this->getPrice($rowData, $rowNumber, $columnResolver);
81 'dest_country_id' => $countryId,
82 'dest_region_id' => $regionId,
83 'dest_zip' => $zipCode,
84 'condition_name' => $conditionShortName,
85 'condition_value' => $conditionValue,
98 private function getCountryId(array $rowData, $rowNumber,
ColumnResolver $columnResolver)
102 if ($this->locationDirectory->hasCountryId($countryCode)) {
103 $countryId = $this->locationDirectory->getCountryId($countryCode);
104 }
elseif ($countryCode ===
'*' || $countryCode ===
'') {
107 throw new RowException(
109 'The "%1" country in row number "%2" is incorrect. Verify the country and try again.',
127 private function getRegionId(array $rowData, $rowNumber, ColumnResolver $columnResolver, $countryId)
130 if ($countryId !==
'0' && $this->locationDirectory->hasRegionId($countryId, $regionCode)) {
131 $regionId = $this->locationDirectory->getRegionId($countryId, $regionCode);
132 }
elseif ($regionCode ===
'*' || $regionCode ===
'') {
135 throw new RowException(
137 'The "%1" region or state in row number "%2" is incorrect. ' 138 .
'Verify the region or state and try again.',
153 private function getZipCode(array $rowData, ColumnResolver $columnResolver)
156 if ($zipCode ===
'') {
171 private function getConditionValue(array $rowData, $rowNumber, $conditionFullName, ColumnResolver $columnResolver)
174 $conditionValue = $columnResolver->getColumnValue($conditionFullName, $rowData);
175 $value = $this->_parseDecimalValue($conditionValue);
177 throw new RowException(
179 'Please correct %1 "%2" in the Row #%3.',
197 private function getPrice(array $rowData, $rowNumber, ColumnResolver $columnResolver)
200 $price = $this->_parseDecimalValue($priceValue);
202 throw new RowException(
204 'The "%1" shipping price in row number "%2" is incorrect. Verify the shipping price and try again.',
220 private function _parseDecimalValue(
$value)
elseif(isset( $params[ 'redirect_parent']))
__construct(LocationDirectory $locationDirectory)
parse(array $rowData, $rowNumber, $websiteId, $conditionShortName, $conditionFullName, ColumnResolver $columnResolver)
getColumnValue($column, array $values)