Collection.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace Smartwave\Dailydeals\Model\ResourceModel\Dailydeal;
  3. class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
  4. {
  5. /**
  6. * ID Field Name
  7. *
  8. * @var string
  9. */
  10. protected $_idFieldName = 'dailydeal_id';
  11. /**
  12. * Event prefix
  13. *
  14. * @var string
  15. */
  16. protected $_eventPrefix = 'sw_dailydeals_dailydeal_collection';
  17. /**
  18. * Event object
  19. *
  20. * @var string
  21. */
  22. protected $_eventObject = 'dailydeal_collection';
  23. /**
  24. * Define resource model
  25. *
  26. * @return void
  27. */
  28. protected function _construct()
  29. {
  30. $this->_init('Smartwave\Dailydeals\Model\Dailydeal', 'Smartwave\Dailydeals\Model\ResourceModel\Dailydeal');
  31. }
  32. /**
  33. * Get SQL for get record count.
  34. * Extra GROUP BY strip added.
  35. *
  36. * @return \Magento\Framework\DB\Select
  37. */
  38. public function getSelectCountSql()
  39. {
  40. $countSelect = parent::getSelectCountSql();
  41. $countSelect->reset(\Zend_Db_Select::GROUP);
  42. return $countSelect;
  43. }
  44. /**
  45. * @param string $valueField
  46. * @param string $labelField
  47. * @param array $additional
  48. * @return array
  49. */
  50. protected function _toOptionArray($valueField = 'dailydeal_id', $labelField = 'sw_product_sku', $additional = [])
  51. {
  52. return parent::_toOptionArray($valueField, $labelField, $additional);
  53. }
  54. }