In the situation where it wont work, when I hover over the previous/next buttons you see that it is a regular url instead of the seo. Also, in the URL input I can see the category SEO is added in the URL, it's domain/dir/cat/product.
In the situation where it does work, when I hover over the previous/next buttons you see that it is the SEO URL. Also, in the URL input the category SEO is not within the URL, it's just the domain/dir/product.
Code: Select all
public function PreNextbyCat($data = array()){
$filter = '';
if (!empty($data['filter_category_id'])) {
if (!empty($data['filter_sub_category'])) {
$implode_data = array();
$implode_data[] = "p2c.category_id = '" . (int)$data['filter_category_id'] . "'";
$this->load->model('catalog/category');
$categories = $this->model_catalog_category->getCategoriesByParentId($data['filter_category_id']);
foreach ($categories as $category_id) {
$implode_data[] = "p2c.category_id = '" . (int)$category_id . "'";
}
$filter .= " AND (" . implode(' OR ', $implode_data) . ")";
} else {
$filter .= " AND p2c.category_id = '" . (int)$data['filter_category_id'] . "'";
}
}
$query1 = $this->db->query("SELECT category_id AS TARGET FROM " . DB_PREFIX . "product_to_category WHERE product_id = '" . $data['product_id'] . "' LIMIT 1 OFFSET 2");
$targetcat = $query1->row['TARGET'];
$nextquery = "SELECT p.product_id as next,p2d.name next_name FROM ".DB_PREFIX."product p LEFT JOIN ".DB_PREFIX."product_to_category p2c ON(p.product_id = p2c.product_id) LEFT JOIN ".DB_PREFIX."product_description p2d ON(p.product_id = p2d.product_id) LEFT JOIN ".DB_PREFIX."product_to_store p2s ON(p.product_id = p2s.product_id) WHERE p2d.language_id = '".(int)$this->config->get('config_language_id')."' AND p2s.store_id = '".(int)$this->config->get('config_store_id')."' AND p.status = '1' AND p.date_available <= NOW() AND p2c.category_id = '" .$targetcat. "' AND p.product_id > '".$data['product_id']."' ".$filter." ORDER BY p.product_id ASC LIMIT 1";
$prevquery = "SELECT p.product_id as prev,p2d.name prev_name FROM ".DB_PREFIX."product p LEFT JOIN ".DB_PREFIX."product_to_category p2c ON(p.product_id = p2c.product_id) LEFT JOIN ".DB_PREFIX."product_description p2d ON(p.product_id = p2d.product_id) LEFT JOIN ".DB_PREFIX."product_to_store p2s ON(p.product_id = p2s.product_id) WHERE p2d.language_id = '".(int)$this->config->get('config_language_id')."' AND p2s.store_id = '".(int)$this->config->get('config_store_id')."' AND p.status = '1' AND p.date_available <= NOW() AND p2c.category_id = '" .$targetcat. "' AND p.product_id < '".$data['product_id']."' ".$filter." ORDER BY p.product_id DESC LIMIT 1";
$prev = $this->db->query($prevquery)->row;
$next = $this->db->query($nextquery)->row;
$query = array_merge($prev,$next);
return $query;
}
Code: Select all
$data['next_link'] = $this->url->link('product/product', $category_link . 'product_id=' . $results['next']);