Created
August 16, 2015 16:52
-
-
Save mpchadwick/441940792e151af5b081 to your computer and use it in GitHub Desktop.
Magento Best Sellers - Configurable Products
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
cpf.entity_id, | |
cpf.name, | |
cpf.type_id, | |
( | |
SELECT SUM(sbam.qty_ordered) | |
FROM sales_bestsellers_aggregated_monthly sbam | |
LEFT JOIN catalog_product_super_link cpsl | |
ON cpsl.product_id = sbam.product_id | |
WHERE sbam.product_id = cpf.entity_id | |
OR cpsl.parent_id = cpf.entity_id | |
) qty_ordered | |
FROM catalog_product_flat_1 cpf | |
INNER JOIN catalog_category_product_index ccpi | |
ON ccpi.product_id = cpf.entity_id | |
AND ccpi.store_id = 1 | |
AND ccpi.visibility IN (2, 4) | |
ORDER BY qty_ordered DESC; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If we don't need to add orders of child simple products we wind up with this...