Collection.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Sales\Model\ResourceModel\Order\Payment;
  7. use Magento\Sales\Api\Data\OrderPaymentSearchResultInterface;
  8. use Magento\Sales\Model\ResourceModel\Order\Collection\AbstractCollection;
  9. /**
  10. * Flat sales order payment collection
  11. */
  12. class Collection extends AbstractCollection implements OrderPaymentSearchResultInterface
  13. {
  14. /**
  15. * Event prefix
  16. *
  17. * @var string
  18. */
  19. protected $_eventPrefix = 'sales_order_payment_collection';
  20. /**
  21. * Event object
  22. *
  23. * @var string
  24. */
  25. protected $_eventObject = 'order_payment_collection';
  26. /**
  27. * @param \Magento\Framework\Data\Collection\EntityFactory $entityFactory
  28. * @param \Psr\Log\LoggerInterface $logger
  29. * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy
  30. * @param \Magento\Framework\Event\ManagerInterface $eventManager
  31. * @param \Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot $entitySnapshot
  32. * @param \Magento\Framework\DB\Adapter\AdapterInterface $connection
  33. * @param \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource
  34. */
  35. public function __construct(
  36. \Magento\Framework\Data\Collection\EntityFactory $entityFactory,
  37. \Psr\Log\LoggerInterface $logger,
  38. \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy,
  39. \Magento\Framework\Event\ManagerInterface $eventManager,
  40. \Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot $entitySnapshot,
  41. \Magento\Framework\DB\Adapter\AdapterInterface $connection = null,
  42. \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null
  43. ) {
  44. parent::__construct(
  45. $entityFactory,
  46. $logger,
  47. $fetchStrategy,
  48. $eventManager,
  49. $entitySnapshot,
  50. $connection,
  51. $resource
  52. );
  53. }
  54. /**
  55. * Model initialization\
  56. *
  57. * @return void
  58. */
  59. protected function _construct()
  60. {
  61. $this->_init(
  62. \Magento\Sales\Model\Order\Payment::class,
  63. \Magento\Sales\Model\ResourceModel\Order\Payment::class
  64. );
  65. }
  66. /**
  67. * Unserialize additional_information in each item
  68. *
  69. * @return $this
  70. */
  71. protected function _afterLoad()
  72. {
  73. foreach ($this->_items as $item) {
  74. $this->getResource()->unserializeFields($item);
  75. }
  76. return parent::_afterLoad();
  77. }
  78. }