diasansley Posted February 25, 2011 Share Posted February 25, 2011 hey guys i wanted the bestseller to be modified as in if i click on a category the bestseller only for that particular category is displayed. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/228764-bestseller-for-categories-14912-opencart/ Share on other sites More sharing options...
trq Posted February 25, 2011 Share Posted February 25, 2011 Where are you stuck? Quote Link to comment https://forums.phpfreaks.com/topic/228764-bestseller-for-categories-14912-opencart/#findComment-1179416 Share on other sites More sharing options...
diasansley Posted February 25, 2011 Author Share Posted February 25, 2011 i have modified a query but with a fixed category id(36,46,86)... it returns a result but i want to make it generic as in for each category clicked i cant get a way how!~!!! its all confusing Thanks Quote Link to comment https://forums.phpfreaks.com/topic/228764-bestseller-for-categories-14912-opencart/#findComment-1179421 Share on other sites More sharing options...
trq Posted February 25, 2011 Share Posted February 25, 2011 We can't help you without seeing the relevant code either. Quote Link to comment https://forums.phpfreaks.com/topic/228764-bestseller-for-categories-14912-opencart/#findComment-1179423 Share on other sites More sharing options...
diasansley Posted February 25, 2011 Author Share Posted February 25, 2011 ok here is controller/product/category.php if ($category_total || $product_total) { $this->data['categories'] = array(); //$results = $this->model_catalog_category->getCategories($category_id); $results = $this->model_catalog_category->getCategories_new('38, 46, 48, 86'); model/catalog/product.php public function getProductsByCategoryId($category_id, $sort = 'p.sort_order', $order = 'ASC', $start = 0, $limit = 20) { $sqlwrk = "SELECT 1 FROM category where parent_id = '" . (int)$category_id . "'"; $query = $this->db->query($sqlwrk); $results = $query->rows; if ($results == null) { $sql = "SELECT *, pd.name AS name, p.image, m.name AS manufacturer, ss.name AS stock, (SELECT AVG(r.rating) FROM " . DB_PREFIX . "review r WHERE p.product_id = r.product_id GROUP BY r.product_id) AS rating 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) LEFT JOIN " . DB_PREFIX . "manufacturer m ON (p.manufacturer_id = m.manufacturer_id) LEFT JOIN " . DB_PREFIX . "stock_status ss ON (p.stock_status_id = ss.stock_status_id) LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (p.product_id = p2c.product_id) WHERE 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') . "' AND ss.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p2c.category_id = '" . (int)$category_id . "'"; } else { /*category_id = $category_id; while (true) { } */ $sql = "SELECT distinct p.*, pd.name AS name, p.image, m.name AS manufacturer, ss.name AS stock, (SELECT AVG(r.rating) FROM " . DB_PREFIX . "review r WHERE p.product_id = r.product_id GROUP BY r.product_id) AS rating 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) LEFT JOIN " . DB_PREFIX . "manufacturer m ON (p.manufacturer_id = m.manufacturer_id) LEFT JOIN " . DB_PREFIX . "stock_status ss ON (p.stock_status_id = ss.stock_status_id) LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (p.product_id = p2c.product_id) INNER JOIN order_product OP ON (p.product_id = OP.product_id) WHERE 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') . "' AND ss.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p2c.category_id in (" . '38, 46, 48, 86' . ")"; } model/catalog/category.php public function getCategories_new($parent_id = 0) { $category_data = $this->cache->get('category.' . $parent_id . '.' . $this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id')); if (!$category_data) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "category c LEFT JOIN " . DB_PREFIX . "category_description cd ON (c.category_id = cd.category_id) LEFT JOIN " . DB_PREFIX . "category_to_store c2s ON (c.category_id = c2s.category_id) WHERE c.parent_id in (" . $parent_id . ") AND cd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND c2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND c.status = '1' AND c.sort_order <> '-1' ORDER BY c.sort_order, LCASE(cd.name)"); $category_data = $query->rows; $this->cache->set('category.' . $parent_id . '.' . $this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id'), $category_data); } return $category_data; } that all the code i have edited. pls try and help me out thanks Quote Link to comment https://forums.phpfreaks.com/topic/228764-bestseller-for-categories-14912-opencart/#findComment-1179424 Share on other sites More sharing options...
trq Posted February 25, 2011 Share Posted February 25, 2011 pls try and help me out Read your posts back. Do you really think you have provided enough information for someone to be able to understand your problem and help you? Quote Link to comment https://forums.phpfreaks.com/topic/228764-bestseller-for-categories-14912-opencart/#findComment-1179429 Share on other sites More sharing options...
diasansley Posted February 25, 2011 Author Share Posted February 25, 2011 i have pasted all that i edited with the hard coded values for the query anything else u need please tell me im more then happy to give it to u thanks Quote Link to comment https://forums.phpfreaks.com/topic/228764-bestseller-for-categories-14912-opencart/#findComment-1179430 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.