-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathFlytcloud_Order_Submit.php
38 lines (33 loc) · 1.34 KB
/
Flytcloud_Order_Submit.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
include('app/Mage.php');
Mage::app();
$adapter = Mage::getSingleton('core/resource')->getConnection('core_write');
$helper=Mage::helper('flytcloud');
$collection = Mage::getResourceModel('flytcloud/order_shipping_status_collection')
->addFieldToFilter('shipping_status',array('eq'=>'3'))
->setPageSize(30)
->setOrder('`order`','desc')
->load();
try{
foreach($collection as $_item){
$fly_order_result = $adapter->query("select * from flytcloud_order_shipping_status where `order`=".$_item->getOrder());
$fly_order = $fly_order_result->fetch();
if($fly_order['flytcloud_order_id']||$fly_order['shipping_status']==5){
continue;
}
$where = 'id='.$_item->getId();
$adapter->update('flytcloud_order_shipping_status',array('shipping_status'=>5),$where);
$order = Mage::getModel('sales/order')->load($_item->getOrder());
if($helper->isSameAddress($order)){
Mage::log($order->getIncrementId(),null,'fly_submmit.log');
$submit = $helper->submitOrderToFlytcloud($order);
if(!$submit){
$adapter->update('flytcloud_order_shipping_status',array('shipping_status'=>3),$where);
}
}else{
$_item->setShippingStatus('4')
->save();
}
}
}catch(Extractor $e){
}