OrderGridUpdater.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Signifyd\Model\SalesOrderGrid;
  7. use Magento\Framework\App\Config\ScopeConfigInterface;
  8. use Magento\Sales\Model\ResourceModel\GridInterface;
  9. /**
  10. * Perfoms sales order grid updating operations.
  11. *
  12. * Serves order grid updates in both synchronous and asynchronous modes.
  13. */
  14. class OrderGridUpdater
  15. {
  16. /**
  17. * @var ScopeConfigInterface
  18. */
  19. private $globalConfig;
  20. /**
  21. * @var GridInterface
  22. */
  23. private $entityGrid;
  24. /**
  25. * @param GridInterface $entityGrid
  26. * @param ScopeConfigInterface $globalConfig
  27. */
  28. public function __construct(
  29. GridInterface $entityGrid,
  30. ScopeConfigInterface $globalConfig
  31. ) {
  32. $this->globalConfig = $globalConfig;
  33. $this->entityGrid = $entityGrid;
  34. }
  35. /**
  36. * Handles synchronous updating order entity in grid.
  37. *
  38. * Works only if asynchronous grid indexing is disabled
  39. * in global settings.
  40. *
  41. * @param int $orderId
  42. * @return void
  43. */
  44. public function update($orderId)
  45. {
  46. if (!$this->globalConfig->getValue('dev/grid/async_indexing')) {
  47. $this->entityGrid->refresh($orderId);
  48. }
  49. }
  50. }