_localeCurrency = $localeCurrency; } /** * Renders grid column * * @param \Magento\Framework\DataObject $row * @return string */ public function render(\Magento\Framework\DataObject $row) { if ($data = $this->_getValue($row)) { $currencyCode = $this->_getCurrencyCode($row); if (!$currencyCode) { return $data; } $data = (float)$data * $this->_getRate($row); $data = sprintf("%f", $data); $data = $this->_localeCurrency->getCurrency($currencyCode)->toCurrency($data); return $data; } return $this->getColumn()->getDefault(); } /** * Returns currency code for the row, false on error * * @param \Magento\Framework\DataObject $row * @return string|false */ protected function _getCurrencyCode($row) { if ($code = $this->getColumn()->getCurrencyCode()) { return $code; } if ($code = $row->getData($this->getColumn()->getCurrency())) { return $code; } return false; } /** * Returns rate for the row, 1 by default * * @param \Magento\Framework\DataObject $row * @return float|int */ protected function _getRate($row) { if ($rate = $this->getColumn()->getRate()) { return (float)$rate; } if ($rate = $row->getData($this->getColumn()->getRateField())) { return (float)$rate; } return 1; } /** * Renders CSS * * @return string */ public function renderCss() { return parent::renderCss() . ' col-price'; } }