Page 1 of 1
How to show Bestseller Random
Posted: Tue Nov 09, 2010 3:57 pm
by moreno13
Hi guys I have a Q how to show bestseller Random any one knows
any help place
I also like to add a watermark in the picture any help
I using 1.4.8b
Thank you
all the experts who take the time to read this post
God Bless you all.
nice work Opencart team

Re: How to show Bestseller Random
Posted: Wed Nov 10, 2010 1:38 pm
by Qphoria
random best sellers:
1. EDIT: catalog/model/catalog/product.php
2. FIND & REPLACE THE ENTIRE FUNCTION:
Code: Select all
public function getBestSellerProducts($limit) {
..........
}
WITH:
Code: Select all
public function getBestSellerProducts($limit) {
//$product_data = $this->cache->get('product.bestseller.' . $this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $limit);
//if (!$product_data) {
$product_data = array();
$query = $this->db->query("SELECT op.product_id, SUM(op.quantity) AS total FROM " . DB_PREFIX . "order_product op LEFT JOIN `" . DB_PREFIX . "order` o ON (op.order_id = o.order_id) WHERE o.order_status_id > '0' GROUP BY op.product_id ORDER BY rand() DESC LIMIT " . (int)$limit);
foreach ($query->rows as $result) {
$product_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.product_id = '" . (int)$result['product_id'] . "' AND p.status = '1' AND p.date_available <= NOW() AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'");
if ($product_query->num_rows) {
$product_data[] = $product_query->row;
}
}
$this->cache->set('product.bestseller.' . $this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $limit, $product_data);
//}
return $product_data;
}
Re: How to show Bestseller Random
Posted: Wed Nov 10, 2010 4:10 pm
by moreno13
Qphoria wrote:random best sellers:
1. EDIT: catalog/model/catalog/product.php
2. FIND & REPLACE THE ENTIRE FUNCTION:
Code: Select all
public function getBestSellerProducts($limit) {
..........
}
WITH:
Code: Select all
public function getBestSellerProducts($limit) {
//$product_data = $this->cache->get('product.bestseller.' . $this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $limit);
//if (!$product_data) {
$product_data = array();
$query = $this->db->query("SELECT op.product_id, SUM(op.quantity) AS total FROM " . DB_PREFIX . "order_product op LEFT JOIN `" . DB_PREFIX . "order` o ON (op.order_id = o.order_id) WHERE o.order_status_id > '0' GROUP BY op.product_id ORDER BY rand() DESC LIMIT " . (int)$limit);
foreach ($query->rows as $result) {
$product_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.product_id = '" . (int)$result['product_id'] . "' AND p.status = '1' AND p.date_available <= NOW() AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'");
if ($product_query->num_rows) {
$product_data[] = $product_query->row;
}
}
$this->cache->set('product.bestseller.' . $this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $limit, $product_data);
//}
return $product_data;
}
Thank you So much Q
You are the best of this forum all I can say abut you is your the BEST!!!

Re: How to show Bestseller Random
Posted: Fri Feb 25, 2011 2:21 pm
by cartchap
is there a way as to how i can get a bestseller for a particular category!! thanks