---
title: "How to Redirect Category with Single Product to Product Page in Magento 2"
url: "https://magecomp.com/blog/redirect-category-with-single-product-to-product-page-in-magento-2/"
date: "2016-02-08T10:30:47+00:00"
modified: "2025-02-22T10:29:05+00:00"
author:
  name: "Dhiren Vasoya"
  url: "https://magecomp.com/"
categories:
  - "How To"
  - "Magento 2"
word_count: 427
reading_time: "3 min read"
summary: "The most successful Ecommerce stores never fail to provide best user experience to their customers by any means. One of the most important aspect of it is to minify pageloads and avail customers wi..."
description: "This Magento 2 tutorial provides you with a simple trick to redirect category with single product to product page"
keywords: "How To, Magento 2"
language: "en"
schema_type: "Article"
related_posts:
  - title: "Best Magento 2 Web Push / Firebase Notification Extension Providers in 2026"
    url: "https://magecomp.com/blog/best-magento-2-web-push-notification-extension-providers/"
  - title: "How Social Media Helps To Drive Your Business Sales"
    url: "https://magecomp.com/blog/social-media-helps-drive-business-sales/"
  - title: "How to Show List of All Categories with Links at Sidebar on Category Page in Magento 2"
    url: "https://magecomp.com/blog/show-list-categories-links-sidebar-category-page-magento-2/"
---

# How to Redirect Category with Single Product to Product Page in Magento 2

_Published: February 8, 2016_  
_Author: Dhiren Vasoya_  

![How to Redirect Category with Single Product to Product Page in Magento 2](https://magecomp.com/blog/wp-content/uploads/2016/02/How-to-Redirect-Category-with-Single-Product-to-Product-Page-in-Magento-2-1024x332.webp)

The most successful Ecommerce stores never fail to provide best user experience to their customers by any means. One of the most important aspect of it is to minify pageloads and avail customers with smoother navigation. This idea can be used in many cases. Let’s take an example of a category with single product.

[![hyva theme development](https://magecomp.com/blog/wp-content/uploads/2025/02/hyva-theme-development-CTA-5.webp)](https://magecomp.com/services/hyva-theme-development/) Redirecting customers to the category page and then to perform repeated click only to move to the product page may be useless in majority of situation. (It’s useful when a category describes some important information before visiting product page.) This illustration creates a need of finding the solution to redirect customers directly on product page in order to provide better navigation.

Let’s take a look at how we can achieve this in **Magento 2**. This requires developing a custom extension with the below code.

1. As stated above, you need to create a small custom extension and modify the block’s method behavior for getting products collection.
    Create etc/di.xml in your extension with the following code:

```

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
<type name="MagentoCatalogBlockProductListProduct">
    <plugin name="firstproduct-category-mod" type="VendorFirstProductBlockCatalogProductListProduct" sortOrder="1"/>
</type>
</config>
```

> Redirect straight to Product page on click of a category with single product in [#Magento2](https://twitter.com/hashtag/Magento2?src=hash) <https://t.co/Nz1oxr6dsN>
>
> — MageComp (@theMageComp) [February 15, 2016](https://twitter.com/theMageComp/status/699130317265838088)

2. then create the plugin class Block/Catalog/Product/ListProduct.php with the code below:

```

<?php

namespace VendorFirstProductBlockCatalogProduct;

class ListProduct
{
    /**
     * @var MagentoFrameworkAppResponseHttp
     */
    protected $response;

    public function __construct(
       MagentoFrameworkAppResponseHttp $response
    )
    {
        $this->response = $response;
    }

    /**
     * @param MagentoEavModelEntityCollectionAbstractCollection $resultCollection
     * @param MagentoCatalogBlockProductListProduct $subject
     * @return MagentoEavModelEntityCollectionAbstractCollection $resultCollection
     */
    public function afterGetLoadedProductCollection(MagentoCatalogBlockProductListProduct $subject, $resultCollection)
    {
        if ($resultCollection->count() == 1) {
            /** @var MagentoCatalogModelProduct $product */
            $product = $resultCollection->getFirstItem();
            $this->response->setRedirect($product->getProductUrl());
        }

        return $resultCollection;
    }
}
```

[![Hire Magento Programmer](https://magecomp.com/blog/wp-content/uploads/2025/02/Hire-Magento-Programmer-CTA-2.webp)](https://magecomp.com/services/hire-magento-programmer/)

Clear the Magento default or other cache you are using.

You can also install the [extension](https://magecomp.com/blog/wp-content/uploads/2016/02/Magecomp_Firstproduct.zip) to implement the above functionality directly to your Magento store.

This extension is prepared using the code of [Yaroslav Rogoza](https://twitter.com/rogyar%22%20target=%22_blank%22%20rel=%22noopener%20noreferrer) done on this GitHub Repo. We are thankful to him for this.
Leave comment if you face any trouble with it.

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


---

_View the original post at: [https://magecomp.com/blog/redirect-category-with-single-product-to-product-page-in-magento-2/](https://magecomp.com/blog/redirect-category-with-single-product-to-product-page-in-magento-2/)_  
_Served as markdown by [Third Audience](https://github.com/third-audience) v3.5.3_  
_Generated: 2026-05-21 15:02:59 UTC_  
