Jump to content

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


alj

Recommended Posts

Hi

On a Prestashop 1.7.7.1 i'm getting this error when going to the product overview in back office.

it is a new fresh install, and before I imported products I could fine access the product overview , but now after importing products, i get this error.
Have tried changing decimals under currencies, deleting cache and changing currency, nothing helped.

Has anyone experienced this error and may have a solution.

Thanks!

screenshot-vildtshop.graffic.mitspace.dk-2021.01.16-11_19_43.png

Edited by alj (see edit history)
Link to comment
Share on other sites

  • 5 weeks later...

I had what appears to be the same problem. This solved it.
Add this logic to the if on line 390 in src/Adapter/Product/AdminProductDataProvider.php

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);
}

 

  • Like 8
  • Thanks 3
Link to comment
Share on other sites

  • 3 months later...
On 2/26/2021 at 4:29 PM, Asger22 said:

I had what appears to be the same problem. This solved it.
Add this logic to the if on line 390 in src/Adapter/Product/AdminProductDataProvider.php


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);
}

 

Thank you, works properly on PS 1.7.7.1

  • Like 1
Link to comment
Share on other sites

On 2/26/2021 at 4:29 PM, Asger22 said:

I had what appears to be the same problem. This solved it.
Add this logic to the if on line 390 in src/Adapter/Product/AdminProductDataProvider.php


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);
}

 

The above worked for me. However, this bug still exists in P.S. 1.7.7.4 has it been reported to PrestaShop?

Link to comment
Share on other sites

On 6/10/2021 at 11:34 PM, Prestafan1234 said:

Who are you replying to? It makes no sense to change to an older version of PHP when PrestaShop 1.7.7.x supports 7.3

I got similar problem with the module and was resolved when I switch to older PHP

Link to comment
Share on other sites

17 hours ago, lototo said:

I got similar problem with the module and was resolved when I switch to older PHP

This is not a module. It is core PrestaShop.

The shop I work on already uses PHP 7.2 so it did not work for me before changes were made (upgraded shop from 1.6 to 1.7)

Link to comment
Share on other sites

  • 1 month later...
On 2/26/2021 at 6:59 PM, Asger22 said:

I had what appears to be the same problem. This solved it.
Add this logic to the if on line 390 in src/Adapter/Product/AdminProductDataProvider.php

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);
}

I copy this code exactly and it works on Prestashop 1.7.7.5.

IF add to this line in this version but this part has changed

product['price'] != null && $product['price_final'] != null) {

 

  • Thanks 1
Link to comment
Share on other sites

  • 2 months later...

Not work for me! =l 

 

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); }

Link to comment
Share on other sites

hace 12 horas, bcpivetta dijo:

Not work for me! =l 

 

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); }

Because your problem is in another function.

First of all, which PHP version are you using?

Link to comment
Share on other sites

On 2/26/2021 at 4:29 PM, Asger22 said:

I had what appears to be the same problem. This solved it.
Add this logic to the if on line 390 in src/Adapter/Product/AdminProductDataProvider.php

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);
}

 

Works... thank you so much

Link to comment
Share on other sites

  • 4 weeks later...
On 2/26/2021 at 5:29 PM, Asger22 said:

I had what appears to be the same problem. This solved it.
Add this logic to the if on line 390 in src/Adapter/Product/AdminProductDataProvider.php

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);
}

 

Worked for me too on upgraded prestashop 1.7.7.5. Thank you!

Link to comment
Share on other sites

Dnia 26.02.2021 o 4:29 PM, Asger22 napisał:

I had what appears to be the same problem. This solved it.
Add this logic to the if on line 390 in src/Adapter/Product/AdminProductDataProvider.php

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);
}

 

It helped me in version 1.7.8.1 with PHP 7.4
===============================
@Asger22

15-02-2022 
Unfortunately, the problem reappears in version 1.7.8.3 - after updating the above code in the AdminProductDataProvider.php file, I can now access the product catalog.
I must point out that for the last 15 days after updating the store from version 1.7.8.2 it worked without corrections, but today something crashed and I had to go back to modifying the file.
Fortunately, the patch works. 🙂

Edited by WartoWiedziec
Updated (see edit history)
Link to comment
Share on other sites

  • 2 months later...
On 2/26/2021 at 4:29 PM, Asger22 said:

I had what appears to be the same problem. This solved it.
Add this logic to the if on line 390 in src/Adapter/Product/AdminProductDataProvider.php

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);
}

 

I have exactly the same problem  in version 1.7.8.2 multistore with PHP 7.4.

Change of code not solved error. Can someone help me to solve the problem ?

Link to comment
Share on other sites

  • 4 weeks later...

EDIT SOLVED!!

Well then the problem is super simple in the end but however you need to put the code as given above see below:

