After trying many times I’ve not made that class instance to work. So I followed the oldest CRUD technique to solve this (Which actually this class is also doing), I’ve written my own SQL
query. This WC_Admin_Report
class is also doing this. It’s kinda works like WooCommerce’s query builder. By the way the below SQL
code solved my problem-
SELECT order_item_meta__product_id.meta_value AS product_id,
Sum(order_item_meta__qty.meta_value) AS order_item_count
FROM wp_posts AS posts
INNER JOIN wp_woocommerce_order_items AS order_items
ON posts.id = order_items.order_id
INNER JOIN wp_woocommerce_order_itemmeta AS order_item_meta__qty
ON ( order_items.order_item_id =
order_item_meta__qty.order_item_id )
AND ( order_item_meta__qty.meta_key = '_qty' )
INNER JOIN wp_woocommerce_order_itemmeta AS order_item_meta__product_id
ON ( order_items.order_item_id = order_item_meta__product_id.order_item_id )
AND ( order_item_meta__product_id.meta_key = '_product_id' )
INNER JOIN wp_woocommerce_order_itemmeta AS
order_item_meta__product_id_array
ON order_items.order_item_id = order_item_meta__product_id_array.order_item_id
WHERE posts.post_type IN ( 'shop_order', 'shop_order_refund' )
AND posts.post_status IN ( 'wc-completed', 'wc-processing', 'wc-on-hold' )
AND posts.post_date >= '2016-11-15'
AND posts.post_date < '2016-11-24'
AND (( order_item_meta__product_id_array.meta_key IN ( '_product_id', '_variation_id' )
AND order_item_meta__product_id_array.meta_value IN ( '15' ) ))
GROUP BY product_id
Hope that also help you.