How can I get "Monthly Best selling product" in Magento 2?
1 Answer
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());
}
-
did you know how can i get best selling product on monthly and daily bases? I refer this link but cant get actual idea :- magento.stackexchange.com/questions/156207/…– JaiminOct 26, 2017 at 5:37
-
-
how to add filters for avoid out of stock and not visible individually from best sellers collection? Aug 22, 2018 at 5:48
-
can you please look into this issue? magento.stackexchange.com/questions/239155/… Aug 22, 2018 at 5:48
-
do we need to pass anything instead of month? Please update full code Nov 6, 2018 at 9:41