<?php $mageFilename = '/mnt/data/html/zuri/public_html/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)); var_dump($result);
<?php echo "_________________"; $proxy = new SoapClient('http://192.168.10.117/magentodemomodule/index.php/api/v2_soap/?wsdl'); $sessionId = $proxy->login('kushapitest', 'admin123'); die; $result = $proxy->customerCustomerCreate($sessionId, array('email' => '*****@*****.**', 'firstname' => 'kush', 'lastname' => 'checklasttname', 'password' => 'admin123', 'website_id' => 1, 'store_id' => 1, 'group_id' => 1)); if ($result) { echo "customer is created sucessfully"; } else { echo "not created"; } //var_dump($result->result); //(object)array('categoryId' => '4'); //array(array("name"=>""))
/** * Dummy Function for testing and code * TODO remove the function from config.xml and here * * @param Varien_Event_Observer $observer * @return Zoffio_WmsApi_Model_Observer */ public function customerSaveAfter(Varien_Event_Observer $observer) { if (self::$_observerExecutionCounter > 1) { return $this; } self::$_observerExecutionCounter++; Mage::log(__CLASS__ . "_" . __FUNCTION__, null, 'shebin.log'); // $event = $observer->getEvent(); $customer = $observer->getCustomer(); Mage::log(get_class($customer), null, 'shebin.log'); $customer_id = $customer->getId(); $zoff_domain = 'zoffio.com'; $wms_email_id = $customer_id . "@" . $zoff_domain; Mage::log($wms_email_id, null, 'shebin.log'); $complexFilter = array('complex_filter' => array(array('key' => 'email', 'value' => array('key' => 'eq', 'value' => $wms_email_id)))); // Mage::log($complexFilter, null, 'shebin.log'); // Mage::log(self::$_apiPassword, null, 'shebin.log'); // establish the connection to WMS api $proxy = new SoapClient(self::$_apiUrl); $sessionId = $proxy->login(self::$_apiUser, self::$_apiPassword); try { $customerList = $proxy->customerCustomerList($sessionId, $complexFilter); } catch (Exception $e) { Mage::log($e->getMessage(), null, 'shebin.log'); Mage::log($e->getTraceAsString(), null, 'shebin.log'); } // Mage::log($event->getData(),null,'shebin.log'); // Mage::log($customer->getData(), null, 'shebin.log'); Mage::log($customerList, null, 'shebin.log'); // If Customer doesn't exist in the WMS if (empty($customerList)) { // Add the customer $customer_details = array('email' => $wms_email_id, 'firstname' => $customer->getFirstname(), 'lastname' => $customer->getLastname(), 'website_id' => $customer->getWebsiteId(), 'store_id' => $customer->getStoreId(), 'group_id' => $customer->getGroupId()); Mage::log($customer_details, null, 'shebin.log'); try { $result = $proxy->customerCustomerCreate($sessionId, $customer_details); } catch (Exception $e) { Mage::log($e->getMessage(), null, 'shebin.log'); // Mage::getSingleton('core/session')->addWarning("Zoffio WMS // API : ".$wms_email_id." : ".$e->getMessage()); } Mage::log($result, null, 'shebin.log'); return $this; } $proxy->endSession($sessionId); // closing session return $this; // Mage::log($observer->getData(),null,'shebin.log'); // Mage::dispatchEvent('admin_session_user_login_success', // array('user'=>$user)); // $user = $observer->getEvent()->getUser(); // $user->doSomething(); }