Refine Post By:

I stumbled across another Magento v1.6 bug related to the isShippingLabelsAvailable() method within the Mage_Adminhtml_Block_Sales_Order_Shipment_Create_Items class. I’ve enhanced my extension from the previous post (Magento v1.6 getShippingMethod Core Fix) to fix this issue as well. You can download the extension by clicking this link. This extension fixes both the getShippingMethod() error in addition to the isShippingLabelAvailable() error.

Fatal error: Call to a member function isShippingLabelsAvailable() on a non-object in app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Create/Items.php on line 132

If you don’t want to download my extension and want to correct the issue yourself, below is the solution. If you don’t know how to correctly extend the core of Magento and override methods, I suggest you download my extension above to prevent hacking the core.

The poison lies within the Mage_Adminhtml_Block_Sales_Order_Shipment_Create_Items class on line 130 within the canCreateShippingLabel() method.

The poison (line 3)

1
2
3
4
  public function canCreateShippingLabel()
    {
      return $this->getOrder()->getShippingCarrier()->isShippingLabelsAvailable();
    }

The solution

1
2
3
4
5
6
7
8
9
  public function canCreateShippingLabel()
    {
      $carrier = $this->getOrder()->getShippingCarrier();
      if(method_exists($carrier, 'isShippingLabelsAvailable')) {
        return $carrier->isShippingLabelsAvailable();
      } else {
        return false;
      }
    }

30 Comments

  1. I’m using your extension and magento is not recognizing the override. Is there anything I can do to make it works?

    I had already logged out and in on the admin panel, but the error message is still the same: “Fatal error: Call to a member function isShippingLabelsAvailable() on a non-object in /sitename/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Create/Items.php on line 132″

  2. Dr. Ens -

    Did you install the extension correctly?
    Your folder structure should look this this:

    app/code/local/Wabism/CoreFix/*
    app/etc/modules/Wabism_CoreFix.xml

  3. Yes, it looks the same.

    It’s ignoring the Wabism extension. Even if I write some wrong code on the extension PHP file it doesn’t show anything wrong to me.

    Is I try to change the core file works fine, but I would like to have the extension working.

    I reindexed all the cache and indexes.

    Is there anything else I could do?

  4. Worked like a charm. Thanks for the fix! I would have been pulling my hair out otherwise.

  5. Josh — no problem at all, thanks for the positive feedback :) .

  6. Thank you for the solution a lot!
    I was able to make a shipment with your hint.
    But after that, I’m getting following message when I click on shipments to see the status..

    Fatal error: Call to a member function isShippingLabelsAvailable() on a non-object in /home/nxsbeaut/public_html/store/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/View/Form.php on line 125

    It is not critical issue since I’m able to process entire order process though..

    Thank you!

  7. FIVE STARS ***** Thanks for the fix! Great help

    Muito obrigado ! in portuguese :)

  8. Thanks again! I’ve used this one as well. Nice blog and tips. Keep up the good work.

  9. Billy,
    Your solution fixed the error messages. Thanks! What I am pulling my hair out on now is that when you do click on SHIP when USPS is the chosen shipping method, you get a PDF with a sample-Do Not Mail label. I have followed all advice to properly activate USPS in the shipping configuration and have had a phone call with tech support at the USPS to verify that label printing is allowed. What am I missing? How do I get the labels to print with live information?
    Thanks!
    Brian

  10. I simply dont know but magento isnt overriding the canCreateShippingLabel() method in Mage_Adminhtml_Block_Sales_Order_Shipment_Create_Items.

    Your file appears to be good, but the error stills the same, point to the wrong place…
    Fatal error: Call to a member function isShippingLabelsAvailable() on a non-object in /home/martins/public_html/babycool/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Create/Items.php on line 132

    If I put your code directly, it works, but this is not good.

    I also gave 777 to your extension dir..
    The structure is fine too. I also tried to reindex and flush both caches.

    Anyway, nice job.

  11. I just updated your config block to:

    Wabism_Corefix_Adminhtml_Block_Sales_Order_Shipment_Create_Items
    Wabism_Corefix_Adminhtml_Block_Sales_Order_Shipment_View_Form

    And it works like a charm.

    Thanks (Obrigado from Brazil)!

    • I’m wondering why you needed to lowercase Corefix, when the module folder name is CoreFix?

      I’m glad it worked out for you i’m just uncertain why this would have been a problem.

  12. Oh, I just forgot to say, that I renamed without need your class and all reference to Wabism_Corefix (instead CoreFix).

  13. Works for me!! :) ))
    Thanks!

  14. [18-Jan-2012 22:49:27] PHP Fatal error: Class ‘Wabism_CoreFix_Sales_Model_Order’ not found in /home/lib/Varien/Data/Collection.php on line 550

    Please advise!

    • Hi,

      Did you install everything into the correct directories?

      Hi Mark –

      The module starts in the Magento root folder.

      [magento_root]/app/code/local/Wabism/*
      [magento_root]/app/etc/modules/*

  15. After you’ve uploaded the files to the correct directories you must clear the cache and log out of admin… log back in and it works a treat :)

  16. Works perfect!!!! THNX

  17. Great work!. Thanks

  18. I suspect the issue comes not from the lack of the method (it comes from the abstract class after all) but rather that the getShippingCarrier method is returning false rather than an object for this particular shipping method – which matches to the text of the error message.

    So I’d check $carrier first eg:
    if($carrier && method_exists($carrier, ‘isShippingLabelsAvailable’))

  19. I’m not that much of a internet reader to be honest but your sites really nice, keep it up!
    I’ll go ahead and bookmark your website to come back later on. Cheers

  20. This is my first visit on this site and i found it very informative as you have provided here in this post.
    I would like to be a part of this site for collecting some more info.
    Thanks for sharing.

  21. Excellent work you did I win my day today!
    thanks for the help!

Leave a comment