Skip to content

Commit b761ec3

Browse files
Merge pull request #8960 from magento-mercury/CEXT-3046
[Mercury Team] Error on api request to update product
2 parents a2e6fc9 + e55cff2 commit b761ec3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

app/code/Magento/Catalog/Model/Product.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1877,8 +1877,10 @@ public function toArray(array $arrAttributes = [])
18771877
{
18781878
$data = parent::toArray($arrAttributes);
18791879
$stock = $this->getStockItem();
1880-
if ($stock) {
1880+
if (is_object($stock) && method_exists($stock, 'toArray')) {
18811881
$data['stock_item'] = $stock->toArray();
1882+
} elseif (is_array($stock)) {
1883+
$data['stock_item'] = $stock;
18821884
}
18831885
unset($data['stock_item']['product']);
18841886
return $data;

0 commit comments

Comments
 (0)