Paulo Binatto Posted January 29, 2018 Share Posted January 29, 2018 Hi, i'm a brazilian, my english isn't good, but i need help to create a product from webservice php. I try but the response is a 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] Invalid argument supplied for foreach() (/home/vipsyste/public_html/prestashop.vipsystem.com.br/classes/Product.php, line 6054)]]></message> </error> </errors> </prestashop> XML send <?xml version="1.0" encoding="UTF-8"?> <prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> <product> <id/> <id_manufacturer/> <id_supplier/> <id_category_default>32</id_category_default> <new/> <cache_default_attribute/> <id_default_image/> <id_default_combination/> <id_tax_rules_group/> <type/> <id_shop_default/> <reference/> <supplier_reference/> <location/> <width/> <height/> <depth/> <weight/> <quantity_discount/> <ean13/> <upc/> <cache_is_pack/> <cache_has_attachments/> <is_virtual/> <on_sale/> <online_only/> <ecotax/> <minimal_quantity/> <price>1000</price> <wholesale_price/> <unity/> <unit_price_ratio/> <additional_shipping_cost/> <customizable/> <text_fields/> <uploadable_files/> <active>1</active> <redirect_type/> <id_product_redirected/> <available_for_order/> <available_date/> <condition/> <show_price/> <indexed/> <visibility/> <advanced_stock_management/> <date_add/> <date_upd/> <pack_stock_type/> <meta_description><language id="3"/></meta_description> <meta_keywords><language id="3"/></meta_keywords> <meta_title><language id="3"/></meta_title> <link_rewrite>nome</link_rewrite> <name>nome</name> <description>descricao</description> <description_short>descricao pequena</description_short> <available_now><language id="3"/></available_now> <available_later><language id="3"/></available_later> <associations> <categories> <category> <id/> </category> </categories> <images> <image> <id/> </image> </images> <combinations> <combination> <id/> </combination> </combinations> <product_option_values> <product_option_value> <id/> </product_option_value> </product_option_values> <product_features> <product_feature> <id/> <id_feature_value/> </product_feature> </product_features> <tags> <tag> <id/> </tag> </tags> <stock_availables> <stock_available> <id/> <id_product_attribute/> </stock_available> </stock_availables> <accessories> <product> <id/> </product> </accessories> <product_bundle> <product> <id/> <quantity/> </product> </product_bundle> </associations> </product> </prestashop> PHP critéria $webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG); $xml = $webService->get(array('url' => PS_SHOP_PATH . '/api/products?schema=blank')); $resources = $xml->children()->children(); unset($resources->position_in_category); unset($resources->manufacturer_name); unset($resources->quantity); unset($resources->position_in_category); unset($resources->manufacturer_name); $resources->price = '1000'; $resources->active = '1'; $resources->link_rewrite = 'nome'; $resources->name = 'nome'; $resources->description = 'descricao'; $resources->description_short = 'descricao pequena'; $resources->id_category_default = '32'; $opt = array('resource' => 'products'); $opt['postXml'] = $xml->asXML(); $xml = $webService->add($opt); Thank's for help me Link to comment Share on other sites More sharing options...
BGUEVARA Posted March 21, 2018 Share Posted March 21, 2018 Saludos, amigo, yo tengo el mismo error, pudiste corregirlo.? Gracias Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now