Element.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Eav\Model\ResourceModel\Form;
  7. /**
  8. * Eav Form Element Resource Model
  9. *
  10. * @author Magento Core Team <core@magentocommerce.com>
  11. */
  12. class Element extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
  13. {
  14. /**
  15. * Initialize connection and define main table
  16. *
  17. * @return void
  18. */
  19. protected function _construct()
  20. {
  21. $this->_init('eav_form_element', 'element_id');
  22. $this->addUniqueField(
  23. ['field' => ['type_id', 'attribute_id'], 'title' => __('Form Element with the same attribute')]
  24. );
  25. }
  26. /**
  27. * Retrieve select object for load object data
  28. *
  29. * @param string $field
  30. * @param mixed $value
  31. * @param \Magento\Eav\Model\Form\Element $object
  32. * @return \Magento\Framework\DB\Select
  33. */
  34. protected function _getLoadSelect($field, $value, $object)
  35. {
  36. $select = parent::_getLoadSelect($field, $value, $object);
  37. $select->join(
  38. $this->getTable('eav_attribute'),
  39. $this->getTable('eav_attribute') . '.attribute_id = ' . $this->getMainTable() . '.attribute_id',
  40. ['attribute_code', 'entity_type_id']
  41. );
  42. return $select;
  43. }
  44. }