I'm trying to get Best Seller Product collection using below code, but it will not display any data

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$productCollection = $objectManager->create('\Magento\Sales\Model\ResourceModel\Report\Bestsellers\CollectionFactory');
$collection = $productCollection->create()->setModel('Magento\Catalog\Model\Product')->setPeriod('yearly');

How to get Best Seller Product collection ?

  • it might not working because you have set "yearly" instead of "year", please check my ans for more information. – Aasim Goriya Feb 13 '19 at 9:51

Please try this code to get best seller product collections using objectManager.

$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) {
| improve this answer | |
  • Hi Aasim Goriya I have used same logic in my custom block but it is displaying empty records (those are not available currently at admin end products grid) could you please advise? – Nagaraju K Apr 9 '19 at 10:43
  • Exclude empty records using filters at code level – Nagaraju K Apr 9 '19 at 10:44
  • @AssimGoriya, How can i get latest month's best seller product? any Idea? – Sanjay Gohil Apr 26 '19 at 10:02

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.