1

My System.log if full of Notices..

2016-03-11T08:23:39+00:00 ERR (3): Notice: Undefined offset: 0  in /var/../app/code/local/Magerevol/Brands/Block/Prodpage.php on line 29

I know what cause this notice, I know how to fix it and it's good that those notices are written in System.log.

The cause that this notice appear is that I forgot to add an image in some places on product pages...

lirics... The question is: How can I find the exact frontpage product url which caused this notice?

2 Answers 2

2

In your app/code/local/Magerevol/Brands/Prodpage.php before line 29 you can do the following, I assume it's an array problem and line 29 contains some code like this:

$array[0]

To find out the product that's causing problem you can do:

if (array_key_exists(0,$array))
{
    // Do what's your code is supposed to do
}
else
{
    Mage::log("This product is missing something:".Mage::helper('core/url')->getCurrentUrl());
}
1
  • 1
    Thanks for the help. For some reason your solution did not bring up the Product ID so I changed the Mage::registry('current_product')->getProductId()) with Mage::helper('core/url')->getCurrentUrl() and that did the trick! Thanks!
    – Alex Pasa
    Commented Mar 11, 2016 at 9:38
2

If you go to the file mentioned in the log - /app/code/local/Magerevol/Brands/Block/Prodpage.php on line 29

Here you can add your own logging, the line should be throwing some sort of exception, wherever it fails, add the following:

$logger = Mage::getModel('core/log_adapter', 'my.log'); $logger->log(Mage::helper('core/url')->getCurrentUrl());

Now, next time the error occurs you will get the current URL logged in your new log file (var/log/my.log)

2
  • Your code helped me to get the url but the accual soltion was provided by @digital-pianism - Your code logs every url that was visited no matter if it trigger a notice or not.
    – Alex Pasa
    Commented Mar 11, 2016 at 9:36
  • Glad i could be of some sort of help, i was hoping the code was catching an exception, which you could then insert my code into, in this case, it would only log the url when the exception was caught. I have up-voted @digital-painism's answer.
    – JoshCarter
    Commented Mar 11, 2016 at 9:44

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.