Collection.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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\Set;
  7. /**
  8. * Eav Resource Attribute Set Collection
  9. *
  10. * @api
  11. * @author Magento Core Team <core@magentocommerce.com>
  12. * @since 100.0.2
  13. */
  14. class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
  15. {
  16. /**
  17. * Resource initialization
  18. *
  19. * @return void
  20. * @codeCoverageIgnore
  21. */
  22. protected function _construct()
  23. {
  24. $this->_init(
  25. \Magento\Eav\Model\Entity\Attribute\Set::class,
  26. \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set::class
  27. );
  28. }
  29. /**
  30. * Add filter by entity type id to collection
  31. *
  32. * @param int $typeId
  33. * @return $this
  34. * @codeCoverageIgnore
  35. */
  36. public function setEntityTypeFilter($typeId)
  37. {
  38. return $this->addFieldToFilter('entity_type_id', $typeId);
  39. }
  40. /**
  41. * Convert collection items to select options array
  42. *
  43. * @return array
  44. */
  45. public function toOptionArray()
  46. {
  47. return parent::_toOptionArray('attribute_set_id', 'attribute_set_name');
  48. }
  49. /**
  50. * Convert collection items to select options hash array
  51. *
  52. * @return array
  53. */
  54. public function toOptionHash()
  55. {
  56. return parent::_toOptionHash('attribute_set_id', 'attribute_set_name');
  57. }
  58. }