---
title: "How to Override a Helper File in Magento 2"
url: "https://magecomp.com/blog/override-a-helper-file-magento-2/"
date: "2017-11-28T17:37:36+00:00"
modified: "2025-06-06T03:06:26+00:00"
author:
  name: "Dhiren Vasoya"
  url: "https://magecomp.com/"
categories:
  - "How To"
  - "Magento 2"
word_count: 296
reading_time: "2 min read"
summary: "Magento projects always end up at customization to fulfill the needs of a store owner or to enhance store functionality &amp; shopping experience. This customization includes adding or overriding e..."
description: "Step by step guide to override a helper file in Magento 2 to provide a personal touch to Magento 2 stores & enhance store functionality."
keywords: "How To, Magento 2"
language: "en"
schema_type: "Article"
related_posts:
  - title: "How to Create Order Programmatically in Magento 2"
    url: "https://magecomp.com/blog/create-order-programmatically-in-magento-2/"
  - title: "Difference Between: Magento 2 WhatsApp Order Notification vs. Magento 2 SMS Notification"
    url: "https://magecomp.com/blog/difference-between-magento-2-whatsapp-order-notification-vs-magento-2-sms-notification/"
  - title: "Magento 2: Add Track Order link with the Order on Order History Page"
    url: "https://magecomp.com/blog/magento-2-add-track-order-link-on-order-history-page/"
---

# How to Override a Helper File in Magento 2

_Published: November 28, 2017_  
_Author: Dhiren Vasoya_  

![img How to override a helper file in Magento 2](https://magecomp.com/blog/wp-content/uploads/2017/11/img_How-to-override-a-helper-file-in-Magento-2-1024x332.webp)

Magento projects always end up at customization to fulfill the needs of a store owner or to enhance store functionality & shopping experience. This customization includes adding or overriding existing elements, provides a personal touch and enhance the functionality of Magento 2 stores, indirectly reflects to business revenue. We have never recommended modifying default Magento core files, but alternative way is to override core files. There are several methods to override helper class, but pick any of it depending on the situation.

[![Magento Malware Removal](https://magecomp.com/blog/wp-content/uploads/2025/02/Magento-Malware-Removal-CTA-5.webp)](https://magecomp.com/magento-malware-removal.html)

Compared to Magento 1, overriding and manipulating with classes is becoming much easier for a developer & allows us more ways of extending the native functionalities. One of our client was facing an issue while overriding helper file so we found and implement the solution. Here I’ve come up with the easiest way to ***override a helper file in Magento 2***. You can even come to us with your requirement to customize your Magento store as per your need.

[![Magento 2 Speed & Performance Optimization Services](https://magecomp.com/blog/wp-content/uploads/2025/02/Magento-2-Speed-Performance-Optimization-Services-CTA-1.webp)](https://magecomp.com/magento-performance-optimization.html)

**Step 1:** First, we need to create a **“di.xml”** file inside the extension in the below directory

**app\code\Vendor\Extension\etc**

```
<?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="VendorExtensionHelperBundel" />
</config>
```

**Step 2:** lastly, we need to create a **“Bundel.php”** file inside the extension in the below directory

**Vendor\Extension\Helper\Bundel.php**

```
<?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.
If you have faced any issue while overriding helper class, let us know in the comment section.

[![hyva theme development](https://magecomp.com/blog/wp-content/uploads/2025/02/hyva-theme-development-CTA-5.webp)](https://magecomp.com/services/hyva-theme-development/)
Happy Overriding!


---

_View the original post at: [https://magecomp.com/blog/override-a-helper-file-magento-2/](https://magecomp.com/blog/override-a-helper-file-magento-2/)_  
_Served as markdown by [Third Audience](https://github.com/third-audience) v3.5.3_  
_Generated: 2026-08-21 04:34:27 UTC_  
