Suppose you have 100 products on offer in your online store. Do you think that each product contributes equally to the store’s revenue? The answer is no. Instead, every store falls in line with the 80-20 rule, or popularly known as the Pareto Principle. In the context of eCommerce, this rule states that 80 percent of the store’s revenue comes only from 20 percent of the products. Therefore, store owners must capitalise on these 20 percent products and ensure they are prominent across the website. One way to do is to set up the recently viewed products Magento 2 feature.
It is simply a way to highlight the recently or most viewed products across various areas of the website, such as product pages, CMS pages, or category pages. While you may think that it serves no purpose, but it has countless benefits, including:
Firstly, by providing users a list of most recently viewed products, you provide them insights into what others are buying. This can compel them to buy the same product, thereby boosting your sales.
Another reason to set up this feature is to boost website engagement. Suppose a user does not like the product they are viewing currently. If they simply close the tab, it will impact your store’s bounce rate and you will lose a potential lead. By displaying other products, you can attract their attention. They may click on related and most viewed products, thereby boosting chances of a successful sale.
Lastly, the most recently viewed products Magento feature can prove helpful from the marketing perspective. Store owners can use these products to create product-specific marketing campaigns. This goes a long way in boosting your sales.
There are different ways to set up this functionality. One is to use a Magento 2 recently viewed products extension. For instance, you can choose and display your most viewed products with a few clicks using our Magento 2 Product Slider Extension. The other method simply involves following the below steps:
First, you need to create a block file (let’s call it BestSeller.php) in the following path.
app\code\Vendor\Extension\Block\BestSeller.php.Add the following code in the file.
<?php namespace FMEextensions\HelloWorld\Block; class BestSeller extends \Magento\Framework\View\Element\Template { protected $_collectionFactory; protected $_productsFactory; public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Reports\Model\ResourceModel\Product\CollectionFactory $productsFactory, array $data = [] ) { $this->_productsFactory = $productsFactory; parent::__construct($context, $data); } public function getMostViewedData(){ $mostViewedCollection = $this->_productsFactory->create()->addViewsCount(); return $mostViewedCollection; } }
Now insert the code shown below in the following phtml file to get product collection from block.
app\code\Vendor\Extension\view\frontend\templates\list.phtml.<?php $mostViewedProduct = $block->getMostViewedData(); ?> <h1>Most Viewed Collection.....</h1> <ul> <?php foreach ($mostViewedProduct as $viewedProduct) { ?> <li><?php echo $viewedProduct>getSku();?>--<?php echo $viewedProduct>getViews();?></li> <?php } ?> </ul>
As said earlier, you can use our Magento 2 Product Slider Extension
to display the most viewed products. It allows you to add multiple sliders to display new, bestselling, most viewed, or featured products anywhere on your product, category, and CMS pages. The extension is extremely easy to configure with a lot of useful features.You get the following features when you opt for the extension.
If you have any issue in using Magento 2 then feel free to contact our support team. They will identify and fix the issue right away.
Other Related Extensions You Might be Interested in:This blog was created with FME's SEO-friendly blog