Skip to content

Commit df3c973

Browse files
committed
Merge remote-tracking branch 'andrew/fixes-for-data-object-part2' into ph-delivery
2 parents 1f6be8c + 141fa48 commit df3c973

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Currency.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,9 @@ protected function _getCurrencyCode($row)
102102
if ($code = $this->getColumn()->getCurrencyCode()) {
103103
return $code;
104104
}
105-
if ($code = $row->getData($this->getColumn()->getCurrency())) {
105+
$currency = $this->getColumn()->getCurrency();
106+
107+
if ($currency !== null && $code = $row->getData($currency)) {
106108
return $code;
107109
}
108110

app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Price.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function render(\Magento\Framework\DataObject $row)
6060
return $data;
6161
}
6262

63-
$data = (float)$data * $this->_getRate($row);
63+
$data = (float) $data * $this->_getRate($row);
6464
$data = sprintf("%f", $data);
6565
$data = $this->_localeCurrency->getCurrency($currencyCode)->toCurrency($data);
6666
return $data;
@@ -79,7 +79,9 @@ protected function _getCurrencyCode($row)
7979
if ($code = $this->getColumn()->getCurrencyCode()) {
8080
return $code;
8181
}
82-
if ($code = $row->getData($this->getColumn()->getCurrency())) {
82+
$currency = $this->getColumn()->getCurrency();
83+
84+
if ($currency !== null && $code = $row->getData($currency)) {
8385
return $code;
8486
}
8587
return false;
@@ -94,10 +96,12 @@ protected function _getCurrencyCode($row)
9496
protected function _getRate($row)
9597
{
9698
if ($rate = $this->getColumn()->getRate()) {
97-
return (float)$rate;
99+
return (float) $rate;
98100
}
99-
if ($rate = $row->getData($this->getColumn()->getRateField())) {
100-
return (float)$rate;
101+
$rateField = $this->getColumn()->getRateField();
102+
103+
if ($rateField !== null && $rate = $row->getData($rateField)) {
104+
return (float) $rate;
101105
}
102106
return 1;
103107
}

lib/internal/Magento/Framework/DataObject.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,8 @@ public function toString($format = '')
368368
} else {
369369
preg_match_all('/\{\{([a-z0-9_]+)\}\}/is', $format, $matches);
370370
foreach ($matches[1] as $var) {
371-
$format = str_replace('{{' . $var . '}}', $this->getData($var), $format);
371+
$data = $this->getData($var) ?? '';
372+
$format = str_replace('{{' . $var . '}}', $data, $format);
372373
}
373374
$result = $format;
374375
}

0 commit comments

Comments
 (0)