Jump to content

Invalid $number parameter: "" cannot be interpreted as a number


Hal_9000

Recommended Posts

Good morning,
after the migration of the e-commerce site in prestashop from olddomain.it to newdomain/folder/ back-office side on Catalog -> Products I see the following error
PrestaShop \ PrestaShop \ Core \ Localization \ Exception \ LocalizationException:
Invalid $ number parameter: "" cannot be interpreted as a number


the configuration of the new domain is the same as the previous one, can you help me understand the problem?
Thank you

PrestaShop\PrestaShop\Core\Localization\Exception\LocalizationException:
Invalid $number parameter: "" cannot be interpreted as a number

  at src/Core/Localization/Number/Formatter.php:108
  at PrestaShop\PrestaShop\Core\Localization\Number\Formatter->format(null, object(Price))
     (src/Core/Localization/Locale.php:154)
  at PrestaShop\PrestaShop\Core\Localization\Locale->formatPrice(null, 'EUR')
     (src/Adapter/Product/AdminProductDataProvider.php:392)
  at PrestaShop\PrestaShop\Adapter\Product\AdminProductDataProvider->getCatalogProductList(0, 300, 'id_product', 'desc', array())
     (src/PrestaShopBundle/Controller/Admin/ProductController.php:160)
  at PrestaShopBundle\Controller\Admin\ProductController->catalogAction(object(Request), 300, 0, 'id_product', 'desc')
     (vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:151)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
     (vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:68)
  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, false)
     (vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:200)
  at Symfony\Component\HttpKernel\Kernel->handle(object(Request), 1, false)
     (adminadst8951/index.php:82)

Schermata 2021-07-12 alle 09.27.12.png

Schermata 2021-07-12 alle 09.27.18.png

Link to comment
Share on other sites

It is a know bug (https://github.com/PrestaShop/PrestaShop/issues/23376)

Change following line which can be found around line 387 - 390 in the file: YOURSHOP/src/Adapter/Product/AdminProductDataProvider.php

Original

    if ($formatCldr) {
        $product['price'] = Tools::displayPrice($product['price'], $currency);
        $product['price_final'] = Tools::displayPrice($product['price_final'], $currency);
    }

Replace with:

if ($formatCldr && $product['price'] != null && $product['price_final'] != null) {
    $product['price'] = $localeCldr->formatPrice($product['price'], $currency->iso_code);
    $product['price_final'] = $localeCldr->formatPrice($product['price_final'], $currency->iso_code);
}

 

Edited by Crezzur (see edit history)
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

  • 5 months later...

Hi Hal_9000 !

Thank you so much you saver me many time your patch work 100 %

 

I've update prestashop before from 1.7.6.9 to 1.7.8.1 & and also to 1.7.8.2 for another customer its working perfectly

 

AdminProductDataProvider.php

AdminProductDataProvider.php_ko-old.php  old file from 1.7.6.9 to 1.7.8.1 & and also to 1.7.8.2

AdminProductDataProvider.php-patch.zip

 

I hope that every one can use this usefull file

Thank you very much Hal_9000 ! yiu are super hero

Bye Paolo from Swiss ;)

 

 

AdminProductDataProvider.php-patch.zip

Link to comment
Share on other sites

  • 5 months later...

I have upgraded from 1.7.6.5 to 1.7.8.5 

when click on Stats in BO - getting this error: see attached screenshot

Invalid $number parameter: "" cannot be interpreted as a number

[PrestaShop\PrestaShop\Core\Localization\Exception\LocalizationException 0]

 

Updating lines  YOURSHOP/src/Adapter/Product/AdminProductDataProvider.php as described above by the #Hal_9000 did not help.

Any further advices would be appreciated.

 

Screenshot 2022-05-21 at 10.09.13.png

Link to comment
Share on other sites

  • 1 month later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...