Prestashop: Uncaught Error: Call to a member function get() on null, WebService orders

Created on 22 Jul 2019  路  13Comments  路  Source: PrestaShop/PrestaShop

The bug
When using orders webservice to update currentState I get an error (see screenshoot)

To Reproduce
try to update an order current state with the webservice

Screenshots
The error :

Fatal error: Uncaught Error: Call to a member function get() on null in /var/www/<my_prestashop_folder>/classes/Tools.php:801
Stack trace:
#0 /var/www/<my_prestashop_folder>/classes/Tools.php(773): ToolsCore::getContextLocale(Object(Context))
#1 /var/www/<my_prestashop_folder>/classes/order/OrderHistory.php(513): ToolsCore::displayPrice(90000, Object(Currency), false)
#2 /var/www/<my_prestashop_folder>/classes/order/OrderHistory.php(468): OrderHistoryCore->sendEmail(Object(Order), false)
#3 /var/www/<my_prestashop_folder>/classes/order/Order.php(1681): OrderHistoryCore->addWithemail()
#4 /var/www/<my_prestashop_folder>/classes/order/Order.php(2407): OrderCore->setCurrentState('9')
#5 /var/www/<my_prestashop_folder>/classes/webservice/WebserviceRequest.php(1574): OrderCore->setWsCurrentState('9')
#6 /var/www/<my_prestashop_folder>/classes/webservice/WebserviceRequest.php(1419): WebserviceRequestCore->saveEntityFromXml(200)
#7 /var/www/<my_prestashop_folder>/classes/webservice/WebserviceRequest.php(590): WebserviceRequestCore->executeEntityPut()
#8 /var/www/<my_prestashop_folder>/we in /var/www/<my_prestashop_folder>/classes/Tools.php on line 801

What I sent :

<?xml version="1.0" encoding="utf-8"?>
<prestashop>
<order>
  <id>7</id>
  <id_address_delivery>35</id_address_delivery>
  <id_address_invoice>35</id_address_invoice>
  <id_cart>7</id_cart>
  <id_currency>1</id_currency>
  <id_lang>1</id_lang>
  <id_customer>1</id_customer>
  <id_carrier>1</id_carrier>
  <current_state>9</current_state>
  <module>ps_checkpayment</module>
  <invoice_number>2</invoice_number>
  <invoice_date>2019-07-22 10:45:50</invoice_date>
  <delivery_number>0</delivery_number>
  <delivery_date>0000-00-00 00:00:00</delivery_date>
  <valid>0</valid>
  <date_add>2019-07-22 10:45:50</date_add>
  <date_upd>2019-07-22 13:37:43</date_upd>
  <id_shop_group>1</id_shop_group>
  <id_shop>1</id_shop>
  <secure_key>4423f0e75abf0e8cb769998d4ecbab23</secure_key>
  <payment>Ch猫que</payment>
  <recyclable>0</recyclable>
  <gift>0</gift>
  <gift_message />
  <mobile_theme>0</mobile_theme>
  <total_discounts>0.000000</total_discounts>
  <total_discounts_tax_incl>0.000000</total_discounts_tax_incl>
  <total_discounts_tax_excl>0.000000</total_discounts_tax_excl>
  <total_paid>90000.000000</total_paid>
  <total_paid_tax_incl>90000.000000</total_paid_tax_incl>
  <total_paid_tax_excl>75000.000000</total_paid_tax_excl>
  <total_paid_real>90000.000000</total_paid_real>
  <total_products>75000.000000</total_products>
  <total_products_wt>90000.000000</total_products_wt>
  <total_shipping>0.000000</total_shipping>
  <total_shipping_tax_incl>0.000000</total_shipping_tax_incl>
  <total_shipping_tax_excl>0.000000</total_shipping_tax_excl>
  <carrier_tax_rate>20.000</carrier_tax_rate>
  <total_wrapping>0.000000</total_wrapping>
  <total_wrapping_tax_incl>0.000000</total_wrapping_tax_incl>
  <total_wrapping_tax_excl>0.000000</total_wrapping_tax_excl>
  <shipping_number />
  <conversion_rate>1.000000</conversion_rate>
  <reference>ZZTKOZXMJ</reference>
  <associations>
    <order_rows>
      <order_row>
        <id>8</id>
        <product_id>9</product_id>
        <product_attribute_id>0</product_attribute_id>
        <product_quantity>3</product_quantity>
        <product_name>Voiture qui roule</product_name>
        <product_reference>VOITURE-ROSE</product_reference>
        <product_ean13 />
        <product_upc />
        <product_price>25000.000000</product_price>
        <unit_price_tax_incl>30000.000000</unit_price_tax_incl>
        <unit_price_tax_excl>25000.000000</unit_price_tax_excl>
      </order_row>
    </order_rows>
  </associations>
  <id_employee>1</id_employee>
