bestseller how is it determined? Can it be based on number of orders instead of quantity? [closed]

magento.stackexchange https://magento.stackexchange.com/questions/108257

  •  29-09-2020
  •  | 
  •  

Question

I just want to know how bestseller is determined. Is it simply based on the quantity of a product ordered? Can it be based on how many orders you have for the product?

For example Product 1 has a minimum qty to order of 500 and product 2 has no minimum qty to order. Say I order 500 orders of product 1 and then order 5 of product 2 in 2 separate orders to total 10 quantity. Could I have my bestseller section setup to show product 2 as the bestseller seeing as two orders were placed opposed to product 1 with 500?

Was it helpful?

Solution

Best sellers are reported on QTY ordered. You can see this by looking at the SQL query generated from the sales reports. (note the SQL below may not be 100% true to core reports SQL as the SQL may have been altered by my Dynamic Category Products extension but the crux of it will be the same)

SELECT 
    SUM(order_items.qty_ordered) AS `ordered_qty`,
    `order_items`.`name` AS `order_items_name`,
    `order_items`.`product_id` AS `entity_id`,
    `e`.`entity_type_id`,
    `e`.`attribute_set_id`,
    `e`.`type_id`,
    `e`.`sku`,
    `e`.`has_options`,
    `e`.`required_options`,
    `e`.`created_at`,
    `e`.`updated_at`
FROM
    `sales_flat_order_item` AS `order_items`
        INNER JOIN
    `sales_flat_order` AS `order` ON `order`.entity_id = order_items.order_id
        AND `order`.state <> 'canceled'
        AND (`order`.created_at BETWEEN '2014-11-15 0:00:00' AND '2016-03-29')
        LEFT JOIN
    `catalog_product_entity` AS `e` ON (e.type_id NOT IN ('grouped' , 'configurable', 'bundle'))
        AND e.entity_id = order_items.product_id
        AND e.entity_type_id = 4
        INNER JOIN
    `catalog_product_website` AS `product_website` ON product_website.product_id = e.entity_id
        AND product_website.website_id IN ('1')
WHERE
    (parent_item_id IS NULL)
        AND (e.entity_id IN (SELECT DISTINCT
            `e`.`entity_id`
        FROM
            `catalog_product_entity` AS `e`
        GROUP BY `e`.`entity_id`))
GROUP BY `order_items`.`product_id`
HAVING (SUM(order_items.qty_ordered) > 0)
ORDER BY `ordered_qty` DESC , `order_items_name` ASC
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top