Collection.php 995 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Downloadable\Model\ResourceModel\Link\Purchased;
  7. /**
  8. * Downloadable links purchased resource collection
  9. *
  10. * @api
  11. * @since 100.0.2
  12. */
  13. class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
  14. {
  15. /**
  16. * Init resource model
  17. *
  18. * @return void
  19. */
  20. protected function _construct()
  21. {
  22. $this->_init(
  23. \Magento\Downloadable\Model\Link\Purchased::class,
  24. \Magento\Downloadable\Model\ResourceModel\Link\Purchased::class
  25. );
  26. }
  27. /**
  28. * Add purchased items to collection
  29. *
  30. * @return $this
  31. */
  32. public function addPurchasedItemsToResult()
  33. {
  34. $this->getSelect()->join(
  35. ['pi' => $this->getTable('downloadable_link_purchased_item')],
  36. 'pi.purchased_id=main_table.purchased_id'
  37. );
  38. return $this;
  39. }
  40. }