1

I have Magento 1.9 CE and I'm trying to create a new module for extend the class Mage_Paypal_Controller_Express_Abstract, but it doesn't work.
Here's the code:

Name_Module.xml in /app/etc/modules

<?xml version="1.0"?>
  <config>
    <modules>
     <Name_Module>
        <active>true</active>
        <codePool>local</codePool>
        <depends></depends>
     </Name_Module>
  </modules>
</config>

config.xml from /app/code/local/Name/Module/etc/

<?xml version="1.0"?>
 <config>
  <modules>
    <Name_Module>
        <version>1.0.0</version>
    </Name_Module>
</modules>
<frontend>  
    <routers>
          <paypal>
            <args>
                <modules>
                        <Name_Module before="Mage_Paypal">Name_Module _Paypal</Name_Module >
                </modules>
             </args>
        </paypal>
    </routers>
</frontend>

and Abstract.php app/code/local/Name//Controller/Paypal/Express/

<?php
include_once('Mage/Paypal/Controller/Express/Abstract.php');
class Name_Module_Paypal_Express_Abstract extends        Mage_Paypal_Controller_Express_Abstract{

/**
 * Submit the order
 */
 public function placeOrderAction()
 {
      //code
  }
 }

Why doesn't it work?

  • "it doesn't work". What doesn't work? What should it do and doesn't do? Please describe any faults, errors (add error logs), screenshots, etc... – 7ochem Sep 15 '15 at 11:09
  • use <depends>Mage_Paypal</depends> instead of <depends></depends> – Amit Bera Sep 15 '15 at 11:32
1

You can't overwrite an Abstract class in Magento. The class that you are trying to overwrite Mage_Paypal_Controller_Express_Abstract is an abstract class and hence can't rewrite by controller-rewrite way.

If you want to edit placeOrderAction(), the only possible way is put that core file in local codepool. For this :

  1. Create a file app\code\local\Mage\Paypal\Controller\Express\Abstract.php
  2. Copy paste original content of the file Abstarct.php to this file.
  3. Now edit placeOrderAction() according to your need.
0

In Magenton abstract class does not override ....SO you can not rewrite class

Mage_Paypal_Controller_Express_Abstract.... 

Also there lot issue in code;

use <depends>Mage_Paypal</depends> instead of <depends></depends>

  • unfortunately nothing changes – Oblomova Sep 15 '15 at 13:12
0

Mage_Paypal_Controller_Express_Abstract is a basic class which implements common methods, you dont need to rewrite it.

Instead you need to define which payment method you want to modify excalty. In your case I suppose it is a Mage_Paypal_ExpressController.

So, all you need to rewrite Mage_Paypal_ExpressController class and implement own logic for method placeOrderAction().

It will work because Mage_Paypal_ExpressController extends Mage_Paypal_Controller_Express_Abstract and all methods you define in Mage_Paypal_ExpressController will replace methods from parent class.

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.