System.log and exact URL of page caused that record
-
29-09-2020 - |
Question
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?
La solution
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());
}
Autres conseils
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)