Collection.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace Dotdigitalgroup\Email\Model\ResourceModel\Review;
  3. class Collection extends
  4. \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
  5. {
  6. /**
  7. * @var string
  8. */
  9. protected $_idFieldName = 'id';
  10. /**
  11. * Initialize resource collection.
  12. *
  13. * @return null
  14. */
  15. public function _construct()
  16. {
  17. $this->_init(
  18. \Dotdigitalgroup\Email\Model\Review::class,
  19. \Dotdigitalgroup\Email\Model\ResourceModel\Review::class
  20. );
  21. }
  22. /**
  23. * Get reviews for export.
  24. *
  25. * @param \Magento\Store\Model\Website $website
  26. * @param int $limit
  27. *
  28. * @return $this
  29. */
  30. public function getReviewsToExportByWebsite(\Magento\Store\Model\Website $website, $limit = 100)
  31. {
  32. return $this->addFieldToFilter('review_imported', ['null' => 'true'])
  33. ->addFieldToFilter(
  34. 'store_id',
  35. ['in' => $website->getStoreIds()]
  36. )
  37. ->setPageSize($limit);
  38. }
  39. }