降低产品价格的准确性


10

正如我在标题中所述,我想从价格(.00)中删除精度

我做了这些:

  1. app / code / core / Mage / Directory / Model / Currency.php中

public function format()

我变了

 return $this->formatPrecision($price, 2, $options, $includeContainer, $addBrackets);

 return $this->formatPrecision($price, 0, $options, $includeContainer, $addBrackets);
  1. /app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Price.php中

public function getEscapedValue()

我变了

 return number_format($value, 2, null, '');

 return number_format($value, 0, null, '');
  1. js / varien / js.js中

我变了

var precision = isNaN(format.precision = Math.abs(format.precision)) ? 2 : format.precision;
var requiredPrecision = isNaN(format.requiredPrecision = Math.abs(format.requiredPrecision)) ? 2 : format.requiredPrecision;

var precision = 0;
var requiredPrecision = 0;
  1. 并在app / code / core / Mage / Core / Model / Store.php中

我变了

public function roundPrice($price)
    {
        return round($price, 2);
    }

 public function roundPrice($price)
    {
        return round($price, 0);
    }

然后我清除了缓存,并重新索引了Magento(即我的1.9版),但是精度并没有消除,我丢失了什么吗?我该怎么办?


始终超越核心课程
Beto Castillo

Answers:



4

旧问题,但实际上并没有一个程序化的正确答案。

$ _product是您的产品对象模型。

$price = ($_product->getFinalPrice() != 0) ? $_product->getFinalPrice()
            : $_product->getPrice();
        if ($round) {
            $store = Mage::app()->getStore(null);
            $currency = $store->getCurrentCurrency();
            return $currency->formatPrecision($price, 0, array(), true, false);
        }
        return Mage::helper('core')->currencyByStore($price)
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.