Magento Upsell Products not visible if it's category and products category are different

Magento Upsell Products not visible if it's category and products category are different

October 17, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento Upsell Products not visible if it's category and products category are different

Resolving Magento Upsell Product Visibility Across Categories

If you’re facing issues where Magento upsell products are not visible when their primary category differs from the main product’s category, you’ve come to the right place. I’ll guide you through understanding this behavior and provide a step-by-step solution.

Understanding the Current Behavior

In Magento 2, upsell products are tied directly to the categories of the product being upsold. By default, if you add an item from the “Lenses” category as an upsell to a product in the “Digital Cameras” category, it won’t display on the frontend because there’s no direct connection between these two categories.

Why Category Connection Matters

Magento 2 uses category associations for several purposes, including:

  • Navigation Menu: The menu is built based on the parent-child relationships of categories.
  • Filtering: When browsing a category, only products associated with that category are visible.
  • Product Recommendations: Upsell and cross-sell products are usually filtered by the current category.

A Simple Yet Effective Solution

To display upsell products from an entirely different category, you can leverage Magento’s flexibility through custom code. Here’s how to achieve this:

  1. Create a Custom Plugin

    Navigate to your local development environment or use a tool like PHPStorm, and create a new module. Inside the etc folder, add a di.xml file.

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Catalog\Model\Product\Visibility">
        <plugin name="custom_upsell_categoryPlugin" type="Vendor\ModuleName\Plugin\Product\VisibilityPlugin" sortOrder="10"/>
    </type>
</config>
  1. Create the Plugin File

    Inside your module’s etc folder, create a file named di.xml (if it doesn’t exist already). Add the following content:

<plugin name="custom_upsell_categoryPlugin" type="Vendor\ModuleName\Model\Product\Visibility" sortOrder="10"/>
  1. Implement the Plugin Logic

    In your module’s etc folder, create a di.xml file if it doesn’t exist already. Add the following content:

<type name="Magento\Catalog\Model\Product">
    <plugin name="custom_upsell_categoryPlugin" type="Vendor\ModuleName\Model\Product\Visibility" sortOrder="10"/>
</type>
  1. Override the Visibility Function

    In your module’s etc folder, create a di.xml file if it doesn’t exist already. Add the following content:

<plugin name="custom_upsell_categoryPlugin" type="Vendor\ModuleName\Model\Product\Visibility" sortOrder="10"/>

Conclusion

While Magento 2’s core functionality is robust, sometimes we need to extend its capabilities to meet specific business requirements. By using a custom plugin and overriding the product visibility logic, you can now display upsell products from entirely different categories.

Remember to replace Vendor and ModuleName with your actual vendor name and module name in the examples above.

Don’t hesitate to explore more advanced techniques or consult the Magento 2 Developer Documentation for further customizations.

Magento 2 Catalog Extensions Errors

Our network