$listing_sql = sprintf(<<<'EOSQL'
SELECT m.*, %s
FROM
products p
LEFT JOIN specials s ON p.products_id = s.products_id
INNER JOIN products_description pd ON p.products_id = pd.products_id
LEFT JOIN (SELECT products_id, COUNT(*) AS attribute_count FROM products_attributes GROUP BY products_id) a ON p.products_id = a.products_id
EOSQL
, Product::COLUMNS);
// show the products of a specified manufacturer
if (empty($_GET['manufacturers_id'])) {
// show the products in a given category
if (isset($_GET['filter_id']) && !Text::is_empty($_GET['filter_id'])) {
// We are asked to show only a specific manufacturer
$listing_sql .= sprintf(<<<'EOSQL'
INNER JOIN manufacturers m ON p.manufacturers_id = m.manufacturers_id
INNER JOIN products_to_categories p2c ON p.products_id = p2c.products_id
WHERE p.products_status = 1 AND m.manufacturers_id = %d AND pd.language_id = %d AND p2c.categories_id = %d
EOSQL
, (int)$_GET['filter_id'], (int)$_SESSION['languages_id'], (int)$current_category_id);
} else {
// We show them all
$listing_sql .= sprintf(<<<'EOSQL'
INNER JOIN products_to_categories p2c ON p.products_id = p2c.products_id
LEFT JOIN manufacturers m ON p.manufacturers_id = m.manufacturers_id
WHERE p.products_status = 1 AND pd.language_id = %d AND p2c.categories_id = %d
EOSQL
, (int)$_SESSION['languages_id'], (int)$current_category_id);
}
} else {
if (isset($_GET['filter_id']) && !Text::is_empty($_GET['filter_id'])) {
// We are asked to show only a specific category
$listing_sql .= sprintf(<<<'EOSQL'
INNER JOIN manufacturers m ON p.manufacturers_id = m.manufacturers_id
INNER JOIN products_to_categories p2c ON p.products_id = p2c.products_id
WHERE p.products_status = 1 AND m.manufacturers_id = %d AND pd.language_id = %d AND p2c.categories_id = %d
EOSQL
, (int)$_GET['manufacturers_id'], (int)$_SESSION['languages_id'], (int)$_GET['filter_id']);
} else {
// We show them all
$listing_sql .= sprintf(<<<'EOSQL'
INNER JOIN manufacturers m ON p.manufacturers_id = m.manufacturers_id
WHERE p.products_status = 1 AND pd.language_id = %d AND m.manufacturers_id = %d
EOSQL
, (int)$_SESSION['languages_id'], (int)$_GET['manufacturers_id']);
}
}
PHP Warning: DB: [1064] You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(" . Tree->get_descendants(implode(', ', array_map('intval', Guarantor::ensur...' at line 7 from <SELECT COUNT(p.products_id) AS total FROM
products p
LEFT JOIN specials s ON p.products_id = s.products_id
INNER JOIN products_description pd ON p.products_id = pd.products_id
LEFT JOIN (SELECT products_id, COUNT(*) AS attribute_count FROM products_attributes GROUP BY products_id) a ON p.products_id = a.products_id INNER JOIN products_to_categories p2c ON p.products_id = p2c.products_id
LEFT JOIN manufacturers m ON p.manufacturers_id = m.manufacturers_id
WHERE p.products_status = 1 AND pd.language_id = 1 AND p2c.categories_id IN (463) (" . Tree->get_descendants(implode(', ', array_map('intval', Guarantor::ensure_global('category_tree')->get_descendants((int)$current_category_id)))) . ") > in /home/***/public_html/includes/system/versioned/1.0.8.1/database_core.php on line 44
// We show them all
$listing_sql .= sprintf(<<<'EOSQL'
INNER JOIN products_to_categories p2c ON p.products_id = p2c.products_id
LEFT JOIN manufacturers m ON p.manufacturers_id = m.manufacturers_id
WHERE p.products_status = 1 AND pd.language_id = %d AND p2c.categories_id IN (%s) (" . Tree->get_descendants(implode(', ', array_map('intval', Guarantor::ensure_global('category_tree')->get_descendants((int)$current_category_id)))) . ")
EOSQL
, (int)$_SESSION['languages_id'], (int)$current_category_id);
// We show them all
$listing_sql .= sprintf(<<<'EOSQL'
INNER JOIN products_to_categories p2c ON p.products_id = p2c.products_id
LEFT JOIN manufacturers m ON p.manufacturers_id = m.manufacturers_id
WHERE p.products_status = 1 AND pd.language_id = %d AND p2c.categories_id IN (%s) (" . Tree->get_descendants(implode(', ', array_map('intval', Guarantor::ensure_global('category_tree')->get_descendants((int)$current_category_id)))) . ")
EOSQL
, (int)$_SESSION['languages_id'], (int)$current_category_id);
// We show them all
$listing_sql .= sprintf(<<<'EOSQL'
INNER JOIN products_to_categories p2c ON p.products_id = p2c.products_id
LEFT JOIN manufacturers m ON p.manufacturers_id = m.manufacturers_id
WHERE p.products_status = 1 AND pd.language_id = %d AND p2c.categories_id IN (%s)
EOSQL
, (int)$_SESSION['languages_id'], implode(', ', array_map('intval', Guarantor::ensure_global('category_tree')->get_descendants((int)$current_category_id))));
//Daniel
Last edited by Kofod95 on Mon Apr 17, 2023 8:56 pm, edited 1 time in total.
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide