Пример #1
0
 /**
  * @param null|int|string $index
  * @return null|string
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function getEscapedValue($index = null)
 {
     $value = $this->getValue();
     if (!is_numeric($value)) {
         return null;
     }
     if ($this->getEntityAttribute()) {
         $format = $this->localeFormat->getPriceFormat();
         $value = number_format($value, $format['precision'], $format['decimalSymbol'], $format['groupSymbol']);
     } else {
         // default format:  1234.56
         $value = number_format($value, 2, null, '');
     }
     return $value;
 }
Пример #2
0
 /**
  * @param null|int|string $index
  * @return null|string
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function getEscapedValue($index = null)
 {
     $values = $this->getValue();
     if (!is_array($values)) {
         return null;
     }
     foreach ($values as $key => $value) {
         if ($this->getEntityAttribute()) {
             $format = $this->localeFormat->getPriceFormat();
             $values[$key]['value'] = number_format($value['value'], $format['precision'], $format['decimalSymbol'], $format['groupSymbol']);
         } else {
             // default format:  1234.56
             $values[$key]['value'] = number_format($value['value'], 2, null, '');
         }
     }
     return $values;
 }
 /**
  * Remove comma from price on JPY
  *
  * @param \Magento\Framework\Locale\Format $subject
  * @param $value
  * @return array
  */
 public function beforeGetNumber(Format $subject, $value)
 {
     $currency = $this->_scopeResolver->getScope()->getCurrentCurrency();
     $locale = $this->_localeResolver->getLocale();
     $format = $subject->getPriceFormat($locale, $currency->getCode());
     if ($currency->getCode() == 'JPY') {
         if ($format['groupSymbol'] == '.') {
             $value = preg_replace('/\\./', '', $value);
             $value = preg_replace('/,/', '.', $value);
         } else {
             $value = preg_replace('/,/', '', $value);
         }
     }
     return [$value];
 }