Here Bestseller Products Collection Not coming zero for current month or day because for this month or day we don't have any orders even it is using old records and showing some number of data in magento 2??
<?php
namespace Vendor\Module\Block;
class BestSeller extends \Magento\Framework\View\Element\Template
{
protected $_collectionFactory;
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Sales\Model\ResourceModel\Report\Bestsellers\CollectionFactory $collectionFactory
) {
$this->_collectionFactory = $collectionFactory;
parent::__construct($context, $data);
}
public function getBestSellerData(){
$bestSellerProdcutCollection = $this->_collectionFactory->create()
->setModel('Magento\Catalog\Model\Product')
->setPeriod('day') //you can add period daily,yearly
->setPageSize(8);
return $bestSellerProdcutCollection;
}
}