覆盖运输方式-我缺少什么 [英] Overridding a Shipping Method - What am I missing

查看:41
本文介绍了覆盖运输方式-我缺少什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我之前写了很多模块,但是由于某种原因,我的运输模块不会覆盖现有的Magneto运输方法.可以吗?我在这里想念什么?模块名称显示在配置区域的高级"选项卡中,因此正在加载该模块,但没有任何反应.有什么提示吗?

I've written many many modules before but for some reason my shipping module won't override an exsiting Magneto shipping method. Is that allowed? What am I missing here? The module name shows up in the advanced tab of the configuration area, so it's getting loaded, but nothing is happening. Any hints?

代码

etc/modules/Ssi_Shipping.xml

etc/modules/Ssi_Shipping.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Ssi_Shipping>
            <active>true</active>
            <codepool>local</codepool>
        </Ssi_Shipping>
    </modules>
</config>

local/Ssi/Shipping/etc.xml

local/Ssi/Shipping/etc.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Ssi_Shipping>
            <version>0.1.0</version>
        </Ssi_Shipping>
    </modules>
    <global>
        <models>
            <shipping>
                <rewrite>
                    <carrier_tablerate>Ssi_Shipping_Model_Carrier_Tablerate</carrier_tablerate>
                </rewrite>

            </shipping>
        </models>
    </global>
</config>

local/Ssi/Shipping/Model/Carrier/Tablerate.php

local/Ssi/Shipping/Model/Carrier/Tablerate.php

<?php
class Ssi_Shipping_Model_Carrier_Tablerate 
    extends Mage_Shipping_Model_Carrier_Tablerate {

        public function isActive()
        {
            Mage::log("here! Ssi_Shipping_Model_Carrier_Tablerate");

            // check to see if it's disabled
            if (parent::isActive() == false)
                return false;

            // check in the shopping cart
            foreach( Mage::getSingleton('checkout/session')->getQuote()->getItemsCollection() as $item ){
                if ($item->getDeliveryFlag() == "test")
                    return true;
            }

            // if nothing is found then disable this option.
            return false;

        }


    }

推荐答案

在仔细研究了这一点之后,我发现覆盖运送控制器的唯一方法是在以下位置复制文件(和目录结构)本地代码文件夹.然后,我基本上可以调整代码.

After working through this one a bit, I found that the only way to override the shipping controller was to make a duplicate of the file (and directory structure) in the local code folder. Then I could basically tweak the code.

不确定Magento为什么似乎不允许这些运输功能的标准替代,但是至少可以解决.

Not sure why Magento doesn't seem to allow the standard overriding of these shipping functions, but a least there is a work around.

这篇关于覆盖运输方式-我缺少什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