Camiloo_Channelunity - Version 1.0.0.8

Version Notes

The ChannelUnity connector kit for Magento.
Allows products with custom options to be uploaded to ChannelUnity. Prevents order import validation errors.

Download this release

Release Info

Developer Magento Core Team
Extension Camiloo_Channelunity
Version 1.0.0.8
Comparing to
See all releases


Code changes from version 1.0.0.7 to 1.0.0.8

app/code/community/Camiloo/Channelunity/Model/Abstract.php CHANGED
@@ -10,53 +10,6 @@
10
  class Camiloo_Channelunity_Model_Abstract
11
  {
12
 
13
- /* From-To range examples.
14
- dataRange [xml element array]
15
- <request>
16
- <requestbody>
17
- <range>
18
- <filter on="date">
19
- <operator type="from">
20
- <value>2001-10-20</value>
21
- </operator>
22
- <operator type="to">
23
- <value>2001-10-22</value>
24
- </operator>
25
- </filter>
26
- <filter on="date">
27
- <operator type="from">
28
- <value>2001-10-20</value>
29
- </operator>
30
- <operator type="to">
31
- <value>2001-10-22</value>
32
- </operator>
33
- </filter>
34
- </range>
35
- </request>
36
- */
37
- /* Simple operator filter example
38
- dataRange [xml element array]
39
- <filter on="product_id">
40
- <operator type="gte">27</operator>
41
- </filter>
42
- */
43
- /* Range filter example
44
-
45
- dataRange [xml element array]
46
- <filter on="product_id">
47
- <operator type="in">
48
- <value>22</value>
49
- <value>23</value>
50
- <value>24</value>
51
- <value>25</value>
52
- <value>26</value>
53
- <value>27</value>
54
- <value>28</value>
55
- <value>29</value>
56
- <value>30</value>
57
- </operator>
58
- </filter>
59
- */
60
  public function filterCollection($collection, $dataRange){
61
 
62
  foreach($dataRange as $filter){
@@ -146,6 +99,18 @@ class Camiloo_Channelunity_Model_Abstract
146
  die;
147
  }
148
 
 
 
 
 
 
 
 
 
 
 
 
 
149
  /**
150
  * Calls the VerifyNotification API.
151
  */
@@ -162,7 +127,7 @@ class Camiloo_Channelunity_Model_Abstract
162
  <Payload>$messageverify</Payload>
163
  </ChannelUnity>");
164
 
165
- curl_setopt($session, CURLOPT_URL, "http://my.channelunity.com/event.php");
166
  curl_setopt($session, CURLOPT_POST, TRUE);
167
  curl_setopt($session, CURLOPT_RETURNTRANSFER, TRUE);
168
  curl_setopt($session, CURLOPT_POSTFIELDS, array('message' => $xml));
@@ -246,7 +211,7 @@ class Camiloo_Channelunity_Model_Abstract
246
 
247
  $xml = urlencode($xml);
248
 
249
- curl_setopt($session, CURLOPT_URL, "http://my.channelunity.com/event.php");
250
  curl_setopt($session, CURLOPT_POST, TRUE);
251
  curl_setopt($session, CURLOPT_RETURNTRANSFER, TRUE);
252
  curl_setopt($session, CURLOPT_POSTFIELDS, array('message' => $xml));
@@ -284,7 +249,7 @@ class Camiloo_Channelunity_Model_Abstract
284
 
285
  $xml = urlencode($xml);
286
 
287
- curl_setopt($session, CURLOPT_URL, "http://my.channelunity.com/event.php");
288
  curl_setopt($session, CURLOPT_POST, TRUE);
289
  curl_setopt($session, CURLOPT_RETURNTRANSFER, TRUE);
290
  curl_setopt($session, CURLOPT_POSTFIELDS, array('message' => $xml));
@@ -296,6 +261,32 @@ class Camiloo_Channelunity_Model_Abstract
296
  return $result;
297
  }
298
 
 
 
 
 
 
299
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
300
  }
301
  ?>
10
  class Camiloo_Channelunity_Model_Abstract
11
  {
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  public function filterCollection($collection, $dataRange){
14
 
15
  foreach($dataRange as $filter){
99
  die;
100
  }
101
 
102
+ public function getEndpoint() {
103
+ if (strpos($_SERVER['SERVER_NAME'], "camiloo.co.uk") !== false) {
104
+
105
+ return "http://staging.channelunity.com/event.php";
106
+ }
107
+ else {
108
+
109
+ return "http://my.channelunity.com/event.php";
110
+ }
111
+ }
112
+
113
+
114
  /**
115
  * Calls the VerifyNotification API.
116
  */
127
  <Payload>$messageverify</Payload>
128
  </ChannelUnity>");
129
 
130
+ curl_setopt($session, CURLOPT_URL, $this->getEndpoint());
131
  curl_setopt($session, CURLOPT_POST, TRUE);
132
  curl_setopt($session, CURLOPT_RETURNTRANSFER, TRUE);
133
  curl_setopt($session, CURLOPT_POSTFIELDS, array('message' => $xml));
211
 
212
  $xml = urlencode($xml);
213
 
214
+ curl_setopt($session, CURLOPT_URL, $this->getEndpoint());
215
  curl_setopt($session, CURLOPT_POST, TRUE);
216
  curl_setopt($session, CURLOPT_RETURNTRANSFER, TRUE);
217
  curl_setopt($session, CURLOPT_POSTFIELDS, array('message' => $xml));
249
 
250
  $xml = urlencode($xml);
251
 
252
+ curl_setopt($session, CURLOPT_URL, $this->getEndpoint());
253
  curl_setopt($session, CURLOPT_POST, TRUE);
254
  curl_setopt($session, CURLOPT_RETURNTRANSFER, TRUE);
255
  curl_setopt($session, CURLOPT_POSTFIELDS, array('message' => $xml));
261
  return $result;
262
  }
263
 
264
+ public function postMyURLToChannelUnity($merchantName) {
265
+
266
+ $session = curl_init();
267
+
268
+ $baseurl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
269
 
270
+ $xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>
271
+ <ChannelUnity>
272
+ <MerchantName>$merchantName</MerchantName>
273
+ <Authorization>" . $this->getValidUserAuth() . "</Authorization>
274
+ <RequestType>SuggestEndpointURL</RequestType>
275
+ <Payload><URL>$baseurl</URL></Payload>
276
+ </ChannelUnity>";
277
+
278
+ $xml = urlencode($xml);
279
+
280
+ curl_setopt($session, CURLOPT_URL, $this->getEndpoint());
281
+ curl_setopt($session, CURLOPT_POST, TRUE);
282
+ curl_setopt($session, CURLOPT_RETURNTRANSFER, TRUE);
283
+ curl_setopt($session, CURLOPT_POSTFIELDS, array('message' => $xml));
284
+
285
+ $result = curl_exec($session);
286
+
287
+ curl_close($session);
288
+
289
+ return $result;
290
+ }
291
  }
