loadByIncrementId($_REQUEST['increment_id']); $order->getPayment()->capture(null); // Capturing the payment $order->setData('state', "complete"); $order->setStatus("complete"); $history = $order->addStatusHistoryComment('Order marked as complete automatically.', false); $history->setIsCustomerNotified(false); $order->save(); Mage::log ( "Successfully completed the order " . $_REQUEST['increment_id'], null, 'complete_order.log'); echo "Success"; } } catch ( Exception $e ) { Mage::log ( "Failed compeleting the order " . $_REQUEST['increment_id'] . ", exception:" . $e->getMessage(), null, 'complete_order.log'); echo "Failed. Exception: " . $e->getMessage(); } } public function putProductsXmlAction() { $baseVar = Mage::getBaseDir('var'); $directory = $baseVar . "/integration/xml/in/products/"; mkdir( $directory, 0777, true); $req = Mage::app()->getRequest(); $xml = $req->getParam('xml'); $filename = $req->getParam('filename'); if ( !$filename ) $filename = time() . ".xml"; $params = array ('default_create_values','create_attributes','update_attributes'); $values = array(); foreach ( $params as $code ) { $value = $req->getParam($code); if ( $code == 'default_create_values' && $value) { $value = parse_ini_string($value,true); } if ( $value ) $values[$code] = $value; } file_put_contents ( $directory . $filename, $xml ); file_put_contents ( $directory . $filename . ".params", json_encode($values) ); } public function getOrdersXmlAction() { $req = Mage::app()->getRequest(); $resultXml = new SimpleXMLElement(''); $converter = Mage::getModel('integration/xml_convert'); $orders = Mage::getModel('integration/xml_orders'); if ( $req->getParam('increment_id') ) { $order = Mage::getModel('sales/order')->load( $req->getParam('increment_id'), 'increment_id'); $resultElem = $orders->parseOrder ( $order ); $converter->addNode ( $resultElem, $resultXml ); } if ( $req->getParam('increment_ids') ) { $ids = explode(",",$req->getParam('increment_ids')); foreach ( $ids as $order_id ) { $order = Mage::getModel('sales/order')->load( $order_id, 'increment_id'); $resultElem = Mage::getModel('integration/xml_orders')->parseOrder ( $order ); $converter->addNode ( $resultElem, $resultXml ); } } if ( $req->getParam('last_days') ) { $days = (int)$req->getParam('last_days'); $orders = Mage::getModel('sales/order') ->getCollection() ->addFieldToFilter('created_at', array('from' => new Zend_Db_Expr("DATE_ADD(CURRENT_DATE(), INTERVAL -$days DAY ) ") )); foreach ( $orders as $order ) { $resultElem = Mage::getModel('integration/xml_orders')->parseOrder ( $order ); $converter->addNode ( $resultElem, $resultXml ); } } $this->getResponse() ->clearHeaders() ->setHeader('Content-Type', 'text/xml') ->setBody( $resultXml->asXml() ); } /** * test action * @return void */ public function stockImportAction() { $helper = new Wexo_Integration_Helper_Data(); $helper->syncStockData(); die('test'); } }