Jump to content

[Solved]Error updating with web service


keko123

Recommended Posts

Hi, i´m new in prestashop.
 
I try update products, clients, addresses and categories but allways have same error:
 
Error : Bad parameters given
 
My code is:

define('DEBUG', true); // Debug mode
define('PS_SHOP_PATH', 'http://www.mydomain.com'); // Root path of your PrestaShop store
define('PS_ADMIN_DIR', getcwd());
define('PS_WS_AUTH_KEY', XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'); // Auth key (Get it in your Back Office)
require_once('PSWebServiceLibrary.php');

 

    try{
        $file = $_GET['file'];
        $id_category = $_GET['id_category'];
        $webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG);
        if (!file_exists('import/categories/'.$file.'.xml')){
            throw new Exception('No read file.');
        }
        $xml=simplexml_load_file('import/categories/'.$file.'.xml');
        
        $opt = array( 'resource' => 'categories' );
        $opt['postXml'] = $xml->asXML();
        $opt['id'] = $id_category;
        $xml = $webService->edit($opt);
        
        if(!file_exists('import/historico/categories/')){
            mkdir('import/historico/categories/', 0755, true);
        }
        rename('import/categories/'.$file.'.xml','import/historico/categories/'.time().'-'.$file.'xml');
    }
    catch (PrestaShopWebserviceException $ex) { echo '<b>Error : '.$ex->getMessage().'</b>'; }
    catch (PrestaShopWebserviceException $e){echo '<b>Error : '.$e->getMessage().'</b>';}
    catch (Exception $excepcion){echo '<b>Error : '.$excepcion->getMessage().'</b>';};
 

 

Content client.xml file is:

 

<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<customer>
    <id_default_group><![CDATA[3]]></id_default_group>
    <deleted><![CDATA[0]]></deleted>
    <passwd><![CDATA[f2b120c2eeed4820a4aaf847f0354643]]></passwd>
    <lastname><![CDATA[Darling]]></lastname>
    <firstname><![CDATA[Wendy Moira]]></firstname>
    <email><![CDATA[[email protected]]]></email>
    <id_gender><![CDATA[2]]></id_gender>
    <birthday><![CDATA[1989-11-12]]></birthday>
    <website/>
    <company/>
</customer>
</prestashop>

 

Add and delete run perfectly. I´m using 1.6.0.5 version

 

Somebody can help me please?

 

Thanks

 

Sergio

Edited by keko123 (see edit history)
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...