I'm new to Magento 2. I want to show the sold count of product only after the order was complete.
I have used this code to display count.
$_product = $block->getProduct();
$sku = $_product->getSku();
$objectModelManager = \Magento\Framework\App\ObjectManager::getInstance ();
$soldproduct = $objectModelManager->get('Magento\Reports\Model\ResourceModel\Product\Sold\Collection')->addOrderedQty()->addAttributeToFilter('sku', $sku)->setOrder('ordered_qty', 'desc')->getFirstItem();
$soldnumber = $soldproduct->getOrderedQty();
?> <div class="sold_count"><b>Sold Count: </b> <?php echo (int)$soldnumber;?> </div>
But for every order placement the count is increasing.But I want show the count of products whose status was completed.
Thanks in advance