Hello,
I wonder if someone out there knows how to modify the sidebox best sellers.
In best sellers sidebox I want only the top 5 to be shown.
I have search the admin area but cant find any settings to modify this.
Help needed, thanks in advance
//Jolas jolas
I have best sellers installed and working, but I would like to change it to be a "hot items". In theory I should be able to modify the SQL statement in header_php.php to limit the query the number of sales in the last 30 days. Unfortunately I have no idea how to do that. Anyone know how?
I found a way to limit it to the last 30 days. The code works, but I would greatly appreciate someone looking at it and maybe cleaning it up or optimizing it a bit. Here is the resulting header_php.php
Code:<?php /** * Best Seller Page * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0 * $Id: header_php.php 165 2008-03-21 04:21:50Z yellow1912 $ */ require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php')); $breadcrumb->add(NAVBAR_TITLE); $disp_order_default = PRODUCT_ALL_LIST_SORT_DEFAULT; require(DIR_WS_MODULES . zen_get_module_directory(FILENAME_LISTING_DISPLAY_ORDER)); $listing_sql = "SELECT p.products_type, p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_date_added, m.manufacturers_name, p.products_model, p.products_quantity, p.products_weight, p.product_is_call, p.product_is_always_free_shipping, p.products_qty_box_status, p.master_categories_id FROM orders o, orders_products op, products p, products_description pd, manufacturers m WHERE o.orders_id = op.orders_id AND op.products_id = p.products_id AND p.products_id = pd.products_id AND p.manufacturers_id = m.manufacturers_id AND p.products_status = 1 AND TO_DAYS(date_purchased) >= (TO_DAYS(NOW())-60) GROUP BY op.products_id ORDER BY SUM(op.products_quantity) desc"; $listing_sql = $db->bindVars($listing_sql, ':languageID', $_SESSION['languages_id'], 'integer'); //check to see if we are in normal mode ... not showcase, not maintenance, etc $show_submit = zen_run_normal(); $define_list = array('PRODUCT_LIST_MODEL' => PRODUCT_LIST_MODEL, 'PRODUCT_LIST_NAME' => PRODUCT_LIST_NAME, 'PRODUCT_LIST_MANUFACTURER' => PRODUCT_LIST_MANUFACTURER, 'PRODUCT_LIST_PRICE' => PRODUCT_LIST_PRICE, 'PRODUCT_LIST_QUANTITY' => PRODUCT_LIST_QUANTITY, 'PRODUCT_LIST_WEIGHT' => PRODUCT_LIST_WEIGHT, 'PRODUCT_LIST_IMAGE' => PRODUCT_LIST_IMAGE); /* , 'PRODUCT_LIST_BUY_NOW' => PRODUCT_LIST_BUY_NOW); */ asort($define_list); reset($define_list); $column_list = array(); foreach ($define_list as $key => $value) { if ($value > 0) $column_list[] = $key; } ?>
I'm working on a simple module that loads the best sellers from a given category from the previous x months. Here is the SQL query:
The issue I am having is that if a product is linked, it doubles up the products_ordered. Any fresh eyes see the mistake?PHP Code:
SELECT DISTINCT (p2c.products_id), SUM( op.products_quantity ) AS products_ordered, pd.products_name, p.products_image
FROM products_to_categories p2c
LEFT JOIN orders_products op ON ( op.products_id = p2c.products_id )
LEFT JOIN orders o ON ( o.orders_id = op.orders_id )
LEFT JOIN products_description pd ON ( pd.products_id = p2c.products_id )
LEFT JOIN products p ON ( p.products_id = p2c.products_id )
WHERE p.products_status =1
AND pd.language_id = '1'
AND (o.date_purchased >= '2010-03-12'
AND o.date_purchased <= '2010-05-13')
AND p2c.categories_id
IN ( 8, 6, 10, 11, 12, 4, 7, 9, 13, 5 )
GROUP BY p2c.products_id
ORDER BY products_ordered DESC , products_name ASC;
If anyone was wondering how to do this, the following query worked:
PHP Code:
SELECT DISTINCT (p2c.products_id), SUM( op.products_quantity ) AS products_ordered, pd.products_name, p.products_image
FROM products_to_categories p2c
LEFT JOIN orders_products op ON ( op.products_id = p2c.products_id )
LEFT JOIN orders o ON ( o.orders_id = op.orders_id )
LEFT JOIN products_description pd ON ( pd.products_id = p2c.products_id )
LEFT JOIN products p ON ( p.products_id = p2c.products_id )
WHERE p.products_status =1
AND pd.language_id = '1'
AND (o.date_purchased >= '2010-03-12'
AND o.date_purchased <= '2010-05-13')
AND p2c.categories_id
IN ( 8, 6, 10, 11, 12, 4, 7, 9, 13, 5 )
GROUP BY p2c.products_id, p2c.categories_id
ORDER BY products_ordered DESC , products_name ASC;
You are hard coding the categories_id rather than pulling dynamically pulling from a Top Level category to grab all of its kids and get them that way?
Or you don't care about being dynamic and just want the few listed categories_id used?
Linda McGrath
If you have to think ... you haven't been zenned ...
Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!
Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
Officially PayPal-Certified! Just click here
Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!
Anyone?![]()
Bookmarks