/** * Export orders data to e commerce * * @param $sOrderKey */ public function exportToECommerce($sOrderKey) { // $aOrderAdd = array(0 => "1f8de1bdcfc2d0b3f93f06b85c86654d");//462 $aOrderAdd = array(0 => $sOrderKey); $this->_oTransactions = oxNew('ectransaction'); $this->_oTransactions->TransactionBegin(); zsDb::setNewConnection(); zsDb::getDb(zsDb::FETCH_MODE_ASSOC, true); // var_dump(zsDb::getDb()->getAll("SELECT * FROM test1 where 1")); foreach ($aOrderAdd as $sOrderKey) { zsDb::setNewConnection(); zsDb::getDb(zsDb::FETCH_MODE_ASSOC); $oOrder = oxNew('oxOrder'); $oOrder->load($sOrderKey); // 451 c43b3524555912c892e70ce39090c9f7 462 1f8de1bdcfc2d0b3f93f06b85c86654d $this->_oOrderCheck = $oOrder; if ($oOrder->oxorder__zsecommerceid->value == null) { $this->_errorWriteMsg(null, "Order # " . $oOrder->oxorder__oxordernr->value . " already import to e commerce"); continue; } // Get order data about user and order payment $oPayment = oxNew('oxpayment'); $oPayment->load($oOrder->oxorder__oxpaymenttype->value); $oUser = $oOrder->getOrderUser(); // Connect to e commerce bd zsDb::setNewConnection(); zsDb::getDb(zsDb::FETCH_MODE_ASSOC, true); // If user have profile in oxid, create user in e commerce if ($oOrder->oxorder__oxuserid->value) { if (!($sCustomerId = $this->_exportCustomers($oOrder, $oUser))) { continue; } // if(!$this->_exportCustomerinfo($sCustomerId)) // continue; if (!($country_id = $this->_getCounty($oOrder))) { continue; } if (!($aUserInfo = $this->_getUserInfoOxid($oOrder))) { continue; } $this->_exportAddressBook($sCustomerId, $aUserInfo, $country_id, $oOrder); } if (!($sCommersOrderId = $this->_exportOrder($sCustomerId, $aUserInfo, $oPayment, $oOrder))) { continue; } if (!($products_update = $this->_exportOrderArticles($oOrder, $sCommersOrderId))) { continue; } /* if(!$this->_exportOrderTotal($sCommersOrderId, "Zwischensumme:", str_replace('.', ',', $oOrder->oxorder__oxtotalbrutsum->value) . ' ' . $this->getConfig()->getActShopCurrencyObject()->sign, $oOrder->oxorder__oxtotalbrutsum->value, "ot_subtotal", 1)) continue; if(!$this->_exportOrderTotal($sCommersOrderId, "<b>Summe</b>:", str_replace('.', ',', $oOrder->oxorder__oxtotalordersum->value) . ' ' . $this->getConfig()->getActShopCurrencyObject()->sign, $oOrder->oxorder__oxtotalordersum->value, "ot_total", 5)) continue; if(!$this->_exportOrderTotal($sCommersOrderId, "Verpackung & Versand:", str_replace('.', ',', $oOrder->oxorder__oxdelcost->value) . ' ' . $this->getConfig()->getActShopCurrencyObject()->sign, $oOrder->oxorder__oxdelcost->value, "ot_shipping", 3)) continue; */ if (!$this->_exportOrdersStatusHistory($sCommersOrderId)) { continue; } $oCommersProducts = oxNew('ecproduct'); $oCommersProducts->UpdateECommerce($products_update); //7570 zsDb::setNewConnection(); zsDb::getDb(zsDb::FETCH_MODE_ASSOC); $oOrder->assign(array("oxorder__zsecommerceid" => $sCommersOrderId)); $oOrder->save(); } zsDb::setNewConnection(); zsDb::getDb(zsDb::FETCH_MODE_ASSOC); }
/** * Delete from the database, returns true on success. * * @param null $sId */ public function deleteECommerce($sId = null) { if (!$sId) { return false; } zsDb::getDb()->execute("delete from {$this->_sClassName} where {$this->_sKeyName} = '{$sId}'"); return true; }