How can I get "Monthly Best selling product" in Magento 2?
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/… – Jaimin Oct 26 '17 at 5:37
-
-
how to add filters for avoid out of stock and not visible individually from best sellers collection? – Nagaraju K Aug 22 '18 at 5:48
-
can you please look into this issue? magento.stackexchange.com/questions/239155/… – Nagaraju K Aug 22 '18 at 5:48
-
do we need to pass anything instead of month? Please update full code – jafar pinjar Nov 6 '18 at 9:41