Collection.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Review\Model\ResourceModel\Review\Summary;
  7. /**
  8. * Review summery collection
  9. *
  10. * @author Magento Core Team <core@magentocommerce.com>
  11. */
  12. class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
  13. {
  14. /**
  15. * {@inheritdoc}
  16. */
  17. protected function _construct()
  18. {
  19. $this->_init(
  20. \Magento\Review\Model\Review\Summary::class,
  21. \Magento\Review\Model\ResourceModel\Review\Summary::class
  22. );
  23. }
  24. /**
  25. * Add entity filter
  26. *
  27. * @param int|string $entityId
  28. * @param int $entityType
  29. * @return $this
  30. */
  31. public function addEntityFilter($entityId, $entityType = 1)
  32. {
  33. $this->_select->where('entity_pk_value IN(?)', $entityId)->where('entity_type = ?', $entityType);
  34. return $this;
  35. }
  36. /**
  37. * Add store filter
  38. *
  39. * @param int $storeId
  40. * @return $this
  41. */
  42. public function addStoreFilter($storeId)
  43. {
  44. $this->_select->where('store_id = ?', $storeId);
  45. return $this;
  46. }
  47. }