Code Customization (Override)

From version 5, EShop has a mechanism to allow you to override it's code (static methods, model, view, controller classes). So in case you have to customize EShop to meet your own need, you won't have to worry about upgrading to loosing this customization while updating to future releases of EShop anymore. Below you can see the details:

Override static methods (helper methods)

EShop has a helpers class which you can see in components/com_eshop/helpers/helper.php. Currently, the following static methods can be overrided:

  1. EShopHelper::getAdminQuoteEmailBody
  2. EShopHelper::getCustomerQuoteEmailBody
  3. EShopHelper::getAdminEmailBody
  4. EShopHelper::getManufacturerEmailBody
  5. EShopHelper::getCustomerEmailBody
  6. EShopHelper::getAdminNotifyEmailBody
  7. EShopHelper::generateInvoicePDF
  8. EShopHelper::getNotifyEmailBody
  9. EShopHelper::getReminderEmailBody
  10. EShopHelper::getAbandonCartEmailBody

To customize a method in this helper class, please folow the steps below:

  1. Create a folder override under components/com_eshop/
  2. Create a sub folder helpers under component/com_eshop/override/
  3. Create a php file with same name: helper.php under folder component/com_eshop/override/helpers/
  4. Add a blank class into that PHP file with class name: EShopOverrideHelpersHelper
/**
 * EShopOverrideHelpersHelper class
 *
 * This class can be used to override some common methods used in EShopHelper class. It is needed when you need to
 * override these methods without having to worry about losing the customization while updating to future releases of EShop
 */
class EShopOverrideHelpersHelper extends EShopHelper
{

}
  1. Copy the original code of the method you want to override into the overrided class you defined above and customize it to meet your need. Please note that these classes extends the original class, so you can call any (public/protected) methods in the parent class.

Override method in a controller class

If you need to override a method inside a controller, please follow the steps below:

  1. Create folder override under components/com_eshop folder (or under administrator/components/com_eshop/ if you want to override a backend controller)
  2. Create a sub folder controller under component/com_eshop/override/ (or under administrator/components/com_eshop/override/)
  3. Create a php file (same name with the php file which contains the method you want to override, for example category.php, product.php, checkout.php)
  4. Add a blank class into that PHP file. The class name must follow this Rule: It has the word Override inserted into the original class name and extends the original class. For example:
/**
 * EShopOverrideControllerProduct class
 *
 * This class is used to show you how to override a controller class in EShop.
 */
class EShopOverrideControllerProduct extends EShopControllerProduct
{

}
  1. Copy the original code of the method you want to override into the class you defined above and customize it to meet your need. Please note that these classes extends the original class, so you can call any (public/protected) methods in the parent class.

Override method in a model class

If you need to override a method inside a model, please follow the steps below:

  1. Create folder override under components/com_eshop folder (or under administrator/components/com_eshop/ if you want to override a backend model)
  2. Create a sub folder model under component/com_eshop/override/ (or under administrator/components/com_eshop/override/)
  3. Create a php file (same name with the php file which contains the method you want to override, for example category.php, product.php, checkout.php)
  4. Add a blank class into that PHP file. The class name must follow this Rule: It has the word Override inserted into the original class name and extends the original class. For example:
/**
 * EShopOverrideModelProduct class
 *
 * This class is used to show you how to override a model class in EShop.
 */
class EShopOverrideModelProduct extends EShopModelProduct
{

}
  1. Copy the original code of the method you want to override into the class you defined above and customize it to meet your need. Please note that these classes extends the original class, so you can call any (public/protected) methods in the parent class.

Override method in a view class

If you need to override a method inside a view, please follow the steps below:

  1. Create folder override under components/com_eshop folder (or under administrator/components/com_eshop/ if you want to override a backend view)
  2. Create a sub folder view under component/com_eshop/override/ (or under administrator/components/com_eshop/override/)
  3. Create a php file (same name with the php file which contains the method you want to override, for example category.php, product.php, checkout.php)
  4. Add a blank class into that PHP file. The class name must follow this Rule: It has the word Override inserted into the original class name and extends the original class. For example:
/**
 * EShopOverrideViewProduct class
 *
 * This class is used to show you how to override a view class in EShop.
 */
class EShopOverrideViewProductHtml extends EShopViewProductHtml
{

}
  1. Copy the original code of the method you want to override into the class you defined above and customize it to meet your need. Please note that these classes extends the original class, so you can call any (public/protected) methods in the parent class.