Skip to content
Merged
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
2 changes: 2 additions & 0 deletions src/sCommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ public function getProducts(array|QueryBuilder $productIds, ?string $lang = null
->where('s_product_category.category', $this->getCategoryId())
->orWhere('s_product_category.scope', 'primary');
})
// Prefer the row of the current category (manual order from admin) over the primary one
->orderByRaw('(' . DB::getTablePrefix() . 's_product_category.category = ' . (int)$this->getCategoryId() . ') desc')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Quote the prefixed table identifier in the raw order clause

When an installation uses a table prefix containing characters that require quoting, such as shop-, this raw fragment is parsed as operators rather than as the s_product_category.category column; the query builder quotes the prefixed table in the FROM clause, but this expression bypasses that quoting, so every getProducts() call fails on that installation. Use the connection grammar to quote the prefixed identifier.

Useful? React with 👍 / 👎.

->limit(1)
])
->whereIn('id', $productIds)
Expand Down