API Forum

This forum is in read-only mode.
Please refer to our API support in case you have any questions.
We can be reached at api@e-conomic.com
e-conomic API developer forum

Product_CreateFromDataArray error, wrong syntax?

0
Hello.
I'm haveing problem creating products with Product_CreateFromDataArray.
I use the follwing code:
    function EC_ProductCreate($client,$createArray) {
        $productGroupHandle = $client-ProductGroup_FindByNumber(array(number = 1))-ProductGroup_FindByNumberResult;;
        $ec_createarray = array();
        $i = 0;
        foreach($createArray as $productdata) {
            $i++;
            $ec_createarray = array(
            'Number'      = $productdataartnr,
            'Name'         = $productdataname,
            'Description'   = '',
            'SalesPrice'   = $productdataprice,
            'CostPrice' = 00,
            'RecommendedPrice' = 00,
            'IsAccessible'   = true,
            'Volume' = 00,
            'ProductGroupHandle'=$productGroupHandle);
            if($i == 3) { break; }
        }
        $superarray = array('data' = $ec_createarray);
        print_r($superarray);
        $result = $client-Product_CreateFromDataArray($superarray)-Product_CreateFromDataArrayResult; // Line 57
        print_r($result);
    }

But I get an error. bellow is the structre of my array and the error msg

    data = Array (
    0 = Array (
        Number = 000001 Name = AA iPhone 4/4S/3G/3GS Billaddare - Vit Description = SalesPrice = 9350000 CostPrice = 0 RecommendedPrice = 0 IsAccessible = 1 Volume = 0
            ProductGroupHandle = stdClass Object (
                Number = 1
            )
        )
    1 = Array (
        Number = 000002 Name = AA Micro USB Billaddare Description = SalesPrice = 7500000 CostPrice = 0 RecommendedPrice = 0 IsAccessible = 1 Volume = 0
            ProductGroupHandle = stdClass Object (
                Number = 1
            )
        )
    2 = Array (
        Number = 000003 Name = AA Mini USB Billaddare Description = SalesPrice = 7500000 CostPrice = 0 RecommendedPrice = 0 IsAccessible = 1 Volume = 0
            ProductGroupHandle = stdClass Object (
                Number = 1
            )
        )
    )
)
Fatal error Uncaught SoapFault exception soapServer EconomicApiExceptionsServerException(E00000)
An internal error has occurred (id=253dd9d0-4516-486a-b669-970a96eef973) in /home/sweetgad/public_html_webshop/Export/ec_funcphp57
Stack trace #0 /home/sweetgad/public_html_webshop/Export/ec_funcphp(57) SoapClient-__call('Product_CreateF', Array)
#1 /home/sweetgad/public_html_webshop/Export/ec_funcphp(57) SoapClient-Product_CreateFromDataArray(Array)
#2 /home/sweetgad/public_html_webshop/Export/indexphp(40) EC_ProductCreate(Object(SoapClient), Array)
#3 {main} thrown in /home/sweetgad/public_html_webshop/Export/ec_funcphp on line 57
created Mar 8, 2013 by PhpMadman
100% Accept Rate
Q 3 A 8 C 2

7 Answers

0
 
Best answer
= array(

                               );
$this-client-OrderLine_CreateFromDataArray(array(id =$i, dataArray=$orderlines));
//set all the properties of a order here..

}

I hope it is helpful

Thanks  Regards
sudheer
answered Mar 20, 2013 by sudheerphp
selected Mar 22, 2013 by nkn
0
Hi there,

I am not able to help you with the PHP code, but I can show what the resulting XML we receive is:

?xml version=1.0 encoding=UTF-8?
SOAP-ENV:Envelope xmlns:SOAP-ENV=http://schemas.xmlsoap.org/soap/envelope/ xmlns:ns1=http://e-conomic.comSOAP-ENV:Bodyns1:Product_CreateFromDataArray//SOAP-ENV:Body/SOAP-ENV:Envelope

The reason the server complains is that there is no array in the envelope.
answered Mar 10, 2013 by nkn
0
That can't be.
I mean. I print the god damn array the line above the soap call.
And it contains the data.
Anyone with some PHP knowledge got any thoughts?
answered Mar 11, 2013 by PhpMadman
0
Okey. Solved that error. seems I need to send it as array('dataArray' = )

        $superarray = $ec_createarray;
        print_r($superarray);
        echo(brbrbr);
        $result = $client-Product_CreateFromDataArray(array(dataArray = $superarray))-Product_CreateFromDataArrayResult; // Line 61

But now I get another error.



Fatal error Uncaught SoapFault exception soapClient EconomicApiExceptionsSchemaException(E00500) The 'id' attribute is not declared (id=27649716-84c9-4bdd-9673-691357c81801) in /home/sweetgad/public_html_webshop/Export/ec_funcphp61 Stack trace #0 /home/sweetgad/public_html_webshop/Export/ec_funcphp(61) SoapClient-__call('Product_CreateF', Array) #1 /home/sweetgad/public_html_webshop/Export/ec_funcphp(61) SoapClient-Product_CreateFromDataArray(Array) #2 /home/sweetgad/public_html_webshop/Export/indexphp(40) EC_ProductCreate(Object(SoapClient), Array) #3 {main} thrown in /home/sweetgad/public_html_webshop/Export/ec_funcphp on line 61
answered Mar 11, 2013 by PhpMadman
0
answered Mar 15, 2013 by sudheerphp
reshown May 24, 2013 by sudheerphp
0
answered Mar 15, 2013 by sudheerphp
reshown May 24, 2013 by sudheerphp
0
Okey. So I just need to add an ID = $i where $i can be a static number i set?
Beacuse i'm adding / updateing products,  so I don't really have any IDnr to use, such as number of OrderLines.
answered Mar 18, 2013 by PhpMadman
Visma e-conomic A/S
...