292
  ?>
app/code/community/Camiloo/Channelunity/Model/Collection.php CHANGED
@@ -1,5 +1,6 @@
1
  <?php
2
- if (version_compare(Mage::getVersion(), "1.6.0.0", ">=")) {
 
3
 
4
  class Camiloo_Channelunity_Model_Collection extends Mage_Catalog_Model_Resource_Product_Collection {
5
  public function isEnabledFlat()
1
  <?php
2
+ if (version_compare(Mage::getVersion(), "1.6.0.0", ">=")
3
+ && class_exists("Mage_Catalog_Model_Resource_Product_Collection")) {
4
 
5
  class Camiloo_Channelunity_Model_Collection extends Mage_Catalog_Model_Resource_Product_Collection {
6
  public function isEnabledFlat()
app/code/community/Camiloo/Channelunity/Model/Customrate.php CHANGED
@@ -14,6 +14,11 @@ class Camiloo_Channelunity_Model_Customrate
14
 
15
  protected $_code = 'channelunitycustomrate';
16
  protected $_isFixed = true;
 
 
 
 
 
17
 
18
  public function collectRates(Mage_Shipping_Model_Rate_Request $request)
19
  {
@@ -21,22 +26,30 @@ class Camiloo_Channelunity_Model_Customrate
21
  return false;
22
  }
23
 
24
- $result = Mage::getModel('shipping/rate_result');
25
-
26
- $method = Mage::getModel('shipping/rate_result_method');
27
- $method->setCarrier('channelunitycustomrate');
28
- $method->setCarrierTitle($this->getConfigData('title'));
29
- $method->setMethod('channelunitycustomrate');
30
- // $method->setMethodTitle(Mage::getSingleton('core/session')->getShippingMethod());
31
-
32
- $shipPrice = Mage::getSingleton('core/session')->getShippingPrice();
33
-
34
- $method->setPrice($shipPrice);
35
- $method->setCost($shipPrice);
36
-
37
- $result->append($method);
38
-
39
- return $result;
 
 
 
 
 
 
 
 
40
  }
41
 
42
  public function getAllowedMethods()
14
 
15
  protected $_code = 'channelunitycustomrate';
16
  protected $_isFixed = true;
17
+
18
+
19
+ public function isActive() {
20
+ return false;
21
+ }
22
 
23
  public function collectRates(Mage_Shipping_Model_Rate_Request $request)
24
  {
26
  return false;
27
  }
28
 
29
+ // check if we are getting the rate for a CU request.
30
+ // to do this, the easiest way is to check for some form
31
+ // of CU data incoming.
32
+ $cuOrderCheck = Mage::registry('cu_order_in_progress');
33
+ if($cuOrderCheck == 1){
34
+ $result = Mage::getModel('shipping/rate_result');
35
+
36
+ $method = Mage::getModel('shipping/rate_result_method');
37
+ $method->setCarrier('channelunitycustomrate');
38
+ $method->setCarrierTitle($this->getConfigData('title'));
39
+ $method->setMethod('channelunitycustomrate');
40
+ // $method->setMethodTitle(Mage::getSingleton('core/session')->getShippingMethod());
41
+
42
+ $shipPrice = Mage::getSingleton('core/session')->getShippingPrice();
43
+
44
+ $method->setPrice($shipPrice);
45
+ $method->setCost($shipPrice);
46
+
47
+ $result->append($method);
48
+
49
+ return $result;
50
+ }else{
51
+ return false;
52
+ }
53
  }
54
 
55
  public function getAllowedMethods()
app/code/community/Camiloo/Channelunity/Model/Observer.php CHANGED
@@ -162,7 +162,7 @@ class Camiloo_Channelunity_Model_Observer extends Camiloo_Channelunity_Model_Abs
162
 
163
  // Item was ordered on website, stock will have reduced, update to CU
164
  $xml = Mage::getModel('channelunity/products')->generateCuXmlForSingleProduct(
165
- $prodTemp->getId(), $storeId);
166
 
167
  $this->postToChannelUnity($xml, "ProductData");
168
  }
@@ -257,8 +257,39 @@ class Camiloo_Channelunity_Model_Observer extends Camiloo_Channelunity_Model_Abs
257
  }
258
  }
259
 
260
- public function categoryDelete(Varien_Event_Observer $observer) {
261
- //TODO
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
262
  }
263
  }
264
  ?>
162
 
163
  // Item was ordered on website, stock will have reduced, update to CU
164
  $xml = Mage::getModel('channelunity/products')->generateCuXmlForSingleProduct(
165
+ $prodTemp->getId(), $storeId, $item->getQtyOrdered());
166
 
167
  $this->postToChannelUnity($xml, "ProductData");
168
  }
257
  }
258
  }
259
 
260
+ public function configSaveAfter(Varien_Event_Observer $observer) {
261
+ try {
262
+ if (is_object($observer)) {
263
+ $event = $observer->getEvent();
264
+
265
+ if (is_object($event)) {
266
+
267
+ $configData = $event->getData('config_data');
268
+
269
+ if (is_object($configData)) {
270
+
271
+ $configData = $configData->getData();
272
+
273
+ if (isset($configData['fieldset_data'])) {
274
+
275
+ $fieldset_data = $configData['fieldset_data'];
276
+
277
+
278
+ if (isset($fieldset_data['merchantname'])) {
279
+
280
+ $merchantName = $fieldset_data['merchantname'];
281
+
282
+ Mage::getModel('channelunity/products')->postMyURLToChannelUnity($merchantName);
283
+
284
+ }
285
+
286
+ }
287
+ }
288
+ }
289
+ }
290
+ }
291
+ catch (Exception $x) {
292
+ }
293
  }
294
  }
295
  ?>
app/code/community/Camiloo/Channelunity/Model/Ordercreatebackport.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * This code is backported from the Magento codebase at v1.4.0.0 to ensure
4
- * compatability across Magento versions older than v1.4. Its v1.4 classname is
5
  * Mage_Sales_Model_Service_Quote. No modifications have been made.
6
  *
7
  * @category Mage
1
  <?php
2
  /**
3
  * This code is backported from the Magento codebase at v1.4.0.0 to ensure
4
+ * compatibility across Magento versions older than v1.4. Its v1.4 classname is
5
  * Mage_Sales_Model_Service_Quote. No modifications have been made.
6
  *
7
  * @category Mage
app/code/community/Camiloo/Channelunity/Model/Orders.php CHANGED
@@ -8,12 +8,9 @@
8
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
  */
10
  class Camiloo_Channelunity_Model_Orders extends Camiloo_Channelunity_Model_Abstract
