Recent Posts


Failed to Save the Package


Frustrated by Magento? Then you’ll love Commerce Bug, the must have debugging extension for anyone using Magento. Whether you’re just starting out or you’re a seasoned pro, Commerce Bug will save you and your team hours everyday. Grab a copy and start working with Magento instead of against it.

Updated for Magento 2! No Frills Magento Layout is the only Magento front end book you'll ever need. Get your copy today!

You’re cruising along, your module has come together. The last step between you and total Magento Connect domination is packaging your extension. You bravely enter System -> Magento Connect -> Package Extension, and with victory in your grasp …

FAILURE! With no clear path forward, you commit seppuku rather than face continued shame.

There’s a common pattern in older parts of the Magento system where a controller will wrap its business logic calls in a try block, with two catches. The first

} catch (Mage_Core_Exception $e){

looks for a Magento exception. If a Magento exception is thrown, then it’s “safe” to show the user that error message. The second catch

    } catch (Exception $e){
        $session->addException($e, Mage::helper('connect')->__('Failed to save the package.'));

is for standard PHP exceptions (or Notices, Warnings, etc. if you’re running in developer mode). Here a hard coded string literal is used because it would be best not to show an end user a raw PHP error message.

Of course, we’ve left wondering why our save failed, so this attempt at security and usability ends up being a cruel failure. There’s no elegant way to fix this either. Whenever I run into it when packaging an extension (which is every time I package an extension), I end up temporarily hacking the core with something like this

    } catch (Exception $e){
        $session->addException($e, Mage::helper('connect')->__('Failed to save the package. '.$e->getMessage()));

This will print out the actual exception message

which is usually enough to track down the problem (in this case I had the wrong target type in the content tab).

Copyright © Alana Storm 1975 – 2023 All Rights Reserved

Originally Posted: 21st October 2011

email hidden; JavaScript is required