<?php ini_set('max_execution_time', 3000); $client = new SoapClient('http://magento-7350-19577-45479.cloudwaysapps.com/api/v2_soap/?wsdl'); // If somestuff requires api authentification, // then get a session token $session = $client->login('testapp', 'mytestapp'); $filter = array('filter' => array(array('key' => 'base_currency_code', 'value' => 'USD'))); //$result = $client->salesOrderList($session, $filter); $result = $client->salesOrderList($session); // If you don't need the session anymore var_dump($result); //echo 'No of Orders : '.count($result); echo '</br>'; foreach ($result as $value) { echo 'Increment ID : ' . $value->increment_id . '</br>'; } //$a=json_decode ($result); //print_r($a); /* ini_set('max_execution_time', 3000); error_reporting(E_ALL); ini_set('display_errors', TRUE); $api_url = "'http://magento-7350-19577-45479.cloudwaysapps.com/api/v2_soap/?wsdl=1"; //For Version 2 //$api_url = "http://yourhost.com/api/soap/?wsdl"; //For Version 1 $username = '******'; $password = '******'; $client = new SoapClient($api_url,array('cache_wsdl' => WSDL_CACHE_NONE)); //Will cnot cache the WSDL
public function mamethodeAction() { echo "<pre>"; $baseDir = Mage::getBaseDir('code'); // include_once // $baseDir.'app/code/community/IWD/OrderManager/Model/Order/Edit.php'; // echo $baseDir.'<br>'; // Mage::log($baseDir,null, 'wms-api.log'); // echo $this->apiUrl. " == " .$this->apiUser. " == " // .$this->apiPassword; $date = date('Y-m-d h:i:s'); echo "Date is " . $date . "<br>"; /** * ##################################################################################### */ // Establish the connection to WMS api $proxy = new SoapClient($this->apiUrl); $sessionId = $proxy->login($this->apiUser, $this->apiPassword); echo $sessionId; // $order_increment_Id = "151020C-811018"; // $order_increment_Id = "20151019C-1992393"; /* * ComplexFilter For Order filter */ $complexFilterOrder = array('complex_filter' => array(array('key' => 'updated_at', 'value' => array('key' => 'from', 'value' => date('Y-m-d', strtotime("-6 days")) . " 00:00:00")), array('key' => 'updated_at', 'value' => array('key' => 'to', 'value' => date('Y-m-d') . " 00:02:00")))); /* * Get Updated Order list from the WMS */ $order_list = $proxy->salesOrderList($sessionId, $complexFilterOrder); $count = 1; /* * Loop through each Order from WMS to check for Invoices and Shipment */ foreach ($order_list as $order) { echo "<br>Order : " . $count . "<br>"; $count++; /* * Complex filter to filter out new Invoices and Shipment for the Corresponding OrderId Instead of the increment order ID */ $complexFilter = array('complex_filter' => array(array('key' => 'order_id', 'value' => array('key' => 'in', 'value' => $order->order_id)), array('key' => 'created_at', 'value' => array('key' => 'from', 'value' => date('Y-m-d', strtotime("-6 days")) . " 00:00:00")), array('key' => 'created_at', 'value' => array('key' => 'to', 'value' => date('Y-m-d') . " 00:02:00")))); // echo "<br>##########################################<br>"; echo "---------------" . $order->order_id . "---------------<br>"; // echo "<br><br>"; /* * Invoice list for the order. */ $invoice_list = $proxy->salesOrderInvoiceList($sessionId, $complexFilter); /* * shipment list for the order. */ $shipment_list = $proxy->salesOrderShipmentList($sessionId, $complexFilter); /* * If there is no invoice or shipment continu with next Order */ if (count($invoice_list) < 1 && count($shipment_list) < 1) { echo "NO Invoice and Shipment<br>"; continue; } var_dump($invoice_list); var_dump($shipment_list); echo "<br>##########################################<br>"; /* * $invoice_list = * $proxy->salesOrderInvoiceList($sessionId,$complexFilter); * $shipment_list = * $proxy->salesOrderShipmentList($sessionId,$complexFilter); * var_dump($invoice_list); * var_dump($shipment_list); */ /* * For each invoice in the invoice list */ foreach ($invoice_list as $invoice) { $invoice_info = $proxy->salesOrderInvoiceInfo($sessionId, $invoice->increment_id); // var_dump($invoice_info); //var_dump(get_class($invoice_info)); $this->addInvoiceFromWMS($invoice_info, $order->order_id); } /* * foreach shipment in the shipment list */ foreach ($shipment_list as $shipment) { $shipment_info = $proxy->salesOrderShipmentInfo($sessionId, $shipment->increment_id); //var_dump(get_class($shipment_info)); // var_dump($shipping_info->order_increment_id); $this->addShipmentFromWMS($shipment_info, $order->order_id); } } $proxy->endSession($sessionId); echo "</pre>"; }
<?php $mageFilename = '../app/Mage.php'; require_once $mageFilename; ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(-1); umask(0); Mage::app("default"); $client = new SoapClient('http://52.11.138.2/index.php/api/v2_soap/?wsdl'); $session = $client->login('testapi', 'justdoit'); /* * $result = $client->customerCustomerCreate ( $session, array ( * 'email' => '*****@*****.**', * 'firstname' => 'Mritunjay', * 'lastname' => 'Kumar', * 'password' => 'mritun11', * 'website_id' => 1, * 'store_id' => 1, * 'group_id' => 1 * ) ); */ $order_complexFilter = array('complex_filter' => array(array('key' => 'increment_id', 'value' => array('key' => 'eq', 'value' => '151016C-811012')))); $result = $client->salesOrderList($session, $order_complexFilter); echo '<pre>'; var_dump($result); echo '</pre>';
<?php try { error_reporting(E_ALL | E_STRICT); ini_set('display_errors', 1); $proxy = new SoapClient('http://xyz.com/index.php/api/v2_soap?wsdl', array('trace' => 1, 'connection_timeout' => 120)); $session = $proxy->login(array('username' => $username, 'apiKey' => $password)); $sessionId = $session->result; $filters = array(); $filters = array('created_at' => array('from' => '2015-04-21 02:13:00', 'to' => '2016-04-21 02:22:00')); $products = $proxy->salesOrderList(array("sessionId" => $sessionId, "filters" => $filters)); // $products = $proxy->customerCustomerList(array("sessionId"=> $sessionId,"filters"=> $filters)); // echo '<h1>Result</h1>'; echo '<pre>'; print_r($products); // echo '</pre>'; } catch (Exception $e) { // echo '<h1>Error</h1>'; echo '<p>'. $e->getMessage().'</p>'; }
/** * * @param Varien_Event_Observer $observer * @return Zoffio_WmsApi_Model_Observer */ public function orderItemRemoveAfter(Varien_Event_Observer $observer) { // $event = $observer->getEvent()->getData(); Mage::log(__CLASS__ . "_" . __FILE__ . "_" . __LINE__, null, 'wms-api.log'); Mage::log(__CLASS__ . "_" . __FUNCTION__ . " " . self::$_observerExecutionCounter, null, 'shebin.log'); // ################################################################### /** * Order Item remove after event to handle the remove Order. */ $order = $observer->getOrder(); $order_status = $order->getData('status'); // return if the order status is not set if (!isset($order_status) || trim($order_status) === '') { return $this; } // Do not push Order that are not approved. if ($order_status != 'approved' && $order_status != 'canceled') { Mage::log('Order not pushed in WMS. Status: ' . $order_status, null, 'wms-api.log', true); return $this; } // Get increment Order Id $zoffio_order_id = $order->getIncrementId(); // connect to the WMS API $proxy = new SoapClient(self::$_apiUrl); $sessionId = $proxy->login(self::$_apiUser, self::$_apiPassword); // Check Order existence in WMS try { $order_existWms = $proxy->salesOrderList($sessionId, $order_complexFilter); } catch (Exception $e) { Mage::log($e->getMessage(), null, 'shebin.log'); Mage::log($e->getTraceAsString(), null, 'shebin.log'); } // Do not push the cancell orders that was not approved to WMS if ($order_status == 'canceled' && count($order_existWms) < 1) { /* * Order should not be pushed when the cancelled order is not there * in the WMS. ie., the Order was not approved. */ Mage::log('Order canceled which is not in WMS ' . $zoffio_order_id, null, 'wms-api.log', true); return $this; } if (count($order_existWms) > 0) { $order_item = $observer->getOrderItem(); $order_product = array(); $item_sku = $order_item->getSku(); $item_qty = 0; // remove product $item_price = 0; $order_products[] = array('sku' => $item_sku, 'qty' => $item_qty, 'price' => $item_price, 'order_increment_id' => $zoffio_order_id); try { $result = $proxy->mdnapiOrderupdateOrderItems($sessionId, $order_products); $result = $proxy->salesOrderAddComment($sessionId, $zoffio_order_id, $order_status); } catch (Exception $e) { Mage::log($e->getMessage(), null, 'wms-api.log'); Mage::log($e->getTraceAsString(), null, 'wms-api.log'); } } // ################################################################### return $this; }