Search result lists disabled products if "search description" checked
Posted: Fri Jan 18, 2008 3:16 pm
how to slove this problem? Looking for help.
OpenCart Community Forum - Discuss shopping cart and e-commerce solutions.
https://forum.opencart.com/
Code: Select all
if (!$session->get('search.description')) {
$sql = "select * from product p left join product_description pd on (p.product_id = pd.product_id) left join image i on (p.image_id = i.image_id) where pd.language_id = '?' and pd.name like '?' and p.date_available < now() and p.status = '1'";
$results = $database->getRows($database->splitQuery($database->parse($sql, $language->getId(), '%' . $session->get('search.search') . '%'), $session->get('search.page'), $config->get('config_max_rows')));
} else {
// $sql = "select * from product p left join product_description pd on (p.product_id = pd.product_id) left join image i on (p.image_id = i.image_id) where pd.language_id = '?' and pd.name like '?' or pd.description like '?' and p.date_available < now() and p.status = '1'";
// ** replace the above line with the following line
$sql = "select * from product p left join product_description pd on (p.product_id = pd.product_id) left join image i on (p.image_id = i.image_id) where pd.language_id = '?' and (pd.name like '?' or pd.description like '?') and p.date_available < now() and p.status = '1'";
$results = $database->getRows($database->splitQuery($database->parse($sql, $language->getId(), '%' . $session->get('search.search') . '%', '%' . $session->get('search.search') . '%'), $session->get('search.page'), $config->get('config_max_rows')));
}