You get a bonus - 1 coin for daily activity. Now you have 1 coin

How to make filterpro in OpenCart show all categories

Practice




How to make filterpro in OpenCart show all categories

in the file /catalog/controller/module/filterpro.php around line 400
do this

$category_id = -1;
if(isset($this->request->post['category_id'])) {
// $category_id = $this->request->post['category_id'];
}


and in the file /catalog/model/filterpro.php

also do this


around line 130

" WHERE c.status=1 AND ";

if((int)$data['category_id']==-1) $sql .= ''; else $sql .= " c.parent_id = '" . (int)$data['category_id'] . "' AND";

$sql .= " cd.language_id =



and 146

if($data['category_id'] and $data['category_id']!=-1) {
$sql .= "LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON(p.product_id = p2c.product_id) ";
}
$sql .= "LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON(p.product_id=p2s.product_id)
WHERE ovd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND od.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id =" . (int)$this->config->get('config_store_id');

if($data['category_id'] and $data['category_id']!=-1) {
$sql .= " AND p2c.category_id = '" . (int)$data['category_id'] . "'";
}




and line 190

if($data['category_id'] and $data['category_id']!=-1 ) {
$sql .= " LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (p2c.product_id=p.product_id)";
}

$sql .= " WHERE p.status = '1' AND p.date_available <= NOW( ) AND p2s.store_id = " . (int)$this->config->get('config_store_id');
if($data['category_id'] and $data['category_id']!=-1 ) {
$sql .= " AND p2c.category_id = '" . (int)$data['category_id'] . "'";
}




and around line 750


i
f ($category_id==-1) $sql .= " AND c.status=1 AND cd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW( ) AND p2s.store_id = " . (int)$this->config->get('config_store_id');


else $sql .= " AND c.status=1 AND c.parent_id = '" . $category_id . "' AND cd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW( ) AND p2s.store_id = " . (int)$this->config->get('config_store_id');

$sql .= ") as innertable WHERE 1 ";

Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Running server side scripts using PHP as an example (LAMP)"

Terms: Running server side scripts using PHP as an example (LAMP)