language = $language; $this->settingsRepository = new \MarketplaceRepository\SettingsRepository($db, $shop); } public function sync() { if(isset($_POST['fsync_datatype'])) { switch($_POST['fsync_datatype']) { case 'product': $result = $this->syncProduct();break; case 'order': $result = $this->syncOrderOrProforma();break; case 'stock': $result = $this->syncStock();break; default: $result = '';break; } } else { $result = ''; } return $result; } public function syncProduct() { $controller = new \Controller\ProductController( $this->settingsRepository ); $controller->sync(); return $this->language->get('success_sync_prod'); } public function syncOrderOrProforma() { $controller = new \Controller\OrderOrProformaController( $this->settingsRepository ); $response = $controller->sync(); if($response == \Core\App\Factory\SettingsFactory::SELECT_ORDER) { return $this->language->get('success_sync_order'); } if($response == \Core\App\Factory\SettingsFactory::SELECT_PROFORMA) { return $this->language->get('success_sync_proforma'); } } public function syncStock() { $controller = new \Controller\StockController( $this->settingsRepository ); $controller->sync(); return $this->language->get('success_sync_stock'); } public function autoSync() { $orderController = new \Controller\OrderOrProformaController( $this->settingsRepository ); $stockController = new \Controller\StockController( $this->settingsRepository ); $orderController->autoSync(); $stockController->autoSync(); } }