更改Magento前端的标准地址格式

更改Magento前端的标准地址格式,magento,Magento,我想在“客户地址”页面上更改Magento的标准地址格式。我该怎么做 对于那些不知道地址格式的人,这是我们写地址的方法。例如,法国的英文格式如下: Addressee (Natural person/Organization) More detailed description of addressee (optional) Housenumber + Streetname Postal code + uppercase town Country (if other than France) 收

我想在“客户地址”页面上更改Magento的标准地址格式。我该怎么做

对于那些不知道地址格式的人,这是我们写地址的方法。例如,法国的英文格式如下:

Addressee (Natural person/Organization) More detailed description of addressee (optional) Housenumber + Streetname Postal code + uppercase town Country (if other than France) 收件人(自然人/组织) 更详细的收件人描述(可选) 门牌号+街道名 邮政编码+大写城镇 国家(如果不是法国) 美国的地址格式如下:

Name of address Street number and name Name of town, State abbreviation + ZIP code (typical handwritten format) 地址名称 街道号码及名称 城镇名称、州缩写+邮政编码 (典型手写格式)
你可以。非常感谢。

一般来说,地址格式包含在app/code/core/Mage/Customer/config.xml中。请查看以下标记:



似乎不再使用config.xml文件(或者只是将默认值加载到数据库中)

转到:

系统->配置->客户->客户配置并向下滚动至地址模板


在这里,您可以找到与XML文件中相同的代码。

Magento呈现地址与Magento管理配置中定义的相同。您可以通过更改地址模板来管理地址格式

转到系统/配置/客户配置/地址模板/Html/ 编辑您希望显示的内容


同样,您也可以编辑PDF模板以更改地址的PDF视图。

我有一个创建模块,用于根据县定义多个地址格式:

下面是创建它的简单方法

为插入更新“目录\国家\格式”表创建管理模块

重写模块中的Mage\u Customer\u Block\u Address\u Renderer\u默认类

覆盖以下功能

public function getFormat(Mage_Customer_Model_Address_Abstract $address=null)
{
    $countryFormat = is_null($address) ? parent::getFormat($address) :       
     $address->getCountryModel()->getFormat($this->getType()->getCode());
     if (is_object($countryFormat)) {
          $cFormat = $countryFormat->getFormat();
      }

    $format = $countryFormat ?   
    (!empty($cFormat)?$cFormat:$this->getType()->getDefaultFormat()) : 
    $this->getType()->getDefaultFormat();
    return $format;
}
这是我的模块,它可以帮助您定义基于客户国家/地区的地址格式


请更具体一些。什么是当前的地址格式,你想要什么样的地址等等。下面是“无法回答”类型的问题我已经编辑了我的帖子。。。ThanksHow是否要在新的Magento订单确认电子邮件中更改此地址格式?在address_templates元素中,您将看到文本、html、pdf和单行的条目。新订单电子邮件通常使用html格式,因此您可能也需要更新该格式。这正是满足我需求的完美解决方案。谢谢,但这仅适用于新的Magento版本:)
public function getFormat(Mage_Customer_Model_Address_Abstract $address=null)
{
    $countryFormat = is_null($address) ? parent::getFormat($address) :       
     $address->getCountryModel()->getFormat($this->getType()->getCode());
     if (is_object($countryFormat)) {
          $cFormat = $countryFormat->getFormat();
      }

    $format = $countryFormat ?   
    (!empty($cFormat)?$cFormat:$this->getType()->getDefaultFormat()) : 
    $this->getType()->getDefaultFormat();
    return $format;
}