StockService.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace Core\App\Service;
  3. class StockService{
  4. protected $marketplaceStockRepository;
  5. protected $facturisStockRepository;
  6. protected $settingsRepository;
  7. protected $marketplaceProductRepository;
  8. public function __construct(
  9. \Core\App\Repository\Marketplace\StockInterface $marketplaceStockRepository,
  10. \Core\App\Repository\Marketplace\ProductInterface $marketplaceProductRepository,
  11. \Core\App\Repository\Facturis\StockInterface $facturisStockRepository,
  12. \Core\App\Repository\Marketplace\SettingsInterface $settingsRepository
  13. )
  14. {
  15. $this->marketplaceStockRepository = $marketplaceStockRepository;
  16. $this->marketplaceProductRepository = $marketplaceProductRepository;
  17. $this->facturisStockRepository = $facturisStockRepository;
  18. $this->settingsRepository = $settingsRepository;
  19. }
  20. public function sync() {
  21. $this->facturisStockRepository->setOptionStockFilter($this->settingsRepository->getOptionStockFilter());
  22. $this->facturisStockRepository->setLocalProducts($this->marketplaceProductRepository->getAll());
  23. $facturisStock = $this->facturisStockRepository->getAll();
  24. $this->marketplaceStockRepository->setStockLocations($this->settingsRepository->getOptionLocations());
  25. $this->marketplaceStockRepository->setLocalProducts($this->marketplaceProductRepository->getAll());
  26. $this->marketplaceStockRepository->update($facturisStock);
  27. }
  28. }