There are some tables related to bestseller in Magento 2 and it is using following tables to get best product collection.


I think, magento2 use sales_bestsellers_aggregated_yearly table for best seller products. I am using \Magento\Sales\Model\ResourceModel\Report\Bestsellers\CollectionFactory and it is working fine.

I am getting the bestseller collection yearly basis. How can i achieve bestseller collection by monthly basis or daily basis.

Thanks in advance.

  • If I want to get collection of last 2 months then ? – Kushangi Panchal Apr 2 '18 at 12:19

Try this

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$productCollection = $objectManager->create('Magento\Reports\Model\ResourceModel\Report\Collection\Factory'); 
$collection = $productCollection->create('Magento\Sales\Model\ResourceModel\Report\Bestsellers\Collection'); 


foreach ($collection as $item) {
  • are there any differences from my answer? – Max Oct 26 '17 at 14:27
  • @Max There is no difference in terms of logic. You only posted the logic of setting intervals and I posted the complete code. That's it. – Dinesh Yadav Oct 26 '17 at 15:19
  • @DineshYadav, can you provide the code with constructor rather than directly with objectManager – jafar pinjar Dec 21 '18 at 6:22

You can use \Magento\Sales\Model\ResourceModel\Report\Bestsellers\Collection::setPeriod method for define aggregation interval.

/** @var \Magento\Sales\Model\ResourceModel\Report\Bestsellers\CollectionFactory $collectionFactory */
$collection = $collectionFactory->create();

Also you can look at Magento\Reports\Block\Adminhtml\Grid\AbstractGrid for clarify interaction with magento base Report Collections.

  • Can you put full answer actually i may making some mistakes so i am not able to get output – Jaimin Oct 26 '17 at 5:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.