Post by moreno13 » Tue Nov 09, 2010 3:57 pm

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 ;)

New member

Posts

Joined
Thu Sep 30, 2010 10:02 am

Post by Qphoria » Wed Nov 10, 2010 1:38 pm

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;
    } 

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by moreno13 » Wed Nov 10, 2010 4:10 pm

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 :ok:
You are the best of this forum all I can say abut you is your the BEST!!! ;)

New member

Posts

Joined
Thu Sep 30, 2010 10:02 am

Post by cartchap » Fri Feb 25, 2011 2:21 pm

is there a way as to how i can get a bestseller for a particular category!! thanks

New member

Posts

Joined
Fri Nov 26, 2010 3:02 pm
Who is online

Users browsing this forum: No registered users and 12 guests