0

After recent update of a Amasty Shipping & Payment By Customer Groups plugin, it stopped working.

After running a conflict check in n98-magerun, I got a conflict like this:

enter image description here

Anyone could guide me how to solve this nicely? Thank you for your interest.

They both extend Mage_Payment_Helper_Data

Here are two files: Amasty:

<?php
/**
 * @author Amasty Team
 * @copyright Copyright (c) 2017 Amasty (https://www.amasty.com)
 * @package Amasty_Methods
 */


class Amasty_Methods_Helper_Payment_Data extends Mage_Payment_Helper_Data
{
    const PAYMENT = 'payment';

    public function getStoreMethods($store = null, $quote = null)
    {
        $methods = parent::getStoreMethods($store, $quote);
        if (!$quote) {
            return $methods;
        }

        if ( Mage::helper('ammethods')->isNullGroups(self::PAYMENT)) {
            $newMethods = array();
            $customer = $quote->getCustomer();
            foreach ($methods as $k => $method) {
                if (!Mage::helper('ammethods')->canUseMethod($method, self::PAYMENT, $customer)) {
                    continue;
                }
                $newMethods[$k] = $method;
            }
            $methods = $newMethods;
        }

        return $methods;
    }
}

SagePay:

<?php

/**
 * REWRITE Mage_Payment Helper
 *
 * @category   Ebizmarts
 * @package    Ebizmarts_SagePaySuite
 * @author     Ebizmarts <info@ebizmarts.com>
 */

class Ebizmarts_SagePaySuite_Helper_Payment_Data extends Mage_Payment_Helper_Data
{
    /**
     * Retrieve all payment methods
     *
     * @param mixed $store
     * @return array
     */
    public function getPaymentMethods($store = null)
    {
        $_methods = parent::getPaymentMethods($store);

        if (isset($_methods['sagepaysuite'])) {
            unset($_methods['sagepaysuite']);
        }
        return $_methods;
    }
}

I want to make sure I rewrite them properly and looking for some advice.

  • Which error you are facing after update? – Dhiren Vasoya Aug 29 '17 at 12:24
  • It's a conflict. Between Amasty and SagePay. They both are trying to rewrite same core block Mage_Payment_Helper_Data. I'm not sure in what order or how they should rewrite. – Greg Aug 29 '17 at 12:26
  • What happens if you change class Amasty_Methods_Helper_Payment_Data extends Mage_Payment_Helper_Data to class Amasty_Methods_Helper_Payment_Data extends Ebizmarts_SagePaySuite_Helper_Payment_Data ? – Ricky Odin Matthews Aug 29 '17 at 12:48
  • Still the conflict is present and module not working. – Greg Aug 29 '17 at 12:53
  • 1
    Boom, that worked and everything is running as it should. I knew there was a simple solution to a problem. Thank you. Do you want to add a answer so I can accept it or answer the question myself? – Greg Aug 29 '17 at 13:13
1

Please try extending your helper class in

app/code/local/Ebizmarts/SagePaySuite/Helper/Payment/Data.php

to

class Ebizmarts_SagePaySuite_Helper_Payment_Data extends Amasty_Methods_Helper_Payment_Data

Please note; if you disable the Amasty module, it will stop the Ebizmarts module from working also with this code. You can always add a <depends> to the module xml if you wish.

More info on ebizmarts docs; http://wiki.ebizmarts.com/sage-pay-common-problems/3rd-party-modules

  • Hymmm, can you tell me how to add the <depends> so they will both work? – Greg Aug 29 '17 at 13:31
  • Sure, more info can be found @ magento.stackexchange.com/questions/10143/… – Ricky Odin Matthews Aug 29 '17 at 13:34
  • 1
    Perfect, I really appreciate your help. I will use the above answer for now but will look deeper into adding the dependency to it later on. Once more thank you for your help. – Greg Aug 29 '17 at 13:36
1

I have checked that Ebizmarts_SagePaySuite_Helper_Payment_Data class is rewritten core class. So you need to follow below steps

  1. Please copy method of Amasty_Methods_Helper_Payment_Data and put it on Ebizmarts_SagePaySuite_Helper_Payment_Data this class.
  2. Please keep override method Amasty_Methods_Helper_Payment_Data so whenever Ebizmates extension is disabled at a time your Amasty module will be working well.

Thank you.

  • Thank you for your response. The problem is now solved easier way by Ebizmarts extending Amasty class. Thank you for your interest and I'm sure merging the code method would work too. – Greg Aug 29 '17 at 13:14

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.