Jump to content

In PrestaShop 1.6: when trying to add product with webservices I am getting error 500 in live server


rajlaskar

Recommended Posts

In PrestaShop 1.6: when trying to add product with webservices I am getting error 500 in live server, but same script works fine in localhost


I am getting this error "Uncaught exception 'PrestaShopWebserviceException' with message 'This call to PrestaShop Web Services failed and returned an HTTP status of 500. That means: Internal Server Error.' in" while executing the below script in linux server for live site, but same works fine localhost, what could be the issue? yes of course I did change the PS_SHOP_PATH and PS_WS_AUTH_KEY value for live site.

<?php
define('DEBUG', true);
define('_PS_DEBUG_SQL_', true);

define('PS_SHOP_PATH', 'http://localhost/prestashop');
define('PS_WS_AUTH_KEY', 'your-key-here');


 
require_once('PSWebServiceLibrary.php');
$webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG);
 

 $xml_product = $webService->get(array('resource' => 'products?schema=blank'));
 $resources_product = $xml_product->children()->children();

 
$resources_product->id_manufacturer ='1';
$resources_product->id_supplier ='1';
$resources_product->id_category_default	='3';
//$resources_product->new	='1';
$resources_product->cache_default_attribute;
$resources_product->id_default_image;
$resources_product->id_default_combination;
$resources_product->id_tax_rules_group;
//$resources_product->position_in_category;	
$resources_product->manufacturer_name;	
//$resources_product->quantity="3";	
$resources_product->type;
$resources_product->id_shop_default;
$resources_product->reference='SKUID45';
$resources_product->supplier_reference;
$resources_product->location;
$resources_product->width;
$resources_product->height;	
$resources_product->depth;	
$resources_product->weight;
$resources_product->quantity_discount;	
$resources_product->ean13;
$resources_product->upc;
$resources_product->cache_is_pack;
$resources_product->cache_has_attachments;
$resources_product->is_virtual;
$resources_product->on_sale;
$resources_product->online_only;
$resources_product->ecotax;
$resources_product->minimal_quantity;
$resources_product->price='20.00';
$resources_product->wholesale_price;
$resources_product->unity;
$resources_product->unit_price_ratio;	
$resources_product->additional_shipping_cost;
$resources_product->customizable;
$resources_product->text_fields;
$resources_product->uploadable_files;
$resources_product->active='1';
$resources_product->redirect_type;
$resources_product->id_product_redirected;
$resources_product->available_for_order;
$resources_product->available_date;	
$resources_product->condition ='new';	
$resources_product->show_price;	
$resources_product->indexed	='1';
$resources_product->visibility = 'both';
$resources_product->advanced_stock_management;
$resources_product->date_add;
$resources_product->date_upd;
$resources_product->meta_description->language ='Product Meta Description';
$resources_product->meta_keywords->language='Product Meta keywords';
$resources_product->meta_title->language='Product Meta Title';
$resources_product->link_rewrite->language='product-url-key';	
$resources_product->name->language='Product Name';	
$resources_product->description->language='Product Description';
$resources_product->description_short->language='Product Short Description ';
$resources_product->available_now->language='30/10/14';	
$resources_product->available_later->language;
$resources_product->associations->categories->addChild('category')->addChild('id', 3);


$xml_product = $webService->add(array('resource' => 'products', 'postXml' => $xml_product->asXML())); 
 
   ?>

what could be the issue, can anyone please help

Link to comment
Share on other sites

Turn on error reporting on the target shop, when add some debug to the prestashop webservice caller (it uses curl, right?) and print out the curl response

 

Thank you Nemo1, for your reply.

 

I am using this library https://github.com/PrestaShop/PrestaShop-webservice-lib/blob/master/PSWebServiceLibrary.php

 

It uses curl , and yes curl is installed on the server

 

This is the error i ma getting in php_errorlog

 

[16-Nov-2014 04:37:41 CST6CDT] PHP Fatal error:  Uncaught exception 'PrestaShopWebserviceException' with message 'This call to PrestaShop Web Services failed and returned an HTTP status of 500. That means: Internal Server Error.' in /home/******************/****/webservices/PSWebServiceLibrary.php:92
Stack trace:
#0 /home/******************/****/webservices/PSWebServiceLibrary.php(221): PrestaShopWebservice->checkStatusCode(500)
#1 /home/******************/****/webservices/add_prod1.php(106): PrestaShopWebservice->add(Array)
#2 {main}
  thrown in /home/******************/****/webservices/PSWebServiceLibrary.php on line 92
Link to comment
Share on other sites

  • 2 weeks later...

thank you Nemo1 for your help, i did not try that, as i had written my own class to directly insert into the DB, actually i have an internal system where all products are entered and i need to export those to prestashop DB from my system, as i have access to both DB, direct insertion and edit working fine for me.

Link to comment
Share on other sites

×
×
  • Create New...