public function orderPushRepeat() { /** @var \Praxigento\Odoo\Api\Data\SaleOrder\PushRepeat\Report $result */ $result = $this->_manObj->create(\Praxigento\Odoo\Api\Data\SaleOrder\PushRepeat\Report::class); $orders = $this->_collector->getOrdersToReplicate(); $entries = []; foreach ($orders as $order) { /** @var \Praxigento\Odoo\Service\Replicate\Request\OrderSave $req */ $req = $this->_manObj->create(\Praxigento\Odoo\Service\Replicate\Request\OrderSave::class); $req->setSaleOrder($order); /** @var \Praxigento\Odoo\Service\Replicate\Response\OrderSave $resp */ $resp = $this->_callReplicate->orderSave($req); $respOdoo = $resp->getOdooResponse(); /** @var \Praxigento\Odoo\Api\Data\SaleOrder\PushRepeat\Report\Entry $reportEntry */ $reportEntry = $this->_manObj->create(\Praxigento\Odoo\Api\Data\SaleOrder\PushRepeat\Report\Entry::class); $id = $order->getEntityId(); $number = $order->getIncrementId(); $reportEntry->setIdMage($id); $reportEntry->setNumber($number); if ($respOdoo instanceof \Praxigento\Odoo\Data\Odoo\Error) { $reportEntry->setIsSucceed(false); $debug = $respOdoo->getDebug(); $name = $respOdoo->getName(); $reportEntry->setDebug($debug); $reportEntry->setErrorName($name); } else { $reportEntry->setIsSucceed(true); } $entries[] = $reportEntry; } $result->setEntries($entries); return $result; }
public function test_orderSave() { $req = new Request\OrderSave(); /* load Magento order */ $mageOrder = $this->_mageRepoSaleOrder->get(70); $req->setSaleOrder($mageOrder); $resp = $this->obj->orderSave($req); $this->assertNotNull($resp); }
/** @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; }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { /* parse arguments */ $argIds = $input->getArgument(static::ARG_IDS); if (is_null($argIds)) { $ids = null; $output->writeln('<info>List of all products will be pulled from Odoo.<info>'); } else { $ids = explode(',', $argIds); $output->writeln("<info>Products with Odoo IDs ({$argIds}) will be pulled from Odoo.<info>"); } /* setup session */ $this->_setAreaCode(); /* call service operation */ /** @var ProductsFromOdooRequest $req */ $req = $this->_manObj->create(ProductsFromOdooRequest::class); $req->setOdooIds($ids); /** @var ProductsFromOdooResponse $resp */ $resp = $this->_callReplicate->productsFromOdoo($req); if ($resp->isSucceed()) { $output->writeln('<info>Replication is done.<info>'); } else { $output->writeln('<info>Replication is failed.<info>'); } }
public function execute(\Magento\Framework\Event\Observer $observer) { /** @var \Magento\Sales\Model\Order $order */ $order = $observer->getData(self::DATA_ORDER); $state = $order->getState(); if ($state == \Magento\Sales\Model\Order::STATE_PROCESSING) { try { $this->_logger->debug("Call to Odoo service to replicate order."); $req = new \Praxigento\Odoo\Service\Replicate\Request\OrderSave(); $req->setSaleOrder($order); $this->_callReplicate->orderSave($req); } catch (\Exception $e) { /* catch all exceptions and steal them */ $msg = 'Some error is occurred on sale order saving to Odoo. Error: ' . $e->getMessage(); $this->_logger->error($msg); } } }
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); } }