11
- {
12
-
13
  protected $_collection = 'sales/order';
14
 
15
-
16
-
17
  /*
18
 
19
  RequestType OrderStatusUpdate
@@ -114,13 +111,11 @@ class Camiloo_Channelunity_Model_Orders extends Camiloo_Channelunity_Model_Abstr
114
  }
115
 
116
  public function doCreate($dataArray, $order) {
117
- // this method takes an array of correct structure and creates a valid order creation
118
- // request within Magento.
119
-
120
-
121
 
122
  echo "<Info>Next order: {$order->OrderId} Create Quote</Info>";
123
-
124
  try {
125
 
126
  $quote = Mage::getModel('sales/quote')->setStoreId((string) $dataArray->StoreviewId);
@@ -194,15 +189,36 @@ class Camiloo_Channelunity_Model_Orders extends Camiloo_Channelunity_Model_Abstr
194
  $currencyObject = Mage::getModel('directory/currency');
195
  $reverseRate = $currencyObject->getResource()->getRate($storeCurrency, (string) $order->Currency);
196
 
197
- if ($reverseRate == "") {
198
- $reverseRate = 1.0;
199
- }
200
-
201
  echo "<ConversionRate>$reverseRate</ConversionRate>";
 
202
 
203
  // add product(s)
204
  foreach ($order->OrderItems->Item as $orderitem) {
205
- $product = Mage::getModel('catalog/product')->loadByAttribute((string) $dataArray->SkuAttribute, (string) $orderitem->SKU);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
206
 
207
  if (is_object($product)) {
208
 
@@ -211,10 +227,14 @@ class Camiloo_Channelunity_Model_Orders extends Camiloo_Channelunity_Model_Abstr
211
  $item = Mage::getModel('sales/quote_item');
212
  $item->setQuote($quote)->setProduct($product);
213
  $item->setData('qty', (string) $orderitem->Quantity);
 
 
 
214
  $quote->addItem($item);
215
  }
216
  else {
217
- echo "<Info>Can't find SKU to add to quote ".((string) $orderitem->SKU).", trying to create stub</Info>";
 
218
 
219
  $prodIdToLoad = 0;
220
 
@@ -262,6 +282,8 @@ class Camiloo_Channelunity_Model_Orders extends Camiloo_Channelunity_Model_Abstr
262
  $item = Mage::getModel('sales/quote_item');
263
  $item->setQuote($quote)->setProduct($product);
264
  $item->setData('qty', (string) $orderitem->Quantity);
 
 
265
  $quote->addItem($item);
266
  }
267
  else {
@@ -294,14 +316,14 @@ class Camiloo_Channelunity_Model_Orders extends Camiloo_Channelunity_Model_Abstr
294
  'postcode' => $postcode,
295
  'region' => (string) $order->ShippingInfo->State,
296
  'region_id' => $regionId,
297
- 'country_id' => (string) $order->ShippingInfo->Country
 
298
  );
299
 
300
  // add the billing address to the quote.
301
  $billingAddress = $quote->getBillingAddress()->addData($billingAddressData);
302
-
303
-
304
- echo "<Info>Set Shipping Address</Info>";
305
 
306
  // set the shipping address
307
  $shippingAddressData = array(
@@ -315,7 +337,8 @@ class Camiloo_Channelunity_Model_Orders extends Camiloo_Channelunity_Model_Abstr
315
  'region' => (string) $order->ShippingInfo->State,
316
  'region_id' => $regionId,
317
  'country_id' => (string) $order->ShippingInfo->Country,
318
- 'telephone' => (string) $order->ShippingInfo->PhoneNumber
 
319
  );
320
 
321
  Mage::getSingleton('core/session')->setShippingPrice(((string) $order->ShippingInfo->ShippingPrice) / $reverseRate);
@@ -355,9 +378,13 @@ class Camiloo_Channelunity_Model_Orders extends Camiloo_Channelunity_Model_Abstr
355
  $service = Mage::getModel('channelunity/ordercreatebackport', $quote);
356
  }
357
 
 
 
 
358
  $service->submitAll();
359
  $newOrder = $service->getOrder(); // returns full order object.
360
-
 
361
 
362
  if (!is_object($newOrder)) {
363
  echo "<NotImported>".((string) $order->OrderId)."</NotImported>";
@@ -370,26 +397,32 @@ class Camiloo_Channelunity_Model_Orders extends Camiloo_Channelunity_Model_Abstr
370
  } catch (Exception $x) {
371
  echo "<Exception><![CDATA[".$x->getMessage()." ".$x->getTraceAsString()."]]></Exception>";
372
  echo "<NotImported>".((string) $order->OrderId)."</NotImported>";
 
373
  return;
374
  }
375
 
376
  $ordStatus = $this->CUOrderStatusToMagentoStatus((string) $order->OrderStatus);
377
 
378
  try {
379
- $newOrder->setState($ordStatus, $ordStatus, 'Order imported from ChannelUnity', false);
380
-
 
 
 
 
381
  }
382
  catch (Exception $x1) {
383
 
384
  try {
385
- $newOrder->setState('closed', 'closed', 'Order imported from ChannelUnity', false);
386
-
387
  }
388
  catch (Exception $x2) {
389
  }
390
  }
391
 
392
- // This order will have been paid for, otherwise it won't have imported
 
393
 
394
  $invoiceId = Mage::getModel('sales/order_invoice_api')
395
  ->create($newOrder->getIncrementId(), array());
@@ -412,9 +445,12 @@ class Camiloo_Channelunity_Model_Orders extends Camiloo_Channelunity_Model_Abstr
412
  $transaction->setOrder($newOrder);
413
  $transaction->setTxnType('capture');
414
  $transaction->setTxnId((string) $order->OrderId);
415
- $transaction->setAdditionalInformation('SubscriptionId', (string) $dataArray->SubscriptionId);
416
- $transaction->setAdditionalInformation('RemoteOrderID', (string) $order->OrderId);
417
- $transaction->setAdditionalInformation('ShippingService', (string) $order->ShippingInfo->Service);
 
 
 
418
 
419
  $serviceType = (string) $order->ServiceSku;
420
  switch ($serviceType) {
@@ -451,7 +487,13 @@ class Camiloo_Channelunity_Model_Orders extends Camiloo_Channelunity_Model_Abstr
451
 
452
  $transaction->setAdditionalInformation('AmazonFBA', 'Yes');
453
  // Can't set 'complete' state manually - ideally import tracking info and create shipment in Mage
454
- // $newOrder->setState('complete', 'complete', 'Order was fulfilled by Amazon', false);
 
 
 
 
 
 
455
  }
456
  $transaction->save();
457
 
@@ -460,9 +502,6 @@ class Camiloo_Channelunity_Model_Orders extends Camiloo_Channelunity_Model_Abstr
460
 
461
  $message = Mage::getModel('giftmessage/message');
462
 
463
- // $gift_sender = $message->getData('sender');
464
- // $gift_recipient = $message->getData('recipient');
465
-
466
  $message->setMessage($order->ShippingInfo->GiftMessage);
467
  $message->save();
468
 
@@ -472,9 +511,58 @@ class Camiloo_Channelunity_Model_Orders extends Camiloo_Channelunity_Model_Abstr
472
  }
473
 
474
  $newOrder->setCreatedAt((string) $order->PurchaseDate);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
475
  $newOrder->save();
476
 
477
-
478
  }
479
 
480
  private function createStubProduct($missingSku, $productTitle, $websiteID, $keyorder, $price, $qty, $skuAttribute) {
@@ -506,7 +594,7 @@ class Camiloo_Channelunity_Model_Orders extends Camiloo_Channelunity_Model_Abstr
506
  // Default Magento attribute
507
  $product->setWeight('0.01');
508
  $product->setVisibility(1); // not visible
509
- $product->setStatus(1); // status = enabled, other price shows as 0.00 in the order
510
  $product->setTaxClassId(0); # My default tax class
511
  $product->setStockData(array(
512
  'is_in_stock' => 1,
@@ -588,7 +676,7 @@ class Camiloo_Channelunity_Model_Orders extends Camiloo_Channelunity_Model_Abstr
588
  $ordStatus = $this->CUOrderStatusToMagentoStatus((string) $singleOrder->OrderStatus);
589
 
590
  try {
591
- $newOrder->setState($ordStatus /*, $ordStatus, 'Order updated from ChannelUnity', false */);
592
 
