Skip to main content
added 248 characters in body
Source Link
Siarhey Uchukhlebau
  • 16.2k
  • 11
  • 55
  • 88

You can check validation rules in the vendor/magento/module-offline-shipping/Model/ResourceModel/Carrier/Tablerate/CSV/RowParser.php:

/**
 * Retrieve region id from provided row data.
 *
 * @param array $rowData
 * @param int $rowNumber
 * @param ColumnResolver $columnResolver
 * @param int $countryId
 * @return array
 * @throws ColumnNotFoundException
 * @throws RowException
 */
private function getRegionIds(array $rowData, $rowNumber, ColumnResolver $columnResolver, $countryId)
{
    $regionCode = $columnResolver->getColumnValue(ColumnResolver::COLUMN_REGION, $rowData);
    if ($countryId !== '0' && $this->locationDirectory->hasRegionId($countryId, $regionCode)) {
        $regionIds = $this->locationDirectory->getRegionIds($countryId, $regionCode);
    } elseif ($regionCode === '*' || $regionCode === '') {
        $regionIds = [0];
    } else {
        throw new RowException(
            __(
                'The "%1" region or state in row number "%2" is incorrect. '
                . 'Verify the region or state and try again.',
                $regionCode,
                $rowNumber
            )
        );
    }
    return $regionIds;
}

By default the 2.4.4 Magento did not have predefined regions for the UAE, so you can't specify a region in the CSV (except empty string or * which means Any Region).

If you want to use regions you must add them manually in the table directory_country_region (it is pretty easy) or you could use this module (paid!) to add them through admin side.

Seems like this is a correct sql for adding the UAE regions (taken from Magento2 : How to add state options for UAE ):

INSERT INTO directory_country_region VALUES (NULL , 'AE', 'AUH','Abu Dhabir'), (NULL , 'AE', 'AJM','Ajman'), (NULL , 'AE', 'SHJ','Sharjah'), (NULL , 'AE', 'DXB','Dubai'), (NULL , 'AE', 'FUJ','Fujairah'), (NULL , 'AE', 'RAK','Ras Al Khaimah'), (NULL , 'AE', 'UAQ','Umm Al Quwain');

You can check validation rules in the vendor/magento/module-offline-shipping/Model/ResourceModel/Carrier/Tablerate/CSV/RowParser.php:

/**
 * Retrieve region id from provided row data.
 *
 * @param array $rowData
 * @param int $rowNumber
 * @param ColumnResolver $columnResolver
 * @param int $countryId
 * @return array
 * @throws ColumnNotFoundException
 * @throws RowException
 */
private function getRegionIds(array $rowData, $rowNumber, ColumnResolver $columnResolver, $countryId)
{
    $regionCode = $columnResolver->getColumnValue(ColumnResolver::COLUMN_REGION, $rowData);
    if ($countryId !== '0' && $this->locationDirectory->hasRegionId($countryId, $regionCode)) {
        $regionIds = $this->locationDirectory->getRegionIds($countryId, $regionCode);
    } elseif ($regionCode === '*' || $regionCode === '') {
        $regionIds = [0];
    } else {
        throw new RowException(
            __(
                'The "%1" region or state in row number "%2" is incorrect. '
                . 'Verify the region or state and try again.',
                $regionCode,
                $rowNumber
            )
        );
    }
    return $regionIds;
}

By default the 2.4.4 Magento did not have predefined regions for the UAE, so you can't specify a region in the CSV (except empty string or * which means Any Region).

You can check validation rules in the vendor/magento/module-offline-shipping/Model/ResourceModel/Carrier/Tablerate/CSV/RowParser.php:

/**
 * Retrieve region id from provided row data.
 *
 * @param array $rowData
 * @param int $rowNumber
 * @param ColumnResolver $columnResolver
 * @param int $countryId
 * @return array
 * @throws ColumnNotFoundException
 * @throws RowException
 */
private function getRegionIds(array $rowData, $rowNumber, ColumnResolver $columnResolver, $countryId)
{
    $regionCode = $columnResolver->getColumnValue(ColumnResolver::COLUMN_REGION, $rowData);
    if ($countryId !== '0' && $this->locationDirectory->hasRegionId($countryId, $regionCode)) {
        $regionIds = $this->locationDirectory->getRegionIds($countryId, $regionCode);
    } elseif ($regionCode === '*' || $regionCode === '') {
        $regionIds = [0];
    } else {
        throw new RowException(
            __(
                'The "%1" region or state in row number "%2" is incorrect. '
                . 'Verify the region or state and try again.',
                $regionCode,
                $rowNumber
            )
        );
    }
    return $regionIds;
}

By default the 2.4.4 Magento did not have predefined regions for the UAE, so you can't specify a region in the CSV (except empty string or * which means Any Region).

If you want to use regions you must add them manually in the table directory_country_region (it is pretty easy) or you could use this module (paid!) to add them through admin side.

Seems like this is a correct sql for adding the UAE regions (taken from Magento2 : How to add state options for UAE ):

INSERT INTO directory_country_region VALUES (NULL , 'AE', 'AUH','Abu Dhabir'), (NULL , 'AE', 'AJM','Ajman'), (NULL , 'AE', 'SHJ','Sharjah'), (NULL , 'AE', 'DXB','Dubai'), (NULL , 'AE', 'FUJ','Fujairah'), (NULL , 'AE', 'RAK','Ras Al Khaimah'), (NULL , 'AE', 'UAQ','Umm Al Quwain');
Source Link
Siarhey Uchukhlebau
  • 16.2k
  • 11
  • 55
  • 88

You can check validation rules in the vendor/magento/module-offline-shipping/Model/ResourceModel/Carrier/Tablerate/CSV/RowParser.php:

/**
 * Retrieve region id from provided row data.
 *
 * @param array $rowData
 * @param int $rowNumber
 * @param ColumnResolver $columnResolver
 * @param int $countryId
 * @return array
 * @throws ColumnNotFoundException
 * @throws RowException
 */
private function getRegionIds(array $rowData, $rowNumber, ColumnResolver $columnResolver, $countryId)
{
    $regionCode = $columnResolver->getColumnValue(ColumnResolver::COLUMN_REGION, $rowData);
    if ($countryId !== '0' && $this->locationDirectory->hasRegionId($countryId, $regionCode)) {
        $regionIds = $this->locationDirectory->getRegionIds($countryId, $regionCode);
    } elseif ($regionCode === '*' || $regionCode === '') {
        $regionIds = [0];
    } else {
        throw new RowException(
            __(
                'The "%1" region or state in row number "%2" is incorrect. '
                . 'Verify the region or state and try again.',
                $regionCode,
                $rowNumber
            )
        );
    }
    return $regionIds;
}

By default the 2.4.4 Magento did not have predefined regions for the UAE, so you can't specify a region in the CSV (except empty string or * which means Any Region).