Bukimedia / PrestaSharp

CSharp .Net client library for the PrestaShop API via web service
GNU General Public License v3.0
154 stars 152 forks source link

PrestaShop 8 #458

Open nturini-cascinanet opened 1 year ago

nturini-cascinanet commented 1 year ago

Trying to add a new product in prestashop 8 i always receive this error

<'?xml version="1.0" encoding="UTF-8"?>
<'prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<'errors>
<'error>
<'code><'![CDATA[3]]><'/code>
<'message><'![CDATA[[PHP Warning #2] foreach() argument must be of type array|object, string given (/var/www/vhosts/...../classes/Product.php, line 7908)]]><'/message>
<'/error>
<'/errors>
<'/prestashop>
HttpStatusCode: InternalServerError
in Bukimedia.PrestaSharp.Factories.RestSharpFactory.CheckResponse(IRestResponse response, RestRequest request)
in Bukimedia.PrestaSharp.Factories.RestSharpFactory.Execute[T](RestRequest request)
in Bukimedia.PrestaSharp.Factories.GenericFactory1.Add(T Entity)

in 1.7.8.x versions the insertion works correctly

DomenicoFormoso commented 12 months ago

I'm interested to know if an update compatible with version 8 will be released in the future.

robertoalonsovelasco commented 8 months ago

(view error / line)

In file clases\product.php i comment this line: (line 7093) and the problem are solved. This is not the best solution and i don't know than delete this line may by thorw.

    // result is indexed by recordset order and not position. positions start at index 1 so we need an empty element

// array_unshift($result, null); // foreach ($result as &$value) { // $value = $value['id_product']; // }

robertoalonsovelasco commented 5 months ago

or this : // result is indexed by recordset order and not position. positions start at index 1 so we need an empty element if ($result !== null) { array_unshift($result, null); foreach ($result as &$value) { if (is_array($value) && isset($value['id_product'])) { $value = $value['id_product']; } } }