Skip to content

With table prefix enabled in app/etc/env.php visit Product/Category pages and you would receive error with raw sql with incorrect table names for store & eav_attribute causing the page to go into 500 error #36478

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -243,19 +243,21 @@ private function categoryProductByCustomSortOrder(int $categoryId): array
$entityTypeId = $this->collection->getEntity()->getTypeId();
$entityMetadata = $this->metadataPool->getMetadata(ProductInterface::class);
$linkField = $entityMetadata->getLinkField();
$eavTable = $this->collection->getTable('eav_attribute');
$query->joinLeft(
['product_var' => $this->collection->getTable('catalog_product_entity_varchar')],
"product_var.{$linkField} = e.{$linkField} AND product_var.attribute_id =
(SELECT attribute_id FROM eav_attribute WHERE entity_type_id={$entityTypeId}
(SELECT attribute_id FROM {$eavTable} WHERE entity_type_id={$entityTypeId}
AND attribute_code='name')",
['product_var.value AS name']
);
} elseif ($field === 'price') {
$storeTable = $this->collection->getTable('store');
$query->joinLeft(
['price_index' => $this->collection->getTable('catalog_product_index_price')],
'price_index.entity_id = e.entity_id'
. ' AND price_index.customer_group_id = 0'
. ' AND price_index.website_id = (Select website_id FROM store WHERE store_id = '
. ' AND price_index.website_id = (Select website_id FROM ' . $storeTable . ' WHERE store_id = '
. $storeId . ')',
['price_index.max_price AS price']
);
Expand Down