6

How can I get "Monthly Best selling product" in Magento 2?

1 Answer 1

13

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'); 

$collection->setPeriod('month');
//$collection->setPeriod('year');
//$collection->setPeriod('day');

foreach ($collection as $item) {
    print_r($item->getData());
}
10

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.