Collection.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Eav\Model\ResourceModel\Entity\Attribute\Group;
  7. /**
  8. * Eav attribute group 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 for collection
  17. *
  18. * @return void
  19. * @codeCoverageIgnore
  20. */
  21. protected function _construct()
  22. {
  23. $this->_init(
  24. \Magento\Eav\Model\Entity\Attribute\Group::class,
  25. \Magento\Eav\Model\ResourceModel\Entity\Attribute\Group::class
  26. );
  27. }
  28. /**
  29. * Set Attribute Set Filter
  30. *
  31. * @param int $setId
  32. * @return $this
  33. */
  34. public function setAttributeSetFilter($setId)
  35. {
  36. $this->addFieldToFilter('attribute_set_id', ['eq' => $setId]);
  37. $this->setOrder('sort_order');
  38. return $this;
  39. }
  40. /**
  41. * Set sort order
  42. *
  43. * @param string $direction
  44. * @return $this
  45. * @codeCoverageIgnore
  46. */
  47. public function setSortOrder($direction = self::SORT_ORDER_ASC)
  48. {
  49. return $this->addOrder('sort_order', $direction);
  50. }
  51. }