2

I have a custom module for checkout. I want to add some custom code for function _getStepCodes() in app/code/core/Mage/Checkout/Block/Onepage/Abstract.php

I found that abstract functions cannot be override or rewrite.

How can I add custom to the function _getStepCodes() in my custom module. Is it possibe to add this function to app/code/local/Vendor/Modulename/Block/Onepage/Abstract.php ?

Any help would be appreciated.

2

It must be understood that Abstract class can't be rewrited but overrided.

The reason is : because the abstract classes are not instantiated !

Rewrite : When you add config nodes in config.xml.

Override : When you copy the class from core to local.

If you want to customise some method in this abstract class, you have to copy the same path to your local, in your case: from app/code/core/Mage/Checkout/Block/Onepage/Abstract.php to app/code/local/Mage/Checkout/Block/Onepage/Abstract.php.

So here Magento takes first the folder from local, he takes what you have updated then he go the core one.

  • I want to add all custom code to my custom module. Is it possible to add the function to app/code/local/Vendor/Checkouykout/Block/Onepage/Abstract.php rather than copying to app/code/local/Mage/Checkout/Block/Onepage/Abstract.php ? I hope my question is clear. – Vindhuja Jul 26 '17 at 8:25
  • I didn't understand, please read again my answer carefully. – PЯINCƏ Jul 26 '17 at 8:39
  • Thanks for your reply. I understood your answer. As I am writing this as a custom module, on disabling this module, the default checkout should work. The file location app/code/local/Mage/Checkout/Block/Onepage/Abstract.php will not be a part of my custom module. ie what I am asking is it possible to include my custom code function to custom module only. – Vindhuja Jul 26 '17 at 9:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.