0

I would overwrite app/code/core/Mage/Shipping/Model/Carrier/Tablerate.php with my custom component. My code:

app/etc/modules/Infocurci_Shipping.xml

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

app/code/local/Infocurci/Shipping/etc/config.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Infocurci_Shipping>
            <version>0.1.0</version>
        </Infocurci_Shipping>
    </modules>
    <global>
        <models>
            <shipping>
                <rewrite>
                    <carrier_tablerate>Infocurci_Shipping_Model_Carrier_Tablerate</carrier_tablerate>
                </rewrite>
            <shipping>
        </models>
    </global>
</config>

app/code/local/Infocurci/Shipping/Model/Carrier/Tablerate.php

<?php
class Infocurci_Shipping_Model_Carrier_Tablerate extends Mage_Shipping_Model_Carrier_Tablerate
{

    public function collectRates(Mage_Shipping_Model_Rate_Request $request)
    {
       die('this is only a test');
    }

}

What's wrong? I do not see my code in action.

2 Answers 2

0

Correct me if i'm wrong. The function collectRates() allready exists in app/code/core/Mage/Shipping/Model/Carrier/Tablerate.php. Your custom Template.php file only extends it, not overriding it.

You can try to copy app/code/core/Mage/Shipping/Model/Carrier/Tablerate.php to app/code/local/Mage/Shipping/Model/Carrier/Tablerate.php and change the collectionRates() function in there.

1
  • I know its a year later, but I've tried your suggestion, and even tried copying the entire shipping folder to local/mage, but its refusing to overwrite the system.xml. Cache is turned off. Any thoughts?
    – Chris
    May 31, 2019 at 16:31
0

Can you try to add the declaration of your own model (?):

<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
    <Infocurci_Shipping>
        <version>0.1.0</version>
    </Infocurci_Shipping>
</modules>
<global>
    <models>
        <shipping>
            <rewrite>
                <carrier_tablerate>Infocurci_Shipping_Model_Carrier_Tablerate</carrier_tablerate>
            </rewrite>
        <shipping>
        <infocurci_shipping>
            <class>Infocurci_Shipping_Model</class>
        </infocurci_shipping>
    </models>
</global>
</config>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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