Magento Forum

XML-RPC version 1.1.3
 
EvanBrassart
Jr. Member
 
Total Posts:  13
Joined:  2008-08-19
Dallas, Texas
 

I am using magento to create few retail websites for different product lines.

I am trying to use the API through XML-RPC to pull down the orders.  I can successfully login and get the “sessionID”

My problem comes in when I pull “sales_order.info” The “items” array is empty on all my orders.

//Custom Data Type for Magento API

[Define_Type:'Mage_Sys']
    [local
:'sessionID']
    [local
:'path']
    [local
:'response']
    [Define_Tag
:'onCreate',-Required='path',-Required='username',-Required='password']
        [Define_Tag
:'Mage_Login',-Required='path',-Required='username',-Required='password']
            [local
:'result'=(XML_RPCCall: -host=(#path),-Method='login', -Params=(Array:(#username),(#password)))]
            
[return:(Decode_XML:(#result))]
        
[/Define_Tag]

        [local
:'ses'=(Mage_login:(#path),(#username),(#password))]
        
[if:(#ses)=='']
            
[fail:-1,'Username and password invalid']
        [else]
            [self
->'sessionID'=(#ses)]
            
[self->'path'=(#path)]
        
[/if]
    [
/Define_Tag]
    
    [Define_Tag
:'Call',-Required='method',-optional='procs']
        [if
:(local_defined:'procs')]
            [local
:'result'=(XML_RPCCall: -host=(self->'path'),-Method='call', -params=(array:(self->'sessionId'),(#method),(#procs)))]
        
[else]
            [local
:'result'=(XML_RPCCall: -host=(self->'path'),-Method='call', -params=(array:(self->'sessionId'),(#method)))]
        
[/if]
        [self
->'response'=(#result)]
        
[return:(#result)]
    
[/Define_Tag]
    
[
/Define_Type]

//LOGIN
[var:'rpc_path'='http://localhost/api/xmlrpc/']
[local
:'Mage'=(Mage_Sys:($rpc_path),'UBER','yayyy')]

//Get the order info
[local:'order_info'=(#Mage->Call('sales_order.info','100000001')))]
[#order_info->(find:'items')->(size)] // ALWAYS 0
 
Magento Community Magento Community
Magento Community
Magento Community
 
Jelmo
Jr. Member
 
Total Posts:  28
Joined:  2008-08-15
 

Hi,

Don’t know if this helps, but i have had a similar problem with sales_order.list.

My code was as followes:

$session $client->call('login', array('api''testApi'));
    
    
$orderList $client->call('call', array($session'sales_order.list'));

    foreach (
$orderList as $order)
        
$detail[$order['increment_id']] $client->call('call', array($session'sales_order.info'$order['increment_id']));

        
print_r($detail);

This just wouldn’t work. After some searching, i found out that the attributes that are send to the sales_order.info function must be in an array. So the working code is:

$session $client->call('login', array('api''testApi'));
    
    
$orderList $client->call('call', array($session'sales_order.list'));

    foreach (
$orderList as $order)
        
$detail[$order['increment_id']] $client->call('call', array($session'sales_order.info', array($order['increment_id'])));

        
print_r($detail);

Hopes this helps you just a bit… smile

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top