pel024 Posted August 28, 2012 Share Posted August 28, 2012 (edited) Hi all, I'm getting millions of the following PHP warnings in the error log: [28-Aug-2012 15:34:40] PHP Warning: array_key_exists() expects parameter 2 to be array, boolean given in /home/dermalse/public_html/dermalsense.com/classes/Product.php on line 1860 Line 1860 of Product.php: $attribute_price = Tools::convertPrice(array_key_exists('attribute_price', $result) ? (float)($result['attribute_price']) : 0, $id_currency); Any ideas? All seems Ok in the FO. Cheers Product.php Edited September 14, 2012 by pel024 (see edit history) Link to comment Share on other sites More sharing options...
bellini13 Posted August 29, 2012 Share Posted August 29, 2012 it is complaining about the variable $result. It needs to be an array or boolean. $result is typically the result of a query against the database. you will need to review the code above that line to determine what $result is, and why it is neither an array or boolean. perhaps the query to the database failed, or no records were returned. 1 Link to comment Share on other sites More sharing options...
pel024 Posted September 5, 2012 Author Share Posted September 5, 2012 Thanks for the reply The code directly above this line is $price = (float)(!$specific_price OR $specific_price['price'] == 0) ? $result['price'] : $specific_price['price']; // convert only if the specific price is in the default currency (id_currency = 0) if (!$specific_price OR !($specific_price['price'] > 0 AND $specific_price['id_currency'])) $price = Tools::convertPrice($price, $id_currency); Does this shed any more light on why this error would suddenly start to occur? I've no clue!! As I said earlier, I can't see any problems in the FO, can I just ignore it? Cheers Link to comment Share on other sites More sharing options...
bellini13 Posted September 5, 2012 Share Posted September 5, 2012 nope, you would have to keep going up the lines of code until you see where $result is defined. It may be passed to the function as a parameter, or defined within the function. Link to comment Share on other sites More sharing options...
pel024 Posted September 13, 2012 Author Share Posted September 13, 2012 Sorry for the delayed response - I've been away. I've been through the whole Product.php and $result appears many times! I'm not a coder, just a humble shop owner so I've no idea where it is actually defined. I've attached it to my original post and wondered if you could take a look. The weird thing is I don't recall ever editing this file, but I could be wrong. Cheers Paul Link to comment Share on other sites More sharing options...
bellini13 Posted September 14, 2012 Share Posted September 14, 2012 line 1852 is where $result is set $result = self::$_pricesLevel2[$cacheId2]; appears to be locating the product and attribute prices. Do you products have attributes? If not, then you likely would not see an issue in the UI. I'm not sure which version of prestashop you are using, but you could download v1.4.9 and see if the Product.php class has changed at all in this function. Perhaps it was a known issue and resolved. Otherwise I would open a bug report for the issue. Link to comment Share on other sites More sharing options...
pel024 Posted September 14, 2012 Author Share Posted September 14, 2012 Found this So I replaced $attribute_price = Tools::convertPrice(array_key_exists('attribute_price', $result) ? (float)($result['attribute_price']) : 0, $id_currency); with this $attribute_price = Tools::convertPrice((is_array($result) && array_key_exists('attribute_price', $result)) ? (float)($result['attribute_price']) : 0, $id_currency); and so far no error messages and everything seems to be working. I did find a bug report made by phrasespot about this but apparently it couldn't be reproduced! Thanks for taking the time to help. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now