sreichel/magento-StackExchange_4DigitPrice

View on GitHub
src/app/code/community/StackExchange/4DigitPrice/Adminhtml/Block/Catalog/Product/Helper/Form/Price.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php
/**
 * StackExchange-Module
 *
 * @author      Sven Reichel <github-sr@hotmail.com>
 * @category    StackExchange
 * @package     StackExchange_4DigitPrice
 */
 
/**
 * Rewrite of Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Price
 */
class StackExchange_4DigitPrice_Adminhtml_Block_Catalog_Product_Helper_Form_Price extends Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Price
{
    /**
     * Get price with 4 digits
     *
     * Rewrite: original methode shows only 2
     *
     * @param  null $index
     * @return string $value product price
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
     */
    public function getEscapedValue($index = null): ?string
    {
        $value = $this->getValue();
        if (!is_numeric($value)) {
            return null;
        }
        return number_format($value, 4, null, '');
    }
}