如何更改 Magento 1.5 中的价格格式或区域设置选项?
我将在magento中写一个常见问题和一个最适合我的解决方案。
我已经在网上搜索并反映了magento代码几个小时,以找到上述问题的解决方案。我希望匈牙利价格格式为 1 000 Ft
而不是 1 000,00 Ft
我已将所有位置的值 ' precision'
替换为 0,但没有成功。 这是我探索的列表:
app/code/core/Mage/Core/Model/Store.php
函数 formatPrice(){ $option = array('precison' => 2 ); ... }
app/code/core/Mage/Directory/Model/Currency.php
函数格式() { $this->formatPrecision($price, 0, $options, $includeContainer, $addBrackets); }
反映代码后,我意识到这一切更改根本无关紧要,因为数字格式信息基于由 Zend core API 提供的 区域设置 信息 >。
这是我找到的解决方案,希望价格格式能够成为整个应用程序的标准。
您可以在 lib/Zend/ 中找到 YY.xml 文件Locale/Data/,其中 YY 是您所在国家/地区的区域设置代码。我的是 hu.xml
您可以找到以下部分:
<currencyFormats>
<currencyFormatLength>
<currencyFormat>
<pattern>#,##0 ¤</pattern>
</currencyFormat>
</currencyFormatLength>
<unitPattern count="other">{0} {1}</unitPattern>
</currencyFormats>
关于格式字符串,您可以在 http://framework.zend.com/manual/en/zend.locale.parsing.html
I'm going to write a common problem in magento and a solution, which best fit for me.
I've been searchin the net and reflecting magento code for hours to find solution to the above problem. I wanted Hungarian price format to be 1 000 Ft
instead of 1 000,00 Ft
I have replaced the value 'precision'
to 0 everywhere, but did not succeed.
Here is a list where I probed:
app/code/core/Mage/Core/Model/Store.php
function formatPrice(){ $option = array('precison' => 2 ); ... }
app/code/core/Mage/Directory/Model/Currency.php
function format() {
$this->formatPrecision($price, 0, $options, $includeContainer, $addBrackets);
}
After reflecting the code I realized that this all change does not matter at all because number format information is based on locale information which is provided by the Zend core API.
So here is the solution I found and hopefully price formatting will be standard for the entire application this way.
You find your YY.xml file in lib/Zend/Locale/Data/, where YY is your countries locale code. Mine is hu.xml
You find the part:
<currencyFormats>
<currencyFormatLength>
<currencyFormat>
<pattern>#,##0 ¤</pattern>
</currencyFormat>
</currencyFormatLength>
<unitPattern count="other">{0} {1}</unitPattern>
</currencyFormats>
About the format string you can find a not-at-all useful information at http://framework.zend.com/manual/en/zend.locale.parsing.html
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将“app/code/core/Mage/Directory/Model/Currency.php”复制到“app/code/local/Mage/Directory/Model/Currency.php”并替换格式函数。
Copy "app/code/core/Mage/Directory/Model/Currency.php" to "app/code/local/Mage/Directory/Model/Currency.php" and replace the format function.