To override Magento 2 Helper file, follow below steps.
First, you need to create a di.xml file at below desired location.
Go to Vendor/Extension/etc/di.xml And add the following code into 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="MagentoBundleHelperData" type="VendorExtensionHelperBundle"/> </config>
Next step is to create bundle.php file at VendorExtensionHelperBundle.php
After that, you need to write your own customization logic in the file.
<?php
namespace VendorExtensionHelper;
use MagentoBundleHelperData as MainHelper;
class Bundel extends MainHelper
{
public function getAllowedSelectionTypes()
{
//write your logic here
}
}
?>
It’s done. You have successfully override helper class using this method.

