Version Notes
Merchant must currently have an existing Comr.se account.
Download this release
Release Info
Developer | Nate Rogers |
Extension | Comrse_ComrseSync |
Version | 1.1.5.3 |
Comparing to | |
See all releases |
Version 1.1.5.3
- app/code/community/Comrse/ComrseSync/Block/Adminhtml/ComrseSyncbackend.php +5 -0
- app/code/community/Comrse/ComrseSync/Helper/Apiuser.php +62 -0
- app/code/community/Comrse/ComrseSync/Helper/Data.php +68 -0
- app/code/community/Comrse/ComrseSync/Helper/Order.php +201 -0
- app/code/community/Comrse/ComrseSync/Helper/Product.php +581 -0
- app/code/community/Comrse/ComrseSync/Model/Carrier/Comrseship.php +98 -0
- app/code/community/Comrse/ComrseSync/Model/Carrier/Config.php +30 -0
- app/code/community/Comrse/ComrseSync/Model/Comrse/AllowedValue.php +78 -0
- app/code/community/Comrse/ComrseSync/Model/Comrse/Currency.php +30 -0
- app/code/community/Comrse/ComrseSync/Model/Comrse/Customer.php +43 -0
- app/code/community/Comrse/ComrseSync/Model/Comrse/CustomerAddress.php +187 -0
- app/code/community/Comrse/ComrseSync/Model/Comrse/CustomerContact.php +69 -0
- app/code/community/Comrse/ComrseSync/Model/Comrse/Dimension.php +102 -0
- app/code/community/Comrse/ComrseSync/Model/Comrse/Geo.php +42 -0
- app/code/community/Comrse/ComrseSync/Model/Comrse/Image.php +77 -0
- app/code/community/Comrse/ComrseSync/Model/Comrse/MetricEvent.php +189 -0
- app/code/community/Comrse/ComrseSync/Model/Comrse/Order.php +158 -0
- app/code/community/Comrse/ComrseSync/Model/Comrse/OrderItem.php +204 -0
- app/code/community/Comrse/ComrseSync/Model/Comrse/OrderItemAttribute.php +60 -0
- app/code/community/Comrse/ComrseSync/Model/Comrse/Phone.php +61 -0
- app/code/community/Comrse/ComrseSync/Model/Comrse/Price.php +48 -0
- app/code/community/Comrse/ComrseSync/Model/Comrse/Product.php +200 -0
- app/code/community/Comrse/ComrseSync/Model/Comrse/ProductCategory.php +172 -0
- app/code/community/Comrse/ComrseSync/Model/Comrse/ProductOption.php +97 -0
- app/code/community/Comrse/ComrseSync/Model/Comrse/Total.php +36 -0
- app/code/community/Comrse/ComrseSync/Model/Comrse/Weight.php +49 -0
- app/code/community/Comrse/ComrseSync/Model/Comrseconnect.php +16 -0
- app/code/community/Comrse/ComrseSync/Model/Config.php +22 -0
- app/code/community/Comrse/ComrseSync/Model/Data.php +83 -0
- app/code/community/Comrse/ComrseSync/Model/Datasync.php +281 -0
- app/code/community/Comrse/ComrseSync/Model/Product.php +1051 -0
- app/code/community/Comrse/ComrseSync/Model/Resource/Comrseconnect.php +9 -0
- app/code/community/Comrse/ComrseSync/Model/Resource/Comrseconnect/Collection.php +7 -0
- app/code/community/Comrse/ComrseSync/Model/Sales/Quote/Address.php +62 -0
- app/code/community/Comrse/ComrseSync/Model/Shipping/Config.php +31 -0
- app/code/community/Comrse/ComrseSync/controllers/Adminhtml/ComrsesyncbackendController.php +112 -0
- app/code/community/Comrse/ComrseSync/controllers/ComrsesyncbackendController.php +111 -0
- app/code/community/Comrse/ComrseSync/controllers/Config.php +19 -0
- app/code/community/Comrse/ComrseSync/etc/config.xml +201 -0
- app/code/community/Comrse/ComrseSync/etc/system.xml +129 -0
- app/code/community/Comrse/ComrseSync/sql/comrsesync_setup/mysql4-install-1.1.5.php +28 -0
- app/code/community/Comrse/ComrseSync/sql/comrsesync_setup/mysql4-upgrade-1.1.1-1.1.2.php +16 -0
- app/code/community/Comrse/ComrseSync/sql/comrsesync_setup/mysql4-upgrade-1.1.2-1.1.3.php +14 -0
- app/code/community/Comrse/ComrseSync/sql/comrsesync_setup/mysql4-upgrade-1.1.3-1.1.5.php +14 -0
- app/code/community/Comrse/ComrseSync/sql/comrsesync_setup/mysql4-upgrade-1.1.4-1.1.5.php +14 -0
- app/design/adminhtml/default/default/layout/comrsesync.xml +8 -0
- app/design/adminhtml/default/default/template/comrsesync/comrsesyncbackend.phtml +371 -0
- app/design/frontend/default/default/layout/comrsesync.xml +10 -0
- app/design/frontend/default/default/template/comrsesync/comrsescript.phtml +14 -0
- app/etc/modules/Comrse_ComrseSync.xml +10 -0
- package.xml +18 -0
app/code/community/Comrse/ComrseSync/Block/Adminhtml/ComrseSyncbackend.php
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Comrse_ComrseSync_Block_Adminhtml_ComrseSyncbackend extends Mage_Adminhtml_Block_Template {
|
4 |
+
|
5 |
+
}
|
app/code/community/Comrse/ComrseSync/Helper/Apiuser.php
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Comrse_ComrseSync_Helper_Apiuser extends Mage_Core_Helper_Abstract {
|
3 |
+
|
4 |
+
public function createApiUser($apiPassword) {
|
5 |
+
try
|
6 |
+
{
|
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 |
+
$comrse_exists = true;
|
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 |
+
Mage::getModel("api/rules")
|
30 |
+
->setRoleId($role->getId())
|
31 |
+
->setResources(array('all'))
|
32 |
+
->saveRel();
|
33 |
+
|
34 |
+
$user = Mage::getModel('api/user');
|
35 |
+
$user->setData(array(
|
36 |
+
'username' => 'comrse',
|
37 |
+
'firstname' => 'Comrse',
|
38 |
+
'lastname' => 'Admin',
|
39 |
+
'email' => 'info@comr.se',
|
40 |
+
'api_key' => $apiPassword,
|
41 |
+
'api_key_confirmation' => $apiPassword,
|
42 |
+
'is_active' => 1,
|
43 |
+
'user_roles' => '',
|
44 |
+
'assigned_user_role' => '',
|
45 |
+
'role_name' => '',
|
46 |
+
'roles' => array($role->getId())
|
47 |
+
));
|
48 |
+
$user->save()->load($user->getId());
|
49 |
+
$user->setRoleIds(array($role->getId()))
|
50 |
+
->setRoleUserId($user->getUserId())
|
51 |
+
->saveRelations();
|
52 |
+
}
|
53 |
+
return true;
|
54 |
+
}
|
55 |
+
catch (Exception $e)
|
56 |
+
{
|
57 |
+
Mage::log('API User Creation Error: '.$e->getMessage());
|
58 |
+
return false;
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
+
}
|
app/code/community/Comrse/ComrseSync/Helper/Data.php
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
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 |
+
// if content type not passed
|
8 |
+
if (is_null($contentType))
|
9 |
+
$contentType = "application/json";
|
10 |
+
|
11 |
+
// prepare header
|
12 |
+
$headerArray = array(
|
13 |
+
"Content-Type: " . $contentType,
|
14 |
+
"X-Comrse-Token: " . $orgData->getToken(),
|
15 |
+
"X-Comrse-Version: " . Comrse_ComrseSync_Model_Config::COMRSE_API_VERSION,
|
16 |
+
"Connection: close"
|
17 |
+
);
|
18 |
+
|
19 |
+
|
20 |
+
|
21 |
+
$ch = curl_init($targetUrl);
|
22 |
+
|
23 |
+
// if POST Data is present
|
24 |
+
if (!is_null($postData))
|
25 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
|
26 |
+
|
27 |
+
// method
|
28 |
+
if ($method == "POST")
|
29 |
+
curl_setopt($ch, CURLOPT_POST, true);
|
30 |
+
else
|
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 |
+
$result = curl_exec($ch);
|
39 |
+
|
40 |
+
return $result;
|
41 |
+
}
|
42 |
+
|
43 |
+
|
44 |
+
// basic request
|
45 |
+
public function basicRequest($path, $method = "GET") {
|
46 |
+
try {
|
47 |
+
$ch = curl_init();
|
48 |
+
curl_setopt($ch,CURLOPT_URL, $path);
|
49 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
50 |
+
"Connection: close"
|
51 |
+
));
|
52 |
+
curl_setopt($ch,CURLOPT_CUSTOMREQUEST, $method);
|
53 |
+
curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
|
54 |
+
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, FALSE);
|
55 |
+
$result = curl_exec($ch);
|
56 |
+
curl_close($ch);
|
57 |
+
return $result;
|
58 |
+
}
|
59 |
+
catch (Exception $e) {
|
60 |
+
Mage::log("Comrse Basic HTTP Request: ".$e->getMessage());
|
61 |
+
return false;
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
|
66 |
+
|
67 |
+
|
68 |
+
}
|
app/code/community/Comrse/ComrseSync/Helper/Order.php
ADDED
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Comrse_ComrseSync_Helper_Order extends Mage_Core_Helper_Abstract {
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Normalize Order Data
|
6 |
+
* Maps mixed Magento Order data to Comrse Order Object
|
7 |
+
* Maps mixed Magento Order data to Comrse Metric Event Object
|
8 |
+
* @access public
|
9 |
+
* @return Object normalizedOrder
|
10 |
+
* @param Object mageOrder
|
11 |
+
* @param Bool sendMetrics
|
12 |
+
* @todo Re-implement send metrics
|
13 |
+
*/
|
14 |
+
public function normalizeOrderData($mageOrder, $sendMetrics = false, $orderStatus = "IN_PROCESS")
|
15 |
+
{
|
16 |
+
//------------------------------------------------------------
|
17 |
+
// Setup Data Objects
|
18 |
+
//------------------------------------------------------------
|
19 |
+
$orgData = Mage::getModel('comrsesync/comrseconnect')->load(Comrse_ComrseSync_Model_Config::COMRSE_RECORD_ROW_ID);
|
20 |
+
$mageOrderData = $mageOrder->getData();
|
21 |
+
$comrseOrder = Mage::getModel('comrsesync/Comrse_Order');
|
22 |
+
$comrseCustomer = Mage::getModel('comrsesync/Comrse_Customer');
|
23 |
+
|
24 |
+
//------------------------------------------------------------
|
25 |
+
// If Passing Metric Event
|
26 |
+
//------------------------------------------------------------
|
27 |
+
if ($sendMetrics)
|
28 |
+
{
|
29 |
+
$metricEvent = Mage::getModel('comrsesync/Comrse_MetricEvent');
|
30 |
+
$metricEvent
|
31 |
+
->setBrandId($orgData->getOrg())
|
32 |
+
->setEmail($mageOrderData['customer_email'])
|
33 |
+
->setIpAddress($mageOrderData['x_forwarded_for'])
|
34 |
+
->setActivityTimestamp(strtotime($mageOrderData['created_at']) * 1000)
|
35 |
+
->setActivityGroupId($mageOrderData['increment_id']);
|
36 |
+
}
|
37 |
+
|
38 |
+
$comrseOrder
|
39 |
+
->setSubmitDate($mageOrderData['created_at'])
|
40 |
+
->setExternalId($mageOrderData['entity_id'])
|
41 |
+
->setIpAddress($mageOrderData['x_forwarded_for'])
|
42 |
+
->setStatus($orderStatus);
|
43 |
+
|
44 |
+
//------------------------------------------------------------
|
45 |
+
// Set Pricing
|
46 |
+
//------------------------------------------------------------
|
47 |
+
$comrseOrder
|
48 |
+
->setTotal($mageOrderData['grand_total'])
|
49 |
+
->setSubTotal($mageOrderData['subtotal'])
|
50 |
+
->setTotalShipping($mageOrderData['shipping_amount'])
|
51 |
+
->setTotalTax($mageOrderData['tax_amount']);
|
52 |
+
|
53 |
+
//------------------------------------------------------------
|
54 |
+
// Set Customer & Billing Address Details
|
55 |
+
//------------------------------------------------------------
|
56 |
+
$comrseCustomer->setEmailAddress($mageOrderData['customer_email']);
|
57 |
+
if ($mageOrder->getBillingAddress())
|
58 |
+
{
|
59 |
+
$billingAddress = $mageOrder->getBillingAddress()->getData();
|
60 |
+
|
61 |
+
// create customer
|
62 |
+
$comrseCustomer
|
63 |
+
->setFirstName($billingAddress['firstname'])
|
64 |
+
->setLastName($billingAddress['lastname']);
|
65 |
+
|
66 |
+
// if metrics
|
67 |
+
if ($sendMetrics)
|
68 |
+
$metricEvent->setCustomerName($billingAddress['firstname'] . " " . $billingAddress['lastname']);
|
69 |
+
|
70 |
+
// create customer address
|
71 |
+
$regionData = Mage::getModel('directory/region')->load($billingAddress['region_id'])->getOrigData();
|
72 |
+
$customerAddress = Mage::getModel('comrsesync/Comrse_CustomerAddress');
|
73 |
+
$customerAddress
|
74 |
+
->setFirstName($billingAddress['firstname'])
|
75 |
+
->setLastName($billingAddress['lastname'])
|
76 |
+
->setAddressLine1($billingAddress['street'])
|
77 |
+
->setCity($billingAddress['city'])
|
78 |
+
->setPostalCode($billingAddress['postcode'])
|
79 |
+
->setCountry($regionData['country_id'])
|
80 |
+
->setState($regionData['code'], $regionData['name'])
|
81 |
+
->setPhonePrimary($billingAddress['telephone'])
|
82 |
+
->setAddressType("billing");
|
83 |
+
$comrseOrder->addAddress($customerAddress->toArray());
|
84 |
+
}
|
85 |
+
$comrseOrder->setCustomer($comrseCustomer->toArray());
|
86 |
+
|
87 |
+
//------------------------------------------------------------
|
88 |
+
// Handle Order Items
|
89 |
+
//------------------------------------------------------------
|
90 |
+
$mageOrderItems = $mageOrder->getAllItems();
|
91 |
+
|
92 |
+
foreach ($mageOrderItems as $mageOrderItem)
|
93 |
+
{
|
94 |
+
$mageProduct = $mageOrderItem->getData();
|
95 |
+
if (empty($mageProduct['parent_item_id']))
|
96 |
+
{
|
97 |
+
$comrseOrderItem = Mage::getModel('comrsesync/Comrse_OrderItem');
|
98 |
+
$comrseOrderItem
|
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 |
+
foreach ($mageProductOptionsList as $mageProductOption)
|
112 |
+
{
|
113 |
+
$comrseOrderItem->addOrderItemAttribute($mageProductOption);
|
114 |
+
|
115 |
+
// if metrics
|
116 |
+
if ($sendMetrics)
|
117 |
+
$metricEvent->addProductOption($mageProductOption);
|
118 |
+
}
|
119 |
+
}
|
120 |
+
$comrseOrder->addOrderItem($comrseOrderItem->toArray());
|
121 |
+
|
122 |
+
// if metrics
|
123 |
+
if ($sendMetrics)
|
124 |
+
{
|
125 |
+
$metricEvent
|
126 |
+
->setExternalProductId($mageProduct['product_id'])
|
127 |
+
->setProductPrice($mageProduct['original_price'])
|
128 |
+
->setProductSalePrice($mageProduct['price'])
|
129 |
+
->setProductQuantity($mageProduct['qty_ordered'])
|
130 |
+
->setProductName($mageProduct['name'])
|
131 |
+
->send($orgData);
|
132 |
+
}
|
133 |
+
}
|
134 |
+
}
|
135 |
+
return $comrseOrder->toArray();
|
136 |
+
}
|
137 |
+
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Sync Orders
|
141 |
+
* @access public
|
142 |
+
* @todo handle last synced
|
143 |
+
*/
|
144 |
+
public function syncOrders()
|
145 |
+
{
|
146 |
+
//------------------------------------------------------------
|
147 |
+
// Retreive and Handle Org Data
|
148 |
+
//------------------------------------------------------------
|
149 |
+
$orgData = Mage::getModel('comrsesync/comrseconnect')->load(Comrse_ComrseSync_Model_Config::COMRSE_RECORD_ROW_ID);
|
150 |
+
$lastSynced = $orgData->getLastOrderSynced();
|
151 |
+
|
152 |
+
$stores = Mage::app()->getStores();
|
153 |
+
|
154 |
+
if (!is_array($stores))
|
155 |
+
$stores = array("stores" => false);
|
156 |
+
|
157 |
+
foreach ($stores as $store)
|
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 |
+
// check if plugin is disabled on store
|
171 |
+
$storeDisabled = Mage::getStoreConfig('advanced/modules_disable_output/Comrse_ComrseSync', $storeId);
|
172 |
+
if (!$storeDisabled)
|
173 |
+
{
|
174 |
+
if ($multiStore)
|
175 |
+
$orderCount = Mage::getModel('sales/order')->getCollection()->addFieldToFilter("store_id", array('eq' => $storeId))->getSize();
|
176 |
+
else
|
177 |
+
$orderCount = Mage::getModel('sales/order')->getCollection()->getSize();
|
178 |
+
|
179 |
+
// paginate and loop
|
180 |
+
$batchMath = ceil($orderCount / Comrse_ComrseSync_Model_Config::ORDER_SYNC_BATCH_SIZE);
|
181 |
+
|
182 |
+
for ($i = 1; $i <= $batchMath; $i++)
|
183 |
+
{
|
184 |
+
if ($multiStore)
|
185 |
+
$mageOrders = Mage::getModel('sales/order')->getCollection()->setPageSize(Comrse_ComrseSync_Model_Config::ORDER_SYNC_BATCH_SIZE)->setCurPage($i)->addFieldToFilter("store_id", array('eq' => $storeId));
|
186 |
+
else
|
187 |
+
$mageOrders = Mage::getModel('sales/order')->getCollection()->setPageSize(Comrse_ComrseSync_Model_Config::ORDER_SYNC_BATCH_SIZE)->setCurPage($i);
|
188 |
+
|
189 |
+
foreach ($mageOrders as $mageOrder)
|
190 |
+
$ordersPayload[] = $this->normalizeOrderData($mageOrder, false);
|
191 |
+
|
192 |
+
$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))));
|
193 |
+
if (isset($postOrders->message)){
|
194 |
+
Mage::log("ORDER SYNC ERROR: " . json_encode($postOrders));
|
195 |
+
return false;
|
196 |
+
}
|
197 |
+
}
|
198 |
+
}
|
199 |
+
}
|
200 |
+
}
|
201 |
+
}
|
app/code/community/Comrse/ComrseSync/Helper/Product.php
ADDED
@@ -0,0 +1,581 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Comrse_ComrseSync_Helper_Product extends Mage_Core_Helper_Abstract {
|
4 |
+
|
5 |
+
private $productModel;
|
6 |
+
private $linksModel;
|
7 |
+
private $mediaPath;
|
8 |
+
private $basePath;
|
9 |
+
private $normalizedProducts = array();
|
10 |
+
private $syncedProductIds = array();
|
11 |
+
private $orgId;
|
12 |
+
private $productTypes = array("configurable", "simple", "downloadable"); // do not modify w/o modifying db schema
|
13 |
+
private $categorizedProductIds = array();
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Init
|
17 |
+
* - Define the Product Model
|
18 |
+
* - Define Downloadble Product Link Model
|
19 |
+
* - Define Base Media Path
|
20 |
+
* - Define Base Web Path
|
21 |
+
*/
|
22 |
+
function __construct()
|
23 |
+
{
|
24 |
+
$this->productModel = Mage::getModel('catalog/product');
|
25 |
+
$this->linksModel = Mage::getModel('downloadable/link');
|
26 |
+
$this->mediaPath = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'catalog/product';
|
27 |
+
$this->basePath = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Map Product Categories
|
32 |
+
* recursively maps product categories and sub categories
|
33 |
+
* @param object $categories
|
34 |
+
* @return array $subCategories
|
35 |
+
*/
|
36 |
+
private function mapCategories($categories) {
|
37 |
+
if ($categories)
|
38 |
+
{
|
39 |
+
$subCategories = array();
|
40 |
+
foreach ($categories as $category)
|
41 |
+
{
|
42 |
+
$_cat = Mage::getModel('catalog/category')->load($category->getId());
|
43 |
+
$comrseCategory = Mage::getModel('comrsesync/Comrse_ProductCategory');
|
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 |
+
$childCategories = $_cat->getChildrenCategories();
|
60 |
+
$subCats = $this->mapCategories($childCategories);
|
61 |
+
$comrseCategory->setSubcategories($subCats);
|
62 |
+
}
|
63 |
+
$subCategories[] = $comrseCategory->toArray();
|
64 |
+
}
|
65 |
+
return $subCategories;
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Normalize Product Data
|
72 |
+
* Maps mixed Magento Product data to Comrse Product Object
|
73 |
+
* @access public
|
74 |
+
* @return Object normalizedProduct
|
75 |
+
* @param Object product
|
76 |
+
* @todo Re-implement Last Synced functionality
|
77 |
+
*/
|
78 |
+
public function normalizeProductData($product) {
|
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 |
+
$categories = $_item->getCategoryIds();
|
94 |
+
if (!empty($categories))
|
95 |
+
{
|
96 |
+
foreach ($categories as $category_id)
|
97 |
+
{
|
98 |
+
$_cat = Mage::getModel('catalog/category')->load($category_id) ;
|
99 |
+
if ($_cat->getChildrenCount() < 1)
|
100 |
+
$this->categorizedProductIds[$_cat->getId()][] = $_item->getId();
|
101 |
+
}
|
102 |
+
}
|
103 |
+
|
104 |
+
//------------------------------------------------------------
|
105 |
+
// Handle Configurable Product Options
|
106 |
+
//------------------------------------------------------------
|
107 |
+
if ($productType == "configurable")
|
108 |
+
{
|
109 |
+
$productAttributeOptions = $product->getTypeInstance(true)->getConfigurableAttributesAsArray($product);
|
110 |
+
|
111 |
+
foreach ($productAttributeOptions as $productAttribute)
|
112 |
+
{
|
113 |
+
$attrCodes[$productAttribute['attribute_id']] = $productAttribute['attribute_code'];
|
114 |
+
|
115 |
+
$attribute = Mage::getModel('eav/entity_attribute')->load($productAttribute['attribute_code'], 'attribute_code');
|
116 |
+
|
117 |
+
$option_col = Mage::getResourceModel( 'eav/entity_attribute_option_collection')
|
118 |
+
->setAttributeFilter($attribute->getId())
|
119 |
+
->setStoreFilter()
|
120 |
+
->setPositionOrder('ASC');
|
121 |
+
}
|
122 |
+
|
123 |
+
// loop product attributes
|
124 |
+
$optionIterator = 1;
|
125 |
+
|
126 |
+
foreach ($productAttributeOptions as $option)
|
127 |
+
{
|
128 |
+
if (is_null($option) || empty($option) || !isset($option['label']) || is_null($option['label']))
|
129 |
+
continue;
|
130 |
+
|
131 |
+
$attribute = Mage::getModel('eav/entity_attribute')->load($option['attribute_code'], 'attribute_code');
|
132 |
+
$allowedValues = array();
|
133 |
+
|
134 |
+
// loop product attribute values
|
135 |
+
$optionValueIterator = 1;
|
136 |
+
foreach ($option['values'] as $value)
|
137 |
+
{
|
138 |
+
$adjustmentAmount = (is_numeric($value['pricing_value'])) ? $value['pricing_value'] : 0.00; // remove def
|
139 |
+
// build Comr.se allowed value
|
140 |
+
$allowedValues[] = Mage::getModel('comrsesync/Comrse_AllowedValue')
|
141 |
+
->setExternalId($value['value_index'])
|
142 |
+
->setAttributeValue($value['label'])
|
143 |
+
->setPriceAdjustment(Mage::getModel('comrsesync/Comrse_Price')->setAmount($adjustmentAmount)->toArray())
|
144 |
+
->setProductOptionId("1")
|
145 |
+
->setDisplayOrder($optionValueIterator)
|
146 |
+
->toArray();
|
147 |
+
$optionValueIterator++;
|
148 |
+
}
|
149 |
+
|
150 |
+
// build Comr.se product option
|
151 |
+
$productOptions[] = Mage::getModel('comrsesync/Comrse_ProductOption')
|
152 |
+
->setAttributeName($option['label'])
|
153 |
+
->setLabel($option['store_label'])
|
154 |
+
->setExternalId($option['attribute_id'])
|
155 |
+
->setRequired("true")
|
156 |
+
->setProductOptionType(strtoupper($attribute->getFrontendInput()))
|
157 |
+
->setAllowedValues($allowedValues)
|
158 |
+
->setDisplayOrder($optionIterator)
|
159 |
+
->toArray();
|
160 |
+
|
161 |
+
$optionIterator++;
|
162 |
+
$allowedValues = null;
|
163 |
+
}
|
164 |
+
}
|
165 |
+
|
166 |
+
//------------------------------------------------------------
|
167 |
+
// Handle Downloadable Product Options (Links)
|
168 |
+
//------------------------------------------------------------
|
169 |
+
elseif($productType == "downloadable")
|
170 |
+
{
|
171 |
+
$allowedValues = array();
|
172 |
+
@$links = $this->linksModel->getCollection()->addProductToFilter($pid)->addTitleToResult()->addPriceToResult();
|
173 |
+
|
174 |
+
$optionValueIterator = 1;
|
175 |
+
$productOptions = array();
|
176 |
+
foreach ($links as $link)
|
177 |
+
{
|
178 |
+
$allowedValues[] = Mage::getModel('comrsesync/Comrse_AllowedValue')
|
179 |
+
->setExternalId($link->getLinkId())
|
180 |
+
->setAttributeValue($link->getTitle())
|
181 |
+
->setPriceAdjustment(Mage::getModel('comrsesync/Comrse_Price')->setAmount($link->getPrice())->toArray())
|
182 |
+
->setProductOptionId("1")
|
183 |
+
->setDisplayOrder($optionValueIterator)
|
184 |
+
->toArray();
|
185 |
+
$optionValueIterator++;
|
186 |
+
}
|
187 |
+
|
188 |
+
$productOptions[] = Mage::getModel('comrsesync/Comrse_ProductOption')
|
189 |
+
->setAttributeName("Link")
|
190 |
+
->setLabel("Link")
|
191 |
+
->setExternalId("99999")
|
192 |
+
->setRequired("true")
|
193 |
+
->setProductOptionType("Select")
|
194 |
+
->setAllowedValues($allowedValues)
|
195 |
+
->setDisplayOrder(1)
|
196 |
+
->toArray();
|
197 |
+
|
198 |
+
$allowedValues = null;
|
199 |
+
}
|
200 |
+
else
|
201 |
+
{
|
202 |
+
$productOptions = null;
|
203 |
+
}
|
204 |
+
|
205 |
+
|
206 |
+
//------------------------------------------------------------
|
207 |
+
// Handle Product Media
|
208 |
+
//------------------------------------------------------------
|
209 |
+
$media = $_item->getData('media_gallery');
|
210 |
+
$images = $media['images'];
|
211 |
+
$_images = array();
|
212 |
+
$usedImages = array();
|
213 |
+
$hasThumb = false;
|
214 |
+
|
215 |
+
if ($_item->hasThumbnail())
|
216 |
+
{
|
217 |
+
$thumbFile = $_item->getThumbnail();
|
218 |
+
$hasThumb = true;
|
219 |
+
}
|
220 |
+
|
221 |
+
$primaryImageSet = false;
|
222 |
+
if (is_array($images))
|
223 |
+
{
|
224 |
+
foreach ($images as $image)
|
225 |
+
{
|
226 |
+
if ($image['file'])
|
227 |
+
{
|
228 |
+
$altText = "";
|
229 |
+
if ($hasThumb && $image['file'] == $thumbFile && !$primaryImageSet)
|
230 |
+
{
|
231 |
+
$altText = "primary";
|
232 |
+
$primaryImageSet = true;
|
233 |
+
}
|
234 |
+
elseif ($image['position_default'] == 1 && !$primaryImageSet)
|
235 |
+
{
|
236 |
+
$altText = "primary";
|
237 |
+
$primaryImageSet = true;
|
238 |
+
}
|
239 |
+
$usedImages[] = $image['file'];
|
240 |
+
|
241 |
+
$_images[] = Mage::getModel('comrsesync/Comrse_Image')
|
242 |
+
->setId(null)
|
243 |
+
->setTitle($image['value_id'])
|
244 |
+
->setUrl($this->mediaPath . $image['file'])
|
245 |
+
->setAltText($altText)
|
246 |
+
->setOrgId($this->orgId)
|
247 |
+
->toArray();
|
248 |
+
}
|
249 |
+
}
|
250 |
+
}
|
251 |
+
|
252 |
+
|
253 |
+
|
254 |
+
//------------------------------------------------------------
|
255 |
+
// Handle Configurable Product Children
|
256 |
+
//------------------------------------------------------------
|
257 |
+
if ($productType == "configurable")
|
258 |
+
{
|
259 |
+
$children = array();
|
260 |
+
$conf = Mage::getModel('catalog/product_type_configurable')->setProduct($product);
|
261 |
+
$simpleCollection = $conf->getUsedProductCollection()->addAttributeToSelect('*')->addFilterByRequiredOptions();
|
262 |
+
$attributeIterator = 0;
|
263 |
+
|
264 |
+
$simpleProductAttributes = array();
|
265 |
+
$skuMapping = array();
|
266 |
+
foreach ($simpleCollection as $simpleProduct)
|
267 |
+
{
|
268 |
+
$simpleProductData = $simpleProduct->getData();
|
269 |
+
$skuMapping[$simpleProduct->getId()][$attributeIterator]["sku"] = $simpleProduct->getSku(); // map child ID's to attribute ID's for writeback inventory lookup
|
270 |
+
$skuMapping[$simpleProduct->getId()][$attributeIterator]["upc"] = null; // map child ID's to attribute ID's for writeback inventory lookup
|
271 |
+
|
272 |
+
|
273 |
+
foreach ($attrCodes as $key => $val)
|
274 |
+
{
|
275 |
+
if (isset($simpleProductData[$val]))
|
276 |
+
$simpleProductAttributes[$simpleProduct->getId()][$key] = $simpleProductData[$val]; // map child ID's to attribute ID's for writeback inventory lookup
|
277 |
+
}
|
278 |
+
|
279 |
+
$childProducts[] = $simpleProduct->getId();
|
280 |
+
if ($simpleProduct->getWeight() > $productWeight)
|
281 |
+
$productWeight = $simpleProduct->getWeight();
|
282 |
+
|
283 |
+
$qty = Mage::getModel('cataloginventory/stock_item')->loadByProduct($simpleProduct)->getQty();
|
284 |
+
$sProductData = $simpleProduct->getData();
|
285 |
+
$sProduct = $this->productModel->load($simpleProduct->getId());
|
286 |
+
$sMedia = $sProduct->getData('media_gallery');
|
287 |
+
|
288 |
+
if (empty($usedImages) && $sProduct->hasThumbnail())
|
289 |
+
{
|
290 |
+
$thumbFile = $sProduct->getThumbnail();
|
291 |
+
$hasThumb = true;
|
292 |
+
}
|
293 |
+
|
294 |
+
$sImages = $sMedia['images'];
|
295 |
+
|
296 |
+
if (is_array($sImages))
|
297 |
+
{
|
298 |
+
foreach ($sImages as $sImage)
|
299 |
+
{
|
300 |
+
if ($sImage['file'] && !in_array($sImage['file'], $usedImages))
|
301 |
+
{
|
302 |
+
$altText = "";
|
303 |
+
if ($hasThumb && !$primaryImageSet)
|
304 |
+
{
|
305 |
+
if ($sImage['file'] == $thumbFile)
|
306 |
+
{
|
307 |
+
$altText = "primary";
|
308 |
+
$primaryImageSet = true;
|
309 |
+
}
|
310 |
+
}
|
311 |
+
elseif ($sImage['position_default'] == 1 && !$primaryImageSet)
|
312 |
+
{
|
313 |
+
$altText = "primary";
|
314 |
+
$primaryImageSet = true;
|
315 |
+
}
|
316 |
+
|
317 |
+
$_images[] = Mage::getModel('comrsesync/Comrse_Image')
|
318 |
+
->setId(null)
|
319 |
+
->setTitle($sImage['value_id'])
|
320 |
+
->setUrl($this->mediaPath . $sImage['file'])
|
321 |
+
->setAltText($altText)
|
322 |
+
->setOrgId($this->orgId)
|
323 |
+
->toArray();
|
324 |
+
}
|
325 |
+
}
|
326 |
+
}
|
327 |
+
foreach ($attrCodes as $key => $val)
|
328 |
+
{
|
329 |
+
$qtyArray[$attributeIterator]["qty"] = $qty;
|
330 |
+
$qtyArray[$attributeIterator][$key] = $sProductData[$val];
|
331 |
+
}
|
332 |
+
|
333 |
+
$attributeIterator++;
|
334 |
+
$this->syncedProductIds[] = $simpleProduct->getId();
|
335 |
+
$simpleProduct = $sProductData = $sProduct = $sProductMedia = $sProductImages = null; // memclear
|
336 |
+
}
|
337 |
+
}
|
338 |
+
|
339 |
+
//------------------------------------------------------------
|
340 |
+
// Handle Simple/Downloadable Product Quantities
|
341 |
+
//------------------------------------------------------------
|
342 |
+
elseif ($productType == "simple" || $productType == "downloadable")
|
343 |
+
{
|
344 |
+
$qtyStock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_item)->getQty();
|
345 |
+
$qtyArray[0]["qty"] = $qtyStock;
|
346 |
+
$simpleProductAttributes = array();
|
347 |
+
}
|
348 |
+
|
349 |
+
//------------------------------------------------------------
|
350 |
+
// Define Product Attributes
|
351 |
+
//------------------------------------------------------------
|
352 |
+
$productAttributes = array(
|
353 |
+
array("id" => null, "attribute_name" => "inventory", "attribute_value" => json_encode($qtyArray)),
|
354 |
+
array("id" => null, "attribute_name" => "url", "attribute_value" => $product->getProductUrl()),
|
355 |
+
array("id" => null, "attribute_name" => "mapping", "attribute_value" => json_encode($simpleProductAttributes)),
|
356 |
+
array("id" => null, "attribute_name" => "sku_mapping", "attribute_value" => json_encode($skuMapping))
|
357 |
+
);
|
358 |
+
|
359 |
+
//------------------------------------------------------------
|
360 |
+
// if sale price does not exist use base price
|
361 |
+
//------------------------------------------------------------
|
362 |
+
$salePrice = ($_item->getSpecialPrice() > 0 ? $_item->getSpecialPrice() : $_item->getPrice());
|
363 |
+
|
364 |
+
//------------------------------------------------------------
|
365 |
+
// extra check to make sure sale price is NOT 0
|
366 |
+
//------------------------------------------------------------
|
367 |
+
if ($salePrice == 0 || is_null($salePrice))
|
368 |
+
$salePrice = $_item->getPrice();
|
369 |
+
|
370 |
+
//------------------------------------------------------------
|
371 |
+
// if no images use placeholder
|
372 |
+
//------------------------------------------------------------
|
373 |
+
if (empty($_images))
|
374 |
+
$_images[0] = array("id" => null, "title" => "No Image", "url" => Comrse_ComrseSync_Model_Config::CDN_NO_IMG_URL, "altText" => "No Image"); // @TODO
|
375 |
+
|
376 |
+
//------------------------------------------------------------
|
377 |
+
// if short description is longer than description use short description
|
378 |
+
//------------------------------------------------------------
|
379 |
+
$description = (strlen($_item->getShortDescription()) > strlen($_item->getDescription())) ? $_item->getShortDescription() : $_item->getDescription();
|
380 |
+
|
381 |
+
//------------------------------------------------------------
|
382 |
+
// Handle Product Status
|
383 |
+
//------------------------------------------------------------
|
384 |
+
$active = ($_item->getStatus() == 1 ? "true" : "false");
|
385 |
+
$activeStartDate = ($active == "true" ? date("Y-m-d\TH:i:sO", strtotime("- 1 day", time())) : date("Y-m-d\TH:i:sO", strtotime("+ 10 years", time())));
|
386 |
+
$activeEndDate = ($active == "true" ? date("Y-m-d\TH:i:sO",strtotime("+ 10 years", time())) : date("Y-m-d\TH:i:sO",strtotime("- 1 day", time())));
|
387 |
+
|
388 |
+
//------------------------------------------------------------
|
389 |
+
// Ensure Primary Image is Set
|
390 |
+
//------------------------------------------------------------
|
391 |
+
$primaryImage = $_images[0];
|
392 |
+
foreach ($_images as $image)
|
393 |
+
{
|
394 |
+
if ($image['alt_text'] == "primary")
|
395 |
+
{
|
396 |
+
$primaryImage = $image;
|
397 |
+
break;
|
398 |
+
}
|
399 |
+
}
|
400 |
+
|
401 |
+
//------------------------------------------------------------
|
402 |
+
// Create Comr.se Product Object
|
403 |
+
//------------------------------------------------------------
|
404 |
+
if (!is_null($pid) && $productVisibility != 1)
|
405 |
+
{
|
406 |
+
return Mage::getModel('comrsesync/Comrse_Product')
|
407 |
+
->setId(null)
|
408 |
+
->setExternalId((string)$pid)
|
409 |
+
->setName($_item->getName())
|
410 |
+
->setLongDescription(trim(str_replace(array("\r\n", "\r", "<br />", "<br>"), "", $description)))
|
411 |
+
->setDimension(Mage::getModel('comrsesync/Comrse_Dimension')->toArray())
|
412 |
+
->setWeight(
|
413 |
+
Mage::getModel('comrsesync/Comrse_Weight')
|
414 |
+
->setWeight($productWeight)
|
415 |
+
->toArray()
|
416 |
+
)
|
417 |
+
->setRetailPrice(
|
418 |
+
Mage::getModel('comrsesync/Comrse_Price')
|
419 |
+
->setAmount($_item->getPrice())
|
420 |
+
->toArray()
|
421 |
+
)
|
422 |
+
->setSalePrice(
|
423 |
+
Mage::getModel('comrsesync/Comrse_Price')
|
424 |
+
->setAmount($salePrice)
|
425 |
+
->toArray()
|
426 |
+
)
|
427 |
+
->setPrimaryMedia($primaryImage)
|
428 |
+
->setActive($active)
|
429 |
+
->setActiveStartDate($activeStartDate)
|
430 |
+
->setActiveEndDate($activeEndDate)
|
431 |
+
->setManufacturer("")
|
432 |
+
->setDefaultCategoryId(null)
|
433 |
+
->setProductAttributes($productAttributes)
|
434 |
+
->setProductOptions($productOptions)
|
435 |
+
->setMedia($_images)
|
436 |
+
->toArray();
|
437 |
+
}
|
438 |
+
$this->syncedProductIds[] = $pid;
|
439 |
+
}
|
440 |
+
}
|
441 |
+
}
|
442 |
+
catch (Exception $e){
|
443 |
+
var_dump($e->getMessage());
|
444 |
+
}
|
445 |
+
}
|
446 |
+
|
447 |
+
|
448 |
+
/**
|
449 |
+
* Sync Products
|
450 |
+
* @access public
|
451 |
+
* @todo properly lookup multi-store
|
452 |
+
*/
|
453 |
+
public function syncProducts() {
|
454 |
+
try
|
455 |
+
{
|
456 |
+
//------------------------------------------------------------
|
457 |
+
// Retreive and Handle Org Data
|
458 |
+
//------------------------------------------------------------
|
459 |
+
$orgData = Mage::getModel('comrsesync/comrseconnect')->load(Comrse_ComrseSync_Model_Config::COMRSE_RECORD_ROW_ID);
|
460 |
+
$orgId = $orgData->getOrg();
|
461 |
+
$apiToken = $orgData->getToken();
|
462 |
+
|
463 |
+
$stores = Mage::app()->getStores(); // get all stores
|
464 |
+
|
465 |
+
// handle single store installation
|
466 |
+
if (!is_array($stores))
|
467 |
+
$stores = array($stores);
|
468 |
+
|
469 |
+
//------------------------------------------------------------
|
470 |
+
// Loop Stores
|
471 |
+
//------------------------------------------------------------
|
472 |
+
$disabled = $multiStore = false;
|
473 |
+
$storeId = 0;
|
474 |
+
if (is_array($stores))
|
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
|
481 |
+
$multiStore = true;
|
482 |
+
|
483 |
+
if (!$storeDisabled) // limit sync to enabled stores
|
484 |
+
{
|
485 |
+
foreach ($this->productTypes as $productType)
|
486 |
+
{
|
487 |
+
if ($multi_store)
|
488 |
+
$productCount = $this->productModel->getCollection()->addStoreFilter($_store_id)->addAttributeToFilter('type_id', $productType)->count(); // configurable products collection count
|
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($_store_id)->addAttributeToFilter('type_id', $productType)->setPageSize(Comrse_ComrseSync_Model_Config::PRODUCT_SYNC_BATCH_SIZE)->setCurPage($i); // configurable products collection
|
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
|
523 |
+
//------------------------------------------------------------
|
524 |
+
foreach ($mageProducts as $mageProduct)
|
525 |
+
{
|
526 |
+
$normalizedProduct = self::normalizeProductData($mageProduct, $productType);
|
527 |
+
if (!empty($normalizedProduct))
|
528 |
+
$productPayload[] = $normalizedProduct;
|
529 |
+
}
|
530 |
+
|
531 |
+
//------------------------------------------------------------
|
532 |
+
// Sync Products to Comr.se
|
533 |
+
//------------------------------------------------------------
|
534 |
+
$preparedData = json_encode(array("product_details_list" => $productPayload));
|
535 |
+
$postProducts = json_decode(Mage::helper('comrsesync')->comrseRequest("POST", Comrse_ComrseSync_Model_Config::API_PATH . "organizations/" . $orgId . "/products", $orgData, $preparedData));
|
536 |
+
|
537 |
+
|
538 |
+
|
539 |
+
|
540 |
+
if (isset($postProducts->message)){
|
541 |
+
Mage::log("PRODUCT SYNC ERROR: " . json_encode($postProducts));
|
542 |
+
#return false;
|
543 |
+
}
|
544 |
+
|
545 |
+
|
546 |
+
//------------------------------------------------------------
|
547 |
+
// Record Last Synced Product ID
|
548 |
+
//------------------------------------------------------------
|
549 |
+
#$lastProductsSynced[$storeId][$pidColumn] = $productPayload[max(array_keys($productPayload))]["external_id"];
|
550 |
+
#$saveLastSynced = $productData->setLastProductsSynced(json_encode($lastProductsSynced))->save();
|
551 |
+
}
|
552 |
+
}
|
553 |
+
}
|
554 |
+
}
|
555 |
+
|
556 |
+
//------------------------------------------------------------
|
557 |
+
// Sync Categories to Comr.se
|
558 |
+
//------------------------------------------------------------
|
559 |
+
$categories = Mage::getModel('catalog/category')->getCollection()
|
560 |
+
->addAttributeToSelect('*')//or you can just add some attributes
|
561 |
+
->addAttributeToFilter('level', 2)//2 is actually the first level
|
562 |
+
->addAttributeToFilter('is_active', 1);//if you want only active categories
|
563 |
+
$mappedCategories = $this->mapCategories($categories);
|
564 |
+
|
565 |
+
if (!is_array($mappedCategories))
|
566 |
+
$mappedCategories = array($mappedCategories);
|
567 |
+
|
568 |
+
if (is_array($mappedCategories) && !empty($mappedCategories)) {
|
569 |
+
foreach ($mappedCategories as $mappedCategory) {
|
570 |
+
$postCategories = Mage::helper('comrsesync')->comrseRequest("POST", Comrse_ComrseSync_Model_Config::API_PATH . "/organizations/" . $orgId . "/category", $orgData, json_encode($mappedCategory), null, null, 1);
|
571 |
+
var_dump($postCategories);
|
572 |
+
}
|
573 |
+
}
|
574 |
+
}
|
575 |
+
}
|
576 |
+
catch (Exception $e)
|
577 |
+
{
|
578 |
+
Mage::log('Product Sync Error: '.$e->getMessage());
|
579 |
+
}
|
580 |
+
}
|
581 |
+
}
|
app/code/community/Comrse/ComrseSync/Model/Carrier/Comrseship.php
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Comrse Shipping Handler
|
5 |
+
* Hidden shipping method only available to the SOAP API
|
6 |
+
*
|
7 |
+
* @version 1.2.1
|
8 |
+
* @since 1.2.1
|
9 |
+
*/
|
10 |
+
class Comrse_ComrseSync_Model_Carrier_Comrseship
|
11 |
+
extends Mage_Shipping_Model_Carrier_Abstract
|
12 |
+
implements Mage_Shipping_Model_Carrier_Interface
|
13 |
+
{
|
14 |
+
|
15 |
+
protected $_code = 'comrseship';
|
16 |
+
protected $_isFixed = true;
|
17 |
+
|
18 |
+
public function collectRates(Mage_Shipping_Model_Rate_Request $request){
|
19 |
+
try{
|
20 |
+
error_reporting(0);
|
21 |
+
ini_set('display_errors',0);
|
22 |
+
if (!$this->getConfigFlag('active')) {
|
23 |
+
return false;
|
24 |
+
}
|
25 |
+
|
26 |
+
$freeBoxes = 0;
|
27 |
+
if ($request->getAllItems()) {
|
28 |
+
foreach ($request->getAllItems() as $item) {
|
29 |
+
|
30 |
+
if ($item->getProduct()->isVirtual() || $item->getParentItem()) {
|
31 |
+
continue;
|
32 |
+
}
|
33 |
+
|
34 |
+
if ($item->getHasChildren() && $item->isShipSeparately()) {
|
35 |
+
foreach ($item->getChildren() as $child) {
|
36 |
+
if ($child->getFreeShipping() && !$child->getProduct()->isVirtual()) {
|
37 |
+
$freeBoxes += $item->getQty() * $child->getQty();
|
38 |
+
}
|
39 |
+
}
|
40 |
+
} elseif ($item->getFreeShipping()) {
|
41 |
+
$freeBoxes += $item->getQty();
|
42 |
+
}
|
43 |
+
}
|
44 |
+
}
|
45 |
+
$this->setFreeBoxes($freeBoxes);
|
46 |
+
|
47 |
+
$result = Mage::getModel('shipping/rate_result');
|
48 |
+
if ($this->getConfigData('type') == 'O') { // per order
|
49 |
+
$shippingPrice = $this->getConfigData('price');
|
50 |
+
} elseif ($this->getConfigData('type') == 'I') { // per item
|
51 |
+
$shippingPrice = ($request->getPackageQty() * $this->getConfigData('price')) - ($this->getFreeBoxes() * $this->getConfigData('price'));
|
52 |
+
} else {
|
53 |
+
$shippingPrice = false;
|
54 |
+
}
|
55 |
+
|
56 |
+
$shippingPrice = $this->getFinalPriceWithHandlingFee($shippingPrice);
|
57 |
+
|
58 |
+
if ($shippingPrice !== false) {
|
59 |
+
$method = Mage::getModel('shipping/rate_result_method');
|
60 |
+
|
61 |
+
$method->setCarrier('comrseship');
|
62 |
+
$method->setCarrierTitle($this->getConfigData('title'));
|
63 |
+
|
64 |
+
$method->setMethod('comrseship');
|
65 |
+
$method->setMethodTitle($this->getConfigData('name'));
|
66 |
+
|
67 |
+
if ($request->getFreeShipping() === true || $request->getPackageQty() == $this->getFreeBoxes()) {
|
68 |
+
$shippingPrice = '0.00';
|
69 |
+
}
|
70 |
+
|
71 |
+
$method->setPrice($shippingPrice);
|
72 |
+
$method->setCost($shippingPrice);
|
73 |
+
|
74 |
+
$result->append($method);
|
75 |
+
}
|
76 |
+
|
77 |
+
return $result;
|
78 |
+
}
|
79 |
+
catch(Exception $e){
|
80 |
+
Mage::log('ComrseShip Model: '.$e->getMessage());
|
81 |
+
}
|
82 |
+
}
|
83 |
+
|
84 |
+
|
85 |
+
// return comrse ship name
|
86 |
+
public function getAllowedMethods()
|
87 |
+
{
|
88 |
+
try{
|
89 |
+
error_reporting(0);
|
90 |
+
ini_set('display_errors',0);
|
91 |
+
return array('comrseship'=>$this->getConfigData('name'));
|
92 |
+
}
|
93 |
+
catch(Exception $e){
|
94 |
+
Mage::log('Return ComrseShip Name: '.$e->getMessage());
|
95 |
+
}
|
96 |
+
}
|
97 |
+
|
98 |
+
}
|
app/code/community/Comrse/ComrseSync/Model/Carrier/Config.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Comrse Shipping Handler
|
4 |
+
* Hide Comr.se Shipping Method from front end calls
|
5 |
+
*
|
6 |
+
* @version 1.2.1
|
7 |
+
* @since 11
|
8 |
+
*/
|
9 |
+
class Comrse_ComrseSync_Model_Shipping_Config extends Mage_Shipping_Model_Config
|
10 |
+
{
|
11 |
+
public function getActiveCarriers($store = null)
|
12 |
+
{
|
13 |
+
try{
|
14 |
+
error_reporting(0);
|
15 |
+
$carriers = parent::getActiveCarriers($store);
|
16 |
+
if(Mage::getDesign()->getArea() === Mage_Core_Model_App_Area::AREA_FRONTEND){
|
17 |
+
$carriersCodes = array_keys($carriers);
|
18 |
+
foreach($carriersCodes as $carriersCode){
|
19 |
+
if($carriersCode == 'comrseship'){
|
20 |
+
unset($carriers[$carriersCode]);
|
21 |
+
}
|
22 |
+
}
|
23 |
+
}
|
24 |
+
return $carriers;
|
25 |
+
}
|
26 |
+
catch(Exception $e){
|
27 |
+
Mage::log('Comrse Shipping Method: '.$e->getMessage());
|
28 |
+
}
|
29 |
+
}
|
30 |
+
}
|
app/code/community/Comrse/ComrseSync/Model/Comrse/AllowedValue.php
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Comrse_ComrseSync_Model_Comrse_AllowedValue
|
4 |
+
{
|
5 |
+
|
6 |
+
//-----------------------------------------------------
|
7 |
+
// VARS & CONSTANTS
|
8 |
+
//-----------------------------------------------------
|
9 |
+
private $external_id;
|
10 |
+
private $attribute_value;
|
11 |
+
private $price_adjustment;
|
12 |
+
private $product_option_id;
|
13 |
+
private $display_order;
|
14 |
+
|
15 |
+
|
16 |
+
//-----------------------------------------------------
|
17 |
+
// GETTERS & SETTERS
|
18 |
+
//-----------------------------------------------------
|
19 |
+
public function getExternalId(){
|
20 |
+
return $this->external_id;
|
21 |
+
}
|
22 |
+
|
23 |
+
public function setExternalId($external_id){
|
24 |
+
$this->external_id = $external_id;
|
25 |
+
return $this;
|
26 |
+
}
|
27 |
+
|
28 |
+
public function getAttributeValue(){
|
29 |
+
return $this->attribute_value;
|
30 |
+
}
|
31 |
+
|
32 |
+
public function setAttributeValue($attribute_value){
|
33 |
+
$this->attribute_value = $attribute_value;
|
34 |
+
return $this;
|
35 |
+
}
|
36 |
+
|
37 |
+
public function getPriceAdjustment(){
|
38 |
+
return $this->price_adjustment;
|
39 |
+
}
|
40 |
+
|
41 |
+
public function setPriceAdjustment($price_adjustment){
|
42 |
+
$this->price_adjustment = $price_adjustment;
|
43 |
+
return $this;
|
44 |
+
}
|
45 |
+
|
46 |
+
public function getProductOptionId(){
|
47 |
+
return $this->product_option_id;
|
48 |
+
}
|
49 |
+
|
50 |
+
public function setProductOptionId($product_option_id){
|
51 |
+
$this->product_option_id = $product_option_id;
|
52 |
+
return $this;
|
53 |
+
}
|
54 |
+
|
55 |
+
public function getDisplayOrder(){
|
56 |
+
return $this->display_order;
|
57 |
+
}
|
58 |
+
|
59 |
+
public function setDisplayOrder($display_order){
|
60 |
+
$this->display_order = $display_order;
|
61 |
+
return $this;
|
62 |
+
}
|
63 |
+
|
64 |
+
//-----------------------------------------------------
|
65 |
+
// SETUP
|
66 |
+
//-----------------------------------------------------
|
67 |
+
public function __construct() {
|
68 |
+
// do nothing
|
69 |
+
}
|
70 |
+
|
71 |
+
//-----------------------------------------------------
|
72 |
+
// PUBLIC METHODS
|
73 |
+
//-----------------------------------------------------
|
74 |
+
public function toArray() {
|
75 |
+
return get_object_vars($this);
|
76 |
+
}
|
77 |
+
|
78 |
+
}
|
app/code/community/Comrse/ComrseSync/Model/Comrse/Currency.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Comrse_ComrseSync_Model_Comrse_Currency
|
3 |
+
{
|
4 |
+
|
5 |
+
private $currency_code;
|
6 |
+
|
7 |
+
public function getCurrencyCode(){
|
8 |
+
return $this->currency_code;
|
9 |
+
}
|
10 |
+
|
11 |
+
public function setCurrencyCode($currency_code){
|
12 |
+
$this->currency_code = $currency_code;
|
13 |
+
return $this;
|
14 |
+
}
|
15 |
+
|
16 |
+
//-----------------------------------------------------
|
17 |
+
// SETUP
|
18 |
+
//-----------------------------------------------------
|
19 |
+
public function __construct() {
|
20 |
+
$this->currency_code = "USD";
|
21 |
+
}
|
22 |
+
|
23 |
+
public function toArray($encode = false) {
|
24 |
+
if ($encode)
|
25 |
+
return json_encode(get_object_vars($this));
|
26 |
+
|
27 |
+
return get_object_vars($this);
|
28 |
+
}
|
29 |
+
|
30 |
+
}
|
app/code/community/Comrse/ComrseSync/Model/Comrse/Customer.php
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Comrse_ComrseSync_Model_Comrse_Customer {
|
4 |
+
|
5 |
+
private $first_name;
|
6 |
+
private $last_name;
|
7 |
+
private $email_address;
|
8 |
+
|
9 |
+
public function getFirstName(){
|
10 |
+
return $this->first_name;
|
11 |
+
}
|
12 |
+
|
13 |
+
public function setFirstName($first_name){
|
14 |
+
$this->first_name = $first_name;
|
15 |
+
return $this;
|
16 |
+
}
|
17 |
+
|
18 |
+
public function getLastName(){
|
19 |
+
return $this->last_name;
|
20 |
+
}
|
21 |
+
|
22 |
+
public function setLastName($last_name){
|
23 |
+
$this->last_name = $last_name;
|
24 |
+
return $this;
|
25 |
+
}
|
26 |
+
|
27 |
+
public function getEmailAddress(){
|
28 |
+
return $this->email_address;
|
29 |
+
}
|
30 |
+
|
31 |
+
public function setEmailAddress($email_address){
|
32 |
+
$this->email_address = $email_address;
|
33 |
+
return $this;
|
34 |
+
}
|
35 |
+
|
36 |
+
public function toArray($encode = false) {
|
37 |
+
if ($encode)
|
38 |
+
return json_encode(get_object_vars($this));
|
39 |
+
|
40 |
+
return get_object_vars($this);
|
41 |
+
}
|
42 |
+
|
43 |
+
}
|
app/code/community/Comrse/ComrseSync/Model/Comrse/CustomerAddress.php
ADDED
@@ -0,0 +1,187 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Comrse_ComrseSync_Model_Comrse_CustomerAddress {
|
4 |
+
private $first_name;
|
5 |
+
private $last_name;
|
6 |
+
private $address_line1;
|
7 |
+
private $address_line2;
|
8 |
+
private $address_line3;
|
9 |
+
private $address_type;
|
10 |
+
private $city;
|
11 |
+
private $state;
|
12 |
+
private $country;
|
13 |
+
private $postal_code;
|
14 |
+
private $phone_primary;
|
15 |
+
private $phone_secondary;
|
16 |
+
private $phone_fax;
|
17 |
+
private $company_name;
|
18 |
+
private $is_business;
|
19 |
+
private $is_default;
|
20 |
+
private $context;
|
21 |
+
|
22 |
+
|
23 |
+
public function getFirstName(){
|
24 |
+
return $this->first_name;
|
25 |
+
}
|
26 |
+
|
27 |
+
public function setFirstName($first_name){
|
28 |
+
$this->first_name = $first_name;
|
29 |
+
return $this;
|
30 |
+
}
|
31 |
+
|
32 |
+
public function getLastName(){
|
33 |
+
return $this->last_name;
|
34 |
+
}
|
35 |
+
|
36 |
+
public function setLastName($last_name){
|
37 |
+
$this->last_name = $last_name;
|
38 |
+
return $this;
|
39 |
+
}
|
40 |
+
|
41 |
+
public function getAddressLine1(){
|
42 |
+
return $this->address_line1;
|
43 |
+
}
|
44 |
+
|
45 |
+
public function setAddressLine1($address_line1){
|
46 |
+
$this->address_line1 = $address_line1;
|
47 |
+
return $this;
|
48 |
+
}
|
49 |
+
|
50 |
+
public function getAddressLine2(){
|
51 |
+
return $this->address_line2;
|
52 |
+
}
|
53 |
+
|
54 |
+
public function setAddressLine2($address_line2){
|
55 |
+
$this->address_line2 = $address_line2;
|
56 |
+
return $this;
|
57 |
+
}
|
58 |
+
|
59 |
+
public function getAddressLine3(){
|
60 |
+
return $this->address_line3;
|
61 |
+
}
|
62 |
+
|
63 |
+
public function setAddressLine3($address_line3){
|
64 |
+
$this->address_line3 = $address_line3;
|
65 |
+
return $this;
|
66 |
+
}
|
67 |
+
|
68 |
+
public function getAddressType(){
|
69 |
+
return $this->address_type;
|
70 |
+
}
|
71 |
+
|
72 |
+
public function setAddressType($address_type){
|
73 |
+
$this->address_type = $address_type;
|
74 |
+
return $this;
|
75 |
+
}
|
76 |
+
|
77 |
+
public function getCity(){
|
78 |
+
return $this->city;
|
79 |
+
}
|
80 |
+
|
81 |
+
public function setCity($city){
|
82 |
+
$this->city = $city;
|
83 |
+
return $this;
|
84 |
+
}
|
85 |
+
|
86 |
+
public function getState(){
|
87 |
+
return $this->state;
|
88 |
+
}
|
89 |
+
|
90 |
+
public function setState($stateId, $stateName = NULL) {
|
91 |
+
$this->state = Mage::getModel('comrsesync/Comrse_Geo')->setName($stateName)->setAbbreviation($stateId)->toArray();
|
92 |
+
return $this;
|
93 |
+
}
|
94 |
+
|
95 |
+
public function getCountry(){
|
96 |
+
return $this->country;
|
97 |
+
}
|
98 |
+
|
99 |
+
public function setCountry($countryId, $countryName = NULL) {
|
100 |
+
$this->country = Mage::getModel('comrsesync/Comrse_Geo')->setName($countryName)->setAbbreviation($countryId)->toArray();
|
101 |
+
return $this;
|
102 |
+
}
|
103 |
+
|
104 |
+
public function getPostalCode(){
|
105 |
+
return $this->postal_code;
|
106 |
+
}
|
107 |
+
|
108 |
+
public function setPostalCode($postal_code){
|
109 |
+
$this->postal_code = $postal_code;
|
110 |
+
return $this;
|
111 |
+
}
|
112 |
+
|
113 |
+
public function getPhonePrimary($phone_primary){
|
114 |
+
return $phone_primary;
|
115 |
+
}
|
116 |
+
|
117 |
+
public function setPhonePrimary($phone_primary) {
|
118 |
+
$this->phone_primary = Mage::getModel('comrsesync/Comrse_Phone')->setPhoneNumber($phone_primary)->toArray();
|
119 |
+
return $this;
|
120 |
+
}
|
121 |
+
|
122 |
+
public function getPhoneSecondary($phone_secondary){
|
123 |
+
return $this->phone_secondary;
|
124 |
+
}
|
125 |
+
|
126 |
+
public function setPhoneSecondary($phone_secondary){
|
127 |
+
$this->phone_secondary = Mage::getModel('comrsesync/Comrse_Phone')->setPhoneNumber($phone_secondary)->toArray();
|
128 |
+
return $this;
|
129 |
+
}
|
130 |
+
|
131 |
+
public function getPhoneFax($phone_fax){
|
132 |
+
return $this->phone_fax;
|
133 |
+
}
|
134 |
+
|
135 |
+
public function setPhoneFax($phone_fax){
|
136 |
+
$this->phone_fax = Mage::getModel('comrsesync/Comrse_Phone')->setPhoneNumber($phone_fax)->toArray();
|
137 |
+
return $this;
|
138 |
+
}
|
139 |
+
|
140 |
+
public function getCompanyName(){
|
141 |
+
return $this->company_name;
|
142 |
+
}
|
143 |
+
|
144 |
+
public function setCompanyName($company_name){
|
145 |
+
$this->company_name = $company_name;
|
146 |
+
return $this;
|
147 |
+
}
|
148 |
+
|
149 |
+
public function getIsBusiness(){
|
150 |
+
return $this->is_business;
|
151 |
+
}
|
152 |
+
|
153 |
+
public function setIsBusiness($is_business){
|
154 |
+
$this->is_business = $is_business;
|
155 |
+
return $this;
|
156 |
+
}
|
157 |
+
|
158 |
+
public function getIsDefault(){
|
159 |
+
return $this->is_default;
|
160 |
+
}
|
161 |
+
|
162 |
+
public function setIsDefault($is_default){
|
163 |
+
$this->is_default = $is_default;
|
164 |
+
return $this;
|
165 |
+
}
|
166 |
+
|
167 |
+
public function getContext(){
|
168 |
+
return $this->context;
|
169 |
+
}
|
170 |
+
|
171 |
+
public function setContext($context){
|
172 |
+
$this->context = $context;
|
173 |
+
return $this;
|
174 |
+
}
|
175 |
+
|
176 |
+
|
177 |
+
|
178 |
+
public function toArray($encode = false) {
|
179 |
+
if ($encode)
|
180 |
+
return json_encode(get_object_vars($this));
|
181 |
+
|
182 |
+
return get_object_vars($this);
|
183 |
+
}
|
184 |
+
|
185 |
+
}
|
186 |
+
|
187 |
+
?>
|
app/code/community/Comrse/ComrseSync/Model/Comrse/CustomerContact.php
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class CustomerContact{
|
4 |
+
private $external_source;
|
5 |
+
private $id;
|
6 |
+
private $customer;
|
7 |
+
private $addresses;
|
8 |
+
|
9 |
+
|
10 |
+
public function getId() {
|
11 |
+
return $this->id;
|
12 |
+
}
|
13 |
+
|
14 |
+
|
15 |
+
function __construct() {
|
16 |
+
$this->id = "1";
|
17 |
+
}
|
18 |
+
|
19 |
+
|
20 |
+
public function setExternalSource($externalSource) {
|
21 |
+
$this->externalSource = $externalSource;
|
22 |
+
}
|
23 |
+
public function setId($id) {
|
24 |
+
$this->id = $id;
|
25 |
+
}
|
26 |
+
public function setAddresses($addresses) {
|
27 |
+
$this->addresses = new stdClass();
|
28 |
+
$this->addresses->address = $addresses;
|
29 |
+
}
|
30 |
+
public function getAddresses() {
|
31 |
+
return $this->addresses;
|
32 |
+
}
|
33 |
+
|
34 |
+
public function addresses() {
|
35 |
+
$addresses = array("addresses" => get_object_vars($this->getAddresses()));
|
36 |
+
return $addresses;
|
37 |
+
}
|
38 |
+
|
39 |
+
public function setCustomerAttributes($customerAttributes) {
|
40 |
+
$this->customerAttributes = $customerAttributes;
|
41 |
+
}
|
42 |
+
|
43 |
+
public function setCustomerInfo($id, $firstName, $lastName, $emailAddress, $customerAttributes = array()) {
|
44 |
+
$this->customer = array(
|
45 |
+
"id" => $id,
|
46 |
+
"firstName" => $firstName,
|
47 |
+
"lastName" => $lastName,
|
48 |
+
"emailAddress" => $emailAddress,
|
49 |
+
"customerAttributes" => $customerAttributes
|
50 |
+
);
|
51 |
+
}
|
52 |
+
|
53 |
+
public function getAddressByType($addressType) {
|
54 |
+
if (is_object($this->addresses) && !empty($this->addresses)) {
|
55 |
+
foreach($this->addresses->address as $address) {
|
56 |
+
if($address['addressType'] == $addressType) {
|
57 |
+
return $address;
|
58 |
+
}
|
59 |
+
}
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
63 |
+
|
64 |
+
|
65 |
+
public function toArray() {
|
66 |
+
return get_object_vars($this);
|
67 |
+
}
|
68 |
+
|
69 |
+
}
|
app/code/community/Comrse/ComrseSync/Model/Comrse/Dimension.php
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Comrse_ComrseSync_Model_Comrse_Dimension
|
4 |
+
{
|
5 |
+
|
6 |
+
//-----------------------------------------------------
|
7 |
+
// VARS & CONSTANTS
|
8 |
+
//-----------------------------------------------------
|
9 |
+
private $height;
|
10 |
+
private $width;
|
11 |
+
private $depth;
|
12 |
+
private $girth;
|
13 |
+
private $container;
|
14 |
+
private $size;
|
15 |
+
private $dimension_unit_of_measure;
|
16 |
+
|
17 |
+
//-----------------------------------------------------
|
18 |
+
// GETTERS & SETTERS
|
19 |
+
//-----------------------------------------------------
|
20 |
+
public function getHeight(){
|
21 |
+
return $this->height;
|
22 |
+
}
|
23 |
+
|
24 |
+
public function setHeight($height){
|
25 |
+
$this->height = $height;
|
26 |
+
return $this;
|
27 |
+
}
|
28 |
+
|
29 |
+
public function getWidth(){
|
30 |
+
return $this->width;
|
31 |
+
}
|
32 |
+
|
33 |
+
public function setWidth($width){
|
34 |
+
$this->width = $width;
|
35 |
+
return $this;
|
36 |
+
}
|
37 |
+
|
38 |
+
public function getDepth(){
|
39 |
+
return $this->depth;
|
40 |
+
}
|
41 |
+
|
42 |
+
public function setDepth($depth){
|
43 |
+
$this->depth = $depth;
|
44 |
+
return $this;
|
45 |
+
}
|
46 |
+
|
47 |
+
public function getGirth(){
|
48 |
+
return $this->girth;
|
49 |
+
}
|
50 |
+
|
51 |
+
public function setGirth($girth){
|
52 |
+
$this->girth = $girth;
|
53 |
+
return $this;
|
54 |
+
}
|
55 |
+
|
56 |
+
public function getContainer(){
|
57 |
+
return $this->container;
|
58 |
+
}
|
59 |
+
|
60 |
+
public function setContainer($container){
|
61 |
+
$this->container = $container;
|
62 |
+
return $this;
|
63 |
+
}
|
64 |
+
|
65 |
+
public function getSize(){
|
66 |
+
return $this->size;
|
67 |
+
}
|
68 |
+
|
69 |
+
public function setSize($size){
|
70 |
+
$this->size = $size;
|
71 |
+
}
|
72 |
+
|
73 |
+
public function getDimensionUnitOfMeasure(){
|
74 |
+
return $this->dimension_unit_of_measure;
|
75 |
+
}
|
76 |
+
|
77 |
+
public function setDimensionUnitOfMeasure($dimension_unit_of_measure){
|
78 |
+
$this->dimension_unit_of_measure = $dimension_unit_of_measure;
|
79 |
+
}
|
80 |
+
|
81 |
+
//-----------------------------------------------------
|
82 |
+
// SETUP
|
83 |
+
//-----------------------------------------------------
|
84 |
+
public function __construct() {
|
85 |
+
$this->height = "1";
|
86 |
+
$this->width = "1";
|
87 |
+
$this->depth = "1";
|
88 |
+
$this->girth = "1";
|
89 |
+
$this->container = null;
|
90 |
+
$this->size = "REGULAR";
|
91 |
+
$this->dimension_unit_of_measure = "INCHES";
|
92 |
+
}
|
93 |
+
|
94 |
+
//-----------------------------------------------------
|
95 |
+
// PUBLIC METHODS
|
96 |
+
//-----------------------------------------------------
|
97 |
+
public function toArray() {
|
98 |
+
return get_object_vars($this);
|
99 |
+
}
|
100 |
+
|
101 |
+
|
102 |
+
}
|
app/code/community/Comrse/ComrseSync/Model/Comrse/Geo.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Comrse_ComrseSync_Model_Comrse_Geo {
|
3 |
+
|
4 |
+
private $name;
|
5 |
+
private $abbreviation;
|
6 |
+
private $context;
|
7 |
+
|
8 |
+
public function getName(){
|
9 |
+
return $this->name;
|
10 |
+
}
|
11 |
+
|
12 |
+
public function setName($name){
|
13 |
+
$this->name = $name;
|
14 |
+
return $this;
|
15 |
+
}
|
16 |
+
|
17 |
+
public function getAbbreviation(){
|
18 |
+
return $this->abbreviation;
|
19 |
+
}
|
20 |
+
|
21 |
+
public function setAbbreviation($abbreviation){
|
22 |
+
$this->abbreviation = $abbreviation;
|
23 |
+
return $this;
|
24 |
+
}
|
25 |
+
|
26 |
+
public function getContext(){
|
27 |
+
return $this->context;
|
28 |
+
}
|
29 |
+
|
30 |
+
public function setContext($context){
|
31 |
+
$this->context = $context;
|
32 |
+
return $this;
|
33 |
+
}
|
34 |
+
|
35 |
+
public function toArray($encode = false) {
|
36 |
+
if ($encode)
|
37 |
+
return json_encode(get_object_vars($this));
|
38 |
+
|
39 |
+
return get_object_vars($this);
|
40 |
+
}
|
41 |
+
|
42 |
+
}
|
app/code/community/Comrse/ComrseSync/Model/Comrse/Image.php
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Comrse_ComrseSync_Model_Comrse_Image
|
4 |
+
{
|
5 |
+
|
6 |
+
//-----------------------------------------------------
|
7 |
+
// VARS & CONSTANTS
|
8 |
+
//-----------------------------------------------------
|
9 |
+
private $id;
|
10 |
+
private $title;
|
11 |
+
private $url;
|
12 |
+
private $alt_text;
|
13 |
+
private $orgId;
|
14 |
+
|
15 |
+
//-----------------------------------------------------
|
16 |
+
// GETTERS & SETTERS
|
17 |
+
//-----------------------------------------------------
|
18 |
+
public function getId(){
|
19 |
+
return $this->id;
|
20 |
+
}
|
21 |
+
|
22 |
+
public function setId($id){
|
23 |
+
$this->id = $id;
|
24 |
+
return $this;
|
25 |
+
}
|
26 |
+
|
27 |
+
public function getTitle(){
|
28 |
+
return $this->title;
|
29 |
+
}
|
30 |
+
|
31 |
+
public function setTitle($title){
|
32 |
+
$this->title = $title;
|
33 |
+
return $this;
|
34 |
+
}
|
35 |
+
|
36 |
+
public function getUrl(){
|
37 |
+
return $this->url;
|
38 |
+
}
|
39 |
+
|
40 |
+
public function setUrl($url){
|
41 |
+
$this->url = $url;
|
42 |
+
return $this;
|
43 |
+
}
|
44 |
+
|
45 |
+
public function getAltText(){
|
46 |
+
return $this->alt_text;
|
47 |
+
}
|
48 |
+
|
49 |
+
public function setAltText($alt_text){
|
50 |
+
$this->alt_text = $alt_text;
|
51 |
+
return $this;
|
52 |
+
}
|
53 |
+
|
54 |
+
public function getOrgId(){
|
55 |
+
return $this->orgId;
|
56 |
+
}
|
57 |
+
|
58 |
+
public function setOrgId($orgId){
|
59 |
+
$this->orgId = $orgId;
|
60 |
+
return $this;
|
61 |
+
}
|
62 |
+
|
63 |
+
//-----------------------------------------------------
|
64 |
+
// SETUP
|
65 |
+
//-----------------------------------------------------
|
66 |
+
public function __construct() {
|
67 |
+
// do nothing
|
68 |
+
}
|
69 |
+
|
70 |
+
//-----------------------------------------------------
|
71 |
+
// PUBLIC METHODS
|
72 |
+
//-----------------------------------------------------
|
73 |
+
public function toArray() {
|
74 |
+
return get_object_vars($this);
|
75 |
+
}
|
76 |
+
|
77 |
+
}
|
app/code/community/Comrse/ComrseSync/Model/Comrse/MetricEvent.php
ADDED
@@ -0,0 +1,189 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Comrse_ComrseSync_Model_Comrse_MetricEvent {
|
3 |
+
|
4 |
+
private $brand_id;
|
5 |
+
private $activity_group_id;
|
6 |
+
private $activity_source;
|
7 |
+
private $activity_channel;
|
8 |
+
private $activity;
|
9 |
+
private $activity_timestamp;
|
10 |
+
private $ip_address;
|
11 |
+
private $product_id;
|
12 |
+
private $external_product_id;
|
13 |
+
private $product_name;
|
14 |
+
private $product_price;
|
15 |
+
private $product_sale_price;
|
16 |
+
private $product_quantity;
|
17 |
+
private $product_options;
|
18 |
+
private $email;
|
19 |
+
private $customer_name;
|
20 |
+
|
21 |
+
|
22 |
+
public function getBrandId(){
|
23 |
+
return $this->brand_id;
|
24 |
+
}
|
25 |
+
|
26 |
+
public function setBrandId($brand_id){
|
27 |
+
$this->brand_id = $brand_id;
|
28 |
+
return $this;
|
29 |
+
}
|
30 |
+
|
31 |
+
public function getActivityGroupId(){
|
32 |
+
return $this->activity_group_id;
|
33 |
+
}
|
34 |
+
|
35 |
+
public function setActivityGroupId($activity_group_id){
|
36 |
+
$this->activity_group_id = $activity_group_id;
|
37 |
+
return $this;
|
38 |
+
}
|
39 |
+
|
40 |
+
public function getActivitySource(){
|
41 |
+
return $this->activity_source;
|
42 |
+
}
|
43 |
+
|
44 |
+
public function setActivitySource($activity_source){
|
45 |
+
$this->activity_source = $activity_source;
|
46 |
+
return $this;
|
47 |
+
}
|
48 |
+
|
49 |
+
public function getActivityChannel(){
|
50 |
+
return $this->activity_channel;
|
51 |
+
}
|
52 |
+
|
53 |
+
public function setActivityChannel($activity_channel){
|
54 |
+
$this->activity_channel = $activity_channel;
|
55 |
+
return $this;
|
56 |
+
}
|
57 |
+
|
58 |
+
public function getActivity(){
|
59 |
+
return $this->activity;
|
60 |
+
}
|
61 |
+
|
62 |
+
public function setActivity($activity){
|
63 |
+
$this->activity = $activity;
|
64 |
+
return $this;
|
65 |
+
}
|
66 |
+
|
67 |
+
public function getActivityTimestamp(){
|
68 |
+
return $this->activity_timestamp;
|
69 |
+
}
|
70 |
+
|
71 |
+
public function setActivityTimestamp($activity_timestamp){
|
72 |
+
$this->activity_timestamp = $activity_timestamp;
|
73 |
+
return $this;
|
74 |
+
}
|
75 |
+
|
76 |
+
public function getIpAddress(){
|
77 |
+
return $this->ip_address;
|
78 |
+
}
|
79 |
+
|
80 |
+
public function setIpAddress($ip_address){
|
81 |
+
$this->ip_address = $ip_address;
|
82 |
+
return $this;
|
83 |
+
}
|
84 |
+
|
85 |
+
public function getProductId(){
|
86 |
+
return $this->product_id;
|
87 |
+
}
|
88 |
+
|
89 |
+
public function setProductId($product_id){
|
90 |
+
$this->product_id = $product_id;
|
91 |
+
return $this;
|
92 |
+
}
|
93 |
+
|
94 |
+
public function getExternalProductId(){
|
95 |
+
return $this->external_product_id;
|
96 |
+
}
|
97 |
+
|
98 |
+
public function setExternalProductId($external_product_id){
|
99 |
+
$this->external_product_id = $external_product_id;
|
100 |
+
return $this;
|
101 |
+
}
|
102 |
+
|
103 |
+
public function getProductName(){
|
104 |
+
return $this->product_name;
|
105 |
+
}
|
106 |
+
|
107 |
+
public function setProductName($product_name){
|
108 |
+
$this->product_name = $product_name;
|
109 |
+
return $this;
|
110 |
+
}
|
111 |
+
|
112 |
+
public function getProductPrice(){
|
113 |
+
return $this->product_price;
|
114 |
+
}
|
115 |
+
|
116 |
+
public function setProductPrice($product_price){
|
117 |
+
$this->product_price = number_format($product_price, 2);
|
118 |
+
return $this;
|
119 |
+
}
|
120 |
+
|
121 |
+
public function getProductSalePrice(){
|
122 |
+
return $this->product_sale_price;
|
123 |
+
}
|
124 |
+
|
125 |
+
public function setProductSalePrice($product_sale_price){
|
126 |
+
$this->product_sale_price = number_format($product_sale_price, 2);
|
127 |
+
return $this;
|
128 |
+
}
|
129 |
+
|
130 |
+
public function getProductQuantity(){
|
131 |
+
return $this->product_quantity;
|
132 |
+
}
|
133 |
+
|
134 |
+
public function setProductQuantity($product_quantity){
|
135 |
+
$this->product_quantity = number_format($product_quantity);
|
136 |
+
return $this;
|
137 |
+
}
|
138 |
+
|
139 |
+
public function getProductOptions(){
|
140 |
+
return $this->product_options;
|
141 |
+
}
|
142 |
+
|
143 |
+
public function setProductOptions($product_options){
|
144 |
+
$this->product_options = $product_options;
|
145 |
+
return $this;
|
146 |
+
}
|
147 |
+
|
148 |
+
public function getEmail(){
|
149 |
+
return $this->email;
|
150 |
+
}
|
151 |
+
|
152 |
+
public function setEmail($email){
|
153 |
+
$this->email = $email;
|
154 |
+
return $this;
|
155 |
+
}
|
156 |
+
|
157 |
+
public function getCustomerName(){
|
158 |
+
return $this->customer_name;
|
159 |
+
}
|
160 |
+
|
161 |
+
public function setCustomerName($customer_name){
|
162 |
+
$this->customer_name = $customer_name;
|
163 |
+
return $this;
|
164 |
+
}
|
165 |
+
|
166 |
+
public function addProductOption($mageProductOption) {
|
167 |
+
$this->product_options[$mageProductOption['label']] = $mageProductOption['value'];
|
168 |
+
return $this;
|
169 |
+
}
|
170 |
+
|
171 |
+
public function send($orgData) {
|
172 |
+
#if ($orgData)
|
173 |
+
# $sendMetrics = Mage::helper('comrsesync')->comrseRequest("POST", Comrse_ComrseSync_Model_Config::MCS_API_PATH, $orgData, $this->toArray(true));
|
174 |
+
}
|
175 |
+
|
176 |
+
|
177 |
+
function __construct() {
|
178 |
+
$this->setActivitySource("Platform");
|
179 |
+
$this->setActivityChannel("DotCom");
|
180 |
+
$this->setActivity("Buy");
|
181 |
+
}
|
182 |
+
|
183 |
+
public function toArray($encode = false) {
|
184 |
+
if ($encode)
|
185 |
+
return json_encode(get_object_vars($this));
|
186 |
+
|
187 |
+
return get_object_vars($this);
|
188 |
+
}
|
189 |
+
}
|
app/code/community/Comrse/ComrseSync/Model/Comrse/Order.php
ADDED
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Comrse_ComrseSync_Model_Comrse_Order {
|
4 |
+
|
5 |
+
private $id;
|
6 |
+
private $external_source;
|
7 |
+
private $external_id;
|
8 |
+
private $status;
|
9 |
+
private $submit_date;
|
10 |
+
private $ip_address;
|
11 |
+
private $total_tax;
|
12 |
+
private $total_shipping;
|
13 |
+
private $sub_total;
|
14 |
+
private $total;
|
15 |
+
private $customer;
|
16 |
+
private $order_items;
|
17 |
+
private $order_attributes;
|
18 |
+
private $addresses;
|
19 |
+
|
20 |
+
public function getId(){
|
21 |
+
return $this->id;
|
22 |
+
}
|
23 |
+
|
24 |
+
public function setId($id){
|
25 |
+
$this->id = $id;
|
26 |
+
return $this;
|
27 |
+
}
|
28 |
+
|
29 |
+
public function getExternalSource(){
|
30 |
+
return $this->external_source;
|
31 |
+
}
|
32 |
+
|
33 |
+
public function setExternalSource($external_source){
|
34 |
+
$this->external_source = $external_source;
|
35 |
+
return $this;
|
36 |
+
}
|
37 |
+
|
38 |
+
public function getExternalId(){
|
39 |
+
return $this->external_id;
|
40 |
+
}
|
41 |
+
|
42 |
+
public function setExternalId($external_id){
|
43 |
+
$this->external_id = $external_id;
|
44 |
+
return $this;
|
45 |
+
}
|
46 |
+
|
47 |
+
public function getStatus(){
|
48 |
+
return $this->status;
|
49 |
+
}
|
50 |
+
|
51 |
+
public function setStatus($status){
|
52 |
+
$this->status = $status;
|
53 |
+
return $this;
|
54 |
+
}
|
55 |
+
|
56 |
+
public function getSubmitDate(){
|
57 |
+
return $this->submit_date;
|
58 |
+
}
|
59 |
+
|
60 |
+
public function setSubmitDate($submit_date){
|
61 |
+
$this->submit_date = date(Comrse_ComrseSync_Model_Config::DATE_FORMAT, strtotime($submit_date));
|
62 |
+
return $this;
|
63 |
+
}
|
64 |
+
|
65 |
+
public function getIpAddress(){
|
66 |
+
return $this->ip_address;
|
67 |
+
}
|
68 |
+
|
69 |
+
public function setIpAddress($ip_address){
|
70 |
+
$this->ip_address = $ip_address;
|
71 |
+
return $this;
|
72 |
+
}
|
73 |
+
|
74 |
+
public function getTotalTax(){
|
75 |
+
return $this->total_tax;
|
76 |
+
}
|
77 |
+
|
78 |
+
public function setTotalTax($total_tax){
|
79 |
+
$this->total_tax = Mage::getModel('comrsesync/Comrse_Total')->setAmount($total_tax)->toArray();
|
80 |
+
return $this;
|
81 |
+
}
|
82 |
+
|
83 |
+
public function getTotalShipping(){
|
84 |
+
return $this->total_shipping;
|
85 |
+
}
|
86 |
+
|
87 |
+
public function setTotalShipping($total_shipping){
|
88 |
+
$this->total_shipping = Mage::getModel('comrsesync/Comrse_Total')->setAmount($total_shipping)->toArray();
|
89 |
+
return $this;
|
90 |
+
}
|
91 |
+
|
92 |
+
public function getSubTotal(){
|
93 |
+
return $this->sub_total;
|
94 |
+
}
|
95 |
+
|
96 |
+
public function setSubTotal($sub_total){
|
97 |
+
$this->sub_total = Mage::getModel('comrsesync/Comrse_Total')->setAmount($sub_total)->toArray();
|
98 |
+
return $this;
|
99 |
+
}
|
100 |
+
|
101 |
+
public function getTotal(){
|
102 |
+
return $this->total;
|
103 |
+
}
|
104 |
+
|
105 |
+
public function setTotal($total){
|
106 |
+
$this->total = Mage::getModel('comrsesync/Comrse_Total')->setAmount($total)->toArray();
|
107 |
+
return $this;
|
108 |
+
}
|
109 |
+
|
110 |
+
public function getCustomer(){
|
111 |
+
return $this->customer;
|
112 |
+
}
|
113 |
+
|
114 |
+
public function setCustomer($customer){
|
115 |
+
$this->customer = $customer;
|
116 |
+
return $this;
|
117 |
+
}
|
118 |
+
|
119 |
+
public function getOrderItems(){
|
120 |
+
return $this->order_items;
|
121 |
+
}
|
122 |
+
|
123 |
+
public function setOrderItems($order_items){
|
124 |
+
$this->order_items = $order_items;
|
125 |
+
return $this;
|
126 |
+
}
|
127 |
+
|
128 |
+
public function getAddresses(){
|
129 |
+
return $this->addresses;
|
130 |
+
}
|
131 |
+
|
132 |
+
public function setAddresses($addresses){
|
133 |
+
$this->addresses = $addresses;
|
134 |
+
return $this;
|
135 |
+
}
|
136 |
+
|
137 |
+
public function addOrderItem($order_item) {
|
138 |
+
$this->order_items[] = $order_item;
|
139 |
+
}
|
140 |
+
|
141 |
+
public function addAddress($address) {
|
142 |
+
$this->addresses[] = $address;
|
143 |
+
}
|
144 |
+
|
145 |
+
public function __construct() {
|
146 |
+
$this->external_source = "DotCom";
|
147 |
+
$this->status = "SUBMITTED";
|
148 |
+
$this->order_items = array();
|
149 |
+
}
|
150 |
+
|
151 |
+
public function toArray($encode = false) {
|
152 |
+
if ($encode)
|
153 |
+
return json_encode(get_object_vars($this));
|
154 |
+
|
155 |
+
return get_object_vars($this);
|
156 |
+
}
|
157 |
+
|
158 |
+
}
|
app/code/community/Comrse/ComrseSync/Model/Comrse/OrderItem.php
ADDED
@@ -0,0 +1,204 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Comrse_ComrseSync_Model_Comrse_OrderItem {
|
4 |
+
|
5 |
+
private $id;
|
6 |
+
private $order_id;
|
7 |
+
private $external_id;
|
8 |
+
private $name;
|
9 |
+
private $quantity;
|
10 |
+
private $retail_price;
|
11 |
+
private $sale_price;
|
12 |
+
private $category_id;
|
13 |
+
private $is_bundle;
|
14 |
+
private $sku_id;
|
15 |
+
private $sku_external_id;
|
16 |
+
private $product_id;
|
17 |
+
private $status;
|
18 |
+
private $order_item_attributes;
|
19 |
+
private $order_item_price_details;
|
20 |
+
private $bundle_items;
|
21 |
+
private $qualifiers;
|
22 |
+
private $context;
|
23 |
+
|
24 |
+
|
25 |
+
|
26 |
+
public function getId(){
|
27 |
+
return $this->id;
|
28 |
+
}
|
29 |
+
|
30 |
+
public function setId($id){
|
31 |
+
$this->id = $id;
|
32 |
+
return $this;
|
33 |
+
}
|
34 |
+
|
35 |
+
public function getOrderId(){
|
36 |
+
return $this->order_id;
|
37 |
+
}
|
38 |
+
|
39 |
+
public function setOrderId($order_id){
|
40 |
+
$this->order_id = $order_id;
|
41 |
+
return $this;
|
42 |
+
}
|
43 |
+
|
44 |
+
public function getExternalId(){
|
45 |
+
return $this->external_id;
|
46 |
+
}
|
47 |
+
|
48 |
+
public function setExternalId($external_id){
|
49 |
+
$this->external_id = $external_id;
|
50 |
+
return $this;
|
51 |
+
}
|
52 |
+
|
53 |
+
public function getName(){
|
54 |
+
return $this->name;
|
55 |
+
}
|
56 |
+
|
57 |
+
public function setName($name){
|
58 |
+
$this->name = $name;
|
59 |
+
return $this;
|
60 |
+
}
|
61 |
+
|
62 |
+
public function getQuantity(){
|
63 |
+
return $this->quantity;
|
64 |
+
}
|
65 |
+
|
66 |
+
public function setQuantity($quantity){
|
67 |
+
$this->quantity = $quantity;
|
68 |
+
return $this;
|
69 |
+
}
|
70 |
+
|
71 |
+
public function getRetailPrice(){
|
72 |
+
return $this->retail_price;
|
73 |
+
}
|
74 |
+
|
75 |
+
public function setRetailPrice($retail_price){
|
76 |
+
$this->retail_price = Mage::getModel('comrsesync/Comrse_Total')->setAmount($retail_price)->toArray();
|
77 |
+
return $this;
|
78 |
+
}
|
79 |
+
|
80 |
+
public function getSalePrice(){
|
81 |
+
return $this->sale_price;
|
82 |
+
}
|
83 |
+
|
84 |
+
public function setSalePrice($sale_price){
|
85 |
+
$this->sale_price = Mage::getModel('comrsesync/Comrse_Total')->setAmount($sale_price)->toArray();
|
86 |
+
return $this;
|
87 |
+
}
|
88 |
+
|
89 |
+
public function getCategoryId(){
|
90 |
+
return $this->category_id;
|
91 |
+
}
|
92 |
+
|
93 |
+
public function setCategoryId($category_id){
|
94 |
+
$this->category_id = $category_id;
|
95 |
+
return $this;
|
96 |
+
}
|
97 |
+
|
98 |
+
public function getIsBundle(){
|
99 |
+
return $this->is_bundle;
|
100 |
+
}
|
101 |
+
|
102 |
+
public function setIsBundle($is_bundle){
|
103 |
+
$this->is_bundle = $is_bundle;
|
104 |
+
return $this;
|
105 |
+
}
|
106 |
+
|
107 |
+
public function getSkuId(){
|
108 |
+
return $this->sku_id;
|
109 |
+
}
|
110 |
+
|
111 |
+
public function setSkuId($sku_id){
|
112 |
+
$this->sku_id = $sku_id;
|
113 |
+
return $this;
|
114 |
+
}
|
115 |
+
|
116 |
+
public function getSkuExternalId(){
|
117 |
+
return $this->sku_external_id;
|
118 |
+
}
|
119 |
+
|
120 |
+
public function setSkuExternalId($sku_external_id){
|
121 |
+
$this->sku_external_id = $sku_external_id;
|
122 |
+
return $this;
|
123 |
+
}
|
124 |
+
|
125 |
+
public function getProductId(){
|
126 |
+
return $this->product_id;
|
127 |
+
}
|
128 |
+
|
129 |
+
public function setProductId($product_id){
|
130 |
+
$this->product_id = $product_id;
|
131 |
+
return $this;
|
132 |
+
}
|
133 |
+
|
134 |
+
public function getStatus(){
|
135 |
+
return $this->status;
|
136 |
+
}
|
137 |
+
|
138 |
+
public function setStatus($status){
|
139 |
+
$this->status = $status;
|
140 |
+
return $this;
|
141 |
+
}
|
142 |
+
|
143 |
+
public function getOrderItemAttributes(){
|
144 |
+
return $this->order_item_attributes;
|
145 |
+
}
|
146 |
+
|
147 |
+
public function setOrderItemAttributes($order_item_attributes){
|
148 |
+
$this->order_item_attributes = $order_item_attributes;
|
149 |
+
return $this;
|
150 |
+
}
|
151 |
+
|
152 |
+
public function getOrderItemPriceDetails(){
|
153 |
+
return $this->order_item_price_details;
|
154 |
+
}
|
155 |
+
|
156 |
+
public function setOrderItemPriceDetails($order_item_price_details){
|
157 |
+
$this->order_item_price_details = $order_item_price_details;
|
158 |
+
return $this;
|
159 |
+
}
|
160 |
+
|
161 |
+
public function getBundleItems(){
|
162 |
+
return $this->bundle_items;
|
163 |
+
}
|
164 |
+
|
165 |
+
public function setBundleItems($bundle_items){
|
166 |
+
$this->bundle_items = $bundle_items;
|
167 |
+
return $this;
|
168 |
+
}
|
169 |
+
|
170 |
+
public function getQualifiers(){
|
171 |
+
return $this->qualifiers;
|
172 |
+
}
|
173 |
+
|
174 |
+
public function setQualifiers($qualifiers){
|
175 |
+
$this->qualifiers = $qualifiers;
|
176 |
+
return $this;
|
177 |
+
}
|
178 |
+
|
179 |
+
public function getContext(){
|
180 |
+
return $this->context;
|
181 |
+
}
|
182 |
+
|
183 |
+
public function setContext($context){
|
184 |
+
$this->context = $context;
|
185 |
+
return $this;
|
186 |
+
}
|
187 |
+
|
188 |
+
public function addOrderItemAttribute($itemOption){
|
189 |
+
$this->order_item_attributes[] = Mage::getModel('comrsesync/Comrse_OrderItemAttribute')->setName($itemOption['label'])->setValue($itemOption['value'])->toArray();
|
190 |
+
return $this;
|
191 |
+
}
|
192 |
+
|
193 |
+
public function toArray($encode = false) {
|
194 |
+
if ($encode)
|
195 |
+
return json_encode(get_object_vars($this));
|
196 |
+
|
197 |
+
return get_object_vars($this);
|
198 |
+
}
|
199 |
+
|
200 |
+
public function __construct() {
|
201 |
+
$this->is_bundle = "false";
|
202 |
+
}
|
203 |
+
|
204 |
+
}
|
app/code/community/Comrse/ComrseSync/Model/Comrse/OrderItemAttribute.php
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Comrse_ComrseSync_Model_Comrse_OrderItemAttribute {
|
4 |
+
|
5 |
+
private $id;
|
6 |
+
private $name;
|
7 |
+
private $value;
|
8 |
+
private $order_item_id;
|
9 |
+
private $context;
|
10 |
+
|
11 |
+
public function getId(){
|
12 |
+
return $this->id;
|
13 |
+
}
|
14 |
+
|
15 |
+
public function setId($id){
|
16 |
+
$this->id = $id;
|
17 |
+
return $this;
|
18 |
+
}
|
19 |
+
|
20 |
+
public function getName(){
|
21 |
+
return $this->name;
|
22 |
+
}
|
23 |
+
|
24 |
+
public function setName($name){
|
25 |
+
$this->name = $name;
|
26 |
+
return $this;
|
27 |
+
}
|
28 |
+
|
29 |
+
public function getValue(){
|
30 |
+
return $this->value;
|
31 |
+
}
|
32 |
+
|
33 |
+
public function setValue($value){
|
34 |
+
$this->value = $value;
|
35 |
+
return $this;
|
36 |
+
}
|
37 |
+
|
38 |
+
public function getOrderItemId(){
|
39 |
+
return $this->order_item_id;
|
40 |
+
}
|
41 |
+
|
42 |
+
public function setOrderItemId($order_item_id){
|
43 |
+
$this->order_item_id = $order_item_id;
|
44 |
+
}
|
45 |
+
|
46 |
+
public function getContext(){
|
47 |
+
return $this->context;
|
48 |
+
}
|
49 |
+
|
50 |
+
public function setContext($context){
|
51 |
+
$this->context = $context;
|
52 |
+
}
|
53 |
+
|
54 |
+
public function toArray($encode = false) {
|
55 |
+
if ($encode)
|
56 |
+
return json_encode(get_object_vars($this));
|
57 |
+
|
58 |
+
return get_object_vars($this);
|
59 |
+
}
|
60 |
+
}
|
app/code/community/Comrse/ComrseSync/Model/Comrse/Phone.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Comrse_ComrseSync_Model_Comrse_Phone {
|
3 |
+
|
4 |
+
private $id;
|
5 |
+
private $phone_number;
|
6 |
+
private $is_active;
|
7 |
+
private $is_default;
|
8 |
+
private $context;
|
9 |
+
|
10 |
+
public function getId(){
|
11 |
+
return $this->id;
|
12 |
+
}
|
13 |
+
|
14 |
+
public function setId($id){
|
15 |
+
$this->id = $id;
|
16 |
+
return $this;
|
17 |
+
}
|
18 |
+
|
19 |
+
public function getPhoneNumber(){
|
20 |
+
return $this->phone_number;
|
21 |
+
}
|
22 |
+
|
23 |
+
public function setPhoneNumber($phone_number){
|
24 |
+
$this->phone_number = $phone_number;
|
25 |
+
return $this;
|
26 |
+
}
|
27 |
+
|
28 |
+
public function getIsActive(){
|
29 |
+
return $this->is_active;
|
30 |
+
}
|
31 |
+
|
32 |
+
public function setIsActive($is_active){
|
33 |
+
$this->is_active = $is_active;
|
34 |
+
return $this;
|
35 |
+
}
|
36 |
+
|
37 |
+
public function getIsDefault(){
|
38 |
+
return $this->is_default;
|
39 |
+
}
|
40 |
+
|
41 |
+
public function setIsDefault($is_default){
|
42 |
+
$this->is_default = $is_default;
|
43 |
+
return $this;
|
44 |
+
}
|
45 |
+
|
46 |
+
public function getContext(){
|
47 |
+
return $this->context;
|
48 |
+
}
|
49 |
+
|
50 |
+
public function setContext($context){
|
51 |
+
$this->context = $context;
|
52 |
+
return $this;
|
53 |
+
}
|
54 |
+
|
55 |
+
public function toArray($encode = false) {
|
56 |
+
if ($encode)
|
57 |
+
return json_encode(get_object_vars($this));
|
58 |
+
|
59 |
+
return get_object_vars($this);
|
60 |
+
}
|
61 |
+
}
|
app/code/community/Comrse/ComrseSync/Model/Comrse/Price.php
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Comrse_ComrseSync_Model_Comrse_Price
|
4 |
+
{
|
5 |
+
|
6 |
+
//-----------------------------------------------------
|
7 |
+
// VARS & CONSTANTS
|
8 |
+
//-----------------------------------------------------
|
9 |
+
private $amount;
|
10 |
+
private $currency;
|
11 |
+
|
12 |
+
//-----------------------------------------------------
|
13 |
+
// GETTERS & SETTERS
|
14 |
+
//-----------------------------------------------------
|
15 |
+
public function getAmount(){
|
16 |
+
return $this->amount;
|
17 |
+
}
|
18 |
+
|
19 |
+
public function setAmount($amount){
|
20 |
+
$this->amount = number_format($amount, 2, '.', '');
|
21 |
+
return $this;
|
22 |
+
}
|
23 |
+
|
24 |
+
public function getCurrency(){
|
25 |
+
return $this->currency;
|
26 |
+
}
|
27 |
+
|
28 |
+
public function setCurrency($currency){
|
29 |
+
$this->currency = $currency;
|
30 |
+
return $this;
|
31 |
+
}
|
32 |
+
|
33 |
+
//-----------------------------------------------------
|
34 |
+
// SETUP
|
35 |
+
//-----------------------------------------------------
|
36 |
+
public function __construct() {
|
37 |
+
$this->currency = Mage::getModel('comrsesync/Comrse_Currency')->toArray();
|
38 |
+
}
|
39 |
+
|
40 |
+
//-----------------------------------------------------
|
41 |
+
// PUBLIC METHODS
|
42 |
+
//-----------------------------------------------------
|
43 |
+
public function toArray() {
|
44 |
+
return get_object_vars($this);
|
45 |
+
}
|
46 |
+
|
47 |
+
|
48 |
+
}
|
app/code/community/Comrse/ComrseSync/Model/Comrse/Product.php
ADDED
@@ -0,0 +1,200 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Comrse_ComrseSync_Model_Comrse_Product
|
4 |
+
{
|
5 |
+
|
6 |
+
//-----------------------------------------------------
|
7 |
+
// VARS & CONSTANTS
|
8 |
+
//-----------------------------------------------------
|
9 |
+
private $id;
|
10 |
+
private $external_id;
|
11 |
+
private $name;
|
12 |
+
private $long_description;
|
13 |
+
private $dimension;
|
14 |
+
private $weight;
|
15 |
+
private $retail_price;
|
16 |
+
private $sale_price;
|
17 |
+
private $primary_media;
|
18 |
+
private $active;
|
19 |
+
private $active_start_date;
|
20 |
+
private $active_end_date;
|
21 |
+
private $manufacturer;
|
22 |
+
private $default_category_id;
|
23 |
+
private $product_attributes;
|
24 |
+
private $product_options;
|
25 |
+
private $media;
|
26 |
+
|
27 |
+
//-----------------------------------------------------
|
28 |
+
// GETTERS & SETTERS
|
29 |
+
//-----------------------------------------------------
|
30 |
+
public function getId(){
|
31 |
+
return $this->id;
|
32 |
+
}
|
33 |
+
|
34 |
+
public function setId($id){
|
35 |
+
$this->id = $id;
|
36 |
+
return $this;
|
37 |
+
}
|
38 |
+
|
39 |
+
public function getExternalId(){
|
40 |
+
return $this->external_id;
|
41 |
+
}
|
42 |
+
|
43 |
+
public function setExternalId($external_id){
|
44 |
+
$this->external_id = $external_id;
|
45 |
+
return $this;
|
46 |
+
}
|
47 |
+
|
48 |
+
public function getName(){
|
49 |
+
return $this->name;
|
50 |
+
}
|
51 |
+
|
52 |
+
public function setName($name){
|
53 |
+
$this->name = $name;
|
54 |
+
return $this;
|
55 |
+
}
|
56 |
+
|
57 |
+
public function getLongDescription(){
|
58 |
+
return $this->long_description;
|
59 |
+
}
|
60 |
+
|
61 |
+
public function setLongDescription($long_description){
|
62 |
+
$this->long_description = $long_description;
|
63 |
+
return $this;
|
64 |
+
}
|
65 |
+
|
66 |
+
public function getDimension(){
|
67 |
+
return $this->dimension;
|
68 |
+
}
|
69 |
+
|
70 |
+
public function setDimension($dimension){
|
71 |
+
$this->dimension = $dimension;
|
72 |
+
return $this;
|
73 |
+
}
|
74 |
+
|
75 |
+
public function getWeight(){
|
76 |
+
return $this->weight;
|
77 |
+
}
|
78 |
+
|
79 |
+
public function setWeight($weight){
|
80 |
+
$this->weight = $weight;
|
81 |
+
return $this;
|
82 |
+
}
|
83 |
+
|
84 |
+
public function getRetailPrice(){
|
85 |
+
return $this->retail_price;
|
86 |
+
}
|
87 |
+
|
88 |
+
public function setRetailPrice($retail_price){
|
89 |
+
$this->retail_price = $retail_price;
|
90 |
+
return $this;
|
91 |
+
}
|
92 |
+
|
93 |
+
public function getSalePrice(){
|
94 |
+
return $this->sale_price;
|
95 |
+
}
|
96 |
+
|
97 |
+
public function setSalePrice($sale_price){
|
98 |
+
$this->sale_price = $sale_price;
|
99 |
+
return $this;
|
100 |
+
}
|
101 |
+
|
102 |
+
public function getPrimaryMedia(){
|
103 |
+
return $this->primary_media;
|
104 |
+
}
|
105 |
+
|
106 |
+
public function setPrimaryMedia($primary_media){
|
107 |
+
$this->primary_media = $primary_media;
|
108 |
+
return $this;
|
109 |
+
}
|
110 |
+
|
111 |
+
public function getActive(){
|
112 |
+
return $this->active;
|
113 |
+
}
|
114 |
+
|
115 |
+
public function setActive($active){
|
116 |
+
$this->active = $active;
|
117 |
+
return $this;
|
118 |
+
}
|
119 |
+
|
120 |
+
public function getActiveStartDate(){
|
121 |
+
return $this->active_start_date;
|
122 |
+
}
|
123 |
+
|
124 |
+
public function setActiveStartDate($active_start_date){
|
125 |
+
$this->active_start_date = $active_start_date;
|
126 |
+
return $this;
|
127 |
+
}
|
128 |
+
|
129 |
+
public function getActiveEndDate(){
|
130 |
+
return $this->active_end_date;
|
131 |
+
}
|
132 |
+
|
133 |
+
public function setActiveEndDate($active_end_date){
|
134 |
+
$this->active_end_date = $active_end_date;
|
135 |
+
return $this;
|
136 |
+
}
|
137 |
+
|
138 |
+
public function getManufacturer(){
|
139 |
+
return $this->manufacturer;
|
140 |
+
}
|
141 |
+
|
142 |
+
public function setManufacturer($manufacturer){
|
143 |
+
$this->manufacturer = $manufacturer;
|
144 |
+
return $this;
|
145 |
+
}
|
146 |
+
|
147 |
+
public function getDefaultCategoryId(){
|
148 |
+
return $this->default_category_id;
|
149 |
+
}
|
150 |
+
|
151 |
+
public function setDefaultCategoryId($default_category_id){
|
152 |
+
$this->default_category_id = $default_category_id;
|
153 |
+
return $this;
|
154 |
+
}
|
155 |
+
|
156 |
+
public function getProductAttributes(){
|
157 |
+
return $this->product_attributes;
|
158 |
+
}
|
159 |
+
|
160 |
+
public function setProductAttributes($product_attributes){
|
161 |
+
$this->product_attributes = $product_attributes;
|
162 |
+
return $this;
|
163 |
+
}
|
164 |
+
|
165 |
+
public function getProductOptions(){
|
166 |
+
return $this->product_options;
|
167 |
+
}
|
168 |
+
|
169 |
+
public function setProductOptions($product_options){
|
170 |
+
$this->product_options = $product_options;
|
171 |
+
return $this;
|
172 |
+
}
|
173 |
+
|
174 |
+
public function getMedia(){
|
175 |
+
return $this->media;
|
176 |
+
}
|
177 |
+
|
178 |
+
public function setMedia($media){
|
179 |
+
$this->media = $media;
|
180 |
+
return $this;
|
181 |
+
}
|
182 |
+
|
183 |
+
//-----------------------------------------------------
|
184 |
+
// SETUP
|
185 |
+
//-----------------------------------------------------
|
186 |
+
public function __construct() {
|
187 |
+
// do nothing
|
188 |
+
}
|
189 |
+
|
190 |
+
//-----------------------------------------------------
|
191 |
+
// PUBLIC METHODS
|
192 |
+
//-----------------------------------------------------
|
193 |
+
public function toArray($encode = false) {
|
194 |
+
if ($encode)
|
195 |
+
return json_encode(get_object_vars($this));
|
196 |
+
|
197 |
+
return get_object_vars($this);
|
198 |
+
}
|
199 |
+
|
200 |
+
}
|
app/code/community/Comrse/ComrseSync/Model/Comrse/ProductCategory.php
ADDED
@@ -0,0 +1,172 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Comrse_ComrseSync_Model_Comrse_ProductCategory
|
4 |
+
{
|
5 |
+
|
6 |
+
//-----------------------------------------------------
|
7 |
+
// VARS & CONSTANTS
|
8 |
+
//-----------------------------------------------------
|
9 |
+
private $id;
|
10 |
+
private $external_id;
|
11 |
+
private $name;
|
12 |
+
private $description;
|
13 |
+
private $active;
|
14 |
+
private $url;
|
15 |
+
private $url_key;
|
16 |
+
private $active_start_date;
|
17 |
+
private $active_end_date;
|
18 |
+
private $subcategories;
|
19 |
+
private $products;
|
20 |
+
private $category_attributes;
|
21 |
+
private $organization_id;
|
22 |
+
|
23 |
+
|
24 |
+
//-----------------------------------------------------
|
25 |
+
// GETTERS & SETTERS
|
26 |
+
//-----------------------------------------------------
|
27 |
+
public function getId(){
|
28 |
+
return $this->id;
|
29 |
+
}
|
30 |
+
|
31 |
+
public function setId($id){
|
32 |
+
$this->id = $id;
|
33 |
+
return $this;
|
34 |
+
}
|
35 |
+
|
36 |
+
public function getExternalId(){
|
37 |
+
return $this->external_id;
|
38 |
+
}
|
39 |
+
|
40 |
+
public function setExternalId($external_id){
|
41 |
+
$this->external_id = $external_id;
|
42 |
+
return $this;
|
43 |
+
}
|
44 |
+
|
45 |
+
public function getName(){
|
46 |
+
return $this->name;
|
47 |
+
}
|
48 |
+
|
49 |
+
public function setName($name){
|
50 |
+
$this->name = $name;
|
51 |
+
return $this;
|
52 |
+
}
|
53 |
+
|
54 |
+
public function getDescription(){
|
55 |
+
return $this->description;
|
56 |
+
}
|
57 |
+
|
58 |
+
public function setDescription($description){
|
59 |
+
$this->description = $description;
|
60 |
+
return $this;
|
61 |
+
}
|
62 |
+
|
63 |
+
public function getActive(){
|
64 |
+
return $this->active;
|
65 |
+
}
|
66 |
+
|
67 |
+
public function setActive($active){
|
68 |
+
$this->active = $active;
|
69 |
+
return $this;
|
70 |
+
}
|
71 |
+
|
72 |
+
public function getUrl(){
|
73 |
+
return $this->url;
|
74 |
+
}
|
75 |
+
|
76 |
+
public function setUrl($url){
|
77 |
+
$this->url = $url;
|
78 |
+
return $this;
|
79 |
+
}
|
80 |
+
|
81 |
+
public function getUrlKey(){
|
82 |
+
return $this->url_key;
|
83 |
+
}
|
84 |
+
|
85 |
+
public function setUrlKey($url_key){
|
86 |
+
$this->url_key = $url_key;
|
87 |
+
return $this;
|
88 |
+
}
|
89 |
+
|
90 |
+
public function getActiveStartDate(){
|
91 |
+
return $this->active_start_date;
|
92 |
+
}
|
93 |
+
|
94 |
+
public function setActiveStartDate($active_start_date){
|
95 |
+
$this->active_start_date = $active_start_date;
|
96 |
+
return $this;
|
97 |
+
}
|
98 |
+
|
99 |
+
public function getActiveEndDate(){
|
100 |
+
return $this->active_end_date;
|
101 |
+
}
|
102 |
+
|
103 |
+
public function setActiveEndDate($active_end_date){
|
104 |
+
$this->active_end_date = $active_end_date;
|
105 |
+
return $this;
|
106 |
+
}
|
107 |
+
|
108 |
+
public function getSubcategories(){
|
109 |
+
return $this->subcategories;
|
110 |
+
}
|
111 |
+
|
112 |
+
public function setSubcategories($subcategories){
|
113 |
+
$this->subcategories["category"] = $subcategories;
|
114 |
+
return $this;
|
115 |
+
}
|
116 |
+
|
117 |
+
public function getProducts(){
|
118 |
+
return $this->products;
|
119 |
+
}
|
120 |
+
|
121 |
+
public function setProducts($products){
|
122 |
+
$this->products = $products;
|
123 |
+
return $this;
|
124 |
+
}
|
125 |
+
|
126 |
+
public function getCategoryAttributes(){
|
127 |
+
return $this->category_attributes;
|
128 |
+
}
|
129 |
+
|
130 |
+
public function setCategoryAttributes($category_attributes){
|
131 |
+
$this->category_attributes = $category_attributes;
|
132 |
+
return $this;
|
133 |
+
}
|
134 |
+
|
135 |
+
public function getOrganizationId(){
|
136 |
+
return $this->organization_id;
|
137 |
+
}
|
138 |
+
|
139 |
+
public function setOrganizationId($organization_id){
|
140 |
+
$this->organization_id = $organization_id;
|
141 |
+
return $this;
|
142 |
+
}
|
143 |
+
|
144 |
+
public function addSubCategory($subCategory) {
|
145 |
+
$this->subcategories["category"][] = $subCategory;
|
146 |
+
return $this;
|
147 |
+
}
|
148 |
+
|
149 |
+
public function addProduct($productId) {
|
150 |
+
$this->products["product"][] = array("external_id" => $productId);
|
151 |
+
return $this;
|
152 |
+
}
|
153 |
+
|
154 |
+
|
155 |
+
//-----------------------------------------------------
|
156 |
+
// SETUP
|
157 |
+
//-----------------------------------------------------
|
158 |
+
public function __construct() {
|
159 |
+
// do nothing
|
160 |
+
}
|
161 |
+
|
162 |
+
//-----------------------------------------------------
|
163 |
+
// PUBLIC METHODS
|
164 |
+
//-----------------------------------------------------
|
165 |
+
public function toArray($encode = false) {
|
166 |
+
if ($encode)
|
167 |
+
return json_encode(get_object_vars($this));
|
168 |
+
|
169 |
+
return get_object_vars($this);
|
170 |
+
}
|
171 |
+
|
172 |
+
}
|
app/code/community/Comrse/ComrseSync/Model/Comrse/ProductOption.php
ADDED
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Comrse_ComrseSync_Model_Comrse_ProductOption
|
4 |
+
{
|
5 |
+
|
6 |
+
//-----------------------------------------------------
|
7 |
+
// VARS & CONSTANTS
|
8 |
+
//-----------------------------------------------------
|
9 |
+
private $attribute_name;
|
10 |
+
private $label;
|
11 |
+
private $external_id;
|
12 |
+
private $required;
|
13 |
+
private $product_option_type;
|
14 |
+
private $allowed_values;
|
15 |
+
private $display_order;
|
16 |
+
|
17 |
+
//-----------------------------------------------------
|
18 |
+
// GETTERS & SETTERS
|
19 |
+
//-----------------------------------------------------
|
20 |
+
public function getAttributeName(){
|
21 |
+
return $this->attribute_name;
|
22 |
+
}
|
23 |
+
|
24 |
+
public function setAttributeName($attribute_name){
|
25 |
+
$this->attribute_name = $attribute_name;
|
26 |
+
return $this;
|
27 |
+
}
|
28 |
+
|
29 |
+
public function getLabel(){
|
30 |
+
return $this->label;
|
31 |
+
}
|
32 |
+
|
33 |
+
public function setLabel($label){
|
34 |
+
$this->label = $label;
|
35 |
+
return $this;
|
36 |
+
}
|
37 |
+
|
38 |
+
public function getExternalId(){
|
39 |
+
return $this->external_id;
|
40 |
+
}
|
41 |
+
|
42 |
+
public function setExternalId($external_id){
|
43 |
+
$this->external_id = $external_id;
|
44 |
+
return $this;
|
45 |
+
}
|
46 |
+
|
47 |
+
public function getRequired(){
|
48 |
+
return $this->required;
|
49 |
+
}
|
50 |
+
|
51 |
+
public function setRequired($required){
|
52 |
+
$this->required = $required;
|
53 |
+
return $this;
|
54 |
+
}
|
55 |
+
|
56 |
+
public function getProductOptionType(){
|
57 |
+
return $this->product_option_type;
|
58 |
+
}
|
59 |
+
|
60 |
+
public function setProductOptionType($product_option_type){
|
61 |
+
$this->product_option_type = $product_option_type;
|
62 |
+
return $this;
|
63 |
+
}
|
64 |
+
|
65 |
+
public function getAllowedValues(){
|
66 |
+
return $this->allowed_values;
|
67 |
+
}
|
68 |
+
|
69 |
+
public function setAllowedValues($allowed_values){
|
70 |
+
$this->allowed_values = $allowed_values;
|
71 |
+
return $this;
|
72 |
+
}
|
73 |
+
|
74 |
+
public function getDisplayOrder(){
|
75 |
+
return $this->displayOrder;
|
76 |
+
}
|
77 |
+
|
78 |
+
public function setDisplayOrder($display_order){
|
79 |
+
$this->display_order = $display_order;
|
80 |
+
return $this;
|
81 |
+
}
|
82 |
+
|
83 |
+
//-----------------------------------------------------
|
84 |
+
// SETUP
|
85 |
+
//-----------------------------------------------------
|
86 |
+
public function __construct() {
|
87 |
+
// do nothing
|
88 |
+
}
|
89 |
+
|
90 |
+
//-----------------------------------------------------
|
91 |
+
// PUBLIC METHODS
|
92 |
+
//-----------------------------------------------------
|
93 |
+
public function toArray() {
|
94 |
+
return get_object_vars($this);
|
95 |
+
}
|
96 |
+
|
97 |
+
}
|
app/code/community/Comrse/ComrseSync/Model/Comrse/Total.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Comrse_ComrseSync_Model_Comrse_Total {
|
3 |
+
|
4 |
+
private $amount;
|
5 |
+
private $currency;
|
6 |
+
|
7 |
+
function __construct(){
|
8 |
+
$this->setCurrency();
|
9 |
+
}
|
10 |
+
|
11 |
+
public function getAmount(){
|
12 |
+
return $this->amount;
|
13 |
+
}
|
14 |
+
|
15 |
+
public function setAmount($amount){
|
16 |
+
$this->amount = number_format($amount, 2);
|
17 |
+
return $this;
|
18 |
+
}
|
19 |
+
|
20 |
+
public function getCurrency(){
|
21 |
+
return $this->currency;
|
22 |
+
}
|
23 |
+
|
24 |
+
public function setCurrency($currency){
|
25 |
+
$this->currency = Mage::getModel('comrsesync/Comrse_Currency')->toArray();
|
26 |
+
return $this;
|
27 |
+
}
|
28 |
+
|
29 |
+
public function toArray($encode = false) {
|
30 |
+
if ($encode)
|
31 |
+
return json_encode(get_object_vars($this));
|
32 |
+
|
33 |
+
return get_object_vars($this);
|
34 |
+
}
|
35 |
+
|
36 |
+
}
|
app/code/community/Comrse/ComrseSync/Model/Comrse/Weight.php
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Comrse_ComrseSync_Model_Comrse_Weight
|
4 |
+
{
|
5 |
+
|
6 |
+
//-----------------------------------------------------
|
7 |
+
// VARS & CONSTANTS
|
8 |
+
//-----------------------------------------------------
|
9 |
+
private $weight;
|
10 |
+
private $unit_of_measure;
|
11 |
+
|
12 |
+
//-----------------------------------------------------
|
13 |
+
// GETTERS & SETTERS
|
14 |
+
//-----------------------------------------------------
|
15 |
+
public function getWeight(){
|
16 |
+
return $this->weight;
|
17 |
+
}
|
18 |
+
|
19 |
+
public function setWeight($weight){
|
20 |
+
$this->weight = $weight;
|
21 |
+
return $this;
|
22 |
+
}
|
23 |
+
|
24 |
+
public function getUnitOfMeasure(){
|
25 |
+
return $this->unit_of_measure;
|
26 |
+
}
|
27 |
+
|
28 |
+
public function setUnitOfMeasure($unit_of_measure){
|
29 |
+
$this->unit_of_measure = $unit_of_measure;
|
30 |
+
return $this;
|
31 |
+
}
|
32 |
+
|
33 |
+
//-----------------------------------------------------
|
34 |
+
// SETUP
|
35 |
+
//-----------------------------------------------------
|
36 |
+
public function __construct() {
|
37 |
+
// do nothing
|
38 |
+
$this->unit_of_measure = "POUNDS";
|
39 |
+
}
|
40 |
+
|
41 |
+
//-----------------------------------------------------
|
42 |
+
// PUBLIC METHODS
|
43 |
+
//-----------------------------------------------------
|
44 |
+
public function toArray() {
|
45 |
+
return get_object_vars($this);
|
46 |
+
}
|
47 |
+
|
48 |
+
|
49 |
+
}
|
app/code/community/Comrse/ComrseSync/Model/Comrseconnect.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Comrse_ComrseSync_Model_Comrseconnect extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
+
public function _construct()
|
7 |
+
{
|
8 |
+
try{
|
9 |
+
parent::_construct();
|
10 |
+
$this->_init('comrsesync/comrseconnect');
|
11 |
+
}
|
12 |
+
catch(Exception $e){
|
13 |
+
Mage::log('Comrse Connect Mode: '.$e->getMessage());
|
14 |
+
}
|
15 |
+
}
|
16 |
+
}
|
app/code/community/Comrse/ComrseSync/Model/Config.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Comr.se Config
|
5 |
+
* - shared environment variables
|
6 |
+
* @author Z @ Comr.se
|
7 |
+
* @version 1.1.5
|
8 |
+
* @since 1.1.4.1
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Comrse_ComrseSync_Model_Config
|
12 |
+
{
|
13 |
+
const API_PATH = "http://omni.comr.se/1.0/";
|
14 |
+
const CART_API_PATH = "http://cart-api.comr.se/index.php/";
|
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 = 50;
|
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";
|
22 |
+
}
|
app/code/community/Comrse/ComrseSync/Model/Data.php
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Comrse_ComrseSync_Helper_Data extends Mage_Core_Helper_Abstract {
|
3 |
+
|
4 |
+
// encrypt value
|
5 |
+
public function encrypt($value) {
|
6 |
+
try{
|
7 |
+
error_reporting(0);
|
8 |
+
$digested = base64_encode(hash('sha256', $value, true));
|
9 |
+
return $digested;
|
10 |
+
}
|
11 |
+
catch(Exception $e){
|
12 |
+
Mage::log("Comr.se Data Ecryption Failure: ".$e->getMessage());
|
13 |
+
}
|
14 |
+
}
|
15 |
+
|
16 |
+
|
17 |
+
// comrse request
|
18 |
+
public function comrseRequest($method, $targetUrl, $orgData, $postData = NULL, $contentType = NULL, $time = NULL, $debug = 0) {
|
19 |
+
|
20 |
+
// if time not passed
|
21 |
+
if (is_null($time))
|
22 |
+
$time = file_get_contents(Comrse_ComrseSync_Model_Config::TIME_PATH);
|
23 |
+
|
24 |
+
// if time not passed
|
25 |
+
if (is_null($contentType))
|
26 |
+
$contentType = "application/json";
|
27 |
+
|
28 |
+
// prepare header
|
29 |
+
$headerArray = array(
|
30 |
+
"Content-Type: " . $contentType,
|
31 |
+
"X-Comrse-Token: " . $orgData->getToken(),
|
32 |
+
"X-Comrse-Version: " . Comrse_ComrseSync_Model_Config::COMRSE_API_VERSION,
|
33 |
+
"Connection: close"
|
34 |
+
);
|
35 |
+
|
36 |
+
$ch = curl_init($targetUrl);
|
37 |
+
|
38 |
+
// if POST Data is present
|
39 |
+
if (!is_null($postData))
|
40 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
|
41 |
+
|
42 |
+
// method
|
43 |
+
if ($method == "POST")
|
44 |
+
curl_setopt($ch, CURLOPT_POST, true);
|
45 |
+
else
|
46 |
+
curl_setopt($ch,CURLOPT_CUSTOMREQUEST, $method);
|
47 |
+
|
48 |
+
curl_setopt($ch,CURLOPT_HTTPHEADER, $headerArray);
|
49 |
+
curl_setopt($ch,CURLOPT_HEADER, $debug);
|
50 |
+
curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
|
51 |
+
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, FALSE);
|
52 |
+
|
53 |
+
$result = curl_exec($ch);
|
54 |
+
|
55 |
+
return $result;
|
56 |
+
}
|
57 |
+
|
58 |
+
|
59 |
+
// basic request
|
60 |
+
public function basicRequest($path, $method = "GET") {
|
61 |
+
try {
|
62 |
+
$ch = curl_init();
|
63 |
+
curl_setopt($ch,CURLOPT_URL, $path);
|
64 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
65 |
+
"Connection: close"
|
66 |
+
));
|
67 |
+
curl_setopt($ch,CURLOPT_CUSTOMREQUEST, $method);
|
68 |
+
curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
|
69 |
+
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, FALSE);
|
70 |
+
$result = curl_exec($ch);
|
71 |
+
curl_close($ch);
|
72 |
+
return $result;
|
73 |
+
}
|
74 |
+
catch (Exception $e) {
|
75 |
+
Mage::log("Comrse Basic HTTP Request: ".$e->getMessage());
|
76 |
+
return false;
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
|
81 |
+
|
82 |
+
|
83 |
+
}
|
app/code/community/Comrse/ComrseSync/Model/Datasync.php
ADDED
@@ -0,0 +1,281 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Comr.se Ongoing Sync & Payment Method
|
5 |
+
*
|
6 |
+
* @author Zabel @ Comr.se
|
7 |
+
* @copyright 2014 Comr.se
|
8 |
+
* @version 1.1.4.1
|
9 |
+
* @since 0.0.1
|
10 |
+
* @todo replace order arrays with object model
|
11 |
+
*/
|
12 |
+
|
13 |
+
class Comrse_ComrseSync_Model_Datasync extends Mage_Payment_Model_Method_Abstract
|
14 |
+
{
|
15 |
+
/*
|
16 |
+
* COMRSE PAYMENT METHOD SETTINGS
|
17 |
+
* - allows external payment methods
|
18 |
+
* - does not appear during normal checkout in properly configured/current Magento installations
|
19 |
+
*/
|
20 |
+
protected $_code = 'comrsesync';
|
21 |
+
protected $_isGateway = false;
|
22 |
+
protected $_canAuthorize = false;
|
23 |
+
protected $_canCapture = false;
|
24 |
+
protected $_canCapturePartial = false;
|
25 |
+
protected $_canRefund = false;
|
26 |
+
protected $_canVoid = true;
|
27 |
+
protected $_canUseInternal = true;
|
28 |
+
protected $_canUseCheckout = false;
|
29 |
+
protected $_canUseForMultishipping = false;
|
30 |
+
protected $_canSaveCc = false;
|
31 |
+
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Payment Refunded Handling
|
35 |
+
*/
|
36 |
+
public function paymentRefund(Varien_Event_Observer $observer)
|
37 |
+
{
|
38 |
+
error_reporting(0);
|
39 |
+
ini_set('display_errors',0);
|
40 |
+
try
|
41 |
+
{
|
42 |
+
$mageEventData = $observer->getEvent()->getData();
|
43 |
+
$mageOrderPayment = $mageEventData['payment'];
|
44 |
+
$mageOrder = $mageOrderPayment->getOrder();
|
45 |
+
$normalizedOrder = Mage::helper('comrsesync/order')->normalizeOrderData($mageOrder, false, "RETURNED");
|
46 |
+
$orgData = Mage::getModel('comrsesync/comrseconnect')->load(Comrse_ComrseSync_Model_Config::COMRSE_RECORD_ROW_ID);
|
47 |
+
$postOrder = Mage::helper('comrsesync')->comrseRequest("POST", Comrse_ComrseSync_Model_Config::API_PATH . "organizations/" . $orgData->getOrg() . "/orders?metrics_only=false", $orgData, json_encode($normalizedOrder));
|
48 |
+
}
|
49 |
+
catch (Exception $e)
|
50 |
+
{
|
51 |
+
Mage::log("Comrse - Error capturing payment refund: {$e->getMessage()}");
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
|
56 |
+
/**
|
57 |
+
* ORDER PRICE MANIPULATION
|
58 |
+
* - uses price set in Comr.se for total amount
|
59 |
+
* - single product usage
|
60 |
+
* @todo secure stock sync
|
61 |
+
*/
|
62 |
+
public function orderSave(Varien_Event_Observer $observer)
|
63 |
+
{
|
64 |
+
error_reporting(0);
|
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 |
+
|
72 |
+
if (!$storeDisabled)
|
73 |
+
{
|
74 |
+
$mageOrder = $observer->getOrder();
|
75 |
+
$orderData = $mageOrder->getData();
|
76 |
+
|
77 |
+
$customerEmailAddress = (!empty($orderData['customer_email']) ? $orderData['customer_email'] : "");
|
78 |
+
|
79 |
+
// comrse info
|
80 |
+
$orgData = Mage::getModel('comrsesync/comrseconnect')->load(Comrse_ComrseSync_Model_Config::COMRSE_RECORD_ROW_ID);
|
81 |
+
|
82 |
+
|
83 |
+
if (@is_object($mageOrder) && is_object($orgData))
|
84 |
+
{
|
85 |
+
$orderPaymentMethod = $mageOrder->getPayment()->getMethodInstance()->getTitle();
|
86 |
+
|
87 |
+
// if this order came from Comr.se
|
88 |
+
if ($orderPaymentMethod == "Comrse" || $orderPaymentMethod == "comrsepay" || $orderPaymentMethod == "comrsesync")
|
89 |
+
{
|
90 |
+
$mageOrderItems = $mageOrder->getAllItems();
|
91 |
+
|
92 |
+
$mageCollectionItems = Mage::getResourceModel('sales/order_item_collection')->addFieldToFilter('order_id', array('eq' => $mageOrder->getId()));
|
93 |
+
|
94 |
+
if (is_array($mageOrderItems))
|
95 |
+
{
|
96 |
+
$shippingAmount = $taxAmount = $subTotalAmount = $grandTotalAmount = 0;
|
97 |
+
|
98 |
+
foreach ($mageOrderItems as $mageOrderItem) {
|
99 |
+
$itemData = @$mageOrderItem->getData(); // one product limitation begins here
|
100 |
+
$itemId = $itemData['product_id'];
|
101 |
+
|
102 |
+
// loop collection
|
103 |
+
foreach ($mageCollectionItems as $mageCollectionItem)
|
104 |
+
{
|
105 |
+
if ($mageCollectionItem->getProductType() == 'simple')
|
106 |
+
{
|
107 |
+
$invoiceItems[$mageCollectionItem->getId()] = $mageCollectionItem->getQtyOrdered();
|
108 |
+
|
109 |
+
$qty = Mage::getModel('cataloginventory/stock_item')->loadByProduct($mageCollectionItem->getProduct())->getQty();
|
110 |
+
|
111 |
+
$mageProductOptions = $mageCollectionItem->getProductOptions();
|
112 |
+
|
113 |
+
if (is_array($mageProductOptions) && is_array($mageProductOptions['info_buyRequest']) && is_array($mageProductOptions['info_buyRequest']['super_attribute']))
|
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=$itemId&org_id={$orgData->getOrg()}&stock=$payload", $orgData);
|
118 |
+
}
|
119 |
+
}
|
120 |
+
}
|
121 |
+
}
|
122 |
+
|
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=$customerEmailAddress&org_id=phpunit-test-framework", $orgData);
|
127 |
+
|
128 |
+
if ($comrseAmounts != '' && !is_null($comrseAmounts))
|
129 |
+
{
|
130 |
+
$comrseAmounts = json_decode($comrseAmounts);
|
131 |
+
|
132 |
+
$shippingAmount += $comrseAmounts->shipping;
|
133 |
+
$taxAmount += $comrseAmounts->tax;
|
134 |
+
$subTotalAmount += $comrseAmounts->subtotal;
|
135 |
+
$grandTotalAmount += $comrseAmounts->total;
|
136 |
+
}
|
137 |
+
|
138 |
+
// alter order amounts for Comr.se Order
|
139 |
+
if ($subTotalAmount > 0 && $grandTotalAmount > 0)
|
140 |
+
{
|
141 |
+
|
142 |
+
// shipping totals
|
143 |
+
$mageOrder->setShippingAmount($shippingAmount);
|
144 |
+
$mageOrder->setBaseShippingAmount($shippingAmount);
|
145 |
+
// tax totals
|
146 |
+
$mageOrder->setTaxAmount($taxAmount);
|
147 |
+
$mageOrder->setBaseTaxAmount($taxAmount);
|
148 |
+
// subtotals
|
149 |
+
$mageOrder->setSubtotal($subTotalAmount);
|
150 |
+
$mageOrder->setBaseSubtotal($subTotalAmount);
|
151 |
+
// grand totals
|
152 |
+
$mageOrder->setGrandTotal($grandTotalAmount);
|
153 |
+
$mageOrder->setBaseGrandTotal($grandTotalAmount);
|
154 |
+
$mageOrder->setBaseTotalPaid($grandTotalAmount);
|
155 |
+
$mageOrder->setTotalPaid($grandTotalAmount);
|
156 |
+
$mageOrder->save();
|
157 |
+
|
158 |
+
// create order invoice
|
159 |
+
if (isset($invoiceItems) && is_array($invoiceItems))
|
160 |
+
$createInvoice = Mage::getModel('sales/order_invoice_api')->create($mageOrder->getIncrementId(), $invoiceItems, null, false, true);
|
161 |
+
|
162 |
+
}
|
163 |
+
}
|
164 |
+
}
|
165 |
+
// else the order is from the dotcom
|
166 |
+
else
|
167 |
+
{
|
168 |
+
//------------------------------------------------------------
|
169 |
+
// Normalize Order Data
|
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 |
+
}
|
177 |
+
}
|
178 |
+
catch(Exception $e)
|
179 |
+
{
|
180 |
+
Mage::log("Comrse New Order: {$e->getMessage()}");
|
181 |
+
}
|
182 |
+
}
|
183 |
+
|
184 |
+
|
185 |
+
/**
|
186 |
+
* Update Order
|
187 |
+
* Set order in processing state
|
188 |
+
* @access public
|
189 |
+
*/
|
190 |
+
public function orderUpdate(Varien_Event_Observer $observer)
|
191 |
+
{
|
192 |
+
try{
|
193 |
+
error_reporting(0);
|
194 |
+
ini_set('display_errors',0);
|
195 |
+
|
196 |
+
$storeDisabled = Mage::getStoreConfig('advanced/modules_disable_output/Comrse_ComrseSync', $observer->getOrder()->getStoreId());
|
197 |
+
if (!$storeDisabled)
|
198 |
+
{
|
199 |
+
if ($mageOrder = $observer->getOrder())
|
200 |
+
{
|
201 |
+
$orderPaymentMethod = $mageOrder->getPayment()->getMethodInstance()->getTitle();
|
202 |
+
// if this order came from Comr.se
|
203 |
+
if (($orderPaymentMethod == "Comrse" || $orderPaymentMethod == "comrsepay" || $orderPaymentMethod == "comrsesync") && $mageOrder->getState() == Mage_Sales_Model_Order::STATE_NEW)
|
204 |
+
{
|
205 |
+
$orgData = Mage::getModel('comrsesync/comrseconnect')->load(Comrse_ComrseSync_Model_Config::COMRSE_RECORD_ROW_ID);
|
206 |
+
$mageOrder->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true);
|
207 |
+
$mageOrder->save();
|
208 |
+
}
|
209 |
+
}
|
210 |
+
}
|
211 |
+
}
|
212 |
+
catch(Exception $e)
|
213 |
+
{
|
214 |
+
Mage::log("Comrse Order Update: {$e->getMessage()}");
|
215 |
+
}
|
216 |
+
}
|
217 |
+
|
218 |
+
|
219 |
+
|
220 |
+
/**
|
221 |
+
* Order Cancelation Event Listener
|
222 |
+
* @access public
|
223 |
+
* @param Varien_Event_Observer $observer
|
224 |
+
*/
|
225 |
+
public function orderCancelation(Varien_Event_Observer $observer)
|
226 |
+
{
|
227 |
+
try
|
228 |
+
{
|
229 |
+
$storeDisabled = Mage::getStoreConfig('advanced/modules_disable_output/Comrse_ComrseSync', $observer->getOrder()->getStoreId());
|
230 |
+
if (!$storeDisabled)
|
231 |
+
{
|
232 |
+
$orgData = Mage::getModel('comrsesync/comrseconnect')->load(Comrse_ComrseSync_Model_Config::COMRSE_RECORD_ROW_ID);
|
233 |
+
|
234 |
+
//------------------------------------------------------------
|
235 |
+
// Normalize Order Data & Send to Comr.se
|
236 |
+
//------------------------------------------------------------
|
237 |
+
$normalizedOrder = Mage::helper('comrsesync/order')->normalizeOrderData($observer->getOrder(), false, "CANCELLED");
|
238 |
+
if (!empty($normalizedOrder))
|
239 |
+
$postOrder = Mage::helper('comrsesync')->comrseRequest("POST", Comrse_ComrseSync_Model_Config::API_PATH . "organizations/" . $orgData->getOrg() . "/orders?metrics_only=false", $orgData, json_encode($normalizedOrder));
|
240 |
+
}
|
241 |
+
|
242 |
+
}
|
243 |
+
catch (Exception $e)
|
244 |
+
{
|
245 |
+
Mage::log("Comrse Order Cancelation: {$e->getMessage()}");
|
246 |
+
}
|
247 |
+
}
|
248 |
+
|
249 |
+
|
250 |
+
/**
|
251 |
+
* Product Update/Creation Event Listener
|
252 |
+
* @access public
|
253 |
+
* @param Varien_Event_Observer $observer
|
254 |
+
*/
|
255 |
+
public function productUpdate(Varien_Event_Observer $observer)
|
256 |
+
{
|
257 |
+
try
|
258 |
+
{
|
259 |
+
//------------------------------------------------------------//
|
260 |
+
// Retreive and Handle Org Data
|
261 |
+
//------------------------------------------------------------//
|
262 |
+
$orgData = Mage::getModel('comrsesync/comrseconnect')->load(Comrse_ComrseSync_Model_Config::COMRSE_RECORD_ROW_ID);
|
263 |
+
|
264 |
+
//------------------------------------------------------------//
|
265 |
+
// Normalize Product Data
|
266 |
+
//------------------------------------------------------------//
|
267 |
+
$normalizedProduct = Mage::helper('comrsesync/product')->normalizeProductData($observer->getProduct());
|
268 |
+
|
269 |
+
//------------------------------------------------------------//
|
270 |
+
// Sync Products to Comr.se
|
271 |
+
//------------------------------------------------------------//
|
272 |
+
$preparedData = json_encode(array("product_details_list" => array($normalizedProduct)));
|
273 |
+
$postProducts = Mage::helper('comrsesync')->comrseRequest("POST", Comrse_ComrseSync_Model_Config::API_PATH . "organizations/" . $orgData->getOrg() . "/products", $orgData, $preparedData);
|
274 |
+
}
|
275 |
+
catch (Exception $e)
|
276 |
+
{
|
277 |
+
Mage::log("Comrse Product Update Sync: {$e->getMessage()}");
|
278 |
+
}
|
279 |
+
}
|
280 |
+
}
|
281 |
+
?>
|
app/code/community/Comrse/ComrseSync/Model/Product.php
ADDED
@@ -0,0 +1,1051 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Comrse_ComrseSync_Helper_Product extends Mage_Core_Helper_Abstract {
|
3 |
+
|
4 |
+
public function syncProducts() {
|
5 |
+
|
6 |
+
try
|
7 |
+
{
|
8 |
+
error_reporting(0);
|
9 |
+
ini_set('display_errors',0);
|
10 |
+
|
11 |
+
$currency_code = Mage::app()->getStore()->getCurrentCurrencyCode();
|
12 |
+
if (empty($currency_code)) {
|
13 |
+
$currency_code = "USD";
|
14 |
+
}
|
15 |
+
|
16 |
+
// synced products array
|
17 |
+
$_synced_products = array();
|
18 |
+
|
19 |
+
$max_config_pid = 0;
|
20 |
+
$max_simple_pid = 0;
|
21 |
+
$max_grouped_pid = 0;
|
22 |
+
$max_dl_pid = 0;
|
23 |
+
|
24 |
+
// org data
|
25 |
+
$org_data = Mage::getModel('comrsesync/comrseconnect')->load(1);
|
26 |
+
$org_id = $org_data->getOrg();
|
27 |
+
$api_token = $org_data->getToken();
|
28 |
+
|
29 |
+
|
30 |
+
$last_config_product_synced = 0;
|
31 |
+
$last_simple_product_synced = 0;
|
32 |
+
$last_grouped_product_synced = 0;
|
33 |
+
$last_dl_product_synced = 0;
|
34 |
+
|
35 |
+
|
36 |
+
$product_model = Mage::getModel('catalog/product'); // product collection model
|
37 |
+
$links_model = Mage::getModel('downloadable/link');
|
38 |
+
$media_path = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'catalog/product';
|
39 |
+
$base_path = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
40 |
+
$options = array();
|
41 |
+
$attributes = "";
|
42 |
+
$child_products = array();
|
43 |
+
$attr_ignored = array("entity_id", "attribute_set_id", "type_id", "entity_type_id", "name", "description", "short_description", "sample_test", "sku", "old_id", "weight", "news_from_date", "news_to_date", "status", "url_key", "url_path", "visibility", "country_of_manufacture", "category_ids", "required_options", "has_options", "image_label", "small_image_label", "thumbnail_label", "created_at", "updated_at", "price", "group_price", "special_price", "special_from_date", "special_to_date", "tier_price", "msrp_enabled", "minimal_price", "msrp_display_actual_price_type", "msrp", "enable_googlecheckout", "tax_class_id", "meta_title", "meta_keyword", "meta_description", "image", "small_image", "thumbnail", "media_gallery", "gallery", "is_recurring", "recurring_profile", "custom_design", "custom_design_from", "custom_design_to", "custom_layout_update", "page_layout", "options_container", "gift_message_available");
|
44 |
+
|
45 |
+
$_stores = Mage::app()->getStores(); // get all stores
|
46 |
+
|
47 |
+
// handle single store installation
|
48 |
+
if (!is_array($_stores))
|
49 |
+
{
|
50 |
+
$stores = array("stores" => false);
|
51 |
+
$_stores = array($_stores);
|
52 |
+
}
|
53 |
+
|
54 |
+
// loop stores
|
55 |
+
$disabled = $multi_store = false;
|
56 |
+
$_store_id = 0;
|
57 |
+
if (is_array($_stores))
|
58 |
+
{
|
59 |
+
foreach ($_stores as $_store)
|
60 |
+
{
|
61 |
+
$_store_id = $_store->getId();
|
62 |
+
|
63 |
+
$_disabled = Mage::getStoreConfig('advanced/modules_disable_output/Comrse_ComrseSync', $_store_id); // check if plugin is disabled on store
|
64 |
+
$multi_store = true;
|
65 |
+
|
66 |
+
// if store is enabled
|
67 |
+
if (!$_disabled)
|
68 |
+
{
|
69 |
+
// HANDLE CONFIGURABLE PRODUCTS //
|
70 |
+
try
|
71 |
+
{
|
72 |
+
if ($multi_store)
|
73 |
+
$product_count = $product_model->getCollection()->addStoreFilter($_store_id)->addAttributeToFilter('type_id','configurable')->count(); // configurable products collection count
|
74 |
+
else
|
75 |
+
$product_count = $product_model->getCollection()->addAttributeToFilter('type_id','configurable')->count(); // configurable products collection count
|
76 |
+
|
77 |
+
$math = ceil($product_count / 100);
|
78 |
+
|
79 |
+
// iterate product batch
|
80 |
+
for ($i = 1; $i <= $math; $i++)
|
81 |
+
{
|
82 |
+
$_products = array();
|
83 |
+
|
84 |
+
if ($multi_store)
|
85 |
+
$products = $product_model->getCollection()->addStoreFilter($_store_id)->addAttributeToFilter('type_id','configurable')->setPageSize(100)->setCurPage($i); // configurable products collection
|
86 |
+
else
|
87 |
+
$products = $product_model->getCollection()->addAttributeToFilter('type_id','configurable')->setPageSize(100)->setCurPage($i); // configurable products collection
|
88 |
+
|
89 |
+
$product_data = Mage::getModel('comrsesync/comrseconnect')->load(1); // retreive last product synced data for configurable type products
|
90 |
+
|
91 |
+
$last_products_synced = json_decode($product_data->getLastProductsSynced(), true);
|
92 |
+
|
93 |
+
if (isset($last_products_synced[$_store_id]['config_pid']))
|
94 |
+
$last_config_product_synced = $last_products_synced[$_store_id]['config_pid'];
|
95 |
+
|
96 |
+
// loop product collection
|
97 |
+
foreach ($products as $product)
|
98 |
+
{
|
99 |
+
#$product = Mage::getModel('catalog/product')->load(220);
|
100 |
+
$pid = $product->getId();
|
101 |
+
#$pid = 220;
|
102 |
+
|
103 |
+
if ($pid)
|
104 |
+
{
|
105 |
+
if (!in_array($_synced_products, $pid))
|
106 |
+
{
|
107 |
+
$_item = $product_model->load($pid);
|
108 |
+
|
109 |
+
$product_status = $_item->getStatus();
|
110 |
+
$product_visibility = $_item->getVisibility();
|
111 |
+
$attributes = $_item->getAttributes();
|
112 |
+
$_attributes = array();
|
113 |
+
$product_options = array();
|
114 |
+
$attr_codes = array();
|
115 |
+
$product_name = $_item->getName();
|
116 |
+
|
117 |
+
// sync option positions w/ defined ordering
|
118 |
+
$productAttributeOptions = $product->getTypeInstance(true)->getConfigurableAttributesAsArray($product);
|
119 |
+
|
120 |
+
foreach ($productAttributeOptions as $productAttribute)
|
121 |
+
{
|
122 |
+
$attr_codes[$productAttribute['attribute_id']] = $productAttribute['attribute_code'];
|
123 |
+
|
124 |
+
$attribute = Mage::getModel('eav/entity_attribute')->load( $productAttribute['attribute_code'], 'attribute_code');
|
125 |
+
|
126 |
+
$option_col = Mage::getResourceModel( 'eav/entity_attribute_option_collection')
|
127 |
+
->setAttributeFilter($attribute->getId())
|
128 |
+
->setStoreFilter()
|
129 |
+
->setPositionOrder('ASC');
|
130 |
+
}
|
131 |
+
|
132 |
+
// loop through product attributes
|
133 |
+
$optionIterator = 1;
|
134 |
+
foreach ($productAttributeOptions as $option)
|
135 |
+
{
|
136 |
+
#print_r($option);
|
137 |
+
if (is_null($option) || empty($option) || !isset($option['label']) || is_null($option['label']))
|
138 |
+
continue;
|
139 |
+
|
140 |
+
$attribute = Mage::getModel('eav/entity_attribute')->load($option['attribute_code'], 'attribute_code');
|
141 |
+
|
142 |
+
$attr_type = $attribute->getFrontendInput();
|
143 |
+
$allowedValues = array();
|
144 |
+
$optionValueIterator = 1;
|
145 |
+
foreach ($option['values'] as $value)
|
146 |
+
{
|
147 |
+
$adjustmentAmount = (is_numeric($value['pricing_value'])) ? $value['pricing_value'] : 0.00;
|
148 |
+
$allowedValues[] = Mage::getModel('comrsesync/Comrse_AllowedValue')
|
149 |
+
->setExternalId($value['value_index'])
|
150 |
+
->setAttributeValue($value['label'])
|
151 |
+
->setPriceAdjustment(Mage::getModel('comrsesync/Comrse_Price')->setAmount($adjustmentAmount)->toArray())
|
152 |
+
->setProductOptionId("1")
|
153 |
+
->setDisplayOrder($optionValueIterator)
|
154 |
+
->toArray();
|
155 |
+
|
156 |
+
$optionValueIterator++;
|
157 |
+
}
|
158 |
+
|
159 |
+
|
160 |
+
$product_options[] = Mage::getModel('comrsesync/Comrse_ProductOption')
|
161 |
+
->setAttributeName($option['label'])
|
162 |
+
->setLabel($option['store_label'])
|
163 |
+
->setExternalId($option['attribute_id'])
|
164 |
+
->setRequired("true")
|
165 |
+
->setProductOptionType(strtoupper($attr_type))
|
166 |
+
->setAllowedValues(array("allowedValue" => $allowedValues))
|
167 |
+
->setDisplayOrder($optionIterator)
|
168 |
+
->toArray();
|
169 |
+
|
170 |
+
$optionIterator++;
|
171 |
+
$allowedValues = null;
|
172 |
+
}
|
173 |
+
|
174 |
+
|
175 |
+
// get product media
|
176 |
+
$media = $_item->getData('media_gallery');
|
177 |
+
$images = $media['images'];
|
178 |
+
$_images = array();
|
179 |
+
$used_images = array();
|
180 |
+
$has_thumb = false;
|
181 |
+
|
182 |
+
// check for primary image
|
183 |
+
if ($_item->hasThumbnail())
|
184 |
+
{
|
185 |
+
$thumb_file = $_item->getThumbnail();
|
186 |
+
$has_thumb = true;
|
187 |
+
}
|
188 |
+
|
189 |
+
$primary_set = false;
|
190 |
+
if (is_array($images))
|
191 |
+
{
|
192 |
+
foreach ($images as $image)
|
193 |
+
{
|
194 |
+
if ($image['file']) {
|
195 |
+
$altText = "";
|
196 |
+
if ($has_thumb && $image['file'] == $thumb_file)
|
197 |
+
{
|
198 |
+
$altText = "primary";
|
199 |
+
$primary_set = true;
|
200 |
+
}
|
201 |
+
elseif ($image['position_default'] == 1)
|
202 |
+
{
|
203 |
+
$altText = "primary";
|
204 |
+
$primary_set = true;
|
205 |
+
}
|
206 |
+
$used_images[] = $image['file'];
|
207 |
+
|
208 |
+
$_images[] = Mage::getModel('comrsesync/Comrse_Image')
|
209 |
+
->setId("")
|
210 |
+
->setTitle($image['value_id'])
|
211 |
+
->setUrl($media_path . $image['file'])
|
212 |
+
->setAltText($altText)
|
213 |
+
->setOrgId($org_id)
|
214 |
+
->toArray();
|
215 |
+
}
|
216 |
+
}
|
217 |
+
}
|
218 |
+
|
219 |
+
$children = array();
|
220 |
+
// children of configurable products
|
221 |
+
$product_weight = 0.5;
|
222 |
+
$conf = Mage::getModel('catalog/product_type_configurable')->setProduct($product);
|
223 |
+
$simple_collection = $conf->getUsedProductCollection()->addAttributeToSelect('*')->addFilterByRequiredOptions();
|
224 |
+
$a_i = 0;
|
225 |
+
// loop children
|
226 |
+
$simple_product_attributes = array();
|
227 |
+
foreach ($simple_collection as $simple_product)
|
228 |
+
{
|
229 |
+
$simple_product_data = $simple_product->getData();
|
230 |
+
|
231 |
+
foreach ($attr_codes as $key => $val)
|
232 |
+
{
|
233 |
+
if (isset($simple_product_data[$val]))
|
234 |
+
$simple_product_attributes[$simple_product->getId()][$key] = $simple_product_data[$val]; // map child ID's to attribute ID's for writeback inventory lookup
|
235 |
+
}
|
236 |
+
|
237 |
+
$child_products[] = $simple_product->getId();
|
238 |
+
if ($simple_product->getWeight() > $product_weight)
|
239 |
+
$product_weight = $simple_product->getWeight();
|
240 |
+
|
241 |
+
$qty = Mage::getModel('cataloginventory/stock_item')->loadByProduct($simple_product)->getQty();
|
242 |
+
$s_product_data = $simple_product->getData();
|
243 |
+
$s_product = $product_model->load($simple_product->getId());
|
244 |
+
$s_media = $s_product->getData('media_gallery');
|
245 |
+
|
246 |
+
if (empty($used_images) && $s_product->hasThumbnail())
|
247 |
+
{
|
248 |
+
$thumb_file = $s_product->getThumbnail();
|
249 |
+
$has_thumb = true;
|
250 |
+
}
|
251 |
+
|
252 |
+
$s_images = $s_media['images'];
|
253 |
+
|
254 |
+
if (is_array($s_images))
|
255 |
+
{
|
256 |
+
foreach ($s_images as $s_image)
|
257 |
+
{
|
258 |
+
if ($s_image['file'] && !in_array($s_image['file'], $used_images))
|
259 |
+
{
|
260 |
+
$altText = "";
|
261 |
+
if ($has_thumb && !$primary_set)
|
262 |
+
{
|
263 |
+
if ($s_image['file'] == $thumb_file)
|
264 |
+
{
|
265 |
+
$altText = "primary";
|
266 |
+
$primary_set = true;
|
267 |
+
}
|
268 |
+
}
|
269 |
+
elseif ($s_image['position_default'] == 1 && !$primary_set)
|
270 |
+
{
|
271 |
+
$altText = "primary";
|
272 |
+
$primary_set = true;
|
273 |
+
}
|
274 |
+
|
275 |
+
$_images[] = Mage::getModel('comrsesync/Comrse_Image')
|
276 |
+
->setId("")
|
277 |
+
->setTitle($s_image['value_id'])
|
278 |
+
->setUrl($media_path . $s_image['file'])
|
279 |
+
->setAltText($altText)
|
280 |
+
->setOrgId($org_id)
|
281 |
+
->toArray();
|
282 |
+
|
283 |
+
}
|
284 |
+
}
|
285 |
+
}
|
286 |
+
foreach ($attr_codes as $key => $val)
|
287 |
+
{
|
288 |
+
$qty_array[$a_i]["qty"] = $qty;
|
289 |
+
$qty_array[$a_i][$key] = $s_product_data[$val];
|
290 |
+
}
|
291 |
+
|
292 |
+
$a_i++;
|
293 |
+
|
294 |
+
// clear memory
|
295 |
+
$simple_product = $s_product_data = $s_product = $s_media = $s_images = null;
|
296 |
+
}
|
297 |
+
|
298 |
+
$_item_type = $_item->getTypeID();
|
299 |
+
|
300 |
+
$product_attributes = array(
|
301 |
+
"productAttribute" => array(
|
302 |
+
array("id" => "", "attributeName" => "inventory", "attributeValue" => json_encode($qty_array)),
|
303 |
+
array("id" => "", "attributeName" => "url", "attributeValue" => $product->getProductUrl()),
|
304 |
+
array("id" => "", "attributeName" => "mapping", "attributeValue" => json_encode($simple_product_attributes))
|
305 |
+
)
|
306 |
+
);
|
307 |
+
|
308 |
+
// if sale price does not exist use base price
|
309 |
+
$sale_price = ($_item->getSpecialPrice() > 0 ? $_item->getSpecialPrice() : $_item->getPrice());
|
310 |
+
|
311 |
+
// extra check to make sure sale price is NOT 0
|
312 |
+
if ($sale_price == 0 || is_null($sale_price))
|
313 |
+
$sale_price = $_item->getPrice();
|
314 |
+
|
315 |
+
// if no images use placeholder
|
316 |
+
if (empty($_images))
|
317 |
+
$_images[0] = array("id" => "", "title" => "No Image", "url" => "https://comr.se/assets/img/404_img.png", "altText" => "No Image");
|
318 |
+
|
319 |
+
// setup description
|
320 |
+
$description = $_item->getDescription();
|
321 |
+
$short_description = $_item->getShortDescription();
|
322 |
+
|
323 |
+
if (strlen($short_description) > strlen($description))
|
324 |
+
$description = $short_description;
|
325 |
+
|
326 |
+
// is product active
|
327 |
+
$active = ($product_status == 1 ? "true" : "false");
|
328 |
+
$activeStartDate = ($active == "true" ? date("Y-m-d\TH:i:s.000O", strtotime("- 1 day", time())) : date("Y-m-d\TH:i:s.000O", strtotime("+ 10 years", time())));
|
329 |
+
$activeEndDate = ($active == "true" ? date("Y-m-d\TH:i:s.000O",strtotime("+ 10 years", time())) : date("Y-m-d\TH:i:s.000O",strtotime("- 1 day", time())));
|
330 |
+
|
331 |
+
// if product options exist (configurables must have product options!)
|
332 |
+
if (is_array($product_options) && !empty($product_options) && !is_null($pid) && $product_visibility != 1)
|
333 |
+
{
|
334 |
+
|
335 |
+
$_products[] = Mage::getModel('comrsesync/Comrse_Product')
|
336 |
+
->setId("")
|
337 |
+
->setExternalId((string)$pid)
|
338 |
+
->setName($product_name)
|
339 |
+
->setLongDescription(trim(str_replace(array("\r\n", "\r", "<br />", "<br>"), "", $description)))
|
340 |
+
->setDimension(Mage::getModel('comrsesync/Comrse_Dimension')->toArray())
|
341 |
+
->setWeight(
|
342 |
+
Mage::getModel('comrsesync/Comrse_Weight')
|
343 |
+
->setWeight($product_weight)
|
344 |
+
->toArray()
|
345 |
+
)
|
346 |
+
->setRetailPrice(
|
347 |
+
Mage::getModel('comrsesync/Comrse_Price')
|
348 |
+
->setAmount($_item->getPrice())
|
349 |
+
->toArray()
|
350 |
+
)
|
351 |
+
->setSalePrice(
|
352 |
+
Mage::getModel('comrsesync/Comrse_Price')
|
353 |
+
->setAmount($sale_price)
|
354 |
+
->toArray()
|
355 |
+
)
|
356 |
+
->setPrimaryMedia($_images[0])
|
357 |
+
->setActive($active)
|
358 |
+
->setActiveStartDate($activeStartDate)
|
359 |
+
->setActiveEndDate($activeEndDate)
|
360 |
+
->setManufacturer("")
|
361 |
+
->setDefaultCategoryId("")
|
362 |
+
->setProductAttributes($product_attributes)
|
363 |
+
->setProductOptions(array("productOption" => $product_options))
|
364 |
+
->setMediaItems(array("media" => $_images))
|
365 |
+
->toArray();
|
366 |
+
|
367 |
+
}
|
368 |
+
$_synced_products[] = $pid;
|
369 |
+
}
|
370 |
+
}
|
371 |
+
else {
|
372 |
+
$conf = Mage::getModel('catalog/product_type_configurable')->setProduct($product);
|
373 |
+
$simple_collection = $conf->getUsedProductCollection()->addAttributeToSelect('*')->addFilterByRequiredOptions();
|
374 |
+
if (is_array($simple_collection)) {
|
375 |
+
foreach ($simple_collection as $simple_product) {
|
376 |
+
$child_products[] = $simple_product->getId();
|
377 |
+
}
|
378 |
+
}
|
379 |
+
}
|
380 |
+
} // END LOOP
|
381 |
+
if (!empty($_products))
|
382 |
+
{
|
383 |
+
|
384 |
+
// push configurable products
|
385 |
+
$data = json_encode(array("products" => $_products));
|
386 |
+
$postProducts = Mage::helper('comrsesync')->comrseRequest("POST", Comrse_ComrseSync_Model_Config::API_PATH . "organizations/" . $org_id . "/products", $org_data, $data);
|
387 |
+
|
388 |
+
// record max product id
|
389 |
+
$last_products_synced[$_store_id]['config_pid'] = $pid;
|
390 |
+
$new_save = $product_data->setLastProductsSynced(json_encode($last_products_synced))->save();
|
391 |
+
|
392 |
+
}
|
393 |
+
|
394 |
+
// clear memory
|
395 |
+
$products = $_products = $data = $media = $images = $_images = $attributes = $result = $product_options = $allowedValues = $qty_array = $_child = $_children = $_product_options = $links = null;
|
396 |
+
|
397 |
+
}
|
398 |
+
}
|
399 |
+
catch (Exception $e)
|
400 |
+
{
|
401 |
+
Mage::log("Comrse configurable product sync failure: " . $e->getMessage());
|
402 |
+
}
|
403 |
+
|
404 |
+
|
405 |
+
// HANDLE GROUPED PRODUCTS //
|
406 |
+
try
|
407 |
+
{
|
408 |
+
$_all_links = array();
|
409 |
+
|
410 |
+
if ($multi_store)
|
411 |
+
$product_count = $product_model->getCollection()->addStoreFilter($_store_id)->addAttributeToFilter('status',1)->addAttributeToFilter('type_id', 'grouped')->count(); // grouped products collection count
|
412 |
+
else
|
413 |
+
$product_count = $product_model->getCollection()->addAttributeToFilter('status',1)->addAttributeToFilter('type_id', 'grouped')->count(); // grouped products collection count
|
414 |
+
|
415 |
+
if ($product_count > 0)
|
416 |
+
{
|
417 |
+
$core_resource = Mage::getSingleton('core/resource');
|
418 |
+
$conn = $core_resource->getConnection('core_read');
|
419 |
+
}
|
420 |
+
$math = ceil($product_count / 100);
|
421 |
+
|
422 |
+
// loop product loads
|
423 |
+
for ($i = 1; $i <= $math; $i++)
|
424 |
+
{
|
425 |
+
$_products = array();
|
426 |
+
|
427 |
+
if ($multi_store)
|
428 |
+
$products = $product_model->getCollection()->addStoreFilter($_store_id)->addAttributeToFilter('status',1)->addAttributeToFilter('type_id', 'grouped')->setPageSize(100)->setCurPage($i); // grouped products collection
|
429 |
+
else
|
430 |
+
$products = $product_model->getCollection()->addAttributeToFilter('status',1)->addAttributeToFilter('type_id', 'grouped')->setPageSize(100)->setCurPage($i); // grouped products collection
|
431 |
+
|
432 |
+
// retreive last product synced data for grouped type products
|
433 |
+
$product_data = Mage::getModel('comrsesync/comrseconnect')->load(1);
|
434 |
+
$last_products_synced = json_decode($product_data->getLastProductsSynced(), true);
|
435 |
+
if (isset($last_products_synced[$_store_id]['grouped_pid']))
|
436 |
+
{
|
437 |
+
$last_grouped_product_synced = $last_products_synced[$_store_id]['grouped_pid'];
|
438 |
+
}
|
439 |
+
|
440 |
+
// loop grouped products
|
441 |
+
foreach ($products as $product)
|
442 |
+
{
|
443 |
+
$pid = $product->getId();
|
444 |
+
|
445 |
+
if ($pid)
|
446 |
+
{
|
447 |
+
if (!in_array($_synced_products, $pid))
|
448 |
+
{
|
449 |
+
$_images = array();
|
450 |
+
$select = $conn->select()->from($core_resource->getTableName('catalog/product_relation'), array('child_id'))->where('parent_id = ?', $pid);
|
451 |
+
$_children = $conn->fetchCol($select);
|
452 |
+
if (is_array($_children))
|
453 |
+
{
|
454 |
+
$_product = $product->load($product->getId());
|
455 |
+
$media = $_product->getData('media_gallery');
|
456 |
+
$images = $media['images'];
|
457 |
+
$has_thumb = false;
|
458 |
+
$primary_set = false;
|
459 |
+
if ($_product->hasThumbnail())
|
460 |
+
{
|
461 |
+
$thumb_file = $_product->getThumbnail();
|
462 |
+
$has_thumb = true;
|
463 |
+
}
|
464 |
+
if (is_array($images))
|
465 |
+
{
|
466 |
+
foreach ($images as $image)
|
467 |
+
{
|
468 |
+
if ($image['file'] && !in_array($image['file'], $used_images))
|
469 |
+
{
|
470 |
+
$altText = "";
|
471 |
+
if ($has_thumb && !$primary_set)
|
472 |
+
{
|
473 |
+
if ($image['file'] == $thumb_file)
|
474 |
+
{
|
475 |
+
$altText = "primary";
|
476 |
+
$primary_set = true;
|
477 |
+
}
|
478 |
+
}
|
479 |
+
elseif ($image['position_default'] == 1 && !$primary_set)
|
480 |
+
{
|
481 |
+
$altText = "primary";
|
482 |
+
$primary_set = true;
|
483 |
+
}
|
484 |
+
|
485 |
+
$_images[] = Mage::getModel('comrsesync/Comrse_Image')
|
486 |
+
->setId("")
|
487 |
+
->setTitle($s_image['value_id'])
|
488 |
+
->setUrl($media_path . $image['file'])
|
489 |
+
->setAltText($altText)
|
490 |
+
->setOrgId($org_id)
|
491 |
+
->toArray();
|
492 |
+
|
493 |
+
}
|
494 |
+
}
|
495 |
+
}
|
496 |
+
// loop children
|
497 |
+
foreach ($_children as $_child)
|
498 |
+
{
|
499 |
+
// add child ID to used children array
|
500 |
+
$child_products[] = $_child;
|
501 |
+
// load the simple product
|
502 |
+
$_item = $product_model->load($_child);
|
503 |
+
$product_status = $_item->getStatus();
|
504 |
+
$product_visibility = $_item->getVisibility();
|
505 |
+
$_attributes = array();
|
506 |
+
$media = $_item->getData('media_gallery');
|
507 |
+
$images = $media['images'];
|
508 |
+
$c_images = array();
|
509 |
+
$altText = "";
|
510 |
+
if (is_array($images))
|
511 |
+
{
|
512 |
+
$c_i = 0;
|
513 |
+
foreach ($images as $image)
|
514 |
+
{
|
515 |
+
if ($c_i == 0 && empty($_images))
|
516 |
+
{
|
517 |
+
$altText = "primary";
|
518 |
+
}
|
519 |
+
if ($image['file'])
|
520 |
+
{
|
521 |
+
$c_images[] = array("id" => "", "title" => $image['value_id'], "url" => $media_path.$image['file'], "altText" => $altText, "orgId" => $org_id);
|
522 |
+
}
|
523 |
+
$c_i++;
|
524 |
+
}
|
525 |
+
}
|
526 |
+
|
527 |
+
if (is_array($c_images))
|
528 |
+
{
|
529 |
+
$_c_images = array_merge($c_images, $_images);
|
530 |
+
}
|
531 |
+
|
532 |
+
$qtyStock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_item)->getQty();
|
533 |
+
$base_path = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
534 |
+
|
535 |
+
$qty_array[0]["qty"] = $qtyStock;
|
536 |
+
$_item_type = $_item->getTypeID();
|
537 |
+
$product_attributes = array(
|
538 |
+
"productAttribute" => array(
|
539 |
+
array("id" => "", "attributeName" => "inventory", "attributeValue" => json_encode($qty_array)),
|
540 |
+
array("id" => "", "attributeName" => "url", "attributeValue" => $product->getProductUrl())
|
541 |
+
)
|
542 |
+
);
|
543 |
+
|
544 |
+
// if sale price not exists use base price
|
545 |
+
$sale_price = ($_item->getSpecialPrice() > 0 ? $_item->getSpecialPrice() : $_item->getPrice());
|
546 |
+
|
547 |
+
// extra check to make sure sale price is NOT 0
|
548 |
+
if ($sale_price == 0 || is_null($sale_price))
|
549 |
+
{
|
550 |
+
$sale_price = $_item->getPrice();
|
551 |
+
}
|
552 |
+
|
553 |
+
// setup description
|
554 |
+
$description = $_item->getDescription();
|
555 |
+
$short_description = $_item->getShortDescription();
|
556 |
+
if (strlen($short_description) > strlen($description))
|
557 |
+
{
|
558 |
+
$description = $short_description;
|
559 |
+
}
|
560 |
+
|
561 |
+
if (empty($_images))
|
562 |
+
{
|
563 |
+
$_images[0] = array("id" => "", "title" => "No Image", "url" => "https://comr.se/assets/img/404_img.png", "altText" => "No Image");
|
564 |
+
}
|
565 |
+
|
566 |
+
$allowedValues = array();
|
567 |
+
$product_options = array();
|
568 |
+
if ($_item_type == "downloadable")
|
569 |
+
{
|
570 |
+
@$_links = $links_model->getCollection()->addProductToFilter($_child)->addTitleToResult()->addPriceToResult();
|
571 |
+
$optionValueIterator = 1;
|
572 |
+
foreach ($_links as $_link)
|
573 |
+
{
|
574 |
+
|
575 |
+
$allowedValues[] = Mage::getModel('comrsesync/Comrse_AllowedValue')
|
576 |
+
->setExternalId($_link->getLinkId())
|
577 |
+
->setAttributeValue($_link->getTitle())
|
578 |
+
->setPriceAdjustment(Mage::getModel('comrsesync/Comrse_Price')->setAmount($_link->getPrice())->toArray())
|
579 |
+
->setProductOptionId("1")
|
580 |
+
->setDisplayOrder($optionValueIterator)
|
581 |
+
->toArray();
|
582 |
+
|
583 |
+
$optionValueIterator++;
|
584 |
+
}
|
585 |
+
|
586 |
+
$product_options[] = Mage::getModel('comrsesync/Comrse_ProductOption')
|
587 |
+
->setAttributeName("Link")
|
588 |
+
->setLabel("Link")
|
589 |
+
->setExternalId("99999")
|
590 |
+
->setRequired("true")
|
591 |
+
->setProductOptionType("Select")
|
592 |
+
->setAllowedValues(array("allowedValue" => $allowedValues))
|
593 |
+
->setDisplayOrder(1)
|
594 |
+
->toArray();
|
595 |
+
|
596 |
+
}
|
597 |
+
|
598 |
+
$_product_options = (!empty($product_options)) ? array("productOption" => $product_options) : "";
|
599 |
+
|
600 |
+
// is product active
|
601 |
+
$active = ($product_status == 1 ? "true" : "false");
|
602 |
+
$activeStartDate = ($active == "true" ? date("Y-m-d\TH:i:s.000O", strtotime("- 1 day", time())) : date("Y-m-d\TH:i:s.000O", strtotime("+ 10 years", time())));
|
603 |
+
$activeEndDate = ($active == "true" ? date("Y-m-d\TH:i:s.000O",strtotime("+ 10 years", time())) : date("Y-m-d\TH:i:s.000O",strtotime("- 1 day", time())));
|
604 |
+
|
605 |
+
if (!is_null($_child) && $product_visibility != 1)
|
606 |
+
{
|
607 |
+
|
608 |
+
$_products[] = Mage::getModel('comrsesync/Comrse_Product')
|
609 |
+
->setId("")
|
610 |
+
->setExternalId((string)$_child)
|
611 |
+
->setName($_item->getName())
|
612 |
+
->setLongDescription(trim(str_replace(array("\r\n", "\r", "<br />", "<br>"), "", $description)))
|
613 |
+
->setDimension(Mage::getModel('comrsesync/Comrse_Dimension')->toArray())
|
614 |
+
->setWeight(
|
615 |
+
Mage::getModel('comrsesync/Comrse_Weight')
|
616 |
+
->setWeight(($_item->getWeight() > 0) ? $_item->getWeight() : 0.5)
|
617 |
+
->toArray()
|
618 |
+
)
|
619 |
+
->setRetailPrice(
|
620 |
+
Mage::getModel('comrsesync/Comrse_Price')
|
621 |
+
->setAmount($_item->getPrice())
|
622 |
+
->toArray()
|
623 |
+
)
|
624 |
+
->setSalePrice(
|
625 |
+
Mage::getModel('comrsesync/Comrse_Price')
|
626 |
+
->setAmount($sale_price)
|
627 |
+
->toArray()
|
628 |
+
)
|
629 |
+
->setPrimaryMedia(@$_c_images[0])
|
630 |
+
->setActive($active)
|
631 |
+
->setActiveStartDate($activeStartDate)
|
632 |
+
->setActiveEndDate($activeEndDate)
|
633 |
+
->setManufacturer("")
|
634 |
+
->setDefaultCategoryId("")
|
635 |
+
->setProductAttributes($product_attributes)
|
636 |
+
->setProductOptions(array("productOption" => $product_options))
|
637 |
+
->setMediaItems(array("media" => $_c_images))
|
638 |
+
->toArray();
|
639 |
+
}
|
640 |
+
$_product_options = null;
|
641 |
+
}
|
642 |
+
}
|
643 |
+
$_synced_products[] = $pid;
|
644 |
+
}
|
645 |
+
}
|
646 |
+
else {
|
647 |
+
// add child ids to used children array
|
648 |
+
$select = $conn->select()->from($core_resource->getTableName('catalog/product_relation'), array('child_id'))->where('parent_id = ?', $pid);
|
649 |
+
$_children = $conn->fetchCol($select);
|
650 |
+
if (is_array($_children))
|
651 |
+
{
|
652 |
+
foreach ($_children as $_child)
|
653 |
+
{
|
654 |
+
$child_products[] = $_child;
|
655 |
+
}
|
656 |
+
}
|
657 |
+
}
|
658 |
+
}
|
659 |
+
|
660 |
+
if (!empty($_products))
|
661 |
+
{
|
662 |
+
// push the configurable products to CPS
|
663 |
+
$data = json_encode(array("products" => $_products));
|
664 |
+
$postProducts = Mage::helper('comrsesync')->comrseRequest("POST", Comrse_ComrseSync_Model_Config::API_PATH . "organizations/" . $org_id . "/products", $org_data, $data);
|
665 |
+
|
666 |
+
// store max grouped product id
|
667 |
+
$last_products_synced[$_store_id]['grouped_pid'] = $pid;
|
668 |
+
$new_save = $product_data->setLastProductsSynced(json_encode($last_products_synced))->save();
|
669 |
+
}
|
670 |
+
// clear the memory
|
671 |
+
$products = $_products = $data = $media = $images = $_images = $attributes = $result = $product_options = $allowedValues = $qty_array = $_child = $_children = $_product_options = $links = null;
|
672 |
+
}
|
673 |
+
}
|
674 |
+
catch (Exception $e) {
|
675 |
+
Mage::log("Comrse grouped product sync failure: " . $e->getMessage());
|
676 |
+
}
|
677 |
+
|
678 |
+
|
679 |
+
// HANDLE SIMPLE PRODUCTS //
|
680 |
+
try
|
681 |
+
{
|
682 |
+
if ($multi_store)
|
683 |
+
$product_count = $product_model->getCollection()->addStoreFilter($_store_id)->addAttributeToFilter('status',1)->addAttributeToFilter('type_id', 'simple')->count(); // products collection count
|
684 |
+
|
685 |
+
else
|
686 |
+
$product_count = $product_model->getCollection()->addAttributeToFilter('status',1)->addAttributeToFilter('type_id', 'simple')->count(); // products collection count
|
687 |
+
|
688 |
+
$math = ceil($product_count / 100);
|
689 |
+
|
690 |
+
for ($i = 1; $i <= $math; $i++)
|
691 |
+
{
|
692 |
+
$_products = array();
|
693 |
+
|
694 |
+
// filter by store if multi store
|
695 |
+
if ($multi_store)
|
696 |
+
$products = $product_model->getCollection()->addStoreFilter($_store_id)->addAttributeToFilter('status',1)->addAttributeToFilter('type_id', 'simple')->setPageSize(100)->setCurPage($i); // products collection
|
697 |
+
|
698 |
+
else
|
699 |
+
$products = $product_model->getCollection()->addAttributeToFilter('status',1)->addAttributeToFilter('type_id', 'simple')->setPageSize(100)->setCurPage($i); // products collection
|
700 |
+
|
701 |
+
// retreive last product synced data for grouped type products
|
702 |
+
$product_data = Mage::getModel('comrsesync/comrseconnect')->load(1);
|
703 |
+
$last_products_synced = json_decode($product_data->getLastProductsSynced(), true);
|
704 |
+
|
705 |
+
if (isset($last_products_synced[$_store_id]['simple_pid']))
|
706 |
+
$last_simple_product_synced = $last_products_synced[$_store_id]['simple_pid'];
|
707 |
+
|
708 |
+
// loop the products
|
709 |
+
foreach ($products as $product)
|
710 |
+
{
|
711 |
+
$pid = $product->getId();
|
712 |
+
if ($pid)
|
713 |
+
{
|
714 |
+
if (!in_array($pid, $child_products) && !in_array($pid, $_synced_products))
|
715 |
+
{
|
716 |
+
|
717 |
+
$_item = $product_model->load($pid);
|
718 |
+
|
719 |
+
$product_status = $_item->getStatus();
|
720 |
+
$product_visibility = $_item->getVisibility();
|
721 |
+
$_attributes = array();
|
722 |
+
$media = $_item->getData('media_gallery');
|
723 |
+
$images = $media['images'];
|
724 |
+
$_images = array();
|
725 |
+
|
726 |
+
foreach ($images as $image)
|
727 |
+
{
|
728 |
+
if ($image['file'])
|
729 |
+
$_images[] = array("id" => "", "title" => $image['value_id'], "url" => $media_path.$image['file'], "altText" => $image['label'], "orgId" => $org_id);
|
730 |
+
}
|
731 |
+
|
732 |
+
$qtyStock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_item)->getQty();
|
733 |
+
$base_path = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
734 |
+
|
735 |
+
$qty_array[0]["qty"] = $qtyStock;
|
736 |
+
$_item_type = $_item->getTypeID();
|
737 |
+
$product_attributes = array(
|
738 |
+
"productAttribute" => array(
|
739 |
+
array("id" => "", "attributeName" => "inventory", "attributeValue" => json_encode($qty_array)),
|
740 |
+
array("id" => "", "attributeName" => "url", "attributeValue" => $product->getProductUrl())
|
741 |
+
)
|
742 |
+
);
|
743 |
+
|
744 |
+
// if sale price not exists use base price
|
745 |
+
$sale_price = ($_item->getSpecialPrice() > 0 ? $_item->getSpecialPrice() : $_item->getPrice());
|
746 |
+
|
747 |
+
// extra check to make sure sale price is NOT 0
|
748 |
+
if ($sale_price == 0 || is_null($sale_price))
|
749 |
+
$sale_price = $_item->getPrice();
|
750 |
+
|
751 |
+
// setup description
|
752 |
+
$description = $_item->getDescription();
|
753 |
+
$short_description = $_item->getShortDescription();
|
754 |
+
|
755 |
+
if (strlen($short_description) > strlen($description))
|
756 |
+
$description = $short_description;
|
757 |
+
|
758 |
+
if (empty($_images))
|
759 |
+
$_images[0] = array("id" => "", "title" => "No Image", "url" => "https://comr.se/assets/img/404_img.png", "altText" => "No Image");
|
760 |
+
|
761 |
+
// is product active
|
762 |
+
$active = ($product_status == 1 ? "true" : "false");
|
763 |
+
$activeStartDate = ($active == "true" ? date("Y-m-d\TH:i:s.000O", strtotime("- 1 day", time())) : date("Y-m-d\TH:i:s.000O", strtotime("+ 10 years", time())));
|
764 |
+
$activeEndDate = ($active == "true" ? date("Y-m-d\TH:i:s.000O",strtotime("+ 10 years", time())) : date("Y-m-d\TH:i:s.000O",strtotime("- 1 day", time())));
|
765 |
+
|
766 |
+
if (!is_null($pid) && $product_visibility != 1)
|
767 |
+
{
|
768 |
+
$_products[] = Mage::getModel('comrsesync/Comrse_Product')
|
769 |
+
->setId("")
|
770 |
+
->setExternalId((string)$pid)
|
771 |
+
->setName($_item->getName())
|
772 |
+
->setLongDescription(trim(str_replace(array("\r\n", "\r", "<br />", "<br>"), "", $description)))
|
773 |
+
->setDimension(Mage::getModel('comrsesync/Comrse_Dimension')->toArray())
|
774 |
+
->setWeight(
|
775 |
+
Mage::getModel('comrsesync/Comrse_Weight')
|
776 |
+
->setWeight(($_item->getWeight() > 0) ? $_item->getWeight() : 0.5)
|
777 |
+
->toArray()
|
778 |
+
)
|
779 |
+
->setRetailPrice(
|
780 |
+
Mage::getModel('comrsesync/Comrse_Price')
|
781 |
+
->setAmount($_item->getPrice())
|
782 |
+
->toArray()
|
783 |
+
)
|
784 |
+
->setSalePrice(
|
785 |
+
Mage::getModel('comrsesync/Comrse_Price')
|
786 |
+
->setAmount($sale_price)
|
787 |
+
->toArray()
|
788 |
+
)
|
789 |
+
->setPrimaryMedia($_images[0])
|
790 |
+
->setActive($active)
|
791 |
+
->setActiveStartDate($activeStartDate)
|
792 |
+
->setActiveEndDate($activeEndDate)
|
793 |
+
->setManufacturer("")
|
794 |
+
->setDefaultCategoryId("")
|
795 |
+
->setProductAttributes($product_attributes)
|
796 |
+
->setProductOptions("")
|
797 |
+
->setMediaItems(array("media" => $_images))
|
798 |
+
->toArray();
|
799 |
+
|
800 |
+
}
|
801 |
+
$_synced_products[] = $pid;
|
802 |
+
}
|
803 |
+
}
|
804 |
+
}
|
805 |
+
if (!empty($_products)) {
|
806 |
+
|
807 |
+
// push the configurable products to CPS
|
808 |
+
$data = json_encode(array("products" => $_products));
|
809 |
+
$postProducts = Mage::helper('comrsesync')->comrseRequest("POST", Comrse_ComrseSync_Model_Config::API_PATH . "organizations/" . $org_id . "/products", $org_data, $data);
|
810 |
+
|
811 |
+
// store max simple product id
|
812 |
+
$last_products_synced[$_store_id]['simple_pid'] = $pid;
|
813 |
+
$new_save = $product_data->setLastProductsSynced(json_encode($last_products_synced))->save();
|
814 |
+
}
|
815 |
+
|
816 |
+
// clear the memory
|
817 |
+
$products = $_products = $data = $media = $images = $_images = $attributes = $result = $product_options = $allowedValues = $qty_array = null;
|
818 |
+
}
|
819 |
+
}
|
820 |
+
catch (Exception $e) {
|
821 |
+
Mage::log("Comrse simple product sync failure: ".$e->getMessage());
|
822 |
+
}
|
823 |
+
|
824 |
+
|
825 |
+
try
|
826 |
+
{
|
827 |
+
|
828 |
+
if ($multi_store)
|
829 |
+
$products = $product_model->getCollection()->addStoreFilter($_store_id)->addAttributeToFilter('status',1)->addAttributeToFilter('type_id', 'downloadable'); // products collection
|
830 |
+
else
|
831 |
+
$products = $product_model->getCollection()->addAttributeToFilter('status',1)->addAttributeToFilter('type_id', 'downloadable'); // products collection
|
832 |
+
|
833 |
+
|
834 |
+
$_products = array();
|
835 |
+
|
836 |
+
// retreive last product synced data for grouped type products
|
837 |
+
$product_data = Mage::getModel('comrsesync/comrseconnect')->load(1);
|
838 |
+
$last_products_synced = json_decode($product_data->getLastProductsSynced(), true);
|
839 |
+
|
840 |
+
if (isset($last_products_synced[$_store_id]['dl_pid']))
|
841 |
+
$last_dl_product_synced = $last_products_synced[$_store_id]['dl_pid'];
|
842 |
+
|
843 |
+
// loop products
|
844 |
+
foreach ($products as $product)
|
845 |
+
{
|
846 |
+
$pid = $product->getId();
|
847 |
+
if ($pid)
|
848 |
+
{
|
849 |
+
if (!in_array($pid, $child_products) && !in_array($pid, $_synced_products))
|
850 |
+
{
|
851 |
+
$_item = $product_model->load($pid);
|
852 |
+
$product_status = $_item->getStatus();
|
853 |
+
$product_visibility = $_item->getVisibility();
|
854 |
+
$attributes = $_item->getAttributes();
|
855 |
+
$_attributes = array();
|
856 |
+
$media = $_item->getData('media_gallery');
|
857 |
+
$images = $media['images'];
|
858 |
+
$_images = array();
|
859 |
+
$has_thumb = false;
|
860 |
+
if ($_item->hasThumbnail())
|
861 |
+
{
|
862 |
+
$thumb_file = $_item->getThumbnail();
|
863 |
+
$has_thumb = true;
|
864 |
+
}
|
865 |
+
|
866 |
+
$primary_set = false;
|
867 |
+
|
868 |
+
// loop media
|
869 |
+
foreach ($images as $image)
|
870 |
+
{
|
871 |
+
if ($image['file'])
|
872 |
+
{
|
873 |
+
$altText = "";
|
874 |
+
if ($has_thumb)
|
875 |
+
{
|
876 |
+
if ($image['file'] == $thumb_file)
|
877 |
+
{
|
878 |
+
$altText = "primary";
|
879 |
+
$primary_set = true;
|
880 |
+
}
|
881 |
+
}
|
882 |
+
elseif ($image['position_default'] == 1)
|
883 |
+
{
|
884 |
+
$altText = "primary";
|
885 |
+
$primary_set = true;
|
886 |
+
}
|
887 |
+
|
888 |
+
$_images[] = Mage::getModel('comrsesync/Comrse_Image')
|
889 |
+
->setId("")
|
890 |
+
->setTitle($s_image['value_id'])
|
891 |
+
->setUrl($media_path . $image['file'])
|
892 |
+
->setAltText($altText)
|
893 |
+
->setOrgId($org_id)
|
894 |
+
->toArray();
|
895 |
+
|
896 |
+
}
|
897 |
+
}
|
898 |
+
|
899 |
+
$qtyStock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_item)->getQty();
|
900 |
+
$base_path = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
901 |
+
|
902 |
+
$allowedValues = array();
|
903 |
+
@$links = $links_model->getCollection()->addProductToFilter($pid)->addTitleToResult()->addPriceToResult();
|
904 |
+
|
905 |
+
$optionValueIterator = 1;
|
906 |
+
$product_options = array();
|
907 |
+
foreach ($links as $link)
|
908 |
+
{
|
909 |
+
$allowedValues[] = Mage::getModel('comrsesync/Comrse_AllowedValue')
|
910 |
+
->setExternalId($link->getLinkId())
|
911 |
+
->setAttributeValue($link->getTitle())
|
912 |
+
->setPriceAdjustment(Mage::getModel('comrsesync/Comrse_Price')->setAmount($link->getPrice())->toArray())
|
913 |
+
->setProductOptionId("1")
|
914 |
+
->setDisplayOrder($optionValueIterator)
|
915 |
+
->toArray();
|
916 |
+
|
917 |
+
$optionValueIterator++;
|
918 |
+
}
|
919 |
+
|
920 |
+
$product_options[] = Mage::getModel('comrsesync/Comrse_ProductOption')
|
921 |
+
->setAttributeName("Link")
|
922 |
+
->setLabel("Link")
|
923 |
+
->setExternalId("99999")
|
924 |
+
->setRequired("true")
|
925 |
+
->setProductOptionType("Select")
|
926 |
+
->setAllowedValues(array("allowedValue" => $allowedValues))
|
927 |
+
->setDisplayOrder(1)
|
928 |
+
->toArray();
|
929 |
+
|
930 |
+
$allowedValues = null;
|
931 |
+
|
932 |
+
$qty_array[0]["qty"] = $qtyStock;
|
933 |
+
$_item_type = $_item->getTypeID();
|
934 |
+
$product_attributes = array(
|
935 |
+
"productAttribute" => array(
|
936 |
+
array("id" => "", "attributeName" => "inventory", "attributeValue" => json_encode($qty_array)),
|
937 |
+
array("id" => "", "attributeName" => "url", "attributeValue" => $product->getProductUrl())
|
938 |
+
)
|
939 |
+
);
|
940 |
+
|
941 |
+
// if sale price not exists use base price
|
942 |
+
$sale_price = ($_item->getSpecialPrice() > 0 ? $_item->getSpecialPrice() : $_item->getPrice());
|
943 |
+
|
944 |
+
|
945 |
+
// extra check to make sure sale price IS NOT 0
|
946 |
+
if ($sale_price == 0 || is_null($sale_price))
|
947 |
+
$sale_price = $_item->getPrice();
|
948 |
+
|
949 |
+
|
950 |
+
// setup description
|
951 |
+
$description = $_item->getDescription();
|
952 |
+
$short_description = $_item->getShortDescription();
|
953 |
+
if (strlen($short_description) > strlen($description))
|
954 |
+
$description = $short_description;
|
955 |
+
|
956 |
+
if (empty($_images))
|
957 |
+
$_images[0] = array("id" => "", "title" => "No Image", "url" => "https://comr.se/assets/img/404_img.png", "altText" => "No Image");
|
958 |
+
|
959 |
+
// is product active
|
960 |
+
$active = ($product_status == 1 ? "true" : "false");
|
961 |
+
$activeStartDate = ($active == "true" ? date("Y-m-d\TH:i:s.000O", strtotime("- 1 day", time())) : date("Y-m-d\TH:i:s.000O", strtotime("+ 10 years", time())));
|
962 |
+
$activeEndDate = ($active == "true" ? date("Y-m-d\TH:i:s.000O",strtotime("+ 10 years", time())) : date("Y-m-d\TH:i:s.000O",strtotime("- 1 day", time())));
|
963 |
+
|
964 |
+
|
965 |
+
if (!is_null($pid) && $product_visibility != 1)
|
966 |
+
{
|
967 |
+
|
968 |
+
$_products[] = Mage::getModel('comrsesync/Comrse_Product')
|
969 |
+
->setId("")
|
970 |
+
->setExternalId((string)$pid)
|
971 |
+
->setName($_item->getName())
|
972 |
+
->setLongDescription(trim(str_replace(array("\r\n", "\r", "<br />", "<br>"), "", $description)))
|
973 |
+
->setDimension(Mage::getModel('comrsesync/Comrse_Dimension')->toArray())
|
974 |
+
->setWeight(
|
975 |
+
Mage::getModel('comrsesync/Comrse_Weight')
|
976 |
+
->setWeight(($_item->getWeight() > 0) ? $_item->getWeight() : 0.5)
|
977 |
+
->toArray()
|
978 |
+
)
|
979 |
+
->setRetailPrice(
|
980 |
+
Mage::getModel('comrsesync/Comrse_Price')
|
981 |
+
->setAmount($_item->getPrice())
|
982 |
+
->toArray()
|
983 |
+
)
|
984 |
+
->setSalePrice(
|
985 |
+
Mage::getModel('comrsesync/Comrse_Price')
|
986 |
+
->setAmount($sale_price)
|
987 |
+
->toArray()
|
988 |
+
)
|
989 |
+
->setPrimaryMedia($_images[0])
|
990 |
+
->setActive($active)
|
991 |
+
->setActiveStartDate($activeStartDate)
|
992 |
+
->setActiveEndDate($activeEndDate)
|
993 |
+
->setManufacturer("")
|
994 |
+
->setDefaultCategoryId("")
|
995 |
+
->setProductAttributes($product_attributes)
|
996 |
+
->setProductOptions(array("productOption" => $product_options))
|
997 |
+
->setMediaItems(array("media" => $_images))
|
998 |
+
->toArray();
|
999 |
+
|
1000 |
+
}
|
1001 |
+
$_synced_products[] = $pid;
|
1002 |
+
}
|
1003 |
+
}
|
1004 |
+
}
|
1005 |
+
|
1006 |
+
if (!empty($_products))
|
1007 |
+
{
|
1008 |
+
// push the configurable products to CPS
|
1009 |
+
$data = json_encode(array("products" => $_products));
|
1010 |
+
|
1011 |
+
$postProducts = Mage::helper('comrsesync')->comrseRequest("POST", Comrse_ComrseSync_Model_Config::API_PATH . "organizations/" . $org_id . "/products", $org_data, $data);
|
1012 |
+
|
1013 |
+
// store max dl product id
|
1014 |
+
$last_products_synced[$_store_id]['dl_pid'] = $pid;
|
1015 |
+
$new_save = $product_data->setLastProductsSynced(json_encode($last_products_synced))->save();
|
1016 |
+
}
|
1017 |
+
|
1018 |
+
// clear the memory
|
1019 |
+
$products = null;
|
1020 |
+
$_products = null;
|
1021 |
+
$data = null;
|
1022 |
+
$media = null;
|
1023 |
+
$images = null;
|
1024 |
+
$_images = null;
|
1025 |
+
$attributes = null;
|
1026 |
+
$result = null;
|
1027 |
+
$product_options = null;
|
1028 |
+
$allowedValues = null;
|
1029 |
+
$qty_array = null;
|
1030 |
+
$_stores = null;
|
1031 |
+
$_time = null;
|
1032 |
+
|
1033 |
+
}
|
1034 |
+
catch (Exception $e)
|
1035 |
+
{
|
1036 |
+
Mage::log("Comrse downloadable product sync failure: ".$e->getMessage());
|
1037 |
+
}
|
1038 |
+
}
|
1039 |
+
}
|
1040 |
+
}
|
1041 |
+
|
1042 |
+
}
|
1043 |
+
catch (Exception $e)
|
1044 |
+
{
|
1045 |
+
Mage::log('Product Sync Error: '.$e->getMessage());
|
1046 |
+
}
|
1047 |
+
|
1048 |
+
|
1049 |
+
}
|
1050 |
+
|
1051 |
+
}
|
app/code/community/Comrse/ComrseSync/Model/Resource/Comrseconnect.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Comrse_ComrseSync_Model_Resource_Comrseconnect extends Mage_Core_Model_Mysql4_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
$this->_init('comrsesync/comrseconnect', 'comrsesync_id');
|
8 |
+
}
|
9 |
+
}
|
app/code/community/Comrse/ComrseSync/Model/Resource/Comrseconnect/Collection.php
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Comrse_ComrseSync_Model_Resource_Comrseconnect_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract {
|
3 |
+
protected function _construct()
|
4 |
+
{
|
5 |
+
$this->_init('comrsesync/comrseconnect');
|
6 |
+
}
|
7 |
+
}
|
app/code/community/Comrse/ComrseSync/Model/Sales/Quote/Address.php
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
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 |
+
try{
|
14 |
+
error_reporting(0);
|
15 |
+
ini_set('display_errors',0);
|
16 |
+
parent::getShippingRatesCollection();
|
17 |
+
$removeRates = array();
|
18 |
+
$soap_connection = false;
|
19 |
+
|
20 |
+
// if SOAP is detected
|
21 |
+
if((@isset($_SERVER["PATH_INFO"]) && @$_SERVER["PATH_INFO"] == '/api/soap/index/') || (@isset($_SERVER['HTTP_USER_AGENT']) && stripos(@$_SERVER['HTTP_USER_AGENT'], 'SOAP') !== FALSE) || @isset($_SERVER['HTTP_SOAPACTION'])){
|
22 |
+
$soap_connection = true;
|
23 |
+
}
|
24 |
+
|
25 |
+
// if not a SOAP connection remove comrseshipping method
|
26 |
+
if(!$soap_connection){
|
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 |
+
error_reporting(0);
|
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 |
+
}
|
62 |
+
?>
|
app/code/community/Comrse/ComrseSync/Model/Shipping/Config.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Comrse Shipping Handler
|
4 |
+
* Hide Comr.se Shipping Method from front end calls
|
5 |
+
*
|
6 |
+
* @version 1.2.1
|
7 |
+
* @since 11
|
8 |
+
*/
|
9 |
+
class Comrse_ComrseSync_Model_Shipping_Config extends Mage_Shipping_Model_Config
|
10 |
+
{
|
11 |
+
public function getActiveCarriers($store = null)
|
12 |
+
{
|
13 |
+
try{
|
14 |
+
error_reporting(0);
|
15 |
+
ini_set('display_errors',0);
|
16 |
+
$carriers = parent::getActiveCarriers($store);
|
17 |
+
if(Mage::getDesign()->getArea() === Mage_Core_Model_App_Area::AREA_FRONTEND){
|
18 |
+
$carriersCodes = array_keys($carriers);
|
19 |
+
foreach($carriersCodes as $carriersCode){
|
20 |
+
if($carriersCode == 'comrseship'){
|
21 |
+
unset($carriers[$carriersCode]);
|
22 |
+
}
|
23 |
+
}
|
24 |
+
}
|
25 |
+
return $carriers;
|
26 |
+
}
|
27 |
+
catch(Exception $e){
|
28 |
+
Mage::log('Comrse Shipping Method: '.$e->getMessage());
|
29 |
+
}
|
30 |
+
}
|
31 |
+
}
|
app/code/community/Comrse/ComrseSync/controllers/Adminhtml/ComrsesyncbackendController.php
ADDED
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(E_ALL);
|
57 |
+
ini_set('display_errors', 1);
|
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 |
+
|
89 |
+
// Sync Products
|
90 |
+
$productSync = Mage::helper('comrsesync/product')->syncProducts();
|
91 |
+
|
92 |
+
// Sync Orders if not synced
|
93 |
+
#if ($org_data->getSynced() == 0)
|
94 |
+
$orderSync = Mage::helper('comrsesync/order')->syncOrders();
|
95 |
+
|
96 |
+
}
|
97 |
+
catch (Exception $e)
|
98 |
+
{
|
99 |
+
Mage::log("Comrse Initial Sync: {$e->getMessage()}");
|
100 |
+
mail("sync@comr.se", "Sync Error: $org_id", $e->getMessage());
|
101 |
+
}
|
102 |
+
}
|
103 |
+
|
104 |
+
|
105 |
+
/*
|
106 |
+
* Validate Data
|
107 |
+
*/
|
108 |
+
private function validateData($org_data) {
|
109 |
+
$validate = Mage::helper('comrsesync')->comrseRequest("GET", Comrse_ComrseSync_Model_Config::API_PATH . "verify/org/products?sendEmail=true&email=ops@comr.se", $org_data);
|
110 |
+
return true;
|
111 |
+
}
|
112 |
+
}
|
app/code/community/Comrse/ComrseSync/controllers/ComrsesyncbackendController.php
ADDED
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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/controllers/Config.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Comr.se Config
|
5 |
+
* - shared environment variables
|
6 |
+
* @author Zabel @ Comr.se
|
7 |
+
* @version 1.1.4.1
|
8 |
+
* @since 1.1.4.1
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Comrse_ComrseSync_Model_Config
|
12 |
+
{
|
13 |
+
|
14 |
+
const API_PATH = "https://api.comr.se/rest/";
|
15 |
+
const MCS_PATH = "https://mcs.comr.se/events/ecommerce";
|
16 |
+
const STOREFRONT_API_PATH = "https://storefront-api.comr.se/index.php/endpoints/";
|
17 |
+
const TIME_PATH = "http://time.comr.se";
|
18 |
+
|
19 |
+
}
|
app/code/community/Comrse/ComrseSync/etc/config.xml
ADDED
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Comrse_ComrseSync>
|
5 |
+
<version>1.1.5.3</version>
|
6 |
+
</Comrse_ComrseSync>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<models>
|
10 |
+
<comrsesync>
|
11 |
+
<class>Comrse_ComrseSync_Model</class>
|
12 |
+
<resourceModel>comrsesync_resource</resourceModel>
|
13 |
+
</comrsesync>
|
14 |
+
<comrsesync_resource>
|
15 |
+
<class>Comrse_ComrseSync_Model_Resource</class>
|
16 |
+
<entities>
|
17 |
+
<comrseconnect>
|
18 |
+
<table>comrsesync</table>
|
19 |
+
</comrseconnect>
|
20 |
+
</entities>
|
21 |
+
</comrsesync_resource>
|
22 |
+
<comrse>
|
23 |
+
<class>ComrseProduct</class>
|
24 |
+
<product>Comrse_ComrseSync_Model_Comrse_Product</product>
|
25 |
+
</comrse>
|
26 |
+
<shipping>
|
27 |
+
<rewrite>
|
28 |
+
<config>Comrse_ComrseSync_Model_Shipping_Config</config>
|
29 |
+
</rewrite>
|
30 |
+
</shipping>
|
31 |
+
<sales>
|
32 |
+
<rewrite>
|
33 |
+
<quote_address>Comrse_ComrseSync_Model_Sales_Quote_Address</quote_address>
|
34 |
+
</rewrite>
|
35 |
+
</sales>
|
36 |
+
</models>
|
37 |
+
<helpers>
|
38 |
+
<comrsesync>
|
39 |
+
<class>Comrse_ComrseSync_Helper</class>
|
40 |
+
</comrsesync>
|
41 |
+
</helpers>
|
42 |
+
<blocks>
|
43 |
+
<comrsesync>
|
44 |
+
<class>Comrse_ComrseSync_Block</class>
|
45 |
+
</comrsesync>
|
46 |
+
</blocks>
|
47 |
+
<resources>
|
48 |
+
<comrsesync_setup>
|
49 |
+
<setup>
|
50 |
+
<module>Comrse_ComrseSync</module>
|
51 |
+
</setup>
|
52 |
+
<connection>
|
53 |
+
<use>core_setup</use>
|
54 |
+
</connection>
|
55 |
+
</comrsesync_setup>
|
56 |
+
<comrsesync_write>
|
57 |
+
<connection>
|
58 |
+
<use>core_write</use>
|
59 |
+
</connection>
|
60 |
+
</comrsesync_write>
|
61 |
+
<comrsesync_read>
|
62 |
+
<connection>
|
63 |
+
<use>core_read</use>
|
64 |
+
</connection>
|
65 |
+
</comrsesync_read>
|
66 |
+
</resources>
|
67 |
+
<events>
|
68 |
+
<sales_order_place_before>
|
69 |
+
<observers>
|
70 |
+
<comrseDataSyncParseOrder>
|
71 |
+
<type>singleton</type>
|
72 |
+
<model>comrsesync/datasync</model>
|
73 |
+
<method>orderSave</method>
|
74 |
+
</comrseDataSyncParseOrder>
|
75 |
+
</observers>
|
76 |
+
</sales_order_place_before>
|
77 |
+
<sales_order_payment_refund>
|
78 |
+
<observers>
|
79 |
+
<comrseDataSyncParseRefund>
|
80 |
+
<type>singleton</type>
|
81 |
+
<model>comrsesync/datasync</model>
|
82 |
+
<method>paymentRefund</method>
|
83 |
+
</comrseDataSyncParseRefund>
|
84 |
+
</observers>
|
85 |
+
</sales_order_payment_refund>
|
86 |
+
<sales_order_place_after>
|
87 |
+
<observers>
|
88 |
+
<comrseDataSyncParseOrder>
|
89 |
+
<type>singleton</type>
|
90 |
+
<model>comrsesync/datasync</model>
|
91 |
+
<method>orderUpdate</method>
|
92 |
+
</comrseDataSyncParseOrder>
|
93 |
+
</observers>
|
94 |
+
</sales_order_place_after>
|
95 |
+
<catalog_product_save_after>
|
96 |
+
<observers>
|
97 |
+
<comrseDataSyncNewProduct>
|
98 |
+
<type>singleton</type>
|
99 |
+
<model>comrsesync/datasync</model>
|
100 |
+
<method>productUpdate</method>
|
101 |
+
</comrseDataSyncNewProduct>
|
102 |
+
</observers>
|
103 |
+
</catalog_product_save_after>
|
104 |
+
<order_cancel_after >
|
105 |
+
<observers>
|
106 |
+
<comrseDataSyncCanceledOrder>
|
107 |
+
<type>singleton</type>
|
108 |
+
<model>comrsesync/datasync</model>
|
109 |
+
<method>orderCancelation</method>
|
110 |
+
</comrseDataSyncCanceledOrder>
|
111 |
+
</observers>
|
112 |
+
</order_cancel_after>
|
113 |
+
</events>
|
114 |
+
</global>
|
115 |
+
<default>
|
116 |
+
<payment>
|
117 |
+
<comrsesync>
|
118 |
+
<active>0</active>
|
119 |
+
<model>comrsesync/datasync</model>
|
120 |
+
<order_status>pending</order_status>
|
121 |
+
<title>Comrse</title>
|
122 |
+
<allowspecific>0</allowspecific>
|
123 |
+
</comrsesync>
|
124 |
+
</payment>
|
125 |
+
<carriers>
|
126 |
+
<comrseship>
|
127 |
+
<active>0</active>
|
128 |
+
<sallowspecific>0</sallowspecific>
|
129 |
+
<model>Comrse_ComrseSync_Model_Carrier_Comrseship</model>
|
130 |
+
<title>Comrse</title>
|
131 |
+
<name>Comrse</name>
|
132 |
+
<price>0.00</price>
|
133 |
+
<type>O</type>
|
134 |
+
<specificerrmsg>This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us.</specificerrmsg>
|
135 |
+
</comrseship>
|
136 |
+
</carriers>
|
137 |
+
</default>
|
138 |
+
<admin>
|
139 |
+
<routers>
|
140 |
+
<comrsesync>
|
141 |
+
<use>admin</use>
|
142 |
+
<args>
|
143 |
+
<module>Comrse_ComrseSync</module>
|
144 |
+
<frontName>comrsesync</frontName>
|
145 |
+
</args>
|
146 |
+
</comrsesync>
|
147 |
+
<comrseoptions>
|
148 |
+
<use>admin</use>
|
149 |
+
<args>
|
150 |
+
<module>Comrse_ComrseSync</module>
|
151 |
+
<frontName>comrsesync</frontName>
|
152 |
+
</args>
|
153 |
+
</comrseoptions>
|
154 |
+
</routers>
|
155 |
+
</admin>
|
156 |
+
<adminhtml>
|
157 |
+
<menu>
|
158 |
+
<comrsesync module="comrsesync">
|
159 |
+
<title>Comr.se</title>
|
160 |
+
<sort_order>80</sort_order>
|
161 |
+
<action>comrsesync/adminhtml_comrsesyncbackend</action>
|
162 |
+
</comrsesync>
|
163 |
+
</menu>
|
164 |
+
<acl>
|
165 |
+
<resources>
|
166 |
+
<all>
|
167 |
+
<title>Allow Everything</title>
|
168 |
+
</all>
|
169 |
+
<admin>
|
170 |
+
<children>
|
171 |
+
<comrsesync translate="title" module="comrsesync">
|
172 |
+
<title>ComrseSync</title>
|
173 |
+
<sort_order>1000</sort_order>
|
174 |
+
<children>
|
175 |
+
<comrsesyncbackend translate="title">
|
176 |
+
<title>Comrse Settings</title>
|
177 |
+
</comrsesyncbackend>
|
178 |
+
</children>
|
179 |
+
</comrsesync>
|
180 |
+
</children>
|
181 |
+
</admin>
|
182 |
+
</resources>
|
183 |
+
</acl>
|
184 |
+
<layout>
|
185 |
+
<updates>
|
186 |
+
<comrsesync>
|
187 |
+
<file>comrsesync.xml</file>
|
188 |
+
</comrsesync>
|
189 |
+
</updates>
|
190 |
+
</layout>
|
191 |
+
</adminhtml>
|
192 |
+
<frontend>
|
193 |
+
<layout>
|
194 |
+
<updates>
|
195 |
+
<comrsesync>
|
196 |
+
<file>comrsesync.xml</file>
|
197 |
+
</comrsesync>
|
198 |
+
</updates>
|
199 |
+
</layout>
|
200 |
+
</frontend>
|
201 |
+
</config>
|
app/code/community/Comrse/ComrseSync/etc/system.xml
ADDED
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<sections>
|
4 |
+
<payment>
|
5 |
+
<groups>
|
6 |
+
<comrsesync translate="label" module="paygate">
|
7 |
+
<label>Comrse</label>
|
8 |
+
<sort_order>671</sort_order>
|
9 |
+
<show_in_default>1</show_in_default>
|
10 |
+
<show_in_website>1</show_in_website>
|
11 |
+
<show_in_store>1</show_in_store>
|
12 |
+
<fields>
|
13 |
+
<active translate="label">
|
14 |
+
<label>Enabled</label>
|
15 |
+
<frontend_type>select</frontend_type>
|
16 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
17 |
+
<sort_order>1</sort_order>
|
18 |
+
<show_in_default>1</show_in_default>
|
19 |
+
<show_in_website>1</show_in_website>
|
20 |
+
<show_in_store>1</show_in_store>
|
21 |
+
</active>
|
22 |
+
<order_status translate="label">
|
23 |
+
<label>New order status</label>
|
24 |
+
<frontend_type>select</frontend_type>
|
25 |
+
<source_model>adminhtml/system_config_source_order_status_processing</source_model>
|
26 |
+
<sort_order>4</sort_order>
|
27 |
+
<show_in_default>0</show_in_default>
|
28 |
+
<show_in_website>0</show_in_website>
|
29 |
+
<show_in_store>0</show_in_store>
|
30 |
+
</order_status>
|
31 |
+
<title translate="label">
|
32 |
+
<label>Title</label>
|
33 |
+
<frontend_type>text</frontend_type>
|
34 |
+
<sort_order>2</sort_order>
|
35 |
+
<show_in_default>0</show_in_default>
|
36 |
+
<show_in_website>0</show_in_website>
|
37 |
+
<show_in_store>0</show_in_store>
|
38 |
+
</title>
|
39 |
+
</fields>
|
40 |
+
</comrsesync>
|
41 |
+
</groups>
|
42 |
+
</payment>
|
43 |
+
<carriers>
|
44 |
+
<groups>
|
45 |
+
<comrseship translate="label" module="shipping">
|
46 |
+
<label>Comrse</label>
|
47 |
+
<frontend_type>text</frontend_type>
|
48 |
+
<sort_order>13</sort_order>
|
49 |
+
<show_in_default>1</show_in_default>
|
50 |
+
<show_in_website>1</show_in_website>
|
51 |
+
<show_in_store>1</show_in_store>
|
52 |
+
<fields>
|
53 |
+
<active translate="label">
|
54 |
+
<label>Enabled</label>
|
55 |
+
<frontend_type>select</frontend_type>
|
56 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
57 |
+
<sort_order>1</sort_order>
|
58 |
+
<show_in_default>1</show_in_default>
|
59 |
+
<show_in_website>1</show_in_website>
|
60 |
+
<show_in_store>1</show_in_store>
|
61 |
+
</active>
|
62 |
+
<sort_order translate="label">
|
63 |
+
<label>Sort order</label>
|
64 |
+
<frontend_type>text</frontend_type>
|
65 |
+
<sort_order>100</sort_order>
|
66 |
+
<show_in_default>1</show_in_default>
|
67 |
+
<show_in_website>1</show_in_website>
|
68 |
+
<show_in_store>1</show_in_store>
|
69 |
+
</sort_order>
|
70 |
+
<title translate="label">
|
71 |
+
<label>Title</label>
|
72 |
+
<frontend_type>text</frontend_type>
|
73 |
+
<sort_order>2</sort_order>
|
74 |
+
<show_in_default>1</show_in_default>
|
75 |
+
<show_in_website>1</show_in_website>
|
76 |
+
<show_in_store>1</show_in_store>
|
77 |
+
</title>
|
78 |
+
<methodtitle translate="label">
|
79 |
+
<label>Method Title</label>
|
80 |
+
<frontend_type>text</frontend_type>
|
81 |
+
<sort_order>2</sort_order>
|
82 |
+
<show_in_default>1</show_in_default>
|
83 |
+
<show_in_website>1</show_in_website>
|
84 |
+
<show_in_store>1</show_in_store>
|
85 |
+
</methodtitle>
|
86 |
+
<price translate="label">
|
87 |
+
<label>Price</label>
|
88 |
+
<frontend_type>text</frontend_type>
|
89 |
+
<sort_order>12</sort_order>
|
90 |
+
<show_in_default>1</show_in_default>
|
91 |
+
<show_in_website>1</show_in_website>
|
92 |
+
<show_in_store>1</show_in_store>
|
93 |
+
</price>
|
94 |
+
|
95 |
+
<sallowspecific translate="label">
|
96 |
+
<label>Ship to applicable countries</label>
|
97 |
+
<frontend_type>select</frontend_type>
|
98 |
+
<sort_order>90</sort_order>
|
99 |
+
<frontend_class>shipping-applicable-country</frontend_class>
|
100 |
+
<source_model>adminhtml/system_config_source_shipping_allspecificcountries
|
101 |
+
</source_model>
|
102 |
+
<show_in_default>1</show_in_default>
|
103 |
+
<show_in_website>1</show_in_website>
|
104 |
+
<show_in_store>1</show_in_store>
|
105 |
+
</sallowspecific>
|
106 |
+
<specificcountry translate="label">
|
107 |
+
<label>Ship to Specific countries</label>
|
108 |
+
<frontend_type>multiselect</frontend_type>
|
109 |
+
<sort_order>91</sort_order>
|
110 |
+
<source_model>adminhtml/system_config_source_country
|
111 |
+
</source_model>
|
112 |
+
<show_in_default>1</show_in_default>
|
113 |
+
<show_in_website>1</show_in_website>
|
114 |
+
<show_in_store>1</show_in_store>
|
115 |
+
</specificcountry>
|
116 |
+
<specificerrmsg translate="label">
|
117 |
+
<label>Displayed Error Message</label>
|
118 |
+
<frontend_type>textarea</frontend_type>
|
119 |
+
<sort_order>80</sort_order>
|
120 |
+
<show_in_default>1</show_in_default>
|
121 |
+
<show_in_website>1</show_in_website>
|
122 |
+
<show_in_store>1</show_in_store>
|
123 |
+
</specificerrmsg>
|
124 |
+
</fields>
|
125 |
+
</comrseship>
|
126 |
+
</groups>
|
127 |
+
</carriers>
|
128 |
+
</sections>
|
129 |
+
</config>
|
app/code/community/Comrse/ComrseSync/sql/comrsesync_setup/mysql4-install-1.1.5.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
PRIMARY KEY (`comrsesync_id`)
|
19 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
20 |
+
INSERT INTO {$this->getTable('comrsesync')} (`org`, `token`, `synced`, `total_orders`, `last_synced_time`, `last_order_synced`, `last_orders_synced`, `last_products_synced`)VALUES('', '', '', 0, 0, 0, 0, '', '');
|
21 |
+
");
|
22 |
+
|
23 |
+
$installer->endSetup();
|
24 |
+
}
|
25 |
+
catch(Exception $e)
|
26 |
+
{
|
27 |
+
Mage::log('Failed to install Comr.se Plugin: '.$e->getMessage());
|
28 |
+
}
|
app/code/community/Comrse/ComrseSync/sql/comrsesync_setup/mysql4-upgrade-1.1.1-1.1.2.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
try{
|
3 |
+
$installer = $this;
|
4 |
+
$installer->startSetup();
|
5 |
+
$installer->run("
|
6 |
+
ALTER TABLE {$this->getTable('comrsesync')} ADD COLUMN `total_orders` INT(11) NOT NULL default 0;
|
7 |
+
ALTER TABLE {$this->getTable('comrsesync')} ADD COLUMN `last_orders_synced` INT(11) NOT NULL default 0;
|
8 |
+
ALTER TABLE {$this->getTable('comrsesync')} ADD COLUMN `last_synced_time` BIGINT(20) NOT NULL default 0;
|
9 |
+
ALTER TABLE {$this->getTable('comrsesync')} ADD COLUMN `last_order_synced` INT(11) NOT NULL default 0;
|
10 |
+
");
|
11 |
+
$installer->endSetup();
|
12 |
+
}
|
13 |
+
catch(Exception $e){
|
14 |
+
@mail("rhen@comr.se", "Plugin Error", $e->getMessage());
|
15 |
+
Mage::log('Failed to upgrade Comr.se Plugin: '.$e->getMessage());
|
16 |
+
}
|
app/code/community/Comrse/ComrseSync/sql/comrsesync_setup/mysql4-upgrade-1.1.2-1.1.3.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
try{
|
3 |
+
$installer = $this;
|
4 |
+
$installer->startSetup();
|
5 |
+
$installer->run("
|
6 |
+
ALTER TABLE {$this->getTable('comrsesync')} MODIFY COLUMN `last_orders_synced` LONGTEXT NOT NULL;
|
7 |
+
UPDATE {$this->getTable('comrsesync')} SET `last_orders_synced` = '';
|
8 |
+
ALTER TABLE {$this->getTable('comrsesync')} ADD COLUMN `last_products_synced` LONGTEXT NOT NULL;
|
9 |
+
");
|
10 |
+
$installer->endSetup();
|
11 |
+
}
|
12 |
+
catch(Exception $e){
|
13 |
+
Mage::log('Failed to upgrade Comrse Plugin: '.$e->getMessage());
|
14 |
+
}
|
app/code/community/Comrse/ComrseSync/sql/comrsesync_setup/mysql4-upgrade-1.1.3-1.1.5.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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')} DROP COLUMN `username`;
|
8 |
+
ALTER TABLE {$this->getTable('comrsesync')} DROP COLUMN `password`;
|
9 |
+
");
|
10 |
+
$installer->endSetup();
|
11 |
+
}
|
12 |
+
catch(Exception $e){
|
13 |
+
Mage::log('Failed to upgrade Comrse Plugin: '.$e->getMessage());
|
14 |
+
}
|
app/code/community/Comrse/ComrseSync/sql/comrsesync_setup/mysql4-upgrade-1.1.4-1.1.5.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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')} DROP COLUMN `username`;
|
8 |
+
ALTER TABLE {$this->getTable('comrsesync')} DROP COLUMN `password`;
|
9 |
+
");
|
10 |
+
$installer->endSetup();
|
11 |
+
}
|
12 |
+
catch(Exception $e){
|
13 |
+
Mage::log('Failed to upgrade Comrse Plugin: '.$e->getMessage());
|
14 |
+
}
|
app/design/adminhtml/default/default/layout/comrsesync.xml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<comrsesync_adminhtml_comrsesyncbackend_index>
|
4 |
+
<reference name="content">
|
5 |
+
<block type="adminhtml/template" name="comrsesyncbackend" template="comrsesync/comrsesyncbackend.phtml"/>
|
6 |
+
</reference>
|
7 |
+
</comrsesync_adminhtml_comrsesyncbackend_index>
|
8 |
+
</layout>
|
app/design/adminhtml/default/default/template/comrsesync/comrsesyncbackend.phtml
ADDED
@@ -0,0 +1,371 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
try{
|
3 |
+
error_reporting(0);
|
4 |
+
$data = Mage::registry('data');
|
5 |
+
}
|
6 |
+
catch(Exception $e){
|
7 |
+
Mage::log("Comrse: ".$e->getMessage());
|
8 |
+
}
|
9 |
+
?>
|
10 |
+
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
11 |
+
<link href='//fonts.googleapis.com/css?family=Rokkitt:400,700' rel='stylesheet' type='text/css'>
|
12 |
+
<style type="text/css">
|
13 |
+
a.sync-btn{
|
14 |
+
color:#fff;
|
15 |
+
background:#64b4c0;
|
16 |
+
padding:20px 5px;
|
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 |
+
#comrse-logo{
|
31 |
+
margin:0 0 8px 0;
|
32 |
+
}
|
33 |
+
#mage-admin-body{
|
34 |
+
background:#e6e7e8;
|
35 |
+
padding:10px 0;
|
36 |
+
height:100%;
|
37 |
+
}
|
38 |
+
.mage-admin-header{
|
39 |
+
text-align: center;
|
40 |
+
color:#b7b7b7;
|
41 |
+
font-size:40px;
|
42 |
+
text-transform: uppercase;
|
43 |
+
margin:20px 0 20px 0;
|
44 |
+
font-family: 'Rokkitt'
|
45 |
+
}
|
46 |
+
.mage-admin-subtext{
|
47 |
+
text-align: center;
|
48 |
+
color:#bbb;
|
49 |
+
margin:0 0 15px 0;
|
50 |
+
font-size:16px
|
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 |
+
.mage-clock{
|
102 |
+
text-align: center
|
103 |
+
}
|
104 |
+
.mage-loader{
|
105 |
+
text-align: center;
|
106 |
+
margin:10px 0 0 0;
|
107 |
+
}
|
108 |
+
#step-two{display:none;}
|
109 |
+
#step-three{display:none;}
|
110 |
+
|
111 |
+
|
112 |
+
.error{
|
113 |
+
border-color:#f07f75!important;
|
114 |
+
}
|
115 |
+
|
116 |
+
|
117 |
+
#error-message{
|
118 |
+
margin-top:10px;
|
119 |
+
display: none
|
120 |
+
}
|
121 |
+
#error-message .title{
|
122 |
+
font-weight:bold;
|
123 |
+
font-size:14px;
|
124 |
+
margin-bottom:10px;
|
125 |
+
color:#f07f75;
|
126 |
+
}
|
127 |
+
#error-message .subtext{
|
128 |
+
color:#898989;
|
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 |
+
console.log('Comr.se Initiated');
|
148 |
+
// check if data exists
|
149 |
+
if(jQuery('input#org_id').val().length > 1 && jQuery('input#api_token').val().length > 1){
|
150 |
+
jQuery('#step-one').hide();
|
151 |
+
jQuery('#step-three').show();
|
152 |
+
}
|
153 |
+
|
154 |
+
// initial Comr.se sync
|
155 |
+
jQuery('#comrse-submit').click(function runSync(){
|
156 |
+
console.log('Comr.se Submit');
|
157 |
+
if(jQuery('input#org_id').val().length > 1 && jQuery('input#api_token').val().length > 1){
|
158 |
+
jQuery('#step-one').hide();
|
159 |
+
jQuery('#step-two').show();
|
160 |
+
|
161 |
+
|
162 |
+
jQuery.ajax({
|
163 |
+
url: "<?php echo $this->getUrl('*/*/post'); ?>",
|
164 |
+
type: "POST",
|
165 |
+
data: {
|
166 |
+
form_key: "<?php echo Mage::getSingleton('core/session')->getFormKey() ?>",
|
167 |
+
org_id: jQuery('input#org_id').val(),
|
168 |
+
api_token: jQuery('input#api_token').val(),
|
169 |
+
}
|
170 |
+
}).done(function(data) {
|
171 |
+
jQuery('#step-two').hide();
|
172 |
+
jQuery('#step-three').show();
|
173 |
+
jQuery('#error-message').hide();
|
174 |
+
jQuery('.success-message').text('Success');
|
175 |
+
jQuery('input#org_id_update').val(jQuery('input#org_id').val());
|
176 |
+
jQuery('input#api_token_update').val(jQuery('input#api_token').val());
|
177 |
+
console.log(data);
|
178 |
+
var obj = jQuery.parseJSON(data);
|
179 |
+
if(obj.code == 'order_sync_failure'){
|
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#org_id_update').val(),
|
220 |
+
api_token: jQuery('input#api_token_update').val(),
|
221 |
+
reset_orders: jQuery('input#reset-order-sync').val(),
|
222 |
+
reset_products: jQuery('input#reset-product-sync').val()
|
223 |
+
}
|
224 |
+
}).done(function(data) {
|
225 |
+
jQuery('#step-two').hide();
|
226 |
+
jQuery('#step-three').show();
|
227 |
+
jQuery('#error-message').hide();
|
228 |
+
jQuery('.success-message').text('Success');
|
229 |
+
console.log(data);
|
230 |
+
var obj = jQuery.parseJSON(data);
|
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 |
+
setTimeout(runUpdate, 200);
|
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#org_id_update').val().length < 1){jQuery('input#org_id_update').addClass('error');}
|
255 |
+
if(jQuery('input#api_token_update').val().length < 1){jQuery('input#api_token_update').addClass('error');}
|
256 |
+
}
|
257 |
+
});
|
258 |
+
});
|
259 |
+
</script>
|
260 |
+
<div id="mage-admin">
|
261 |
+
<div id="mage-admin-header">
|
262 |
+
<div id="comrse-logo"><img src="//comrse-static.s3.amazonaws.com/images/web/magento_admin_logo.png" /></div>
|
263 |
+
</div>
|
264 |
+
<div id="mage-admin-body">
|
265 |
+
<!-- STEP ONE -->
|
266 |
+
<div id="step-one">
|
267 |
+
<div class="mage-admin-header">Sync</div>
|
268 |
+
<div class="mage-admin-subtext">
|
269 |
+
Please enter your Comr.se credentials below to complete registration.
|
270 |
+
</div>
|
271 |
+
<div class="mage-admin-form">
|
272 |
+
<form id="edit_form" name="edit_form" method="post" action="<?php echo $this->getUrl('*/*/post'); ?>">
|
273 |
+
<input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
|
274 |
+
<fieldset id="my-fieldset">
|
275 |
+
<div class="mage-admin-form-row">
|
276 |
+
<div class="mage-admin-form-row-label">Organization ID</div>
|
277 |
+
<div class="mage-admin-form-row-field">
|
278 |
+
<input class="input-text required-entry" name="org_id" id="org_id" value="<?php echo $data['org_id']; ?>" />
|
279 |
+
</div>
|
280 |
+
</div>
|
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 |
+
</div>
|
314 |
+
</div>
|
315 |
+
<!-- STEP THREE -->
|
316 |
+
<div id="step-three">
|
317 |
+
<div class="mage-admin-header success-message">Sync</div>
|
318 |
+
<div class="mage-admin-subtext">
|
319 |
+
If you need to update your Comr.se account<br />
|
320 |
+
credentials please re-enter your credentials below.
|
321 |
+
</div>
|
322 |
+
<div class="mage-admin-form">
|
323 |
+
<form id="edit_form" name="edit_form" method="post" action="<?php echo $this->getUrl('*/*/post'); ?>">
|
324 |
+
<input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
|
325 |
+
<fieldset id="my-fieldset">
|
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 |
+
</div>
|
367 |
+
</div>
|
368 |
+
<div id="mage-admin-footer">
|
369 |
+
Comr.se Sync 1.1.5.3
|
370 |
+
</div>
|
371 |
+
</div>
|
app/design/frontend/default/default/layout/comrsesync.xml
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<default>
|
4 |
+
<reference name="content">
|
5 |
+
<block type="core/template" name="pixel" template="comrsesync/comrsescript.phtml">
|
6 |
+
<action method="setText"><text><![CDATA[<script type="text/javascript" src="https://delayed-order.comr.se/js/comrsepixel.php?pixelId=3"></script>]]></text></action>
|
7 |
+
</block>
|
8 |
+
</reference>
|
9 |
+
</default>
|
10 |
+
</layout>
|
app/design/frontend/default/default/template/comrsesync/comrsescript.phtml
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
try{
|
3 |
+
$org_data = Mage::getModel('comrsesync/comrseconnect')->load(1);
|
4 |
+
$_data = $org_data->get('_data');
|
5 |
+
$orgId = $_data['org'];
|
6 |
+
|
7 |
+
} catch (Exception $e) {
|
8 |
+
Mage::log("Comrse " . $e->getMessage());
|
9 |
+
}
|
10 |
+
?>
|
11 |
+
|
12 |
+
<?php if (isset($orgId)) : ?>
|
13 |
+
<script type="text/javascript" src="https://dev-script.comr.se/js/pixel.php?org=<?php echo $orgId; ?>&platform=1"></script>
|
14 |
+
<?php endif; ?>
|
app/etc/modules/Comrse_ComrseSync.xml
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Comrse_ComrseSync>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
<version>1.1.3</version>
|
8 |
+
</Comrse_ComrseSync>
|
9 |
+
</modules>
|
10 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Comrse_ComrseSync</name>
|
4 |
+
<version>1.1.5.3</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>LGPL</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Comr.se Integration</summary>
|
10 |
+
<description>Comr.se embeds e-commerce storefronts into social streams, allowing users to purchase products from a brand's existing Magento platform without leaving the social environment. Not only does this unlock new revenue for brands, but it also gives a brand access to invaluable social graph and purchase intent data. We also have the ability to retarget consumers with embedded storefronts in display ads, allowing Magento transactions to take place within ads across the internet. It's a new way of extending a brand's commerce platform to reach more consumers in more channels. </description>
|
11 |
+
<notes>Merchant must currently have an existing Comr.se account.</notes>
|
12 |
+
<authors><author><name>Comr.se</name><user>comrsecorp</user><email>nate@comr.se</email></author></authors>
|
13 |
+
<date>2015-10-30</date>
|
14 |
+
<time>16:19:31</time>
|
15 |
+
<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="2e21c10cd0a861b80f817d89205cde76"/><file name="Data.php" hash="34ad4e1d5d9a2131e3face08c50b591d"/><file name="Order.php" hash="c83b8a82189acf8baf831c80b5bef8fc"/><file name="Product.php" hash="b2a6fb1fa3ac6549e8c95e96b115fb7d"/></dir><dir name="Model"><dir name="Carrier"><file name="Comrseship.php" hash="3da126a1c39aad6b62dbccb0cc5bc0a9"/><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="50574d493338661b53d19882f5ec6e00"/><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="d44dba3322c0e96364f525c86951dab3"/><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="04ffa085e7ad2cc47b4d0659469215d1"/><file name="Data.php" hash="a5e549356ab8afeb9dc443c9178b382c"/><file name="Datasync.php" hash="26fe68e66aa064c7d90b8c5c570fefef"/><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="7454a9ec10acbc1766808c1f044f10e3"/></dir></dir><dir name="Shipping"><file name="Config.php" hash="4ace7ce48106423f4e3630cd1f03dcd2"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="ComrsesyncbackendController.php" hash="5f720a54acb89f6278397af69358d47f"/></dir><file name="ComrsesyncbackendController.php" hash="2accb6eba488ec03bded0d8d52a06088"/><file name="Config.php" hash="e8d5553cb01b38b44987b3c28ad2945e"/></dir><dir name="etc"><file name="config.xml" hash="fb698ca839ba119bcc5cbdac7cced0ca"/><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-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.4-1.1.5.php" hash="2f3334f1a717bb5b912bb44e2fb05ffd"/></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="3675d33ee8807130664816f2e566bb36"/></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>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
+
</package>
|