I am importing some products. Generally this works fine and when it does raise an error, I skip that item because I handle it using try / catch. I have an issue sometimes though where the catch isn't triggered despite an error being raised.

For instance, one product threw an error here in Catalog\Product\Type\Configurable.php with this line:

foreach ($this->getConfigurableAttributes($product) as $attribute) {
            $this->getProduct($product)->setData($attribute->getProductAttribute()->getAttributeCode(), null);

basically it was reporting that $attribute was null (and it threw the error when debugging using xdebug) however, instead of then going into my catch code, it just stopped the script. I have already fixed the issue that caused this BUT I need to know how to catch things like this and skip / log the item, not just stop the script.

Can anyone lend some advice please?

  • Hmm, turns out it's raising a PHP Fatal error which is the actual issue.
    – webnoob
    Oct 2, 2013 at 9:32

1 Answer 1


Fatal Error's will cause the Magento error handling and any other Error handling to fail. This is by design in PHP. With that in mind, I am now logging the errors using a shutdown event.

register_shutdown_function(array($this, "fatalErrorHandler"));
function fatalErrorHandler() {
    $error = error_get_last();

    if($error !== null) {
        //Do some primitive logging

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.