</order>
</prestashop>

Additional information
In Tools.php at line 795 $context->controller is null , at line 797 SymfonyContainer::getInstance(); return null too

Overrides are disabled and non native modules too

1.7.6.0 Bug Duplicate Order WS

All 13 comments

on 1.7.6.0 (after upgrading from 1.7.5.1)

Hi @pkshetlie,

I did not manage to reproduce the issue with PS1.7.6.0. after upgrade from PS1.7.5.2 using the 1-click upgrade v4.9.0.
I used this script

<?php
/**
 * Created by PhpStorm.
 * User: khouloud.belguith
 * Date: 22/05/19
 * Time: 09:01
 */
define('DEBUG', true);
ini_set('display_errors','on');
define('PS_SHOP_PATH', 'http://shop.com');
define('PS_WS_AUTH_KEY', 'Key');
require_once('PSWebServiceLibrary.php');
$ws = new PrestaShopWebservice(
    'shop.com',
    'Key',
    false);
$id = 6; //ID order Here
$xml = $ws->get(array('resource' => 'orders', 'id' => $id));
echo "BEFORE\n";
echo $xml->asXML();
unset($xml->order->current_state);
$xml->order->shipping_number = 10;
$xml->order->current_state = 4;
$opt['putXml'] = $xml->asXML();
$opt['id'] = $id;
$opt['resource'] = 'orders';

$xml = $ws->edit($opt);


$xml = $ws->get(array('resource' => 'orders', 'id' => $id));
echo "AFTER\n";
echo $xml->asXML();

Thanks to check & feedback.

I disable my modules, delete overrided classes in folder, use your script and get the same error message. :(

@pkshetlie, the status of the order is not updated?

Thanks!

@khouloudbelguith the status is changing but still the same error after

@pkshetlie,

Overrides are disabled and non native modules too

How did you disabled the Overrides & the non native modules?

Thanks!

@khouloudbelguith via the backoffice (performance) for non native and override
and I uninstall MY modules, then go to override folder and check that everything is removed

@pkshetlie, the option "Disable non PrestaShop modules" doesn't work as reported in this issue: https://github.com/PrestaShop/PrestaShop/issues/9965 & the "Disable all overrides" doesn't work as reported here: https://github.com/PrestaShop/PrestaShop/issues/14596

Thanks to check & feedback

@pkshetlie do you only get this error when new state has "send email to customer" enable ?
maby related to #14842

@khouloudbelguith I tried to uninstall all other module than prestashop's and no changes

@thbl nice catch, when I change state for 5 (one that doesn't send email in my conf) it works

Hi @pkshetlie,

The issue is added to our debug roadmap.
Your ticket is a duplicate of #14842
So, I close it.
Thanks!

Duplicate of #14842

@khouloudbelguith I don't agree, #14842 is a duplicate of mine it comes after ;)

Thank you for all, waiting for the patch ;)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

PrestaShark picture PrestaShark  路  3Comments

hiousi picture hiousi  路  3Comments

zuk3975 picture zuk3975  路  3Comments

khouloudbelguith picture khouloudbelguith  路  3Comments

wikao2 picture wikao2  路  3Comments