NotSyncedOrderIdListProvider.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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\Sales\Model\ResourceModel\Provider\NotSyncedDataProviderInterface;
  8. use Magento\Signifyd\Model\ResourceModel;
  9. use Magento\Signifyd\Model\ResourceModel\CaseEntity;
  10. /**
  11. * Provides order ids list which Signifyd Case guaranty status were changed
  12. */
  13. class NotSyncedOrderIdListProvider implements NotSyncedDataProviderInterface
  14. {
  15. /**
  16. * @var ResourceModel\CaseEntity
  17. */
  18. private $caseEntity;
  19. /**
  20. * @param ResourceModel\CaseEntity $caseEntity
  21. */
  22. public function __construct(
  23. CaseEntity $caseEntity
  24. ) {
  25. $this->caseEntity = $caseEntity;
  26. }
  27. /**
  28. * @inheritdoc
  29. */
  30. public function getIds($mainTableName, $gridTableName)
  31. {
  32. $connection = $this->caseEntity->getConnection();
  33. $select = $connection->select()
  34. ->from($this->caseEntity->getMainTable(), ['order_id'])
  35. ->joinLeft(
  36. [$gridTableName => $connection->getTableName($gridTableName)],
  37. sprintf(
  38. '%s.%s = %s.%s',
  39. $this->caseEntity->getMainTable(),
  40. 'order_id',
  41. $gridTableName,
  42. 'entity_id'
  43. ),
  44. []
  45. )
  46. ->where('guarantee_disposition != signifyd_guarantee_status');
  47. return $connection->fetchAll($select, [], \Zend_Db::FETCH_COLUMN);
  48. }
  49. }