123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- namespace Magento\Eav\Model\ResourceModel\Form\Element;
- /**
- * Eav Form Element Resource Collection
- *
- * @api
- * @since 100.0.2
- */
- class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
- {
- /**
- * Initialize collection model
- *
- * @return void
- * @codeCoverageIgnore
- */
- protected function _construct()
- {
- $this->_init(\Magento\Eav\Model\Form\Element::class, \Magento\Eav\Model\ResourceModel\Form\Element::class);
- }
- /**
- * Add Form Type filter to collection
- *
- * @param \Magento\Eav\Model\Form\Type|int $type
- * @return $this
- */
- public function addTypeFilter($type)
- {
- if ($type instanceof \Magento\Eav\Model\Form\Type) {
- $type = $type->getId();
- }
- return $this->addFieldToFilter('type_id', $type);
- }
- /**
- * Add Form Fieldset filter to collection
- *
- * @param \Magento\Eav\Model\Form\Fieldset|int $fieldset
- * @return $this
- */
- public function addFieldsetFilter($fieldset)
- {
- if ($fieldset instanceof \Magento\Eav\Model\Form\Fieldset) {
- $fieldset = $fieldset->getId();
- }
- return $this->addFieldToFilter('fieldset_id', $fieldset);
- }
- /**
- * Add Attribute filter to collection
- *
- * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute|int $attribute
- *
- * @return $this
- */
- public function addAttributeFilter($attribute)
- {
- if ($attribute instanceof \Magento\Eav\Model\Entity\Attribute\AbstractAttribute) {
- $attribute = $attribute->getId();
- }
- return $this->addFieldToFilter('attribute_id', $attribute);
- }
- /**
- * Set order by element sort order
- *
- * @return $this
- * @codeCoverageIgnore
- */
- public function setSortOrder()
- {
- $this->setOrder('sort_order', self::SORT_ORDER_ASC);
- return $this;
- }
- /**
- * Join attribute data
- *
- * @return $this
- */
- protected function _joinAttributeData()
- {
- $this->getSelect()->join(
- ['eav_attribute' => $this->getTable('eav_attribute')],
- 'main_table.attribute_id = eav_attribute.attribute_id',
- ['attribute_code', 'entity_type_id']
- );
- return $this;
- }
- /**
- * Load data (join attribute data)
- *
- * @param bool $printQuery
- * @param bool $logQuery
- * @return $this
- */
- public function load($printQuery = false, $logQuery = false)
- {
- if (!$this->isLoaded()) {
- $this->_joinAttributeData();
- }
- return parent::load($printQuery, $logQuery);
- }
- }
|