Magento 2 How to Display All Products in One Page?

Description when show all product

When creating a page to show all the products in the store, customers can see more comprehensively about the store’s products.

  1. Shows the native toolbar, for sorting/pagination
  2. Makes your “All” products “page” show up in the category navigation menu (you can change this with “Show In Navigation” dropdown.)
  3. Allows you to set the default sorting preferences, to show newest products first, or whatever sorting you desire.

Today, I am going to show everybody a best practice, How to display all products on one page in Magento 2. I mean create a page show all products in Magento 2. In this exercise, I am going to create a page called “One Page Products”, that it will display all products same as the category detail page.

Create Module OnePageProduct

Step 1: Create a new module named Magepow_OnePageProducts

  • Create the file named registration.php in the path app/code/Magepow/OnePageProducts

  • Create the file named module.xml in the path app/code/Magepow/OnePageProducts/etc/module.xml
<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Magepow_OnePageProducts" setup_version="2.0.0" />

Step 2: Declare the route named magepow to accessing this page

  • Create the file named routes.xml in the path app/code/Magepow/OnePageProducts/etc/frontend/routes.xml
<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
    <router id="standard">
        <route id="magepow" frontName="magepow">
            <module name="Magepow_OnePageProducts" />

Step 3: Create the action named Onepage in the controller named Product

  • Create the Onepage.php file in the path app/code/Magepow/OnePageProducts/Controller/Product/Onepage.php

namespace Magepow\OnePageProducts\Controller\Product;

class Onepage extends \Magento\Framework\App\Action\Action
     * @var \Magento\Catalog\Api\CategoryRepositoryInterface
    protected $categoryRepository;

     * @var \Magento\Store\Model\StoreManagerInterface
    protected $_storeManager;

     * @var \Magento\Framework\Registry
    protected $_coreRegistry;

     * @var \Magento\Framework\View\Result\PageFactory
    protected $resultPageFactory;

     * @param \Magento\Framework\App\Action\Context $context
     * @param \Magento\Framework\Registry $coreRegistry
     * @param \Magento\Catalog\Api\CategoryRepositoryInterface $categoryRepository
     * @param \Magento\Store\Model\StoreManagerInterface $storeManager
     * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
    public function __construct(
        \Magento\Framework\App\Action\Context $context,
        \Magento\Framework\Registry $coreRegistry,
        \Magento\Catalog\Api\CategoryRepositoryInterface $categoryRepository,
        \Magento\Store\Model\StoreManagerInterface $storeManager,
        \Magento\Framework\View\Result\PageFactory $resultPageFactory
    ) {
        $this->_coreRegistry = $coreRegistry;
        $this->categoryRepository = $categoryRepository;
        $this->_storeManager = $storeManager;
        $this->resultPageFactory = $resultPageFactory;

     * @return \Magento\Framework\View\Result\Page
    public function execute()
        $store = $this->_storeManager->getStore();
        $category = $this->categoryRepository->get(
        $title = $this->_prepareLayout();
        $this->_coreRegistry->register('current_category', $category);

        $page = $this->resultPageFactory->create();
                'label' => __('Home'),
                'title' => __('Go to Home Page'),
                'link' => $store->getBaseUrl()
                'label' => __('All View Products'),
                'title' => __('All View Products')
        $page->getConfig()->getTitle()->set(__('All View Products'));
        $page->getConfig()->setDescription(__('All View Products'));
        $page->getConfig()->setKeywords(__('All View Products'));
        $page->getConfig()->addRemotePageAsset($this->_url->getUrl('magepow/product/onepage'), 'canonical', ['attributes' => ['rel' => 'canonical']]);

        return $page;
public function _prepareLayout()  
    $this->pageConfig->getTitle()->set(__('All View Products'));  
    return parent::_prepareLayout();  

Step 4: Create the layout named magepow_product_onepage.xml

  • The structure of a layout will be app/code/Magepow/OnePageProducts/view/frontend/layout/magepow_product_onepage.xml
<?xml version="1.0"?>

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <update handle="catalog_category_view" />
    <update handle="catalog_category_view_type_layered" />

Step 5: Install the new module

run commands.

php bin/magento setup:upgrade

php bin/magento setup:static-content:deploy -f

php bin/magento cache:flush


Test and see the results- Go to the page with the path magepow/product/onepage

Thank you for your watching. If you have any questions about this best practice please feel free to leave a comment below.

Hope this article will help you in some way, You can see useful articles in the next articles.

Anything you need support from Magento 2 feels free to contact us at Magepow and

Phone: (+84)865633728

Email: support@alothemes.com