Magento 2: Override/Rewrite Block, Model, Controller, Helper using Plugin & Preference

This article shows how you can override / rewrite Block, Controller, Model, and Helper in Magento 2. This can be done by two ways: 1) using Preference 2) using Plugin Preference is similar to class rewrite in Magento 1. There is always possibility of conflict when two or more custom modules try to rewrite/override same … Read more

Magento: Avoid Module/Extension Rewrite/Override Class Conflict

While developing Magento modules/extensions, we often come up with a case where our module and some other module are rewriting/overriding the same core class. Hence, we get a conflict here and either our module or the other module will not function as expected. There are some ways to avoid such conflicts. I will explain about … Read more

Magento: Overriding / Rewriting Mysql4 and Resource Eav Collection Class

Here is a tip to override/rewrite Mysql4 and Resource Eav collection class. I will only be including the config xml code. You can read more about Model Overriding over here: Magento: Model Controller Block Helper Override By Mysql4 Collection Class, I mean like the following class: Mage_Sales_Model_Mysql4_Order_Collection Overriding Mysql4 Collection Class <global> <models> <sales_mysql4> <rewrite> … Read more

PHP: Simple and easy way to format URL string

Here, I will be showing you a simple and easy one line code to format URL string with PHP. By URL string, I mean the url key in any Search Engine Friendly URL. I have used preg_replace function to do so. preg_replace($pattern, $replacement, $string) preg_replace function performs a regular expression search and replace. This will … Read more