如何删除Magento-1价格的小数? [英] How To Remove Decimal From Magento-1 Prices?
问题描述
我在搜索中发现的所有内容都是为此提供的编程解决方案. 我知道我们可以为英语商店修改/lib/Zend/Locale/Data/en.xml. en.xml中有这部分:
all I found in my search is a programming solution for this. I know that we can modify /lib/Zend/Locale/Data/en.xml for english stores. there was in en.xml this part:
<currencyFormats>
<currencyFormatLength>
<currencyFormat>
<pattern>#,##0.00 ¤</pattern>
</currencyFormat>
</currencyFormatLength>
</currencyFormats>
价格以以下格式显示:1,321.54 现在要从价格中删除小数部分,我认为我唯一要做的就是更改en.xml,如下所示:
And the price was displaying in this format: 1,321.54 now to remove the decimal part from price I think the only thing I have to do is change en.xml to be like the following:
<currencyFormats>
<currencyFormatLength>
<currencyFormat>
<pattern>#,##0 ¤</pattern>
</currencyFormat>
</currencyFormatLength>
</currencyFormats>
问题是在此更改之后,价格将按需要显示(1,132格式),但没有货币符号($). 我在这里想念的是什么? 预先感谢.
The problem is after this change the prices are show as desired (1,132 Format) but without currency symbol ($). what I'm missing here?? Thanks in advance.
更新 我仍在尝试将 模式 节点更改为以下
update I'm still trying, when pattern node changed to the following
<pattern>¤ #,##0</pattern>
价格带有货币符号($ 1,132),但不在期望的位置O_O,要求在右侧没有左侧的货币符号:( SO ..
the prices are coming with currency symbol ($ 1,132) but not in desired position O_O, the requirement is to have currency symbol on the right side no left :( SO..
推荐答案
要更改magento中的价格精度,您需要覆盖一些核心文件.
In order to change price precision in magento you would need to overwrite some core files.
在下面的示例中,我们将精度更改为0.
In the example below we are changing precision to 0.
1):覆盖lib/Zend/Currency.php并更改精度:
1) Overwrite lib/Zend/Currency.php and change precision around line:
69 protected $_options = array(
70 'position' => self::STANDARD,
71 'script' => null,
72 'format' => null,
73 'display' => self::NO_SYMBOL,
74 'precision' => 0, /*CHANGE*/
75 'name' => null,
76 'currency' => null,
77 'symbol' => null,
78 'locale' => null,
79 'value' => 0,
80 'service' => null,
81 'tag' => 'Zend_Locale'
82 );
2)覆盖app/code/core/Mage/Core/Model/Store.php并更改roundPrice函数:
2) overwrite app/code/core/Mage/Core/Model/Store.php and change roundPrice function:
public function roundPrice($price)
{
return round($price, 4);
}
3)覆盖app/code/core/Mage/Directory/Model/Currency.php并更改格式功能:
3) overwrite app/code/core/Mage/Directory/Model/Currency.php and change format function:
public function format($price,
$options=array(),
$includeContainer = true,
$addBrackets = false)
{
return $this->formatPrecision( $price,
4,
$options,
$includeContainer,
$addBrackets);
}
这篇关于如何删除Magento-1价格的小数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!