I'm trying to increase the cross-sell products on the cart page up to 5.

In Magento-1, this is possible by overriding a checkout block (or changing a var in the core). I've been trying to use something similar to do this in Magento-2 but I am unable to produce any results.

Could someone please help me with increasing the limit.

2 Answers 2


You can easily change following variable in Magento/Checkout/Block/Cart/Crosssell.php

protected $_maxItemCount = 4;

Check more detail here

NB: Don't modify core file.


Make sure your module depends on 'Magento_Checkout' module in module.xml

create Vendor/Module/etc/frontend/module.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
    <module name="Vendor_Module" setup_version="1.0.0"></module>
            <module name="Magento_Checkout"/>

Create Vendor/Module/etc/frontend/di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Checkout\Block\Cart\Crosssell" type="Vendor\Module\Block\Checkout\Block\Cart\Crosssell" />

Create Vendor/Module/Block/Checkout/Block/Cart/Crosssell.php

namespace Vendor\Module\Block\Checkout\Block\Cart;

use Magento\CatalogInventory\Helper\Stock as StockHelper;

class Crosssell extends \Magento\Checkout\Block\Cart\Crosssell
    public function __construct(
        \Magento\Catalog\Block\Product\Context $context,
        \Magento\Checkout\Model\Session $checkoutSession,
        \Magento\Catalog\Model\Product\Visibility $productVisibility,
        \Magento\Catalog\Model\Product\LinkFactory $productLinkFactory,
        \Magento\Quote\Model\Quote\Item\RelatedProducts $itemRelationsList,
        StockHelper $stockHelper,
        array $data = []
    ) {
        // this variable you can change what you need
        $this->_maxItemCount = 8;
  • Never edit core files. Jun 7, 2017 at 14:55
  • Yes, But he is looking for class for overwrite.
    – Sohel Rana
    Jun 7, 2017 at 15:00
  • @SohelRana by default 4 product will display in magento2? Jun 12, 2019 at 8:54
  • Yes @NagarajuK by default 4 product will display. check this file Magento\Checkout\Block\Cart\Crosssell variable $_maxItemCount.
    – Msquare
    Dec 3, 2020 at 10:10

For magento 2 Store > Configuration > Catalog > Catalog > Rule-Based Product Relations > Maximum Number of Products in Cross-Sell Product List

  • This seems to be in adobe commerce only, not the community version
    – omerts
    Aug 4, 2021 at 21:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.