Collection.php 2.4 KB

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