Add this logic to the if on line 390 in src/Adapter/Product/AdminProductDataProvider.php

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

PAR

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);
}

Then when you have all the products displayed, search in the page or pages for the mention N/D of the column Amount including tax

Edit the product and delete all the combinations (shops only) Then save then put all the shops and recreate the combinations! Then modify the variations for each shop and save for each of the shops then go back to all the shops then save until you have the updated product message!!

Do this for all products with N/D then once finished you can remove the piece of code :).

Problem solved !!

In the future create your variations before on all the shops then configure each shop their price etc ..

Edited by Esh-Network (see edit history)
Link to comment
Share on other sites

  • 2 weeks later...
En 24/2/2022 a las 8:45 PM, Esh-Network dijo:

EDIT SOLVED!!

Well then the problem is super simple in the end but however you need to put the code as given above see below:

Add this logic to the if on line 390 in src/Adapter/Product/AdminProductDataProvider.php

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

PAR

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);
}

Then when you have all the products displayed, search in the page or pages for the mention N/D of the column Amount including tax

Edit the product and delete all the combinations (shops only) Then save then put all the shops and recreate the combinations! Then modify the variations for each shop and save for each of the shops then go back to all the shops then save until you have the updated product message!!

Do this for all products with N/D then once finished you can remove the piece of code :).

Problem solved !!

In the future create your variations before on all the shops then configure each shop their price etc ..

Yes, this is the solution given in a previous answer

 

 

Link to comment
Share on other sites

  • 3 months later...

In my case this error appears after upgrade from PS 1.7.6.5 to PS 1.7.8.6,  and only when I click on Stats Dashboard link in back office.

Solution: as per this fix in src/Core/Localization/Locale.php, to add just one line 152:

if ( $number === null ) return null;

The final view:

    public function formatPrice($number, $currencyCode)
    {
      if ( $number === null ) return null;
        return $this->numberFormatter->format(
            $number,
            $this->getPriceSpecification($currencyCode)
        );
    }

 

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...
On 6/29/2022 at 2:06 PM, Yulia Vitun said:

In my case this error appears after upgrade from PS 1.7.6.5 to PS 1.7.8.6,  and only when I click on Stats Dashboard link in back office.

Solution: as per this fix in src/Core/Localization/Locale.php, to add just one line 152:

if ( $number === null ) return null;

The final view:

    public function formatPrice($number, $currencyCode)
    {
      if ( $number === null ) return null;
        return $this->numberFormatter->format(
            $number,
            $this->getPriceSpecification($currencyCode)
        );
    }

 

This work for me. In my case, I cant enter to backoffice cart list.

  • Thanks 1
Link to comment
Share on other sites

  • 1 month later...

....also I found this solution: 


to add this if logic to the line 390 in src/Adapter/Product/AdminProductDataProvider.php

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);
}

I add two solutions mentioned, lets see ))

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

  • 1 month later...
  • 3 months later...
On 2/26/2021 at 4:29 PM, Asger22 said:

I had what appears to be the same problem. This solved it.
Add this logic to the if on line 390 in src/Adapter/Product/AdminProductDataProvider.php

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);
}

 

Thanks so much for your solution. It works to me :)

Prestashop version 1.7.8.8

Link to comment
Share on other sites

  • 1 month later...

I am having similar error, non of the fixes mentioned did the trick..

 

Invalid $number parameter: "3,89 €" cannot be interpreted as a number

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

Link to comment
Share on other sites

  • 2 weeks later...
On 2/26/2021 at 5:29 PM, Asger22 said:

I had what appears to be the same problem. This solved it.
Add this logic to the if on line 390 in src/Adapter/Product/AdminProductDataProvider.php

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);
}

 

thanks, same problem multistore 1.7.7.7

Link to comment
Share on other sites

  • 1 month later...

Hello,

I have this issue too and I don't found a good solution. Your solution can maybe work but it is not recommended to override the src folder. So I don't really understand how I can solve the problem.

Link to comment
Share on other sites

2 hours ago, Yohannn said:

Hello,

I have this issue too and I don't found a good solution. Your solution can maybe work but it is not recommended to override the src folder. So I don't really understand how I can solve the problem.

there is not other solution in this topic except this one:

Add this logic to the if on line 390 in src/Adapter/Product/AdminProductDataProvider.php

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);
}

It's safe to change this line.

Link to comment
Share on other sites

14 hours ago, Prestan0ob said:

there is not other solution in this topic except this one:

Add this logic to the if on line 390 in src/Adapter/Product/AdminProductDataProvider.php

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);
}

It's safe to change this line.

Yes I understand this but if in the next time I want to upgrade my prestashop version, the line added will be disappear

 

Edited by Yohannn (see edit history)
Link to comment
Share on other sites

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...