【问题标题】:How to add country in Magento2?如何在 Magento2 中添加国家/地区?
【发布时间】:2019-12-06 08:47:36
【问题描述】:

我们有 Magento 2.2.5 版。

我们尝试启用(添加)科索沃。

所以:

  1. 在数据库目录中添加_country XK、XK 和 XKX
  2. 进入 /vendor/magento/zendframework1/library/Zend/Locale/Data 和 用科索沃(已经存在)编辑 en.xml/it.xml 也添加科索沃
  3. 使用控制台刷新缓存

当我们进入管理配置到一般添加可用国家时,不存在。我们还尝试添加一个测试国家,但不工作。我们也尝试编辑 /vendor/magento/module-directory/etc/config.xml 添加允许国家/地区。

我们该怎么做?

【问题讨论】:

    标签: configuration magento2 country


    【解决方案1】:

    在 Magento 中添加新国家非常容易,只需按照以下步骤操作即可。

    Step1: Open lib/zend/locale/data/en.xml
    
    Step2: Locate territories tag in this file
    
    Step3: copy one of the territory tags for the syntax and paste it within the territories tag
    
    Step4: hard part here is to add country code in this file as might not be able to find a unique one, so it’s upto you.
    
    Step5: Save this file
    
    Step6: Open table name directory_country
    
    Step7: It has predefined syntax follow then same and create a new row and enter the same country code as entered in the en.xml file in 3 columns
    
    Step8: Refresh the site’s cache.
    
    Step9: Admin > Configuration > General
    

    应在允许的国家/地区列表中选择此新国家/地区。

    【讨论】:

    • 不适用于我的版本有 /vendor/magento/zendframework1/library/Zend/Locale/Data 而不是 /lib/zend/locale/data/
    • 之后清除缓存并重新生成静态内容
    • 我们不会重新生成静态内容、清除缓存、刷新缓存、重新索引...
    • 这适用于 2.2* 版本,正如 PUno 指出的那样,目录是 /vendor/magento/zendframework1/library/Zend/Locale/Data,但请记住,如果您使用此方法,如果您更新Magento 你需要重新应用修复。
    【解决方案2】:

    我点击了下面的链接,它可以帮助我添加一个新的国家

    Add new nation into nation's list in Magento 2.3.5

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-07
      • 2015-09-13
      相关资源
      最近更新 更多