Version Notes
Merchant must currently have an existing Comr.se account.
- Add's 1.9.x support.
Download this release
Release Info
Developer | Nate Rogers |
Extension | Comrse_ComrseSync |
Version | 1.1.6 |
Comparing to | |
See all releases |
Code changes from version 1.1.5.3 to 1.1.6
- app/code/community/Comrse/ComrseSync/Helper/Apiuser.php +38 -33
- app/code/community/Comrse/ComrseSync/Helper/Customer.php +117 -0
- app/code/community/Comrse/ComrseSync/Helper/Data.php +35 -30
- app/code/community/Comrse/ComrseSync/Helper/Order.php +174 -147
- app/code/community/Comrse/ComrseSync/Helper/Product.php +112 -65
- app/code/community/Comrse/ComrseSync/Model/Carrier/Comrseship.php +5 -7
- app/code/community/Comrse/ComrseSync/Model/Comrse/Customer.php +41 -3
- app/code/community/Comrse/ComrseSync/Model/Comrse/ProductCategory.php +3 -3
- app/code/community/Comrse/ComrseSync/Model/Config.php +2 -1
- app/code/community/Comrse/ComrseSync/Model/Datasync.php +6 -5
- app/code/community/Comrse/ComrseSync/Model/Sales/Quote/Address.php +25 -28
- app/code/community/Comrse/ComrseSync/controllers/Adminhtml/ComrsesyncbackendController.php +36 -24
- app/code/community/Comrse/ComrseSync/controllers/ComrsesyncbackendController.php +0 -111
- app/code/community/Comrse/ComrseSync/etc/config.xml +1 -1
- app/code/community/Comrse/ComrseSync/sql/comrsesync_setup/mysql4-install-1.1.6.php +29 -0
- app/code/community/Comrse/ComrseSync/sql/comrsesync_setup/mysql4-upgrade-1.1.3-1.1.6.php +15 -0
- app/code/community/Comrse/ComrseSync/sql/comrsesync_setup/mysql4-upgrade-1.1.4-1.1.6.php +15 -0
- app/code/community/Comrse/ComrseSync/sql/comrsesync_setup/mysql4-upgrade-1.1.5-1.1.6.php +12 -0
- app/code/community/Comrse/ComrseSync/sql/comrsesync_setup/mysql4-upgrade-1.1.6.0-1.1.6.php +12 -0
- app/design/adminhtml/default/default/template/comrsesync/comrsesyncbackend.phtml +340 -312
- package.xml +10 -8
app/code/community/Comrse/ComrseSync/Helper/Apiuser.php
CHANGED
@@ -7,49 +7,54 @@ class Comrse_ComrseSync_Helper_Apiuser extends Mage_Core_Helper_Abstract {
|
|
7 |
error_reporting(0);
|
8 |
ini_set('display_errors',0);
|
9 |
|
|
|
|
|
|
|
10 |
// Create API user if not exists
|
11 |
$api_users = Mage::getModel('api/user')->getCollection();
|
12 |
$comrse_exists = false;
|
13 |
foreach ($api_users as $api_user)
|
14 |
{
|
15 |
$user = $api_user->getData();
|
16 |
-
|
17 |
if ($user['username'] == 'comrse')
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
20 |
}
|
21 |
-
if (!$comrse_exists)
|
22 |
-
{
|
23 |
-
$role = Mage::getModel('api/roles')
|
24 |
-
->setName('comrse')
|
25 |
-
->setPid(false)
|
26 |
-
->setRoleType('G')
|
27 |
-
->save();
|
28 |
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
33 |
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
->
|
52 |
-
|
|
|
|
|
|
|
|
|
53 |
return true;
|
54 |
}
|
55 |
catch (Exception $e)
|
7 |
error_reporting(0);
|
8 |
ini_set('display_errors',0);
|
9 |
|
10 |
+
if (!$apiPassword || empty($apiPassword))
|
11 |
+
return false;
|
12 |
+
|
13 |
// Create API user if not exists
|
14 |
$api_users = Mage::getModel('api/user')->getCollection();
|
15 |
$comrse_exists = false;
|
16 |
foreach ($api_users as $api_user)
|
17 |
{
|
18 |
$user = $api_user->getData();
|
|
|
19 |
if ($user['username'] == 'comrse')
|
20 |
+
{
|
21 |
+
$soapUser = Mage::getModel('api/user');
|
22 |
+
$soapUser->load($user['user_id']);
|
23 |
+
$soapUser->__set('api_key', $apiPassword);
|
24 |
+
$soapUser->save();
|
25 |
+
return true;
|
26 |
+
}
|
27 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
+
$role = Mage::getModel('api/roles')
|
30 |
+
->setName('comrse')
|
31 |
+
->setPid(false)
|
32 |
+
->setRoleType('G')
|
33 |
+
->save();
|
34 |
|
35 |
+
Mage::getModel("api/rules")
|
36 |
+
->setRoleId($role->getId())
|
37 |
+
->setResources(array('all'))
|
38 |
+
->saveRel();
|
39 |
+
|
40 |
+
$user = Mage::getModel('api/user');
|
41 |
+
$user->setData(array(
|
42 |
+
'username' => 'comrse',
|
43 |
+
'firstname' => 'Comrse',
|
44 |
+
'lastname' => 'Admin',
|
45 |
+
'email' => 'info@comr.se',
|
46 |
+
'api_key' => $apiPassword,
|
47 |
+
'api_key_confirmation' => $apiPassword,
|
48 |
+
'is_active' => 1,
|
49 |
+
'user_roles' => '',
|
50 |
+
'assigned_user_role' => '',
|
51 |
+
'role_name' => '',
|
52 |
+
'roles' => array($role->getId())
|
53 |
+
));
|
54 |
+
$user->save()->load($user->getId());
|
55 |
+
$user->setRoleIds(array($role->getId()))
|
56 |
+
->setRoleUserId($user->getUserId())
|
57 |
+
->saveRelations();
|
58 |
return true;
|
59 |
}
|
60 |
catch (Exception $e)
|
app/code/community/Comrse/ComrseSync/Helper/Customer.php
ADDED
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Comrse_ComrseSync_Helper_Customer extends Mage_Core_Helper_Abstract {
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Normalize Customer Data
|
6 |
+
* Maps mixed Magento Customer data to Comrse Customer Object
|
7 |
+
* @access public
|
8 |
+
* @return Array normalizedCustomer
|
9 |
+
* @param Object mageCustomer
|
10 |
+
*/
|
11 |
+
public function normalizeCustomerData($mageCustomer, $orgId)
|
12 |
+
{
|
13 |
+
try
|
14 |
+
{
|
15 |
+
$commerceCustomer = Mage::getModel('comrsesync/Comrse_Customer');
|
16 |
+
$commerceCustomer
|
17 |
+
->setFirstName($mageCustomer['firstname'])
|
18 |
+
->setLastName($mageCustomer['lastname'])
|
19 |
+
->setEmailAddress($mageCustomer['email'])
|
20 |
+
->setExternalId($mageCustomer['entity_id'])
|
21 |
+
->setOrgId($orgId);
|
22 |
+
return $commerceCustomer->toArray();
|
23 |
+
}
|
24 |
+
catch (Exception $e)
|
25 |
+
{
|
26 |
+
Mage::log("Comrse Customer Data Normalization Error: {$e->getMessage()}");
|
27 |
+
}
|
28 |
+
}
|
29 |
+
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Sync Orders
|
33 |
+
* @access public
|
34 |
+
*/
|
35 |
+
public function syncCustomers()
|
36 |
+
{
|
37 |
+
try
|
38 |
+
{
|
39 |
+
//------------------------------------------------------------
|
40 |
+
// Retreive and Handle Org Data
|
41 |
+
//------------------------------------------------------------
|
42 |
+
$orgData = Mage::getModel('comrsesync/comrseconnect')->load(Comrse_ComrseSync_Model_Config::COMRSE_RECORD_ROW_ID);
|
43 |
+
$lastCustomersSynced = json_decode($orgData->getLastCustomersSynced(), true);
|
44 |
+
|
45 |
+
$stores = Mage::app()->getStores();
|
46 |
+
|
47 |
+
if (!is_array($stores))
|
48 |
+
$stores = array("stores" => false);
|
49 |
+
|
50 |
+
foreach ($stores as $store)
|
51 |
+
{
|
52 |
+
if (isset($stores[0]['stores']) && $stores[0]['stores'] === false)
|
53 |
+
{
|
54 |
+
$storeDisabled = $multiStore = false;
|
55 |
+
$storeId = 0;
|
56 |
+
}
|
57 |
+
else
|
58 |
+
{
|
59 |
+
$storeId = $store->getId();
|
60 |
+
$multiStore = true;
|
61 |
+
}
|
62 |
+
$lastCustomersOfStoreSynced = (isset($lastCustomersSynced[$storeId])) ? $lastCustomersSynced[$storeId] : 0;
|
63 |
+
|
64 |
+
// check if plugin is disabled on store
|
65 |
+
$storeDisabled = Mage::getStoreConfig('advanced/modules_disable_output/Comrse_ComrseSync', $storeId);
|
66 |
+
if (!$storeDisabled)
|
67 |
+
{
|
68 |
+
|
69 |
+
$customerCount = ($multiStore) ? Mage::getModel('customer/customer')->getCollection()->addFieldToFilter("store_id", array('eq' => $storeId))->addAttributeToFilter('entity_id', array('gt' => $lastCustomersOfStoreSynced))->getSize() : Mage::getModel('customer/customer')->getCollection()->getSize();
|
70 |
+
|
71 |
+
// paginate and loop
|
72 |
+
$batchMath = ceil($customerCount / Comrse_ComrseSync_Model_Config::CUSTOMER_SYNC_BATCH_SIZE) + 1;
|
73 |
+
for ($i = 1; $i <= $batchMath; $i++)
|
74 |
+
{
|
75 |
+
$maxCustomerId = 0;
|
76 |
+
$customersPayload = array();
|
77 |
+
|
78 |
+
if ($multiStore)
|
79 |
+
$mageCustomers = Mage::getModel('customer/customer')->getCollection()->setPageSize(Comrse_ComrseSync_Model_Config::ORDER_SYNC_BATCH_SIZE)->setCurPage($i)->addFieldToFilter("store_id", array('eq' => $storeId))->addAttributeToFilter('entity_id', array('gt' => $lastCustomersOfStoreSynced))->addAttributeToSelect('firstname')->addAttributeToSelect('lastname')->addAttributeToSelect('email');
|
80 |
+
else
|
81 |
+
$mageCustomers = Mage::getModel('customer/customer')->getCollection()->setPageSize(Comrse_ComrseSync_Model_Config::ORDER_SYNC_BATCH_SIZE)->setCurPage($i)->addAttributeToFilter('entity_id', array('gt' => $lastCustomersOfStoreSynced))->addAttributeToSelect('firstname')->addAttributeToSelect('lastname')->addAttributeToSelect('email');
|
82 |
+
|
83 |
+
if ($mageCustomers)
|
84 |
+
{
|
85 |
+
foreach ($mageCustomers as $mageCustomer)
|
86 |
+
{
|
87 |
+
$customersPayload[] = $this->normalizeCustomerData($mageCustomer, $orgData->getOrg());
|
88 |
+
if ($mageCustomer['entity_id'] > $maxCustomerId)
|
89 |
+
$maxCustomerId = $mageCustomer['entity_id'];
|
90 |
+
}
|
91 |
+
}
|
92 |
+
|
93 |
+
if (!empty($customersPayload))
|
94 |
+
{
|
95 |
+
// submit customers to Commerce
|
96 |
+
$postCustomers = Mage::helper('comrsesync')->comrseRequest("POST", Comrse_ComrseSync_Model_Config::API_PATH . "organizations/" . $orgData->getOrg() . "/customers?metrics_only=false", $orgData, json_encode(array("customers" => $customersPayload)));
|
97 |
+
$lastCustomersSynced[$storeId] = $maxCustomerId;
|
98 |
+
if (isset($postCustomers->message))
|
99 |
+
{
|
100 |
+
Mage::log("COMMERCE CUSTOMER SYNC ERROR: " . json_encode($postCustomers));
|
101 |
+
return false;
|
102 |
+
}
|
103 |
+
}
|
104 |
+
}
|
105 |
+
}
|
106 |
+
}
|
107 |
+
//------------------------------------------------------------
|
108 |
+
// Record Last Synced Product ID
|
109 |
+
//------------------------------------------------------------
|
110 |
+
$saveLastSynced = @$orgData->setLastCustomersSynced(json_encode($lastCustomersSynced))->save();
|
111 |
+
}
|
112 |
+
catch (Exception $e)
|
113 |
+
{
|
114 |
+
Mage::log("Comrse Customer Sync Error: {$e->getMessage()}");
|
115 |
+
}
|
116 |
+
}
|
117 |
+
}
|
app/code/community/Comrse/ComrseSync/Helper/Data.php
CHANGED
@@ -3,41 +3,46 @@ class Comrse_ComrseSync_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
3 |
|
4 |
// comrse request
|
5 |
public function comrseRequest($method, $targetUrl, $orgData, $postData = NULL, $contentType = NULL, $time = NULL, $debug = 0) {
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
$contentType
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
18 |
|
19 |
-
|
20 |
|
21 |
-
|
|
|
|
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
|
|
|
|
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
curl_setopt($ch,
|
30 |
-
|
31 |
-
curl_setopt($ch,CURLOPT_CUSTOMREQUEST, $method);
|
32 |
-
|
33 |
-
curl_setopt($ch,CURLOPT_HTTPHEADER, $headerArray);
|
34 |
-
curl_setopt($ch,CURLOPT_HEADER, $debug);
|
35 |
-
curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
|
36 |
-
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, FALSE);
|
37 |
|
38 |
-
|
39 |
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
}
|
42 |
|
43 |
|
@@ -57,7 +62,7 @@ class Comrse_ComrseSync_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
57 |
return $result;
|
58 |
}
|
59 |
catch (Exception $e) {
|
60 |
-
Mage::log("Comrse Basic HTTP Request: ".$e->getMessage());
|
61 |
return false;
|
62 |
}
|
63 |
}
|
3 |
|
4 |
// comrse request
|
5 |
public function comrseRequest($method, $targetUrl, $orgData, $postData = NULL, $contentType = NULL, $time = NULL, $debug = 0) {
|
6 |
+
try
|
7 |
+
{
|
8 |
+
// if content type not passed
|
9 |
+
if (is_null($contentType))
|
10 |
+
$contentType = "application/json";
|
11 |
+
|
12 |
+
// prepare header
|
13 |
+
$headerArray = array(
|
14 |
+
"Content-Type: " . $contentType,
|
15 |
+
"X-Comrse-Token: " . $orgData->getToken(),
|
16 |
+
"X-Comrse-Version: " . Comrse_ComrseSync_Model_Config::COMRSE_API_VERSION,
|
17 |
+
"Connection: close"
|
18 |
+
);
|
19 |
|
20 |
+
$ch = curl_init($targetUrl);
|
21 |
|
22 |
+
// if POST Data is present
|
23 |
+
if (!is_null($postData))
|
24 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
|
25 |
|
26 |
+
// method
|
27 |
+
if ($method == "POST")
|
28 |
+
curl_setopt($ch, CURLOPT_POST, true);
|
29 |
+
else
|
30 |
+
curl_setopt($ch,CURLOPT_CUSTOMREQUEST, $method);
|
31 |
|
32 |
+
curl_setopt($ch,CURLOPT_HTTPHEADER, $headerArray);
|
33 |
+
curl_setopt($ch,CURLOPT_HEADER, $debug);
|
34 |
+
curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
|
35 |
+
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, FALSE);
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
+
$result = curl_exec($ch);
|
38 |
|
39 |
+
return $result;
|
40 |
+
}
|
41 |
+
catch (Exception $e)
|
42 |
+
{
|
43 |
+
Mage::log("Comrse Service Request Error: {$e->getMessage()}");
|
44 |
+
return false;
|
45 |
+
}
|
46 |
}
|
47 |
|
48 |
|
62 |
return $result;
|
63 |
}
|
64 |
catch (Exception $e) {
|
65 |
+
Mage::log("Comrse Basic HTTP Request Error: ".$e->getMessage());
|
66 |
return false;
|
67 |
}
|
68 |
}
|
app/code/community/Comrse/ComrseSync/Helper/Order.php
CHANGED
@@ -13,126 +13,132 @@ class Comrse_ComrseSync_Helper_Order extends Mage_Core_Helper_Abstract {
|
|
13 |
*/
|
14 |
public function normalizeOrderData($mageOrder, $sendMetrics = false, $orderStatus = "IN_PROCESS")
|
15 |
{
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
|
|
37 |
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
|
92 |
-
|
93 |
-
{
|
94 |
-
$mageProduct = $mageOrderItem->getData();
|
95 |
-
if (empty($mageProduct['parent_item_id']))
|
96 |
{
|
97 |
-
$
|
98 |
-
$
|
99 |
-
->setExternalId($mageProduct['product_id'])
|
100 |
-
->setProductId($mageProduct['product_id'])
|
101 |
-
->setName($mageProduct['name'])
|
102 |
-
->setQuantity($mageProduct['qty_ordered'])
|
103 |
-
->setRetailPrice($mageProduct['original_price'])
|
104 |
-
->setSalePrice($mageProduct['price']);
|
105 |
-
|
106 |
-
$mageProductOptions = $mageOrderItem->getProductOptions();
|
107 |
-
$mageProductOptionsList = $mageProductOptions['attributes_info'];
|
108 |
-
|
109 |
-
if (is_array($mageProductOptionsList))
|
110 |
{
|
111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
{
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
|
|
|
|
|
|
118 |
}
|
119 |
-
|
120 |
-
$comrseOrder->addOrderItem($comrseOrderItem->toArray());
|
121 |
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
|
|
132 |
}
|
133 |
}
|
|
|
|
|
|
|
|
|
|
|
134 |
}
|
135 |
-
return $comrseOrder->toArray();
|
136 |
}
|
137 |
|
138 |
|
@@ -143,59 +149,80 @@ class Comrse_ComrseSync_Helper_Order extends Mage_Core_Helper_Abstract {
|
|
143 |
*/
|
144 |
public function syncOrders()
|
145 |
{
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
$stores = Mage::app()->getStores();
|
153 |
|
154 |
-
|
155 |
-
$stores = array("stores" => false);
|
156 |
|
157 |
-
|
158 |
-
|
159 |
-
if (isset($stores[0]['stores']) && $stores[0]['stores'] === false)
|
160 |
-
{
|
161 |
-
$storeDisabled = $multiStore = false;
|
162 |
-
$storeId = 0;
|
163 |
-
}
|
164 |
-
else
|
165 |
-
{
|
166 |
-
$storeId = $store->getId();
|
167 |
-
$multiStore = true;
|
168 |
-
}
|
169 |
|
170 |
-
|
171 |
-
$storeDisabled = Mage::getStoreConfig('advanced/modules_disable_output/Comrse_ComrseSync', $storeId);
|
172 |
-
if (!$storeDisabled)
|
173 |
{
|
174 |
-
if ($
|
175 |
-
|
176 |
-
|
177 |
-
$
|
178 |
-
|
179 |
-
|
180 |
-
|
|
|
|
|
|
|
181 |
|
182 |
-
|
|
|
|
|
183 |
{
|
184 |
if ($multiStore)
|
185 |
-
$
|
186 |
else
|
187 |
-
$
|
188 |
|
189 |
-
|
190 |
-
|
191 |
|
192 |
-
$
|
193 |
-
|
194 |
-
|
195 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
}
|
|
|
197 |
}
|
198 |
}
|
199 |
}
|
|
|
|
|
|
|
|
|
200 |
}
|
|
|
201 |
}
|
13 |
*/
|
14 |
public function normalizeOrderData($mageOrder, $sendMetrics = false, $orderStatus = "IN_PROCESS")
|
15 |
{
|
16 |
+
try {
|
17 |
+
//------------------------------------------------------------
|
18 |
+
// Setup Data Objects
|
19 |
+
//------------------------------------------------------------
|
20 |
+
$orgData = Mage::getModel('comrsesync/comrseconnect')->load(Comrse_ComrseSync_Model_Config::COMRSE_RECORD_ROW_ID);
|
21 |
+
$mageOrderData = $mageOrder->getData();
|
22 |
+
$comrseOrder = Mage::getModel('comrsesync/Comrse_Order');
|
23 |
+
$comrseCustomer = Mage::getModel('comrsesync/Comrse_Customer');
|
24 |
+
|
25 |
+
//------------------------------------------------------------
|
26 |
+
// If Passing Metric Event
|
27 |
+
//------------------------------------------------------------
|
28 |
+
if ($sendMetrics)
|
29 |
+
{
|
30 |
+
$metricEvent = Mage::getModel('comrsesync/Comrse_MetricEvent');
|
31 |
+
$metricEvent
|
32 |
+
->setBrandId($orgData->getOrg())
|
33 |
+
->setEmail($mageOrderData['customer_email'])
|
34 |
+
->setIpAddress($mageOrderData['x_forwarded_for'])
|
35 |
+
->setActivityTimestamp(strtotime($mageOrderData['created_at']) * 1000)
|
36 |
+
->setActivityGroupId($mageOrderData['increment_id']);
|
37 |
+
}
|
38 |
|
39 |
+
$comrseOrder
|
40 |
+
->setSubmitDate($mageOrderData['created_at'])
|
41 |
+
->setExternalId($mageOrderData['entity_id'])
|
42 |
+
->setIpAddress($mageOrderData['x_forwarded_for'])
|
43 |
+
->setStatus($orderStatus);
|
44 |
+
|
45 |
+
//------------------------------------------------------------
|
46 |
+
// Set Pricing
|
47 |
+
//------------------------------------------------------------
|
48 |
+
$comrseOrder
|
49 |
+
->setTotal($mageOrderData['grand_total'])
|
50 |
+
->setSubTotal($mageOrderData['subtotal'])
|
51 |
+
->setTotalShipping($mageOrderData['shipping_amount'])
|
52 |
+
->setTotalTax($mageOrderData['tax_amount']);
|
53 |
+
|
54 |
+
//------------------------------------------------------------
|
55 |
+
// Set Customer & Billing Address Details
|
56 |
+
//------------------------------------------------------------
|
57 |
+
$comrseCustomer->setEmailAddress($mageOrderData['customer_email']);
|
58 |
+
if ($mageOrder->getBillingAddress())
|
59 |
+
{
|
60 |
+
$billingAddress = $mageOrder->getBillingAddress()->getData();
|
61 |
|
62 |
+
// create customer
|
63 |
+
$comrseCustomer
|
64 |
+
->setFirstName($billingAddress['firstname'])
|
65 |
+
->setLastName($billingAddress['lastname']);
|
66 |
|
67 |
+
// if metrics
|
68 |
+
if ($sendMetrics)
|
69 |
+
$metricEvent->setCustomerName($billingAddress['firstname'] . " " . $billingAddress['lastname']);
|
70 |
+
|
71 |
+
// create customer address
|
72 |
+
$regionData = Mage::getModel('directory/region')->load($billingAddress['region_id'])->getOrigData();
|
73 |
+
$customerAddress = Mage::getModel('comrsesync/Comrse_CustomerAddress');
|
74 |
+
$customerAddress
|
75 |
+
->setFirstName($billingAddress['firstname'])
|
76 |
+
->setLastName($billingAddress['lastname'])
|
77 |
+
->setAddressLine1($billingAddress['street'])
|
78 |
+
->setCity($billingAddress['city'])
|
79 |
+
->setPostalCode($billingAddress['postcode'])
|
80 |
+
->setCountry($regionData['country_id'])
|
81 |
+
->setState($regionData['code'], $regionData['name'])
|
82 |
+
->setPhonePrimary($billingAddress['telephone'])
|
83 |
+
->setAddressType("billing");
|
84 |
+
$comrseOrder->addAddress($customerAddress->toArray());
|
85 |
+
}
|
86 |
+
$comrseOrder->setCustomer($comrseCustomer->toArray());
|
87 |
|
88 |
+
//------------------------------------------------------------
|
89 |
+
// Handle Order Items
|
90 |
+
//------------------------------------------------------------
|
91 |
+
$mageOrderItems = $mageOrder->getAllItems();
|
92 |
|
93 |
+
foreach ($mageOrderItems as $mageOrderItem)
|
|
|
|
|
|
|
94 |
{
|
95 |
+
$mageProduct = $mageOrderItem->getData();
|
96 |
+
if (empty($mageProduct['parent_item_id']))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
{
|
98 |
+
$comrseOrderItem = Mage::getModel('comrsesync/Comrse_OrderItem');
|
99 |
+
$comrseOrderItem
|
100 |
+
->setExternalId($mageProduct['product_id'])
|
101 |
+
->setProductId($mageProduct['product_id'])
|
102 |
+
->setName($mageProduct['name'])
|
103 |
+
->setQuantity($mageProduct['qty_ordered'])
|
104 |
+
->setRetailPrice($mageProduct['original_price'])
|
105 |
+
->setSalePrice($mageProduct['price']);
|
106 |
+
|
107 |
+
$mageProductOptions = $mageOrderItem->getProductOptions();
|
108 |
+
$mageProductOptionsList = $mageProductOptions['attributes_info'];
|
109 |
+
|
110 |
+
if (is_array($mageProductOptionsList))
|
111 |
{
|
112 |
+
foreach ($mageProductOptionsList as $mageProductOption)
|
113 |
+
{
|
114 |
+
$comrseOrderItem->addOrderItemAttribute($mageProductOption);
|
115 |
+
|
116 |
+
// if metrics
|
117 |
+
if ($sendMetrics)
|
118 |
+
$metricEvent->addProductOption($mageProductOption);
|
119 |
+
}
|
120 |
}
|
121 |
+
$comrseOrder->addOrderItem($comrseOrderItem->toArray());
|
|
|
122 |
|
123 |
+
// if metrics
|
124 |
+
if ($sendMetrics)
|
125 |
+
{
|
126 |
+
$metricEvent
|
127 |
+
->setExternalProductId($mageProduct['product_id'])
|
128 |
+
->setProductPrice($mageProduct['original_price'])
|
129 |
+
->setProductSalePrice($mageProduct['price'])
|
130 |
+
->setProductQuantity($mageProduct['qty_ordered'])
|
131 |
+
->setProductName($mageProduct['name'])
|
132 |
+
->send($orgData);
|
133 |
+
}
|
134 |
}
|
135 |
}
|
136 |
+
return $comrseOrder->toArray();
|
137 |
+
}
|
138 |
+
catch (Exception $e)
|
139 |
+
{
|
140 |
+
Mage::log("Comrse Order Sync Data Normalization Error: {$e->getMessage()}");
|
141 |
}
|
|
|
142 |
}
|
143 |
|
144 |
|
149 |
*/
|
150 |
public function syncOrders()
|
151 |
{
|
152 |
+
try {
|
153 |
+
//------------------------------------------------------------
|
154 |
+
// Retreive and Handle Org Data
|
155 |
+
//------------------------------------------------------------
|
156 |
+
$orgData = Mage::getModel('comrsesync/comrseconnect')->load(Comrse_ComrseSync_Model_Config::COMRSE_RECORD_ROW_ID);
|
157 |
+
$lastSynced = $orgData->getLastOrderSynced();
|
|
|
158 |
|
159 |
+
$stores = Mage::app()->getStores();
|
|
|
160 |
|
161 |
+
if (!is_array($stores))
|
162 |
+
$stores = array("stores" => false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
|
164 |
+
foreach ($stores as $store)
|
|
|
|
|
165 |
{
|
166 |
+
if (isset($stores[0]['stores']) && $stores[0]['stores'] === false)
|
167 |
+
{
|
168 |
+
$storeDisabled = $multiStore = false;
|
169 |
+
$storeId = 0;
|
170 |
+
}
|
171 |
+
else
|
172 |
+
{
|
173 |
+
$storeId = $store->getId();
|
174 |
+
$multiStore = true;
|
175 |
+
}
|
176 |
|
177 |
+
// check if plugin is disabled on store
|
178 |
+
$storeDisabled = Mage::getStoreConfig('advanced/modules_disable_output/Comrse_ComrseSync', $storeId);
|
179 |
+
if (!$storeDisabled)
|
180 |
{
|
181 |
if ($multiStore)
|
182 |
+
$orderCount = Mage::getModel('sales/order')->getCollection()->addFieldToFilter("store_id", array('eq' => $storeId))->getSize();
|
183 |
else
|
184 |
+
$orderCount = Mage::getModel('sales/order')->getCollection()->getSize();
|
185 |
|
186 |
+
// paginate and loop
|
187 |
+
$batchMath = ceil($orderCount / Comrse_ComrseSync_Model_Config::ORDER_SYNC_BATCH_SIZE);
|
188 |
|
189 |
+
for ($i = 1; $i <= $batchMath; $i++)
|
190 |
+
{
|
191 |
+
$ordersPayload = array();
|
192 |
+
if ($multiStore)
|
193 |
+
$mageOrders = Mage::getModel('sales/order')->getCollection()->setPageSize(Comrse_ComrseSync_Model_Config::ORDER_SYNC_BATCH_SIZE)->setCurPage($i)->addFieldToFilter("store_id", array('eq' => $storeId));
|
194 |
+
else
|
195 |
+
$mageOrders = Mage::getModel('sales/order')->getCollection()->setPageSize(Comrse_ComrseSync_Model_Config::ORDER_SYNC_BATCH_SIZE)->setCurPage($i);
|
196 |
+
|
197 |
+
foreach ($mageOrders as $mageOrder)
|
198 |
+
$ordersPayload[] = $this->normalizeOrderData($mageOrder, false);
|
199 |
+
|
200 |
+
|
201 |
+
$postOrders = json_decode(Mage::helper('comrsesync')->comrseRequest("POST", Comrse_ComrseSync_Model_Config::API_PATH . "organizations/" . $orgData->getOrg() . "/orders?metrics_only=false", $orgData, json_encode(array("orders" => $ordersPayload))));
|
202 |
+
|
203 |
+
if (isset($postOrders->message)){
|
204 |
+
Mage::log("ORDER SYNC ERROR: " . json_encode($postOrders));
|
205 |
+
return false;
|
206 |
+
}
|
207 |
+
|
208 |
+
else
|
209 |
+
{
|
210 |
+
//------------------------------------------------------------
|
211 |
+
// Record Last Synced Order ID
|
212 |
+
//------------------------------------------------------------
|
213 |
+
$lastOrderSynced = @$ordersPayload[max(array_keys($ordersPayload))]["external_id"];
|
214 |
+
$saveLastSyncedOrder = @$orgData->setLastOrderSynced($lastOrderSynced)->save();
|
215 |
+
$saveLastSyncedOrders = @$orgData->setLastOrdersSynced(json_encode(array($storeId => $lastOrderSynced)))->save();
|
216 |
+
}
|
217 |
}
|
218 |
+
$setSynced = $orgData->setSynced(1)->save();
|
219 |
}
|
220 |
}
|
221 |
}
|
222 |
+
catch (Exception $e)
|
223 |
+
{
|
224 |
+
Mage::log("Comrse Order Sync Error: {$e->getMessage()}");
|
225 |
+
}
|
226 |
}
|
227 |
+
|
228 |
}
|
app/code/community/Comrse/ComrseSync/Helper/Product.php
CHANGED
@@ -34,35 +34,52 @@ class Comrse_ComrseSync_Helper_Product extends Mage_Core_Helper_Abstract {
|
|
34 |
* @return array $subCategories
|
35 |
*/
|
36 |
private function mapCategories($categories) {
|
37 |
-
|
38 |
{
|
39 |
-
$
|
40 |
-
|
|
|
|
|
|
|
41 |
{
|
42 |
-
$
|
43 |
-
$
|
44 |
-
$comrseCategory
|
45 |
-
->setExternalId($_cat->getId())
|
46 |
-
->setName($_cat->getName())
|
47 |
-
->setDescription($_cat->getDescription())
|
48 |
-
->setUrl($_cat->getUrlPath())
|
49 |
-
->setUrlKey($_cat->getUrlKey())
|
50 |
-
->setActiveStartDate(date("Y-m-d\TH:i:sO", strtotime($_cat->getCreatedAt())))
|
51 |
-
->setActiveEndDate(date("Y-m-d\TH:i:sO", strtotime("+ 10 years", time())));
|
52 |
-
|
53 |
-
if (isset($this->categorizedProductIds[$_cat->getId()]) && !empty($this->categorizedProductIds[$_cat->getId()]))
|
54 |
-
foreach ($this->categorizedProductIds[$_cat->getId()] as $categorizedProductId)
|
55 |
-
$comrseCategory->addProduct($categorizedProductId);
|
56 |
-
|
57 |
-
if ((int)$_cat->getChildrenCount() > 0)
|
58 |
{
|
59 |
-
|
60 |
-
$
|
61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
}
|
63 |
-
$subCategories
|
64 |
}
|
65 |
-
|
|
|
|
|
66 |
}
|
67 |
}
|
68 |
|
@@ -79,25 +96,48 @@ class Comrse_ComrseSync_Helper_Product extends Mage_Core_Helper_Abstract {
|
|
79 |
error_reporting(0);
|
80 |
try
|
81 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
if ($pid = $product->getId())
|
83 |
{
|
84 |
if (!in_array($pid, $this->syncedProductIds))
|
85 |
{
|
86 |
$_item = $this->productModel->load($pid); // load extended product data
|
|
|
87 |
$productOptions = array();
|
88 |
$attrCodes = array();
|
89 |
$productVisibility = $_item->getVisibility();
|
90 |
$productType = $_item->getTypeID();
|
91 |
$productWeight = ($_item->getWeight() > 0) ? $_item->getWeight() : 0.5;
|
92 |
|
93 |
-
|
|
|
|
|
94 |
if (!empty($categories))
|
95 |
{
|
96 |
-
foreach ($categories as $
|
97 |
{
|
98 |
-
$
|
99 |
-
|
100 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
}
|
102 |
}
|
103 |
|
@@ -406,7 +446,7 @@ class Comrse_ComrseSync_Helper_Product extends Mage_Core_Helper_Abstract {
|
|
406 |
return Mage::getModel('comrsesync/Comrse_Product')
|
407 |
->setId(null)
|
408 |
->setExternalId((string)$pid)
|
409 |
-
->setName($
|
410 |
->setLongDescription(trim(str_replace(array("\r\n", "\r", "<br />", "<br>"), "", $description)))
|
411 |
->setDimension(Mage::getModel('comrsesync/Comrse_Dimension')->toArray())
|
412 |
->setWeight(
|
@@ -440,7 +480,7 @@ class Comrse_ComrseSync_Helper_Product extends Mage_Core_Helper_Abstract {
|
|
440 |
}
|
441 |
}
|
442 |
catch (Exception $e){
|
443 |
-
|
444 |
}
|
445 |
}
|
446 |
|
@@ -475,6 +515,7 @@ class Comrse_ComrseSync_Helper_Product extends Mage_Core_Helper_Abstract {
|
|
475 |
{
|
476 |
foreach ($stores as $store)
|
477 |
{
|
|
|
478 |
$storeId = $store->getId();
|
479 |
|
480 |
$storeDisabled = Mage::getStoreConfig('advanced/modules_disable_output/Comrse_ComrseSync', $storeId); // check if plugin is disabled on store
|
@@ -484,39 +525,44 @@ class Comrse_ComrseSync_Helper_Product extends Mage_Core_Helper_Abstract {
|
|
484 |
{
|
485 |
foreach ($this->productTypes as $productType)
|
486 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
487 |
if ($multi_store)
|
488 |
-
$productCount = $this->productModel->getCollection()->addStoreFilter($
|
489 |
else
|
490 |
-
$productCount = $this->productModel->getCollection()->addAttributeToFilter('type_id', $productType)->count(); // configurable products collection count
|
491 |
|
|
|
492 |
$batchMath = ceil($productCount / Comrse_ComrseSync_Model_Config::PRODUCT_SYNC_BATCH_SIZE);
|
493 |
|
|
|
494 |
// iterate product batch
|
495 |
for ($i = 1; $i <= $batchMath; $i++)
|
496 |
{
|
497 |
if ($multiStore)
|
498 |
-
$mageProducts = $this->productModel->getCollection()->addStoreFilter($
|
499 |
else
|
500 |
-
$mageProducts = $this->productModel->getCollection()->addAttributeToFilter('type_id', $productType)->setPageSize(Comrse_ComrseSync_Model_Config::PRODUCT_SYNC_BATCH_SIZE)->setCurPage($i);
|
501 |
|
502 |
$productPayload = array();
|
503 |
|
504 |
-
switch ($productType)
|
505 |
-
{
|
506 |
-
case "downloadable" : $pidColumn = "dl_pid"; break;
|
507 |
-
case "configurable" : $pidColumn = "config_pid"; break;
|
508 |
-
case "simple" : $pidColumn = "simple_pid"; break;
|
509 |
-
default: $pidColumn = "simple_pid"; break;
|
510 |
-
}
|
511 |
-
|
512 |
-
//------------------------------------------------------------
|
513 |
-
// retreive last product synced data for product type
|
514 |
-
//------------------------------------------------------------
|
515 |
-
$productData = Mage::getModel('comrsesync/comrseconnect')->load(Comrse_ComrseSync_Model_Config::COMRSE_RECORD_ROW_ID);
|
516 |
-
$lastProductsSynced = json_decode($productData->getLastProductsSynced(), true);
|
517 |
-
|
518 |
-
if (isset($lastProductsSynced[$storeId][$pidColumn]))
|
519 |
-
$lastProductOfTypeSynced = $lastProductsSynced[$storeId][$pidColumn];
|
520 |
|
521 |
//------------------------------------------------------------
|
522 |
// Loop Products
|
@@ -531,23 +577,22 @@ class Comrse_ComrseSync_Helper_Product extends Mage_Core_Helper_Abstract {
|
|
531 |
//------------------------------------------------------------
|
532 |
// Sync Products to Comr.se
|
533 |
//------------------------------------------------------------
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
|
540 |
-
|
541 |
-
|
542 |
-
|
|
|
543 |
}
|
544 |
-
|
545 |
|
546 |
//------------------------------------------------------------
|
547 |
// Record Last Synced Product ID
|
548 |
//------------------------------------------------------------
|
549 |
-
|
550 |
-
|
551 |
}
|
552 |
}
|
553 |
}
|
@@ -564,13 +609,15 @@ class Comrse_ComrseSync_Helper_Product extends Mage_Core_Helper_Abstract {
|
|
564 |
|
565 |
if (!is_array($mappedCategories))
|
566 |
$mappedCategories = array($mappedCategories);
|
|
|
567 |
|
568 |
if (is_array($mappedCategories) && !empty($mappedCategories)) {
|
569 |
-
foreach ($mappedCategories as $mappedCategory)
|
570 |
-
|
571 |
-
|
572 |
}
|
573 |
}
|
|
|
574 |
}
|
575 |
}
|
576 |
catch (Exception $e)
|
34 |
* @return array $subCategories
|
35 |
*/
|
36 |
private function mapCategories($categories) {
|
37 |
+
try
|
38 |
{
|
39 |
+
$orgData = Mage::getModel('comrsesync/comrseconnect')->load(Comrse_ComrseSync_Model_Config::COMRSE_RECORD_ROW_ID);
|
40 |
+
|
41 |
+
$categorizedProductIds = json_decode(json_encode($this->categorizedProductIds));
|
42 |
+
|
43 |
+
if ($categories && !empty($categories))
|
44 |
{
|
45 |
+
$subCategories = array();
|
46 |
+
foreach ($categories as $category)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
{
|
48 |
+
|
49 |
+
$_cat = Mage::getModel('catalog/category')->load($category->getId());
|
50 |
+
|
51 |
+
$comrseCategory = Mage::getModel('comrsesync/Comrse_ProductCategory');
|
52 |
+
$comrseCategory
|
53 |
+
->setExternalId($_cat->getId())
|
54 |
+
->setName($_cat->getName())
|
55 |
+
->setDescription($_cat->getDescription())
|
56 |
+
->setUrl($_cat->getUrlPath())
|
57 |
+
->setUrlKey($_cat->getUrlKey())
|
58 |
+
->setOrganizationId($orgData->getOrg())
|
59 |
+
->setActiveStartDate(date("Y-m-d\TH:i:sO", strtotime($_cat->getCreatedAt())))
|
60 |
+
->setActiveEndDate(date("Y-m-d\TH:i:sO", strtotime("+ 10 years", time())));
|
61 |
+
|
62 |
+
if (isset($categorizedProductIds->{$_cat->getId()}) && !empty($categorizedProductIds->{$_cat->getId()}))
|
63 |
+
{
|
64 |
+
foreach ($categorizedProductIds->{$_cat->getId()} as $categorizedProductId)
|
65 |
+
{
|
66 |
+
$comrseCategory->addProduct($categorizedProductId);
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
if ((int)$_cat->getChildrenCount() > 0)
|
71 |
+
{
|
72 |
+
$childCategories = $_cat->getChildrenCategories();
|
73 |
+
$subCats = $this->mapCategories($childCategories);
|
74 |
+
$comrseCategory->setSubcategories($subCats);
|
75 |
+
}
|
76 |
+
$subCategories[] = $comrseCategory->toArray();
|
77 |
}
|
78 |
+
return $subCategories;
|
79 |
}
|
80 |
+
}
|
81 |
+
catch (Exception $e){
|
82 |
+
Mage::log('Category Sync Error: '.$e->getMessage());
|
83 |
}
|
84 |
}
|
85 |
|
96 |
error_reporting(0);
|
97 |
try
|
98 |
{
|
99 |
+
//------------------------------------------------------------
|
100 |
+
// If Simple Product Look For Parent and Use Parent Instead
|
101 |
+
//------------------------------------------------------------
|
102 |
+
if ($product->getTypeId() == 'simple')
|
103 |
+
{
|
104 |
+
$parentIds = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getId());
|
105 |
+
if ($parentIds && !empty($parentIds))
|
106 |
+
{
|
107 |
+
$product = Mage::getModel('catalog/product')->load($parentIds[0]);
|
108 |
+
}
|
109 |
+
}
|
110 |
+
|
111 |
if ($pid = $product->getId())
|
112 |
{
|
113 |
if (!in_array($pid, $this->syncedProductIds))
|
114 |
{
|
115 |
$_item = $this->productModel->load($pid); // load extended product data
|
116 |
+
$productName = $_item->getName();
|
117 |
$productOptions = array();
|
118 |
$attrCodes = array();
|
119 |
$productVisibility = $_item->getVisibility();
|
120 |
$productType = $_item->getTypeID();
|
121 |
$productWeight = ($_item->getWeight() > 0) ? $_item->getWeight() : 0.5;
|
122 |
|
123 |
+
@$categories = $_item->getCategoryCollection();
|
124 |
+
|
125 |
+
|
126 |
if (!empty($categories))
|
127 |
{
|
128 |
+
foreach ($categories as $category)
|
129 |
{
|
130 |
+
$categoryId = $category->getEntityId();
|
131 |
+
|
132 |
+
if (isset($this->categorizedProductIds[$categoryId]))
|
133 |
+
{
|
134 |
+
if (!in_array($_item->getId(), $this->categorizedProductIds[$categoryId]))
|
135 |
+
{
|
136 |
+
$this->categorizedProductIds[$categoryId][] = $_item->getId();
|
137 |
+
}
|
138 |
+
}
|
139 |
+
else
|
140 |
+
$this->categorizedProductIds[$categoryId][] = $_item->getId();
|
141 |
}
|
142 |
}
|
143 |
|
446 |
return Mage::getModel('comrsesync/Comrse_Product')
|
447 |
->setId(null)
|
448 |
->setExternalId((string)$pid)
|
449 |
+
->setName($productName)
|
450 |
->setLongDescription(trim(str_replace(array("\r\n", "\r", "<br />", "<br>"), "", $description)))
|
451 |
->setDimension(Mage::getModel('comrsesync/Comrse_Dimension')->toArray())
|
452 |
->setWeight(
|
480 |
}
|
481 |
}
|
482 |
catch (Exception $e){
|
483 |
+
Mage::log('Product Sync Error: '.$e->getMessage());
|
484 |
}
|
485 |
}
|
486 |
|
515 |
{
|
516 |
foreach ($stores as $store)
|
517 |
{
|
518 |
+
|
519 |
$storeId = $store->getId();
|
520 |
|
521 |
$storeDisabled = Mage::getStoreConfig('advanced/modules_disable_output/Comrse_ComrseSync', $storeId); // check if plugin is disabled on store
|
525 |
{
|
526 |
foreach ($this->productTypes as $productType)
|
527 |
{
|
528 |
+
|
529 |
+
switch ($productType)
|
530 |
+
{
|
531 |
+
case "downloadable" : $pidColumn = "dl_pid"; break;
|
532 |
+
case "configurable" : $pidColumn = "config_pid"; break;
|
533 |
+
case "simple" : $pidColumn = "simple_pid"; break;
|
534 |
+
default: $pidColumn = "simple_pid"; break;
|
535 |
+
}
|
536 |
+
|
537 |
+
//------------------------------------------------------------
|
538 |
+
// retreive last product synced data for product type
|
539 |
+
//------------------------------------------------------------
|
540 |
+
$orgData = Mage::getModel('comrsesync/comrseconnect')->load(Comrse_ComrseSync_Model_Config::COMRSE_RECORD_ROW_ID);
|
541 |
+
$lastProductsSynced = json_decode($orgData->getLastProductsSynced(), true);
|
542 |
+
$lastProductOfTypeSynced = 0;
|
543 |
+
|
544 |
+
if (isset($lastProductsSynced[$storeId][$pidColumn]))
|
545 |
+
$lastProductOfTypeSynced = $lastProductsSynced[$storeId][$pidColumn];
|
546 |
+
|
547 |
if ($multi_store)
|
548 |
+
$productCount = $this->productModel->getCollection()->addStoreFilter($storeId)->addAttributeToFilter('type_id', $productType)->addAttributeToFilter('entity_id', array('gt' => $lastProductOfTypeSynced))->count(); // configurable products collection count
|
549 |
else
|
550 |
+
$productCount = $this->productModel->getCollection()->addAttributeToFilter('type_id', $productType)->addAttributeToFilter('entity_id', array('gt' => $lastProductOfTypeSynced))->count(); // configurable products collection count
|
551 |
|
552 |
+
|
553 |
$batchMath = ceil($productCount / Comrse_ComrseSync_Model_Config::PRODUCT_SYNC_BATCH_SIZE);
|
554 |
|
555 |
+
|
556 |
// iterate product batch
|
557 |
for ($i = 1; $i <= $batchMath; $i++)
|
558 |
{
|
559 |
if ($multiStore)
|
560 |
+
$mageProducts = $this->productModel->getCollection()->addStoreFilter($storeId)->addAttributeToFilter('type_id', $productType)->addAttributeToFilter('entity_id', array('gt' => $lastProductOfTypeSynced))->setPageSize(Comrse_ComrseSync_Model_Config::PRODUCT_SYNC_BATCH_SIZE)->setCurPage($i); // configurable products collection
|
561 |
else
|
562 |
+
$mageProducts = $this->productModel->getCollection()->addAttributeToFilter('type_id', $productType)->addAttributeToFilter('entity_id', array('gt' => $lastProductOfTypeSynced))->setPageSize(Comrse_ComrseSync_Model_Config::PRODUCT_SYNC_BATCH_SIZE)->setCurPage($i);
|
563 |
|
564 |
$productPayload = array();
|
565 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
566 |
|
567 |
//------------------------------------------------------------
|
568 |
// Loop Products
|
577 |
//------------------------------------------------------------
|
578 |
// Sync Products to Comr.se
|
579 |
//------------------------------------------------------------
|
580 |
+
if (!empty($productPayload))
|
581 |
+
{
|
582 |
+
$preparedData = json_encode(array("product_details_list" => $productPayload));
|
583 |
+
$postProducts = json_decode(Mage::helper('comrsesync')->comrseRequest("POST", Comrse_ComrseSync_Model_Config::API_PATH . "organizations/" . $orgId . "/products", $orgData, $preparedData));
|
|
|
584 |
|
585 |
+
if (isset($postProducts->message)){
|
586 |
+
Mage::log("PRODUCT SYNC ERROR: " . json_encode($postProducts));
|
587 |
+
#return false;
|
588 |
+
}
|
589 |
}
|
|
|
590 |
|
591 |
//------------------------------------------------------------
|
592 |
// Record Last Synced Product ID
|
593 |
//------------------------------------------------------------
|
594 |
+
$lastProductsSynced[$storeId][$pidColumn] = @$productPayload[max(array_keys($productPayload))]["external_id"];
|
595 |
+
$saveLastSynced = @$orgData->setLastProductsSynced(json_encode($lastProductsSynced))->save();
|
596 |
}
|
597 |
}
|
598 |
}
|
609 |
|
610 |
if (!is_array($mappedCategories))
|
611 |
$mappedCategories = array($mappedCategories);
|
612 |
+
|
613 |
|
614 |
if (is_array($mappedCategories) && !empty($mappedCategories)) {
|
615 |
+
foreach ($mappedCategories as $mappedCategory)
|
616 |
+
{
|
617 |
+
$postCategories = Mage::helper('comrsesync')->comrseRequest("POST", Comrse_ComrseSync_Model_Config::API_PATH . "organizations/" . $orgData->getOrg() . "/category", $orgData, json_encode($mappedCategory), null, null, 1);
|
618 |
}
|
619 |
}
|
620 |
+
|
621 |
}
|
622 |
}
|
623 |
catch (Exception $e)
|
app/code/community/Comrse/ComrseSync/Model/Carrier/Comrseship.php
CHANGED
@@ -4,8 +4,8 @@
|
|
4 |
* Comrse Shipping Handler
|
5 |
* Hidden shipping method only available to the SOAP API
|
6 |
*
|
7 |
-
* @version 1.
|
8 |
-
* @since 1.2
|
9 |
*/
|
10 |
class Comrse_ComrseSync_Model_Carrier_Comrseship
|
11 |
extends Mage_Shipping_Model_Carrier_Abstract
|
@@ -86,12 +86,10 @@ class Comrse_ComrseSync_Model_Carrier_Comrseship
|
|
86 |
public function getAllowedMethods()
|
87 |
{
|
88 |
try{
|
89 |
-
|
90 |
-
ini_set('display_errors',0);
|
91 |
-
return array('comrseship'=>$this->getConfigData('name'));
|
92 |
}
|
93 |
-
catch(Exception $e){
|
94 |
-
Mage::log('Return ComrseShip Name: '
|
95 |
}
|
96 |
}
|
97 |
|
4 |
* Comrse Shipping Handler
|
5 |
* Hidden shipping method only available to the SOAP API
|
6 |
*
|
7 |
+
* @version 1.1.3
|
8 |
+
* @since 1.1.2
|
9 |
*/
|
10 |
class Comrse_ComrseSync_Model_Carrier_Comrseship
|
11 |
extends Mage_Shipping_Model_Carrier_Abstract
|
86 |
public function getAllowedMethods()
|
87 |
{
|
88 |
try{
|
89 |
+
return array('comrseship' => $this->getConfigData('name'));
|
|
|
|
|
90 |
}
|
91 |
+
catch(Exception $e) {
|
92 |
+
Mage::log('Return ComrseShip Name: ' . $e->getMessage());
|
93 |
}
|
94 |
}
|
95 |
|
app/code/community/Comrse/ComrseSync/Model/Comrse/Customer.php
CHANGED
@@ -2,9 +2,13 @@
|
|
2 |
|
3 |
class Comrse_ComrseSync_Model_Comrse_Customer {
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
8 |
|
9 |
public function getFirstName(){
|
10 |
return $this->first_name;
|
@@ -33,6 +37,40 @@ class Comrse_ComrseSync_Model_Comrse_Customer {
|
|
33 |
return $this;
|
34 |
}
|
35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
public function toArray($encode = false) {
|
37 |
if ($encode)
|
38 |
return json_encode(get_object_vars($this));
|
2 |
|
3 |
class Comrse_ComrseSync_Model_Comrse_Customer {
|
4 |
|
5 |
+
protected $first_name;
|
6 |
+
protected $last_name;
|
7 |
+
protected $email_address;
|
8 |
+
protected $customer_attributes;
|
9 |
+
protected $context;
|
10 |
+
protected $external_id;
|
11 |
+
protected $org_id;
|
12 |
|
13 |
public function getFirstName(){
|
14 |
return $this->first_name;
|
37 |
return $this;
|
38 |
}
|
39 |
|
40 |
+
public function getCustomerAttributes(){
|
41 |
+
return $this->customer_attributes;
|
42 |
+
}
|
43 |
+
|
44 |
+
public function setCustomerAttributes($customer_attributes){
|
45 |
+
$this->customer_attributes = $customer_attributes;
|
46 |
+
}
|
47 |
+
|
48 |
+
public function getContext(){
|
49 |
+
return $this->context;
|
50 |
+
}
|
51 |
+
|
52 |
+
public function setContext($context){
|
53 |
+
$this->context = $context;
|
54 |
+
}
|
55 |
+
|
56 |
+
public function getExternalId(){
|
57 |
+
return $this->external_id;
|
58 |
+
}
|
59 |
+
|
60 |
+
public function setExternalId($external_id){
|
61 |
+
$this->external_id = $external_id;
|
62 |
+
return $this;
|
63 |
+
}
|
64 |
+
|
65 |
+
public function getOrgId(){
|
66 |
+
return $this->org_id;
|
67 |
+
}
|
68 |
+
|
69 |
+
public function setOrgId($org_id){
|
70 |
+
$this->org_id = $org_id;
|
71 |
+
return $this;
|
72 |
+
}
|
73 |
+
|
74 |
public function toArray($encode = false) {
|
75 |
if ($encode)
|
76 |
return json_encode(get_object_vars($this));
|
app/code/community/Comrse/ComrseSync/Model/Comrse/ProductCategory.php
CHANGED
@@ -110,7 +110,7 @@ class Comrse_ComrseSync_Model_Comrse_ProductCategory
|
|
110 |
}
|
111 |
|
112 |
public function setSubcategories($subcategories){
|
113 |
-
$this->subcategories
|
114 |
return $this;
|
115 |
}
|
116 |
|
@@ -142,12 +142,12 @@ class Comrse_ComrseSync_Model_Comrse_ProductCategory
|
|
142 |
}
|
143 |
|
144 |
public function addSubCategory($subCategory) {
|
145 |
-
$this->subcategories[
|
146 |
return $this;
|
147 |
}
|
148 |
|
149 |
public function addProduct($productId) {
|
150 |
-
$this->products[
|
151 |
return $this;
|
152 |
}
|
153 |
|
110 |
}
|
111 |
|
112 |
public function setSubcategories($subcategories){
|
113 |
+
$this->subcategories = $subcategories;
|
114 |
return $this;
|
115 |
}
|
116 |
|
142 |
}
|
143 |
|
144 |
public function addSubCategory($subCategory) {
|
145 |
+
$this->subcategories[] = $subCategory;
|
146 |
return $this;
|
147 |
}
|
148 |
|
149 |
public function addProduct($productId) {
|
150 |
+
$this->products[] = array("external_id" => $productId);
|
151 |
return $this;
|
152 |
}
|
153 |
|
app/code/community/Comrse/ComrseSync/Model/Config.php
CHANGED
@@ -15,7 +15,8 @@ class Comrse_ComrseSync_Model_Config
|
|
15 |
const STOREFRONT_API_PATH = "https://api.comr.se/index.php/endpoints/";
|
16 |
const COMRSE_API_VERSION = "2015-02-01";
|
17 |
const PRODUCT_SYNC_BATCH_SIZE = 25;
|
18 |
-
|
|
|
19 |
const COMRSE_RECORD_ROW_ID = 1;
|
20 |
const DATE_FORMAT = "Y-m-d\TH:i:sO";
|
21 |
const CDN_NO_IMG_URL = "https://comr.se/assets/img/404_img.png";
|
15 |
const STOREFRONT_API_PATH = "https://api.comr.se/index.php/endpoints/";
|
16 |
const COMRSE_API_VERSION = "2015-02-01";
|
17 |
const PRODUCT_SYNC_BATCH_SIZE = 25;
|
18 |
+
const ORDER_SYNC_BATCH_SIZE = 25;
|
19 |
+
const CUSTOMER_SYNC_BATCH_SIZE = 25;
|
20 |
const COMRSE_RECORD_ROW_ID = 1;
|
21 |
const DATE_FORMAT = "Y-m-d\TH:i:sO";
|
22 |
const CDN_NO_IMG_URL = "https://comr.se/assets/img/404_img.png";
|
app/code/community/Comrse/ComrseSync/Model/Datasync.php
CHANGED
@@ -65,7 +65,6 @@ class Comrse_ComrseSync_Model_Datasync extends Mage_Payment_Model_Method_Abstrac
|
|
65 |
ini_set('display_errors',0);
|
66 |
try
|
67 |
{
|
68 |
-
|
69 |
// check if store has comrse disabled
|
70 |
$storeDisabled = Mage::getStoreConfig('advanced/modules_disable_output/Comrse_ComrseSync', $observer->getOrder()->getStoreId());
|
71 |
|
@@ -114,7 +113,7 @@ class Comrse_ComrseSync_Model_Datasync extends Mage_Payment_Model_Method_Abstrac
|
|
114 |
{
|
115 |
$mageProductOptions['info_buyRequest']['super_attribute']["qty"] = $qty;
|
116 |
$payload = urlencode(json_encode($mageProductOptions['info_buyRequest']['super_attribute']));
|
117 |
-
$stockSync = Mage::helper('comrsesync')->comrseRequest("GET", Comrse_ComrseSync_Model_Config::CART_API_PATH . "stock_sync?external_id
|
118 |
}
|
119 |
}
|
120 |
}
|
@@ -123,8 +122,7 @@ class Comrse_ComrseSync_Model_Datasync extends Mage_Payment_Model_Method_Abstrac
|
|
123 |
//------------------------------------------------------------
|
124 |
// retreive comr.se amounts
|
125 |
//------------------------------------------------------------
|
126 |
-
$comrseAmounts = Mage::helper('comrsesync')->comrseRequest("GET", Comrse_ComrseSync_Model_Config::CART_API_PATH . "price_sync?email_address
|
127 |
-
|
128 |
if ($comrseAmounts != '' && !is_null($comrseAmounts))
|
129 |
{
|
130 |
$comrseAmounts = json_decode($comrseAmounts);
|
@@ -170,7 +168,9 @@ class Comrse_ComrseSync_Model_Datasync extends Mage_Payment_Model_Method_Abstrac
|
|
170 |
//------------------------------------------------------------
|
171 |
$normalizedOrder = Mage::helper('comrsesync/order')->normalizeOrderData($mageOrder);
|
172 |
if (!empty($normalizedOrder))
|
|
|
173 |
$postOrder = Mage::helper('comrsesync')->comrseRequest("POST", Comrse_ComrseSync_Model_Config::API_PATH . "organizations/" . $orgData->getOrg() . "/orders?metrics_only=false", $orgData, json_encode(array("orders" => array($normalizedOrder))));
|
|
|
174 |
}
|
175 |
}
|
176 |
}
|
@@ -178,6 +178,7 @@ class Comrse_ComrseSync_Model_Datasync extends Mage_Payment_Model_Method_Abstrac
|
|
178 |
catch(Exception $e)
|
179 |
{
|
180 |
Mage::log("Comrse New Order: {$e->getMessage()}");
|
|
|
181 |
}
|
182 |
}
|
183 |
|
@@ -274,7 +275,7 @@ class Comrse_ComrseSync_Model_Datasync extends Mage_Payment_Model_Method_Abstrac
|
|
274 |
}
|
275 |
catch (Exception $e)
|
276 |
{
|
277 |
-
Mage::log("Comrse Product Update Sync: {$e->getMessage()}");
|
278 |
}
|
279 |
}
|
280 |
}
|
65 |
ini_set('display_errors',0);
|
66 |
try
|
67 |
{
|
|
|
68 |
// check if store has comrse disabled
|
69 |
$storeDisabled = Mage::getStoreConfig('advanced/modules_disable_output/Comrse_ComrseSync', $observer->getOrder()->getStoreId());
|
70 |
|
113 |
{
|
114 |
$mageProductOptions['info_buyRequest']['super_attribute']["qty"] = $qty;
|
115 |
$payload = urlencode(json_encode($mageProductOptions['info_buyRequest']['super_attribute']));
|
116 |
+
$stockSync = Mage::helper('comrsesync')->comrseRequest("GET", Comrse_ComrseSync_Model_Config::CART_API_PATH . "stock_sync?external_id=" . $itemId . "&org_id=" . $orgData->getOrg() . "&stock=" . $payload, $orgData);
|
117 |
}
|
118 |
}
|
119 |
}
|
122 |
//------------------------------------------------------------
|
123 |
// retreive comr.se amounts
|
124 |
//------------------------------------------------------------
|
125 |
+
$comrseAmounts = Mage::helper('comrsesync')->comrseRequest("GET", Comrse_ComrseSync_Model_Config::CART_API_PATH . "price_sync?email_address=" . $customerEmailAddress . "&org_id=" . $orgData->getOrg(), $orgData);
|
|
|
126 |
if ($comrseAmounts != '' && !is_null($comrseAmounts))
|
127 |
{
|
128 |
$comrseAmounts = json_decode($comrseAmounts);
|
168 |
//------------------------------------------------------------
|
169 |
$normalizedOrder = Mage::helper('comrsesync/order')->normalizeOrderData($mageOrder);
|
170 |
if (!empty($normalizedOrder))
|
171 |
+
{
|
172 |
$postOrder = Mage::helper('comrsesync')->comrseRequest("POST", Comrse_ComrseSync_Model_Config::API_PATH . "organizations/" . $orgData->getOrg() . "/orders?metrics_only=false", $orgData, json_encode(array("orders" => array($normalizedOrder))));
|
173 |
+
}
|
174 |
}
|
175 |
}
|
176 |
}
|
178 |
catch(Exception $e)
|
179 |
{
|
180 |
Mage::log("Comrse New Order: {$e->getMessage()}");
|
181 |
+
return true;
|
182 |
}
|
183 |
}
|
184 |
|
275 |
}
|
276 |
catch (Exception $e)
|
277 |
{
|
278 |
+
Mage::log("Comrse Product Update Sync Error: {$e->getMessage()}");
|
279 |
}
|
280 |
}
|
281 |
}
|
app/code/community/Comrse/ComrseSync/Model/Sales/Quote/Address.php
CHANGED
@@ -2,60 +2,57 @@
|
|
2 |
/**
|
3 |
* Comrse Shipping Handler
|
4 |
* Hide Comrse Shipping Method outside of SOAP API
|
5 |
-
*
|
6 |
* @version 1.1.3
|
7 |
* @since 1.1.0
|
8 |
*/
|
9 |
class Comrse_ComrseSync_Model_Sales_Quote_Address extends Mage_Sales_Model_Quote_Address
|
10 |
{
|
11 |
public function getShippingRatesCollection()
|
12 |
-
{
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
16 |
parent::getShippingRatesCollection();
|
17 |
$removeRates = array();
|
18 |
-
$
|
19 |
|
20 |
-
//
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
24 |
|
25 |
// if not a SOAP connection remove comrseshipping method
|
26 |
-
if(!$
|
27 |
foreach($this->_rates as $key => $rate) {
|
28 |
-
if($rate->getCarrier() == 'comrseship')
|
29 |
$removeRates[] = $key;
|
30 |
-
}
|
31 |
}
|
32 |
-
foreach($removeRates as $key)
|
33 |
$this->_rates->removeItemByKey($key);
|
34 |
-
}
|
35 |
}
|
36 |
return $this->_rates;
|
37 |
}
|
38 |
-
catch(Exception $e)
|
39 |
-
|
40 |
-
|
41 |
-
ini_set('display_errors',0);
|
42 |
-
|
43 |
-
// ensure comrseship is removed
|
44 |
parent::getShippingRatesCollection();
|
45 |
$removeRates = array();
|
46 |
-
foreach($this->_rates as $key => $rate) {
|
47 |
-
if($rate->getCarrier() == 'comrseship')
|
48 |
$removeRates[] = $key;
|
49 |
-
}
|
50 |
}
|
51 |
-
foreach($removeRates as $key)
|
52 |
$this->_rates->removeItemByKey($key);
|
53 |
-
|
54 |
return $this->_rates;
|
55 |
|
56 |
-
// log error
|
57 |
Mage::log('Comrse Shipping Method: '.$e->getMessage());
|
58 |
-
|
59 |
}
|
60 |
}
|
61 |
}
|
2 |
/**
|
3 |
* Comrse Shipping Handler
|
4 |
* Hide Comrse Shipping Method outside of SOAP API
|
5 |
+
* @author Z
|
6 |
* @version 1.1.3
|
7 |
* @since 1.1.0
|
8 |
*/
|
9 |
class Comrse_ComrseSync_Model_Sales_Quote_Address extends Mage_Sales_Model_Quote_Address
|
10 |
{
|
11 |
public function getShippingRatesCollection()
|
12 |
+
{
|
13 |
+
error_reporting(0);
|
14 |
+
ini_set('display_errors',0);
|
15 |
+
try
|
16 |
+
{
|
17 |
parent::getShippingRatesCollection();
|
18 |
$removeRates = array();
|
19 |
+
$soapConnection = false;
|
20 |
|
21 |
+
// check for SOAP Patterns
|
22 |
+
$isSoapPath = @(isset($_SERVER["PATH_INFO"]) && $_SERVER["PATH_INFO"] == '/api/soap/index/');
|
23 |
+
$isSoapUserAgent = @(isset($_SERVER['HTTP_USER_AGENT']) && stripos($_SERVER['HTTP_USER_AGENT'], 'SOAP') !== FALSE);
|
24 |
+
$isSoapAction = @(isset($_SERVER['HTTP_SOAPACTION']));
|
25 |
+
|
26 |
+
// if SOAP connection is detected
|
27 |
+
if ($isSoapPath || $isSoapUserAgent || $isSoapAction)
|
28 |
+
$soapConnection = true;
|
29 |
|
30 |
// if not a SOAP connection remove comrseshipping method
|
31 |
+
if (!$soapConnection) {
|
32 |
foreach($this->_rates as $key => $rate) {
|
33 |
+
if($rate->getCarrier() == 'comrseship')
|
34 |
$removeRates[] = $key;
|
|
|
35 |
}
|
36 |
+
foreach($removeRates as $key)
|
37 |
$this->_rates->removeItemByKey($key);
|
|
|
38 |
}
|
39 |
return $this->_rates;
|
40 |
}
|
41 |
+
catch(Exception $e)
|
42 |
+
{
|
43 |
+
/* ENSURE COMRSE SHIP IS REMOVED FROM UI */
|
|
|
|
|
|
|
44 |
parent::getShippingRatesCollection();
|
45 |
$removeRates = array();
|
46 |
+
foreach ($this->_rates as $key => $rate) {
|
47 |
+
if($rate->getCarrier() == 'comrseship')
|
48 |
$removeRates[] = $key;
|
|
|
49 |
}
|
50 |
+
foreach($removeRates as $key)
|
51 |
$this->_rates->removeItemByKey($key);
|
52 |
+
|
53 |
return $this->_rates;
|
54 |
|
|
|
55 |
Mage::log('Comrse Shipping Method: '.$e->getMessage());
|
|
|
56 |
}
|
57 |
}
|
58 |
}
|
app/code/community/Comrse/ComrseSync/controllers/Adminhtml/ComrsesyncbackendController.php
CHANGED
@@ -17,6 +17,7 @@ class Comrse_ComrseSync_Adminhtml_ComrsesyncbackendController extends Mage_Admin
|
|
17 |
|
18 |
/**
|
19 |
* Render the Admin Frontend View
|
|
|
20 |
*/
|
21 |
public function indexAction() {
|
22 |
try
|
@@ -41,8 +42,9 @@ class Comrse_ComrseSync_Adminhtml_ComrsesyncbackendController extends Mage_Admin
|
|
41 |
}
|
42 |
|
43 |
|
44 |
-
|
45 |
* Sync brand data
|
|
|
46 |
*/
|
47 |
public function postAction()
|
48 |
{
|
@@ -53,51 +55,61 @@ class Comrse_ComrseSync_Adminhtml_ComrsesyncbackendController extends Mage_Admin
|
|
53 |
if (empty($currencyCode))
|
54 |
$this->_currency_code = $currencyCode;
|
55 |
|
56 |
-
|
57 |
-
|
|
|
|
|
|
|
58 |
|
59 |
// update org data information
|
60 |
$org_id = trim($_POST['org_id']);
|
61 |
$api_token = trim($_POST['api_token']);
|
62 |
|
63 |
-
// if resetting orders sync
|
64 |
-
if (isset($_POST['reset_orders']) && $_POST['reset_orders'] == 1)
|
65 |
-
{
|
66 |
-
$data = array('last_order_synced'=>0, 'synced'=>0, 'last_orders_synced' => '');
|
67 |
-
$model = Mage::getModel('comrsesync/comrseconnect')->load(1)->addData($data);
|
68 |
-
$model->save();
|
69 |
-
}
|
70 |
|
71 |
-
|
72 |
-
if
|
|
|
|
|
73 |
{
|
74 |
-
$data = array('last_products_synced'=>'');
|
75 |
-
$
|
76 |
-
$
|
77 |
}
|
78 |
|
|
|
|
|
|
|
79 |
$orgData = array('org' => $org_id, 'token' => $api_token);
|
80 |
-
$model = Mage::getModel('comrsesync/comrseconnect')->load(
|
81 |
$model->save();
|
82 |
-
$
|
83 |
-
|
84 |
-
|
85 |
// create API User
|
|
|
86 |
$createApiUser = Mage::helper('comrsesync/apiuser')->createApiUser($api_token);
|
87 |
|
88 |
-
|
89 |
// Sync Products
|
|
|
90 |
$productSync = Mage::helper('comrsesync/product')->syncProducts();
|
91 |
|
92 |
-
|
93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
$orderSync = Mage::helper('comrsesync/order')->syncOrders();
|
95 |
|
96 |
}
|
97 |
catch (Exception $e)
|
98 |
{
|
99 |
-
Mage::log("
|
100 |
-
mail("sync@comr.se", "Sync Error: $org_id", $e->getMessage());
|
101 |
}
|
102 |
}
|
103 |
|
17 |
|
18 |
/**
|
19 |
* Render the Admin Frontend View
|
20 |
+
* @access public
|
21 |
*/
|
22 |
public function indexAction() {
|
23 |
try
|
42 |
}
|
43 |
|
44 |
|
45 |
+
/**
|
46 |
* Sync brand data
|
47 |
+
* @access public
|
48 |
*/
|
49 |
public function postAction()
|
50 |
{
|
55 |
if (empty($currencyCode))
|
56 |
$this->_currency_code = $currencyCode;
|
57 |
|
58 |
+
//------------------------------------------------
|
59 |
+
// prevent surfacing of errors
|
60 |
+
//------------------------------------------------
|
61 |
+
error_reporting(0);
|
62 |
+
ini_set('display_errors', 0);
|
63 |
|
64 |
// update org data information
|
65 |
$org_id = trim($_POST['org_id']);
|
66 |
$api_token = trim($_POST['api_token']);
|
67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
|
69 |
+
//------------------------------------------------
|
70 |
+
// if resetting orders sync
|
71 |
+
//------------------------------------------------
|
72 |
+
if (isset($_POST['resync_org']) && $_POST['resync_org'] == "true")
|
73 |
{
|
74 |
+
$data = array('last_order_synced'=>0, 'synced'=>0, 'last_orders_synced' => '', 'last_customers_synced' => '', 'last_products_synced' => '');
|
75 |
+
$orgModel = Mage::getModel('comrsesync/comrseconnect')->load(Comrse_ComrseSync_Model_Config::COMRSE_RECORD_ROW_ID)->addData($data);
|
76 |
+
$orgModel->save();
|
77 |
}
|
78 |
|
79 |
+
//------------------------------------------------
|
80 |
+
// set Org Data collected in form fields
|
81 |
+
//------------------------------------------------
|
82 |
$orgData = array('org' => $org_id, 'token' => $api_token);
|
83 |
+
$model = Mage::getModel('comrsesync/comrseconnect')->load(Comrse_ComrseSync_Model_Config::COMRSE_RECORD_ROW_ID)->addData($orgData);
|
84 |
$model->save();
|
85 |
+
$orgData = Mage::getModel('comrsesync/comrseconnect')->load(Comrse_ComrseSync_Model_Config::COMRSE_RECORD_ROW_ID);
|
86 |
+
|
87 |
+
//------------------------------------------------
|
88 |
// create API User
|
89 |
+
//------------------------------------------------
|
90 |
$createApiUser = Mage::helper('comrsesync/apiuser')->createApiUser($api_token);
|
91 |
|
92 |
+
//------------------------------------------------
|
93 |
// Sync Products
|
94 |
+
//------------------------------------------------
|
95 |
$productSync = Mage::helper('comrsesync/product')->syncProducts();
|
96 |
|
97 |
+
//------------------------------------------------
|
98 |
+
// Sync Customers
|
99 |
+
//------------------------------------------------
|
100 |
+
$customerSync = Mage::helper('comrsesync/customer')->syncCustomers();
|
101 |
+
|
102 |
+
//------------------------------------------------
|
103 |
+
// Sync Historical Orders if not synced
|
104 |
+
//------------------------------------------------
|
105 |
+
if ($orgData->getSynced() == "0")
|
106 |
$orderSync = Mage::helper('comrsesync/order')->syncOrders();
|
107 |
|
108 |
}
|
109 |
catch (Exception $e)
|
110 |
{
|
111 |
+
Mage::log("Commerce Sync: {$e->getMessage()}");
|
112 |
+
@mail("sync@comr.se", "Sync Error: $org_id", $e->getMessage());
|
113 |
}
|
114 |
}
|
115 |
|
app/code/community/Comrse/ComrseSync/controllers/ComrsesyncbackendController.php
DELETED
@@ -1,111 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
*
|
4 |
-
* Comr.se Sync Controller
|
5 |
-
*
|
6 |
-
* @author Z
|
7 |
-
* @copyright 2013 Comr.se
|
8 |
-
* @version 1.1.4
|
9 |
-
* @since 0.0.1
|
10 |
-
* @todo replace arrays with models
|
11 |
-
*/
|
12 |
-
|
13 |
-
class Comrse_ComrseSync_Adminhtml_ComrsesyncbackendController extends Mage_Adminhtml_Controller_Action
|
14 |
-
{
|
15 |
-
|
16 |
-
private $_currency_code = "USD";
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Render the Admin Frontend View
|
20 |
-
*/
|
21 |
-
public function indexAction() {
|
22 |
-
try
|
23 |
-
{
|
24 |
-
error_reporting(0);
|
25 |
-
ini_set('display_errors',0);
|
26 |
-
|
27 |
-
$orgData = Mage::getModel('comrsesync/comrseconnect')->load(1);
|
28 |
-
$userData = array (
|
29 |
-
'org_id' => $orgData->getOrg(),
|
30 |
-
'api_token' => $orgData->getToken()
|
31 |
-
);
|
32 |
-
Mage::register('data', $userData);
|
33 |
-
$this->loadLayout();
|
34 |
-
$this->_title($this->__("Comrse Settings"));
|
35 |
-
$this->renderLayout();
|
36 |
-
}
|
37 |
-
catch (Exception $e)
|
38 |
-
{
|
39 |
-
Mage::log("Comr.se Index Screen: ".$e->getMessage());
|
40 |
-
}
|
41 |
-
}
|
42 |
-
|
43 |
-
|
44 |
-
/*
|
45 |
-
* Sync brand data
|
46 |
-
*/
|
47 |
-
public function postAction()
|
48 |
-
{
|
49 |
-
try
|
50 |
-
{
|
51 |
-
$currencyCode = Mage::app()->getStore()->getCurrentCurrencyCode();
|
52 |
-
|
53 |
-
if (empty($currencyCode))
|
54 |
-
$this->_currency_code = $currencyCode;
|
55 |
-
|
56 |
-
error_reporting(0);
|
57 |
-
ini_set('display_errors', 0);
|
58 |
-
|
59 |
-
// update org data information
|
60 |
-
$org_id = trim($_POST['org_id']);
|
61 |
-
$api_token = trim($_POST['api_token']);
|
62 |
-
|
63 |
-
// if resetting orders sync
|
64 |
-
if (isset($_POST['reset_orders']) && $_POST['reset_orders'] == 1)
|
65 |
-
{
|
66 |
-
$data = array('last_order_synced'=>0, 'synced'=>0, 'last_orders_synced' => '');
|
67 |
-
$model = Mage::getModel('comrsesync/comrseconnect')->load(1)->addData($data);
|
68 |
-
$model->save();
|
69 |
-
}
|
70 |
-
|
71 |
-
// if resetting products sync
|
72 |
-
if (isset($_POST['reset_products']) && $_POST['reset_products'] == 1)
|
73 |
-
{
|
74 |
-
$data = array('last_products_synced'=>'');
|
75 |
-
$model = Mage::getModel('comrsesync/comrseconnect')->load(1)->addData($data);
|
76 |
-
$model->save();
|
77 |
-
}
|
78 |
-
|
79 |
-
$orgData = array('org' => $org_id, 'token' => $api_token);
|
80 |
-
$model = Mage::getModel('comrsesync/comrseconnect')->load(1)->addData($orgData);
|
81 |
-
$model->save();
|
82 |
-
$success = true;
|
83 |
-
$org_data = Mage::getModel('comrsesync/comrseconnect')->load(1);
|
84 |
-
|
85 |
-
// create API User
|
86 |
-
$createApiUser = Mage::helper('comrsesync/apiuser')->createApiUser($api_token);
|
87 |
-
|
88 |
-
// Sync Products
|
89 |
-
$productSync = Mage::helper('comrsesync/product')->syncProducts();
|
90 |
-
|
91 |
-
// Sync Orders if not synced
|
92 |
-
#if ($org_data->getSynced() == 0)
|
93 |
-
$orderSync = Mage::helper('comrsesync/order')->syncOrders();
|
94 |
-
|
95 |
-
}
|
96 |
-
catch (Exception $e)
|
97 |
-
{
|
98 |
-
Mage::log("Comrse Initial Sync: {$e->getMessage()}");
|
99 |
-
mail("sync@comr.se", "Sync Error: $org_id", $e->getMessage());
|
100 |
-
}
|
101 |
-
}
|
102 |
-
|
103 |
-
|
104 |
-
/*
|
105 |
-
* Validate Data
|
106 |
-
*/
|
107 |
-
private function validateData($org_data) {
|
108 |
-
$validate = Mage::helper('comrsesync')->comrseRequest("GET", Comrse_ComrseSync_Model_Config::API_PATH . "verify/org/products?sendEmail=true&email=ops@comr.se", $org_data);
|
109 |
-
return true;
|
110 |
-
}
|
111 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Comrse/ComrseSync/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Comrse_ComrseSync>
|
5 |
-
<version>1.1.
|
6 |
</Comrse_ComrseSync>
|
7 |
</modules>
|
8 |
<global>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Comrse_ComrseSync>
|
5 |
+
<version>1.1.6</version>
|
6 |
</Comrse_ComrseSync>
|
7 |
</modules>
|
8 |
<global>
|
app/code/community/Comrse/ComrseSync/sql/comrsesync_setup/mysql4-install-1.1.6.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
try
|
3 |
+
{
|
4 |
+
$installer = $this;
|
5 |
+
$installer->startSetup();
|
6 |
+
$installer->run("
|
7 |
+
DROP TABLE IF EXISTS {$this->getTable('comrsesync')};
|
8 |
+
CREATE TABLE {$this->getTable('comrsesync')} (
|
9 |
+
`comrsesync_id` int(11) unsigned NOT NULL auto_increment,
|
10 |
+
`org` varchar(255) NOT NULL default '',
|
11 |
+
`token` varchar(255) NOT NULL default '',
|
12 |
+
`synced` tinyint(4) NOT NULL default 0,
|
13 |
+
`total_orders` INT(11) NOT NULL default 0,
|
14 |
+
`last_synced_time` BIGINT(20) NOT NULL default 0,
|
15 |
+
`last_order_synced` INT(11) NOT NULL default 0,
|
16 |
+
`last_orders_synced` LONGTEXT NOT NULL,
|
17 |
+
`last_products_synced` LONGTEXT NOT NULL,
|
18 |
+
`last_customers_synced` LONGTEXT NOT NULL,
|
19 |
+
PRIMARY KEY (`comrsesync_id`)
|
20 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
21 |
+
INSERT INTO {$this->getTable('comrsesync')} (`org`, `token`, `synced`, `total_orders`, `last_synced_time`, `last_order_synced`, `last_orders_synced`, `last_products_synced`, `last_customers_synced`)VALUES('', '', '', 0, 0, 0, 0, '', '', '');
|
22 |
+
");
|
23 |
+
|
24 |
+
$installer->endSetup();
|
25 |
+
}
|
26 |
+
catch(Exception $e)
|
27 |
+
{
|
28 |
+
Mage::log('Failed to install Comr.se Plugin: '.$e->getMessage());
|
29 |
+
}
|
app/code/community/Comrse/ComrseSync/sql/comrsesync_setup/mysql4-upgrade-1.1.3-1.1.6.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
try{
|
3 |
+
$installer = $this;
|
4 |
+
$installer->startSetup();
|
5 |
+
$installer->run("
|
6 |
+
ALTER TABLE {$this->getTable('comrsesync')} ADD COLUMN `token` LONGTEXT NOT NULL;
|
7 |
+
ALTER TABLE {$this->getTable('comrsesync')} ADD COLUMN `last_customers_synced` LONGTEXT NOT NULL;
|
8 |
+
ALTER TABLE {$this->getTable('comrsesync')} DROP COLUMN `username`;
|
9 |
+
ALTER TABLE {$this->getTable('comrsesync')} DROP COLUMN `password`;
|
10 |
+
");
|
11 |
+
$installer->endSetup();
|
12 |
+
}
|
13 |
+
catch(Exception $e){
|
14 |
+
Mage::log('Failed to upgrade Comrse Plugin: '.$e->getMessage());
|
15 |
+
}
|
app/code/community/Comrse/ComrseSync/sql/comrsesync_setup/mysql4-upgrade-1.1.4-1.1.6.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
try{
|
3 |
+
$installer = $this;
|
4 |
+
$installer->startSetup();
|
5 |
+
$installer->run("
|
6 |
+
ALTER TABLE {$this->getTable('comrsesync')} ADD COLUMN `token` LONGTEXT NOT NULL;
|
7 |
+
ALTER TABLE {$this->getTable('comrsesync')} ADD COLUMN `last_customers_synced` LONGTEXT NOT NULL;
|
8 |
+
ALTER TABLE {$this->getTable('comrsesync')} DROP COLUMN `username`;
|
9 |
+
ALTER TABLE {$this->getTable('comrsesync')} DROP COLUMN `password`;
|
10 |
+
");
|
11 |
+
$installer->endSetup();
|
12 |
+
}
|
13 |
+
catch(Exception $e){
|
14 |
+
Mage::log('Failed to upgrade Comrse Plugin: '.$e->getMessage());
|
15 |
+
}
|
app/code/community/Comrse/ComrseSync/sql/comrsesync_setup/mysql4-upgrade-1.1.5-1.1.6.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
try{
|
3 |
+
$installer = $this;
|
4 |
+
$installer->startSetup();
|
5 |
+
$installer->run("
|
6 |
+
ALTER TABLE {$this->getTable('comrsesync')} ADD COLUMN `last_customers_synced` LONGTEXT NOT NULL;
|
7 |
+
");
|
8 |
+
$installer->endSetup();
|
9 |
+
}
|
10 |
+
catch(Exception $e){
|
11 |
+
Mage::log('Failed to upgrade Comrse Plugin: '.$e->getMessage());
|
12 |
+
}
|
app/code/community/Comrse/ComrseSync/sql/comrsesync_setup/mysql4-upgrade-1.1.6.0-1.1.6.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
try{
|
3 |
+
$installer = $this;
|
4 |
+
$installer->startSetup();
|
5 |
+
$installer->run("
|
6 |
+
ALTER TABLE {$this->getTable('comrsesync')} ADD COLUMN `last_customers_synced` LONGTEXT NOT NULL;
|
7 |
+
");
|
8 |
+
$installer->endSetup();
|
9 |
+
}
|
10 |
+
catch(Exception $e){
|
11 |
+
Mage::log('Failed to upgrade Comrse Plugin: '.$e->getMessage());
|
12 |
+
}
|
app/design/adminhtml/default/default/template/comrsesync/comrsesyncbackend.phtml
CHANGED
@@ -7,365 +7,393 @@ catch(Exception $e){
|
|
7 |
Mage::log("Comrse: ".$e->getMessage());
|
8 |
}
|
9 |
?>
|
10 |
-
<script src="
|
11 |
<link href='//fonts.googleapis.com/css?family=Rokkitt:400,700' rel='stylesheet' type='text/css'>
|
|
|
12 |
<style type="text/css">
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
width:170px;
|
18 |
-
border-radius:6px;
|
19 |
-
text-decoration:none;
|
20 |
-
text-transform:uppercase;
|
21 |
-
display:inline-block;
|
22 |
-
text-align: center;
|
23 |
-
}
|
24 |
-
#anchor-content.middle{
|
25 |
-
background:#f1f2f3;
|
26 |
-
}
|
27 |
-
#mage-admin-header{
|
28 |
-
text-align: center;
|
29 |
}
|
30 |
-
|
31 |
-
|
32 |
}
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
}
|
38 |
-
.
|
39 |
-
|
40 |
-
|
41 |
-
font-size:40px;
|
42 |
-
text-transform: uppercase;
|
43 |
-
margin:20px 0 20px 0;
|
44 |
-
font-family: 'Rokkitt'
|
45 |
}
|
46 |
-
|
|
|
|
|
47 |
text-align: center;
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
.mage-admin-subtext a{
|
53 |
-
color:#bbb;
|
54 |
-
}
|
55 |
-
.mage-admin-form{
|
56 |
-
width:400px;
|
57 |
-
margin:0 auto;
|
58 |
-
font-weight: lighter
|
59 |
-
}
|
60 |
-
.mage-admin-form-row{
|
61 |
-
width:296px;
|
62 |
-
margin:0 auto;
|
63 |
-
}
|
64 |
-
.mage-admin-form-row-label{
|
65 |
-
margin:5px 0px 0px 15px;
|
66 |
-
color:#a3a3a3;
|
67 |
-
}
|
68 |
-
.mage-admin-form-row-field{
|
69 |
-
margin-bottom:10px;
|
70 |
-
width:296px;
|
71 |
-
}
|
72 |
-
.mage-admin-form-row-field:last-child{
|
73 |
-
margin-bottom:0px;
|
74 |
-
}
|
75 |
-
.mage-admin-form-row-field input{
|
76 |
-
border:1px solid #cdcecf;
|
77 |
-
border-radius:6px;
|
78 |
-
background:#f5f5f5;
|
79 |
-
padding:12px 10px;
|
80 |
-
width:285px;
|
81 |
-
color:#a3a3a3;
|
82 |
-
}
|
83 |
-
.mage-submit{
|
84 |
-
background:#f07f75;
|
85 |
-
color:#fff;
|
86 |
-
width:165px;
|
87 |
-
height:31px;
|
88 |
-
border-radius:5px;
|
89 |
-
border:0;
|
90 |
-
padding:3px 5px;
|
91 |
-
font-size:12px;
|
92 |
}
|
93 |
-
.mage-admin-form-row-submit{
|
94 |
-
text-align: center;
|
95 |
-
margin:0 auto;
|
96 |
-
width:296px;
|
97 |
-
margin-top:20px;
|
98 |
-
margin-bottom:20px;
|
99 |
|
100 |
-
|
101 |
-
.
|
102 |
-
|
103 |
-
|
104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
text-align: center;
|
106 |
-
|
107 |
-
|
108 |
-
#
|
109 |
-
#step-three{display:none;}
|
110 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
|
112 |
-
.
|
113 |
-
|
114 |
-
|
|
|
|
|
|
|
|
|
|
|
115 |
|
|
|
|
|
|
|
|
|
116 |
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
}
|
|
|
130 |
#incomplete-sync{
|
131 |
color:#f07f75;
|
132 |
}
|
133 |
#error-message .subtext span{
|
134 |
font-weight:bold;
|
135 |
}
|
136 |
-
|
137 |
-
#mage-admin-footer{
|
138 |
-
text-align: center;
|
139 |
-
font-size:11px;
|
140 |
-
color:#aaa;
|
141 |
-
padding:5px 0;
|
142 |
-
}
|
143 |
</style>
|
|
|
144 |
<script type="text/javascript">
|
145 |
$.noConflict();
|
146 |
jQuery(document).ready(function(){
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
jQuery('#error-message').show();
|
181 |
-
jQuery('#last-order-synced').text(obj.last);
|
182 |
-
jQuery('#order-count').text(obj.total);
|
183 |
-
}
|
184 |
-
else{
|
185 |
-
jQuery('#error-message').hide();
|
186 |
-
}
|
187 |
-
})
|
188 |
-
.fail(function(data) {
|
189 |
-
console.log(data);
|
190 |
-
console.log("OUTPUT");
|
191 |
-
setTimeout(runSync, 200);
|
192 |
-
})
|
193 |
-
.always(function(data){
|
194 |
-
console.log(data);
|
195 |
-
|
196 |
-
jQuery('#step-two').hide();
|
197 |
-
jQuery('#step-three').show();
|
198 |
-
});
|
199 |
-
}
|
200 |
-
else{
|
201 |
-
// add error classes if empty
|
202 |
-
if(jQuery('input#org_id').val().length < 1){jQuery('input#org_id').addClass('error');}
|
203 |
-
if(jQuery('input#api_token').val().length < 1){jQuery('input#api_token').addClass('error');}
|
204 |
-
}
|
205 |
-
});
|
206 |
-
|
207 |
-
|
208 |
-
// secondary Comr.se sync
|
209 |
-
jQuery('#comrse-submit-update').click(function runUpdate(){
|
210 |
-
if(jQuery('input#org_id_update').val().length > 1 && jQuery('input#api_token_update').val().length > 1){
|
211 |
-
jQuery('#step-three').hide();
|
212 |
-
jQuery('#step-two').show();
|
213 |
|
214 |
jQuery.ajax({
|
215 |
url: "<?php echo $this->getUrl('*/*/post'); ?>",
|
216 |
type: "POST",
|
217 |
data: {
|
218 |
form_key: "<?php echo Mage::getSingleton('core/session')->getFormKey() ?>",
|
219 |
-
org_id: jQuery('input#
|
220 |
-
api_token: jQuery('input#
|
221 |
-
|
222 |
-
reset_products: jQuery('input#reset-product-sync').val()
|
223 |
}
|
224 |
}).done(function(data) {
|
225 |
-
jQuery('
|
226 |
-
jQuery('
|
227 |
-
jQuery('#
|
228 |
-
jQuery('
|
229 |
-
|
230 |
-
|
231 |
-
if(obj.code == 'order_sync_failure'){
|
232 |
-
jQuery('#error-message').show();
|
233 |
-
jQuery('#last-order-synced').text(obj.last);
|
234 |
-
jQuery('#order-count').text(obj.total);
|
235 |
-
}
|
236 |
-
else{
|
237 |
-
jQuery('#error-message').hide();
|
238 |
-
}
|
239 |
})
|
240 |
.fail(function(data) {
|
241 |
-
|
|
|
242 |
})
|
243 |
.always(function(data){
|
244 |
console.log(data);
|
245 |
-
jQuery('#step-two').hide();
|
246 |
-
jQuery('#step-three').show();
|
247 |
});
|
248 |
-
// remove error classes if has them
|
249 |
-
jQuery('input#org_id_update').removeClass('error');
|
250 |
-
jQuery('input#api_token_update').removeClass('error');
|
251 |
}
|
252 |
else{
|
253 |
// add error classes if empty
|
254 |
-
if(jQuery('input#
|
255 |
-
if(jQuery('input#
|
256 |
}
|
257 |
});
|
|
|
|
|
|
|
|
|
|
|
258 |
});
|
259 |
</script>
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
<div
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
<
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
<div class="mage-admin-form-row">
|
282 |
-
<div class="mage-admin-form-row-label">Comrse API Token</div>
|
283 |
-
<div class="mage-admin-form-row-field">
|
284 |
-
<input class="input-text required-entry" name="api_token" id="api_token" value="<?php echo $data['api_token']; ?>" />
|
285 |
-
</div>
|
286 |
-
</div>
|
287 |
-
<div class="mage-admin-form-row">
|
288 |
-
<div class="mage-admin-form-row-submit">
|
289 |
-
<input type="button" class="mage-submit comrse-submit-trigger" name="submit-comrse" id="comrse-submit" value="Submit" />
|
290 |
-
</div>
|
291 |
-
</div>
|
292 |
-
</fieldset>
|
293 |
-
</form>
|
294 |
-
</div>
|
295 |
-
</div>
|
296 |
-
<!-- STEP TWO -->
|
297 |
-
<div id="step-two">
|
298 |
-
<div class="mage-admin-header">Good Job!</div>
|
299 |
-
<div class="mage-admin-subtext">
|
300 |
-
That should do it. Go ahead and take a coffee<br />
|
301 |
-
break or watch <a href="http://www.youtube.com/watch?v=Sagg08DrO5U" target="_blank">this</a> while we SYNC your store.
|
302 |
-
</div>
|
303 |
-
<div class="mage-clock">
|
304 |
-
<img src="//comrse-static.s3.amazonaws.com/images/web/mage_admin_clock.png" />
|
305 |
-
</div>
|
306 |
-
<div class="mage-loader">
|
307 |
-
<img src="//comrse-static.s3.amazonaws.com/images/web/magento_loading_bar.gif" />
|
308 |
-
</div>
|
309 |
-
<div class="mage-admin-form-row">
|
310 |
-
<div class="mage-admin-form-row-submit">
|
311 |
-
<input type="button" class="mage-submit" name="back-to-comrse" id="cback-to-comrse" value="Return to Comr.se" />
|
312 |
</div>
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
<div class="
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
</div>
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
<div class="mage-admin-form-row">
|
327 |
-
<div class="mage-admin-form-row-label">Organization ID</div>
|
328 |
-
<div class="mage-admin-form-row-field">
|
329 |
-
<input class="input-text required-entry" name="org_id" id="org_id_update" value="<?php echo $data['org_id']; ?>" />
|
330 |
-
</div>
|
331 |
-
</div>
|
332 |
-
<div class="mage-admin-form-row">
|
333 |
-
<div class="mage-admin-form-row-label">Comrse API Token</div>
|
334 |
-
<div class="mage-admin-form-row-field">
|
335 |
-
<input class="input-text required-entry" name="api_token" id="api_token_update" value="<?php echo $data['api_token']; ?>" />
|
336 |
-
</div>
|
337 |
-
</div>
|
338 |
-
<div class="mage-admin-form-row">
|
339 |
-
<div id="error-message">
|
340 |
-
<div class="subtext">
|
341 |
-
<span id="incomplete-sync">Incomplete Sync:</span> <span id="last-order-synced"></span> of <span id="order-count"></span> orders successfully synced. Please click 'Update Settings' to resume sync.
|
342 |
-
</div>
|
343 |
-
</div>
|
344 |
-
<div class="mage-admin-form-row-submit">
|
345 |
-
<?php
|
346 |
-
try{
|
347 |
-
error_reporting(0);
|
348 |
-
$org_data = Mage::getModel('comrsesync/comrseconnect')->load(1);
|
349 |
-
?>
|
350 |
-
<input type="hidden" name="total-orders" value="<?php echo $org_data->getTotalOrders(); ?>" />
|
351 |
-
<input type="hidden" name="last-synced" value="<?php echo $org_data->getLastOrderSynced(); ?>" />
|
352 |
-
<?php
|
353 |
-
}
|
354 |
-
catch(Exception $e){
|
355 |
-
@mail("rhen@comr.se", "Plugin Error", $e->getMessage());
|
356 |
-
}
|
357 |
-
?>
|
358 |
-
<input type="hidden" name="reset-order-sync" id="reset-order-sync" value="0" />
|
359 |
-
<input type="hidden" name="reset-product-sync" id="reset-product-sync" value="0" />
|
360 |
-
<input type="button" class="mage-submit comrse-submit-trigger" name="submit-comrse" id="comrse-submit-update" value="Update Settings" />
|
361 |
-
</div>
|
362 |
-
</div>
|
363 |
-
</fieldset>
|
364 |
-
</form>
|
365 |
</div>
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
370 |
</div>
|
371 |
-
</div>
|
7 |
Mage::log("Comrse: ".$e->getMessage());
|
8 |
}
|
9 |
?>
|
10 |
+
<script src="https://code.jquery.com/jquery-2.2.2.min.js" integrity="sha256-36cp2Co+/62rEAAYHLmRCPIych47CvdM+uTBJwSzWjI=" crossorigin="anonymous"></script>
|
11 |
<link href='//fonts.googleapis.com/css?family=Rokkitt:400,700' rel='stylesheet' type='text/css'>
|
12 |
+
<link href='//maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css' rel='stylesheet' type='text/css' />
|
13 |
<style type="text/css">
|
14 |
+
|
15 |
+
|
16 |
+
.comrse-wrapper ol, .comrse-wrapper ul {
|
17 |
+
list-style: none;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
}
|
19 |
+
.comrse-wrapper blockquote, .comrse-wrapper q {
|
20 |
+
quotes: none;
|
21 |
}
|
22 |
+
.comrse-wrapper blockquote:before, .comrse-wrapper blockquote:after,
|
23 |
+
q:before, q:after {
|
24 |
+
content: '';
|
25 |
+
content: none;
|
26 |
}
|
27 |
+
.comrse-wrapper table {
|
28 |
+
border-collapse: collapse;
|
29 |
+
border-spacing: 0;
|
|
|
|
|
|
|
|
|
30 |
}
|
31 |
+
|
32 |
+
.comrse-settings-back {
|
33 |
+
font-size:11px;
|
34 |
text-align: center;
|
35 |
+
margin-top:10px;
|
36 |
+
color:#999;
|
37 |
+
cursor: pointer;
|
38 |
+
display:none;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
+
|
42 |
+
.comrse-wrapper {
|
43 |
+
font-family: "Open Sans", "Helvetica Neue", "Helvetica", "Arial", sans-serif;
|
44 |
+
font-size: 15px;
|
45 |
+
line-height: 21px;
|
46 |
+
color: #556270;
|
47 |
+
background: #fff;
|
48 |
+
-webkit-font-smoothing: antialiased;
|
49 |
+
-moz-osx-font-smoothing: grayscale; }
|
50 |
+
|
51 |
+
.comrse-wrapper p {
|
52 |
+
font-size: .9em;
|
53 |
+
line-height: 1.5em;
|
54 |
+
display: block; }
|
55 |
+
|
56 |
+
.comrse-wrapper a.return {
|
57 |
+
width: 75%;
|
58 |
+
height: auto;
|
59 |
+
padding: 7px 0px;
|
60 |
+
text-align: center;
|
61 |
+
background: #2DB89A;
|
62 |
+
display: block;
|
63 |
+
color: #FFFFFF;
|
64 |
+
text-decoration: none;
|
65 |
+
font-weight: 600;
|
66 |
+
border-radius: 20px;
|
67 |
+
margin: 0px auto;
|
68 |
+
transition: .2s ease-in-out;
|
69 |
+
-webkit-transition: .2s ease-in-out;
|
70 |
+
-moz-transition: .2s ease-in-out;
|
71 |
+
-o-transition: .2s ease-in-out; }
|
72 |
+
a.return:hover {
|
73 |
+
background: #22c3a1; }
|
74 |
+
|
75 |
+
.comrse-wrapper {
|
76 |
+
width: 100%;
|
77 |
+
height: auto;
|
78 |
+
max-width: 1200px;
|
79 |
+
margin: 0px auto;
|
80 |
+
padding: 60px 0px;
|
81 |
+
display: block; }
|
82 |
+
.comrse-wrapper .update-container, .comrse-wrapper .success-container {
|
83 |
+
width: 465px;
|
84 |
+
height: auto;
|
85 |
+
display: block;
|
86 |
+
margin: 0px auto; }
|
87 |
+
|
88 |
+
.comrse-wrapper .spinning-sync {
|
89 |
+
width: 100%;
|
90 |
+
height: auto;
|
91 |
+
margin-top: 30px;
|
92 |
+
margin-bottom: 30px; }
|
93 |
+
.comrse-wrapper .spinning-sync i {
|
94 |
text-align: center;
|
95 |
+
display: block;
|
96 |
+
font-size: 3em;
|
97 |
+
color: #2DB89A; }
|
|
|
98 |
|
99 |
+
.comrse-wrapper .form-container {
|
100 |
+
padding: 30px 0px; }
|
101 |
+
.comrse-wrapper .form-container input {
|
102 |
+
font-family: "Open Sans", "Helvetica Neue", "Helvetica", "Arial", sans-serif;
|
103 |
+
color: #556270;
|
104 |
+
font-size: .85em;
|
105 |
+
transition: .2s ease-in-out;
|
106 |
+
-webkit-transition: .2s ease-in-out;
|
107 |
+
-moz-transition: .2s ease-in-out;
|
108 |
+
-o-transition: .2s ease-in-out; }
|
109 |
+
.comrse-wrapper .form-container input:focus {
|
110 |
+
outline: none; }
|
111 |
+
.comrse-wrapper .form-container .sync-inventory {
|
112 |
+
width: 100%;
|
113 |
+
height: 20px;
|
114 |
+
text-align: center; }
|
115 |
+
.comrse-wrapper .form-container .sync-inventory .info-bubble {
|
116 |
+
width: 90%;
|
117 |
+
height: auto;
|
118 |
+
padding: 15px 5%;
|
119 |
+
background: #fbfbfc;
|
120 |
+
border: 1px solid rgba(85, 98, 112, 0.2);
|
121 |
+
border-radius: 3px;
|
122 |
+
position: relative;
|
123 |
+
margin-top: 10px; }
|
124 |
+
.comrse-wrapper .form-container .sync-inventory .info-bubble .bubble-arrow {
|
125 |
+
width: 19px;
|
126 |
+
height: 8px;
|
127 |
+
display: block;
|
128 |
+
background: url("http://dwio61axsaytx.cloudfront.net/images/web/magento_sprite.png") 0px -39px;
|
129 |
+
position: absolute;
|
130 |
+
top: -7.5px;
|
131 |
+
right: 143px; }
|
132 |
+
.comrse-wrapper .form-container .sync-inventory .info-bubble p {
|
133 |
+
font-size: .75em;
|
134 |
+
font-weight: 400;
|
135 |
+
text-align: left; }
|
136 |
+
.comrse-wrapper .form-container .sync-inventory .info-bubble a.close {
|
137 |
+
color: rgba(85, 98, 112, 0.5);
|
138 |
+
display: inline-block;
|
139 |
+
position: absolute;
|
140 |
+
top: 4px;
|
141 |
+
right: 7px; }
|
142 |
+
.comrse-wrapper .form-container .checkbox-container {
|
143 |
+
display: inline-block;
|
144 |
+
position: relative; }
|
145 |
+
.comrse-wrapper .form-container .checkbox-container .box {
|
146 |
+
position: absolute;
|
147 |
+
padding:0!important;
|
148 |
+
width: 11px;
|
149 |
+
height: 11px;
|
150 |
+
top: 5px;
|
151 |
+
left: 11px;
|
152 |
+
border-radius: 2px;
|
153 |
+
background: #FFFFFF;
|
154 |
+
border: 1px solid rgba(85, 98, 112, 0.5);
|
155 |
+
z-index: 0; }
|
156 |
+
.comrse-wrapper .form-container .checkbox-container input[type="checkbox"].check {
|
157 |
+
border: 0;
|
158 |
+
clip: rect(0 0 0 0);
|
159 |
+
height: 1px;
|
160 |
+
margin: -1px;
|
161 |
+
overflow: hidden;
|
162 |
+
padding: 0;
|
163 |
+
position: absolute;
|
164 |
+
width: 1px; }
|
165 |
+
.comrse-wrapper .form-container .checkbox-container input[type=checkbox].check ~ label:before {
|
166 |
+
font-family: FontAwesome;
|
167 |
+
content: "";
|
168 |
+
display: inline-block;
|
169 |
+
font-size: 1.1em;
|
170 |
+
border-radius: 2px;
|
171 |
+
width: 11px;
|
172 |
+
height: 11px;
|
173 |
+
cursor: pointer;
|
174 |
+
position: absolute;
|
175 |
+
left: 12px;
|
176 |
+
z-index: 10; }
|
177 |
+
.comrse-wrapper .form-container .checkbox-container input[type=checkbox].check:checked ~ label:before {
|
178 |
+
content: "\f00c";
|
179 |
+
font-size: 1.1em;
|
180 |
+
color: #2DB89A; }
|
181 |
+
.comrse-wrapper .form-container .checkbox-container label {
|
182 |
+
font-size: .75em;
|
183 |
+
font-weight: 700;
|
184 |
+
display: inline-block;
|
185 |
+
margin-left: 30px;
|
186 |
+
cursor: pointer; }
|
187 |
+
.form-container .checkbox-container label a {
|
188 |
+
font-size: 1.2em; }
|
189 |
+
.comrse-wrapper .form-container .input-container {
|
190 |
+
width: 100%;
|
191 |
+
display: block;
|
192 |
+
position: relative;
|
193 |
+
margin-bottom: 12px; }
|
194 |
+
.comrse-wrapper .form-container .input-container input[type="text"], .comrse-wrapper .form-container .input-container input[type="password"] {
|
195 |
+
width: 90%;
|
196 |
+
padding: 10px 5%;
|
197 |
+
background: rgba(255, 255, 255, 0.9);
|
198 |
+
border: 1px solid rgba(85, 98, 112, 0.2);
|
199 |
+
border-radius: 20px; }
|
200 |
+
.comrse-wrapper .form-container .input-container input[type="text"]:focus, .comrse-wrapper .form-container .input-container input[type="password"]:focus {
|
201 |
+
border: 1px solid rgba(85, 98, 112, 0.4);
|
202 |
+
background: white; }
|
203 |
+
.comrse-wrapper .form-container .input-container input[type="button"] {
|
204 |
+
width: 100%;
|
205 |
+
padding: 10px 0;
|
206 |
+
background: #2DB89A;
|
207 |
+
border-radius: 20px;
|
208 |
+
text-align: center;
|
209 |
+
border: none;
|
210 |
+
color: #FFFFFF;
|
211 |
+
font-weight: 600;
|
212 |
+
cursor: pointer;
|
213 |
+
transition: .2s ease-in-out;
|
214 |
+
-webkit-transition: .2s ease-in-out;
|
215 |
+
-moz-transition: .2s ease-in-out;
|
216 |
+
-o-transition: .2s ease-in-out; }
|
217 |
+
.comrse-wrapper .form-container .input-container input[type="button"]:hover {
|
218 |
+
background: #22c3a1; }
|
219 |
+
.comrse-wrapper .form-container .input-container .show {
|
220 |
+
width: 22%;
|
221 |
+
padding: 8px 0 7px 0;
|
222 |
+
position: absolute;
|
223 |
+
right: -1px;
|
224 |
+
top: 0px;
|
225 |
+
background: #d0d5db;
|
226 |
+
border-top-right-radius: 20px;
|
227 |
+
border-bottom-right-radius: 20px; }
|
228 |
|
229 |
+
.comrse-wrapper h1 {
|
230 |
+
width: 160px;
|
231 |
+
height: 37px;
|
232 |
+
margin: 0px auto;
|
233 |
+
display: block;
|
234 |
+
background: url("http://dwio61axsaytx.cloudfront.net/images/web/magento_sprite.png") 0px -1px; }
|
235 |
+
h1 span {
|
236 |
+
display: none; }
|
237 |
|
238 |
+
.comrse-wrapper p.sub-head {
|
239 |
+
text-align: center;
|
240 |
+
line-height: 1.5em;
|
241 |
+
font-size: .9em; }
|
242 |
|
243 |
+
.comrse-wrapper a {
|
244 |
+
color: #2DB89A; }
|
245 |
+
|
246 |
+
.comrse-wrapper h2 {
|
247 |
+
font-size: 1.3em;
|
248 |
+
line-height: 1.5em;
|
249 |
+
font-weight: 700;
|
250 |
+
color: #2DB89A;
|
251 |
+
display: block;
|
252 |
+
text-align: center;
|
253 |
+
text-transform: uppercase;
|
254 |
+
margin-top: 40px;
|
255 |
+
margin-bottom: 5px; }
|
256 |
+
.comrse-wrapper h2 i {
|
257 |
+
margin-right: 5px; }
|
258 |
+
|
259 |
+
.input-error{
|
260 |
+
border-color:#f07f75!important;
|
261 |
}
|
262 |
+
|
263 |
#incomplete-sync{
|
264 |
color:#f07f75;
|
265 |
}
|
266 |
#error-message .subtext span{
|
267 |
font-weight:bold;
|
268 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
269 |
</style>
|
270 |
+
|
271 |
<script type="text/javascript">
|
272 |
$.noConflict();
|
273 |
jQuery(document).ready(function(){
|
274 |
+
jQuery('#info-trigger').click(function(e) {
|
275 |
+
e.preventDefault();
|
276 |
+
jQuery('.info-bubble').fadeToggle('fast');
|
277 |
+
});
|
278 |
+
|
279 |
+
jQuery('a.close').click(function(e) {
|
280 |
+
e.preventDefault();
|
281 |
+
jQuery('.info-bubble').fadeOut('fast');
|
282 |
+
});
|
283 |
+
|
284 |
+
jQuery('input#show').change(function(){
|
285 |
+
if (jQuery(this).is(':checked'))
|
286 |
+
jQuery('#api_token').attr('type', 'text');
|
287 |
+
else
|
288 |
+
jQuery('#api_token').attr('type', 'password')
|
289 |
+
});
|
290 |
+
|
291 |
+
// initial Comr.se sync
|
292 |
+
jQuery('#comrse-submit').unbind('click').click(function runSync(){
|
293 |
+
if(jQuery('input#org_id').val().length > 1 && jQuery('input#api_token').val().length > 1){
|
294 |
+
jQuery('.update-container').hide();
|
295 |
+
jQuery('.success-container').show();
|
296 |
+
|
297 |
+
jQuery('input#org_id').removeClass('input-error');
|
298 |
+
jQuery('input#api_token').removeClass('input-error');
|
299 |
+
|
300 |
+
|
301 |
+
jQuery('.sync-message').text('Syncing...');
|
302 |
+
jQuery('.sync-message-subtext').html('That should do it. Go ahead and take a coffee break <br>while we sync your store.</p>');
|
303 |
+
jQuery('#syncing-icon-action').addClass('fa-refresh');
|
304 |
+
jQuery('#syncing-icon-action').addClass('fa-spin');
|
305 |
+
jQuery('#syncing-icon-action').removeClass('fa-check-circle-o');
|
306 |
+
jQuery('.comrse-settings-back').hide();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
307 |
|
308 |
jQuery.ajax({
|
309 |
url: "<?php echo $this->getUrl('*/*/post'); ?>",
|
310 |
type: "POST",
|
311 |
data: {
|
312 |
form_key: "<?php echo Mage::getSingleton('core/session')->getFormKey() ?>",
|
313 |
+
org_id: jQuery('input#org_id').val(),
|
314 |
+
api_token: jQuery('input#api_token').val(),
|
315 |
+
resync_org: jQuery('input#sync').is(':checked')
|
|
|
316 |
}
|
317 |
}).done(function(data) {
|
318 |
+
jQuery('.sync-message').text('Success!');
|
319 |
+
jQuery('.sync-message-subtext').html('That should do it. Click <strong>Return to Comr.se</strong> below<br>to start using your account.');
|
320 |
+
jQuery('#syncing-icon-action').removeClass('fa-refresh');
|
321 |
+
jQuery('#syncing-icon-action').removeClass('fa-spin');
|
322 |
+
jQuery('#syncing-icon-action').addClass('fa-check-circle-o');
|
323 |
+
jQuery('.comrse-settings-back').show();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
324 |
})
|
325 |
.fail(function(data) {
|
326 |
+
console.log(data);
|
327 |
+
setTimeout(runSync, 200);
|
328 |
})
|
329 |
.always(function(data){
|
330 |
console.log(data);
|
|
|
|
|
331 |
});
|
|
|
|
|
|
|
332 |
}
|
333 |
else{
|
334 |
// add error classes if empty
|
335 |
+
if(jQuery('input#org_id').val().length < 1){jQuery('input#org_id').addClass('input-error');}
|
336 |
+
if(jQuery('input#api_token').val().length < 1){jQuery('input#api_token').addClass('input-error');}
|
337 |
}
|
338 |
});
|
339 |
+
|
340 |
+
jQuery('.comrse-settings-back').click(function(){
|
341 |
+
jQuery('.update-container').show();
|
342 |
+
jQuery('.success-container').hide();
|
343 |
+
});
|
344 |
});
|
345 |
</script>
|
346 |
+
|
347 |
+
<div class="comrse-wrapper">
|
348 |
+
<h1><span>Commerce Inc.</span></h1>
|
349 |
+
|
350 |
+
<div class="update-container">
|
351 |
+
<h2><i class="fa fa-refresh"></i><span>sync</span></h2>
|
352 |
+
<p class="sub-head">Enter your Commerce account credentials below.</p>
|
353 |
+
|
354 |
+
<div class="form-container">
|
355 |
+
<form id="magento-form" name="edit_form" method="post" action="<?php echo $this->getUrl('*/*/post'); ?>">
|
356 |
+
<input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
|
357 |
+
<fieldset id="my-fieldset">
|
358 |
+
<div class="input-container"><input class="input-text required-entry" type="text" id="org_id" placeholder="Organization ID" value="<?php echo $data['org_id']; ?>"></div>
|
359 |
+
<div class="input-container">
|
360 |
+
<input class="input-text required-entry" type="password" id="api_token" name="api_token" value="<?php echo $data['api_token']; ?>" placeholder="Commerce API Token">
|
361 |
+
<div class="show">
|
362 |
+
<div class="checkbox-container">
|
363 |
+
<input id="show" type="checkbox" class="check">
|
364 |
+
<label for="show"><span>Show</span></label>
|
365 |
+
<div class="box"></div>
|
366 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
367 |
</div>
|
368 |
+
</div>
|
369 |
+
<div class="input-container"><input type="button" name="name" class="mage-submit comrse-submit-trigger" name="submit-comrse" id="comrse-submit" value="Update Account Settings"></div>
|
370 |
+
|
371 |
+
<div class="sync-inventory">
|
372 |
+
<div class="checkbox-container">
|
373 |
+
<input id="sync" name="resync_org" type="checkbox" value="1" class="check">
|
374 |
+
<label for="sync"><span>Resync product inventory</span> <a id="info-trigger" href=""><i class="fa fa-question-circle"></i></a></label>
|
375 |
+
<div class="box"></div>
|
376 |
</div>
|
377 |
+
|
378 |
+
<div class="info-bubble" style="display: none;">
|
379 |
+
<div class="bubble-arrow"></div>
|
380 |
+
<p>If you are having issues with your store updating, you may need a fresh sync of your inventory. To do this, check the box above. <a class="close" href=""><i class="fa fa-times"></i></a></p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
381 |
</div>
|
382 |
+
</div>
|
383 |
+
</fieldset>
|
384 |
+
</form>
|
385 |
+
</div>
|
386 |
+
</div><!-- End of Update Container -->
|
387 |
+
|
388 |
+
<div class="success-container" style="display:none;">
|
389 |
+
<h2><span class="sync-message">Syncing...</span></h2>
|
390 |
+
<p class="sub-head sync-message-subtext">That should do it. Go ahead and take a coffee break <br>while we sync your store.</p>
|
391 |
+
|
392 |
+
<div class="spinning-sync">
|
393 |
+
<i id="syncing-icon-action" class="fa fa-refresh fa-spin"></i>
|
394 |
+
</div>
|
395 |
+
|
396 |
+
<a href="http://sell.comr.se" class="return" target="_blank">Return to Comr.se</a>
|
397 |
+
<div class="comrse-settings-back"><span><i class="fa fa-caret-left"></i> Commerce Settings</span></div>
|
398 |
</div>
|
399 |
+
</div>
|
package.xml
CHANGED
@@ -1,18 +1,20 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Comrse_ComrseSync</name>
|
4 |
-
<version>1.1.
|
5 |
<stability>stable</stability>
|
6 |
-
<license>LGPL</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Comr.se Integration</summary>
|
10 |
-
<description>
|
11 |
-
<notes>Merchant must currently have an existing Comr.se account
|
12 |
-
|
13 |
-
|
14 |
-
<
|
15 |
-
<
|
|
|
|
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Comrse_ComrseSync</name>
|
4 |
+
<version>1.1.6</version>
|
5 |
<stability>stable</stability>
|
6 |
+
<license uri="http://comr.se/terms-of-use/">LGPL</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Comr.se Integration</summary>
|
10 |
+
<description>Commerce enables retailers and manufacturers to publish, manage and optimize their merchandise sales across a suite of Buy Now channels, including Twitter, Facebook, Amazon, eBay and more. Commerce is a cloud-based BUY NOW platform with a complete ecosystem of integrations to deliver true omni-channel commerce for your brand - simplifying the value chain for merchants by connecting their existing Magento systems directly to Buy Now sales channels through a single integration. </description>
|
11 |
+
<notes>Merchant must currently have an existing Comr.se account.
|
12 |
+

|
13 |
+
- Add's 1.9.x support.</notes>
|
14 |
+
<authors><author><name>Nate Rogers</name><user>comrsecorp</user><email>nate@comr.se</email></author></authors>
|
15 |
+
<date>2016-04-05</date>
|
16 |
+
<time>18:36:59</time>
|
17 |
+
<contents><target name="magecommunity"><dir name="Comrse"><dir name="ComrseSync"><dir name="Block"><dir name="Adminhtml"><file name="ComrseSyncbackend.php" hash="87404c789baccdd3624b6fc13021f0ac"/></dir></dir><dir name="Helper"><file name="Apiuser.php" hash="6ff4c585e4a61c496d7063f4a1a49308"/><file name="Customer.php" hash="d8e68837e8002f478e2ff49dd0368fca"/><file name="Data.php" hash="9e23daf17a3a747a6d3e8c8f369afd0e"/><file name="Order.php" hash="bba328562892a44af47acd859f1129ae"/><file name="Product.php" hash="d15f04dce60b1723575bb8a0253aa535"/></dir><dir name="Model"><dir name="Carrier"><file name="Comrseship.php" hash="f880843264d5cc7d2aa7649b43f28315"/><file name="Config.php" hash="f9134a251c055d7558cace014bf8a768"/></dir><dir name="Comrse"><file name="AllowedValue.php" hash="401b5531ea87dd31a509551ac1f2d98f"/><file name="Currency.php" hash="1caf1ad6f369dd5a4a0901a98b2ef57a"/><file name="Customer.php" hash="bf65183eb9cf5b5765d9f958e0eea71d"/><file name="CustomerAddress.php" hash="c29a08709cc3627c9d0c045bc7797db1"/><file name="CustomerContact.php" hash="bd52728de491b59ea63f8ba2afc4a649"/><file name="Dimension.php" hash="f32320adf5c027188f8887c081dfbbe7"/><file name="Geo.php" hash="9063ca0c5e066a033e6a2ed8dab056af"/><file name="Image.php" hash="cc9583867487bf0ef51b31d0747da6a7"/><file name="MetricEvent.php" hash="42518c8e351c48d34678db1a645369fb"/><file name="Order.php" hash="ac21205606166e964fc4bd33856af85a"/><file name="OrderItem.php" hash="0776165a67e5c1dafe102a073961e9cf"/><file name="OrderItemAttribute.php" hash="d571aa12b90bd460b8b44d85837686b2"/><file name="Phone.php" hash="82f9371dc0dd15ec6ef4aa9eddc7ce02"/><file name="Price.php" hash="e37ec55c77bf1a4c272837353db5f7f2"/><file name="Product.php" hash="ff130b1428c141a51f831947d55daed5"/><file name="ProductCategory.php" hash="a2affc2c0bd8bf7fd2d07336b8487b63"/><file name="ProductOption.php" hash="35f0acbc2378523f56c6a6c08bac169b"/><file name="Total.php" hash="7f0e7da9a7450c672583cd026fb4a23a"/><file name="Weight.php" hash="7383193b8504cc78d88d8e6ca52de6f3"/></dir><file name="Comrseconnect.php" hash="d4c6c8dd83aeeca207178a8db8182a90"/><file name="Config.php" hash="eda5ffc8606ead008fadef83e5d8448f"/><file name="Data.php" hash="a5e549356ab8afeb9dc443c9178b382c"/><file name="Datasync.php" hash="ce909c2a9b2377e1581a41d9b96621c0"/><file name="Product.php" hash="6e3b6fa05694e1680c95ab3133898efd"/><dir name="Resource"><dir name="Comrseconnect"><file name="Collection.php" hash="1c7ea37cfb2a7772170a613f0db62be0"/></dir><file name="Comrseconnect.php" hash="48b49b4ca1d8f77e963720cb60958541"/></dir><dir name="Sales"><dir name="Quote"><file name="Address.php" hash="9885bc590edff28c30a6dbf6df15a792"/></dir></dir><dir name="Shipping"><file name="Config.php" hash="4ace7ce48106423f4e3630cd1f03dcd2"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="ComrsesyncbackendController.php" hash="44c39bf08c4f4d49c6c0917bb5c6e23a"/></dir><file name="Config.php" hash="e8d5553cb01b38b44987b3c28ad2945e"/></dir><dir name="etc"><file name="config.xml" hash="9cffa9b8adb23daf676957f6e5e94e30"/><file name="system.xml" hash="5977026ecc43c7507154105998913a70"/></dir><dir name="sql"><dir name="comrsesync_setup"><file name="mysql4-install-1.1.5.php" hash="81dbeee62b8195a19150ff679e1c06be"/><file name="mysql4-install-1.1.6.php" hash="94686ddfa6bcc4b8069ff1bfba1378cf"/><file name="mysql4-upgrade-1.1.1-1.1.2.php" hash="90383897e6ca7adf2854bfbb1cd9c3ef"/><file name="mysql4-upgrade-1.1.2-1.1.3.php" hash="84bfc7ca32b4f36032088bdd87d85fa1"/><file name="mysql4-upgrade-1.1.3-1.1.5.php" hash="2f3334f1a717bb5b912bb44e2fb05ffd"/><file name="mysql4-upgrade-1.1.3-1.1.6.php" hash="a44da2ef88efe1ad079be77bb030e51d"/><file name="mysql4-upgrade-1.1.4-1.1.5.php" hash="2f3334f1a717bb5b912bb44e2fb05ffd"/><file name="mysql4-upgrade-1.1.4-1.1.6.php" hash="244836b044b17c536c92c436b403e8c2"/><file name="mysql4-upgrade-1.1.5-1.1.6.php" hash="d425cac540896c8dd8896fabc65d6eb7"/><file name="mysql4-upgrade-1.1.6.0-1.1.6.php" hash="d425cac540896c8dd8896fabc65d6eb7"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Comrse_ComrseSync.xml" hash="9bae8bbee88808f46e1af8d4e023c47f"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="comrsesync.xml" hash="e0efc2bb875ff1af895ab3936822a1bf"/></dir><dir name="template"><dir name="comrsesync"><file name="comrsesyncbackend.phtml" hash="0d949d5678f97e8035e577c05dc11494"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="comrsesync.xml" hash="218c252a1214388cd49b73c1acf80dcd"/></dir><dir name="template"><dir name="comrsesync"><file name="comrsescript.phtml" hash="1720137bcea9e88179235c73d1d4bc96"/></dir></dir></dir></dir></dir></target></contents>
|
18 |
<compatible/>
|
19 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
20 |
</package>
|