I am very much new on this forum and have a small problem I hope somebody knowledgeable in MySQL and PHP can help me with. I made a duplicate of the "special.php"-page to make a new "latest.php"-page. Everything seams to be working fine. Result is here: http://dartbutiken.se/butik/index.php?r ... uct/latest
But I dont have pagination. I know why, but I dont know how to solve it.
In the controller/product/special.php file you find the following lines controlling the pagination-process:
First this:
Code: Select all
$product_total = $this->model_catalog_product->getTotalProductSpecials();
Code: Select all
$pagination->total = $product_total;
$pagination->page = $page;
$pagination->limit = $this->config->get('config_catalog_limit');
$pagination->text = $this->language->get('text_pagination');
$pagination->url = HTTP_SERVER . 'index.php?route=product/special' . $url . '&page={page}';
$this->data['pagination'] = $pagination->render();
In the model/catalog/product.php file you find the SQL-statement:
Code: Select all
public function getTotalProductSpecials() {
if ($this->customer->isLogged()) {
$customer_group_id = $this->customer->getCustomerGroupId();
} else {
$customer_group_id = $this->config->get('config_customer_group_id');
}
$query = $this->db->query("SELECT COUNT(DISTINCT ps.product_id) AS total FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) LEFT JOIN " . DB_PREFIX . "product_special ps ON (p.product_id = ps.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) AND ps.product_id NOT IN (SELECT pd2.product_id FROM " . DB_PREFIX . "product_discount pd2 WHERE p.product_id = pd2.product_id AND pd2.customer_group_id = '" . (int)$customer_group_id . "' AND pd2.quantity = '1' AND ((pd2.date_start = '0000-00-00' OR pd2.date_start < NOW()) AND (pd2.date_end = '0000-00-00' OR pd2.date_end > NOW())))");
if (isset($query->row['total'])) {
return $query->row['total'];
} else {
return 0;
}
}
Regards,