Magento 2 - Why upsell section is displaying bundle products?

I faced one strange issue, that is we didn't add any upsell rule and we didn't add any upsell products in the prodcut via admin. But somehow upsell section is displaying associated bundle products collection when we loaded simple product collection. After debugging, we found the below observer will add the bundle products in upsell section when it matches with getAllowedSelectionTypes.

vendor/magento/module-bundle/etc/frontend/events.xml
<event name="catalog_product_upsell">
    <observer name="bundle_observer" instance="Magento\Bundle\Observer\AppendUpsellProductsObserver"/>
</event>
vendor/magento/module-bundle/Observer/AppendUpsellProductsObserver.php
if (!in_array($product->getTypeId(), $this->bundleData->getAllowedSelectionTypes())) {
    return $this;
}

We can find the same observer in the Magento official GitHub codebase. I have checked the Magento official documentation and there are no clear updates about the above observer.


I found this known issue: https://github.com/magento/magento2/issues/5665


I feel this is the worst idea without giving any controls from admin, Magento added bundle products in the simple product upsell section. At least, it should be shown the added products in the admin upsell section. If you are looking to disable this feature, please create the below events.xml in your custom extension.

app/code/Custom/Extension/etc/frontend/events.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <!-- Disabling Default Observer Magento\Bundle\Observer\AppendUpsellProductsObserver -->
    <event name="catalog_product_upsell">
        <observer name="bundle_observer" disabled="true"/>
    </event>
</config>

After that, run the needed Magento commands as setup upgrade, di-compile, static content deploy, cache flush.

I hope it helps! If you have any questions/suggestions, please mention them in the comment.



4 views0 comments

Recent Posts

See All

Check TTFB from Ubuntu terminal

We can print the TTFB multiple times by using the below command in the ubuntu terminal. for i in {0..3}; do echo -n "$i :: "; curl --resolve 'www.yoursite.com:443:your-ip' --output /dev/null -w "Respo

Magento 2.4.2 .htaccess changes...

I have just noticed, In Magento 2.4.2 release, the Magento root folder .htaccess file changed completely compared to the 2.4.1 release. I found this commit without much explanation, due to this chan

Magento 2 CMS block with the same ID already exists

I have seen the below error when I open cms block grid something went wrong with processing the default view and we have restored the filter to its original state. I found the below log in the excepti

Follow Me

  • LinkedIn
  • Twitter
  • Facebook
  • YouTube
  • Instagram

©2020 by Bilal Usean. Proudly created with Wix.com