Model/ResourceModel/Catalog.php
public function getBestsellerCollection($from, $to, $limit, $storeId)
    {
        //create report collection
        $reportProductCollection = $this->productSoldFactory->create()
            ->addOrderedQty($from, $to)
            ->setOrder('ordered_qty', 'desc')
            ->setStoreIds([$storeId])
            ->setPageSize($limit);

        $productsSku = $reportProductCollection->getColumnValues('order_items_sku');

        return $this->getProductsCollectionBySku($productsSku);
    }
public function getBestsellerCollection($from, $to, $limit, $storeId)
    {
        //create report collection
        $reportProductCollection = $this->productSoldFactory->create()
            ->addOrderedQty($from, $to)
            ->setOrder('ordered_qty', 'desc')
            ->setStoreIds([$storeId])
            ->setPageSize($limit);

        $productsSku = $reportProductCollection->getColumnValues('order_items_sku');

        return $this->getProductsCollectionBySku($productsSku);
    }
public function getBestsellerCollection ( $ from , $ to , $ limit , $ storeId ) { //create report collection $ reportProductCollection = $ this -> productSoldFactory -> create ( ) -> addOrderedQty ( $ from , $ to ) -> setOrder ( 'ordered_qty' , 'desc' ) -> setStoreIds ( [ $ storeId ] ) -> setPageSize ( $ limit ) ; $ productsSku = $ reportProductCollection -> getColumnValues ( 'order_items_sku' ) ; return $ this -> getProductsCollectionBySku ( $ productsSku ) ; }
Get bestseller collection.

@param string $from
@param string $to
@param int $limit
@param int $storeId

@return array|\Magento\Catalog\Model\ResourceModel\Product\Collection
Get bestseller collection .