Version Notes
The ChannelUnity connector kit for Magento.
Allows automatic installation via www.channelunity.com. Fixes an issue related to flat product tables support.
Download this release
Release Info
Developer | Magento Core Team |
Extension | Camiloo_Channelunity |
Version | 1.0.0.11 |
Comparing to | |
See all releases |
Code changes from version 1.0.0.10 to 1.0.0.11
- app/code/community/Camiloo/Channelunity/Model/Abstract.php +97 -9
- app/code/community/Camiloo/Channelunity/Model/Observer.php +39 -23
- app/code/community/Camiloo/Channelunity/Model/Orders.php +83 -42
- app/code/community/Camiloo/Channelunity/Model/Products.php +89 -14
- app/code/community/Camiloo/Channelunity/controllers/ApiController.php +89 -45
- app/code/community/Camiloo/Channelunity/etc/config.xml +8 -0
- app/code/community/Camiloo/Channelunity/etc/system.xml +9 -0
- app/design/adminhtml/default/default/template/channelunity/configheader.phtml +1 -1
- package.xml +5 -5
app/code/community/Camiloo/Channelunity/Model/Abstract.php
CHANGED
@@ -178,16 +178,33 @@ class Camiloo_Channelunity_Model_Abstract
|
|
178 |
return Mage::getStoreConfig('channelunityint/generalsettings/merchantname');
|
179 |
}
|
180 |
|
181 |
-
|
|
|
|
|
|
|
182 |
{
|
183 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
. ":" . hash("sha256", Mage::getStoreConfig('channelunityint/generalsettings/merchantpassword'));
|
185 |
|
186 |
-
|
187 |
-
|
|
|
|
|
188 |
}
|
189 |
|
190 |
-
|
|
|
|
|
|
|
191 |
{
|
192 |
$apikeyTemp = Mage::getStoreConfig('channelunityint/generalsettings/apikey');
|
193 |
|
@@ -197,12 +214,23 @@ class Camiloo_Channelunity_Model_Abstract
|
|
197 |
|
198 |
$session = curl_init();
|
199 |
|
200 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
201 |
<ChannelUnity>
|
202 |
<MerchantName>" . $this->getMerchantName() . "</MerchantName>
|
203 |
<Authorization>" . $this->getValidUserAuth() . "</Authorization>
|
204 |
<RequestType>ValidateUser</RequestType>
|
205 |
</ChannelUnity>";
|
|
|
206 |
|
207 |
$xml = urlencode($xml);
|
208 |
|
@@ -219,7 +247,7 @@ class Camiloo_Channelunity_Model_Abstract
|
|
219 |
|
220 |
if (isset($xml->ApiKey)) {
|
221 |
Mage::getModel('core/config')->saveConfig(
|
222 |
-
|
223 |
|
224 |
return $xml->ApiKey;
|
225 |
}
|
@@ -228,9 +256,23 @@ class Camiloo_Channelunity_Model_Abstract
|
|
228 |
return "";
|
229 |
}
|
230 |
|
231 |
-
public function
|
232 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
233 |
|
|
|
|
|
234 |
$session = curl_init();
|
235 |
|
236 |
$xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>
|
@@ -242,6 +284,8 @@ class Camiloo_Channelunity_Model_Abstract
|
|
242 |
<Payload>$xml</Payload>
|
243 |
</ChannelUnity>";
|
244 |
|
|
|
|
|
245 |
$xml = urlencode($xml);
|
246 |
|
247 |
curl_setopt($session, CURLOPT_URL, $this->getEndpoint());
|
@@ -253,12 +297,13 @@ class Camiloo_Channelunity_Model_Abstract
|
|
253 |
|
254 |
curl_close($session);
|
255 |
|
|
|
|
|
256 |
return $result;
|
257 |
}
|
258 |
|
259 |
public function postMyURLToChannelUnity($merchantName)
|
260 |
{
|
261 |
-
|
262 |
$session = curl_init();
|
263 |
|
264 |
$baseurl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
@@ -331,4 +376,47 @@ class Camiloo_Channelunity_Model_Abstract
|
|
331 |
return $ignoreDisabled;
|
332 |
}
|
333 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
334 |
}
|
178 |
return Mage::getStoreConfig('channelunityint/generalsettings/merchantname');
|
179 |
}
|
180 |
|
181 |
+
/**
|
182 |
+
* Returns a Base64 encoded user authentication string.
|
183 |
+
*/
|
184 |
+
public function getValidUserAuth($user = null, $pass = null)
|
185 |
{
|
186 |
+
if ($user != null) {
|
187 |
+
$auth = $user . ":" . hash("sha256", $pass);
|
188 |
+
|
189 |
+
$auth = base64_encode($auth);
|
190 |
+
return $auth;
|
191 |
+
|
192 |
+
}
|
193 |
+
else {
|
194 |
+
|
195 |
+
$auth = Mage::getStoreConfig('channelunityint/generalsettings/merchantusername')
|
196 |
. ":" . hash("sha256", Mage::getStoreConfig('channelunityint/generalsettings/merchantpassword'));
|
197 |
|
198 |
+
$auth = base64_encode($auth);
|
199 |
+
return $auth;
|
200 |
+
|
201 |
+
}
|
202 |
}
|
203 |
|
204 |
+
/**
|
205 |
+
* Returns the CU API Key, calling to CU server if needed to retrieve it.
|
206 |
+
*/
|
207 |
+
public function getApiKey($merchantname = null, $username = null, $password = null)
|
208 |
{
|
209 |
$apikeyTemp = Mage::getStoreConfig('channelunityint/generalsettings/apikey');
|
210 |
|
214 |
|
215 |
$session = curl_init();
|
216 |
|
217 |
+
if ($merchantname != null) {
|
218 |
+
$xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>
|
219 |
+
<ChannelUnity>
|
220 |
+
<MerchantName>" . $merchantname . "</MerchantName>
|
221 |
+
<Authorization>" . $this->getValidUserAuth($username, $password) . "</Authorization>
|
222 |
+
<RequestType>ValidateUser</RequestType>
|
223 |
+
</ChannelUnity>";
|
224 |
+
}
|
225 |
+
else {
|
226 |
+
|
227 |
+
$xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>
|
228 |
<ChannelUnity>
|
229 |
<MerchantName>" . $this->getMerchantName() . "</MerchantName>
|
230 |
<Authorization>" . $this->getValidUserAuth() . "</Authorization>
|
231 |
<RequestType>ValidateUser</RequestType>
|
232 |
</ChannelUnity>";
|
233 |
+
}
|
234 |
|
235 |
$xml = urlencode($xml);
|
236 |
|
247 |
|
248 |
if (isset($xml->ApiKey)) {
|
249 |
Mage::getModel('core/config')->saveConfig(
|
250 |
+
'channelunityint/generalsettings/apikey', $xml->ApiKey);
|
251 |
|
252 |
return $xml->ApiKey;
|
253 |
}
|
256 |
return "";
|
257 |
}
|
258 |
|
259 |
+
public function setCredentialsInModule($merchantname, $username, $password)
|
260 |
{
|
261 |
+
Mage::getModel('core/config')->saveConfig(
|
262 |
+
'channelunityint/generalsettings/merchantname', $merchantname);
|
263 |
+
Mage::getModel('core/config')->saveConfig(
|
264 |
+
'channelunityint/generalsettings/merchantusername', $username);
|
265 |
+
Mage::getModel('core/config')->saveConfig(
|
266 |
+
'channelunityint/generalsettings/merchantpassword', $password);
|
267 |
+
Mage::getModel('core/config')->saveConfig(
|
268 |
+
'channelunityint/generalsettings/apikey', '');
|
269 |
+
|
270 |
+
$this->getApiKey($merchantname, $username, $password);
|
271 |
+
$this->postMyURLToChannelUnity($merchantname);
|
272 |
+
}
|
273 |
|
274 |
+
public function postToChannelUnity($xml, $requestType)
|
275 |
+
{
|
276 |
$session = curl_init();
|
277 |
|
278 |
$xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>
|
284 |
<Payload>$xml</Payload>
|
285 |
</ChannelUnity>";
|
286 |
|
287 |
+
Mage::log('TX '.$xml);
|
288 |
+
|
289 |
$xml = urlencode($xml);
|
290 |
|
291 |
curl_setopt($session, CURLOPT_URL, $this->getEndpoint());
|
297 |
|
298 |
curl_close($session);
|
299 |
|
300 |
+
Mage::log('RX '.$result);
|
301 |
+
|
302 |
return $result;
|
303 |
}
|
304 |
|
305 |
public function postMyURLToChannelUnity($merchantName)
|
306 |
{
|
|
|
307 |
$session = curl_init();
|
308 |
|
309 |
$baseurl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
376 |
return $ignoreDisabled;
|
377 |
}
|
378 |
|
379 |
+
/**
|
380 |
+
* @return array
|
381 |
+
*/
|
382 |
+
public function getProductsToUpdate()
|
383 |
+
{
|
384 |
+
$products = array();
|
385 |
+
$configValue = Mage::getStoreConfig('channelunityint/cron/productstoupdate');
|
386 |
+
|
387 |
+
if($configValue) {
|
388 |
+
$products = (array) json_decode($configValue);
|
389 |
+
}
|
390 |
+
|
391 |
+
return $products;
|
392 |
+
}
|
393 |
+
|
394 |
+
/**
|
395 |
+
* @param null $products
|
396 |
+
*/
|
397 |
+
public function setProductsToUpdate($products = null)
|
398 |
+
{
|
399 |
+
$configValue = json_encode($products);
|
400 |
+
Mage::getModel('core/config')->saveConfig('channelunityint/cron/productstoupdate', $configValue);
|
401 |
+
}
|
402 |
+
|
403 |
+
/**
|
404 |
+
*
|
405 |
+
*/
|
406 |
+
protected function updateProductData($storeViewId, $data)
|
407 |
+
{
|
408 |
+
// Set variables
|
409 |
+
$sourceUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
410 |
+
|
411 |
+
// Create XML
|
412 |
+
$xml = <<<XML
|
413 |
+
<Products>
|
414 |
+
<SourceURL>{$sourceUrl}</SourceURL>
|
415 |
+
<StoreViewId>{$storeViewId}</StoreViewId>
|
416 |
+
{$data}
|
417 |
+
</Products>
|
418 |
+
XML;
|
419 |
+
// Send XML to CU
|
420 |
+
return $this->postToChannelUnity($xml, 'ProductData');
|
421 |
+
}
|
422 |
}
|
app/code/community/Camiloo/Channelunity/Model/Observer.php
CHANGED
@@ -410,15 +410,22 @@ XML;
|
|
410 |
private function _updateOrderProducts($order)
|
411 |
{
|
412 |
try {
|
413 |
-
|
414 |
// Set variables
|
415 |
$items = $order->getAllItems();
|
416 |
$storeViewId = $order->getStore()->getId();
|
417 |
$data = '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
418 |
|
419 |
// Loop through items
|
420 |
-
foreach ($items as $item)
|
421 |
-
|
422 |
// Load product
|
423 |
$product = Mage::getModel('catalog/product')
|
424 |
->loadByAttribute('sku', $item->getSku());
|
@@ -426,15 +433,36 @@ XML;
|
|
426 |
continue;
|
427 |
}
|
428 |
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
434 |
}
|
435 |
|
436 |
-
|
437 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
438 |
} catch (Exception $e) {
|
439 |
Mage::logException($e);
|
440 |
}
|
@@ -442,19 +470,7 @@ XML;
|
|
442 |
|
443 |
private function _updateProductData($storeViewId, $data)
|
444 |
{
|
445 |
-
|
446 |
-
$sourceUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
447 |
-
|
448 |
-
// Create XML
|
449 |
-
$xml = <<<XML
|
450 |
-
<Products>
|
451 |
-
<SourceURL>{$sourceUrl}</SourceURL>
|
452 |
-
<StoreViewId>{$storeViewId}</StoreViewId>
|
453 |
-
{$data}
|
454 |
-
</Products>
|
455 |
-
XML;
|
456 |
-
// Send XML to CU
|
457 |
-
return $this->postToChannelUnity($xml, 'ProductData');
|
458 |
}
|
459 |
|
460 |
}
|
410 |
private function _updateOrderProducts($order)
|
411 |
{
|
412 |
try {
|
|
|
413 |
// Set variables
|
414 |
$items = $order->getAllItems();
|
415 |
$storeViewId = $order->getStore()->getId();
|
416 |
$data = '';
|
417 |
+
|
418 |
+
$productsToUpdate = array();
|
419 |
+
|
420 |
+
$updateStockOnCron = Mage::getStoreConfig('channelunityint/cron/updatestockoncron');
|
421 |
+
|
422 |
+
if($updateStockOnCron == 1) {
|
423 |
+
$productsToUpdate = $this->getProductsToUpdate();
|
424 |
+
}
|
425 |
|
426 |
// Loop through items
|
427 |
+
foreach ($items as $item)
|
428 |
+
{
|
429 |
// Load product
|
430 |
$product = Mage::getModel('catalog/product')
|
431 |
->loadByAttribute('sku', $item->getSku());
|
433 |
continue;
|
434 |
}
|
435 |
|
436 |
+
if($updateStockOnCron == 1)
|
437 |
+
{
|
438 |
+
if(isset($productsToUpdate[$storeViewId])) {
|
439 |
+
if(!in_array($product->getId(), $productsToUpdate)) {
|
440 |
+
$productsToUpdate[$storeViewId][] = $product->getId();
|
441 |
+
}
|
442 |
+
} else {
|
443 |
+
$productsToUpdate[$storeViewId][] = $product->getId();
|
444 |
+
}
|
445 |
+
}
|
446 |
+
else
|
447 |
+
{
|
448 |
+
// Add XML
|
449 |
+
$data .= Mage::getModel('channelunity/products')
|
450 |
+
->generateCuXmlForSingleProduct(
|
451 |
+
$product->getId(), $storeViewId, 0
|
452 |
+
);
|
453 |
+
}
|
454 |
+
|
455 |
}
|
456 |
|
457 |
+
if($updateStockOnCron == 1)
|
458 |
+
{
|
459 |
+
$this->setProductsToUpdate($productsToUpdate);
|
460 |
+
}
|
461 |
+
else
|
462 |
+
{
|
463 |
+
// Send to CU
|
464 |
+
$this->_updateProductData($storeViewId, $data);
|
465 |
+
}
|
466 |
} catch (Exception $e) {
|
467 |
Mage::logException($e);
|
468 |
}
|
470 |
|
471 |
private function _updateProductData($storeViewId, $data)
|
472 |
{
|
473 |
+
return $this->updateProductData($storeViewId, $data);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
474 |
}
|
475 |
|
476 |
}
|
app/code/community/Camiloo/Channelunity/Model/Orders.php
CHANGED
@@ -12,6 +12,7 @@ class Camiloo_Channelunity_Model_Orders extends Camiloo_Channelunity_Model_Abstr
|
|
12 |
{
|
13 |
|
14 |
protected $_collection = 'sales/order';
|
|
|
15 |
|
16 |
/*
|
17 |
|
@@ -84,7 +85,6 @@ class Camiloo_Channelunity_Model_Orders extends Camiloo_Channelunity_Model_Abstr
|
|
84 |
|
85 |
public function generateCuXmlForOrderShip($order, $carrierName, $shipMethod, $trackNumber)
|
86 |
{
|
87 |
-
|
88 |
$orderXml = $this->generateCuXmlForOrderStatus($order);
|
89 |
|
90 |
if (!empty($orderXml)) {
|
@@ -113,6 +113,51 @@ class Camiloo_Channelunity_Model_Orders extends Camiloo_Channelunity_Model_Abstr
|
|
113 |
return $in_str;
|
114 |
}
|
115 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
public function doCreate($dataArray, $order)
|
117 |
{
|
118 |
// this method takes an array of the normal structure and creates an
|
@@ -127,10 +172,8 @@ class Camiloo_Channelunity_Model_Orders extends Camiloo_Channelunity_Model_Abstr
|
|
127 |
// we need to verify (from our XML) that we can create customer accounts
|
128 |
// and that we can contact the customer.
|
129 |
|
130 |
-
|
131 |
echo "<Info>Create Customer</Info>";
|
132 |
|
133 |
-
|
134 |
$customer = Mage::getModel('customer/customer')
|
135 |
->setWebsiteId((string) $dataArray->WebsiteId)
|
136 |
->loadByEmail((string) $order->BillingInfo->Email);
|
@@ -330,7 +373,7 @@ class Camiloo_Channelunity_Model_Orders extends Camiloo_Channelunity_Model_Abstr
|
|
330 |
}
|
331 |
|
332 |
Mage::getSingleton('core/session')->setShippingPrice(
|
333 |
-
$this->getDeTaxPrice((
|
334 |
|
335 |
// add the shipping address to the quote.
|
336 |
$shippingAddress = $quote->getShippingAddress()->addData($shippingAddressData);
|
@@ -359,13 +402,13 @@ class Camiloo_Channelunity_Model_Orders extends Camiloo_Channelunity_Model_Abstr
|
|
359 |
|
360 |
if (is_object($product)) {
|
361 |
|
362 |
-
$product->setPrice($this->getDeTaxPrice((
|
363 |
|
364 |
$item = Mage::getModel('sales/quote_item');
|
365 |
$item->setQuote($quote)->setProduct($product);
|
366 |
$item->setData('qty', (string) $orderitem->Quantity);
|
367 |
-
$item->setCustomPrice($this->getDeTaxPrice((
|
368 |
-
$item->setOriginalCustomPrice($this->getDeTaxPrice((
|
369 |
// $item->setQtyInvoiced((string) $orderitem->Quantity);
|
370 |
|
371 |
$quote->addItem($item);
|
@@ -409,13 +452,13 @@ class Camiloo_Channelunity_Model_Orders extends Camiloo_Channelunity_Model_Abstr
|
|
409 |
|
410 |
if (is_object($product)) {
|
411 |
|
412 |
-
$product->setPrice($this->getDeTaxPrice((
|
413 |
|
414 |
$item = Mage::getModel('sales/quote_item');
|
415 |
$item->setQuote($quote)->setProduct($product);
|
416 |
$item->setData('qty', (string) $orderitem->Quantity);
|
417 |
-
$item->setCustomPrice($this->getDeTaxPrice((
|
418 |
-
$item->setOriginalCustomPrice($this->getDeTaxPrice((
|
419 |
// $item->setQtyInvoiced((string) $orderitem->Quantity);
|
420 |
$quote->addItem($item);
|
421 |
|
@@ -450,7 +493,15 @@ class Camiloo_Channelunity_Model_Orders extends Camiloo_Channelunity_Model_Abstr
|
|
450 |
$shippingAddress->setShippingMethod('channelunitycustomrate_channelunitycustomrate');
|
451 |
$shippingAddress->setShippingDescription((string) $order->ShippingInfo->Service);
|
452 |
$shippingAddress->setPaymentMethod('channelunitypayment');
|
453 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
454 |
$quote->getPayment()->importData(array(
|
455 |
'method' => 'channelunitypayment'
|
456 |
));
|
@@ -466,8 +517,10 @@ class Camiloo_Channelunity_Model_Orders extends Camiloo_Channelunity_Model_Abstr
|
|
466 |
// upgrade to admin permissions to avoid item qty not available issue
|
467 |
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
|
468 |
|
469 |
-
|
470 |
-
|
|
|
|
|
471 |
// we're done; sign out of admin permission
|
472 |
Mage::app()->setCurrentStore($currentstore);
|
473 |
|
@@ -536,32 +589,7 @@ class Camiloo_Channelunity_Model_Orders extends Camiloo_Channelunity_Model_Abstr
|
|
536 |
$transaction->setAdditionalInformation('ShippingService', (string) $order->ShippingInfo->Service);
|
537 |
|
538 |
$serviceType = (string) $order->ServiceSku;
|
539 |
-
|
540 |
-
case "CU_AMZ_UK":
|
541 |
-
$serviceType = "Amazon.co.uk";
|
542 |
-
break;
|
543 |
-
case "CU_AMZ_COM":
|
544 |
-
$serviceType = "Amazon.com";
|
545 |
-
break;
|
546 |
-
case "CU_AMZ_DE":
|
547 |
-
$serviceType = "Amazon.de";
|
548 |
-
break;
|
549 |
-
case "CU_AMZ_FR":
|
550 |
-
$serviceType = "Amazon.fr";
|
551 |
-
break;
|
552 |
-
case "CU_AMZ_CA":
|
553 |
-
$serviceType = "Amazon.ca";
|
554 |
-
break;
|
555 |
-
case "CU_AMZ_IT":
|
556 |
-
$serviceType = "Amazon.it";
|
557 |
-
break;
|
558 |
-
case "CU_AMZ_ES":
|
559 |
-
$serviceType = "Amazon.es";
|
560 |
-
break;
|
561 |
-
case "CU_AMZ_JP":
|
562 |
-
$serviceType = "Amazon.co.jp";
|
563 |
-
break;
|
564 |
-
}
|
565 |
|
566 |
$transaction->setAdditionalInformation('ServiceType', $serviceType);
|
567 |
|
@@ -571,7 +599,6 @@ class Camiloo_Channelunity_Model_Orders extends Camiloo_Channelunity_Model_Abstr
|
|
571 |
$transaction->setAdditionalInformation('AmazonFBA', 'Yes');
|
572 |
// Can't set 'complete' state manually - ideally import tracking info and create shipment in Mage
|
573 |
|
574 |
-
|
575 |
$newOrder->setData('state', 'complete');
|
576 |
$newOrder->setStatus('complete');
|
577 |
$history = $newOrder->addStatusHistoryComment('Order was fulfilled by Amazon', false);
|
@@ -812,9 +839,11 @@ class Camiloo_Channelunity_Model_Orders extends Camiloo_Channelunity_Model_Abstr
|
|
812 |
return $rate;
|
813 |
}
|
814 |
|
815 |
-
public function getDeTaxPrice($price, $address = null)
|
816 |
{
|
817 |
$priceIncTax = Mage::getStoreConfig('channelunityint/generalsettings/priceinctax');
|
|
|
|
|
818 |
|
819 |
if ($priceIncTax == 1) {
|
820 |
return $price;
|
@@ -864,7 +893,7 @@ class Camiloo_Channelunity_Model_Orders extends Camiloo_Channelunity_Model_Abstr
|
|
864 |
|
865 |
try {
|
866 |
$transaction = Mage::getModel('sales/order_payment_transaction')
|
867 |
-
->loadByTxnId();
|
868 |
|
869 |
$newOrder = $transaction->getOrder();
|
870 |
if (is_object($newOrder)) {
|
@@ -887,6 +916,18 @@ class Camiloo_Channelunity_Model_Orders extends Camiloo_Channelunity_Model_Abstr
|
|
887 |
$bOrderExisted = true;
|
888 |
}
|
889 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
890 |
|
891 |
$table_prefix = Mage::getConfig()->getTablePrefix();
|
892 |
|
12 |
{
|
13 |
|
14 |
protected $_collection = 'sales/order';
|
15 |
+
protected $_setReservedOrderId = false; //set reserved order id as marketplace order number for quote
|
16 |
|
17 |
/*
|
18 |
|
85 |
|
86 |
public function generateCuXmlForOrderShip($order, $carrierName, $shipMethod, $trackNumber)
|
87 |
{
|
|
|
88 |
$orderXml = $this->generateCuXmlForOrderStatus($order);
|
89 |
|
90 |
if (!empty($orderXml)) {
|
113 |
return $in_str;
|
114 |
}
|
115 |
|
116 |
+
public function channelSkuToName($serviceType) {
|
117 |
+
switch ($serviceType) {
|
118 |
+
case "CU_AMZ_UK":
|
119 |
+
$serviceType = "Amazon.co.uk";
|
120 |
+
break;
|
121 |
+
case "CU_AMZ_COM":
|
122 |
+
$serviceType = "Amazon.com";
|
123 |
+
break;
|
124 |
+
case "CU_AMZ_DE":
|
125 |
+
$serviceType = "Amazon.de";
|
126 |
+
break;
|
127 |
+
case "CU_AMZ_FR":
|
128 |
+
$serviceType = "Amazon.fr";
|
129 |
+
break;
|
130 |
+
case "CU_AMZ_CA":
|
131 |
+
$serviceType = "Amazon.ca";
|
132 |
+
break;
|
133 |
+
case "CU_AMZ_IT":
|
134 |
+
$serviceType = "Amazon.it";
|
135 |
+
break;
|
136 |
+
case "CU_AMZ_ES":
|
137 |
+
$serviceType = "Amazon.es";
|
138 |
+
break;
|
139 |
+
case "CU_AMZ_JP":
|
140 |
+
$serviceType = "Amazon.co.jp";
|
141 |
+
break;
|
142 |
+
case "CU_AMZ_CN":
|
143 |
+
$serviceType = "Amazon.cn";
|
144 |
+
break;
|
145 |
+
case "CU_EBAY_UK":
|
146 |
+
$serviceType = "eBay UK";
|
147 |
+
break;
|
148 |
+
case "CU_EBAY_COM":
|
149 |
+
$serviceType = "eBay.com USA";
|
150 |
+
break;
|
151 |
+
case "CU_EBAY_DE":
|
152 |
+
$serviceType = "eBay Germany";
|
153 |
+
break;
|
154 |
+
case "CU_PLAY_COM":
|
155 |
+
$serviceType = "Play.com UK";
|
156 |
+
break;
|
157 |
+
}
|
158 |
+
return $serviceType;
|
159 |
+
}
|
160 |
+
|
161 |
public function doCreate($dataArray, $order)
|
162 |
{
|
163 |
// this method takes an array of the normal structure and creates an
|
172 |
// we need to verify (from our XML) that we can create customer accounts
|
173 |
// and that we can contact the customer.
|
174 |
|
|
|
175 |
echo "<Info>Create Customer</Info>";
|
176 |
|
|
|
177 |
$customer = Mage::getModel('customer/customer')
|
178 |
->setWebsiteId((string) $dataArray->WebsiteId)
|
179 |
->loadByEmail((string) $order->BillingInfo->Email);
|
373 |
}
|
374 |
|
375 |
Mage::getSingleton('core/session')->setShippingPrice(
|
376 |
+
$this->getDeTaxPrice((float) $order->ShippingInfo->ShippingPrice, (float) $order->ShippingInfo->ShippingTax) / $reverseRate );
|
377 |
|
378 |
// add the shipping address to the quote.
|
379 |
$shippingAddress = $quote->getShippingAddress()->addData($shippingAddressData);
|
402 |
|
403 |
if (is_object($product)) {
|
404 |
|
405 |
+
$product->setPrice($this->getDeTaxPrice((float) $orderitem->Price, (float) $orderitem->Tax, $shippingAddress) / $reverseRate);
|
406 |
|
407 |
$item = Mage::getModel('sales/quote_item');
|
408 |
$item->setQuote($quote)->setProduct($product);
|
409 |
$item->setData('qty', (string) $orderitem->Quantity);
|
410 |
+
$item->setCustomPrice($this->getDeTaxPrice((float) $orderitem->Price, (float) $orderitem->Tax, $shippingAddress));
|
411 |
+
$item->setOriginalCustomPrice($this->getDeTaxPrice((float) $orderitem->Price, (float) $orderitem->Tax, $shippingAddress));
|
412 |
// $item->setQtyInvoiced((string) $orderitem->Quantity);
|
413 |
|
414 |
$quote->addItem($item);
|
452 |
|
453 |
if (is_object($product)) {
|
454 |
|
455 |
+
$product->setPrice($this->getDeTaxPrice((float) $orderitem->Price, (float) $orderitem->Tax, $shippingAddress) / $reverseRate);
|
456 |
|
457 |
$item = Mage::getModel('sales/quote_item');
|
458 |
$item->setQuote($quote)->setProduct($product);
|
459 |
$item->setData('qty', (string) $orderitem->Quantity);
|
460 |
+
$item->setCustomPrice($this->getDeTaxPrice((float) $orderitem->Price, (float) $orderitem->Tax, $shippingAddress));
|
461 |
+
$item->setOriginalCustomPrice($this->getDeTaxPrice((float) $orderitem->Price, (float) $orderitem->Tax, $shippingAddress));
|
462 |
// $item->setQtyInvoiced((string) $orderitem->Quantity);
|
463 |
$quote->addItem($item);
|
464 |
|
493 |
$shippingAddress->setShippingMethod('channelunitycustomrate_channelunitycustomrate');
|
494 |
$shippingAddress->setShippingDescription((string) $order->ShippingInfo->Service);
|
495 |
$shippingAddress->setPaymentMethod('channelunitypayment');
|
496 |
+
|
497 |
+
if($this->_setReservedOrderId)
|
498 |
+
{
|
499 |
+
$quote->setReservedOrderId($order->OrderId);
|
500 |
+
// $quote->setOrigOrderId($order->OrderId);
|
501 |
+
// $quote->setRealOrderId($order->OrderId);
|
502 |
+
// $quote->setExtOrderId($order->OrderId);
|
503 |
+
}
|
504 |
+
|
505 |
$quote->getPayment()->importData(array(
|
506 |
'method' => 'channelunitypayment'
|
507 |
));
|
517 |
// upgrade to admin permissions to avoid item qty not available issue
|
518 |
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
|
519 |
|
520 |
+
$service->submitAll();
|
521 |
+
$newOrder = $service->getOrder(); // returns full order object.
|
522 |
+
// $newOrder = $service->submitOrder();
|
523 |
+
|
524 |
// we're done; sign out of admin permission
|
525 |
Mage::app()->setCurrentStore($currentstore);
|
526 |
|
589 |
$transaction->setAdditionalInformation('ShippingService', (string) $order->ShippingInfo->Service);
|
590 |
|
591 |
$serviceType = (string) $order->ServiceSku;
|
592 |
+
$serviceType = $this->channelSkuToName($serviceType);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
593 |
|
594 |
$transaction->setAdditionalInformation('ServiceType', $serviceType);
|
595 |
|
599 |
$transaction->setAdditionalInformation('AmazonFBA', 'Yes');
|
600 |
// Can't set 'complete' state manually - ideally import tracking info and create shipment in Mage
|
601 |
|
|
|
602 |
$newOrder->setData('state', 'complete');
|
603 |
$newOrder->setStatus('complete');
|
604 |
$history = $newOrder->addStatusHistoryComment('Order was fulfilled by Amazon', false);
|
839 |
return $rate;
|
840 |
}
|
841 |
|
842 |
+
public function getDeTaxPrice($price, $tax = 0, $address = null)
|
843 |
{
|
844 |
$priceIncTax = Mage::getStoreConfig('channelunityint/generalsettings/priceinctax');
|
845 |
+
|
846 |
+
$price = $price + $tax;
|
847 |
|
848 |
if ($priceIncTax == 1) {
|
849 |
return $price;
|
893 |
|
894 |
try {
|
895 |
$transaction = Mage::getModel('sales/order_payment_transaction')
|
896 |
+
->loadByTxnId($orderId);
|
897 |
|
898 |
$newOrder = $transaction->getOrder();
|
899 |
if (is_object($newOrder)) {
|
916 |
$bOrderExisted = true;
|
917 |
}
|
918 |
}
|
919 |
+
|
920 |
+
// Additional check good for failsafe
|
921 |
+
if (!$bOrderExisted)
|
922 |
+
{
|
923 |
+
$existingOrder = Mage::getModel('sales/order')->loadByIncrementId($orderId);
|
924 |
+
$existingOrderData = $existingOrder->getData();
|
925 |
+
if(!empty($existingOrderData))
|
926 |
+
{
|
927 |
+
$this->doSingleOrder($order, $existingOrder);
|
928 |
+
$bOrderExisted = true;
|
929 |
+
}
|
930 |
+
}
|
931 |
|
932 |
$table_prefix = Mage::getConfig()->getTablePrefix();
|
933 |
|
app/code/community/Camiloo/Channelunity/Model/Products.php
CHANGED
@@ -10,7 +10,6 @@
|
|
10 |
*/
|
11 |
class Camiloo_Channelunity_Model_Products extends Camiloo_Channelunity_Model_Abstract
|
12 |
{
|
13 |
-
|
14 |
protected $_collection = 'catalog/product';
|
15 |
private $starttime;
|
16 |
private $endtime;
|
@@ -27,7 +26,6 @@ class Camiloo_Channelunity_Model_Products extends Camiloo_Channelunity_Model_Abs
|
|
27 |
|
28 |
public function postProductTypesToCU($request)
|
29 |
{
|
30 |
-
|
31 |
$url = (string) $request->URL;
|
32 |
$putData = tmpfile();
|
33 |
$bytes = 0;
|
@@ -509,8 +507,11 @@ class Camiloo_Channelunity_Model_Products extends Camiloo_Channelunity_Model_Abs
|
|
509 |
public function generateCuXmlSku($args)
|
510 |
{
|
511 |
$row = $args['row'];
|
512 |
-
|
513 |
-
|
|
|
|
|
|
|
514 |
}
|
515 |
|
516 |
public function generateCuXmlForProductEcho($args)
|
@@ -593,9 +594,12 @@ class Camiloo_Channelunity_Model_Products extends Camiloo_Channelunity_Model_Abs
|
|
593 |
|
594 |
public function getAllSKUs($request)
|
595 |
{
|
596 |
-
|
597 |
-
|
598 |
-
|
|
|
|
|
|
|
599 |
|
600 |
$ignoreDisabled = Mage::getStoreConfig('channelunityint/generalsettings/ignoredisabledproducts');
|
601 |
|
@@ -606,7 +610,8 @@ class Camiloo_Channelunity_Model_Products extends Camiloo_Channelunity_Model_Abs
|
|
606 |
$sql = $collectionOfProduct->getSelect();
|
607 |
|
608 |
$result = Mage::getSingleton('core/resource_iterator')->walk(
|
609 |
-
|
|
|
610 |
);
|
611 |
}
|
612 |
|
@@ -644,12 +649,12 @@ class Camiloo_Channelunity_Model_Products extends Camiloo_Channelunity_Model_Abs
|
|
644 |
$collectionOfProduct->addFieldToFilter('status', 1);
|
645 |
}
|
646 |
|
647 |
-
$totalNumProducts = $this->executeQueryScalar(str_replace("SELECT", "SELECT count(*) as count_cu, ",
|
648 |
-
|
649 |
|
650 |
$collectionOfProduct->addStoreFilter($storeId);
|
651 |
|
652 |
-
//Only to retrieve the last item in shop
|
653 |
$collectionOfProduct->setOrder('entity_id', 'DESC');
|
654 |
$collectionOfProduct->setPageSize(1);
|
655 |
$collectionOfProduct->setCurPage(1);
|
@@ -684,10 +689,12 @@ class Camiloo_Channelunity_Model_Products extends Camiloo_Channelunity_Model_Abs
|
|
684 |
echo "<Query><![CDATA[$query]]></Query>\n";
|
685 |
|
686 |
try {
|
687 |
-
|
688 |
-
|
|
|
689 |
} catch (Exception $x1) {
|
690 |
-
Mage::getSingleton('core/resource_iterator')->walk($collectionOfProduct->getSelect(),
|
|
|
691 |
}
|
692 |
|
693 |
// Let the cloud know where to start from the next time it calls
|
@@ -707,6 +714,74 @@ class Camiloo_Channelunity_Model_Products extends Camiloo_Channelunity_Model_Abs
|
|
707 |
echo "</Products>\n";
|
708 |
}
|
709 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
710 |
private function executeQuery($sql)
|
711 |
{
|
712 |
$db = Mage::getSingleton("core/resource")->getConnection("core_write");
|
10 |
*/
|
11 |
class Camiloo_Channelunity_Model_Products extends Camiloo_Channelunity_Model_Abstract
|
12 |
{
|
|
|
13 |
protected $_collection = 'catalog/product';
|
14 |
private $starttime;
|
15 |
private $endtime;
|
26 |
|
27 |
public function postProductTypesToCU($request)
|
28 |
{
|
|
|
29 |
$url = (string) $request->URL;
|
30 |
$putData = tmpfile();
|
31 |
$bytes = 0;
|
507 |
public function generateCuXmlSku($args)
|
508 |
{
|
509 |
$row = $args['row'];
|
510 |
+
if(isset($row["sku"]) && !empty($row["sku"]))
|
511 |
+
{
|
512 |
+
$productId = $row["sku"];
|
513 |
+
echo "<SKU><![CDATA[ " . $productId . " ]]></SKU>";
|
514 |
+
}
|
515 |
}
|
516 |
|
517 |
public function generateCuXmlForProductEcho($args)
|
594 |
|
595 |
public function getAllSKUs($request)
|
596 |
{
|
597 |
+
if (version_compare(Mage::getVersion(), "1.6.0.0", ">=")
|
598 |
+
&& class_exists("Mage_Catalog_Model_Resource_Product_Collection")) {
|
599 |
+
$collectionOfProduct = Mage::getModel('channelunity/collection')->addAttributeToSelect('sku');
|
600 |
+
} else {
|
601 |
+
$collectionOfProduct = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('sku');
|
602 |
+
}
|
603 |
|
604 |
$ignoreDisabled = Mage::getStoreConfig('channelunityint/generalsettings/ignoredisabledproducts');
|
605 |
|
610 |
$sql = $collectionOfProduct->getSelect();
|
611 |
|
612 |
$result = Mage::getSingleton('core/resource_iterator')->walk(
|
613 |
+
$sql, array(array($this, 'generateCuXmlSku')), array('storeId' => 0),
|
614 |
+
$collectionOfProduct->getSelect()->getAdapter()
|
615 |
);
|
616 |
}
|
617 |
|
649 |
$collectionOfProduct->addFieldToFilter('status', 1);
|
650 |
}
|
651 |
|
652 |
+
$totalNumProducts = $this->executeQueryScalar(str_replace("SELECT", "SELECT count(*) as count_cu, ",
|
653 |
+
$collectionOfProduct->getSelect()), 'count_cu');
|
654 |
|
655 |
$collectionOfProduct->addStoreFilter($storeId);
|
656 |
|
657 |
+
// Only to retrieve the last item in shop
|
658 |
$collectionOfProduct->setOrder('entity_id', 'DESC');
|
659 |
$collectionOfProduct->setPageSize(1);
|
660 |
$collectionOfProduct->setCurPage(1);
|
689 |
echo "<Query><![CDATA[$query]]></Query>\n";
|
690 |
|
691 |
try {
|
692 |
+
Mage::getSingleton('core/resource_iterator')->walk($query,
|
693 |
+
array(array($this, 'generateCuXmlForProductEcho')), array('storeId' => $storeId),
|
694 |
+
$collectionOfProduct->getSelect()->getAdapter());
|
695 |
} catch (Exception $x1) {
|
696 |
+
Mage::getSingleton('core/resource_iterator')->walk($collectionOfProduct->getSelect(),
|
697 |
+
array(array($this, 'generateCuXmlForProductEcho')), array('storeId' => $storeId));
|
698 |
}
|
699 |
|
700 |
// Let the cloud know where to start from the next time it calls
|
714 |
echo "</Products>\n";
|
715 |
}
|
716 |
|
717 |
+
public function cronupdate()
|
718 |
+
{
|
719 |
+
$productsUpdated = array();
|
720 |
+
$productsToUpdate = array();
|
721 |
+
|
722 |
+
$data = '';
|
723 |
+
|
724 |
+
$updateStockOnCron = Mage::getStoreConfig('channelunityint/cron/updatestockoncron');
|
725 |
+
|
726 |
+
if($updateStockOnCron == 1)
|
727 |
+
{
|
728 |
+
$productsToUpdate = $this->getProductsToUpdate();
|
729 |
+
|
730 |
+
if(!empty($productsToUpdate))
|
731 |
+
{
|
732 |
+
foreach($productsToUpdate as $storeViewId => $products)
|
733 |
+
{
|
734 |
+
if(!empty($products))
|
735 |
+
{
|
736 |
+
foreach($products as $prId)
|
737 |
+
{
|
738 |
+
$data .= $this->generateCuXmlForSingleProduct($prId, $storeViewId, 0);
|
739 |
+
$productsUpdated[$storeViewId][] = $prId;
|
740 |
+
}
|
741 |
+
}
|
742 |
+
}
|
743 |
+
|
744 |
+
if($data)
|
745 |
+
{
|
746 |
+
$result = $this->updateProductData($storeViewId, $data);
|
747 |
+
|
748 |
+
$xml = simplexml_load_string($result, 'SimpleXMLElement', LIBXML_NOCDATA);
|
749 |
+
|
750 |
+
if (isset($xml->Status))
|
751 |
+
{
|
752 |
+
$status = (string) $xml->Status;
|
753 |
+
if($status == 'OK') {
|
754 |
+
$this->unsetProductsToUpdate($productsUpdated);
|
755 |
+
}
|
756 |
+
}
|
757 |
+
}
|
758 |
+
}
|
759 |
+
}
|
760 |
+
}
|
761 |
+
|
762 |
+
private function unsetProductsToUpdate($productsUpdated)
|
763 |
+
{
|
764 |
+
$productsToUpdate = $this->getProductsToUpdate();
|
765 |
+
|
766 |
+
if(!empty($productsUpdated))
|
767 |
+
{
|
768 |
+
foreach($productsUpdated as $storeViewId => $products)
|
769 |
+
{
|
770 |
+
if(!empty($products))
|
771 |
+
{
|
772 |
+
foreach($products as $prId)
|
773 |
+
{
|
774 |
+
if(isset($productsToUpdate[$storeViewId][$prId])) {
|
775 |
+
unset($productsToUpdate[$storeViewId][$prId]);
|
776 |
+
}
|
777 |
+
}
|
778 |
+
}
|
779 |
+
}
|
780 |
+
|
781 |
+
$this->setProductsToUpdate($productsToUpdate);
|
782 |
+
}
|
783 |
+
}
|
784 |
+
|
785 |
private function executeQuery($sql)
|
786 |
{
|
787 |
$db = Mage::getSingleton("core/resource")->getConnection("core_write");
|
app/code/community/Camiloo/Channelunity/controllers/ApiController.php
CHANGED
@@ -13,7 +13,6 @@ class Camiloo_Channelunity_ApiController extends Mage_Core_Controller_Front_Acti
|
|
13 |
|
14 |
private function terminate($message)
|
15 |
{
|
16 |
-
|
17 |
echo '<?xml version="1.0" encoding="utf-8" ?>';
|
18 |
echo ' <ChannelUnity>';
|
19 |
echo ' <Status>' . $message . '</Status>';
|
@@ -30,53 +29,85 @@ class Camiloo_Channelunity_ApiController extends Mage_Core_Controller_Front_Acti
|
|
30 |
}
|
31 |
}
|
32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
public function ordertestAction()
|
34 |
{
|
35 |
|
36 |
$xml = <<<EOD
|
37 |
-
<?xml version="1.0" encoding="utf-8"
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
EOD;
|
81 |
|
82 |
$this->doApiProcess($xml, true);
|
@@ -176,13 +207,26 @@ EOD;
|
|
176 |
echo ' </ChannelUnity>';
|
177 |
}
|
178 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
/**
|
180 |
* This is the main API beacon for the connector module
|
181 |
* It will verify the request then pass it onto the model.
|
182 |
* */
|
183 |
public function indexAction()
|
184 |
{
|
185 |
-
|
186 |
$xml = $this->getRequest()->getPost('xml');
|
187 |
if (!isset($xml)) {
|
188 |
|
13 |
|
14 |
private function terminate($message)
|
15 |
{
|
|
|
16 |
echo '<?xml version="1.0" encoding="utf-8" ?>';
|
17 |
echo ' <ChannelUnity>';
|
18 |
echo ' <Status>' . $message . '</Status>';
|
29 |
}
|
30 |
}
|
31 |
|
32 |
+
public function orderremoveAction()
|
33 |
+
{
|
34 |
+
/*
|
35 |
+
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
|
36 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId('1000000');
|
37 |
+
$order->delete();
|
38 |
+
*/
|
39 |
+
}
|
40 |
+
|
41 |
public function ordertestAction()
|
42 |
{
|
43 |
|
44 |
$xml = <<<EOD
|
45 |
+
<?xml version="1.0" encoding="utf-8" ?>
|
46 |
+
<ChannelUnity>
|
47 |
+
<Notification>
|
48 |
+
<ID>1334834111876</ID>
|
49 |
+
<Timestamp>Thu Apr 19 12:15:11 BST 2012</Timestamp>
|
50 |
+
<Type>OrderNotification</Type>
|
51 |
+
<Payload>
|
52 |
+
<MerchantName>marktest</MerchantName>
|
53 |
+
<SourceId>10</SourceId>
|
54 |
+
<FriendlyName>English</FriendlyName>
|
55 |
+
<URL>http://__.camiloo.co.uk/channelunity/api/index</URL>
|
56 |
+
<MainCountry>United Kingdom</MainCountry>
|
57 |
+
<FrameworkType>Magento</FrameworkType>
|
58 |
+
<WebsiteId>1</WebsiteId>
|
59 |
+
<StoreId>1</StoreId>
|
60 |
+
<StoreviewId>1</StoreviewId>
|
61 |
+
<SubscriptionId>304</SubscriptionId>
|
62 |
+
<SkuAttribute>sku</SkuAttribute>
|
63 |
+
<Orders>
|
64 |
+
<Order>
|
65 |
+
<ServiceSku>CU_AMZ_UK</ServiceSku>
|
66 |
+
<OrderId>228-8888888-0277162-4</OrderId>
|
67 |
+
<PurchaseDate>2013-01-03T12:33:10+00:00</PurchaseDate>
|
68 |
+
<Currency>GBP</Currency>
|
69 |
+
<OrderFlags></OrderFlags>
|
70 |
+
<OrderStatus>Complete</OrderStatus>
|
71 |
+
<StockReservedCart>0</StockReservedCart>
|
72 |
+
<ShippingInfo>
|
73 |
+
<RecipientName><![CDATA[Mrs Ship]]></RecipientName>
|
74 |
+
<Email><![CDATA[ship@ship.com]]></Email>
|
75 |
+
<Address1><![CDATA[1 High St]]></Address1>
|
76 |
+
<Address2><![CDATA[]]></Address2>
|
77 |
+
<Address3><![CDATA[]]></Address3>
|
78 |
+
<City><![CDATA[Manchester]]></City>
|
79 |
+
<State>Greater Manchester</State>
|
80 |
+
<PostalCode>M1 1AA</PostalCode>
|
81 |
+
<Country><![CDATA[GB]]></Country>
|
82 |
+
<PhoneNumber><![CDATA[01981 239329]]></PhoneNumber>
|
83 |
+
<ShippingPrice>2.00</ShippingPrice>
|
84 |
+
<ShippingTax>0.00</ShippingTax>
|
85 |
+
<Service><![CDATA[Std UK Europe 2]]></Service>
|
86 |
+
<DeliveryInstructions><![CDATA[]]></DeliveryInstructions>
|
87 |
+
<GiftWrapPrice>0.00</GiftWrapPrice>
|
88 |
+
<GiftWrapTax>0.00</GiftWrapTax>
|
89 |
+
<GiftWrapType></GiftWrapType>
|
90 |
+
<GiftMessage><![CDATA[]]></GiftMessage>
|
91 |
+
</ShippingInfo>
|
92 |
+
<BillingInfo>
|
93 |
+
<Name><![CDATA[Mr Billing]]></Name>
|
94 |
+
<Email><![CDATA[b@c.com]]></Email>
|
95 |
+
<PhoneNumber><![CDATA[01987 228228]]></PhoneNumber>
|
96 |
+
</BillingInfo>
|
97 |
+
<OrderItems>
|
98 |
+
<Item>
|
99 |
+
<SKU><![CDATA[M9179LL]]></SKU>
|
100 |
+
<Name><![CDATA[30" Flat-Panel TFT-LCD Cinema HD Monitor]]></Name>
|
101 |
+
<Quantity>1.000</Quantity>
|
102 |
+
<Price>600.00</Price>
|
103 |
+
<Tax>0.00</Tax>
|
104 |
+
</Item>
|
105 |
+
</OrderItems>
|
106 |
+
</Order>
|
107 |
+
</Orders>
|
108 |
+
</Payload>
|
109 |
+
</Notification>
|
110 |
+
</ChannelUnity>
|
111 |
EOD;
|
112 |
|
113 |
$this->doApiProcess($xml, true);
|
207 |
echo ' </ChannelUnity>';
|
208 |
}
|
209 |
|
210 |
+
public function setcredentialsAction()
|
211 |
+
{
|
212 |
+
// Only sets them if they're blank
|
213 |
+
if (Mage::getModel('channelunity/products')->getMerchantName() == '') {
|
214 |
+
|
215 |
+
$merchantname = $this->getRequest()->getParam('mct');
|
216 |
+
$username = $this->getRequest()->getParam('usr');
|
217 |
+
$password = $this->getRequest()->getParam('pass');
|
218 |
+
|
219 |
+
Mage::getModel('channelunity/products')->setCredentialsInModule($merchantname, $username, $password);
|
220 |
+
Mage::getModel('channelunity/orders')->verifyMyself(null);
|
221 |
+
}
|
222 |
+
}
|
223 |
+
|
224 |
/**
|
225 |
* This is the main API beacon for the connector module
|
226 |
* It will verify the request then pass it onto the model.
|
227 |
* */
|
228 |
public function indexAction()
|
229 |
{
|
|
|
230 |
$xml = $this->getRequest()->getPost('xml');
|
231 |
if (!isset($xml)) {
|
232 |
|
app/code/community/Camiloo/Channelunity/etc/config.xml
CHANGED
@@ -5,6 +5,14 @@
|
|
5 |
<version>1.0.0</version>
|
6 |
</Camiloo_Channelunity>
|
7 |
</modules>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
<frontend>
|
9 |
<secure_url>
|
10 |
<channelunity_cronrun>/channelunity/cron/cronrun/</channelunity_cronrun>
|
5 |
<version>1.0.0</version>
|
6 |
</Camiloo_Channelunity>
|
7 |
</modules>
|
8 |
+
<crontab>
|
9 |
+
<jobs>
|
10 |
+
<channelunity_products_cronupdate>
|
11 |
+
<schedule><cron_expr>*/5 * * * *</cron_expr></schedule>
|
12 |
+
<run><model>channelunity/products::cronupdate</model></run>
|
13 |
+
</channelunity_products_cronupdate>
|
14 |
+
</jobs>
|
15 |
+
</crontab>
|
16 |
<frontend>
|
17 |
<secure_url>
|
18 |
<channelunity_cronrun>/channelunity/cron/cronrun/</channelunity_cronrun>
|
app/code/community/Camiloo/Channelunity/etc/system.xml
CHANGED
@@ -103,6 +103,15 @@ Please leave this blank and it will be populated automatically.
|
|
103 |
<show_in_website>0</show_in_website>
|
104 |
<show_in_store>0</show_in_store>
|
105 |
</ignorefbaqty>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
</fields>
|
107 |
</generalsettings>
|
108 |
</groups>
|
103 |
<show_in_website>0</show_in_website>
|
104 |
<show_in_store>0</show_in_store>
|
105 |
</ignorefbaqty>
|
106 |
+
<updatestockoncron>
|
107 |
+
<label>Update Ordered Products Stock Only On Cron Basis</label>
|
108 |
+
<frontend_type>select</frontend_type>
|
109 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
110 |
+
<sort_order>55</sort_order>
|
111 |
+
<show_in_default>1</show_in_default>
|
112 |
+
<show_in_website>0</show_in_website>
|
113 |
+
<show_in_store>0</show_in_store>
|
114 |
+
</updatestockoncron>
|
115 |
</fields>
|
116 |
</generalsettings>
|
117 |
</groups>
|
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.11");
|
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@channelunity.com</description>
|
13 |
<notes>The ChannelUnity connector kit for Magento.
|
14 |
-
|
15 |
<authors><author><name>Camiloo Limited</name><user>auto-converted</user><email>hello@camiloo.co.uk</email></author></authors>
|
16 |
-
<date>
|
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.11</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@channelunity.com</description>
|
13 |
<notes>The ChannelUnity connector kit for Magento.
|
14 |
+
Allows automatic installation via www.channelunity.com. Fixes an issue related to flat product tables support.</notes>
|
15 |
<authors><author><name>Camiloo Limited</name><user>auto-converted</user><email>hello@camiloo.co.uk</email></author></authors>
|
16 |
+
<date>2013-01-10</date>
|
17 |
+
<time>12:37:21</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="975989deeafee651fa1e340139af6300"/><file name="paymentinfo.phtml" hash="76caa9ce9fbe2d6e044c0504a07b1094"/></dir></dir></dir></dir></dir></target><target name="magecommunity"><dir name="Camiloo"><dir name="Channelunity"><dir name="Block"><file name="Configheader.php" hash="3e8ac32de257ecff2631046941e6137e"/><file name="Paymentform.php" hash="fabdb31dc620cfb9ab61c8c725c17d9c"/><file name="Paymentinfo.php" hash="53895170d72a8dde7c8580be51057978"/></dir><dir name="controllers"><file name="ApiController.php" hash="ecc5a4bafa94ee218e73da6e5397ee23"/><file name="ApiController.php.old.php" hash="01ff34c2cf5798a82cfc11b19ab6decd"/></dir><dir name="etc"><file name="config.xml" hash="d1f11f74fc3f651bca80223c92f9c9ea"/><file name="system.xml" hash="e28563b67338d75cf60a94d2fd9f850a"/></dir><dir name="Helper"><file name="Data.php" hash="3c92fe3908be9de73f04dbfd67539830"/></dir><dir name="Model"><file name="Abstract.php" hash="b191a52486a80add7e51e5e1f691c008"/><file name="Attributes.php" hash="e7e3c18496a4a33d0bb1cb56a0a2122e"/><file name="Categories.php" hash="8a45e805e20f2138194820bc5ea9f0d5"/><file name="Checkforupdates.php" hash="1059e54fb953d343dbbbf42a025148e8"/><file name="Collection.php" hash="2aa4e920044de962d1813a48defe29f1"/><file name="Customrate.php" hash="5bd3a98549764890c5b3ebc311e8c114"/><file name="Entity.php" hash="fc95b86e51597afad477cd09db5c8b4d"/><file name="Observer.php" hash="4837df027561b8482a87e22f62cf3e11"/><file name="Ordercreatebackport.php" hash="c2db4232b69e06a0f897a94735546cb4"/><file name="Orders.php" hash="e5000f854f655806a59a6ec644de76cf"/><file name="Payment.php" hash="40352086906a6a09ca220605706d62d4"/><file name="Paymentinfo.php" hash="5ae85a0e16183b3b2ee35aad71c722d8"/><file name="Paymentmethoduk.php" hash="d03558fd4886a68e8b2d618dbd64e19f"/><file name="Products.php" hash="5001579e4051846bca4246384d3e6726"/><file name="Stores.php" hash="67cacf0dd8ef1f8baa8ee706e9014e3e"/></dir><dir name="sql"><dir name="channelunity_setup"><file name="install-1.0.0.php" hash="4d1afd779a923d7755289ec169fa188d"/><file name="mysql4-install-0.0.1.php" hash="934e5541c3a9d54fafda920ac121b5bf"/></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>
|