marketplaceProformaRepository = $marketplaceProformaRepository; $this->marketplaceProductRepository = $marketplaceProductRepository; $this->facturisProformaRepository = $facturisProformaRepository; $this->facturisCustomerRepository = $facturisCustomerRepository; $this->facturisProductRepository = $facturisProductRepository; $this->settingsRepository = $settingsRepository; } public function sync() { $facturisCustomers = $this->facturisCustomerRepository->getAll(); $facturisProducts = $this->facturisProductRepository->getAll(); $this->marketplaceProformaRepository->setRemoteCustomers($facturisCustomers); $this->marketplaceProformaRepository->setRemoteProducts($facturisProducts); $this->marketplaceProformaRepository->setOrderedDaysAgo($this->settingsRepository->getOptionOrderedDaysAgo()); $this->marketplaceProformaRepository->setProformaSerie($this->settingsRepository->getOptionProformaSerie()); $withOutDiscount = true; $marketplaceProducts = $this->marketplaceProductRepository->getAll($withOutDiscount); $this->marketplaceProformaRepository->setLocalProducts((array) $marketplaceProducts); $this->marketplaceProformaRepository->setWithDiscount($this->settingsRepository->getOptionWithDiscount()); $marketplaceProformas = $this->marketplaceProformaRepository->getAll(); if(!empty($marketplaceProformas)) { foreach($marketplaceProformas as $marketplaceProforma) { $result = $this->facturisProformaRepository->add($marketplaceProforma); //$this->marketplaceProformaRepository->addProforma($marketplaceProforma, $result); } } } public function add($orderId) { $result = array(); $facturisCustomers = $this->facturisCustomerRepository->getAll(); $facturisProducts = $this->facturisProductRepository->getAll(); $this->marketplaceProformaRepository->setRemoteCustomers($facturisCustomers); $this->marketplaceProformaRepository->setRemoteProducts($facturisProducts); $proformaSerie2 = $this->settingsRepository->getOptionProformaSerie2(); if (!empty($proformaSerie2)) { $this->marketplaceProformaRepository->setProformaSerie($proformaSerie2); } else { $this->marketplaceProformaRepository->setProformaSerie($this->settingsRepository->getOptionProformaSerie()); } $withOutDiscount = true; $marketplaceProducts = $this->marketplaceProductRepository->getAll($withOutDiscount); $this->marketplaceProformaRepository->setLocalProducts((array) $marketplaceProducts); $this->marketplaceProformaRepository->setWithDiscount($this->settingsRepository->getOptionWithDiscount()); $marketplaceProforma = $this->marketplaceProformaRepository->getByOrderId($orderId); if (!empty($marketplaceProforma)) { $result = $this->facturisProformaRepository->add($marketplaceProforma); $this->marketplaceProformaRepository->addProforma($marketplaceProforma, $result); return $result; } return $result; } }