12

For bestseller create a block in __construct get instance of \Magento\Sales\Model\ResourceModel\Report\Bestsellers\CollectionFactory $collectionFactory, ex <?php namespace Sugarcode\Test\Block; class Test extends \Magento\Framework\View\Element\Template { protected $_coreRegistry = null; protected $_collectionFactory; public function ...


12

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-&...


8

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\...


4

I have created something similar using following code. app/code/Anshu/Bestsellerwidget/registration.php <?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, 'Anshu_Bestsellerwidget', __DIR__ ); app/code/Anshu/Bestsellerwidget/etc/module.xml <?xml version="1.0"?> &...


4

Sales module has a cronjob defined in magento/module-sales/etc/crontab.xml: <job name="aggregate_sales_report_bestsellers_data" instance="Magento\Sales\Model\CronJob\AggregateSalesReportBestsellersData" method="execute"> <schedule>0 0 * * *</schedule> </job> So you have to configure your Magento's cron to be running ...


4

Step 1: Create a block file <?php namespace QaisarSatti\HelloWorld\Block; class BestSeller extends \Magento\Framework\View\Element\Template { protected $_collectionFactory; public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Sales\Model\ResourceModel\Report\Bestsellers\CollectionFactory $collectionFactory, ...


3

I got the answer by just adding following code in my css file float:left


3

Check my code below for more information : You can also download my extension from Github. https://github.com/hirenrk4/Magento-2-Best-Seller This way user can get a Category and sub category best the selling product for each category I've created the module following your instructions to Best sellerFilter On category list Page Filter. app/code/Hiren/...


3

Admin panel has a section Reports/Refresh Statistics. Select an item(Bestsellers) and press submit.


3

Try code below : protected $_collectionFactory; public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Sales\Model\ResourceModel\Report\Bestsellers\CollectionFactory $collectionFactory, array $data = [] ) { $this->_collectionFactory = $collectionFactory; parent::__construct($context, $data); } public ...


3

It's very simple, you just need to add below code in your di.xml file here in your custom module app/code/Vendor/Module/etc/di.xml Content for this file is.. <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <preference for="Magento\Sales\Model\...


2

you can try the following solutions. 1) try extension. https://www.magentocommerce.com/magento-connect/best-seller-products-extension.html 2) create your modules http://inchoo.net/magento/bestseller-products-in-magento/ https://blog.amasty.com/how-to-display-bestselling-products-in-magento-source-code/ http://way2discuss.blogspot.in/2012/05/magento-...


2

M2 have some tables related to bestsell sales_bestsellers_aggregated_daily sales_bestsellers_aggregated_monthly sales_bestsellers_aggregated_yearly In code you can filter bestsell by method joinField you can do this $storeId = $this->_storeManager->getStore(true)->getId(); /** @var $collection \Magento\Catalog\Model\ResourceModel\Product\...


2

I work with the table Bestsellers to Show Bestsellers in Frontend like the class from inchoo... The table is by default empty - the Graph in backend to. If u make a Update for the Statistics then are Data available. Go in Backend to Reports > Update Reports, Select the one you want to see and chose the Action. Good Luck!


2

app/etc/modules/Dexm_Best.xml <?xml version="1.0"?> <config> <modules> <Dexm_Best> <active>true</active> <codePool>local</codePool> </Dexm_Best> </modules> </config> app/local/Dexm/Best/etc/config.xml <?xml version="1.0"?> <config> ...


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-&...


2

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(); $collection->setPeriod('month'); //$collection->setPeriod('day'); //$...


2

Its better to use productRepository:- inject BestSellerProducts class in your class via DI $bestSellerProducts->getBestSellingProducts(); your custom class can be as:- <?php namespace Vendor\ModlueName\Model; use Magento\Framework\Api\SearchCriteriaBuilder; use Magento\Catalog\Api\ProductRepositoryInterface; class BestSellerProducts { /** @...


2

open below file and declare of helper after flush and check it. app/design/frontend/default/theme/template/catalog/product/bestseller.phtml $_helper = Mage::helper('catalog/output');


1

SOLUTION Need override the file: "Mage/Catalog/Model/Resource/Product/Collection.php" Add the next function at the end of the file: public function addWebsiteFilterPurchased() { $storeId = Mage::app()->getRequest()->getParam('store'); if($storeId == null){ $storeId = Mage::app()->getStore()->getStoreId(); } $this-...


1

Did you try using following code: Mage_Reports_Model_Resource_Product_Collection /** * Add store restrictions to product collection * * @param array $storeIds * @param array $websiteIds * @return Mage_Reports_Model_Resource_Product_Collection */ public function addStoreRestrictions($storeIds, $websiteIds) { if (!is_array($storeIds)) { $...


1

Try the following code: protected $_collectionFactory; \Magento\Sales\Model\ResourceModel\Report\Bestsellers\CollectionFactory $collectionFactory, $this->_collectionFactory = $collectionFactory; $bestSellerProdcutCollection = $this->_collectionFactory->create() ->setModel('Magento\Catalog\Model\Product') ->setPageSize(8); ...


1

Its good to join the stock filter in your collection for better performance. However seeing your code you already have any answer for it. $_product->getIsSalable() Check this at top before creating your product div.


1

Simple logic behind that number of product quantity order most is bestseller product. You can also see on line 138 Magento\Sales\Model\ResourceModel\Report\Bestsellers.php 'qty_ordered' => new \Zend_Db_Expr('SUM(order_item.qty_ordered)')


1

I think you can modify Best selling product this according to your need -: collect the collection, group by orderid . setorder descending then you easily make uniques product array and setPageSize() depend on your need .


1

Take a look: vendor/magento/module-sales/Model/ResourceModel/Report/Bestsellers/Collection.php. We can see the limit: /** * Rating limit * * @var int */ protected $_ratingLimit = 5; We can try to reset the default limit, and then set the new one: $dataCollection = $collection->getSelect(); $dataCollection->reset(\Magento\Framework\DB\Select::...


1

U can used this code and get the Bestseller Product, $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'); $...


1

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-&...


1

You can try this code in that you can also filter the product by Month,year or day . $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $productCollection = $objectManager->create('Magento\Reports\Model\ResourceModel\Report\Collection\Factory'); $collection = $productCollection->create('Magento\Sales\Model\ResourceModel\Report\...


1

Vipul Jethva, In order , getting product collection of best seller ,first you need to get product ids from $products by: $ids = $products>getColumnValues('product_id'); Then create a product collection and filter that collection by $ids and category id $collection = Mage::getModel('catalog/product')->getCollection()->addIdFilter($ids); $...


Only top voted, non community-wiki answers of a minimum length are eligible