'2014/06/12'에 해당되는 글 1건

  1. 2014.06.12 [magento] 마젠토 금액표시 변경, 금액 소수점 없애기
Magento2014. 6. 12. 02:13

마젠토 관련해서 수정하다가 한국에선 검색어가 너무 없어 포스팅한다.


구글링해보면 PHP를 수정하는 방법에 대해서는 무수히 나오는데..


1) /app/code/core/Mage/Core/Model/Store.php


public function roundPrice($price)

{

//return round($price, 2); 

return round($price0);    //변경

}



2) /lib/Zend/Currency.php


protected $_options = array(

'position'  => self::STANDARD,

      'script'    => null,

      'format'    => null,

      'display'   => self::NO_SYMBOL,

      //'precision' => 2,

      'precision' => 0,    //변경

      'name'      => null,

      'currency'  => null,

      'symbol'    => null,

      'locale'    => null,

      'value'     => 0,

      'service'   => null,

      'tag'       => 'Zend_Locale'

);



3) /app/code/core/Mage/Directory/Model/Currency.php


public function format($price, $options = array(), $includeContainer = true, $addBrackets = false)

{

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

return $this->formatPrecision($price, 0$options$includeContainer$addBrackets);    //변경

}


4) /app/code/core/Mage/Core/Helper/Data.php


public function formatPrice($price, $includeContainer = true)

{

//return Mage::app()->getStore()->formatPrice($price, $includeContainer);

$temp = Mage::app()->getStore()->formatPrice($price$includeContainer); //변경

return preg_replace("/.00/","",$temp); //쓸모없는짓임.. ;;

}



등등 가지가지 방법들이 아주 많다. 그런데 사실 위의 모든 부분을 변경해보면 알겠지만 의미가 없다..


PHP에서 변수를 변경해서 뿌려보면 알겠지만 결국엔 생성된 값뒤에 .00 가 붙게된다.



문제는 결국 화면에 뿌려지기 직전(아직 어느단계가 마지막인지 모르겠다..OTL), 또는 화면에 뿌려지면서 추가되는것으로 보여진다.


그렇게 최종 변경한 방법은 아래와 같다.


5) /lib/Zend/Locale/Data/ko.xml


currencyFormats > currencyFormatLength > currencyFormat > pattern > ¤#,##0.00 부분에서 .00 만 빼주면 된다.

(역시 화면에 뿌려질때였다.)


<currencyFormats>

<currencyFormatLength>

<currencyFormat>

<pattern>¤#,##0</pattern>

</currencyFormat>

</currencyFormatLength>

<unitPattern count="other">{0} {1}</unitPattern>

</currencyFormats>




결과적으론 5)/lib/Zend/Locale/Data/ko.xml 만 수정해도 소수점을 삭제 할 수 있다.

다만, 서비스시 문제가 발생하지 않는지 의문이 든다.(PHP수정을 함께 한다면 단편적인 문제는 없을것같다는 생각이 들지만.. 오버라이딩을 하지 않았을때의 문제는 아직 하나도 모르겠다.- 오버라이딩 방법도..OTL )


이 부분에 대해서는 좀더 확인 후 추가 하도록 하자.








Posted by E.No