I'm trying to complete my software which interacting with the Magento API and another external API (REST). In this project I forwarding the orders of the other shop system towards Magento and I'm able to create a order (yeha!).
Unfortunately, Magento seems to cause an fatal error after the successful order. That's a problem because I've to convert about hundrets orders...
Fatal error: Uncaught SoapFault exception: [SOAP-ENV:Server] Call to a member function getSelect() on a non-object in /var/orders.php:280 Stack trace: #0 /var/orders.php: SoapClient->__call('call', Array) #1 /var/orders.php: SoapClient->call('6ceb613d278de9e...', 'cart.order', Array) #2 /var/orders.php: complete_order(Array, 3) #3 /var/orders.php: new_orders(Object(mysqli))
Does anybody have any idea how to solve that?
The involved line in the PHP file:
$result = $client->call($session, 'cart.info', $shopping_cart_id);
The whole PHP code:
function complete_order($val,$i=1) { if($i == 3) { $client = new SoapClient(MAGENTO_HOST.'/api/soap/?wsdl'); $session = $client->login(MAGENTO_API_USER, MAGENTO_API_KEY); # Choose a store id $store_id = $client->call($session, 'category.currentStore', MAGENTO_STORE_ID); # Create a new shopping cart $shopping_cart_id = $client->call( $session, 'cart.create', $store_id ); # Add products to cart # $product_for_cart = array( array( "sku" => "TOPP19600", "qty" => 2, "options" => null ), array( "sku" => "TOPP19601", "qty" => 1, "options" => null ) ); $val['items'] = $product_for_cart; foreach($val['items'] AS $item) { $filters = array( 'status' => array( '=' => 1 ), 'sku' => array( '=' => $item['sku']), ); $result = $client->call($session, 'catalog_product.list', array($filters,$store_id)); if($result != NULL AND count($result) > 0) { $product_for_cart[] = array('product_id' => $result[0]['product_id'], 'qty' => $item['qty']); } else { # unknown product found # echo('Unknown product'); } } # Customer information (as guest) # $customer = array( 'mode' => 'guest', 'firstname' => $val['invoice_address']['firstname'], 'lastname' => $val['invoice_address']['lastname'], 'email' => $val['invoice_address']['email'], 'website_id' => 0, 'store_id' => 0, 'group_id' => 0, 'dob' => date('d.m.Y',$val['created_at']), 'confirmation' => 1 ); $resultCustomerSet = $client->call($session, 'cart_customer.set', array($shopping_cart_id, $customer, $store_id) ); // Set customer addresses, for example guest's addresses $arrAddresses = array( array( "mode" => "shipping", "firstname" => "testFirstname", "lastname" => "testLastname", "company" => "testCompany", "street" => "testStreet", "city" => "testCity", "region" => "testRegion", "postcode" => "testPostcode", "country_id" => "id", "telephone" => "0123456789", "fax" => "0123456789", "is_default_shipping" => 0, "is_default_billing" => 0 ), array( "mode" => "billing", "firstname" => "testFirstname", "lastname" => "testLastname", "company" => "testCompany", "street" => "testStreet", "city" => "testCity", "region" => "testRegion", "postcode" => "testPostcode", "country_id" => "id", "telephone" => "0123456789", "fax" => "0123456789", "is_default_shipping" => 0, "is_default_billing" => 0 ) ); $add_product_to_cart = $client->call($session,"cart_product.add",array($shopping_cart_id, $product_for_cart)); $resultCustomerAddresses = $client->call($session,"cart_customer.addresses",array($shopping_cart_id, $arrAddresses, $store_id)); $choose_shipping_method = $client->call($session, 'cart_shipping.method', array($shopping_cart_id, 'pl_store_pickup_kostenlose_selbstabholung_w_hrend_den_gesch_ftszeiten_sie_erhalten_eine_e_mail_benachrichtigung_sobald_ihre_bestellung_zur_abholung_bereit_liegt__jawolle_rheinstr_29_66113_saarbr_cken')); $resultPaymentMethod = $client->call($session,'cart_payment.method',array($shopping_cart_id, $paymentMethod = array('method' => 'bankpayment'))); # Finishing order # $result = $client->call($session, 'cart.info', $shopping_cart_id); $client->endSession($session);
orders.php
, because it seems as the error is thrown there in line 280.