magento 1.9没有显示"州"结帐时下拉菜单

时间:2015-08-11 07:29:58

标签: php mysql magento

我正在运行magento 1.9.2.0,我配置了配置选项以询问"状态"对于意大利,但当我试图购买该州时,实际上并不需要。

这里有一些截图:

http://i.stack.imgur.com/jIfiY.png http://i.stack.imgur.com/TIWkZ.png

对我来说,这看起来像一个magento bug。我该如何解决?

2 个答案:

答案 0 :(得分:0)

您必须填充数据库中的directory_country_region表。

您可以运行以下内容:

INSERT INTO 
  `directory_country_region` 
  (`region_id`, `country_id`, `code`, `default_name`) 
VALUES
  (NULL, 'IT', 'IT-52', 'Toscana'), // example with ISO_3166-2 REGION code
  ...
  (NULL, 'IT', 'IT-BO', 'Bologna'); // example with ISO_3166-2 PROVINCE code

小解释:

  • region_id自动递增
  • IT是意大利的ISO-3166-2 country_id。请参阅https://en.wikipedia.org/wiki/ISO_3166-2:IT
  • code是系统中识别区域的内部值,在最佳实践中使用iso区域代码是好的,您可以在{{3}中检索意大利20个区域的列表}。您也可以提供意大利的110个省份,在这种情况下使用省代码而不是区域代码,您可以在https://en.wikipedia.org/wiki/ISO_3166-2:IT#Regions
  • 中检索110个省份的代码列表
  • default_name是ISO_3166-2地区|省名。您可以稍后使用Magento翻译流程更新名称

答案 1 :(得分:0)

利用Nolweig的示例和外部来源,我创建了脚本来导入所有意大利地区。

error_reporting(E_ALL);
ini_set('display_errors', '1');

require_once 'app/Mage.php';

umask(0);
Mage::app('');

// set up array containing regions to be added (region_code => region_name)
$new_regions = array(
   'AG' => 'Agrigento',
   'AL' => 'Alessandria',
   'AN' => 'Ancona',
   'AO' => 'Aosta',
   'AR' => 'Arezzo',
   'AP' => 'Ascoli Piceno',
   'AT' => 'Asti',
   'AV' => 'Avellino',
   'BA' => 'Bari',
   'BT' => 'Barletta-Andria-Trani',
   'BL' => 'Belluno',
   'BN' => 'Benevento',
   'BG' => 'Bergamo',
   'BI' => 'Biella',
   'BO' => 'Bologna',
   'BZ' => 'Bolzano',
   'BS' => 'Brescia',
   'BR' => 'Brindisi',
   'CA' => 'Cagliari',
   'CL' => 'Caltanissetta',
   'CB' => 'Campobasso',
   'CI' => 'Carbonia-Iglesias',
   'CE' => 'Caserta',
   'CT' => 'Catania',
   'CZ' => 'Catanzaro',
   'CH' => 'Chieti',
   'CO' => 'Como',
   'CS' => 'Cosenza',
   'CR' => 'Cremona',
   'KR' => 'Crotone',
   'CN' => 'Cuneo',
   'EN' => 'Enna',
   'FM' => 'Fermo',
   'FE' => 'Ferrara',
   'FI' => 'Firenze',
   'FG' => 'Foggia',
   'FC' => 'Forlì-Cesena',
   'FR' => 'Frosinone',
   'GE' => 'Genova',
   'GO' => 'Gorizia',
   'GR' => 'Grosseto',
   'IM' => 'Imperia',
   'IS' => 'Isernia',
   'SP' => 'La Spezia',
   'AQ' => 'L\'Aquila',
   'LT' => 'Latina',
   'LE' => 'Lecce',
   'LC' => 'Lecco',
   'LI' => 'Livorno',
   'LO' => 'Lodi',
   'LU' => 'Lucca',
   'MC' => 'Macerata',
   'MN' => 'Mantova',
   'MS' => 'Massa-Carrara',
   'MT' => 'Matera',
   'ME' => 'Messina',
   'MI' => 'Milano',
   'MO' => 'Modena',
   'MB' => 'Monza e della Brianza',
   'NA' => 'Napoli',
   'NO' => 'Novara',
   'NU' => 'Nuoro',
   'OT' => 'Olbia-Tempio',
   'OR' => 'Oristano',
   'PD' => 'Padova',
   'PA' => 'Palermo',
   'PR' => 'Parma',
   'PV' => 'Pavia',
   'PG' => 'Perugia',
   'PU' => 'Pesaro e Urbino',
   'PE' => 'Pescara',
   'PC' => 'Piacenza',
   'PI' => 'Pisa',
   'PT' => 'Pistoia',
   'PN' => 'Pordenone',
   'PZ' => 'Potenza',
   'PO' => 'Prato',
   'RG' => 'Ragusa',
   'RA' => 'Ravenna',
   'RC' => 'Reggio Calabria',
   'RE' => 'Reggio Emilia',
   'RI' => 'Rieti',
   'RN' => 'Rimini',
   'RM' => 'Roma',
   'RO' => 'Rovigo',
   'SA' => 'Salerno',
   'VS' => 'Medio Campidano',
   'SS' => 'Sassari',
   'SV' => 'Savona',
   'SI' => 'Siena',
   'SR' => 'Siracusa',
   'SO' => 'Sondrio',
   'TA' => 'Taranto',
   'TE' => 'Teramo',
   'TR' => 'Terni',
   'TO' => 'Torino',
   'OG' => 'Ogliastra',
   'TP' => 'Trapani',
   'TN' => 'Trento',
   'TV' => 'Treviso',
   'TS' => 'Trieste',
   'UD' => 'Udine',
   'VA' => 'Varese',
   'VE' => 'Venezia',
   'VB' => 'Verbano-Cusio-Ossola',
   'VC' => 'Vercelli',
   'VR' => 'Verona',
   'VV' => 'Vibo Valentia',
   'VI' => 'Vicenza',
   'VT' => 'Viterbo',
);

// specify country code for new regions
$country_code = 'IT';

// specify locale
$locale = 'it_IT';

// create our core_write conection object
$connection = Mage::getSingleton('core/resource')->getConnection('core_write');

// iterate our new regions
foreach ($new_regions as $region_code => $region_name) {

    // insert region 
    $sql = "INSERT INTO `directory_country_region` (`region_id`,`country_id`,`code`,`default_name`) VALUES (NULL,?,?,?)";
    $connection->query($sql,array($country_code,$region_code,$region_name));

    // get new region id for next query
    $region_id = $connection->lastInsertId();

    // insert region name
    $sql = "INSERT INTO `directory_country_region_name` (`locale`,`region_id`,`name`) VALUES (?,?,?)";
    $connection->query($sql,array($locale,$region_id,$region_name));
}

echo 'Import finished';