/** @inheritdoc */ public function save(\Praxigento\Odoo\Data\Odoo\Inventory $data) { /** @var $req \Praxigento\Odoo\Service\Replicate\Request\ProductSave */ $req = $this->manObj->create(\Praxigento\Odoo\Service\Replicate\Request\ProductSave::class); $req->setProductBundle($data); $resp = $this->_callOdooReplicate->productSave($req); $result = $resp->isSucceed(); 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); } }