/** * Renders the object to array * * @param array $arrAttributes Attribute array * @return array */ public function toArray(array $arrAttributes = []) { $data = parent::toArray($arrAttributes); $stock = $this->getStockItem(); if ($stock) { $data['stock_item'] = $stock->toArray(); } unset($data['stock_item']['product']); return $data; }