/** @inheritdoc */ public function get($ids = null) { /* prepare request parameters */ if (is_array($ids)) { $params = [self::ODOO_IDS => $ids]; } elseif (is_int($ids)) { $params = [self::ODOO_IDS => [$ids]]; } else { $params = [self::ODOO_IDS => []]; } /* perform request and extract result data */ $cover = $this->_rest->request($params, self::ROUTE); $data = $cover->getResultData(); $result = $this->_mageSrvInProc->convertValue($data, \Praxigento\Odoo\Data\Odoo\Inventory::class); return $result; }
public function save($order) { /* prepare request parameters */ $underscored = $order->getData(null, true); /* perform request and extract result data */ $cover = $this->_rest->request($underscored, self::ROUTE); $data = $cover->getResultData(); if ($data) { $result = $this->_mageSrvInProc->convertValue($data, \Praxigento\Odoo\Data\Odoo\SaleOrder\Response::class); } else { $error = $cover->getError(); $result = $this->_mageSrvInProc->convertValue($error, \Praxigento\Odoo\Data\Odoo\Error::class); /** TODO : delete tmp code (cannot use getData as getter for property) */ $debug = $error['data']['debug']; $name = $error['data']['name']; $result->setDebug($debug); $result->setName($name); } return $result; }
protected function execute(\Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output) { /* load JSON data */ $fileData = file_get_contents(__DIR__ . '/data.json'); $jsonData = json_decode($fileData, true); $bundle = $this->_serviceInputProcessor->convertValue($jsonData['data'], \Praxigento\Odoo\Data\Odoo\Inventory::class); $def = $this->_manTrans->begin(); try { /* create products using replication */ /** @var ProductSaveRequest $req */ $req = $this->_manObj->create(ProductSaveRequest::class); $req->setProductBundle($bundle); $this->_callReplicate->productSave($req); /* enable categories after replication */ $this->_subCats->enableForAllStoreViews(); $this->_manTrans->commit($def); } finally { // transaction will be rolled back if commit is not done (otherwise - do nothing) $this->_manTrans->end($def); } }