Get the Bestseller Products

Bestseller products can be displayed in Magento admin only for the Admin users. Let's see how its possible to display them also in your store for your customers!

First of all we have to create a block class where we will get all the bestseller products. Through the constructor we can get the singleton instance of a factory for a specific model using dependency injection. The factory classes that we need are the following:



We need both as the product data of the bestseller collection are not enough to show a complete product list.

So what we do, is to create an array of all bestseller product ids for the current store view, and then we use this array to filter the product collection, adding necessary data and also adding status and visibility filter.

Then in your template, you can call the getItems() function like $block->getItems() .

The full example as extension can be found here. Feel free to share this post and ask your questions in the comments below.

Till next time!