Skip to content

Commit

Permalink
Fix missing database prefix when get Table names (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
broopdias authored Jun 8, 2023
1 parent 03d5ed3 commit 29ec429
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 12 deletions.
8 changes: 4 additions & 4 deletions Block/Adminhtml/Element/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@ protected function getCustomCollection()
$collection = $this->elementFactory->create()->getCollection();
$collection->getSelect()
->joinLeft(
['leet' => 'layout_element_entity_text'],
['leet' => $collection->getTable('layout_element_entity_text')],
'e.entity_id = leet.entity_id AND show_in_grid = leet.attribute_id',
['leet.attribute_id', 'leet.value AS value'])
->joinLeft(
['eav' => 'eav_attribute'],
['eav' => $collection->getTable('eav_attribute')],
'leet.attribute_id = eav.attribute_id',
['eav.attribute_code']
)
Expand All @@ -149,11 +149,11 @@ protected function getCustomCollection()
$collection = $this->elementFactory->create()->getCollection();
$collection->getSelect()
->joinLeft(
['leev' => 'layout_element_entity_varchar'],
['leev' => $collection->getTable('layout_element_entity_varchar')],
'e.entity_id = leev.entity_id AND show_in_grid = leev.attribute_id',
['leev.attribute_id', 'leev.value'])
->joinLeft(
['eav' => 'eav_attribute'],
['eav' => $collection->getTable('eav_attribute')],
'leev.attribute_id = eav.attribute_id',
['eav.attribute_code']
)
Expand Down
2 changes: 1 addition & 1 deletion Block/Adminhtml/Group/Edit/Tab/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ protected function getAllFieldsOptions($id)
->addFieldToFilter('template_id', ['eq' => $id]);
$allFieldsCollection->getSelect()
->join(
['eav' => 'eav_attribute'],
['eav' => $allFieldsCollection->getTable('eav_attribute')],
'main_table.eav_attribute_id = eav.attribute_id',
['eav.attribute_code', 'eav.frontend_label', 'eav.frontend_input']
);
Expand Down
6 changes: 5 additions & 1 deletion Block/Adminhtml/Group/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ protected function _prepareCollection()
{
$collection = $this->groupFactory->create()->getCollection();
$collection->getSelect()
->join('layout_template as ly', 'main_table.template_id = ly.entity_id', 'ly.code as template_name');
->join(
['ly' => $collection->getTable('layout_template')],
'main_table.template_id = ly.entity_id',
'ly.code as template_name'
);

$this->setCollection($collection);
return parent::_prepareCollection();
Expand Down
2 changes: 1 addition & 1 deletion Block/Adminhtml/TemplateFields/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected function _prepareCollection()
$collection
->getSelect()
->join(
['eav' => 'eav_attribute'],
['eav' => $collection->getTable('eav_attribute')],
'main_table.eav_attribute_id = eav.attribute_id',
['eav.attribute_code', 'eav.frontend_label', 'eav.frontend_input']
);
Expand Down
2 changes: 1 addition & 1 deletion Controller/Adminhtml/Group/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function execute()
$model = $this->groupFactory->create()->getCollection();
$model->getSelect()
->joinLeft(
['lgs' => 'layout_group_store'],
['lgs' => $model->getTable('layout_group_store')],
'main_table.entity_id = lgs.group_id',
['GROUP_CONCAT(`lgs`.`store_id`) as store_ids']
)
Expand Down
2 changes: 1 addition & 1 deletion Controller/Adminhtml/TemplateFields/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function execute()
$model = $this->templateFieldsFactory->create()->getCollection();
$model->getSelect()
->join(
['eav' => 'eav_attribute'],
['eav' => $model->getTable('eav_attribute')],
'main_table.eav_attribute_id = eav.attribute_id',
['eav.attribute_code', 'eav.frontend_label', 'eav.frontend_input']
);
Expand Down
6 changes: 3 additions & 3 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public function getGroup($id = false, $field = 'group_code')

$group->getSelect()
->joinLeft(
['lgs' => 'layout_group_store'],
['lgs' => $group->getTable('layout_group_store')],
'main_table.entity_id = lgs.group_id',
['lgs.store_id']
)
Expand Down Expand Up @@ -247,7 +247,7 @@ public function getFieldsTemplate($idGroup)
$templateFields
->getSelect()
->join(
['eav' => 'eav_attribute'],
['eav' => $templateFields->getTable('eav_attribute')],
'main_table.eav_attribute_id = eav.attribute_id',
['eav.attribute_code', 'eav.frontend_label', 'eav.frontend_input']
);
Expand Down Expand Up @@ -306,7 +306,7 @@ public function getAttributeOptions($templateId)
$templateFields
->getSelect()
->join(
['eav' => 'eav_attribute'],
['eav' => $templateFields->getTable('eav_attribute')],
'main_table.eav_attribute_id = eav.attribute_id',
['eav.attribute_code', 'eav.frontend_label', 'eav.frontend_input']
);
Expand Down

0 comments on commit 29ec429

Please sign in to comment.