---
title: "Magento 2: How to Get Best Seller Products Collection"
url: "https://magecomp.com/blog/get-best-seller-products-collection-in-magento-2/"
date: "2020-07-20T14:45:53+00:00"
modified: "2025-02-20T10:03:05+00:00"
author:
  name: "Dhiren Vasoya"
  url: "https://magecomp.com/"
categories:
  - "General"
  - "Magento 2"
word_count: 428
reading_time: "3 min read"
summary: "Hello Magento pals?,"
description: "The products sold in large numbers and that are top-rated then that are recognized as BestSeller products. Learn Magento 2 Get Best Sellers Collection stepwise."
keywords: "General, Magento 2"
language: "en"
schema_type: "Article"
related_posts:
  - title: "PPC Strategies Your B2B Business Needs To Try"
    url: "https://magecomp.com/blog/ppc-strategies-for-b2b-business/"
  - title: "How to Get Product Image URL in Magento 2"
    url: "https://magecomp.com/blog/how-to-get-product-image-url-in-magento-2/"
  - title: "How to Get Bundle Product Option Image in Magento 2"
    url: "https://magecomp.com/blog/get-bundle-product-option-image-magento-2/"
---

# Magento 2: How to Get Best Seller Products Collection

_Published: July 20, 2020_  
_Author: Dhiren Vasoya_  

![How to Get Best Seller Products Collection in m2](https://magecomp.com/blog/wp-content/uploads/2020/07/How-to-Get-Best-Seller-Products-Collection-in-m2-1024x512.webp)

Hello Magento pals?,
How are you? Hopefully, I am getting you safely. Our today’s tutorial topic is Magento 2 Get Best Sellers Collection. Let me tell you about our previous topic so you can check out [**How to Add Dynamic Link to Footer in Magento 2**](https://magecomp.com/blog/add-dynamic-link-footer-magento-2/). Let’s Get Started?
[![hyva theme development](https://magecomp.com/blog/wp-content/uploads/2025/02/hyva-theme-development-CTA-4.webp)](https://magecomp.com/services/hyva-theme-development/)

## Introduction:
Magento is considered one of the leading E-commerce platforms for online stores because of its advanced features. In that, the most interesting feature is Best Seller Products. The products which are sold in large numbers and that are top-rated that are recognized as BestSeller products. It helps the customers to make a more precise decision by viewing details about the best sellers collection. For displaying the best seller products follow the below-given steps:
## Steps for Magento 2 Get Best Sellers Collection:
**Step 1:** Firstly, Create one block file on our custom extension
add Blockname.php in the following path
app\code\Vendor\Extension\Block\Blockname.php

```
<?php

namespace VendorExtensionBlock;

use MagentoCatalogBlockProductContext;
use MagentoCatalogModelResourceModelProductCollectionFactory;
use MagentoSalesModelResourceModelReportBestsellersCollectionFactory as BestSellersCollectionFactory;
use MagentoFrameworkViewElementTemplate;
use MagentoStoreModelStoreManagerInterface;

class Blockname extends Template
{
    protected $_bestSellersCollectionFactory;
    protected $_productCollectionFactory;
    protected $_storeManager;

    public function __construct(
        Context $context,
        CollectionFactory $productCollectionFactory,
        StoreManagerInterface $storeManager,
        BestSellersCollectionFactory $bestSellersCollectionFactory,
    ) {
        $this->_bestSellersCollectionFactory = $bestSellersCollectionFactory;
        $this->_storeManager = $storeManager;
        $this->_productCollectionFactory $productCollectionFactory;
	    parent::__construct($context);
    }

    public function getProductCollection()
    {
        $productIds = [];
        $bestSellers = $this->_bestSellersCollectionFactory->create()
            ->setPeriod('month');
        foreach ($bestSellers as $product) {
            $productIds[] = $product->getProductId();
        }
        $collection = $this->_productCollectionFactory->create()->addIdFilter($productIds);
        $collection->addMinimalPrice()
            ->addFinalPrice()
            ->addTaxPercents()
            ->addAttributeToSelect('*')
            ->addStoreFilter($this->getStoreId())
            ->setPageSize(count($productIds));
        return $collection;
    }

    public function getStoreId(){
        return $this->_storeManager->getStore()->getId();
    }
}
```

[![Magento version upgrade](https://magecomp.com/blog/wp-content/uploads/2025/02/Magento-2-Version-Upgrade-CTA-2-2.webp)](https://magecomp.com/services/magento-upgrade-services/)

**Step 2:** After the above step Insert the below code in phtml file at the following path.

app\code\Vendor\Extension\view\frontend\templates\list.phtml.

```
<?php
$collection = $block->getProductCollection();
foreach ($collection as $_product)
{
    echo $product->getName() . ' - ' . $product->getProductUrl() . '<br />';
}
```

**Step 3:** Flush Cache and view the result.
That’s It.
## Final Words:
After the completion of the given above steps, you will be able to get the bestseller collection in Magento 2. In case any difficulties you face in the above-given steps then list down in the comment section below I will solve it for you. Make sure you don’t forget to share the article with your developer friends and help them. Till then stay home and stay safe.
[![Magento 2 Speed & Performance Optimization Services](https://magecomp.com/blog/wp-content/uploads/2025/02/Magento-2-Speed-Performance-Optimization-Services-CTA-2.webp)](https://magecomp.com/magento-performance-optimization.html)

Happy Coding?


---

_View the original post at: [https://magecomp.com/blog/get-best-seller-products-collection-in-magento-2/](https://magecomp.com/blog/get-best-seller-products-collection-in-magento-2/)_  
_Served as markdown by [Third Audience](https://github.com/third-audience) v3.5.3_  
_Generated: 2026-09-17 02:39:04 UTC_  
