Collection.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Sales\Model\ResourceModel\Transaction\Grid;
  7. /**
  8. * @SuppressWarnings(PHPMD.DepthOfInheritance)
  9. */
  10. class Collection extends \Magento\Sales\Model\ResourceModel\Order\Payment\Transaction\Collection
  11. {
  12. /**
  13. * Core registry
  14. *
  15. * @var \Magento\Framework\Registry
  16. */
  17. protected $registryManager = null;
  18. /**
  19. * @param \Magento\Framework\Data\Collection\EntityFactory $entityFactory
  20. * @param \Psr\Log\LoggerInterface $logger
  21. * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy
  22. * @param \Magento\Framework\Event\ManagerInterface $eventManager
  23. * @param \Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot $entitySnapshot
  24. * @param \Magento\Framework\Registry $registryManager
  25. * @param \Magento\Framework\DB\Adapter\AdapterInterface|null $connection
  26. * @param \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource
  27. */
  28. public function __construct(
  29. \Magento\Framework\Data\Collection\EntityFactory $entityFactory,
  30. \Psr\Log\LoggerInterface $logger,
  31. \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy,
  32. \Magento\Framework\Event\ManagerInterface $eventManager,
  33. \Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot $entitySnapshot,
  34. \Magento\Framework\Registry $registryManager,
  35. \Magento\Framework\DB\Adapter\AdapterInterface $connection = null,
  36. \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null
  37. ) {
  38. $this->registryManager = $registryManager;
  39. parent::__construct(
  40. $entityFactory,
  41. $logger,
  42. $fetchStrategy,
  43. $eventManager,
  44. $entitySnapshot,
  45. $connection,
  46. $resource
  47. );
  48. }
  49. /**
  50. * Resource initialization
  51. *
  52. * @return $this
  53. */
  54. protected function _initSelect()
  55. {
  56. parent::_initSelect();
  57. $order = $this->registryManager->registry('current_order');
  58. if ($order) {
  59. $this->addOrderIdFilter($order->getId());
  60. }
  61. $this->addOrderInformation(['increment_id']);
  62. $this->addPaymentInformation(['method']);
  63. return $this;
  64. }
  65. }