protected function parseAttributes($data) { if (property_exists($data, 'attributes')) { $data = $data->attributes; } if (property_exists($data, 'product_id')) { $data->id = $data->product_id; } return $data; }