Skip to content

Commit 2f79a06

Browse files
committed
Error on api request to update product
1 parent af9ab20 commit 2f79a06

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
@@ -1886,8 +1886,10 @@ public function toArray(array $arrAttributes = [])
18861886
{
18871887
$data = parent::toArray($arrAttributes);
18881888
$stock = $this->getStockItem();
1889-
if ($stock) {
1889+
if (is_object($stock) && method_exists($stock, 'toArray')) {
18901890
$data['stock_item'] = $stock->toArray();
1891+
} elseif (is_array($stock)) {
1892+
$data['stock_item'] = $stock;
18911893
}
18921894
unset($data['stock_item']['product']);
18931895
return $data;

0 commit comments

Comments
 (0)