Jump to content

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


alj
 Share

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)

Share this post


Link to post
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 6
  • Thanks 2

Share this post


Link to post
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

Share this post


Link to post
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?

Share this post


Link to post
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

Share this post


Link to post
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)

Share this post


Link to post
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

Share this post


Link to post
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); }

Share this post


Link to post
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?

Share this post


Link to post
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

Share this post


Link to post
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!

Share this post


Link to post
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)

Share this post


Link to post
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 ?

Share this post


Link to post
Share on other sites

3 hours ago, anitanails said:

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 ?

Probably you have the same error but in another part of code. Please upload a screenshot.

Share this post


Link to post
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)

Share this post


Link to post
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

 

 

Share this post


Link to post
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)
        );
    }

 

Share this post


Link to post
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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More