593
  }
594
  catch (Exception $x1) {
8
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
  */
10
  class Camiloo_Channelunity_Model_Orders extends Camiloo_Channelunity_Model_Abstract
11
+ {
 
12
  protected $_collection = 'sales/order';
13
 
 
 
14
  /*
15
 
16
  RequestType OrderStatusUpdate
111
  }
112
 
113
  public function doCreate($dataArray, $order) {
114
+ // this method takes an array of the normal structure and creates an
115
+ // order creation request within Magento.
 
 
116
 
117
  echo "<Info>Next order: {$order->OrderId} Create Quote</Info>";
118
+ Mage::register('cu_order_in_progress',1);
119
  try {
120
 
121
  $quote = Mage::getModel('sales/quote')->setStoreId((string) $dataArray->StoreviewId);
189
  $currencyObject = Mage::getModel('directory/currency');
190
  $reverseRate = $currencyObject->getResource()->getRate($storeCurrency, (string) $order->Currency);
191
 
192
+ if ($reverseRate == "") {
193
+ $reverseRate = 1.0;
194
+ }
195
+
196
  echo "<ConversionRate>$reverseRate</ConversionRate>";
197
+ $itemOptions = array();
198
 
199
  // add product(s)
200
  foreach ($order->OrderItems->Item as $orderitem) {
201
+ $product = Mage::getModel('catalog/product')->loadByAttribute(
202
+ (string) $dataArray->SkuAttribute,
203
+ (string) $orderitem->SKU);
204
+
205
+ // First check if this is a custom option
206
+ if (!is_object($product)) {
207
+ $skuparts = explode("-", (string) $orderitem->SKU);
208
+
209
+ if (count($skuparts) > 1) {
210
+ $parentsku = $skuparts[0];
211
+
212
+ $product = Mage::getModel('catalog/product')->loadByAttribute(
213
+ (string) $dataArray->SkuAttribute,
214
+ $parentsku);
215
+
216
+ for ($i = 1; $i < count($skuparts); $i++) {
217
+ $itemOptions[$parentsku][] = $skuparts[$i];
218
+ }
219
+ }
220
+ }
221
+ // ------------------------------------------------------
222
 
223
  if (is_object($product)) {
224
 
227
  $item = Mage::getModel('sales/quote_item');
228
  $item->setQuote($quote)->setProduct($product);
229
  $item->setData('qty', (string) $orderitem->Quantity);
230
+ $item->setCustomPrice((string) $orderitem->Price);
231
+ $item->setOriginalCustomPrice((string) $orderitem->Price);
232
+
233
  $quote->addItem($item);
234
  }
235
  else {
236
+ echo "<Info>Can't find SKU to add to quote ".((string) $orderitem->SKU)
237
+ .", trying to create stub</Info>";
238
 
239
  $prodIdToLoad = 0;
240
 
282
  $item = Mage::getModel('sales/quote_item');
283
  $item->setQuote($quote)->setProduct($product);
284
  $item->setData('qty', (string) $orderitem->Quantity);
285
+ $item->setCustomPrice((string) $orderitem->Price);
286
+ $item->setOriginalCustomPrice((string) $orderitem->Price);
287
  $quote->addItem($item);
288
  }
289
  else {
316
  'postcode' => $postcode,
317
  'region' => (string) $order->ShippingInfo->State,
318
  'region_id' => $regionId,
319
+ 'country_id' => (string) $order->ShippingInfo->Country,
320
+ 'should_ignore_validation' => true
321
  );
322
 
323
  // add the billing address to the quote.
324
  $billingAddress = $quote->getBillingAddress()->addData($billingAddressData);
325
+
326
+ echo "<Info>Set Shipping Address</Info>";
 
327
 
328
  // set the shipping address
329
  $shippingAddressData = array(
337
  'region' => (string) $order->ShippingInfo->State,
338
  'region_id' => $regionId,
339
  'country_id' => (string) $order->ShippingInfo->Country,
340
+ 'telephone' => (string) $order->ShippingInfo->PhoneNumber,
341
+ 'should_ignore_validation' => true
342
  );
343
 
344
  Mage::getSingleton('core/session')->setShippingPrice(((string) $order->ShippingInfo->ShippingPrice) / $reverseRate);
378
  $service = Mage::getModel('channelunity/ordercreatebackport', $quote);
379
  }
380
 
381
+ $currentstore = Mage::app()->getStore()->getId();
382
+ // upgrade to admin permissions to avoid item qty not available issue
383
+ Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
384
  $service->submitAll();
385
  $newOrder = $service->getOrder(); // returns full order object.
386
+ // we're done; sign out of admin permission
387
+ Mage::app()->setCurrentStore($currentstore);
388
 
389
  if (!is_object($newOrder)) {
390
  echo "<NotImported>".((string) $order->OrderId)."</NotImported>";
397
  } catch (Exception $x) {
398
  echo "<Exception><![CDATA[".$x->getMessage()." ".$x->getTraceAsString()."]]></Exception>";
399
  echo "<NotImported>".((string) $order->OrderId)."</NotImported>";
400
+ Mage::unregister('cu_order_in_progress');
401
  return;
402
  }
403
 
404
  $ordStatus = $this->CUOrderStatusToMagentoStatus((string) $order->OrderStatus);
405
 
406
  try {
407
+ $newOrder->setData('state', $ordStatus);
408
+ $newOrder->setStatus($ordStatus);
409
+ $history = $newOrder->addStatusHistoryComment(
410
+ 'Order imported from ChannelUnity', false);
411
+ $history->setIsCustomerNotified(false);
412
+
413
  }
414
  catch (Exception $x1) {
415
 
416
  try {
417
+ $newOrder->setState('closed', 'closed',
418
+ 'Order imported from ChannelUnity', false);
419
  }
420
  catch (Exception $x2) {
421
  }
422
  }
423
 
424
+ // This order will have been paid for, otherwise it won't
425
+ // have imported
426
 
427
  $invoiceId = Mage::getModel('sales/order_invoice_api')
428
  ->create($newOrder->getIncrementId(), array());
445
  $transaction->setOrder($newOrder);
446
  $transaction->setTxnType('capture');
447
  $transaction->setTxnId((string) $order->OrderId);
448
+ $transaction->setAdditionalInformation('SubscriptionId',
449
+ (string) $dataArray->SubscriptionId);
450
+ $transaction->setAdditionalInformation('RemoteOrderID',
451
+ (string) $order->OrderId);
452
+ $transaction->setAdditionalInformation('ShippingService',
453
+ (string) $order->ShippingInfo->Service);
454
 
455
  $serviceType = (string) $order->ServiceSku;
456
  switch ($serviceType) {
487
 
488
  $transaction->setAdditionalInformation('AmazonFBA', 'Yes');
489
  // Can't set 'complete' state manually - ideally import tracking info and create shipment in Mage
490
+
491
+
492
+ $newOrder->setData('state', 'complete');
493
+ $newOrder->setStatus('complete');
494
+ $history = $newOrder->addStatusHistoryComment('Order was fulfilled by Amazon', false);
495
+ $history->setIsCustomerNotified(false);
496
+
497
  }
498
  $transaction->save();
499
 
502
 
503
  $message = Mage::getModel('giftmessage/message');
504
 
 
 
 
505
  $message->setMessage($order->ShippingInfo->GiftMessage);
506
  $message->save();
507
 
511
  }
512
 
513
  $newOrder->setCreatedAt((string) $order->PurchaseDate);
514
+
515
+ //================ Add custom options where applicable ============
516
+ $allItems = $newOrder->getAllItems();
517
+ foreach ($allItems as $item) {
518
+ if (isset($itemOptions[$item->getSku()])) {
519
+ $optionsToAdd = $itemOptions[$item->getSku()];
520
+
521
+ $optionArray = array();
522
+
523
+ foreach ($optionsToAdd as $customSkuToAdd) {
524
+ $productTemp = Mage::getModel('catalog/product')->load($item->getProductId());
525
+
526
+ $tempOption = $productTemp->getOptions();
527
+ foreach ($tempOption as $option) {
528
+ $temp = $option->getData();
529
+
530
+ $values = $option->getValues();
531
+ if (count($values) > 0) {
532
+ foreach ($values as $value) {
533
+
534
+ if ($value["sku"] == $customSkuToAdd) {
535
+
536
+ echo "<Info>Add custom option: $customSkuToAdd</Info>";
537
+
538
+ $optionArray[count($optionArray)]
539
+ = array(
540
+ 'label' => $temp["default_title"],
541
+ 'value' => $value["title"],
542
+ 'print_value' => $value["title"],
543
+ 'option_type' => 'radio',
544
+ 'custom_view' => false,
545
+ 'option_id' => $temp["option_id"],
546
+ 'option_value' => $value->getId()
547
+ );
548
+ }
549
+
550
+ }
551
+ }
552
+ }
553
+
554
+
555
+ }
556
+
557
+ $item->setProductOptions(array('options' => $optionArray
558
+ ));
559
+
560
+ $item->save();
561
+ }
562
+ }
563
  $newOrder->save();
564
 
565
+ Mage::unregister('cu_order_in_progress');
566
  }
567
 
568
  private function createStubProduct($missingSku, $productTitle, $websiteID, $keyorder, $price, $qty, $skuAttribute) {
594
  // Default Magento attribute
595
  $product->setWeight('0.01');
596
  $product->setVisibility(1); // not visible
597
+ $product->setStatus(1); // status = enabled, otherwise price shows as 0.00 in the order
598
  $product->setTaxClassId(0); # My default tax class
599
  $product->setStockData(array(
600
  'is_in_stock' => 1,
676
  $ordStatus = $this->CUOrderStatusToMagentoStatus((string) $singleOrder->OrderStatus);
677
 
678
  try {
679
+ $newOrder->setData('state',$ordStatus);
680
 
681
  }
682
  catch (Exception $x1) {
app/code/community/Camiloo/Channelunity/Model/Products.php CHANGED
@@ -167,8 +167,12 @@
167
  }
168
  }
169
 
170
- public function generateCuXmlForSingleProduct($productId, $storeId) {
171
  $productXml = "";
 
 
 
 
172
 
173
  $product = Mage::getModel('catalog/product');
174
  $product->setStoreId($storeId)->load($productId);
@@ -180,7 +184,7 @@
180
  }
181
 
182
  $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product->getId());
183
- $qty = $stock->getData('qty');
184
 
185
  $catids = implode(',', $product->getCategoryIds());
186
  $categories = $product->getCategoryIds();
@@ -197,7 +201,7 @@
197
 
198
  $productXml = "<Product>\n";
199
  $productXml .= " <RemoteId>".$product->getId()."</RemoteId>\n";
200
- $productXml .= " <ProductType>".$attributeSetName."</ProductType>\n";
201
  $productXml .= " <Title><![CDATA[{$product->getData('name')} ]]></Title>\n";
202
  $productXml .= " <Description><![CDATA[{$product->getData('description')} ]]></Description>\n";
203
  $productXml .= " <SKU><![CDATA[{$product->getData('sku')}]]></SKU>\n";
@@ -257,6 +261,80 @@
257
  $productXml .= " <SKU><![CDATA[{$cp->getData('sku')}]]></SKU>\n";
258
  }
259
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
260
 
261
  $variationXml .= " </Variations>\n";
262
  $productXml .= " </RelatedSKUs>\n";
@@ -265,6 +343,82 @@
265
  $productXml .= " <Custom>\n";
266
 
267
  // Enumerate all other attribute values
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
268
 
269
  $attributeNames = array_keys($product->getData());
270
 
@@ -313,7 +467,11 @@
313
  else {
314
 
315
  if (!is_object($prodDataValue)) {
 
 
 
316
  $productXml .= " <$attr><![CDATA[".$prodDataValue."]]></$attr>\n";
 
317
  } else if ('Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Type_Configurable_Attribute_Collection'
318
  == get_class($prodDataValue)) {
319
  $productXml .= " <$attr><![CDATA[Mage_Core_Model_Mysql4_Collection_Abstract]]></$attr>\n";
@@ -321,12 +479,6 @@
321
  }
322
  }
323
  }
324
-
325
- $productXml .= " </Custom>\n";
326
- $productXml .= "</Product>\n";
327
-
328
- unset($product);
329
-
330
  return $productXml;
331
  }
332
 
@@ -426,7 +578,8 @@
426
  try {
427
 
428
  // get the highest product ID
429
- if (version_compare(Mage::getVersion(), "1.6.0.0", ">=")) {
 
430
  $collectionOfProduct = Mage::getModel('channelunity/collection')->addStoreFilter($storeId);
431
  }
432
  else {
@@ -438,7 +591,8 @@
438
  $totp = $collectionOfProduct->getFirstItem();
439
  $totp = $totp->getEntityId();
440
 
441
- if (version_compare(Mage::getVersion(), "1.6.0.0", ">=")) {
 
442
  $collectionOfProduct = Mage::getModel('channelunity/collection')->addStoreFilter($storeId);
443
  }
444
  else {
@@ -454,7 +608,7 @@
454
  $this->maxMemory = str_replace("M", "", $this->maxMemory);
455
  $this->maxMemory = $this->maxMemory * 1024 * 1024;
456
  } else if ($this->maxMemoryChar == "G") {
457
- $this->maxMemory = str_replace("G", "", $maxMemory);
458
  $this->maxMemory = $this->maxMemory * 1024 * 1024 * 1024;
459
  }
460
 
167
  }
168
  }
169
 
170
+ public function generateCuXmlForSingleProduct($productId, $storeId, $reduceStockBy = 0) {
171
  $productXml = "";
172
+ $bNeedCustomOptionProducts = false; // custom options needed?
173
+ $skuList = array(); // SKUs of the custom option child products
174
+ $customOptionAttrs = array();
175
+ $customOptionsData = array();
176
 
177
  $product = Mage::getModel('catalog/product');
178
  $product->setStoreId($storeId)->load($productId);
184
  }
185
 
186
  $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product->getId());
187
+ $qty = $stock->getData('qty') - $reduceStockBy;
188
 
189
  $catids = implode(',', $product->getCategoryIds());
190
  $categories = $product->getCategoryIds();
201
 
202
  $productXml = "<Product>\n";
203
  $productXml .= " <RemoteId>".$product->getId()."</RemoteId>\n";
204
+ $productXml .= " <ProductType><![CDATA[".$attributeSetName." ]]></ProductType>\n";
205
  $productXml .= " <Title><![CDATA[{$product->getData('name')} ]]></Title>\n";
206
  $productXml .= " <Description><![CDATA[{$product->getData('description')} ]]></Description>\n";
207
  $productXml .= " <SKU><![CDATA[{$product->getData('sku')}]]></SKU>\n";
261
  $productXml .= " <SKU><![CDATA[{$cp->getData('sku')}]]></SKU>\n";
262
  }
263
  }
264
+ else if ($product->getData('has_options') == 1) {
265
+ $bNeedCustomOptionProducts = true;
266
+
267
+ // Product has custom options
268
+
269
+ foreach ($product->getOptions() as $o) {
270
+ $optionType = $o->getType();
271
+
272
+ // Look at only drop down boxes or radio buttons
273
+
274
+ if (($optionType == 'drop_down' || $optionType == 'radio')
275
+ && $o->getData("is_require") == 1) {
276
+
277
+ $optTitle = $o->getData('title');
278
+ $optTitle = "custom_".ereg_replace("[^A-Za-z0-9_]", "", str_replace(" ", "_", $optTitle));
279
+
280
+ $customOptionsData[$optTitle] = array();
281
+
282
+ $variationXml .= " <Variation><![CDATA[{$optTitle}]]></Variation>\n";
283
+ $customOptionAttrs[] = $optTitle;
284
+
285
+ $values = $o->getValues();
286
+
287
+ if (count($skuList) == 0) {
288
+
289
+ foreach ($values as $k => $v) {
290
+
291
+ $skuList[] = $product->getData('sku')."-".$v->getData('sku');
292
+
293
+ $customOptionsData[count($customOptionAttrs)][$v->getData('sku')] = array();
294
+ $customOptionsData[count($customOptionAttrs)][$v->getData('sku')]["title"] = $v->getData('title');
295
+ $customOptionsData[count($customOptionAttrs)][$v->getData('sku')]["price"] = $v->getData('price');
296
+ $customOptionsData[count($customOptionAttrs)][$v->getData('sku')]["price_type"] = $v->getData('price_type');
297
+ }
298
+
299
+ }
300
+ else {
301
+ // Take a copy of the current SKU list
302
+ // append all the combinations
303
+
304
+ $tempSkuList = array();
305
+ foreach ($values as $k => $v) {
306
+
307
+ $tempSkuList[] = $v->getData('sku');
308
+
309
+ $customOptionsData[count($customOptionAttrs)][$v->getData('sku')] = array();
310
+ $customOptionsData[count($customOptionAttrs)][$v->getData('sku')]["title"] = $v->getData('title');
311
+ $customOptionsData[count($customOptionAttrs)][$v->getData('sku')]["price"] = $v->getData('price');
312
+ $customOptionsData[count($customOptionAttrs)][$v->getData('sku')]["price_type"] = $v->getData('price_type');
313
+ }
314
+
315
+ $newSkuList = array();
316
+
317
+ foreach ($skuList as $oldSku) {
318
+
319
+ foreach ($tempSkuList as $newSku) {
320
+
321
+ $newSkuList[] = $oldSku."-".$newSku;
322
+ }
323
+ }
324
+
325
+ $skuList = $newSkuList;
326
+ }
327
+
328
+ }
329
+ }
330
+
331
+ // Build up the SKU combinations for each combination of options
332
+ foreach ($skuList as $relsku) {
333
+
334
+ $productXml .= " <SKU><![CDATA[{$relsku}]]></SKU>\n";
335
+ }
336
+
337
+ }
338
 
339
  $variationXml .= " </Variations>\n";
340
  $productXml .= " </RelatedSKUs>\n";
343
  $productXml .= " <Custom>\n";
344
 
345
  // Enumerate all other attribute values
346
+ $productXml .= $this->enumerateCustomAttributesForProduct($product);
347
+
348
+ $productXml .= " </Custom>\n";
349
+ $productXml .= "</Product>\n";
350
+
351
+ // ============ Now generate product elements for all possible custom options ============
352
+ $idIncrement = 1000000;
353
+
354
+ if ($bNeedCustomOptionProducts) {
355
+
356
+ foreach ($skuList as $customSku) {
357
+
358
+ $skuParts = explode("-", str_replace($product->getData('sku'), "temp", $customSku));
359
+
360
+ $productXml .= "<Product>\n";
361
+ $productXml .= " <RemoteId>".(($idIncrement++) + $product->getId())."</RemoteId>\n";
362
+ $productXml .= " <ProductType><![CDATA[".$attributeSetName." ]]></ProductType>\n";
363
+ $productXml .= " <Title><![CDATA[{$product->getData('name')} ]]></Title>\n";
364
+ $productXml .= " <Description><![CDATA[{$product->getData('description')} ]]></Description>\n";
365
+ $productXml .= " <SKU><![CDATA[{$customSku}]]></SKU>\n";
366
+ $productXml .= " <Quantity>{$qty}</Quantity>\n";
367
+ $productXml .= " <Category>{$catids}</Category>\n";
368
+ $productXml .= " <CategoryName><![CDATA[{$catnames} ]]></CategoryName>\n";
369
+ $productXml .= " <Image><![CDATA[{$imageUrl}]]></Image>\n";
370
+ $productXml .= " <RelatedSKUs> </RelatedSKUs> <Variations> </Variations>\n";
371
+ $productXml .= " <Custom>\n";
372
+
373
+ // Enumerate all other attribute values
374
+ $productXml .= $this->enumerateCustomAttributesForProduct($product);
375
+
376
+ $basePrice = $product->getData('price');
377
+ $extraPrice = 0.00;
378
+
379
+ $indexTemp = 1;
380
+ for ( ; $indexTemp < count($skuParts); ) {
381
+ $part = $skuParts[$indexTemp];
382
+
383
+ $keycust = $customOptionAttrs[$indexTemp-1];
384
+
385
+ $custValue = $customOptionsData[$indexTemp][$part]['title'];
386
+
387
+ $priceExtra = $customOptionsData[$indexTemp][$part]['price'];
388
+ $priceType = $customOptionsData[$indexTemp][$part]['price_type'];
389
+
390
+ if ($priceType == "fixed") {
391
+
392
+ $extraPrice += (double)$priceExtra;
393
+ }
394
+ else if ($priceType == "percent") {
395
+
396
+ $extraPrice += $basePrice * (100.0 + $priceExtra)/100.0;
397
+ }
398
+
399
+ $productXml .= " <$keycust><![CDATA[".$custValue."]]></$keycust>\n";
400
+
401
+ $indexTemp++;
402
+ }
403
+
404
+ $basePrice += $extraPrice; // custom options have prices attached
405
+
406
+ $productXml .= " </Custom>\n";
407
+
408
+
409
+ $productXml .= " <Price>$basePrice</Price>\n";
410
+
411
+ $productXml .= "</Product>\n";
412
+ }
413
+ }
414
+ // =======================================================================================
415
+ unset($product);
416
+
417
+ return $productXml;
418
+ }
419
+
420
+ public function enumerateCustomAttributesForProduct($product) {
421
+ $productXml = "";
422
 
423
  $attributeNames = array_keys($product->getData());
424
 
467
  else {
468
 
469
  if (!is_object($prodDataValue)) {
470
+
471
+ $prodDataValue = str_replace("<![CDATA[", "", $prodDataValue);
472
+ $prodDataValue = str_replace("]]>", "", $prodDataValue);
473
  $productXml .= " <$attr><![CDATA[".$prodDataValue."]]></$attr>\n";
474
+
475
  } else if ('Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Type_Configurable_Attribute_Collection'
476
  == get_class($prodDataValue)) {
477
  $productXml .= " <$attr><![CDATA[Mage_Core_Model_Mysql4_Collection_Abstract]]></$attr>\n";
479
  }
480
  }
481
  }
 
 
 
 
 
 
482
  return $productXml;
483
  }
484
 
578
  try {
579
 
580
  // get the highest product ID
581
+ if (version_compare(Mage::getVersion(), "1.6.0.0", ">=")
582
+ && class_exists("Mage_Catalog_Model_Resource_Product_Collection")) {
583
  $collectionOfProduct = Mage::getModel('channelunity/collection')->addStoreFilter($storeId);
584
  }
585
  else {
591
  $totp = $collectionOfProduct->getFirstItem();
592
  $totp = $totp->getEntityId();
593
 
594
+ if (version_compare(Mage::getVersion(), "1.6.0.0", ">=")
595
+ && class_exists("Mage_Catalog_Model_Resource_Product_Collection")) {
596
  $collectionOfProduct = Mage::getModel('channelunity/collection')->addStoreFilter($storeId);
597
  }
598
  else {
608
  $this->maxMemory = str_replace("M", "", $this->maxMemory);
609
  $this->maxMemory = $this->maxMemory * 1024 * 1024;
610
  } else if ($this->maxMemoryChar == "G") {
611
+ $this->maxMemory = str_replace("G", "", $this->maxMemory);
612
  $this->maxMemory = $this->maxMemory * 1024 * 1024 * 1024;
613
  }
614
 
app/code/community/Camiloo/Channelunity/controllers/ApiController.php CHANGED
@@ -31,8 +31,8 @@ class Camiloo_Channelunity_ApiController extends Mage_Core_Controller_Front_Acti
31
  <?xml version="1.0" encoding="utf-8" ?><ChannelUnity><Notification><ID>1334834111876</ID><Timestamp>Thu Apr 19 12:15:11 BST 2012</Timestamp><Type>OrderNotification</Type><Payload><MerchantName>marktest</MerchantName><SourceId>10</SourceId><FriendlyName>English</FriendlyName><URL>http://__.camiloo.co.uk/channelunity/api/index</URL><MainCountry>United Kingdom</MainCountry><FrameworkType>Magento</FrameworkType><WebsiteId>1</WebsiteId><StoreId>1</StoreId><StoreviewId>1</StoreviewId><SubscriptionId>304</SubscriptionId><SkuAttribute>sku</SkuAttribute><Orders>
32
  <Order>
33
  <ServiceSku>CU_AMZ_UK</ServiceSku>
34
- <OrderId>202-8888888-0277161</OrderId>
35
- <PurchaseDate>2012-04-10T01:33:10+00:00</PurchaseDate>
36
  <Currency>GBP</Currency>
37
  <OrderFlags></OrderFlags>
38
  <OrderStatus>Processing</OrderStatus>
@@ -44,9 +44,9 @@ class Camiloo_Channelunity_ApiController extends Mage_Core_Controller_Front_Acti
44
  <Address2><![CDATA[]]></Address2>
45
  <Address3><![CDATA[]]></Address3>
46
  <City><![CDATA[Manchester]]></City>
47
- <State>none</State>
48
  <PostalCode>M1 1AA</PostalCode>
49
- <Country><![CDATA[UK]]></Country>
50
  <PhoneNumber><![CDATA[01981 239329]]></PhoneNumber>
51
  <ShippingPrice>2.00</ShippingPrice>
52
  <ShippingTax>0.00</ShippingTax>
31
  <?xml version="1.0" encoding="utf-8" ?><ChannelUnity><Notification><ID>1334834111876</ID><Timestamp>Thu Apr 19 12:15:11 BST 2012</Timestamp><Type>OrderNotification</Type><Payload><MerchantName>marktest</MerchantName><SourceId>10</SourceId><FriendlyName>English</FriendlyName><URL>http://__.camiloo.co.uk/channelunity/api/index</URL><MainCountry>United Kingdom</MainCountry><FrameworkType>Magento</FrameworkType><WebsiteId>1</WebsiteId><StoreId>1</StoreId><StoreviewId>1</StoreviewId><SubscriptionId>304</SubscriptionId><SkuAttribute>sku</SkuAttribute><Orders>
32
  <Order>
33
  <ServiceSku>CU_AMZ_UK</ServiceSku>
34
+ <OrderId>228-8888888-0277162</OrderId>
35
+ <PurchaseDate>2012-06-10T01:33:10+00:00</PurchaseDate>
36
  <Currency>GBP</Currency>
37
  <OrderFlags></OrderFlags>
38
  <OrderStatus>Processing</OrderStatus>
44
  <Address2><![CDATA[]]></Address2>
45
  <Address3><![CDATA[]]></Address3>
46
  <City><![CDATA[Manchester]]></City>
47
+ <State>Greater Manchester</State>
48
  <PostalCode>M1 1AA</PostalCode>
49
+ <Country><![CDATA[GB]]></Country>
50
  <PhoneNumber><![CDATA[01981 239329]]></PhoneNumber>
51
  <ShippingPrice>2.00</ShippingPrice>
52
  <ShippingTax>0.00</ShippingTax>
app/code/community/Camiloo/Channelunity/etc/config.xml CHANGED
@@ -219,12 +219,23 @@
219
  </channelunity>
220
  </observers>
221
  </catalog_controller_category_delete>
 
 
 
 
 
 
 
 
 
222
  </events>
223
  </global>
224
  <default>
225
  <carriers>
226
  <channelunitycustomrate>
227
- <active>0</active>
 
 
228
  <model>channelunity/customrate</model>
229
  <title>ChannelUnity Shipping</title>
230
  <name>ChannelUnity Rate</name>
219
  </channelunity>
220
  </observers>
221
  </catalog_controller_category_delete>
222
+ <core_config_data_save_after>
223
+ <observers>
224
+ <channelunity>
225
+ <type>model</type>
226
+ <class>channelunity/observer</class>
227
+ <method>configSaveAfter</method>
228
+ </channelunity>
229
+ </observers>
230
+ </core_config_data_save_after>
231
  </events>
232
  </global>
233
  <default>
234
  <carriers>
235
  <channelunitycustomrate>
236
+ <active>1</active>
237
+ <show_on_frontend>0</show_on_frontend>
238
+ <show_on_backend>0</show_on_backend>
239
  <model>channelunity/customrate</model>
240
  <title>ChannelUnity Shipping</title>
241
  <name>ChannelUnity Rate</name>
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.5");
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.8");
20
  $html = $xml->DisplayMessage[0];
21
  echo $html;
22
  ?>
package.xml CHANGED
@@ -1,21 +1,21 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Camiloo_Channelunity</name>
4
- <version>1.0.0.7</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.camiloo.co.uk/license.txt">Camiloo EULA</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>Camiloo ChannelUnity Integration for Magento.</summary>
10
  <description>This module allows Magento to connect to your account on channelunity.com
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
- Resolves an issue where orders already cancelled on the marketplace not already imported into Magento were duplicated.</notes>
15
  <authors><author><name>Camiloo Limited</name><user>auto-converted</user><email>hello@camiloo.co.uk</email></author></authors>
16
- <date>2012-06-04</date>
17
- <time>14:07:11</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="943b579d8dd91f2afc813fdf011e7351"/><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="6cc9052f6dd80e9460bc40d208fb5779"/><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="857d7d23882394c33f96e14dece757c2"/></dir><dir name="Model"><file name="Abstract.php" hash="de4075b91bbb176c807ad12061789774"/><file name="Attributes.php" hash="054b33cadc22acda31056e5b4cb8ff56"/><file name="Categories.php" hash="fd3806b220fd579b00bc5ab5fd464170"/><file name="Checkforupdates.php" hash="e2675f59cc61e54ad1a20f76865ce653"/><file name="Collection.php" hash="2fee7c15f58053c7b8fc9a2c011b97ac"/><file name="Customrate.php" hash="f388bd243823436828c1bb214b3f81be"/><file name="Entity.php" hash="0032a6c24cb75beb2ae073a56c2a1564"/><file name="Observer.php" hash="f734886fbecb301e766eeeeb8e95f2f3"/><file name="Ordercreatebackport.php" hash="3b696fb97ce6550a967d76436a3d131c"/><file name="Orders.php" hash="4e183704166647a0effbe41d40ed12f4"/><file name="Payment.php" hash="7fe570cf0aaf7c2bcdf1982b6e69caa6"/><file name="Paymentinfo.php" hash="e11658c9fa02420557441f5c8a41f8a0"/><file name="Paymentmethoduk.php" hash="a99409ed4ee5f7e426df4eaf793482d6"/><file name="Products.php" hash="2b707afa872a220afb3d5c1560af7743"/><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>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Camiloo_Channelunity</name>
4
+ <version>1.0.0.8</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.camiloo.co.uk/license.txt">Camiloo EULA</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>ChannelUnity Integration for Magento.</summary>
10
  <description>This module allows Magento to connect to your account on channelunity.com
11
 
12
+ Should you need any help getting started, please email support@channelunity.com</description>
13
  <notes>The ChannelUnity connector kit for Magento.
14
+ Allows products with custom options to be uploaded to ChannelUnity. Prevents order import validation errors.</notes>
15
  <authors><author><name>Camiloo Limited</name><user>auto-converted</user><email>hello@camiloo.co.uk</email></author></authors>
16
+ <date>2012-07-02</date>
17
+ <time>22:09:39</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="df298d12a6d69f6acdd974742cf91957"/><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="3148140b7866c820607b6b08c4ce8a99"/><file name="ApiController.php.old.php" hash="01ff34c2cf5798a82cfc11b19ab6decd"/></dir><dir name="etc"><file name="config.xml" hash="972a911499e3fb5feb873c2164d409c4"/><file name="system.xml" hash="b43f861f8ab3dadca3c122be10790609"/></dir><dir name="Helper"><file name="Data.php" hash="857d7d23882394c33f96e14dece757c2"/></dir><dir name="Model"><file name="Abstract.php" hash="9562198c4f35997f3cc81e35c35819f2"/><file name="Attributes.php" hash="054b33cadc22acda31056e5b4cb8ff56"/><file name="Categories.php" hash="fd3806b220fd579b00bc5ab5fd464170"/><file name="Checkforupdates.php" hash="e2675f59cc61e54ad1a20f76865ce653"/><file name="Collection.php" hash="707e40c83bfc057ab557b5fad21727e5"/><file name="Customrate.php" hash="f6e64e362fa36b3854d8dacfc3e677c2"/><file name="Entity.php" hash="0032a6c24cb75beb2ae073a56c2a1564"/><file name="Observer.php" hash="2d4c49738479b98889e39dc95d8d65e0"/><file name="Ordercreatebackport.php" hash="dd84aa8fc0c4b62022850bfa74bff37f"/><file name="Orders.php" hash="5fae119970401d888973f5afcd7344a4"/><file name="Payment.php" hash="7fe570cf0aaf7c2bcdf1982b6e69caa6"/><file name="Paymentinfo.php" hash="e11658c9fa02420557441f5c8a41f8a0"/><file name="Paymentmethoduk.php" hash="a99409ed4ee5f7e426df4eaf793482d6"/><file name="Products.php" hash="a0f15a0b178de8bafe09de02192b4fb8"/><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>