We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 8838a9c + b761ec3 commit ef5588eCopy full SHA for ef5588e
app/code/Magento/Catalog/Model/Product.php
@@ -1877,8 +1877,10 @@ public function toArray(array $arrAttributes = [])
1877
{
1878
$data = parent::toArray($arrAttributes);
1879
$stock = $this->getStockItem();
1880
- if ($stock) {
+ if (is_object($stock) && method_exists($stock, 'toArray')) {
1881
$data['stock_item'] = $stock->toArray();
1882
+ } elseif (is_array($stock)) {
1883
+ $data['stock_item'] = $stock;
1884
}
1885
unset($data['stock_item']['product']);
1886
return $data;
0 commit comments