getIncrementId()', 'order::store_id', 'order::base_grand_total', '(order::base_grand_total - order::base_tax_amount)', 'order::base_tax_amount', 'billing_address::firstname . " ". billing_address::lastname', 'str_replace("\n", " ", billing_address::street )' , 'billing_address::city', 'billing_address::postcode', 'Mage::app()->getLocale()->getCountryTranslation(billing_address::country_id)', 'billing_address::telephone', 'billing_address::email', 'shipping_address::firstname . " " . shipping_address::lastname', 'str_replace("\n", " ", shipping_address::street )', 'shipping_address::city', 'shipping_address::postcode', 'Mage::app()->getLocale()->getCountryTranslation(shipping_address::country_id)', 'order::created_at', 'order::order_currency_code', 'product::sku', 'product::name', 'order_item_parent::price', 'order_item_parent::tax_percent', 'order_item::qty_ordered', 'order::store_id', 'order::customer_id', 'payment_info::transaction_id' ); protected $_ordersExportDelimiter = ";"; protected $baseCsv = null; public function __construct() { $this->_processedFilesStorage = "./var/integration/csv_products_processed/" . date("Y-m-d_H_i_s"); $this->baseCsv = new Wexo_Integration_Model_Adapter_Base_Csv(); $this->baseCsv->_orderColumns = $this->_orderColumns; parent::__construct(); } public function mapItem ( $order, $item, $line, $is_memo = false ) { if ( $is_memo ) { $item = Mage::getModel('sales/order_item')->load($item->getOrderItemId()); } //if ( $item->getProductType() == 'simple' ) return $line; $not_allowed = array ( 'configurable', 'bundle', 'grouped' ); if ( in_array ( $item->getProductType(), $not_allowed ) ) return null; return $line; } public function convertCreditmemos ( $memo ) { try { // change this to qty for creditmemos $this->baseCsv->_orderColumns[19] = 'order_item::qty'; $tmp = $this->baseCsv->mapOrder ( $memo, true ); return $tmp; } catch ( Exception $e ) { die ( $e->getMessage() ); } } public function putCreditmemos ( $creditmemos ) { $fh = fopen ( $this->_memosExportFile, 'w' ); foreach ( $creditmemos as $line ) { fputcsv ( $fh, $line, $this->_ordersExportDelimiter ); } fclose ( $fh ); $this->baseCsv->confirmCreditmemos ( $creditmemos ); } public function confirmCreditmemos ( $creditmemos ) { $memoId = NULL; foreach ( $creditmemos as $memo ) { if ( $memo[0] ) $memoId = $memo[0]; } if ( $memoId ) $this->_adapterPublisher->confirmMemo ( $memoId ); } public function convertOrders ( $order ) { $this->_ordersExportFile = Mage::getBaseDir() . '/var/c5-integration/' . $order->getIncrementId() . ".csv"; return $this->baseCsv->mapOrder ( $order ); } public function putOrders( $orders ) { $fh = fopen ( $this->_ordersExportFile, 'a' ); foreach ( $orders as $line ) { //var_dump ( $line ); if ( !fputcsv ( $fh, $line, $this->_ordersExportDelimiter ) ) { throw new Exception("Failed to write orders to " . $this->_ordersExportFile); } } fclose ( $fh ); $this->baseCsv->confirmOrders ( $orders ); } public function confirmOrders ( $orders ) { $orderId = NULL; foreach ( $orders as $order ) { if ( $order[0] ) $orderId = $order[0]; } if ( $orderId ) $this->_adapterPublisher->confirmOrder ( $orderId ); } }