How to fix “PHP Notice” errors received on various PrestaShop requests?

How to fix “PHP Notice” errors received on various PrestaShop requests?

Sometimes, when sending requests to the PrestaShop Webservice API, you may encounter messages like:

[PHP Notice #8] Trying to access array offset on value of type bool (/var/www/html/classes/Product.php, line 7178)

These warnings or notices can block API communication, causing our PrestaShop connector to fail.
This usually happens when PHP is configured to display errors instead of logging them — meaning that even harmless notices are sent directly in the API response and break the XML or JSON output.

Common Causes

1. Third-party module issues

You may have an external plugin or module that is not fully compatible with the Webservice API.
The module name often appears in the error message.

Example:

prestapyt.prestapyt.PrestaShopWebServiceError:
'[PHP Warning #2] Creating default object from empty value
(/modules/bolcom/bolcom.php, line 565)'

In this case, contact the module developer to fix or update the module.

2. Incompatible PHP version

Each PrestaShop version supports specific PHP versions. Running an older PrestaShop (e.g., 1.7.x) on a newer PHP (like 8.1 or 8.2) can trigger such warnings.

✅ Always make sure your PHP version matches your PrestaShop version.
See the official PrestaShop system requirements.

3. PrestaShop or PHP emits warnings to output

Even without third-party code, some PrestaShop builds may generate minor warnings.
These should never appear in API responses — they must be logged, not displayed.

How to Fix It

To prevent notices and warnings from breaking API responses, configure your web server or PHP environment to hide such messages from output and log them instead.

These settings work on any environment — Apache, Nginx, cPanel, or shared hosting.

Option 1: Update PHP configuration (recommended)

Add or modify these settings in your php.ini or .user.ini:

; Disable showing errors in API responses
display_errors = Off
display_startup_errors = Off

; Log all errors instead
log_errors = On

; Report all errors except notices and warnings
error_reporting = E_ALL & ~E_NOTICE & ~E_WARNING & ~E_DEPRECATED & ~E_STRICT

Then restart your web server or PHP service.

Option 2: Apache .htaccess configuration

If you can’t edit php.ini, add these lines to your .htaccess file in the PrestaShop root directory:

php_flag display_errors Off
php_flag display_startup_errors Off
php_value error_reporting 22519
php_flag log_errors On

Option 3: Nginx with PHP-FPM

If your site runs behind Nginx and PHP-FPM, edit your PHP pool configuration file
(e.g. /etc/php/8.1/fpm/pool.d/www.conf):

php_flag[display_errors] = off
php_flag[display_startup_errors] = off
php_flag[log_errors] = on
php_value[error_reporting] = E_ALL & ~E_NOTICE & ~E_WARNING & ~E_DEPRECATED & ~E_STRICT

Then reload PHP-FPM and Nginx:

sudo systemctl reload php8.1-fpm
sudo systemctl reload nginx

Test Your API

After updating configuration, test failed PrestaShop API endpoint using curl or your browser:

curl -i "https://yourstore.com/api/products/1?ws_key=XXXX"

If you still see [PHP Notice] or [PHP Warning] in the response, PHP output is still not fully suppressed.

Check your PHP version and server logs — warnings should now appear only in the logs, not in API output.

Summary

Problem

Cause

Fix

[PHP Notice] or [PHP Warning] in API output

PHP displays errors instead of logging

Disable display_errors, enable log_errors

3rd-party module error

Unstable or outdated module

Contact module developer

PrestaShop running on unsupported PHP

Version mismatch

Use supported PHP version

Once you disable error display and enable logging, PrestaShop’s API will return clean XML/JSON responses, and your connectors will function correctly.

Still Need Help?

Contact our support team: Support Portal

Related Posts