SourceIndexer.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. declare(strict_types=1);
  7. namespace Magento\InventoryIndexer\Indexer\Source;
  8. use Magento\InventoryIndexer\Indexer\Stock\StockIndexer;
  9. /**
  10. * Source indexer
  11. *
  12. * @api
  13. */
  14. class SourceIndexer
  15. {
  16. /**
  17. * @var GetAssignedStockIds
  18. */
  19. private $getAssignedStockIds;
  20. /**
  21. * @var StockIndexer
  22. */
  23. private $stockIndexer;
  24. /**
  25. * @param GetAssignedStockIds $getAssignedStockIds
  26. * @param StockIndexer $stockIndexer
  27. */
  28. public function __construct(
  29. GetAssignedStockIds $getAssignedStockIds,
  30. StockIndexer $stockIndexer
  31. ) {
  32. $this->getAssignedStockIds = $getAssignedStockIds;
  33. $this->stockIndexer = $stockIndexer;
  34. }
  35. /**
  36. * @return void
  37. */
  38. public function executeFull()
  39. {
  40. $this->stockIndexer->executeFull();
  41. }
  42. /**
  43. * @param string $sourceCode
  44. * @return void
  45. */
  46. public function executeRow(string $sourceCode)
  47. {
  48. $this->executeList([$sourceCode]);
  49. }
  50. /**
  51. * @param array $sourceCodes
  52. */
  53. public function executeList(array $sourceCodes)
  54. {
  55. $stockIds = $this->getAssignedStockIds->execute($sourceCodes);
  56. $this->stockIndexer->executeList($stockIds);
  57. }
  58. }