0
  1. When the module is enabled, refreshing the cart page will sometimes return Fatal error: Call to a member function setStore() on a non-object in /var/www/html/site-magento19/public_html/app/code/core/Mage/Shipping/Model/Shipping.php on line 424
  2. Though it seems to be trying to rewrite the class (guessing by the error above) I cannot get any results.

Most Recent: Module/Enhancedshipping/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Module_Enhancedshipping>
            <version>0.2.0</version>
        </Module_Enhancedshipping>
    </modules>
    <global>
         <models>
           <shipping>
             <rewrite>
                  <carrier_freeshipping>Module_Enhancedshipping_Model_Shipping_Carrier_Freeshipping</carrier_freeshipping>
             </rewrite>
           </shipping>
         </models>
    </global> 
</config>

Module/Enhancedshipping/Model/Shipping/Carrier/Freeshipping.php

<?php

class Module_Enhancedshipping_Model_Shipping_Carrier_Freeshipping extends Mage_Shipping_Model_Carrier_Freeshipping {
   public function collectRates(Mage_Shipping_Model_Rate_Request $request)
    {
        die('Because I want results'); 
    } 
}

2 Answers 2

2

<enhancedshipping> should be <shipping>. Try below config.xml code:

<?xml version="1.0"?>
<config>
    <modules>
        <Module_Enhancedshipping>
            <version>0.2.0</version>
        </Module_Enhancedshipping>
    </modules>
    <global>
         <models>
           <shipping>
             <rewrite>
                  <carrier_freeshipping>Module_Enhancedshipping_Model_Shipping_Carrier_Freeshipping</carrier_freeshipping>
             </rewrite>
           </shipping>
         </models>
    </global> 
</config>

Also it's good practice to use full php tag, <?php. short tags can lead to errors if it's not enabled in php.ini

5
  • I've implemented the changes that you recommended (updated in original post). However, my model is still not being called. Would observing the model instead help me in case another module rewrites the same class? That said this is a fresh install of magento with zero customizations other than the one I am attempting to implement. Jun 11, 2015 at 11:01
  • the fatal error you are getting is because magento is not able to find your new shipping carrier class. Please make sure full tags (<?php), file path and class name are correct.
    – MagExt
    Jun 11, 2015 at 16:26
  • Everything is exactly as it appears above. I've updated my PHP tags as well. Jun 11, 2015 at 17:08
  • looks perfectly fine to me.. I believe you cleared the cache to check it again right?
    – MagExt
    Jun 11, 2015 at 17:53
  • Have you changed <module> to <modules> tag in config.xml file? in the original question it isn't.
    – MagExt
    Jun 11, 2015 at 18:21
0

As you have want to rewrite the class Mage_Shipping_Model_Carrier_Freeshipping then should be change the <shipping>.

If we accumulate Mage_Shipping_Model_Carrier_Freeshipping class in factory pattern then it should be 'shipping/carrier_freeshipping'

shipping call as model prefix of Module Mage_Shipping which define at app/code/core/Mage/Shipping/etc/config.xml

<global>
....
<models>
<shipping> <!-- model prefix identifire --->
<class>Mage_Shipping_Model</class>
</shipping>
</models>
..

Your Answer

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

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