简体   繁体   English

Magento 1.9-Paypal Express Checkout的自定义无法正常工作

[英]Magento 1.9 - Customizations to Paypal Express Checkout not working

I am trying to customize the Magento Paypal Express Checkout functionality to pass the order total amount using current store's currency and rather than the base currency to Paypal. 我正在尝试自定义Magento Paypal Express Checkout功能,以使用当前商店的货币而不是基础货币将订单总金额传递给Paypal。 However, my customizations aren't appearing on the site. 但是,我的自定义内容未显示在网站上。

Here is what I have created: 这是我创建的:

app/code/local/My/Paypal/Model/Express/Checkout.php

<?php

class My_Paypal_Model_Express_Checkout extends Mage_Paypal_Model_Express_Checkout {

    public function getCheckoutShortcutImageUrl() {
        //Copy pasted the original code with some modifications to use
        // _quote->getGrandTotal()
    }

    public function start($returnUrl, $cancelUrl, $button = null) {
        //Copy pasted original code with modifications to use
        //_quote->getGrandTotal() and _quote->getStoreCurrencyCode()
    }

}

?>

app/code/local/My/Paypal/etc/config.xml

<?xml version="1.0"?>
<config>
  <modules>
    <My_Paypal>
      <version>0.1.0</version>
    </My_Paypal>
  </modules>
  <global>
    <models>
      <paypal>
        <rewrite>
          <express_checkout>My_Paypal_Model_Express_Checkout</express_checkout>
        </rewrite>
      </paypal>
    </models>
  <global>
</config>

app/etc/modules/My_Paypal.xml

<?xml version="1.0"?>
<config>
  <modules>
    <My_Paypal>
      <active>true</active>
      <codePool>local</codePool>
      <version>0.1.0</version>
    </My_Paypal>
  </modules>
</config>

I see my module showing up correctly under System -> Configuration -> Advanced -> Advanced -> Disable Modules Output as Enable , while Mage_Poll and Mage_Tag are showing up as Disable . 我看到我的模块在Mage_Poll System -> Configuration -> Advanced -> Advanced -> Disable Modules OutputEnable ,而Mage_PollMage_Tag显示为Disable

Directly changing Mage_Paypal_Model_Express_Checkout works, so I know my code changes work, but the correct way of customizing a model doesn't seem to work. 直接更改Mage_Paypal_Model_Express_Checkout有效的,所以我知道我的代码更改有效,但是自定义模型的正确方法似乎无效。

I refresh and flush the Magento cache with each change, so it's not just a caching issue. 我会随着每次更改刷新并刷新Magento缓存,因此这不仅是缓存问题。

My guess is that there is something wrong with my config.xml , but at this point I can't seem to figure out what. 我的猜测是config.xml出了点问题,但是目前我似乎还没弄清楚是什么。

Any ideas? 有任何想法吗? Alternatively, a better way of achieving what I want to do would also work. 另外,实现我想要做的更好的方法也可以。

Also, how do I debug Magento to understand what may be erroring out in my customization? 另外,如何调试Magento以了解自定义中可能出现的错误? Are there logs I can turn on or look at? 是否有我可以打开或查看的日志?

your way of implementing it is well enough. 您实施它的方式就足够了。 the only better way would be using events, but that is not always possible. 唯一更好的方法是使用事件,但这并不总是可能的。

try to add dependency to paypal module and check if this model already has been rewritten elsewhere. 尝试将依赖项添加到paypal模块,并检查该模型是否已经在其他地方重写。

<config>
  <modules>
    <My_Paypal>
      <active>true</active>
      <codePool>local</codePool>
      <depends>
          <Mage_Paypal />
      </depends>
    </My_Paypal>
  </modules>
</config>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM