We have a problem when add a product in REST services
i send this....
application/xml:
<id_manufacturer>4</id_manufacturer>
<id_supplier>1</id_supplier>
<id_category_default>2</id_category_default>
<cache_default_attribute>0</cache_default_attribute>
<id_default_image>3</id_default_image>
<id_default_combination>0</id_default_combination>
<id_tax_rules_group>1</id_tax_rules_group>
simple
<id_shop_default>1</id_shop_default>
1002
<supplier_reference>demo_6_70</supplier_reference>
0.000000
0.000000
0.000000
0.300000
<quantity_discount>0</quantity_discount>
8470000002
<cache_is_pack>0</cache_is_pack>
<cache_has_attachments>0</cache_has_attachments>
<is_virtual>0</is_virtual>
<additional_delivery_times>1</additional_delivery_times>
<delivery_in_stock>
</delivery_in_stock>
<delivery_out_stock>
</delivery_out_stock>
1
<on_sale>0</on_sale>
<online_only>0</online_only>
0.000000
<minimal_quantity>1</minimal_quantity>
<low_stock_alert>0</low_stock_alert>
100.0000
<wholesale_price>0.000000</wholesale_price>
<unit_price_ratio>0.000000</unit_price_ratio>
<additional_shipping_cost>0.000000</additional_shipping_cost>
0
<text_fields>0</text_fields>
<uploadable_files>0</uploadable_files>
1
<redirect_type>301-category</redirect_type>
<id_type_redirected>0</id_type_redirected>
<available_for_order>1</available_for_order>
<available_date>0000-00-00</available_date>
<show_condition>0</show_condition>
new
<show_price>1</show_price>
1
both
<advanced_stock_management>0</advanced_stock_management>
<date_add>2022-04-25 11:39:18</date_add>
<date_upd>2022-05-04 11:46:10</date_upd>
<pack_stock_type>3</pack_stock_type>
<meta_description>
</meta_description>
<meta_keywords>
</meta_keywords>
<meta_title>
</meta_title>
<link_rewrite>
the-best-is-yet-to-come-framed-poster
</link_rewrite>
ARTICULO-PRO-AZUL-20...
Y esta es la descripcion larga del articulo ARTICULO-PRO-AZUL-20... ARTICULO-PRO-AZUL-20... ARTICULO-PRO-AZUL-20...ARTICULO-PRO-AZUL-20...ARTICULO-PRO-AZUL-20... Descripcion larga
<description_short>
Esta es la descripcion corta del articulo ARTICULO-PRO-AZUL-20...
</description_short>
<available_now>
</available_now>
<available_later>
</available_later>
2
31
3
<product_option_values />
<product_features>
<product_feature>
1
<id_feature_value>6</id_feature_value>
</product_feature>
</product_features>
<stock_availables>
<stock_available>
3
<id_product_attribute>0</id_product_attribute>
</stock_available>
<stock_available>
32
<id_product_attribute>13</id_product_attribute>
</stock_available>
<stock_available>
33
<id_product_attribute>14</id_product_attribute>
</stock_available>
<stock_available>
34
<id_product_attribute>15</id_product_attribute>
</stock_available>
</stock_availables>
<product_bundle />
ws_key: LRU7ZXT7J6XB1TI6EPUKJ7NWG81EKQXJ
Library Version:
1.0.0
NuGet Package Url:
PrestaSharp 1.2.9
Prestashop version:
1.7.8.5
Describe the Bug:
HttpStatusCode: InternalServerError
To Reproduce:
1.
2.
3.
Expected Behavior:
when i append de product....tho code is here
/// <summary>
/// Add a list of entities.
/// </summary>
/// <param name="Entities"></param>
/// <returns></returns>
public List<T> AddList(List<T> Entities)
{
List<PrestaSharp.Entities.PrestaShopEntity> EntitiesToAdd = new List<PrestaSharp.Entities.PrestaShopEntity>();
foreach (T Entity in Entities)
{
Entity.id = null;
EntitiesToAdd.Add(Entity);
}
RestRequest request = this.RequestForAdd(pluralEntityName, EntitiesToAdd);
return this.Execute<List<T>>(request);
}
el mensaje de error es este PHP Notice #8] Trying to access array offset on value of type bool (/var/www/html/classes/Product.php, line 7170)
I found the problem, it is in the setter of the Product class in the id_default_image field.
NO OK >> public long? id_default_image { get; set;}
OK >> public long? id_default_image { get; }
Thanks
I found the problem, it is in the setter of the Product class in the id_default_image field.
NO OK >> public long? id_default_image { get; set;}
OK >> public long? id_default_image { get; }
Thanks
Hello, i proceeded with that solution but in my case it didn't work.
What i did to solve this issue was add the if not result return false to the class Product.php on the path public_html/Classes/product.php.
Credits to: https://stackoverflow.com/a/69623640/13090191
Hope this helps somebody in the future too
public function getCoverWs()
{
$result = $this->getCover($this->id);
if (!$result) {
return false;
}
return $result['id_image'];
}