Bojanstven Posted May 16, 2017 Share Posted May 16, 2017 (edited) Kinda disappointed by PrestaShop 1.7, must say.... The official Google Analytics modules, latest version, officially developed by PrestaShop crashes on all product pages... Google Analytics v2.3.4 - by PrestaShop ContextErrorException in ganalytics.php line 539:Notice: A non well formed numeric value encountered in ganalytics.php line 539 at ErrorHandler->handleError('8', 'A non well formed numeric value encountered', '/home/bbooks/public_html/modules/ganalytics/ganalytics.php', '539', array('product' => array('id_shop_default' => '1', 'id_manufacturer' => '1', 'id_supplier' => '1', 'reference' => 'demo_3', ....etc... This errors only happens on PRODUCT PAGES, other pages seem to be fine... Line 539 in PrestaShop 1.7.1.1, official Google Analytics Module v2.3.4, line 539 'price' => number_format($product['price'], '2') Here is the whole code block: if ($full) { $ga_product = array( 'id' => $product_id, 'name' => Tools::jsonEncode($product['name']), 'category' => Tools::jsonEncode($product['category']), 'brand' => isset($product['manufacturer_name']) ? Tools::jsonEncode($product['manufacturer_name']) : '', 'variant' => Tools::jsonEncode($variant), 'type' => $product_type, 'position' => $index ? $index : '0', 'quantity' => $product_qty, 'list' => Tools::getValue('controller'), 'url' => isset($product['link']) ? urlencode($product['link']) : '', 'price' => number_format($product['price'], '2') ); Any ideas guys? Edited May 16, 2017 by Bojanstven (see edit history) 1 Link to comment Share on other sites More sharing options...
wjq588jk Posted May 21, 2017 Share Posted May 21, 2017 up! thanks a lot for advance Link to comment Share on other sites More sharing options...
Bojanstven Posted May 24, 2017 Author Share Posted May 24, 2017 I figured out what this was all about. If you use a different currency that does NOT match to standard English decimal mark it is going to crash. In my case currency was RSD and it uses decimal point, like 199,99 RSD instead of usual 199.99 EUR/USD. Or in case of larger numbers, 2.199,99 RSD as opposed to 2,199.99 EUR/USD Product Price in Presta 1.7 is defined as a string if I'm not mistaking, so that produces an error, since Presta is expecting to find a different string type. Anyways, I temporarily solved it by just removing the last line of code and it works for me with different decimal marks: 'price' => number_format($product['price'], '2') Should anyone have the same problem, I think this should help. Or edit the string type for the price. Best, Bojan Link to comment Share on other sites More sharing options...
ssuchanowski Posted July 23, 2017 Share Posted July 23, 2017 +1 Really no one fixed this so far? It's has been months.. Link to comment Share on other sites More sharing options...
Matthieu_ Posted August 2, 2017 Share Posted August 2, 2017 I had the same problem, number_format take a float as first parameter, and for me, $product['price'] return a string like "22,40 €" ! So i solved it by changing the line 589 by 'price' => number_format(floatval(str_replace(',', '.', $product['price'])), '2') Hope this helps Link to comment Share on other sites More sharing options...
mourad1081 Posted January 7, 2019 Share Posted January 7, 2019 On 7/23/2017 at 11:50 PM, ssuchanowski said: +1 Really no one fixed this so far? It's has been months.. Now it has been years... Link to comment Share on other sites More sharing options...
hortiz Posted October 2, 2019 Share Posted October 2, 2019 On 1/7/2019 at 10:27 AM, mourad1081 said: Now it has been years... Yeap.. Prestashop 1.7, recently installed and still same issue.. in different line for me, apparently not related to currency 1/1) ContextErrorException Notice: Undefined index: name in ganalytics.php line 530 --> 'name' => Tools::jsonEncode($product['name']), Link to comment Share on other sites More sharing options...
Oznerologos Posted November 6, 2019 Share Posted November 6, 2019 Hi everyone ! I'm currently experiencing the same issue as Hortiz : when i click on one of my products, i get a PHP error (I enabled the debug mode as it is my "test" website) : Notice: Undefined index: name in ganalytics.php line 530 if ($full) { $ga_product = array( 'id' => $product_id, 'name' => Tools::jsonEncode($product['name']), // This is line 530 /////////////////////////////////////////////////// 'category' => Tools::jsonEncode($product['category']), 'brand' => isset($product['manufacturer_name']) ? Tools::jsonEncode($product['manufacturer_name']) : '', 'variant' => Tools::jsonEncode($variant), 'type' => $product_type, 'position' => $index ? $index : '0', 'quantity' => $product_qty, 'list' => Tools::getValue('controller'), 'url' => isset($product['link']) ? urlencode($product['link']) : '', 'price' => number_format($product['price'], '2') ); } Any idea where does this error come from ? Thanks for your help ! Link to comment Share on other sites More sharing options...
Fred Peng Posted April 19, 2020 Share Posted April 19, 2020 On 8/2/2017 at 4:12 PM, Matthieu_ said: 'price' => number_format(floatval(str_replace(',', '.', $product['price'])), '2') This works for me. Thanks a lot. Link to comment Share on other sites More sharing options...
m2ma Posted December 3, 2020 Share Posted December 3, 2020 (edited) Hey, i have a similar problem here with presta 1.6.1.27 and Google Analytics v2.3.4 Notice: Undefined index: name in /home/site/domains/site.com/public_html/modules/ganalytics/ganalytics.php on line 530 Notice: Undefined index: category in /home/site/domains/site.com/public_html/modules/ganalytics/ganalytics.php on line 531 Edited December 10, 2020 by m2ma (see edit history) Link to comment Share on other sites More sharing options...
lozaria Posted July 6, 2021 Share Posted July 6, 2021 And still this is not fixed??? WTF? 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