How to Change Cross-Sell Product Limit in Magento 2 -
Hello magento friends todays in this blog post im share with you to How to Change Cross-Sell Product Limit in Magento 2. In Magento 2, the cross-sell product limit is the maximum number of cross-sell products displayed on a product page. By default, Magento 2 limits the number of cross-sell products to 4. If you want to change this limit, you can follow these steps:
Please note that modifying core files directly is not recommended in Magento, as it can lead to compatibility issues and difficulties during future upgrades. It's better to use custom modules or themes to make changes. Here's how you can achieve this through a custom module:
➤ Create a Custom Module:
Create a new directory for your module in the app/code directory of your Magento installation. For example, if your company name is "MyCompany" and your module name is "CustomCrossSell", your module directory would be app/code/MyCompany/CustomCrossSell.
Inside your module directory, create the necessary subdirectories and files according to Magento's module structure.
➤ Define Module Configuration:
Create a registration.php file in your module directory to register your module.
Create a etc/module.xml file in your module directory to define your module.
➤ Create Configuration File:
Create a etc/frontend/di.xml file in your module directory to override the default configuration.
➤ Override Default Configuration:
In the di.xml file, add the following content to override the default cross-sell product limit:
In this example, we're changing the cross-sell product limit to 6. You can replace the 6 with your desired limit.
➤ Enable the Module:
Run the following commands from your Magento root directory:
➤ Check the Result:
After enabling the module and clearing the cache, visit a product page on your Magento store that has cross-sell products. You should now see the updated cross-sell product limit.
Please keep in mind that this is just a basic guide to achieve the desired outcome. Depending on your specific requirements and setup, you might need to adjust these steps or handle additional aspects of module development. Always remember to test your changes thoroughly before deploying them to a production environment.