I'm creating a report using the Magento databse and I just can't get it to cooperate with me.
I need to list the categories of a shop as well as how many Active Products there are in each category.
Ie: Bags (5) Shoes (12) Pencils (6)
etc.
what I found so far is that:
catalog_category_flat_store_9 lists the categories of the store along with a category id
the category id can be used in
catalog_category_productto get Product id'sthe Product id can be used in
catalog_product_entityto get the sku (and to filter out the configured Products)the sku can be used in
catalog_product_flat_9to get an entity id (which is retarded - they should have just included the categories and if it's active in there)the entity id can be used in
catalog_product_entity_intto get a list of integerseav_attributecan be used to find that attribute id 96 (in my case) is the status attribute that shows wether or not something is Active
is this the right way to go about or is there a much simpler way of doing this?
So far, I've gotten as far as
SELECT entity_id FROM `catalog_product_flat_9` WHERE sku = (SELECT p.sku
FROM catalog_product_entity AS p
LEFT JOIN catalog_category_product AS cp ON p.entity_id = cp.product_id
WHERE p.type_id = 'simple'
AND cp.category_id = 89)
which isn't working, but at least it's a start