Version Notes
The ChannelUnity connector kit for Magento.
This version imports the shipping service level into an order, and also resolves an issue when copying product data where catalog flat product is enabled.
Download this release
Release Info
Developer | Magento Core Team |
Extension | Camiloo_Channelunity |
Version | 1.0.0.3 |
Comparing to | |
See all releases |
Code changes from version 1.0.0.2 to 1.0.0.3
- app/code/community/Camiloo/Channelunity/Model/Categories.php +23 -17
- app/code/community/Camiloo/Channelunity/Model/Collection.php +11 -0
- app/code/community/Camiloo/Channelunity/Model/Customrate.php +1 -1
- app/code/community/Camiloo/Channelunity/Model/Observer.php +192 -100
- app/code/community/Camiloo/Channelunity/Model/Orders.php +7 -7
- app/code/community/Camiloo/Channelunity/Model/Products.php +30 -7
- app/code/community/Camiloo/Channelunity/controllers/ApiController.php +3 -2
- app/code/community/Camiloo/Channelunity/etc/config.xml +9 -0
- app/design/adminhtml/default/default/template/channelunity/configheader.phtml +1 -1
- package.xml +5 -5
app/code/community/Camiloo/Channelunity/Model/Categories.php
CHANGED
@@ -48,23 +48,29 @@ class Camiloo_Channelunity_Model_Categories extends Camiloo_Channelunity_Model_A
|
|
48 |
<StoreviewId><![CDATA[{$storeViewId}]]></StoreviewId>\n";
|
49 |
|
50 |
foreach ($collection as $category) {
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
}
|
69 |
|
70 |
$messageToSend .= "</CategoryList>";
|
48 |
<StoreviewId><![CDATA[{$storeViewId}]]></StoreviewId>\n";
|
49 |
|
50 |
foreach ($collection as $category) {
|
51 |
+
|
52 |
+
// $children = $category->getChildren();
|
53 |
+
$pid = $category->getData('parent_id');
|
54 |
+
$lvl = $category->getData('level');
|
55 |
+
// $childCount = $children->count();
|
56 |
+
|
57 |
+
$catPathTemp = $category->getData('path');
|
58 |
+
|
59 |
+
if (strpos($catPathTemp, "$rootCatId/") === 0 // start of path
|
60 |
+
|| strpos($catPathTemp, "/$rootCatId/") > 0 // middle of path
|
61 |
+
|| strpos($catPathTemp, "/$rootCatId") == (strlen($catPathTemp)-strlen("/$rootCatId")) ) // OR at END of path
|
62 |
+
{
|
63 |
+
$messageToSend .= "<Category>\n";
|
64 |
+
$messageToSend .= " <ID><![CDATA[{$category->getId()}]]></ID>\n";
|
65 |
+
$messageToSend .= " <Name><![CDATA[{$category->getName()}]]></Name>\n";
|
66 |
+
$messageToSend .= " <Position><![CDATA[{$category->getData('position')}]]></Position>\n";
|
67 |
+
$messageToSend .= " <CategoryPath><![CDATA[{$catPathTemp}]]></CategoryPath>\n";
|
68 |
+
$messageToSend .= " <ParentID><![CDATA[{$category->getData('parent_id')}]]></ParentID>\n";
|
69 |
+
$messageToSend .= " <Level><![CDATA[{$category->getData('level')}]]></Level>\n";
|
70 |
+
$messageToSend .= "</Category>\n\n";
|
71 |
+
|
72 |
+
}
|
73 |
+
|
74 |
}
|
75 |
|
76 |
$messageToSend .= "</CategoryList>";
|
app/code/community/Camiloo/Channelunity/Model/Collection.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Camiloo_Channelunity_Model_Collection extends Mage_Catalog_Model_Resource_Product_Collection {
|
5 |
+
public function isEnabledFlat()
|
6 |
+
{
|
7 |
+
return false;
|
8 |
+
}
|
9 |
+
}
|
10 |
+
|
11 |
+
|
app/code/community/Camiloo/Channelunity/Model/Customrate.php
CHANGED
@@ -20,7 +20,7 @@ class Camiloo_Channelunity_Model_Customrate
|
|
20 |
$method->setCarrier('channelunitycustomrate');
|
21 |
$method->setCarrierTitle($this->getConfigData('title'));
|
22 |
$method->setMethod('channelunitycustomrate');
|
23 |
-
|
24 |
|
25 |
$shipPrice = Mage::getSingleton('core/session')->getShippingPrice();
|
26 |
|
20 |
$method->setCarrier('channelunitycustomrate');
|
21 |
$method->setCarrierTitle($this->getConfigData('title'));
|
22 |
$method->setMethod('channelunitycustomrate');
|
23 |
+
// $method->setMethodTitle(Mage::getSingleton('core/session')->getShippingMethod());
|
24 |
|
25 |
$shipPrice = Mage::getSingleton('core/session')->getShippingPrice();
|
26 |
|
app/code/community/Camiloo/Channelunity/Model/Observer.php
CHANGED
@@ -1,122 +1,199 @@
|
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
|
|
3 |
class Camiloo_Channelunity_Model_Observer extends Camiloo_Channelunity_Model_Abstract {
|
4 |
|
|
|
|
|
|
|
5 |
public function productWasSaved(Varien_Event_Observer $observer) {
|
6 |
-
|
7 |
-
|
8 |
-
|
|
|
9 |
|
10 |
-
$xml = "<Products>\n";
|
11 |
-
$xml .= "<SourceURL>".Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB)
|
12 |
-
."</SourceURL>\n";
|
13 |
-
|
14 |
-
$xml .= "<StoreViewId>$storeViewId</StoreViewId>\n";
|
15 |
-
|
16 |
-
$xml .= Mage::getModel('channelunity/products')->generateCuXmlForSingleProduct($product->getId(), $storeViewId);
|
17 |
-
|
18 |
-
$xml .= "</Products>\n";
|
19 |
-
|
20 |
-
$this->postToChannelUnity($xml, "ProductData");
|
21 |
-
}
|
22 |
-
|
23 |
-
public function hookToControllerActionPostDispatch($observer) {
|
24 |
-
$evname = $observer->getEvent()->getControllerAction()->getFullActionName();
|
25 |
-
|
26 |
-
if ($evname == 'adminhtml_catalog_product_action_attribute_save')
|
27 |
-
{
|
28 |
$xml = "<Products>\n";
|
29 |
$xml .= "<SourceURL>".Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB)
|
30 |
."</SourceURL>\n";
|
31 |
|
32 |
-
$storeViewId = Mage::helper('adminhtml/catalog_product_edit_action_attribute')->getSelectedStoreId();
|
33 |
$xml .= "<StoreViewId>$storeViewId</StoreViewId>\n";
|
34 |
|
35 |
-
$
|
36 |
-
|
37 |
-
foreach ($pids as $productId) {
|
38 |
-
$xml .= Mage::getModel('channelunity/products')->generateCuXmlForSingleProduct(
|
39 |
-
$productId, $storeViewId);
|
40 |
-
}
|
41 |
|
42 |
$xml .= "</Products>\n";
|
43 |
|
44 |
$this->postToChannelUnity($xml, "ProductData");
|
45 |
}
|
46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
|
48 |
-
$this->
|
|
|
|
|
|
|
49 |
}
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
}
|
54 |
}
|
55 |
|
|
|
|
|
|
|
56 |
public function orderWasPlaced(Varien_Event_Observer $observer)
|
57 |
{
|
58 |
-
|
59 |
-
|
60 |
-
$ev = $observer->getEvent();
|
61 |
-
|
62 |
-
if (is_object($ev)) {
|
63 |
|
64 |
-
|
65 |
|
66 |
-
|
67 |
-
|
68 |
-
$items = $order->getAllItems();
|
69 |
|
70 |
-
|
71 |
|
72 |
-
|
73 |
-
|
74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
}
|
76 |
|
77 |
public function getItemsForUpdateCommon($items, $storeId) {
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
|
|
|
|
|
|
85 |
|
86 |
-
|
|
|
|
|
|
|
|
|
87 |
}
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
$prodTemp->getId(), $storeId);
|
92 |
-
|
93 |
-
$this->postToChannelUnity($xml, "ProductData");
|
94 |
-
}
|
95 |
}
|
96 |
|
97 |
public function onInvoicePaid(Varien_Event_Observer $observer)
|
98 |
{
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
|
|
|
|
|
|
|
|
109 |
}
|
110 |
|
111 |
/**
|
112 |
* Order is cancelled and has been saved. post order status change msg to CU
|
113 |
*/
|
114 |
public function checkForCancellation(Varien_Event_Observer $observer) {
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
|
|
|
|
|
|
120 |
}
|
121 |
|
122 |
/**
|
@@ -124,38 +201,53 @@ class Camiloo_Channelunity_Model_Observer extends Camiloo_Channelunity_Model_Abs
|
|
124 |
*/
|
125 |
public function saveTrackingToAmazon(Varien_Event_Observer $observer)
|
126 |
{
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
|
|
|
|
|
|
|
|
142 |
}
|
143 |
|
144 |
public function shipAmazon(Varien_Event_Observer $observer)
|
145 |
{
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
|
|
|
|
|
|
|
|
154 |
}
|
155 |
|
|
|
|
|
|
|
156 |
public function categorySave(Varien_Event_Observer $observer) {
|
157 |
-
|
158 |
-
|
|
|
|
|
|
|
|
|
159 |
}
|
160 |
|
161 |
public function categoryDelete(Varien_Event_Observer $observer) {
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* ChannelUnity observers.
|
5 |
+
* Posts events to the CU cloud when various Magento events occur.
|
6 |
+
*/
|
7 |
class Camiloo_Channelunity_Model_Observer extends Camiloo_Channelunity_Model_Abstract {
|
8 |
|
9 |
+
/**
|
10 |
+
* Called on saving a product in Magento.
|
11 |
+
*/
|
12 |
public function productWasSaved(Varien_Event_Observer $observer) {
|
13 |
+
try {
|
14 |
+
$product = $observer->getEvent()->getProduct();
|
15 |
+
|
16 |
+
$storeViewId = $product->getStoreId();
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
$xml = "<Products>\n";
|
19 |
$xml .= "<SourceURL>".Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB)
|
20 |
."</SourceURL>\n";
|
21 |
|
|
|
22 |
$xml .= "<StoreViewId>$storeViewId</StoreViewId>\n";
|
23 |
|
24 |
+
$xml .= Mage::getModel('channelunity/products')->generateCuXmlForSingleProduct($product->getId(), $storeViewId);
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
$xml .= "</Products>\n";
|
27 |
|
28 |
$this->postToChannelUnity($xml, "ProductData");
|
29 |
}
|
30 |
+
catch (Exception $x) {
|
31 |
+
}
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Called on deleting a product in Magento.
|
36 |
+
*/
|
37 |
+
public function productWasDeleted(Varien_Event_Observer $observer) {
|
38 |
+
try {
|
39 |
+
$product = $observer->getEvent()->getProduct();
|
40 |
+
|
41 |
+
$storeViewId = $product->getStoreId();
|
42 |
+
|
43 |
+
$xml = "<Products>\n";
|
44 |
+
$xml .= "<SourceURL>".Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB)
|
45 |
+
."</SourceURL>\n";
|
46 |
+
$xml .= "<StoreViewId>$storeViewId</StoreViewId>\n";
|
47 |
+
$xml .= "<ProductID>{$product->getId()}</ProductID>\n";
|
48 |
+
$xml .= "<Deleted>TRUE</Deleted>\n";
|
49 |
+
|
50 |
+
$xml .= "</Products>\n";
|
51 |
|
52 |
+
$this->postToChannelUnity($xml, "ProductData");
|
53 |
+
|
54 |
+
}
|
55 |
+
catch (Exception $x) {
|
56 |
}
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Allows the observing of more generic events in Magento.
|
61 |
+
* Useful in multiple product save for example.
|
62 |
+
*/
|
63 |
+
public function hookToControllerActionPostDispatch($observer) {
|
64 |
+
try {
|
65 |
+
$evname = $observer->getEvent()->getControllerAction()->getFullActionName();
|
66 |
|
67 |
+
if ($evname == 'adminhtml_catalog_product_action_attribute_save')
|
68 |
+
{
|
69 |
+
$xml = "<Products>\n";
|
70 |
+
$xml .= "<SourceURL>".Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB)
|
71 |
+
."</SourceURL>\n";
|
72 |
+
|
73 |
+
$storeViewId = Mage::helper('adminhtml/catalog_product_edit_action_attribute')->getSelectedStoreId();
|
74 |
+
$xml .= "<StoreViewId>$storeViewId</StoreViewId>\n";
|
75 |
+
|
76 |
+
$pids = Mage::helper('adminhtml/catalog_product_edit_action_attribute')->getProductIds();
|
77 |
+
|
78 |
+
foreach ($pids as $productId) {
|
79 |
+
$xml .= Mage::getModel('channelunity/products')->generateCuXmlForSingleProduct(
|
80 |
+
$productId, $storeViewId);
|
81 |
+
}
|
82 |
+
|
83 |
+
$xml .= "</Products>\n";
|
84 |
+
|
85 |
+
$this->postToChannelUnity($xml, "ProductData");
|
86 |
+
}
|
87 |
+
else if ($evname == 'adminhtml_catalog_category_save') {
|
88 |
+
|
89 |
+
$this->categorySave($observer);
|
90 |
+
}
|
91 |
+
else if ($evname == 'adminhtml_catalog_category_delete') {
|
92 |
+
|
93 |
+
$this->categoryDelete($observer);
|
94 |
+
}
|
95 |
+
else if ($evname == 'adminhtml_catalog_product_delete') {
|
96 |
+
$xml = "<Products>\n";
|
97 |
+
$xml .= "<SourceURL>".Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB)
|
98 |
+
."</SourceURL>\n";
|
99 |
+
|
100 |
+
$storeViewId = Mage::helper('adminhtml/catalog_product_edit_action_attribute')->getSelectedStoreId();
|
101 |
+
$xml .= "<StoreViewId>$storeViewId</StoreViewId>\n";
|
102 |
+
|
103 |
+
$productId = $observer->getEvent()->getControllerAction()->getRequest()->getParam('id');
|
104 |
+
|
105 |
+
$xml .= "<DeletedProductId>".$productId."</DeletedProductId>\n";
|
106 |
+
|
107 |
+
$xml .= "</Products>\n";
|
108 |
+
|
109 |
+
$this->postToChannelUnity($xml, "ProductData");
|
110 |
+
}
|
111 |
+
}
|
112 |
+
catch (Exception $x) {
|
113 |
}
|
114 |
}
|
115 |
|
116 |
+
/**
|
117 |
+
* Called on placing an order. Stock levels are updated on CU.
|
118 |
+
*/
|
119 |
public function orderWasPlaced(Varien_Event_Observer $observer)
|
120 |
{
|
121 |
+
try {
|
122 |
+
if (is_object($observer)) {
|
|
|
|
|
|
|
123 |
|
124 |
+
$ev = $observer->getEvent();
|
125 |
|
126 |
+
if (is_object($ev)) {
|
|
|
|
|
127 |
|
128 |
+
$order = $ev->getOrder();
|
129 |
|
130 |
+
if (is_object($order)) {
|
131 |
+
|
132 |
+
$items = $order->getAllItems();
|
133 |
+
|
134 |
+
$this->getItemsForUpdateCommon($items, $order->getStore()->getId());
|
135 |
+
|
136 |
+
}
|
137 |
+
}
|
138 |
+
}
|
139 |
+
}
|
140 |
+
catch (Exception $x) {
|
141 |
+
}
|
142 |
}
|
143 |
|
144 |
public function getItemsForUpdateCommon($items, $storeId) {
|
145 |
+
try {
|
146 |
+
foreach ($items as $item) {
|
147 |
+
|
148 |
+
$sku = $item->getSku();
|
149 |
+
|
150 |
+
$prodTemp = Mage::getModel('catalog/product')->loadByAttribute('sku', $sku);
|
151 |
+
if (!$prodTemp) {
|
152 |
+
|
153 |
+
continue;
|
154 |
+
}
|
155 |
|
156 |
+
// Item was ordered on website, stock will have reduced, update to CU
|
157 |
+
$xml = Mage::getModel('channelunity/products')->generateCuXmlForSingleProduct(
|
158 |
+
$prodTemp->getId(), $storeId);
|
159 |
+
|
160 |
+
$this->postToChannelUnity($xml, "ProductData");
|
161 |
}
|
162 |
+
}
|
163 |
+
catch (Exception $x) {
|
164 |
+
}
|
|
|
|
|
|
|
|
|
165 |
}
|
166 |
|
167 |
public function onInvoicePaid(Varien_Event_Observer $observer)
|
168 |
{
|
169 |
+
try {
|
170 |
+
if (is_object($observer) && is_object($observer->getInvoice()))
|
171 |
+
{
|
172 |
+
$order = $observer->getInvoice()->getOrder();
|
173 |
+
|
174 |
+
if (is_object($order))
|
175 |
+
{
|
176 |
+
$items = $order->getAllItems();
|
177 |
+
$this->getItemsForUpdateCommon($items, $order->getStore()->getId());
|
178 |
+
}
|
179 |
+
}
|
180 |
+
}
|
181 |
+
catch (Exception $x) {
|
182 |
+
}
|
183 |
}
|
184 |
|
185 |
/**
|
186 |
* Order is cancelled and has been saved. post order status change msg to CU
|
187 |
*/
|
188 |
public function checkForCancellation(Varien_Event_Observer $observer) {
|
189 |
+
try {
|
190 |
+
$order = $observer->getOrder();
|
191 |
+
|
192 |
+
$xml = Mage::getModel('channelunity/orders')->generateCuXmlForOrderStatus($order);
|
193 |
+
$this->postToChannelUnity($xml, "OrderStatusUpdate");
|
194 |
+
}
|
195 |
+
catch (Exception $x) {
|
196 |
+
}
|
197 |
}
|
198 |
|
199 |
/**
|
201 |
*/
|
202 |
public function saveTrackingToAmazon(Varien_Event_Observer $observer)
|
203 |
{
|
204 |
+
try {
|
205 |
+
// Only mark as shipped when order has tracking information.
|
206 |
+
$track = $observer->getEvent()->getTrack();
|
207 |
+
$order = $track->getShipment()->getOrder();
|
208 |
+
|
209 |
+
if ($track->getCarrierCode() == "custom") {
|
210 |
+
$carrierName = $track->getTitle();
|
211 |
+
} else {
|
212 |
+
$carrierName = $track->getCarrierCode();
|
213 |
+
}
|
214 |
+
|
215 |
+
$xml = Mage::getModel('channelunity/orders')->generateCuXmlForOrderShip($order,
|
216 |
+
$carrierName,
|
217 |
+
$track->getTitle(),
|
218 |
+
$track->getNumber());
|
219 |
+
$this->postToChannelUnity($xml, "OrderStatusUpdate");
|
220 |
+
}
|
221 |
+
catch (Exception $x) {
|
222 |
+
}
|
223 |
}
|
224 |
|
225 |
public function shipAmazon(Varien_Event_Observer $observer)
|
226 |
{
|
227 |
+
try {
|
228 |
+
$shipment = $observer->getEvent()->getShipment();
|
229 |
+
$order = $shipment->getOrder();
|
230 |
+
|
231 |
+
$xml = Mage::getModel('channelunity/orders')->generateCuXmlForOrderShip($order,
|
232 |
+
"",
|
233 |
+
"",
|
234 |
+
"");
|
235 |
+
$this->postToChannelUnity($xml, "OrderStatusUpdate");
|
236 |
+
}
|
237 |
+
catch (Exception $x) {
|
238 |
+
}
|
239 |
}
|
240 |
|
241 |
+
/**
|
242 |
+
* Category is saved. CU needs to know about it.
|
243 |
+
*/
|
244 |
public function categorySave(Varien_Event_Observer $observer) {
|
245 |
+
try {
|
246 |
+
$myStoreURL = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
247 |
+
$categoryStatus = Mage::getModel('channelunity/categories')->postCategoriesToCU($myStoreURL);
|
248 |
+
}
|
249 |
+
catch (Exception $x) {
|
250 |
+
}
|
251 |
}
|
252 |
|
253 |
public function categoryDelete(Varien_Event_Observer $observer) {
|
app/code/community/Camiloo/Channelunity/Model/Orders.php
CHANGED
@@ -277,11 +277,11 @@ class Camiloo_Channelunity_Model_Orders extends Camiloo_Channelunity_Model_Abstr
|
|
277 |
'region' => (string) $order->ShippingInfo->State,
|
278 |
'region_id' => (string) $order->ShippingInfo->State,
|
279 |
'country_id' => (string) $order->ShippingInfo->Country,
|
280 |
-
// 'email' => (string) $order->ShippingInfo->email,
|
281 |
'telephone' => (string) $order->ShippingInfo->PhoneNumber
|
282 |
);
|
283 |
|
284 |
Mage::getSingleton('core/session')->setShippingPrice(((string) $order->ShippingInfo->ShippingPrice) / $reverseRate);
|
|
|
285 |
|
286 |
// add the shipping address to the quote.
|
287 |
$shippingAddress = $quote->getShippingAddress()->addData($shippingAddressData);
|
@@ -290,14 +290,13 @@ class Camiloo_Channelunity_Model_Orders extends Camiloo_Channelunity_Model_Abstr
|
|
290 |
$method->setCarrier('channelunitycustomrate');
|
291 |
$method->setCarrierTitle('ChannelUnity Shipping');
|
292 |
$method->setMethod('channelunitycustomrate');
|
293 |
-
$method->setMethodTitle(
|
294 |
|
295 |
$shipPrice = Mage::getSingleton('core/session')->getShippingPrice();
|
296 |
|
297 |
$method->setPrice($shipPrice);
|
298 |
$method->setCost($shipPrice);
|
299 |
-
|
300 |
-
|
301 |
$rate = Mage::getModel('sales/quote_address_rate')
|
302 |
->importShippingRate($method);
|
303 |
|
@@ -375,9 +374,10 @@ class Camiloo_Channelunity_Model_Orders extends Camiloo_Channelunity_Model_Abstr
|
|
375 |
$transaction->setOrderPaymentObject($newOrder->getPayment());
|
376 |
$transaction->setOrder($newOrder);
|
377 |
$transaction->setTxnType('capture');
|
378 |
-
$transaction->setTxnId((string) $order->OrderId);
|
379 |
$transaction->setAdditionalInformation('SubscriptionId', (string) $dataArray->SubscriptionId);
|
380 |
$transaction->setAdditionalInformation('RemoteOrderID', (string) $order->OrderId);
|
|
|
381 |
|
382 |
$serviceType = (string) $order->ServiceSku;
|
383 |
switch ($serviceType) {
|
@@ -413,7 +413,7 @@ class Camiloo_Channelunity_Model_Orders extends Camiloo_Channelunity_Model_Abstr
|
|
413 |
if (isset($order->OrderFlags) && ( ((string) $order->OrderFlags) == "AMAZON_FBA")) {
|
414 |
|
415 |
$transaction->setAdditionalInformation('AmazonFBA', 'Yes');
|
416 |
-
//
|
417 |
// $newOrder->setState('complete', 'complete', 'Order was fulfilled by Amazon', false);
|
418 |
}
|
419 |
$transaction->save();
|
@@ -434,7 +434,7 @@ class Camiloo_Channelunity_Model_Orders extends Camiloo_Channelunity_Model_Abstr
|
|
434 |
$newOrder->setData('gift_message_id', $gift_message_id);
|
435 |
}
|
436 |
|
437 |
-
$newOrder->setCreatedAt((
|
438 |
$newOrder->save();
|
439 |
|
440 |
|
277 |
'region' => (string) $order->ShippingInfo->State,
|
278 |
'region_id' => (string) $order->ShippingInfo->State,
|
279 |
'country_id' => (string) $order->ShippingInfo->Country,
|
|
|
280 |
'telephone' => (string) $order->ShippingInfo->PhoneNumber
|
281 |
);
|
282 |
|
283 |
Mage::getSingleton('core/session')->setShippingPrice(((string) $order->ShippingInfo->ShippingPrice) / $reverseRate);
|
284 |
+
// Mage::getSingleton('core/session')->setShippingMethod((string) $order->ShippingInfo->Service);
|
285 |
|
286 |
// add the shipping address to the quote.
|
287 |
$shippingAddress = $quote->getShippingAddress()->addData($shippingAddressData);
|
290 |
$method->setCarrier('channelunitycustomrate');
|
291 |
$method->setCarrierTitle('ChannelUnity Shipping');
|
292 |
$method->setMethod('channelunitycustomrate');
|
293 |
+
$method->setMethodTitle((string) $order->ShippingInfo->Service);
|
294 |
|
295 |
$shipPrice = Mage::getSingleton('core/session')->getShippingPrice();
|
296 |
|
297 |
$method->setPrice($shipPrice);
|
298 |
$method->setCost($shipPrice);
|
299 |
+
|
|
|
300 |
$rate = Mage::getModel('sales/quote_address_rate')
|
301 |
->importShippingRate($method);
|
302 |
|
374 |
$transaction->setOrderPaymentObject($newOrder->getPayment());
|
375 |
$transaction->setOrder($newOrder);
|
376 |
$transaction->setTxnType('capture');
|
377 |
+
$transaction->setTxnId((string) $order->OrderId);
|
378 |
$transaction->setAdditionalInformation('SubscriptionId', (string) $dataArray->SubscriptionId);
|
379 |
$transaction->setAdditionalInformation('RemoteOrderID', (string) $order->OrderId);
|
380 |
+
$transaction->setAdditionalInformation('ShippingService', (string) $order->ShippingInfo->Service);
|
381 |
|
382 |
$serviceType = (string) $order->ServiceSku;
|
383 |
switch ($serviceType) {
|
413 |
if (isset($order->OrderFlags) && ( ((string) $order->OrderFlags) == "AMAZON_FBA")) {
|
414 |
|
415 |
$transaction->setAdditionalInformation('AmazonFBA', 'Yes');
|
416 |
+
// Can't set 'complete' state manually - ideally import tracking info and create shipment in Mage
|
417 |
// $newOrder->setState('complete', 'complete', 'Order was fulfilled by Amazon', false);
|
418 |
}
|
419 |
$transaction->save();
|
434 |
$newOrder->setData('gift_message_id', $gift_message_id);
|
435 |
}
|
436 |
|
437 |
+
$newOrder->setCreatedAt((string) $order->PurchaseDate);
|
438 |
$newOrder->save();
|
439 |
|
440 |
|
app/code/community/Camiloo/Channelunity/Model/Products.php
CHANGED
@@ -275,11 +275,17 @@
|
|
275 |
$myval = serialize($myval);
|
276 |
}
|
277 |
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
|
|
|
|
|
|
|
|
|
|
|
|
|
283 |
$prodDataValue = $myval;
|
284 |
}
|
285 |
} else {
|
@@ -376,6 +382,23 @@
|
|
376 |
return $val;
|
377 |
}
|
378 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
379 |
/**
|
380 |
* Return a set of product data to CU.
|
381 |
*/
|
@@ -396,19 +419,19 @@
|
|
396 |
try {
|
397 |
|
398 |
// get the highest product ID
|
399 |
-
$collectionOfProduct = Mage::getModel(
|
400 |
$collectionOfProduct->setOrder('entity_id', 'DESC');
|
401 |
$collectionOfProduct->setPageSize(1);
|
402 |
$collectionOfProduct->setCurPage(1);
|
403 |
$totp = $collectionOfProduct->getFirstItem();
|
404 |
$totp = $totp->getEntityId();
|
405 |
|
406 |
-
$collectionOfProduct = Mage::getModel(
|
407 |
|
408 |
$totalNumProducts = $this->executeQueryScalar(str_replace("SELECT", "SELECT count(*) as count_cu, ", $collectionOfProduct->getSelect()), 'count_cu');
|
409 |
|
410 |
$collectionOfProduct->addAttributeToFilter("entity_id", array('gteq' => $rangeFrom))
|
411 |
-
|
412 |
|
413 |
// monitor memory and max exec
|
414 |
if ($this->maxMemoryChar == "M") {
|
275 |
$myval = serialize($myval);
|
276 |
}
|
277 |
|
278 |
+
if (is_object($attribute)) {
|
279 |
+
|
280 |
+
$prodDataValue = $attribute->getSource()
|
281 |
+
->getOptionText($myval);
|
282 |
|
283 |
+
if ($prodDataValue == '') {
|
284 |
+
|
285 |
+
$prodDataValue = $myval;
|
286 |
+
}
|
287 |
+
}
|
288 |
+
else {
|
289 |
$prodDataValue = $myval;
|
290 |
}
|
291 |
} else {
|
382 |
return $val;
|
383 |
}
|
384 |
|
385 |
+
public function doSetValue($request) {
|
386 |
+
$storeId = (string) $request->StoreviewId;
|
387 |
+
$fieldName = (string) $request->FieldName;
|
388 |
+
$fieldValue = (string) $request->FieldValue;
|
389 |
+
$sku = (string) $request->SKU;
|
390 |
+
|
391 |
+
$collectionOfProduct = Mage::getModel($this->_collection)->getCollection()->addStoreFilter($storeId);
|
392 |
+
$collectionOfProduct->setPageSize(1);
|
393 |
+
$collectionOfProduct->setCurPage(1);
|
394 |
+
$collectionOfProduct->addFieldToFilter('sku', $sku);
|
395 |
+
$product = $collectionOfProduct->getFirstItem();
|
396 |
+
|
397 |
+
// set an attribute for the product
|
398 |
+
$product->setData($fieldName, $fieldValue);
|
399 |
+
$product->save();
|
400 |
+
}
|
401 |
+
|
402 |
/**
|
403 |
* Return a set of product data to CU.
|
404 |
*/
|
419 |
try {
|
420 |
|
421 |
// get the highest product ID
|
422 |
+
$collectionOfProduct = Mage::getModel('channelunity/collection')->addStoreFilter($storeId);
|
423 |
$collectionOfProduct->setOrder('entity_id', 'DESC');
|
424 |
$collectionOfProduct->setPageSize(1);
|
425 |
$collectionOfProduct->setCurPage(1);
|
426 |
$totp = $collectionOfProduct->getFirstItem();
|
427 |
$totp = $totp->getEntityId();
|
428 |
|
429 |
+
$collectionOfProduct = Mage::getModel('channelunity/collection')->addStoreFilter($storeId);
|
430 |
|
431 |
$totalNumProducts = $this->executeQueryScalar(str_replace("SELECT", "SELECT count(*) as count_cu, ", $collectionOfProduct->getSelect()), 'count_cu');
|
432 |
|
433 |
$collectionOfProduct->addAttributeToFilter("entity_id", array('gteq' => $rangeFrom))
|
434 |
+
->setOrder('entity_id', 'ASC');
|
435 |
|
436 |
// monitor memory and max exec
|
437 |
if ($this->maxMemoryChar == "M") {
|
app/code/community/Camiloo/Channelunity/controllers/ApiController.php
CHANGED
@@ -10,6 +10,7 @@ class Camiloo_Channelunity_ApiController extends Mage_Core_Controller_Front_Acti
|
|
10 |
echo ' </ChannelUnity>';
|
11 |
die;
|
12 |
}
|
|
|
13 |
public function testtableAction() {
|
14 |
if (Mage::getModel('channelunity/orders')->table_exists("moo")) {
|
15 |
echo "true";
|
@@ -133,8 +134,8 @@ EOD;
|
|
133 |
Mage::getModel('channelunity/orders')->doUpdate($request);
|
134 |
break;
|
135 |
|
136 |
-
case "
|
137 |
-
|
138 |
break;
|
139 |
|
140 |
case "ProductData":
|
10 |
echo ' </ChannelUnity>';
|
11 |
die;
|
12 |
}
|
13 |
+
|
14 |
public function testtableAction() {
|
15 |
if (Mage::getModel('channelunity/orders')->table_exists("moo")) {
|
16 |
echo "true";
|
134 |
Mage::getModel('channelunity/orders')->doUpdate($request);
|
135 |
break;
|
136 |
|
137 |
+
case "AttributePush":
|
138 |
+
Mage::getModel('channelunity/products')->doSetValue($request);
|
139 |
break;
|
140 |
|
141 |
case "ProductData":
|
app/code/community/Camiloo/Channelunity/etc/config.xml
CHANGED
@@ -129,6 +129,15 @@
|
|
129 |
</channelunity>
|
130 |
</observers>
|
131 |
</catalog_product_save_after>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
<controller_action_postdispatch>
|
133 |
<observers>
|
134 |
|
129 |
</channelunity>
|
130 |
</observers>
|
131 |
</catalog_product_save_after>
|
132 |
+
<catalog_controller_product_delete>
|
133 |
+
<observers>
|
134 |
+
<channelunity>
|
135 |
+
<type>model</type>
|
136 |
+
<class>channelunity/observer</class>
|
137 |
+
<method>productWasDeleted</method>
|
138 |
+
</channelunity>
|
139 |
+
</observers>
|
140 |
+
</catalog_controller_product_delete>
|
141 |
<controller_action_postdispatch>
|
142 |
<observers>
|
143 |
|
app/design/adminhtml/default/default/template/channelunity/configheader.phtml
CHANGED
@@ -16,7 +16,7 @@
|
|
16 |
<h3>ChannelUnity Integration for Magento</h3>
|
17 |
Devised and Developed in Manchester, UK by <a href="http://www.camiloo.co.uk/?ref=cu" target="_blank">Camiloo Limited</a><br />
|
18 |
<?php
|
19 |
-
$xml = Mage::getModel('channelunity/checkforupdates')->getRemoteXMLFileData("http://my.channelunity.com/versioncheck.php?Version=1.0.0.
|
20 |
$html = $xml->DisplayMessage[0];
|
21 |
echo $html;
|
22 |
?>
|
16 |
<h3>ChannelUnity Integration for Magento</h3>
|
17 |
Devised and Developed in Manchester, UK by <a href="http://www.camiloo.co.uk/?ref=cu" target="_blank">Camiloo Limited</a><br />
|
18 |
<?php
|
19 |
+
$xml = Mage::getModel('channelunity/checkforupdates')->getRemoteXMLFileData("http://my.channelunity.com/versioncheck.php?Version=1.0.0.3");
|
20 |
$html = $xml->DisplayMessage[0];
|
21 |
echo $html;
|
22 |
?>
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Camiloo_Channelunity</name>
|
4 |
-
<version>1.0.0.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.camiloo.co.uk/license.txt">Camiloo EULA</license>
|
7 |
<channel>community</channel>
|
@@ -11,11 +11,11 @@
|
|
11 |
|
12 |
Should you need any help getting started, please email support@camiloo.co.uk</description>
|
13 |
<notes>The ChannelUnity connector kit for Magento.
|
14 |
-
This version
|
15 |
<authors><author><name>Camiloo Limited</name><user>auto-converted</user><email>hello@camiloo.co.uk</email></author></authors>
|
16 |
-
<date>2012-05-
|
17 |
-
<time>
|
18 |
-
<contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="channelunity"><file name="configheader.phtml" hash="
|
19 |
<compatible/>
|
20 |
<dependencies/>
|
21 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Camiloo_Channelunity</name>
|
4 |
+
<version>1.0.0.3</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.camiloo.co.uk/license.txt">Camiloo EULA</license>
|
7 |
<channel>community</channel>
|
11 |
|
12 |
Should you need any help getting started, please email support@camiloo.co.uk</description>
|
13 |
<notes>The ChannelUnity connector kit for Magento.
|
14 |
+
This version imports the shipping service level into an order, and also resolves an issue when copying product data where catalog flat product is enabled.</notes>
|
15 |
<authors><author><name>Camiloo Limited</name><user>auto-converted</user><email>hello@camiloo.co.uk</email></author></authors>
|
16 |
+
<date>2012-05-13</date>
|
17 |
+
<time>20:18:08</time>
|
18 |
+
<contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="channelunity"><file name="configheader.phtml" hash="162d755efb5cc23dfb49e9d9f479248c"/><file name="paymentinfo.phtml" hash="60967f7ab38fe17c879b272eed25f986"/></dir></dir></dir></dir></dir></target><target name="magecommunity"><dir name="Camiloo"><dir name="Channelunity"><dir name="Block"><file name="Configheader.php" hash="6d7de078f04901e94b8b9675bcd9e4ac"/><file name="Paymentform.php" hash="1f3e79556f15a57b9761c3665a103103"/><file name="Paymentinfo.php" hash="6c3c36d92592dd802fb8045dc065d231"/></dir><dir name="controllers"><file name="ApiController.php" hash="97e35be7817e58617c3a60daaeb070ac"/><file name="ApiController.php.old.php" hash="01ff34c2cf5798a82cfc11b19ab6decd"/></dir><dir name="etc"><file name="config.xml" hash="4d813910e0807b964b3e68484eb38f41"/><file name="system.xml" hash="b43f861f8ab3dadca3c122be10790609"/></dir><dir name="Helper"><file name="Data.php" hash="1ccace887d4a09eca0b641394c65d35f"/></dir><dir name="Model"><file name="Abstract.php" hash="dde32099ae2fc34f9cd7e9c2ae23bc3c"/><file name="Attributes.php" hash="b6428ef515e083e172ccf0b6e07e32fe"/><file name="Categories.php" hash="39e83c8cd3a75821feb358843ea80c9a"/><file name="Checkforupdates.php" hash="6fcf97b37aa3f3a1e0149f7761975925"/><file name="Collection.php" hash="28172943843f2462d75193a9f9be78b9"/><file name="Customrate.php" hash="bf274c6eaeacd56e22b0dc92e476d1ad"/><file name="Entity.php" hash="8ff876068c52106c589a5079cc0f9215"/><file name="Observer.php" hash="7571550a51d97398d01dcaba3d091436"/><file name="Ordercreatebackport.php" hash="3b696fb97ce6550a967d76436a3d131c"/><file name="Orders.php" hash="85dbe1274bb2600068b9e7aa5d0ca356"/><file name="Payment.php" hash="7fe570cf0aaf7c2bcdf1982b6e69caa6"/><file name="Paymentinfo.php" hash="e11658c9fa02420557441f5c8a41f8a0"/><file name="Paymentmethoduk.php" hash="a99409ed4ee5f7e426df4eaf793482d6"/><file name="Products.php" hash="fb35dc5c88ed976e7cfce58fea905892"/><file name="Stores.php" hash="7f299877f0b62ca9d30a46b333124680"/></dir><dir name="sql"><dir name="channelunity_setup"><file name="install-1.0.0.php" hash="7127fff7219108813aa35dd7596b09d3"/><file name="mysql4-install-0.0.1.php" hash="7ebc892c87b9401bf402a7e1976133e3"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Camiloo_Channelunity.xml" hash="cccfbce64ee176372c5afecb8676fab0"/></dir></target></contents>
|
19 |
<compatible/>
|
20 |
<dependencies/>
|
21 |
</package>
|