Version Notes
Version 2.0.5
Download this release
Release Info
Developer | Cosmic Cart, Inc. |
Extension | CosmicCart |
Version | 2.0.5 |
Comparing to | |
See all releases |
Code changes from version 1.0.0 to 2.0.5
- app/code/community/CosmicCart/Cosmicapi/Helper/Data.php +88 -0
- app/code/community/CosmicCart/Cosmicapi/Model/Cosmicapi.php +37 -0
- app/code/community/CosmicCart/Cosmicapi/Model/Resource/Cosmicapi.php +20 -0
- app/code/community/CosmicCart/Cosmicapi/Model/Resource/Cosmicapi/Collection.php +21 -0
- app/code/community/CosmicCart/Cosmicapi/controllers/RestController.php +220 -0
- app/code/community/CosmicCart/Cosmicapi/etc/config.xml +62 -0
- app/code/community/CosmicCart/Cosmicapi/sql/cosmicapi_setup/install-0.1.0.php +28 -0
- app/code/community/CosmicCart/Integration/Block/Adminhtml/Cosmiccart.php +38 -0
- app/code/community/CosmicCart/Integration/Block/Adminhtml/Cosmiccart/Edit.php +56 -0
- app/code/community/CosmicCart/Integration/Block/Adminhtml/Cosmiccart/Edit/Form.php +30 -0
- app/code/community/CosmicCart/Integration/Block/Adminhtml/Cosmiccart/Edit/Tab/Form.php +47 -0
- app/code/community/CosmicCart/Integration/Block/Adminhtml/Cosmiccart/Edit/Tabs.php +35 -0
- app/code/community/CosmicCart/Integration/Block/Adminhtml/Cosmiccart/Grid.php +104 -0
- app/code/community/CosmicCart/Integration/Block/Adminhtml/Storeselect.php +237 -0
- app/code/community/CosmicCart/Integration/Block/Cosmiccart.php +19 -0
- app/code/community/CosmicCart/Integration/Helper/Data.php +83 -17
- app/code/community/CosmicCart/Integration/Model/AccessToken.php +63 -57
- app/code/community/CosmicCart/Integration/Model/Adminhtml/System/Config/Backend/Dynamic/Cron.php +61 -0
- app/code/community/CosmicCart/Integration/Model/Adminhtml/System/Config/Ean.php +34 -0
- app/code/community/CosmicCart/Integration/Model/Adminhtml/System/Config/Source/Payment.php +61 -0
- app/code/community/CosmicCart/Integration/Model/Api.php +0 -41
- app/code/community/CosmicCart/Integration/Model/Api/Resource.php +0 -28
- app/code/community/CosmicCart/Integration/Model/Api/V2.php +0 -25
- app/code/community/CosmicCart/Integration/Model/Batch.php +40 -0
- app/code/community/CosmicCart/Integration/Model/Client.php +56 -51
- app/code/community/CosmicCart/Integration/Model/ErrorHandler.php +59 -0
- app/code/community/CosmicCart/Integration/Model/Exporter.php +961 -0
- app/code/community/CosmicCart/Integration/Model/Mail.php +45 -0
- app/code/community/CosmicCart/Integration/{OAuth2Client.php → Model/Oauth2client.php} +25 -26
- app/code/community/CosmicCart/Integration/Model/Observer.php +192 -0
- app/code/community/CosmicCart/Integration/Model/Order/Api/V2.php +318 -207
- app/code/community/CosmicCart/Integration/Model/Pay.php +80 -80
- app/code/community/CosmicCart/Integration/Model/Product/Api/V2.php +0 -83
- app/code/community/CosmicCart/Integration/Model/Resource/AccessToken.php +56 -56
- app/code/community/CosmicCart/Integration/Model/Resource/AccessToken/Collection.php +19 -19
- app/code/community/CosmicCart/Integration/Model/Resource/Batch.php +20 -0
- app/code/community/CosmicCart/Integration/Model/Resource/Batch/Collection.php +21 -0
- app/code/community/CosmicCart/Integration/Model/Resource/Client.php +56 -56
- app/code/community/CosmicCart/Integration/Model/Resource/Client/Collection.php +19 -19
- app/code/community/CosmicCart/Integration/Model/Resource/Setup.php +15 -15
- app/code/community/CosmicCart/Integration/Model/Shipment/Observer.php +0 -79
- app/code/community/CosmicCart/Integration/Model/System/Config/Source/Environment.php +29 -0
- app/code/community/CosmicCart/Integration/controllers/Adminhtml/ActivationController.php +0 -118
- app/code/community/CosmicCart/Integration/controllers/Adminhtml/Integration/ActivationController.php +129 -0
- app/code/community/CosmicCart/Integration/controllers/Adminhtml/Integration/BatchController.php +85 -0
- app/code/community/CosmicCart/Integration/etc/api.xml +0 -41
- app/code/community/CosmicCart/Integration/etc/config.xml +168 -115
- app/code/community/CosmicCart/Integration/etc/cosmiccart.ini +0 -1
- app/code/community/CosmicCart/Integration/etc/system.xml +151 -16
- app/code/community/CosmicCart/Integration/etc/wsdl.xml +0 -44
- app/code/community/CosmicCart/Integration/etc/wsi.xml +0 -359
- app/code/community/CosmicCart/Integration/sql/cosmiccart_integration_setup/install-1.0.0.php +60 -68
- app/code/community/CosmicCart/Integration/sql/cosmiccart_integration_setup/upgrade-1.0.0-1.0.1.php +52 -0
- app/code/community/CosmicCart/Integration/sql/cosmiccart_integration_setup/upgrade-2.0.0-2.0.1.php +29 -0
- app/design/adminhtml/default/default/layout/cosmiccart/integration.xml +9 -5
- app/design/adminhtml/default/default/template/cosmiccart/activation.phtml +40 -11
- app/etc/modules/CosmicCart_Cosmicapi.xml +10 -0
- app/locale/en_US/CosmicCart_Integration.csv +4 -2
- app/locale/en_US/template/email/cosmiccart/generic_error.html +19 -0
- app/locale/en_US/template/email/cosmiccart/import_exception.html +13 -0
- app/locale/en_US/template/email/cosmiccart/package_shipped.html +18 -0
- app/locale/en_US/template/email/cosmiccart/refund_exception.html +18 -0
- package.xml +11 -11
app/code/community/CosmicCart/Cosmicapi/Helper/Data.php
ADDED
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
+
*
|
7 |
+
* @category CosmicCart
|
8 |
+
* @package Integration
|
9 |
+
* @copyright Copyright (c) 2015 Cosmic Cart, Inc.
|
10 |
+
* @license CosmicCart Software License https://cosmiccart.com/help/license/software
|
11 |
+
*/
|
12 |
+
|
13 |
+
|
14 |
+
class CosmicCart_Cosmicapi_Helper_Data extends Mage_Core_Helper_Abstract
|
15 |
+
{
|
16 |
+
public function auth($data)
|
17 |
+
{
|
18 |
+
if (empty($data['username']) OR empty($data['password'])) {
|
19 |
+
$jsonObject['error'] = 'Credentials not supplied';
|
20 |
+
$jsonObject['status'] = 401;
|
21 |
+
$jsonObject['code'] = 'INVALID_CREDENTIALS';
|
22 |
+
return $jsonObject;
|
23 |
+
}
|
24 |
+
$username = $data['username'];
|
25 |
+
$password = $data['password'];
|
26 |
+
$isValid = Mage::getModel('api/user')->authenticate($username, $password);
|
27 |
+
if ($isValid) {
|
28 |
+
$jsonObject['token'] = $this->generateToken();
|
29 |
+
} else {
|
30 |
+
$jsonObject['error'] = 'Provided Username and Password is invalid';
|
31 |
+
$jsonObject['status'] = 401;
|
32 |
+
$jsonObject['code'] = 'INVALID_CREDENTIALS';
|
33 |
+
}
|
34 |
+
return $jsonObject;
|
35 |
+
}
|
36 |
+
|
37 |
+
public function generateToken()
|
38 |
+
{
|
39 |
+
$token = Mage::helper('core')->getRandomString(50);
|
40 |
+
$this->saveToken($token);
|
41 |
+
return $token;
|
42 |
+
}
|
43 |
+
|
44 |
+
public function saveToken($token)
|
45 |
+
{
|
46 |
+
$newTokenObject = Mage::getModel('cosmicapi/cosmicapi');
|
47 |
+
$newTokenObject->setTokenKey($token)->save();
|
48 |
+
return;
|
49 |
+
}
|
50 |
+
|
51 |
+
private final function isValid($token)
|
52 |
+
{
|
53 |
+
$collection = Mage::getModel('cosmicapi/cosmicapi')->getCollection();
|
54 |
+
$collection->addFieldToFilter('token_key', $token);
|
55 |
+
|
56 |
+
if ($collection->getSize() < 1) {
|
57 |
+
return false;
|
58 |
+
}
|
59 |
+
|
60 |
+
$tokenObject = $collection->getFirstItem();
|
61 |
+
$data = $tokenObject->getData();
|
62 |
+
|
63 |
+
if (!empty($data)) {
|
64 |
+
return true;
|
65 |
+
} else {
|
66 |
+
return false;
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
public final function validateData($request)
|
71 |
+
{
|
72 |
+
$token = $request->getHeader('X-CCAPI-Token');
|
73 |
+
if (!isset($token)) {
|
74 |
+
$response['error'] = 'No token attached';
|
75 |
+
$response['status'] = 401;
|
76 |
+
$response['code'] = 'MISSING_TOKEN';
|
77 |
+
return $response;
|
78 |
+
} else if (!$this->isValid($token)) {
|
79 |
+
$response['error'] = 'Invalid token provided';
|
80 |
+
$response['status'] = 401;
|
81 |
+
$response['code'] = 'INVALID_TOKEN';
|
82 |
+
return $response;
|
83 |
+
}
|
84 |
+
|
85 |
+
return true;
|
86 |
+
}
|
87 |
+
|
88 |
+
}
|
app/code/community/CosmicCart/Cosmicapi/Model/Cosmicapi.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
+
*
|
7 |
+
* @category CosmicCart
|
8 |
+
* @package Integration
|
9 |
+
* @copyright Copyright (c) 2015 Cosmic Cart, Inc.
|
10 |
+
* @license CosmicCart Software License https://cosmiccart.com/help/license/software
|
11 |
+
*/
|
12 |
+
|
13 |
+
|
14 |
+
class CosmicCart_Cosmicapi_Model_Cosmicapi extends Mage_Core_Model_Abstract
|
15 |
+
{
|
16 |
+
|
17 |
+
public function _construct()
|
18 |
+
{
|
19 |
+
parent::_construct();
|
20 |
+
$this->_init('cosmicapi/cosmicapi');
|
21 |
+
}
|
22 |
+
|
23 |
+
public function invalidateTokens()
|
24 |
+
{
|
25 |
+
$tokenCollection = $this->getResourceCollection();
|
26 |
+
|
27 |
+
if ($tokenCollection->getSize() > 0) {
|
28 |
+
foreach ($tokenCollection as $token) {
|
29 |
+
if ($token AND $token->getId()) {
|
30 |
+
$token->delete();
|
31 |
+
}
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
}
|
36 |
+
|
37 |
+
}
|
app/code/community/CosmicCart/Cosmicapi/Model/Resource/Cosmicapi.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
+
*
|
7 |
+
* @category CosmicCart
|
8 |
+
* @package Integration
|
9 |
+
* @copyright Copyright (c) 2015 Cosmic Cart, Inc.
|
10 |
+
* @license CosmicCart Software License https://cosmiccart.com/help/license/software
|
11 |
+
*/
|
12 |
+
|
13 |
+
|
14 |
+
class CosmicCart_Cosmicapi_Model_Resource_Cosmicapi extends Mage_Core_Model_Resource_Db_Abstract {
|
15 |
+
|
16 |
+
public function _construct() {
|
17 |
+
$this->_init('cosmicapi/cosmicapi', 'token_id');
|
18 |
+
}
|
19 |
+
|
20 |
+
}
|
app/code/community/CosmicCart/Cosmicapi/Model/Resource/Cosmicapi/Collection.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
+
*
|
7 |
+
* @category CosmicCart
|
8 |
+
* @package Integration
|
9 |
+
* @copyright Copyright (c) 2015 Cosmic Cart, Inc.
|
10 |
+
* @license CosmicCart Software License https://cosmiccart.com/help/license/software
|
11 |
+
*/
|
12 |
+
|
13 |
+
|
14 |
+
class CosmicCart_Cosmicapi_Model_Resource_Cosmicapi_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract {
|
15 |
+
|
16 |
+
public function _construct() {
|
17 |
+
parent::_construct();
|
18 |
+
$this->_init('cosmicapi/cosmicapi');
|
19 |
+
}
|
20 |
+
|
21 |
+
}
|
app/code/community/CosmicCart/Cosmicapi/controllers/RestController.php
ADDED
@@ -0,0 +1,220 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
+
*
|
7 |
+
* @category CosmicCart
|
8 |
+
* @package Integration
|
9 |
+
* @copyright Copyright (c) 2015 Cosmic Cart, Inc.
|
10 |
+
* @license CosmicCart Software License https://cosmiccart.com/help/license/software
|
11 |
+
*/
|
12 |
+
|
13 |
+
|
14 |
+
class CosmicCart_Cosmicapi_RestController extends Mage_Core_Controller_Front_Action
|
15 |
+
{
|
16 |
+
|
17 |
+
public function authAction()
|
18 |
+
{
|
19 |
+
$isPost = $this->getRequest()->isPost();
|
20 |
+
if (!$isPost) {
|
21 |
+
$this->getResponse()->setHeader('HTTP/1.1', '403 Forbidden');
|
22 |
+
return;
|
23 |
+
}
|
24 |
+
|
25 |
+
try {
|
26 |
+
$params = $this->_getAuthParams();
|
27 |
+
} Catch (Exception $e) {
|
28 |
+
$this->sendInvalidCredentialsResponse($e->getMessage());
|
29 |
+
return;
|
30 |
+
}
|
31 |
+
|
32 |
+
$response = Mage::helper('cosmicapi')->auth($params);
|
33 |
+
$this->sendResponse($response);
|
34 |
+
}
|
35 |
+
|
36 |
+
public function getCatalogInventoryStockItemAction()
|
37 |
+
{
|
38 |
+
if ($this->validateRequest()) {
|
39 |
+
try {
|
40 |
+
$params = $this->_getStockItemParams();
|
41 |
+
$productIds = $params['product_ids'];
|
42 |
+
$products = Mage::getSingleton("cataloginventory/stock_item_api_v2")->items($productIds);
|
43 |
+
if (count($products) == 0) {
|
44 |
+
$this->sendResponse(array(
|
45 |
+
'error' => 'The requested productIds were not found.',
|
46 |
+
'status' => 404,
|
47 |
+
'code' => 'PRODUCTS_NOT_FOUND'
|
48 |
+
));
|
49 |
+
} else {
|
50 |
+
$this->sendResponse($products);
|
51 |
+
}
|
52 |
+
} catch (Exception $e) {
|
53 |
+
$this->sendUnexpectedError($e);
|
54 |
+
}
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
public function getShippingMethodsListAction()
|
59 |
+
{
|
60 |
+
if ($this->validateRequest()) {
|
61 |
+
try {
|
62 |
+
$params = $this->_getShippingMethodsListParams();
|
63 |
+
|
64 |
+
$addressData = $params['address_data'];
|
65 |
+
$orderItemsData = $params['order_items_data'];
|
66 |
+
$store = $params['store'];
|
67 |
+
|
68 |
+
$response = Mage::getModel('cosmiccart_integration/order_api_v2')
|
69 |
+
->getShippingMethodsList($addressData, $orderItemsData, $store);
|
70 |
+
$this->sendResponse($response);
|
71 |
+
} catch (Exception $e) {
|
72 |
+
$this->sendUnexpectedError($e);
|
73 |
+
}
|
74 |
+
}
|
75 |
+
}
|
76 |
+
|
77 |
+
public function getSalesTaxAction()
|
78 |
+
{
|
79 |
+
if ($this->validateRequest()) {
|
80 |
+
try {
|
81 |
+
$params = $this->_getSalesTaxParams();
|
82 |
+
|
83 |
+
$addressData = $params['address_data'];
|
84 |
+
$orderItemsData = $params['order_items_data'];
|
85 |
+
$store = $params['store'];
|
86 |
+
|
87 |
+
$response = Mage::getModel('cosmiccart_integration/order_api_v2')
|
88 |
+
->getSalesTax($addressData, $orderItemsData, $store);
|
89 |
+
$this->sendResponse($response);
|
90 |
+
} catch (Exception $e) {
|
91 |
+
$this->sendUnexpectedError($e);
|
92 |
+
}
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
+
public function orderCreateAction()
|
97 |
+
{
|
98 |
+
if ($this->validateRequest()) {
|
99 |
+
try {
|
100 |
+
$params = $this->_getOrderCreateParams();
|
101 |
+
$orderData = $params['order_data'];
|
102 |
+
$store = $params['store'];
|
103 |
+
$response = Mage::getModel('cosmiccart_integration/order_api_v2')->create($orderData, $store);
|
104 |
+
$this->sendResponse($response);
|
105 |
+
} catch (Exception $e) {
|
106 |
+
$this->sendUnexpectedError($e);
|
107 |
+
}
|
108 |
+
}
|
109 |
+
}
|
110 |
+
|
111 |
+
private function _getAuthParams()
|
112 |
+
{
|
113 |
+
$params = $this->_getPostParams('Credentials not supplied');
|
114 |
+
if (!isset($params['username']) OR !isset($params['password'])) {
|
115 |
+
Mage::throwException('Credentials not supplied properly');
|
116 |
+
}
|
117 |
+
|
118 |
+
return $params;
|
119 |
+
}
|
120 |
+
|
121 |
+
private function _getStockItemParams()
|
122 |
+
{
|
123 |
+
$params = $this->_getPostParams('Product Ids not supplied');
|
124 |
+
if (!isset($params['product_ids'])) {
|
125 |
+
Mage::throwException('Product Ids not supplied properly');
|
126 |
+
}
|
127 |
+
|
128 |
+
return $params;
|
129 |
+
}
|
130 |
+
|
131 |
+
private function _getSalesTaxParams()
|
132 |
+
{
|
133 |
+
return $this->_getShippingMethodsListParams();
|
134 |
+
}
|
135 |
+
|
136 |
+
private function _getOrderCreateParams()
|
137 |
+
{
|
138 |
+
$params = $this->_getPostParams('Order data is not supplied');
|
139 |
+
if (!isset($params['order_data'])) {
|
140 |
+
Mage::throwException('Order data not supplied properly');
|
141 |
+
}
|
142 |
+
|
143 |
+
if (!isset($params['store'])) {
|
144 |
+
Mage::throwException('Store not supplied properly');
|
145 |
+
}
|
146 |
+
|
147 |
+
return $params;
|
148 |
+
}
|
149 |
+
|
150 |
+
private function _getShippingMethodsListParams()
|
151 |
+
{
|
152 |
+
$params = $this->_getPostParams('Address data not supplied');
|
153 |
+
if (!isset($params['address_data'])) {
|
154 |
+
Mage::throwException('Address data not supplied properly');
|
155 |
+
}
|
156 |
+
|
157 |
+
if (!isset($params['order_items_data'])) {
|
158 |
+
Mage::throwException('Order items data not supplied properly');
|
159 |
+
}
|
160 |
+
|
161 |
+
if (!isset($params['store'])) {
|
162 |
+
Mage::throwException('Store not supplied properly');
|
163 |
+
}
|
164 |
+
return $params;
|
165 |
+
}
|
166 |
+
|
167 |
+
private function _getPostParams($errMessage)
|
168 |
+
{
|
169 |
+
$postBody = $this->getRequest()->getRawBody();
|
170 |
+
if (empty($postBody)) {
|
171 |
+
Mage::throwException($errMessage);
|
172 |
+
}
|
173 |
+
|
174 |
+
$params = json_decode($postBody, true);
|
175 |
+
if (empty($params) OR !is_array($params)) {
|
176 |
+
Mage::throwException($errMessage);
|
177 |
+
}
|
178 |
+
|
179 |
+
return $params;
|
180 |
+
}
|
181 |
+
|
182 |
+
private function sendInvalidCredentialsResponse($message)
|
183 |
+
{
|
184 |
+
return $this->sendResponse(array(
|
185 |
+
'error' => $message,
|
186 |
+
'status' => 401,
|
187 |
+
'code' => 'INVALID_CREDENTIALS'
|
188 |
+
));
|
189 |
+
}
|
190 |
+
|
191 |
+
private function sendResponse($response)
|
192 |
+
{
|
193 |
+
$this->getResponse()->clearHeaders()->setHeader('Content-Type', 'application/json', true);
|
194 |
+
if (!is_object($response) && isset($response['status'])) {
|
195 |
+
$this->getResponse()->setHeader('HTTP/1.0', $response['status'], true);
|
196 |
+
unset($response['status']);
|
197 |
+
}
|
198 |
+
$this->getResponse()->setBody(json_encode($response));
|
199 |
+
return $this;
|
200 |
+
}
|
201 |
+
|
202 |
+
private final function validateRequest()
|
203 |
+
{
|
204 |
+
$result = Mage::helper('cosmicapi')->validateData($this->getRequest());
|
205 |
+
if (true !== $result AND isset($result['status'])) {
|
206 |
+
$this->sendResponse($result);
|
207 |
+
return false;
|
208 |
+
}
|
209 |
+
return true;
|
210 |
+
}
|
211 |
+
|
212 |
+
private function sendUnexpectedError($e)
|
213 |
+
{
|
214 |
+
$response['error'] = 'An unexpected error occurred.';
|
215 |
+
$response['reason'] = $e->getMessage();
|
216 |
+
$response['status'] = 400;
|
217 |
+
$response['code'] = 'UNKNOWN';
|
218 |
+
$this->sendResponse($response);
|
219 |
+
}
|
220 |
+
}
|
app/code/community/CosmicCart/Cosmicapi/etc/config.xml
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<CosmicCart_Cosmicapi>
|
5 |
+
<version>2.0.5</version>
|
6 |
+
</CosmicCart_Cosmicapi>
|
7 |
+
</modules>
|
8 |
+
<frontend>
|
9 |
+
<routers>
|
10 |
+
<cosmicapi>
|
11 |
+
<use>standard</use>
|
12 |
+
<args>
|
13 |
+
<module>CosmicCart_Cosmicapi</module>
|
14 |
+
<frontName>cosmicapi</frontName>
|
15 |
+
</args>
|
16 |
+
</cosmicapi>
|
17 |
+
</routers>
|
18 |
+
</frontend>
|
19 |
+
<global>
|
20 |
+
<helpers>
|
21 |
+
<cosmicapi>
|
22 |
+
<class>CosmicCart_Cosmicapi_Helper</class>
|
23 |
+
</cosmicapi>
|
24 |
+
</helpers>
|
25 |
+
<models>
|
26 |
+
<cosmicapi>
|
27 |
+
<class>CosmicCart_Cosmicapi_Model</class>
|
28 |
+
<resourceModel>cosmicapi_resource</resourceModel>
|
29 |
+
</cosmicapi>
|
30 |
+
<cosmicapi_resource>
|
31 |
+
<class>CosmicCart_Cosmicapi_Model_Resource</class>
|
32 |
+
<entities>
|
33 |
+
<cosmicapi>
|
34 |
+
<table>cosmicapi_token</table>
|
35 |
+
</cosmicapi>
|
36 |
+
</entities>
|
37 |
+
</cosmicapi_resource>
|
38 |
+
</models>
|
39 |
+
<resources>
|
40 |
+
<cosmicapi_setup>
|
41 |
+
<setup>
|
42 |
+
<module>CosmicCart_Cosmicapi</module>
|
43 |
+
</setup>
|
44 |
+
<connection>
|
45 |
+
<use>core_setup</use>
|
46 |
+
</connection>
|
47 |
+
</cosmicapi_setup>
|
48 |
+
</resources>
|
49 |
+
</global>
|
50 |
+
<crontab>
|
51 |
+
<jobs>
|
52 |
+
<my_cron>
|
53 |
+
<schedule>
|
54 |
+
<cron_expr>0 0 */5 * *</cron_expr>
|
55 |
+
</schedule>
|
56 |
+
<run>
|
57 |
+
<model>cosmicapi/cosmicapi::invalidateTokens</model>
|
58 |
+
</run>
|
59 |
+
</my_cron>
|
60 |
+
</jobs>
|
61 |
+
</crontab>
|
62 |
+
</config>
|
app/code/community/CosmicCart/Cosmicapi/sql/cosmicapi_setup/install-0.1.0.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
+
*
|
7 |
+
* @category CosmicCart
|
8 |
+
* @package Integration
|
9 |
+
* @copyright Copyright (c) 2015 Cosmic Cart, Inc.
|
10 |
+
* @license CosmicCart Software License https://cosmiccart.com/help/license/software
|
11 |
+
*/
|
12 |
+
|
13 |
+
|
14 |
+
$installer = $this;
|
15 |
+
$installer->startSetup();
|
16 |
+
$table = $installer->getConnection()
|
17 |
+
->newTable($installer->getTable('cosmicapi/cosmicapi'))
|
18 |
+
->addColumn('token_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
19 |
+
'identity' => true,
|
20 |
+
'unsigned' => true,
|
21 |
+
'nullable' => false,
|
22 |
+
'primary' => true,
|
23 |
+
), 'Id')
|
24 |
+
->addColumn('token_key', Varien_Db_Ddl_Table::TYPE_VARCHAR, null, array(
|
25 |
+
'nullable' => false,
|
26 |
+
), 'Token Key');
|
27 |
+
$installer->getConnection()->createTable($table);
|
28 |
+
$installer->endSetup();
|
app/code/community/CosmicCart/Integration/Block/Adminhtml/Cosmiccart.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
+
*
|
7 |
+
* @category CosmicCart
|
8 |
+
* @package Integration
|
9 |
+
* @copyright Copyright (c) 2015 Cosmic Cart, Inc.
|
10 |
+
* @license CosmicCart Software License https://cosmiccart.com/help/license/software
|
11 |
+
*/
|
12 |
+
|
13 |
+
class CosmicCart_Integration_Block_Adminhtml_Cosmiccart extends Mage_Adminhtml_Block_Widget_Grid_Container
|
14 |
+
{
|
15 |
+
public function __construct()
|
16 |
+
{
|
17 |
+
$this->_controller = 'adminhtml_cosmiccart';
|
18 |
+
$this->_blockGroup = 'cosmiccart_integration';
|
19 |
+
$this->_headerText = Mage::helper('cosmiccart_integration')->__('Cosmiccart Manager');
|
20 |
+
$this->_addButtonLabel = Mage::helper('cosmiccart_integration')->__('Add Cosmiccart');
|
21 |
+
parent::__construct();
|
22 |
+
$this->_removeButton('add');
|
23 |
+
|
24 |
+
$_url = Mage::getModel('adminhtml/url')->getUrl(
|
25 |
+
'adminhtml/integration_batch/new',
|
26 |
+
null
|
27 |
+
);
|
28 |
+
|
29 |
+
$this->addButton(
|
30 |
+
'create_prescription',
|
31 |
+
array(
|
32 |
+
'label' => Mage::helper('cosmiccart_integration')->__('Start new batch'),
|
33 |
+
'onclick' => 'setLocation(\''.$_url.'\')',
|
34 |
+
'class' => 'add'
|
35 |
+
)
|
36 |
+
);
|
37 |
+
}
|
38 |
+
}
|
app/code/community/CosmicCart/Integration/Block/Adminhtml/Cosmiccart/Edit.php
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
+
*
|
7 |
+
* @category CosmicCart
|
8 |
+
* @package Integration
|
9 |
+
* @copyright Copyright (c) 2015 Cosmic Cart, Inc.
|
10 |
+
* @license CosmicCart Software License https://cosmiccart.com/help/license/software
|
11 |
+
*/
|
12 |
+
|
13 |
+
|
14 |
+
class CosmicCart_Integration_Block_Adminhtml_Cosmiccart_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
15 |
+
{
|
16 |
+
public function __construct()
|
17 |
+
{
|
18 |
+
parent::__construct();
|
19 |
+
|
20 |
+
$this->_objectId = 'id';
|
21 |
+
$this->_blockGroup = 'cosmiccart';
|
22 |
+
$this->_controller = 'adminhtml_cosmiccart';
|
23 |
+
|
24 |
+
$this->_updateButton('save', 'label', Mage::helper('cosmiccart_integration')->__('Save Cosmiccart'));
|
25 |
+
$this->_updateButton('delete', 'label', Mage::helper('cosmiccart_integration')->__('Delete Cosmiccart'));
|
26 |
+
|
27 |
+
$this->_addButton('saveandcontinue', array(
|
28 |
+
'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
|
29 |
+
'onclick' => 'saveAndContinueEdit()',
|
30 |
+
'class' => 'save',
|
31 |
+
), -100);
|
32 |
+
|
33 |
+
$this->_formScripts[] = "
|
34 |
+
function toggleEditor() {
|
35 |
+
if (tinyMCE.getInstanceById('cosmiccart_content') == null) {
|
36 |
+
tinyMCE.execCommand('mceAddControl', false, 'cosmiccart_content');
|
37 |
+
} else {
|
38 |
+
tinyMCE.execCommand('mceRemoveControl', false, 'cosmiccart_content');
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
+
function saveAndContinueEdit(){
|
43 |
+
editForm.submit($('edit_form').action+'back/edit/');
|
44 |
+
}
|
45 |
+
";
|
46 |
+
}
|
47 |
+
|
48 |
+
public function getHeaderText()
|
49 |
+
{
|
50 |
+
if( Mage::registry('cosmiccart_data') && Mage::registry('cosmiccart_data')->getId() ) {
|
51 |
+
return Mage::helper('cosmiccart_integration')->__("Edit Cosmiccart '%s'", $this->htmlEscape(Mage::registry('cosmiccart_data')->getTitle()));
|
52 |
+
} else {
|
53 |
+
return Mage::helper('cosmiccart_integration')->__('Add Cosmiccart');
|
54 |
+
}
|
55 |
+
}
|
56 |
+
}
|
app/code/community/CosmicCart/Integration/Block/Adminhtml/Cosmiccart/Edit/Form.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
+
*
|
7 |
+
* @category CosmicCart
|
8 |
+
* @package Integration
|
9 |
+
* @copyright Copyright (c) 2015 Cosmic Cart, Inc.
|
10 |
+
* @license CosmicCart Software License https://cosmiccart.com/help/license/software
|
11 |
+
*/
|
12 |
+
|
13 |
+
|
14 |
+
class CosmicCart_Integration_Block_Adminhtml_Cosmiccart_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
15 |
+
{
|
16 |
+
protected function _prepareForm()
|
17 |
+
{
|
18 |
+
$form = new Varien_Data_Form(array(
|
19 |
+
'id' => 'edit_form',
|
20 |
+
'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
|
21 |
+
'method' => 'post',
|
22 |
+
'enctype' => 'multipart/form-data'
|
23 |
+
)
|
24 |
+
);
|
25 |
+
|
26 |
+
$form->setUseContainer(true);
|
27 |
+
$this->setForm($form);
|
28 |
+
return parent::_prepareForm();
|
29 |
+
}
|
30 |
+
}
|
app/code/community/CosmicCart/Integration/Block/Adminhtml/Cosmiccart/Edit/Tab/Form.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
+
*
|
7 |
+
* @category CosmicCart
|
8 |
+
* @package Integration
|
9 |
+
* @copyright Copyright (c) 2015 Cosmic Cart, Inc.
|
10 |
+
* @license CosmicCart Software License https://cosmiccart.com/help/license/software
|
11 |
+
*/
|
12 |
+
|
13 |
+
|
14 |
+
class CosmicCart_Integration_Block_Adminhtml_Cosmiccart_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
15 |
+
{
|
16 |
+
protected function _prepareForm()
|
17 |
+
{
|
18 |
+
$form = new Varien_Data_Form();
|
19 |
+
$this->setForm($form);
|
20 |
+
$fieldset = $form->addFieldset('cosmiccart_form', array('legend'=>Mage::helper('cosmiccart_integration')->__('Item information')));
|
21 |
+
|
22 |
+
$fieldset->addField('name', 'text', array(
|
23 |
+
'label' => Mage::helper('cosmiccart_integration')->__('Title'),
|
24 |
+
'class' => '',
|
25 |
+
'required' => true,
|
26 |
+
'name' => 'name',
|
27 |
+
));
|
28 |
+
|
29 |
+
$fieldset->addField('cosmiccart_date', 'date', array(
|
30 |
+
'label' => Mage::helper('cosmiccart_integration')->__('Select Date'),
|
31 |
+
'class' => '',
|
32 |
+
'required' => true,
|
33 |
+
'format' => 'yyyy-MM-dd',
|
34 |
+
'name' => 'cosmiccart_date',
|
35 |
+
'image' => $this->getSkinUrl('images/grid-cal.gif')
|
36 |
+
));
|
37 |
+
|
38 |
+
if ( Mage::getSingleton('adminhtml/session')->getCosmiccartData() )
|
39 |
+
{
|
40 |
+
$form->setValues(Mage::getSingleton('adminhtml/session')->getCosmiccartData());
|
41 |
+
Mage::getSingleton('adminhtml/session')->setCosmiccartData(null);
|
42 |
+
} elseif ( Mage::registry('cosmiccart_data') ) {
|
43 |
+
$form->setValues(Mage::registry('cosmiccart_data')->getData());
|
44 |
+
}
|
45 |
+
return parent::_prepareForm();
|
46 |
+
}
|
47 |
+
}
|
app/code/community/CosmicCart/Integration/Block/Adminhtml/Cosmiccart/Edit/Tabs.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
+
*
|
7 |
+
* @category CosmicCart
|
8 |
+
* @package Integration
|
9 |
+
* @copyright Copyright (c) 2015 Cosmic Cart, Inc.
|
10 |
+
* @license CosmicCart Software License https://cosmiccart.com/help/license/software
|
11 |
+
*/
|
12 |
+
|
13 |
+
|
14 |
+
class CosmicCart_Integration_Block_Adminhtml_Cosmiccart_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
15 |
+
{
|
16 |
+
|
17 |
+
public function __construct()
|
18 |
+
{
|
19 |
+
parent::__construct();
|
20 |
+
$this->setId('cosmiccart_tabs');
|
21 |
+
$this->setDestElementId('edit_form');
|
22 |
+
$this->setTitle(Mage::helper('cosmiccart_integration')->__('Cosmiccart Information'));
|
23 |
+
}
|
24 |
+
|
25 |
+
protected function _beforeToHtml()
|
26 |
+
{
|
27 |
+
$this->addTab('form_section', array(
|
28 |
+
'label' => Mage::helper('cosmiccart_integration')->__('Cosmiccart Information'),
|
29 |
+
'title' => Mage::helper('cosmiccart_integration')->__('Cosmiccart Information'),
|
30 |
+
'content' => $this->getLayout()->createBlock('cosmiccart/adminhtml_cosmiccart_edit_tab_form')->toHtml(),
|
31 |
+
));
|
32 |
+
|
33 |
+
return parent::_beforeToHtml();
|
34 |
+
}
|
35 |
+
}
|
app/code/community/CosmicCart/Integration/Block/Adminhtml/Cosmiccart/Grid.php
ADDED
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
+
*
|
7 |
+
* @category CosmicCart
|
8 |
+
* @package Integration
|
9 |
+
* @copyright Copyright (c) 2015 Cosmic Cart, Inc.
|
10 |
+
* @license CosmicCart Software License https://cosmiccart.com/help/license/software
|
11 |
+
*/
|
12 |
+
|
13 |
+
|
14 |
+
class CosmicCart_Integration_Block_Adminhtml_Cosmiccart_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
15 |
+
{
|
16 |
+
public function __construct()
|
17 |
+
{
|
18 |
+
parent::__construct();
|
19 |
+
$this->setId('cosmiccartGrid');
|
20 |
+
$this->setDefaultSort('batch_id');
|
21 |
+
$this->setDefaultDir('ASC');
|
22 |
+
$this->setSaveParametersInSession(true);
|
23 |
+
}
|
24 |
+
|
25 |
+
protected function _prepareCollection()
|
26 |
+
{
|
27 |
+
$collection = Mage::getModel('cosmiccart_integration/batch')->getCollection();
|
28 |
+
$this->setCollection($collection);
|
29 |
+
return parent::_prepareCollection();
|
30 |
+
}
|
31 |
+
|
32 |
+
protected function _prepareColumns()
|
33 |
+
{
|
34 |
+
$this->addColumn('batch_id', array(
|
35 |
+
'header' => Mage::helper('cosmiccart_integration')->__('ID'),
|
36 |
+
'align' =>'right',
|
37 |
+
'width' => '50px',
|
38 |
+
'index' => 'batch_id',
|
39 |
+
));
|
40 |
+
|
41 |
+
$this->addColumn('start_time', array(
|
42 |
+
'header' => Mage::helper('cosmiccart_integration')->__('Start Time'),
|
43 |
+
'align' =>'left',
|
44 |
+
'index' => 'start_time',
|
45 |
+
));
|
46 |
+
|
47 |
+
$this->addColumn('end_time', array(
|
48 |
+
'header' => Mage::helper('cosmiccart_integration')->__('End Time'),
|
49 |
+
'align' =>'left',
|
50 |
+
'index' => 'end_time',
|
51 |
+
));
|
52 |
+
$this->addColumn('total_row_count', array(
|
53 |
+
'header' => Mage::helper('cosmiccart_integration')->__('Simple Product Row Count'),
|
54 |
+
'align' =>'left',
|
55 |
+
'index' => 'total_row_count',
|
56 |
+
));
|
57 |
+
$this->addColumn('number_of_processed_row', array(
|
58 |
+
'header' => Mage::helper('cosmiccart_integration')->__('Simple Product Processed Row'),
|
59 |
+
'align' =>'left',
|
60 |
+
'index' => 'number_of_processed_row',
|
61 |
+
));
|
62 |
+
$this->addColumn('config_total_row_count', array(
|
63 |
+
'header' => Mage::helper('cosmiccart_integration')->__('Config Product Row Count'),
|
64 |
+
'align' =>'left',
|
65 |
+
'index' => 'config_total_row_count',
|
66 |
+
));
|
67 |
+
$this->addColumn('config_number_of_processed_row', array(
|
68 |
+
'header' => Mage::helper('cosmiccart_integration')->__('Config Product Processed Row'),
|
69 |
+
'align' =>'left',
|
70 |
+
'index' => 'config_number_of_processed_row',
|
71 |
+
));
|
72 |
+
$this->addColumn('current_stage', array(
|
73 |
+
'header' => Mage::helper('cosmiccart_integration')->__('Current Stage'),
|
74 |
+
'align' =>'left',
|
75 |
+
'index' => 'current_stage',
|
76 |
+
));
|
77 |
+
$this->addColumn('comment', array(
|
78 |
+
'header' => Mage::helper('cosmiccart_integration')->__('Comment'),
|
79 |
+
'align' =>'left',
|
80 |
+
'index' => 'comment',
|
81 |
+
));
|
82 |
+
|
83 |
+
return parent::_prepareColumns();
|
84 |
+
}
|
85 |
+
|
86 |
+
protected function _prepareMassaction()
|
87 |
+
{
|
88 |
+
$this->setMassactionIdField('cosmiccart_id');
|
89 |
+
$this->getMassactionBlock()->setFormFieldName('cosmiccart');
|
90 |
+
|
91 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
92 |
+
'label' => Mage::helper('cosmiccart_integration')->__('Delete'),
|
93 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
94 |
+
'confirm' => Mage::helper('cosmiccart_integration')->__('Are you sure?')
|
95 |
+
));
|
96 |
+
|
97 |
+
return $this;
|
98 |
+
}
|
99 |
+
|
100 |
+
public function getRowUrl($row)
|
101 |
+
{
|
102 |
+
}
|
103 |
+
|
104 |
+
}
|
app/code/community/CosmicCart/Integration/Block/Adminhtml/Storeselect.php
ADDED
@@ -0,0 +1,237 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
+
*
|
7 |
+
* @category CosmicCart
|
8 |
+
* @package Integration
|
9 |
+
* @copyright Copyright (c) 2015 Cosmic Cart, Inc.
|
10 |
+
* @license CosmicCart Software License https://cosmiccart.com/help/license/software
|
11 |
+
*/
|
12 |
+
|
13 |
+
|
14 |
+
class CosmicCart_Integration_Block_Adminhtml_Storeselect extends Mage_Adminhtml_Block_Template
|
15 |
+
{
|
16 |
+
/**
|
17 |
+
* Key in config for store switcher hint
|
18 |
+
*/
|
19 |
+
const XPATH_HINT_KEY = 'store_switcher';
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @var array
|
23 |
+
*/
|
24 |
+
protected $_storeIds;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Name of store variable
|
28 |
+
*
|
29 |
+
* @var string
|
30 |
+
*/
|
31 |
+
protected $_storeVarName = 'store';
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Url for store switcher hint
|
35 |
+
*
|
36 |
+
* @var string
|
37 |
+
*/
|
38 |
+
protected $_hintUrl;
|
39 |
+
|
40 |
+
/**
|
41 |
+
* @var bool
|
42 |
+
*/
|
43 |
+
protected $_hasDefaultOption = true;
|
44 |
+
|
45 |
+
public function __construct()
|
46 |
+
{
|
47 |
+
parent::__construct();
|
48 |
+
$this->setTemplate('store/switcher.phtml');
|
49 |
+
$this->setUseConfirm(true);
|
50 |
+
$this->setUseAjax(true);
|
51 |
+
$this->setDefaultStoreName($this->__('All Store Views'));
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Deprecated
|
56 |
+
*/
|
57 |
+
public function getWebsiteCollection()
|
58 |
+
{
|
59 |
+
$collection = Mage::getModel('core/website')->getResourceCollection();
|
60 |
+
|
61 |
+
$websiteIds = $this->getWebsiteIds();
|
62 |
+
if (!is_null($websiteIds)) {
|
63 |
+
$collection->addIdFilter($this->getWebsiteIds());
|
64 |
+
}
|
65 |
+
|
66 |
+
return $collection->load();
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Get websites
|
71 |
+
*
|
72 |
+
* @return array
|
73 |
+
*/
|
74 |
+
public function getWebsites()
|
75 |
+
{
|
76 |
+
$websites = Mage::app()->getWebsites();
|
77 |
+
if ($websiteIds = $this->getWebsiteIds()) {
|
78 |
+
foreach ($websites as $websiteId => $website) {
|
79 |
+
if (!in_array($websiteId, $websiteIds)) {
|
80 |
+
unset($websites[$websiteId]);
|
81 |
+
}
|
82 |
+
}
|
83 |
+
}
|
84 |
+
return $websites;
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Deprecated
|
89 |
+
*/
|
90 |
+
public function getGroupCollection($website)
|
91 |
+
{
|
92 |
+
if (!$website instanceof Mage_Core_Model_Website) {
|
93 |
+
$website = Mage::getModel('core/website')->load($website);
|
94 |
+
}
|
95 |
+
return $website->getGroupCollection();
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Get store groups for specified website
|
100 |
+
*
|
101 |
+
* @param Mage_Core_Model_Website $website
|
102 |
+
* @return array
|
103 |
+
*/
|
104 |
+
public function getStoreGroups($website)
|
105 |
+
{
|
106 |
+
if (!$website instanceof Mage_Core_Model_Website) {
|
107 |
+
$website = Mage::app()->getWebsite($website);
|
108 |
+
}
|
109 |
+
return $website->getGroups();
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Deprecated
|
114 |
+
*/
|
115 |
+
public function getStoreCollection($group)
|
116 |
+
{
|
117 |
+
if (!$group instanceof Mage_Core_Model_Store_Group) {
|
118 |
+
$group = Mage::getModel('core/store_group')->load($group);
|
119 |
+
}
|
120 |
+
$stores = $group->getStoreCollection();
|
121 |
+
$_storeIds = $this->getStoreIds();
|
122 |
+
if (!empty($_storeIds)) {
|
123 |
+
$stores->addIdFilter($_storeIds);
|
124 |
+
}
|
125 |
+
return $stores;
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Get store views for specified store group
|
130 |
+
*
|
131 |
+
* @param Mage_Core_Model_Store_Group $group
|
132 |
+
* @return array
|
133 |
+
*/
|
134 |
+
public function getStores($group)
|
135 |
+
{
|
136 |
+
if (!$group instanceof Mage_Core_Model_Store_Group) {
|
137 |
+
$group = Mage::app()->getGroup($group);
|
138 |
+
}
|
139 |
+
$stores = $group->getStores();
|
140 |
+
if ($storeIds = $this->getStoreIds()) {
|
141 |
+
foreach ($stores as $storeId => $store) {
|
142 |
+
if (!in_array($storeId, $storeIds)) {
|
143 |
+
unset($stores[$storeId]);
|
144 |
+
}
|
145 |
+
}
|
146 |
+
}
|
147 |
+
return $stores;
|
148 |
+
}
|
149 |
+
|
150 |
+
public function getSwitchUrl()
|
151 |
+
{
|
152 |
+
if ($url = $this->getData('switch_url')) {
|
153 |
+
return $url;
|
154 |
+
}
|
155 |
+
return $this->getUrl('*/*/*', array('_current' => true, $this->_storeVarName => null));
|
156 |
+
}
|
157 |
+
|
158 |
+
public function setStoreVarName($varName)
|
159 |
+
{
|
160 |
+
$this->_storeVarName = $varName;
|
161 |
+
return $this;
|
162 |
+
}
|
163 |
+
|
164 |
+
public function getStoreId()
|
165 |
+
{
|
166 |
+
return $this->getRequest()->getParam($this->_storeVarName);
|
167 |
+
}
|
168 |
+
|
169 |
+
public function setStoreIds($storeIds)
|
170 |
+
{
|
171 |
+
$this->_storeIds = $storeIds;
|
172 |
+
return $this;
|
173 |
+
}
|
174 |
+
|
175 |
+
public function getStoreIds()
|
176 |
+
{
|
177 |
+
return $this->_storeIds;
|
178 |
+
}
|
179 |
+
|
180 |
+
public function isShow()
|
181 |
+
{
|
182 |
+
return !Mage::app()->isSingleStoreMode();
|
183 |
+
}
|
184 |
+
|
185 |
+
protected function _toHtml()
|
186 |
+
{
|
187 |
+
return parent::_toHtml();
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Set/Get whether the switcher should show default option
|
192 |
+
*
|
193 |
+
* @param bool $hasDefaultOption
|
194 |
+
* @return bool
|
195 |
+
*/
|
196 |
+
public function hasDefaultOption($hasDefaultOption = null)
|
197 |
+
{
|
198 |
+
if (null !== $hasDefaultOption) {
|
199 |
+
$this->_hasDefaultOption = $hasDefaultOption;
|
200 |
+
}
|
201 |
+
return $this->_hasDefaultOption;
|
202 |
+
}
|
203 |
+
|
204 |
+
/**
|
205 |
+
* Return url for store switcher hint
|
206 |
+
*
|
207 |
+
* @return string
|
208 |
+
*/
|
209 |
+
public function getHintUrl()
|
210 |
+
{
|
211 |
+
if (null === $this->_hintUrl) {
|
212 |
+
$this->_hintUrl = Mage::helper('core/hint')->getHintByCode(self::XPATH_HINT_KEY);
|
213 |
+
}
|
214 |
+
return $this->_hintUrl;
|
215 |
+
}
|
216 |
+
|
217 |
+
/**
|
218 |
+
* Return store switcher hint html
|
219 |
+
*
|
220 |
+
* @return string
|
221 |
+
*/
|
222 |
+
public function getHintHtml()
|
223 |
+
{
|
224 |
+
$html = '';
|
225 |
+
$url = $this->getHintUrl();
|
226 |
+
if ($url) {
|
227 |
+
$html = '<a'
|
228 |
+
. ' href="'. $this->escapeUrl($url) . '"'
|
229 |
+
. ' onclick="this.target=\'_blank\'"'
|
230 |
+
. ' title="' . $this->__('What is this?') . '"'
|
231 |
+
. ' class="link-store-scope">'
|
232 |
+
. $this->__('What is this?')
|
233 |
+
. '</a>';
|
234 |
+
}
|
235 |
+
return $html;
|
236 |
+
}
|
237 |
+
}
|
app/code/community/CosmicCart/Integration/Block/Cosmiccart.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
+
*
|
7 |
+
* @category CosmicCart
|
8 |
+
* @package Integration
|
9 |
+
* @copyright Copyright (c) 2015 Cosmic Cart, Inc.
|
10 |
+
* @license CosmicCart Software License https://cosmiccart.com/help/license/software
|
11 |
+
*/
|
12 |
+
|
13 |
+
class CosmicCart_Integration_Block_Cosmiccart extends Mage_Core_Block_Template
|
14 |
+
{
|
15 |
+
public function _prepareLayout()
|
16 |
+
{
|
17 |
+
return parent::_prepareLayout();
|
18 |
+
}
|
19 |
+
}
|
app/code/community/CosmicCart/Integration/Helper/Data.php
CHANGED
@@ -1,18 +1,84 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
* NOTICE OF LICENSE
|
4 |
-
*
|
5 |
-
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
-
*
|
7 |
-
* @category CosmicCart
|
8 |
-
* @package Integration
|
9 |
-
* @copyright Copyright (c)
|
10 |
-
* @license
|
11 |
-
*/
|
12 |
-
|
13 |
-
|
14 |
-
class CosmicCart_Integration_Helper_Data extends Mage_Core_Helper_Abstract
|
15 |
-
{
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
}
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
+
*
|
7 |
+
* @category CosmicCart
|
8 |
+
* @package Integration
|
9 |
+
* @copyright Copyright (c) 2015 Cosmic Cart, Inc.
|
10 |
+
* @license CosmicCart Software License https://cosmiccart.com/help/license/software
|
11 |
+
*/
|
12 |
+
|
13 |
+
|
14 |
+
class CosmicCart_Integration_Helper_Data extends Mage_Core_Helper_Abstract
|
15 |
+
{
|
16 |
+
const CRON_EXPORT_ENABLED = 'cosmiccart/configurable_cron/enable';
|
17 |
+
const COSMICCART_PAYMENT_METHOD_CODE = 'cosmiccart/options/payment_method';
|
18 |
+
|
19 |
+
|
20 |
+
const COSMICCART_API_ENVIRONMENT_PATH = 'cosmiccart/options/environment';
|
21 |
+
|
22 |
+
const COSMICCART_API_STAGING_URL_PATH = 'cosmiccart/options/staging_api_url';
|
23 |
+
const COSMICCART_API_STAGING_SFTP_PATH = 'cosmiccart/options/staging_api_sftp';
|
24 |
+
|
25 |
+
const COSMICCART_API_PRODUCTION_URL_PATH = 'cosmiccart/options/production_api_url';
|
26 |
+
const COSMICCART_API_PRODUCTION_SFTP_PATH = 'cosmiccart/options/production_api_sftp';
|
27 |
+
|
28 |
+
const COSMICCART_API_LOCAL_URL_PATH = 'cosmiccart/options/local_api_url';
|
29 |
+
const COSMICCART_API_LOCAL_SFTP_PATH = 'cosmiccart/options/local_api_sftp';
|
30 |
+
|
31 |
+
public function checkBatch($batch_id)
|
32 |
+
{
|
33 |
+
$batch = Mage::getModel('cosmiccart_integration/batch')->load($batch_id);
|
34 |
+
//This will return batch Id or null
|
35 |
+
return $batch->getId();
|
36 |
+
}
|
37 |
+
|
38 |
+
public function cronAutoexportEnabled()
|
39 |
+
{
|
40 |
+
return Mage::getStoreConfigFlag(self::CRON_EXPORT_ENABLED);
|
41 |
+
}
|
42 |
+
|
43 |
+
public function getCosmicCartPaymentMethod()
|
44 |
+
{
|
45 |
+
return Mage::getStoreConfig(self::COSMICCART_PAYMENT_METHOD_CODE);
|
46 |
+
}
|
47 |
+
|
48 |
+
public function getApiUrl()
|
49 |
+
{
|
50 |
+
$env = $this->getEnvironment();
|
51 |
+
if ($env == CosmicCart_Integration_Model_System_Config_Source_Environment::COSMICCART_ENV_PRODUCTION) {
|
52 |
+
return Mage::getStoreConfig(self::COSMICCART_API_PRODUCTION_URL_PATH);
|
53 |
+
} else if ($env == CosmicCart_Integration_Model_System_Config_Source_Environment::COSMICCART_ENV_LOCAL) {
|
54 |
+
return Mage::getStoreConfig(self::COSMICCART_API_LOCAL_URL_PATH);
|
55 |
+
}
|
56 |
+
//Return Staging as default
|
57 |
+
return Mage::getStoreConfig(self::COSMICCART_API_STAGING_URL_PATH);
|
58 |
+
}
|
59 |
+
|
60 |
+
public function getSftpUrl()
|
61 |
+
{
|
62 |
+
$env = $this->getEnvironment();
|
63 |
+
if ($env == CosmicCart_Integration_Model_System_Config_Source_Environment::COSMICCART_ENV_PRODUCTION) {
|
64 |
+
return Mage::getStoreConfig(self::COSMICCART_API_PRODUCTION_SFTP_PATH);
|
65 |
+
} else if ($env == CosmicCart_Integration_Model_System_Config_Source_Environment::COSMICCART_ENV_LOCAL) {
|
66 |
+
return Mage::getStoreConfig(self::COSMICCART_API_LOCAL_SFTP_PATH);
|
67 |
+
}
|
68 |
+
//Return Staging as default
|
69 |
+
return Mage::getStoreConfig(self::COSMICCART_API_STAGING_SFTP_PATH);
|
70 |
+
}
|
71 |
+
|
72 |
+
public function getEnvironment()
|
73 |
+
{
|
74 |
+
$env = Mage::getStoreConfig(self::COSMICCART_API_ENVIRONMENT_PATH);
|
75 |
+
if (empty($env)) {
|
76 |
+
//Set Staging as default if not set
|
77 |
+
$env = CosmicCart_Integration_Model_System_Config_Source_Environment::COSMICCART_ENV_STAGING;
|
78 |
+
}
|
79 |
+
|
80 |
+
return $env;
|
81 |
+
}
|
82 |
+
|
83 |
+
|
84 |
}
|
app/code/community/CosmicCart/Integration/Model/AccessToken.php
CHANGED
@@ -1,58 +1,64 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
* NOTICE OF LICENSE
|
4 |
-
*
|
5 |
-
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
-
*
|
7 |
-
* @category CosmicCart
|
8 |
-
* @package Integration
|
9 |
-
* @copyright Copyright (c)
|
10 |
-
* @license
|
11 |
-
*/
|
12 |
-
|
13 |
-
|
14 |
-
/**
|
15 |
-
* AccessToken model
|
16 |
-
*
|
17 |
-
* @method CosmicCart_Integration_Model_Resource_AccessToken _getResource()
|
18 |
-
* @method CosmicCart_Integration_Model_Resource_AccessToken getResource()
|
19 |
-
* @method string getAccessToken()
|
20 |
-
* @method CosmicCart_Integration_Model_AccessToken setAccessToken(string $value)
|
21 |
-
* @method string getRefreshToken()
|
22 |
-
* @method CosmicCart_Integration_Model_AccessToken setRefreshToken(string $value)
|
23 |
-
* @method string getTokenType()
|
24 |
-
* @method CosmicCart_Integration_Model_AccessToken setTokenType(string $value)
|
25 |
-
* @method string getScope()
|
26 |
-
* @method CosmicCart_Integration_Model_AccessToken setScope(string $value)
|
27 |
-
* @method date getExpires()
|
28 |
-
* @method CosmicCart_Integration_Model_AccessToken setExpires(date $value)
|
29 |
-
*/
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
}
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
+
*
|
7 |
+
* @category CosmicCart
|
8 |
+
* @package Integration
|
9 |
+
* @copyright Copyright (c) 2015 Cosmic Cart, Inc.
|
10 |
+
* @license CosmicCart Software License https://cosmiccart.com/help/license/software
|
11 |
+
*/
|
12 |
+
|
13 |
+
|
14 |
+
/**
|
15 |
+
* AccessToken model
|
16 |
+
*
|
17 |
+
* @method CosmicCart_Integration_Model_Resource_AccessToken _getResource()
|
18 |
+
* @method CosmicCart_Integration_Model_Resource_AccessToken getResource()
|
19 |
+
* @method string getAccessToken()
|
20 |
+
* @method CosmicCart_Integration_Model_AccessToken setAccessToken(string $value)
|
21 |
+
* @method string getRefreshToken()
|
22 |
+
* @method CosmicCart_Integration_Model_AccessToken setRefreshToken(string $value)
|
23 |
+
* @method string getTokenType()
|
24 |
+
* @method CosmicCart_Integration_Model_AccessToken setTokenType(string $value)
|
25 |
+
* @method string getScope()
|
26 |
+
* @method CosmicCart_Integration_Model_AccessToken setScope(string $value)
|
27 |
+
* @method date getExpires()
|
28 |
+
* @method CosmicCart_Integration_Model_AccessToken setExpires(date $value)
|
29 |
+
*/
|
30 |
+
class CosmicCart_Integration_Model_AccessToken extends Mage_Core_Model_Abstract
|
31 |
+
{
|
32 |
+
protected $_resourceCollectionName = 'cosmiccart_integration/accessToken_collection';
|
33 |
+
|
34 |
+
protected function _construct()
|
35 |
+
{
|
36 |
+
$this->_init('cosmiccart_integration/accessToken');
|
37 |
+
}
|
38 |
+
|
39 |
+
public function exists()
|
40 |
+
{
|
41 |
+
$existing = $this->findExisting();
|
42 |
+
return !empty($existing);
|
43 |
+
}
|
44 |
+
|
45 |
+
public function findExisting()
|
46 |
+
{
|
47 |
+
$accessToken = null;
|
48 |
+
|
49 |
+
$collection = $this->getCollection();
|
50 |
+
if ($collection->getSize() > 0) {
|
51 |
+
$accessToken = $collection->getFirstItem();
|
52 |
+
}
|
53 |
+
|
54 |
+
return $accessToken;
|
55 |
+
}
|
56 |
+
|
57 |
+
public function deleteExisting()
|
58 |
+
{
|
59 |
+
foreach ($this->getCollection() as $accessToken) {
|
60 |
+
$accessToken->delete();
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
}
|
app/code/community/CosmicCart/Integration/Model/Adminhtml/System/Config/Backend/Dynamic/Cron.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
+
*
|
7 |
+
* @category CosmicCart
|
8 |
+
* @package Integration
|
9 |
+
* @copyright Copyright (c) 2015 Cosmic Cart, Inc.
|
10 |
+
* @license CosmicCart Software License https://cosmiccart.com/help/license/software
|
11 |
+
*/
|
12 |
+
|
13 |
+
class CosmicCart_Integration_Model_Adminhtml_System_Config_Backend_Dynamic_Cron extends Mage_Core_Model_Config_Data
|
14 |
+
{
|
15 |
+
const CRON_STRING_PATH = 'crontab/jobs/integration_cosmiccart_generate_batch/schedule/cron_expr';
|
16 |
+
|
17 |
+
protected function isEnabled()
|
18 |
+
{
|
19 |
+
$enabled = $this->getData('groups/configurable_cron/fields/enable/value');
|
20 |
+
$flag = strtolower($enabled);
|
21 |
+
if (!empty($flag) && 'false' !== $flag) {
|
22 |
+
return true;
|
23 |
+
} else {
|
24 |
+
return false;
|
25 |
+
}
|
26 |
+
}
|
27 |
+
|
28 |
+
protected function _afterSave()
|
29 |
+
{
|
30 |
+
if (!$this->isEnabled()) {
|
31 |
+
$config = Mage::getModel('core/config_data')->load(self::CRON_STRING_PATH, 'path');
|
32 |
+
if ($config->getId()) {
|
33 |
+
$config->delete();
|
34 |
+
}
|
35 |
+
return $this;
|
36 |
+
}
|
37 |
+
|
38 |
+
$time = $this->getData('groups/configurable_cron/fields/time/value');
|
39 |
+
|
40 |
+
$cronExprArray = array(
|
41 |
+
intval($time[1]), # Minute
|
42 |
+
intval($time[0]), # Hour
|
43 |
+
'*', # Day of the Month
|
44 |
+
'*', # Month of the Year
|
45 |
+
'*', # Day of the Week
|
46 |
+
);
|
47 |
+
$cronExprString = join(' ', $cronExprArray);
|
48 |
+
try {
|
49 |
+
Mage::getModel('core/config_data')
|
50 |
+
->load(self::CRON_STRING_PATH, 'path')
|
51 |
+
->setValue($cronExprString)
|
52 |
+
->setPath(self::CRON_STRING_PATH)
|
53 |
+
->save();
|
54 |
+
} catch (Exception $e) {
|
55 |
+
throw new Exception(Mage::helper('cron')->__('Unable to save the cron expression.'));
|
56 |
+
|
57 |
+
}
|
58 |
+
|
59 |
+
return $this;
|
60 |
+
}
|
61 |
+
}
|
app/code/community/CosmicCart/Integration/Model/Adminhtml/System/Config/Ean.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
+
*
|
7 |
+
* @category CosmicCart
|
8 |
+
* @package Integration
|
9 |
+
* @copyright Copyright (c) 2015 Cosmic Cart, Inc.
|
10 |
+
* @license CosmicCart Software License https://cosmiccart.com/help/license/software
|
11 |
+
*/
|
12 |
+
|
13 |
+
class CosmicCart_Integration_Model_Adminhtml_System_Config_Ean extends Mage_Core_Model_Config_Data
|
14 |
+
{
|
15 |
+
public function save()
|
16 |
+
{
|
17 |
+
$ean = $this->getValue();
|
18 |
+
|
19 |
+
// Using the SKU as the attribute causes a SQL error
|
20 |
+
if (strtolower($ean) == "sku") {
|
21 |
+
Mage::throwException("SKU cannot be used as the EAN/UPC attribute.");
|
22 |
+
}
|
23 |
+
|
24 |
+
// Check to see if the attribute they entered is a valid attribute
|
25 |
+
$attr = Mage::getResourceModel('catalog/eav_attribute')
|
26 |
+
->loadByCode('catalog_product',$ean);
|
27 |
+
|
28 |
+
if (!$attr->getId()) {
|
29 |
+
Mage::throwException($ean . ' is not a valid attribute.');
|
30 |
+
}
|
31 |
+
|
32 |
+
return parent::save();
|
33 |
+
}
|
34 |
+
}
|
app/code/community/CosmicCart/Integration/Model/Adminhtml/System/Config/Source/Payment.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* NOTICE OF LICENSE
|
5 |
+
*
|
6 |
+
* This source file is subject to the Cosmic Cart license, a commercial license.
|
7 |
+
*
|
8 |
+
* @category CosmicCart
|
9 |
+
* @package Integration
|
10 |
+
* @copyright Copyright (c) 2015 Cosmic Cart, Inc.
|
11 |
+
* @license CosmicCart Software License https://cosmiccart.com/help/license/software
|
12 |
+
*/
|
13 |
+
|
14 |
+
|
15 |
+
class CosmicCart_Integration_Model_Adminhtml_System_Config_Source_Payment
|
16 |
+
{
|
17 |
+
/**
|
18 |
+
* Options getter
|
19 |
+
*
|
20 |
+
* @return array
|
21 |
+
*/
|
22 |
+
public function toOptionArray()
|
23 |
+
{
|
24 |
+
return $this->_getPaymentMethods();
|
25 |
+
}
|
26 |
+
|
27 |
+
private function _getPaymentMethods()
|
28 |
+
{
|
29 |
+
$payments = Mage::getSingleton('payment/config')->getActiveMethods();
|
30 |
+
$methods = array(array('value' => '', 'label' => Mage::helper('adminhtml')->__('--Please Select--')));
|
31 |
+
|
32 |
+
foreach ($payments as $paymentCode => $paymentModel) {
|
33 |
+
//Let's skip methods that can refund online
|
34 |
+
try {
|
35 |
+
if ($paymentModel->canRefund()) {
|
36 |
+
continue;
|
37 |
+
}
|
38 |
+
} catch (Exception $e) {
|
39 |
+
Mage::log($e->getMessage());
|
40 |
+
continue;
|
41 |
+
}
|
42 |
+
|
43 |
+
if ($paymentModel instanceof Mage_Payment_Model_Method_Cc) {
|
44 |
+
continue;
|
45 |
+
}
|
46 |
+
|
47 |
+
if ($paymentCode == 'free') {
|
48 |
+
continue;
|
49 |
+
}
|
50 |
+
|
51 |
+
$paymentTitle = Mage::getStoreConfig('payment/' . $paymentCode . '/title');
|
52 |
+
$methods[$paymentCode] = array(
|
53 |
+
'label' => $paymentTitle,
|
54 |
+
'value' => $paymentCode,
|
55 |
+
);
|
56 |
+
}
|
57 |
+
|
58 |
+
return $methods;
|
59 |
+
}
|
60 |
+
|
61 |
+
}
|
app/code/community/CosmicCart/Integration/Model/Api.php
DELETED
@@ -1,41 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
* NOTICE OF LICENSE
|
4 |
-
*
|
5 |
-
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
-
*
|
7 |
-
* @category CosmicCart
|
8 |
-
* @package Integration
|
9 |
-
* @copyright Copyright (c) 2014 Cosmic Cart, Inc.
|
10 |
-
* @license Proprietary
|
11 |
-
*/
|
12 |
-
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Integration Test API
|
16 |
-
*
|
17 |
-
* @category Local
|
18 |
-
* @package CosmicCart_Integration
|
19 |
-
* @author Erik Dannenberg <erik.dannenberg@bbe-consulting.de>
|
20 |
-
*/
|
21 |
-
class CosmicCart_Integration_Model_Api extends CosmicCart_Integration_Model_Api_Resource {
|
22 |
-
|
23 |
-
// constructor
|
24 |
-
public function __construct()
|
25 |
-
{
|
26 |
-
}
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Says hello
|
30 |
-
*
|
31 |
-
* @param string name to greet
|
32 |
-
* @return string the greeting
|
33 |
-
*/
|
34 |
-
public function helloWorld($name) {
|
35 |
-
if ( $name != '' ) {
|
36 |
-
return sprintf('Hello %s! Nice day isn\'t it?', $name);
|
37 |
-
} else {
|
38 |
-
$this->_fault('myerror_code');
|
39 |
-
}
|
40 |
-
}
|
41 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/CosmicCart/Integration/Model/Api/Resource.php
DELETED
@@ -1,28 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
* NOTICE OF LICENSE
|
4 |
-
*
|
5 |
-
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
-
*
|
7 |
-
* @category CosmicCart
|
8 |
-
* @package Integration
|
9 |
-
* @copyright Copyright (c) 2014 Cosmic Cart, Inc.
|
10 |
-
* @license Proprietary
|
11 |
-
*/
|
12 |
-
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Integration API base class
|
16 |
-
*
|
17 |
-
* @category Local
|
18 |
-
* @package CosmicCart_Integration
|
19 |
-
* @author Erik Dannenberg <erik.dannenberg@bbe-consulting.de>
|
20 |
-
*/
|
21 |
-
class CosmicCart_Integration_Model_Api_Resource extends Mage_Api_Model_Resource_Abstract
|
22 |
-
{
|
23 |
-
// constructor
|
24 |
-
public function __construct()
|
25 |
-
{
|
26 |
-
}
|
27 |
-
|
28 |
-
} // Class CosmicCart_Integration_Model_Api_Resource End
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/CosmicCart/Integration/Model/Api/V2.php
DELETED
@@ -1,25 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
* NOTICE OF LICENSE
|
4 |
-
*
|
5 |
-
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
-
*
|
7 |
-
* @category CosmicCart
|
8 |
-
* @package Integration
|
9 |
-
* @copyright Copyright (c) 2014 Cosmic Cart, Inc.
|
10 |
-
* @license Proprietary
|
11 |
-
*/
|
12 |
-
|
13 |
-
/**
|
14 |
-
* The class that actually get's called for V2 api calls,
|
15 |
-
* usually the business logic is the same for each api so
|
16 |
-
* we just extend from the v1 api class and be done with it.
|
17 |
-
*
|
18 |
-
*/
|
19 |
-
class CosmicCart_Integration_Model_Api_V2 extends CosmicCart_Integration_Model_Api
|
20 |
-
{
|
21 |
-
// constructor
|
22 |
-
public function __construct()
|
23 |
-
{
|
24 |
-
}
|
25 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/CosmicCart/Integration/Model/Batch.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
+
*
|
7 |
+
* @category CosmicCart
|
8 |
+
* @package Integration
|
9 |
+
* @copyright Copyright (c) 2015 Cosmic Cart, Inc.
|
10 |
+
* @license CosmicCart Software License https://cosmiccart.com/help/license/software
|
11 |
+
*/
|
12 |
+
|
13 |
+
|
14 |
+
class CosmicCart_Integration_Model_Batch extends Mage_Core_Model_Abstract
|
15 |
+
{
|
16 |
+
public function _construct()
|
17 |
+
{
|
18 |
+
parent::_construct();
|
19 |
+
$this->_init('cosmiccart_integration/batch');
|
20 |
+
}
|
21 |
+
|
22 |
+
public function startBatchSession()
|
23 |
+
{
|
24 |
+
$data = array();
|
25 |
+
$data['start_time'] = '';
|
26 |
+
$data['end_time'] = '';
|
27 |
+
$data['total_row_count'] = 0;
|
28 |
+
$data['config_total_row_count'] = 0;
|
29 |
+
$data['number_of_processed_row'] = 0;
|
30 |
+
$data['config_number_of_processed_row'] = 0;
|
31 |
+
$data['current_stage'] = 0;
|
32 |
+
$data['comment'] = 'Initializing...';
|
33 |
+
$data['num_of_times_retried'] = 0;
|
34 |
+
|
35 |
+
$this->setData($data)
|
36 |
+
->save();
|
37 |
+
|
38 |
+
return $this;
|
39 |
+
}
|
40 |
+
}
|
app/code/community/CosmicCart/Integration/Model/Client.php
CHANGED
@@ -1,51 +1,56 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
* NOTICE OF LICENSE
|
4 |
-
*
|
5 |
-
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
-
*
|
7 |
-
* @category CosmicCart
|
8 |
-
* @package Integration
|
9 |
-
* @copyright Copyright (c)
|
10 |
-
* @license
|
11 |
-
*/
|
12 |
-
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Client model
|
16 |
-
*
|
17 |
-
* @method string getClientId()
|
18 |
-
* @method CosmicCart_Integration_Model_Client setClientId(string $value)
|
19 |
-
* @method string getClientSecret()
|
20 |
-
* @method CosmicCart_Integration_Model_Client setClientSecret(string $value)
|
21 |
-
*/
|
22 |
-
class CosmicCart_Integration_Model_Client extends Mage_Core_Model_Abstract
|
23 |
-
{
|
24 |
-
protected $_resourceCollectionName = 'cosmiccart_integration/client_collection';
|
25 |
-
|
26 |
-
protected function _construct()
|
27 |
-
{
|
28 |
-
$this->_init('cosmiccart_integration/client');
|
29 |
-
}
|
30 |
-
|
31 |
-
public function exists()
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
+
*
|
7 |
+
* @category CosmicCart
|
8 |
+
* @package Integration
|
9 |
+
* @copyright Copyright (c) 2015 Cosmic Cart, Inc.
|
10 |
+
* @license CosmicCart Software License https://cosmiccart.com/help/license/software
|
11 |
+
*/
|
12 |
+
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Client model
|
16 |
+
*
|
17 |
+
* @method string getClientId()
|
18 |
+
* @method CosmicCart_Integration_Model_Client setClientId(string $value)
|
19 |
+
* @method string getClientSecret()
|
20 |
+
* @method CosmicCart_Integration_Model_Client setClientSecret(string $value)
|
21 |
+
*/
|
22 |
+
class CosmicCart_Integration_Model_Client extends Mage_Core_Model_Abstract
|
23 |
+
{
|
24 |
+
protected $_resourceCollectionName = 'cosmiccart_integration/client_collection';
|
25 |
+
|
26 |
+
protected function _construct()
|
27 |
+
{
|
28 |
+
$this->_init('cosmiccart_integration/client');
|
29 |
+
}
|
30 |
+
|
31 |
+
public function exists()
|
32 |
+
{
|
33 |
+
$existing = $this->findExisting();
|
34 |
+
return !empty($existing);
|
35 |
+
}
|
36 |
+
|
37 |
+
public function findExisting()
|
38 |
+
{
|
39 |
+
$client = null;
|
40 |
+
|
41 |
+
$collection = $this->getCollection();
|
42 |
+
if ($collection->getSize() > 0) {
|
43 |
+
$client = $collection->getFirstItem();
|
44 |
+
}
|
45 |
+
|
46 |
+
return $client;
|
47 |
+
}
|
48 |
+
|
49 |
+
public function deleteExisting()
|
50 |
+
{
|
51 |
+
foreach ($this->getCollection() as $client) {
|
52 |
+
$client->delete();
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
+
}
|
app/code/community/CosmicCart/Integration/Model/ErrorHandler.php
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
+
*
|
7 |
+
* @category CosmicCart
|
8 |
+
* @package Integration
|
9 |
+
* @copyright Copyright (c) 2015 Cosmic Cart, Inc.
|
10 |
+
* @license CosmicCart Software License https://cosmiccart.com/help/license/software
|
11 |
+
*/
|
12 |
+
|
13 |
+
class CosmicCart_Integration_Model_ErrorHandler
|
14 |
+
{
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Creates a shutdown handler that will mail any errors to us.
|
18 |
+
*
|
19 |
+
* @param $store The store id
|
20 |
+
*/
|
21 |
+
public function initErrorHandler($store)
|
22 |
+
{
|
23 |
+
error_reporting(E_ALL);
|
24 |
+
|
25 |
+
if (!function_exists('handleErrors')) {
|
26 |
+
function handleErrors($store)
|
27 |
+
{
|
28 |
+
$isError = false;
|
29 |
+
if ($error = error_get_last()) {
|
30 |
+
switch ($error['type']) {
|
31 |
+
case E_ERROR:
|
32 |
+
case E_CORE_ERROR:
|
33 |
+
case E_COMPILE_ERROR:
|
34 |
+
case E_USER_ERROR:
|
35 |
+
$isError = true;
|
36 |
+
break;
|
37 |
+
}
|
38 |
+
}
|
39 |
+
if ($isError) {
|
40 |
+
Mage::getModel('cosmiccart_integration/mail')->sendEmail(
|
41 |
+
'cosmiccart_integration_generic_error_tpl',
|
42 |
+
'api-fallback@cosmiccart.com',
|
43 |
+
'Cosmic Cart API Fallback Team',
|
44 |
+
'Generic Error (Fallback Email)',
|
45 |
+
array(
|
46 |
+
'message' => $error['message'],
|
47 |
+
'file' => $error['file'],
|
48 |
+
'line' => $error['line'],
|
49 |
+
'siteUrl' => Mage::getStoreConfig('web/secure/base_url', $store)
|
50 |
+
)
|
51 |
+
);
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
register_shutdown_function('handleErrors', $store);
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
+
}
|
app/code/community/CosmicCart/Integration/Model/Exporter.php
ADDED
@@ -0,0 +1,961 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
+
*
|
7 |
+
* @category CosmicCart
|
8 |
+
* @package Integration
|
9 |
+
* @copyright Copyright (c) 2015 Cosmic Cart, Inc.
|
10 |
+
* @license CosmicCart Software License https://cosmiccart.com/help/license/software
|
11 |
+
*/
|
12 |
+
|
13 |
+
class CosmicCart_Integration_Model_Exporter
|
14 |
+
{
|
15 |
+
private $_configurablesCollection = array();
|
16 |
+
private $_simplesCollection = array();
|
17 |
+
private $_configurablesIdsCollection = array();
|
18 |
+
|
19 |
+
private $_pageSize = null;
|
20 |
+
|
21 |
+
private $_configurableTypeInstance = null;
|
22 |
+
|
23 |
+
private $_exportData = array();
|
24 |
+
private $_processedCount = 0;
|
25 |
+
|
26 |
+
private $_exportStoreId = null;
|
27 |
+
private $_brandAttributeCode = null;
|
28 |
+
private $_eanAttributeCode = null;
|
29 |
+
|
30 |
+
public static $_exporterCron = false;
|
31 |
+
public static $_batchGenerateCron = false;
|
32 |
+
|
33 |
+
private $_store = null;
|
34 |
+
private $_brandAttributeType = null;
|
35 |
+
|
36 |
+
|
37 |
+
public function generateBatch()
|
38 |
+
{
|
39 |
+
if (!Mage::helper('cosmiccart_integration')->cronAutoexportEnabled()) {
|
40 |
+
return $this;
|
41 |
+
}
|
42 |
+
|
43 |
+
//Prevent duplicated CRON running same time
|
44 |
+
if (self::$_batchGenerateCron == true) {
|
45 |
+
return $this;
|
46 |
+
}
|
47 |
+
$this->exportCatalog('new');
|
48 |
+
|
49 |
+
self::$_batchGenerateCron = true;
|
50 |
+
return $this;
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Cronjob proxy
|
55 |
+
*
|
56 |
+
* @return CosmicCart_Integration_Model_Exporter
|
57 |
+
*/
|
58 |
+
public function cronprocess()
|
59 |
+
{
|
60 |
+
//Prevent duplicated CRON running same time
|
61 |
+
if (self::$_exporterCron == true) {
|
62 |
+
return $this;
|
63 |
+
}
|
64 |
+
|
65 |
+
$process = Mage::helper('catalog/product_flat')->getProcess();
|
66 |
+
$status = $process->getStatus();
|
67 |
+
$process->setStatus(Mage_Index_Model_Process::STATUS_RUNNING);
|
68 |
+
|
69 |
+
try {
|
70 |
+
$this->exportCatalog();
|
71 |
+
} Catch (Exception $e) {
|
72 |
+
$process->setStatus($status);
|
73 |
+
Mage::throwException($e);
|
74 |
+
}
|
75 |
+
|
76 |
+
$process->setStatus($status);
|
77 |
+
|
78 |
+
self::$_exporterCron = true;
|
79 |
+
return $this;
|
80 |
+
}
|
81 |
+
|
82 |
+
public function getStore()
|
83 |
+
{
|
84 |
+
if (!$this->_store) {
|
85 |
+
$this->_store = Mage::getStoreConfig('cosmiccart/store');
|
86 |
+
}
|
87 |
+
return $this->_store;
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Exports the default store's catalog to a gzipped json file on the Cosmic Cart sftp server.
|
92 |
+
*
|
93 |
+
* @throws Exception
|
94 |
+
*/
|
95 |
+
public function exportCatalog($target_batch = null)
|
96 |
+
{
|
97 |
+
$store = $this->getStore();
|
98 |
+
$storeObject = Mage::getSingleton('core/store')->load($store);
|
99 |
+
|
100 |
+
$currency = $storeObject->getCurrentCurrencyCode();
|
101 |
+
|
102 |
+
// Load our activated client. This is required or else the export cannot take place.
|
103 |
+
$client = Mage::getModel('cosmiccart_integration/client')->findExisting();
|
104 |
+
if (!$client) {
|
105 |
+
throw new Exception('No client detected');
|
106 |
+
}
|
107 |
+
|
108 |
+
// Setup error notifications to ourselves.
|
109 |
+
$this->initErrorHandler($store);
|
110 |
+
$numWritten = 1;
|
111 |
+
|
112 |
+
if ($target_batch != null) {
|
113 |
+
// Create the new batch and start from here.
|
114 |
+
Mage::getModel('cosmiccart_integration/batch')->startBatchSession();
|
115 |
+
return $this;
|
116 |
+
}
|
117 |
+
|
118 |
+
$rows = $this->_getBatchRows();
|
119 |
+
|
120 |
+
if (!$rows OR !is_array($rows) OR count($rows) < 1) {
|
121 |
+
return $this;
|
122 |
+
}
|
123 |
+
|
124 |
+
foreach ($rows as $row) {
|
125 |
+
// Based on the status do different things.
|
126 |
+
// 0 - Not yet started (Default)
|
127 |
+
// 1 - Getting Row counts
|
128 |
+
// 2 - Processing rows
|
129 |
+
// 3 - Merging files into one big file & Gzip the files
|
130 |
+
// 4 - In process of FTP the file
|
131 |
+
// 5 - Completed
|
132 |
+
// 6 - Fatal error
|
133 |
+
try {
|
134 |
+
|
135 |
+
if ($row['current_stage'] == 0) {
|
136 |
+
$row = $this->_handleStage0($row, $store);
|
137 |
+
}
|
138 |
+
|
139 |
+
// Start the process
|
140 |
+
if ($row['current_stage'] == 1) {
|
141 |
+
$row = $this->_handleStage1($row);
|
142 |
+
}
|
143 |
+
|
144 |
+
if ($row['current_stage'] == 2) {
|
145 |
+
$row = $this->_handleStage2($row, $store, $currency);
|
146 |
+
}
|
147 |
+
|
148 |
+
if ($row['current_stage'] == 3) {
|
149 |
+
$row = $this->_handleStage3($row);
|
150 |
+
}
|
151 |
+
|
152 |
+
if ($row['current_stage'] == 4) {
|
153 |
+
$row = $this->_handleStage4($row, $client);
|
154 |
+
}
|
155 |
+
|
156 |
+
} catch (Exception $error) {
|
157 |
+
// If it failed for whatever reason, log it into the comment field and increment num_of_retries of 1
|
158 |
+
$data = array();
|
159 |
+
$row['num_of_times_retried'] = $row['num_of_times_retried'] + 1;
|
160 |
+
$data['num_of_times_retried'] = $row['num_of_times_retried'];
|
161 |
+
$data['comment'] = $error->getMessage();
|
162 |
+
|
163 |
+
$where = $this->_getWriteConnection()->quoteInto('batch_id =?', $row['batch_id']);
|
164 |
+
$this->_getWriteConnection()->update($this->_getTableName('cosmiccart_integration/batch'), $data, $where);
|
165 |
+
|
166 |
+
if ($row['num_of_times_retried'] >= 3) {
|
167 |
+
// Mark this process fatal error
|
168 |
+
$data['current_stage'] = 6;
|
169 |
+
$where = $this->_getWriteConnection()->quoteInto('batch_id =?', $row['batch_id']);
|
170 |
+
$this->_getWriteConnection()->update($this->_getTableName('cosmiccart_integration/batch'), $data, $where);
|
171 |
+
$row['current_stage'] = 6;
|
172 |
+
}
|
173 |
+
}
|
174 |
+
}
|
175 |
+
|
176 |
+
return $this;
|
177 |
+
}
|
178 |
+
|
179 |
+
private function _handleStage0($row, $store)
|
180 |
+
{
|
181 |
+
// First, let's find all the configurable products that are visible and enabled (PRODUCT)
|
182 |
+
$configurables_collection = $this->_getConfigurablesCollection($store);
|
183 |
+
$simple_collection = $this->_getSimplesCollection($store);
|
184 |
+
|
185 |
+
// Now find out how much record is returning
|
186 |
+
$configurables_collection_count = $configurables_collection->getSize();
|
187 |
+
$simple_collection_count = $simple_collection->getSize();
|
188 |
+
|
189 |
+
// Update the row count now
|
190 |
+
$data = array();
|
191 |
+
$data['total_row_count'] = $simple_collection_count;
|
192 |
+
$data['config_total_row_count'] = $configurables_collection_count;
|
193 |
+
$data['current_stage'] = 1;
|
194 |
+
$data['comment'] = 'Scheduled';
|
195 |
+
$data['start_time'] = date("Y-m-d H:i:s");
|
196 |
+
|
197 |
+
$where = $this->_getWriteConnection()->quoteInto('batch_id =?', $row['batch_id']);
|
198 |
+
$this->_getWriteConnection()->update($this->_getTableName('cosmiccart_integration/batch'), $data, $where);
|
199 |
+
|
200 |
+
$row['total_row_count'] = $simple_collection_count;
|
201 |
+
$row['config_total_row_count'] = $configurables_collection_count;
|
202 |
+
$row['current_stage'] = 1;
|
203 |
+
|
204 |
+
return $row;
|
205 |
+
}
|
206 |
+
|
207 |
+
private function _handleStage1($row)
|
208 |
+
{
|
209 |
+
$data = array();
|
210 |
+
$data['current_stage'] = 2;
|
211 |
+
$data['comment'] = 'Processing rows';
|
212 |
+
$where = $this->_getWriteConnection()->quoteInto('batch_id =?', $row['batch_id']);
|
213 |
+
$this->_getWriteConnection()->update($this->_getTableName('cosmiccart_integration/batch'), $data, $where);
|
214 |
+
|
215 |
+
$row['current_stage'] = 2;
|
216 |
+
return $row;
|
217 |
+
}
|
218 |
+
|
219 |
+
private function _handleStage2($row, $store, $currency)
|
220 |
+
{
|
221 |
+
// Process the export
|
222 |
+
$configurables_collection = $this->_getConfigurablesCollection($store);
|
223 |
+
$simple_collection = $this->_getSimplesCollection($store);
|
224 |
+
|
225 |
+
// Work on configurable first
|
226 |
+
try {
|
227 |
+
$numWritten = 0;
|
228 |
+
if ($row['config_number_of_processed_row'] < $row['config_total_row_count']) {
|
229 |
+
$numWritten = $this->exportCollection(
|
230 |
+
$store,
|
231 |
+
$currency,
|
232 |
+
$row['config_total_row_count'],
|
233 |
+
$configurables_collection,
|
234 |
+
$row['config_number_of_processed_row'],
|
235 |
+
$row['batch_id'],
|
236 |
+
true
|
237 |
+
);
|
238 |
+
}
|
239 |
+
} catch (Exception $e) {
|
240 |
+
Mage::log(__FILE__ . ' ' . __LINE__ . ' ' . " Error: " . $e->getMessage() . " - " . time(), null, 'cosmiccart-export.log');
|
241 |
+
Mage::getModel('cosmiccart_integration/mail')->sendEmail(
|
242 |
+
'cosmiccart_integration_import_exception_tpl',
|
243 |
+
'api-fallback@cosmiccart.com',
|
244 |
+
'Cosmic Cart API Fallback Team',
|
245 |
+
'Catalog Import Exception (Fallback Email)',
|
246 |
+
array(
|
247 |
+
'exception' => $e,
|
248 |
+
'pageSize' => $this->_getPageSize(),
|
249 |
+
'siteUrl' => Mage::getStoreConfig('web/secure/base_url', $store)
|
250 |
+
)
|
251 |
+
);
|
252 |
+
throw $e;
|
253 |
+
}
|
254 |
+
|
255 |
+
// Work on simple last
|
256 |
+
try {
|
257 |
+
$numWritten = 0;
|
258 |
+
if ($row['number_of_processed_row'] < $row['total_row_count']) {
|
259 |
+
$numWritten = $this->exportCollection(
|
260 |
+
$store,
|
261 |
+
$currency,
|
262 |
+
$row['total_row_count'],
|
263 |
+
$simple_collection,
|
264 |
+
$row['number_of_processed_row'],
|
265 |
+
$row['batch_id'],
|
266 |
+
false
|
267 |
+
);
|
268 |
+
}
|
269 |
+
} catch (Exception $e) {
|
270 |
+
Mage::log(__FILE__ . ' ' . __LINE__ . ' ' . " Error: " . $e->getMessage() . " - " . time(), null, 'cosmiccart-export.log');
|
271 |
+
Mage::getModel('cosmiccart_integration/mail')->sendEmail(
|
272 |
+
'cosmiccart_integration_import_exception_tpl',
|
273 |
+
'api-fallback@cosmiccart.com',
|
274 |
+
'Cosmic Cart API Fallback Team',
|
275 |
+
'Catalog Import Exception (Fallback Email)',
|
276 |
+
array(
|
277 |
+
'exception' => $e,
|
278 |
+
'pageSize' => $this->_getPageSize(),
|
279 |
+
'siteUrl' => Mage::getStoreConfig('web/secure/base_url', $store)
|
280 |
+
)
|
281 |
+
);
|
282 |
+
|
283 |
+
throw $e;
|
284 |
+
}
|
285 |
+
|
286 |
+
// Check to see if we had everything?
|
287 |
+
$updateSql = sprintf("UPDATE %s SET current_stage = 3, current_stage = 3, comment = 'Gzip contents...'
|
288 |
+
WHERE number_of_processed_row >= total_row_count
|
289 |
+
AND config_total_row_count >= config_number_of_processed_row AND batch_id = %s",
|
290 |
+
$this->_getTableName('cosmiccart_integration/batch'), $row['batch_id']);
|
291 |
+
|
292 |
+
$this->_getWriteConnection()->exec($updateSql);
|
293 |
+
|
294 |
+
$row['current_stage'] = 3;
|
295 |
+
|
296 |
+
return $row;
|
297 |
+
}
|
298 |
+
|
299 |
+
private function _handleStage3($row)
|
300 |
+
{
|
301 |
+
// Merge the files
|
302 |
+
// File path of final result
|
303 |
+
$exportDir = $this->_getExportDir();
|
304 |
+
$exportReadyFile = $exportDir . DS . $row['batch_id'] . '.gz';
|
305 |
+
|
306 |
+
// Compress it with gzip
|
307 |
+
$fp = gzopen($exportReadyFile, 'w9');
|
308 |
+
gzwrite($fp, "[");
|
309 |
+
|
310 |
+
// Files
|
311 |
+
$files = glob($exportDir . DS . $row['batch_id'] . DS . "*.txt");
|
312 |
+
|
313 |
+
$filecounter = 0;
|
314 |
+
foreach ($files as $file) {
|
315 |
+
gzwrite($fp, file_get_contents($file));
|
316 |
+
/* after appending every file we need to append comma (,) */
|
317 |
+
$filecounter++;
|
318 |
+
if ($filecounter < count($files)) {
|
319 |
+
gzwrite($fp, ",");
|
320 |
+
}
|
321 |
+
@unlink($file);
|
322 |
+
}
|
323 |
+
|
324 |
+
gzwrite($fp, "]");
|
325 |
+
gzclose($fp);
|
326 |
+
|
327 |
+
$data = array();
|
328 |
+
$data['current_stage'] = 4;
|
329 |
+
$data['comment'] = 'Uploading data...';
|
330 |
+
$data['num_of_times_retried'] = 0;
|
331 |
+
|
332 |
+
$where = $this->_getWriteConnection()->quoteInto('batch_id =?', $row['batch_id']);
|
333 |
+
$this->_getWriteConnection()->update($this->_getTableName('cosmiccart_integration/batch'), $data, $where);
|
334 |
+
|
335 |
+
$row['current_stage'] = 4;
|
336 |
+
|
337 |
+
return $row;
|
338 |
+
}
|
339 |
+
|
340 |
+
private function _handleStage4($row, $client)
|
341 |
+
{
|
342 |
+
$sftpServer = Mage::helper('cosmiccart_integration')->getSftpUrl();
|
343 |
+
|
344 |
+
// Upload FTP
|
345 |
+
$connection = $this->open(array(
|
346 |
+
'host' => $sftpServer,
|
347 |
+
'username' => $this->generateUsername($client->getClientId()),
|
348 |
+
'password' => $client->getClientSecret(),
|
349 |
+
'timeout' => '7200'
|
350 |
+
), $row['batch_id']);
|
351 |
+
|
352 |
+
// File path of final result
|
353 |
+
$sftpTargetFile = 'Magento_Export_' . date('YmjHis') . '.gz';
|
354 |
+
|
355 |
+
$exportDir = $this->_getExportDir();
|
356 |
+
$exportReadyFile = $exportDir . DS . $row['batch_id'] . '.gz';
|
357 |
+
|
358 |
+
$connection->put($sftpTargetFile, $exportReadyFile, NET_SFTP_LOCAL_FILE);
|
359 |
+
$connection->disconnect();
|
360 |
+
|
361 |
+
// Removed temporary folder
|
362 |
+
@rmdir($exportDir . DS . $row['batch_id']);
|
363 |
+
|
364 |
+
// Remove temp local file
|
365 |
+
@unlink($exportReadyFile);
|
366 |
+
|
367 |
+
$data = array();
|
368 |
+
$data['current_stage'] = 5;
|
369 |
+
$data['end_time'] = date("Y-m-d H:i:s");
|
370 |
+
$data['num_of_times_retried'] = 0;
|
371 |
+
$data['comment'] = 'Completed!';
|
372 |
+
|
373 |
+
$where = $this->_getWriteConnection()->quoteInto('batch_id =?', $row['batch_id']);
|
374 |
+
$this->_getWriteConnection()->update($this->_getTableName('cosmiccart_integration/batch'), $data, $where);
|
375 |
+
|
376 |
+
$row['current_stage'] = 5;
|
377 |
+
|
378 |
+
return $row;
|
379 |
+
}
|
380 |
+
|
381 |
+
/**
|
382 |
+
* Get Configurables collection
|
383 |
+
*
|
384 |
+
* @param $store
|
385 |
+
* @return mixed
|
386 |
+
*/
|
387 |
+
private function _getConfigurablesCollection($store)
|
388 |
+
{
|
389 |
+
if (!isset($this->_configurablesCollection[$store]) OR $this->_configurablesCollection[$store] == null) {
|
390 |
+
$this->_configurablesCollection[$store] = $this->_prepareProductCollection('configurable', $store);
|
391 |
+
}
|
392 |
+
|
393 |
+
return $this->_configurablesCollection[$store];
|
394 |
+
}
|
395 |
+
|
396 |
+
/**
|
397 |
+
* Get Configurables collection without attribute joins
|
398 |
+
*
|
399 |
+
* @param $store
|
400 |
+
* @return mixed
|
401 |
+
*/
|
402 |
+
private function _getConfigurablesIdsCollection($store)
|
403 |
+
{
|
404 |
+
if (!isset($this->_configurablesIdsCollection[$store]) OR $this->_configurablesIdsCollection[$store] == null) {
|
405 |
+
$this->_configurablesIdsCollection[$store] = $this->_prepareProductCollection('configurable_ids', $store);
|
406 |
+
}
|
407 |
+
|
408 |
+
return $this->_configurablesIdsCollection[$store];
|
409 |
+
}
|
410 |
+
|
411 |
+
/**
|
412 |
+
* Get Simple products collection
|
413 |
+
*
|
414 |
+
* @param $store
|
415 |
+
* @return mixed
|
416 |
+
*/
|
417 |
+
private function _getSimplesCollection($store)
|
418 |
+
{
|
419 |
+
if (!isset($this->_simplesCollection[$store]) OR $this->_simplesCollection[$store] == null) {
|
420 |
+
$this->_simplesCollection[$store] = $this->_prepareProductCollection('simple', $store);
|
421 |
+
}
|
422 |
+
|
423 |
+
return $this->_simplesCollection[$store];
|
424 |
+
}
|
425 |
+
|
426 |
+
/**
|
427 |
+
* Get Folder for exported files
|
428 |
+
*
|
429 |
+
* @return string
|
430 |
+
*/
|
431 |
+
private function _getExportDir()
|
432 |
+
{
|
433 |
+
return Mage::getBaseDir('tmp') . DS . 'cosmic_cart_export';
|
434 |
+
}
|
435 |
+
|
436 |
+
private function _getBatchRows()
|
437 |
+
{
|
438 |
+
$select = $this->_getReadConnection()
|
439 |
+
->select()
|
440 |
+
->from($this->_getTableName('cosmiccart_integration/batch'), array('*'))
|
441 |
+
->where('current_stage IN (0,1,2,3,4)')
|
442 |
+
->order('current_stage ASC');
|
443 |
+
|
444 |
+
$rows = $this->_getReadConnection()->fetchAll($select);
|
445 |
+
return $rows;
|
446 |
+
}
|
447 |
+
|
448 |
+
|
449 |
+
private function _getPageSize()
|
450 |
+
{
|
451 |
+
if (!$this->_pageSize) {
|
452 |
+
$this->_pageSize = Mage::getStoreConfig('cosmiccart/export_opt/max_batch_size');
|
453 |
+
if (empty($this->_pageSize)) {
|
454 |
+
$this->_pageSize = 3000;
|
455 |
+
}
|
456 |
+
}
|
457 |
+
return $this->_pageSize;
|
458 |
+
}
|
459 |
+
|
460 |
+
|
461 |
+
/**
|
462 |
+
* Serializes a page of products to file.
|
463 |
+
*/
|
464 |
+
private function exportCollection($store, $currency, $collectionCounter, $collection, $number_of_processed_row, $batchId, $isConfigurable)
|
465 |
+
{
|
466 |
+
$stopNow = false;
|
467 |
+
|
468 |
+
$this->_exportStoreId = $store;
|
469 |
+
|
470 |
+
// Prepare the temp export path
|
471 |
+
$exportDir = $this->_getExportDir() . DS . $batchId;
|
472 |
+
// Set up our output file stream
|
473 |
+
$out = new Varien_Io_File();
|
474 |
+
$out->setAllowCreateFolders(true);
|
475 |
+
$out->open(array('path' => $exportDir));
|
476 |
+
|
477 |
+
do {
|
478 |
+
Mage::log(__FILE__ . ' ' . __LINE__ . ' ' . "Batch Started: " . $number_of_processed_row . " - " . time(), null, 'cosmiccart-export.log');
|
479 |
+
|
480 |
+
if (Mage::helper('cosmiccart_integration')->checkBatch($batchId) != $batchId) {
|
481 |
+
throw new Exception('User cancelled');
|
482 |
+
break;
|
483 |
+
}
|
484 |
+
|
485 |
+
$product_collection = clone($collection);
|
486 |
+
$product_collection->getSelect()->order('e.entity_id ASC')->limit($this->_getPageSize(), $number_of_processed_row);
|
487 |
+
|
488 |
+
if ($product_collection == null) {
|
489 |
+
$stopNow = true;
|
490 |
+
break;
|
491 |
+
} else {
|
492 |
+
// Start working on the export
|
493 |
+
/*
|
494 |
+
* export file name for configurable products should be different because it overriding values with simple product file name
|
495 |
+
* like 0.txt - configurable product file name & same 0.txt - simple product file name
|
496 |
+
* so first in file configurable products will list but at the time of simple products export it will override previous values
|
497 |
+
* */
|
498 |
+
if ($isConfigurable) {
|
499 |
+
$export_file_name = $exportDir . DS . "C-" . $number_of_processed_row . '.txt';
|
500 |
+
} else {
|
501 |
+
$export_file_name = $exportDir . DS . $number_of_processed_row . '.txt';
|
502 |
+
}
|
503 |
+
|
504 |
+
file_put_contents($export_file_name, '');
|
505 |
+
$this->_processedCount = 0;
|
506 |
+
|
507 |
+
$mediaUrl = Mage::getSingleton('catalog/product_media_config')->getBaseMediaUrl();
|
508 |
+
|
509 |
+
$customColumns = array(
|
510 |
+
'store_id' => new Zend_Db_Expr($this->_getReadConnection()->quoteInto('?', $store)),
|
511 |
+
'currency_code' => new Zend_Db_Expr($this->_getReadConnection()->quoteInto('?', $currency)),
|
512 |
+
'img_url' => sprintf("CONCAT('%s', IF(at_image.value_id > 0, at_image.value, at_image_default.value))", $mediaUrl),
|
513 |
+
);
|
514 |
+
|
515 |
+
if ($isConfigurable) {
|
516 |
+
$customColumns['raw_item_type'] = new Zend_Db_Expr($this->_getReadConnection()->quoteInto('?', 'PRODUCT'));
|
517 |
+
} else {
|
518 |
+
$customColumns['raw_item_type'] = new Zend_Db_Expr($this->_getReadConnection()->quoteInto('?', 'STANDALONE'));
|
519 |
+
}
|
520 |
+
|
521 |
+
$product_collection->getSelect()->columns($customColumns);
|
522 |
+
|
523 |
+
$this->_exportData = array();
|
524 |
+
|
525 |
+
$product_collection->walk(array($this, 'exportCollectionCallback'));
|
526 |
+
|
527 |
+
if ($isConfigurable) {
|
528 |
+
//Prepare configurable child collection
|
529 |
+
$childCollection = $this->_getChildrenProductsCollection($store);
|
530 |
+
|
531 |
+
$customColumns['raw_item_type'] = new Zend_Db_Expr($this->_getReadConnection()->quoteInto('?', 'VARIANT'));
|
532 |
+
$childCollection->getSelect()->columns($customColumns);
|
533 |
+
$childCollection->walk(array($this, 'exportCollectionCallback'));
|
534 |
+
}
|
535 |
+
|
536 |
+
file_put_contents($export_file_name, implode(',', $this->_exportData), FILE_APPEND);
|
537 |
+
|
538 |
+
// Update the batch information
|
539 |
+
Mage::log(__FILE__ . ' ' . __LINE__ . ' ' . "Batch Ended: " . $number_of_processed_row . " - " . time(), null, 'cosmiccart-export.log');
|
540 |
+
if ($isConfigurable) {
|
541 |
+
$sql = 'UPDATE cosmiccart_batch_status SET config_number_of_processed_row = config_number_of_processed_row + ' . $this->_processedCount . ' WHERE batch_id = ' . $batchId;
|
542 |
+
$this->_getWriteConnection()->query($sql);
|
543 |
+
$number_of_processed_row = $this->_getReadConnection()->fetchOne('SELECT config_number_of_processed_row FROM cosmiccart_batch_status WHERE batch_id = ' . $batchId);
|
544 |
+
} else {
|
545 |
+
$sql = 'UPDATE cosmiccart_batch_status SET number_of_processed_row = number_of_processed_row + ' . $this->_processedCount . ' WHERE batch_id = ' . $batchId;
|
546 |
+
$this->_getWriteConnection()->query($sql);
|
547 |
+
$number_of_processed_row = $this->_getReadConnection()->fetchOne('SELECT number_of_processed_row FROM cosmiccart_batch_status WHERE batch_id = ' . $batchId);
|
548 |
+
}
|
549 |
+
}
|
550 |
+
|
551 |
+
if ($number_of_processed_row >= $collectionCounter) {
|
552 |
+
$stopNow = true;
|
553 |
+
}
|
554 |
+
|
555 |
+
} while (!$stopNow);
|
556 |
+
|
557 |
+
return $number_of_processed_row;
|
558 |
+
}
|
559 |
+
|
560 |
+
private function _getConfigurableAttributes($parentSku, $child)
|
561 |
+
{
|
562 |
+
$data = array();
|
563 |
+
|
564 |
+
$parentId = Mage::getModel('catalog/product')->getResource()->getIdBySku($parentSku);
|
565 |
+
$parent = Mage::getModel('catalog/product')->load($parentId);
|
566 |
+
if ($parent AND $parent->getId()) {
|
567 |
+
$configurableAttributes = $parent->getTypeInstance(true)->getConfigurableAttributesAsArray($parent);
|
568 |
+
|
569 |
+
foreach ($configurableAttributes as $attribute) {
|
570 |
+
$label = $attribute['frontend_label'];
|
571 |
+
$attributeCode = $attribute['attribute_code'];
|
572 |
+
|
573 |
+
$attr = Mage::getResourceModel('catalog/product')->getAttributeRawValue($child->getId(), $attributeCode, $this->_exportStoreId);
|
574 |
+
|
575 |
+
if ($attr) {
|
576 |
+
$child->setData($attributeCode, $attr);
|
577 |
+
$value = $child->getAttributeText($attributeCode);
|
578 |
+
$data[] = array(
|
579 |
+
'attribute' => $label,
|
580 |
+
'value' => $value
|
581 |
+
);
|
582 |
+
}
|
583 |
+
}
|
584 |
+
|
585 |
+
return $data;
|
586 |
+
}
|
587 |
+
}
|
588 |
+
|
589 |
+
public function exportCollectionCallback($product)
|
590 |
+
{
|
591 |
+
$helper = Mage::helper('core');
|
592 |
+
$storeId = $this->_exportStoreId;
|
593 |
+
|
594 |
+
$price = $product->getPrice() ? number_format($product->getPrice(), 2, ".", "") : null;
|
595 |
+
$specialPrice = $product->getSpecialPrice() ? number_format($product->getSpecialPrice(), 2, ".", "") : null;
|
596 |
+
|
597 |
+
$brandType = $this->_getBrandAttributeType();
|
598 |
+
if (is_null($brandType)) {
|
599 |
+
$brandType = 'text';
|
600 |
+
}
|
601 |
+
|
602 |
+
if ($brandType == 'select') {
|
603 |
+
$brandCode = $this->_getBrandAttributeCode($this->getStore());
|
604 |
+
$product->setStoreId($this->getStore())
|
605 |
+
->setData(
|
606 |
+
$brandCode,
|
607 |
+
$product->getProductBrand()
|
608 |
+
);
|
609 |
+
$brand = $product->getAttributeText($brandCode);
|
610 |
+
|
611 |
+
} elseif ($brandType == 'multiselect') {
|
612 |
+
|
613 |
+
$productBrand = null;
|
614 |
+
$brand = $product->getProductBrand();
|
615 |
+
if ($brand) {
|
616 |
+
$brands = explode(',', $brand);
|
617 |
+
if ($brands AND is_array($brands) AND count($brands)) {
|
618 |
+
$productBrand = $brands[0];
|
619 |
+
}
|
620 |
+
}
|
621 |
+
|
622 |
+
$brandCode = $this->_getBrandAttributeCode($this->getStore());
|
623 |
+
$product->setStoreId($this->getStore())
|
624 |
+
->setData(
|
625 |
+
$brandCode,
|
626 |
+
$productBrand
|
627 |
+
);
|
628 |
+
$brand = $product->getAttributeText($brandCode);
|
629 |
+
} else {
|
630 |
+
$brand = $product->getProductBrand();
|
631 |
+
}
|
632 |
+
|
633 |
+
$brand = $brand ? $brand : null;
|
634 |
+
|
635 |
+
$prodResult = array(
|
636 |
+
'product_id' => $product->getId(),
|
637 |
+
'sku' => $product->getSku(),
|
638 |
+
'name' => $product->getName(),
|
639 |
+
'price' => $price,
|
640 |
+
'special_price' => $specialPrice,
|
641 |
+
'special_from_date' => $product->getSpecialFromDate(),
|
642 |
+
'special_to_date' => $product->getSpecialToDate(),
|
643 |
+
'currency_code' => $product->getCurrencyCode(),
|
644 |
+
'parent_sku' => null,
|
645 |
+
'store_id' => $storeId,
|
646 |
+
'description' => $product->getDescription(),
|
647 |
+
'raw_item_type' => $product->getRawItemType(),
|
648 |
+
'categories' => $product->getCategoryIds(),
|
649 |
+
'available' => $product->isSalable(),
|
650 |
+
'brand' => $brand,
|
651 |
+
'ean' => $product->getProductEan(),
|
652 |
+
'images' => array(
|
653 |
+
array(
|
654 |
+
'url' => $product->getImgUrl(),
|
655 |
+
'position' => "0"
|
656 |
+
)
|
657 |
+
),
|
658 |
+
'attributes' => null
|
659 |
+
);
|
660 |
+
|
661 |
+
if ($product->getRawItemType() == 'VARIANT') {
|
662 |
+
|
663 |
+
$parentIds = $this->_getConfigurableTypeInstance()->getParentIdsByChild($product->getId());
|
664 |
+
$query = sprintf("SELECT sku FROM %s WHERE entity_id IN('%s')", $this->_getTableName('catalog/product'), implode("','", $parentIds));
|
665 |
+
$result = $this->_getReadConnection()->fetchCol($query);
|
666 |
+
|
667 |
+
foreach ($result as $parentSku) {
|
668 |
+
|
669 |
+
$result = $prodResult;
|
670 |
+
$result['parent_sku'] = $parentSku;
|
671 |
+
|
672 |
+
$attributes = $this->_getConfigurableAttributes($parentSku, $product);
|
673 |
+
$result['attributes'] = $attributes;
|
674 |
+
|
675 |
+
//Handle product export here for each product
|
676 |
+
$this->_exportData[] = $helper->jsonEncode($result);
|
677 |
+
}
|
678 |
+
|
679 |
+
return $this;
|
680 |
+
}
|
681 |
+
|
682 |
+
//Handle product export here for regular products
|
683 |
+
|
684 |
+
//Processed count increment only for parent products!!!
|
685 |
+
$this->_processedCount++;
|
686 |
+
$this->_exportData[] = $helper->jsonEncode($prodResult);
|
687 |
+
|
688 |
+
return $this;
|
689 |
+
}
|
690 |
+
|
691 |
+
private function _getConfigurableTypeInstance()
|
692 |
+
{
|
693 |
+
if (!$this->_configurableTypeInstance) {
|
694 |
+
$this->_configurableTypeInstance = Mage::getSingleton('catalog/product_type_configurable');
|
695 |
+
}
|
696 |
+
|
697 |
+
return $this->_configurableTypeInstance;
|
698 |
+
}
|
699 |
+
|
700 |
+
/**
|
701 |
+
* Opens an SFTP connection. This was pulled out of Varien_Io_Sftp because that class had a bug in how it called
|
702 |
+
* Net_SFTP::put(), ƒorcing the expectation of a string of data instead of a file name.
|
703 |
+
*
|
704 |
+
* @param array $args
|
705 |
+
* @return Net_SFTP|null
|
706 |
+
* @throws Exception
|
707 |
+
*/
|
708 |
+
private function open(array $args = array(), $batchId)
|
709 |
+
{
|
710 |
+
$connection = null;
|
711 |
+
if (!isset($args['timeout'])) {
|
712 |
+
$args['timeout'] = Varien_Io_Sftp::REMOTE_TIMEOUT;
|
713 |
+
}
|
714 |
+
if (strpos($args['host'], ':') !== false) {
|
715 |
+
list($host, $port) = explode(':', $args['host'], 2);
|
716 |
+
} else {
|
717 |
+
$host = $args['host'];
|
718 |
+
$port = Varien_Io_Sftp::SSH2_PORT;
|
719 |
+
}
|
720 |
+
$connection = new Net_SFTP($host, $port, $args['timeout']);
|
721 |
+
if (!$connection->login($args['username'], $args['password'])) {
|
722 |
+
// If ftp is not connecting then remove temporary folder
|
723 |
+
$baseDir = Mage::getBaseDir();
|
724 |
+
@rmdir($baseDir . DS . 'var' . DS . 'cosmic_cart_export' . DS . $batchId);
|
725 |
+
throw new Exception(sprintf(__("Unable to open SFTP connection as %s@%s", $args['username'], $args['host'])));
|
726 |
+
}
|
727 |
+
return $connection;
|
728 |
+
}
|
729 |
+
|
730 |
+
/**
|
731 |
+
* Turns the given clientId into a username for SFTP. Strips hyphens and truncates to 12 chars.
|
732 |
+
*
|
733 |
+
* @param $clientId
|
734 |
+
* @return String
|
735 |
+
*/
|
736 |
+
private function generateUsername($clientId)
|
737 |
+
{
|
738 |
+
return 'mag' . substr(str_replace('-', '', $clientId), 0, 12);
|
739 |
+
}
|
740 |
+
|
741 |
+
private function initErrorHandler($store)
|
742 |
+
{
|
743 |
+
Mage::getSingleton('cosmiccart_integration/errorHandler')->initErrorHandler($store);
|
744 |
+
}
|
745 |
+
|
746 |
+
private function _getResourceSingleton()
|
747 |
+
{
|
748 |
+
return Mage::getSingleton('core/resource');
|
749 |
+
}
|
750 |
+
|
751 |
+
private function _getTableName($name)
|
752 |
+
{
|
753 |
+
return $this->_getResourceSingleton()->getTableName($name);
|
754 |
+
}
|
755 |
+
|
756 |
+
private function _getConnection($type)
|
757 |
+
{
|
758 |
+
return $this->_getResourceSingleton()->getConnection($type);
|
759 |
+
}
|
760 |
+
|
761 |
+
private function _getReadConnection()
|
762 |
+
{
|
763 |
+
return $this->_getConnection('core_read');
|
764 |
+
}
|
765 |
+
|
766 |
+
private function _getWriteConnection()
|
767 |
+
{
|
768 |
+
return $this->_getConnection('core_write');
|
769 |
+
}
|
770 |
+
|
771 |
+
private function _prepareProductCollection($type, $store)
|
772 |
+
{
|
773 |
+
$isVisible = array('in' => Mage::getSingleton('catalog/product_visibility')->getVisibleInSiteIds());
|
774 |
+
Mage::app()->setCurrentStore($store);
|
775 |
+
$collection = Mage::getModel('catalog/product')
|
776 |
+
->getCollection()->addStoreFilter($store);
|
777 |
+
|
778 |
+
switch ($type) {
|
779 |
+
case 'configurable': {
|
780 |
+
$collection
|
781 |
+
->addAttributeToFilter('type_id', 'configurable')
|
782 |
+
->addAttributeToFilter('status', 1)
|
783 |
+
->addAttributeToFilter('visibility', $isVisible);
|
784 |
+
}
|
785 |
+
break;
|
786 |
+
case 'configurable_ids': {
|
787 |
+
$collection
|
788 |
+
->addAttributeToFilter('type_id', 'configurable')
|
789 |
+
->addAttributeToFilter('status', 1)
|
790 |
+
->addAttributeToFilter('visibility', $isVisible);
|
791 |
+
$collection->getSelect()->reset(Zend_Db_Select::COLUMNS);
|
792 |
+
$collection->getSelect()->columns('entity_id');
|
793 |
+
//We don't want here to join other fields
|
794 |
+
return $collection;
|
795 |
+
}
|
796 |
+
break;
|
797 |
+
case 'simple': {
|
798 |
+
$collection
|
799 |
+
->addAttributeToFilter('type_id', 'simple')
|
800 |
+
->addAttributeToFilter('status', 1)
|
801 |
+
->addAttributeToFilter('visibility', $isVisible)
|
802 |
+
->joinTable('catalog/product_relation', 'child_id=entity_id', array(
|
803 |
+
'parent_id' => 'parent_id'
|
804 |
+
), null, 'left')
|
805 |
+
->addAttributeToFilter(array(
|
806 |
+
array(
|
807 |
+
'attribute' => 'parent_id',
|
808 |
+
'null' => null
|
809 |
+
)
|
810 |
+
));
|
811 |
+
}
|
812 |
+
break;
|
813 |
+
}
|
814 |
+
|
815 |
+
$collection = $this->_joinCollectionAttributes($collection, $store);
|
816 |
+
return $collection;
|
817 |
+
}
|
818 |
+
|
819 |
+
private function _joinCollectionAttributes($collection, $store)
|
820 |
+
{
|
821 |
+
$collection->joinAttribute(
|
822 |
+
'name',
|
823 |
+
'catalog_product/name',
|
824 |
+
'entity_id',
|
825 |
+
null,
|
826 |
+
'left',
|
827 |
+
$store
|
828 |
+
);
|
829 |
+
|
830 |
+
$collection->joinAttribute(
|
831 |
+
'price',
|
832 |
+
'catalog_product/price',
|
833 |
+
'entity_id',
|
834 |
+
null,
|
835 |
+
'left',
|
836 |
+
$store
|
837 |
+
);
|
838 |
+
|
839 |
+
$collection->joinAttribute(
|
840 |
+
'special_price',
|
841 |
+
'catalog_product/special_price',
|
842 |
+
'entity_id',
|
843 |
+
null,
|
844 |
+
'left',
|
845 |
+
$store
|
846 |
+
);
|
847 |
+
|
848 |
+
$collection->joinAttribute(
|
849 |
+
'special_from_date',
|
850 |
+
'catalog_product/special_from_date',
|
851 |
+
'entity_id',
|
852 |
+
null,
|
853 |
+
'left',
|
854 |
+
$store
|
855 |
+
);
|
856 |
+
|
857 |
+
$collection->joinAttribute(
|
858 |
+
'special_to_date',
|
859 |
+
'catalog_product/special_to_date',
|
860 |
+
'entity_id',
|
861 |
+
null,
|
862 |
+
'left',
|
863 |
+
$store
|
864 |
+
);
|
865 |
+
|
866 |
+
$collection->joinAttribute(
|
867 |
+
'image',
|
868 |
+
'catalog_product/image',
|
869 |
+
'entity_id',
|
870 |
+
null,
|
871 |
+
'left',
|
872 |
+
$store
|
873 |
+
);
|
874 |
+
|
875 |
+
$collection->joinAttribute(
|
876 |
+
'description',
|
877 |
+
'catalog_product/description',
|
878 |
+
'entity_id',
|
879 |
+
null,
|
880 |
+
'left',
|
881 |
+
$store
|
882 |
+
);
|
883 |
+
|
884 |
+
if ($code = $this->_getBrandAttributeCode($store)) {
|
885 |
+
$collection->joinAttribute(
|
886 |
+
'product_brand',
|
887 |
+
sprintf('catalog_product/%s', $code),
|
888 |
+
'entity_id',
|
889 |
+
null,
|
890 |
+
'left',
|
891 |
+
$store
|
892 |
+
);
|
893 |
+
}
|
894 |
+
|
895 |
+
if ($code = $this->_getEanAttributeCode($store)) {
|
896 |
+
$collection->joinAttribute(
|
897 |
+
'product_ean',
|
898 |
+
sprintf('catalog_product/%s', $code),
|
899 |
+
'entity_id',
|
900 |
+
null,
|
901 |
+
'left',
|
902 |
+
$store
|
903 |
+
);
|
904 |
+
}
|
905 |
+
|
906 |
+
return $collection;
|
907 |
+
}
|
908 |
+
|
909 |
+
private function _getChildrenProductsCollection($store)
|
910 |
+
{
|
911 |
+
$parentIdsSelect = 0;
|
912 |
+
|
913 |
+
$configurableIdsCollection = $this->_getConfigurablesIdsCollection($store);
|
914 |
+
if ($configurableIdsCollection) {
|
915 |
+
$parentIdsSelect = $configurableIdsCollection->getSelect();
|
916 |
+
}
|
917 |
+
|
918 |
+
$childrenIdsSelect = sprintf("(SELECT DISTINCT main_table.product_id FROM %s as main_table
|
919 |
+
WHERE main_table.parent_id IN(%s))",
|
920 |
+
$this->_getTableName('catalog/product_super_link'),
|
921 |
+
$parentIdsSelect
|
922 |
+
);
|
923 |
+
|
924 |
+
$childCollection = Mage::getModel('catalog/product')->getCollection();
|
925 |
+
$childCollection = $this->_joinCollectionAttributes($childCollection, $store);
|
926 |
+
|
927 |
+
$childCollection->getSelect()->joinInner(array('tbl1' => new Zend_Db_Expr($childrenIdsSelect)), 'tbl1.product_id = e.entity_id', array(), null);
|
928 |
+
$childCollection->addAttributeToFilter('status', 1);
|
929 |
+
|
930 |
+
return $childCollection;
|
931 |
+
}
|
932 |
+
|
933 |
+
private function _getBrandAttributeCode($store = null)
|
934 |
+
{
|
935 |
+
if (is_null($this->_brandAttributeCode)) {
|
936 |
+
$this->_brandAttributeCode = Mage::getStoreConfig('cosmiccart/export_opt/brand_attr_code', $store);
|
937 |
+
}
|
938 |
+
return $this->_brandAttributeCode;
|
939 |
+
}
|
940 |
+
|
941 |
+
private function _getEanAttributeCode($store = null)
|
942 |
+
{
|
943 |
+
if (is_null($this->_eanAttributeCode)) {
|
944 |
+
$this->_eanAttributeCode = Mage::getStoreConfig('cosmiccart/export_opt/ean_attr_code', $store);
|
945 |
+
}
|
946 |
+
return $this->_eanAttributeCode;
|
947 |
+
}
|
948 |
+
|
949 |
+
private function _getBrandAttributeType()
|
950 |
+
{
|
951 |
+
if (!$this->_brandAttributeType) {
|
952 |
+
$code = $this->_getBrandAttributeCode($this->getStore());
|
953 |
+
$attribute = Mage::getModel('eav/entity_attribute')->loadByCode('catalog_product', $code);
|
954 |
+
if ($attribute) {
|
955 |
+
$this->_brandAttributeType = $attribute->getFrontendInput();
|
956 |
+
}
|
957 |
+
}
|
958 |
+
|
959 |
+
return $this->_brandAttributeType;
|
960 |
+
}
|
961 |
+
}
|
app/code/community/CosmicCart/Integration/Model/Mail.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
+
*
|
7 |
+
* @category CosmicCart
|
8 |
+
* @package Integration
|
9 |
+
* @copyright Copyright (c) 2015 Cosmic Cart, Inc.
|
10 |
+
* @license CosmicCart Software License https://cosmiccart.com/help/license/software
|
11 |
+
*/
|
12 |
+
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Created by IntelliJ IDEA.
|
16 |
+
* User: mcsenter
|
17 |
+
* Date: 4/18/14
|
18 |
+
* Time: 6:30 PM
|
19 |
+
*/
|
20 |
+
class CosmicCart_Integration_Model_Mail extends Mage_Core_Model_Email_Template
|
21 |
+
{
|
22 |
+
/**
|
23 |
+
* Sends email.
|
24 |
+
*
|
25 |
+
* @param $templateId
|
26 |
+
* @param $email
|
27 |
+
* @param $name
|
28 |
+
* @param $subject
|
29 |
+
* @param array $params
|
30 |
+
*/
|
31 |
+
public function sendEmail($templateId, $email, $name, $subject, $params = array())
|
32 |
+
{
|
33 |
+
$storeEmail = Mage::getStoreConfig('trans_email/ident_support/email');
|
34 |
+
$sender = array('name' => 'Cosmic Cart Magento Module', 'email' => $storeEmail);
|
35 |
+
$this->setDesignConfig(array('area' => 'frontend', 'store' => $this->getDesignConfig()->getStore()))
|
36 |
+
->setTemplateSubject($subject)
|
37 |
+
->sendTransactional(
|
38 |
+
$templateId,
|
39 |
+
$sender,
|
40 |
+
$email,
|
41 |
+
$name,
|
42 |
+
$params
|
43 |
+
);
|
44 |
+
}
|
45 |
+
}
|
app/code/community/CosmicCart/Integration/{OAuth2Client.php → Model/Oauth2client.php}
RENAMED
@@ -6,18 +6,12 @@
|
|
6 |
*
|
7 |
* @category CosmicCart
|
8 |
* @package Integration
|
9 |
-
* @copyright Copyright (c)
|
10 |
-
* @license
|
11 |
*/
|
12 |
|
13 |
-
|
14 |
-
|
15 |
-
* User: mcsenter
|
16 |
-
* Date: 9/11/13
|
17 |
-
* Time: 10:39 AM
|
18 |
-
* To change this template use File | Settings | File Templates.
|
19 |
-
*/
|
20 |
-
class OAuth2Client
|
21 |
{
|
22 |
public $baseApiUrl = '';
|
23 |
public $client_id = '';
|
@@ -25,10 +19,9 @@ class OAuth2Client
|
|
25 |
public $grant_type = 'password';
|
26 |
public $accessTokenUri = 'oauth/token';
|
27 |
|
28 |
-
public function
|
29 |
{
|
30 |
-
$
|
31 |
-
$this->baseApiUrl = $settings['base_api_url'];
|
32 |
if (empty($client_id)) {
|
33 |
$client = $this->loadClient();
|
34 |
$client_id = $client->getClientId();
|
@@ -36,6 +29,8 @@ class OAuth2Client
|
|
36 |
}
|
37 |
$this->client_id = $client_id;
|
38 |
$this->client_secret = $client_secret;
|
|
|
|
|
39 |
}
|
40 |
|
41 |
public function getAccessToken($username, $password)
|
@@ -51,15 +46,14 @@ class OAuth2Client
|
|
51 |
|
52 |
public function get($api, $params, $header = null)
|
53 |
{
|
54 |
-
|
55 |
-
error_log("GET URL: $url");
|
56 |
$ch = curl_init($url);
|
57 |
curl_setopt_array($ch, array(
|
58 |
CURLOPT_RETURNTRANSFER => 1,
|
59 |
CURLOPT_HTTPHEADER => array($header)
|
60 |
));
|
61 |
$response = curl_exec($ch);
|
62 |
-
|
63 |
return json_decode($response);
|
64 |
}
|
65 |
|
@@ -112,6 +106,10 @@ class OAuth2Client
|
|
112 |
return $this->post('subOrder/package', $package);
|
113 |
}
|
114 |
|
|
|
|
|
|
|
|
|
115 |
private function post($api, $params, $accessToken = null)
|
116 |
{
|
117 |
$response = null;
|
@@ -119,10 +117,8 @@ class OAuth2Client
|
|
119 |
$accessToken = $this->loadAccessToken();
|
120 |
}
|
121 |
if (!empty($accessToken)) {
|
122 |
-
error_log('Posting to: ' . $this->getApiUrl($api));
|
123 |
$ch = curl_init($this->getApiUrl($api));
|
124 |
$params = json_encode($params);
|
125 |
-
error_log($params);
|
126 |
$headers = array(
|
127 |
'Content-Type: application/json',
|
128 |
'Content-Length: ' . strlen($params)
|
@@ -130,20 +126,26 @@ class OAuth2Client
|
|
130 |
$headers[] = $this->createAccessTokenHeader($accessToken);
|
131 |
curl_setopt_array($ch, array(
|
132 |
CURLOPT_POST => 1,
|
133 |
-
CURLOPT_SSL_VERIFYPEER =>
|
134 |
CURLOPT_POSTFIELDS => $params,
|
135 |
CURLOPT_RETURNTRANSFER => true,
|
136 |
CURLOPT_HTTPHEADER => $headers
|
137 |
));
|
138 |
$response = curl_exec($ch);
|
|
|
139 |
curl_close($ch);
|
140 |
-
error_log($response);
|
141 |
if (empty($response)) {
|
142 |
throw new Exception('Could not communicate with Cosmic Cart.');
|
143 |
} else {
|
144 |
$response = json_decode($response);
|
145 |
-
if (
|
146 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
}
|
148 |
}
|
149 |
} else {
|
@@ -167,7 +169,6 @@ class OAuth2Client
|
|
167 |
|
168 |
private function loadAccessToken()
|
169 |
{
|
170 |
-
error_log("Need to load accessToken...");
|
171 |
$accessToken = null;
|
172 |
$accessTokens = Mage::getModel('cosmiccart_integration/accessToken')->getCollection();
|
173 |
foreach ($accessTokens as $token) {
|
@@ -175,7 +176,6 @@ class OAuth2Client
|
|
175 |
break;
|
176 |
}
|
177 |
if (!empty($accessToken)) {
|
178 |
-
error_log("Found access token in database: $accessToken");
|
179 |
$now = time();
|
180 |
$expires = $accessToken->getExpires();
|
181 |
if ($now >= $expires) {
|
@@ -197,7 +197,6 @@ class OAuth2Client
|
|
197 |
protected function createAccessTokenHeader($accessToken)
|
198 |
{
|
199 |
$header = 'Authorization: Bearer ' . $accessToken->getAccessToken();
|
200 |
-
error_log("added auth header: $header");
|
201 |
return $header;
|
202 |
}
|
203 |
|
@@ -220,4 +219,4 @@ class OAuth2Client
|
|
220 |
#echo("<script> top.location.href='index.php#".$this->provider."'</script>");
|
221 |
|
222 |
}
|
223 |
-
}
|
6 |
*
|
7 |
* @category CosmicCart
|
8 |
* @package Integration
|
9 |
+
* @copyright Copyright (c) 2015 Cosmic Cart, Inc.
|
10 |
+
* @license CosmicCart Software License https://cosmiccart.com/help/license/software
|
11 |
*/
|
12 |
|
13 |
+
|
14 |
+
class CosmicCart_Integration_Model_Oauth2client extends Varien_Object
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
{
|
16 |
public $baseApiUrl = '';
|
17 |
public $client_id = '';
|
19 |
public $grant_type = 'password';
|
20 |
public $accessTokenUri = 'oauth/token';
|
21 |
|
22 |
+
public function init($client_id = null, $client_secret = null)
|
23 |
{
|
24 |
+
$this->baseApiUrl = Mage::helper('cosmiccart_integration')->getApiUrl();
|
|
|
25 |
if (empty($client_id)) {
|
26 |
$client = $this->loadClient();
|
27 |
$client_id = $client->getClientId();
|
29 |
}
|
30 |
$this->client_id = $client_id;
|
31 |
$this->client_secret = $client_secret;
|
32 |
+
|
33 |
+
return $this;
|
34 |
}
|
35 |
|
36 |
public function getAccessToken($username, $password)
|
46 |
|
47 |
public function get($api, $params, $header = null)
|
48 |
{
|
49 |
+
$url = $this->getApiUrl($api, $params);
|
|
|
50 |
$ch = curl_init($url);
|
51 |
curl_setopt_array($ch, array(
|
52 |
CURLOPT_RETURNTRANSFER => 1,
|
53 |
CURLOPT_HTTPHEADER => array($header)
|
54 |
));
|
55 |
$response = curl_exec($ch);
|
56 |
+
curl_close($ch);
|
57 |
return json_decode($response);
|
58 |
}
|
59 |
|
106 |
return $this->post('subOrder/package', $package);
|
107 |
}
|
108 |
|
109 |
+
public function refund($subOrderId, $refund) {
|
110 |
+
return $this->post('sellers/orders/'.$subOrderId.'/refunds', $refund);
|
111 |
+
}
|
112 |
+
|
113 |
private function post($api, $params, $accessToken = null)
|
114 |
{
|
115 |
$response = null;
|
117 |
$accessToken = $this->loadAccessToken();
|
118 |
}
|
119 |
if (!empty($accessToken)) {
|
|
|
120 |
$ch = curl_init($this->getApiUrl($api));
|
121 |
$params = json_encode($params);
|
|
|
122 |
$headers = array(
|
123 |
'Content-Type: application/json',
|
124 |
'Content-Length: ' . strlen($params)
|
126 |
$headers[] = $this->createAccessTokenHeader($accessToken);
|
127 |
curl_setopt_array($ch, array(
|
128 |
CURLOPT_POST => 1,
|
129 |
+
CURLOPT_SSL_VERIFYPEER => true,
|
130 |
CURLOPT_POSTFIELDS => $params,
|
131 |
CURLOPT_RETURNTRANSFER => true,
|
132 |
CURLOPT_HTTPHEADER => $headers
|
133 |
));
|
134 |
$response = curl_exec($ch);
|
135 |
+
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
136 |
curl_close($ch);
|
|
|
137 |
if (empty($response)) {
|
138 |
throw new Exception('Could not communicate with Cosmic Cart.');
|
139 |
} else {
|
140 |
$response = json_decode($response);
|
141 |
+
if ($statusCode >= 400 && $statusCode <= 600) {
|
142 |
+
if (!empty($response->error)) {
|
143 |
+
throw new Exception($response->error_description);
|
144 |
+
} else if (!empty($response->message)) {
|
145 |
+
throw new Exception($response->message);
|
146 |
+
} else {
|
147 |
+
throw new Exception('Could not reach Cosmic Cart API '.$api.' '.$statusCode);
|
148 |
+
}
|
149 |
}
|
150 |
}
|
151 |
} else {
|
169 |
|
170 |
private function loadAccessToken()
|
171 |
{
|
|
|
172 |
$accessToken = null;
|
173 |
$accessTokens = Mage::getModel('cosmiccart_integration/accessToken')->getCollection();
|
174 |
foreach ($accessTokens as $token) {
|
176 |
break;
|
177 |
}
|
178 |
if (!empty($accessToken)) {
|
|
|
179 |
$now = time();
|
180 |
$expires = $accessToken->getExpires();
|
181 |
if ($now >= $expires) {
|
197 |
protected function createAccessTokenHeader($accessToken)
|
198 |
{
|
199 |
$header = 'Authorization: Bearer ' . $accessToken->getAccessToken();
|
|
|
200 |
return $header;
|
201 |
}
|
202 |
|
219 |
#echo("<script> top.location.href='index.php#".$this->provider."'</script>");
|
220 |
|
221 |
}
|
222 |
+
}
|
app/code/community/CosmicCart/Integration/Model/Observer.php
ADDED
@@ -0,0 +1,192 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
+
*
|
7 |
+
* @category CosmicCart
|
8 |
+
* @package Integration
|
9 |
+
* @copyright Copyright (c) 2015 Cosmic Cart, Inc.
|
10 |
+
* @license CosmicCart Software License https://cosmiccart.com/help/license/software
|
11 |
+
*/
|
12 |
+
|
13 |
+
|
14 |
+
class CosmicCart_Integration_Model_Observer
|
15 |
+
{
|
16 |
+
protected function _getSession()
|
17 |
+
{
|
18 |
+
return Mage::getSingleton('adminhtml/session');
|
19 |
+
}
|
20 |
+
|
21 |
+
public function onSalesOrderShipmentSaveAfter(Varien_Event_Observer $observer)
|
22 |
+
{
|
23 |
+
if (Mage::getStoreConfigFlag('cosmiccart/options/debug') == false) {
|
24 |
+
/* We are observing all shipments, but we are really interested in only those resulting from a Cosmic Cart purchase. */
|
25 |
+
$shipment = $observer->getEvent()->getShipment();
|
26 |
+
if (!$shipment) {
|
27 |
+
return $observer;
|
28 |
+
}
|
29 |
+
|
30 |
+
if ($shipment->getCosmiccartProcessed()) {
|
31 |
+
return $observer;
|
32 |
+
}
|
33 |
+
|
34 |
+
$resource = Mage::getSingleton('core/resource');
|
35 |
+
|
36 |
+
$id = $shipment->getId();
|
37 |
+
$query = sprintf("UPDATE %s SET cosmiccart_processed = 1 WHERE entity_id = %s", $resource->getTableName('sales/shipment'), $id);
|
38 |
+
Mage::getSingleton('core/resource')->getConnection('core_write')->exec($query);
|
39 |
+
|
40 |
+
$order = $shipment->getOrder();
|
41 |
+
if (!$order) {
|
42 |
+
return $observer;
|
43 |
+
}
|
44 |
+
|
45 |
+
$cosmicOrderId = $order->getCosmicCartOrderId();
|
46 |
+
if (!empty($cosmicOrderId)) {
|
47 |
+
$payment = $order->getPayment();
|
48 |
+
if (!empty($payment)) {
|
49 |
+
/* We must have a Payment and that Payment must have been with our custom "cosmiccart" method */
|
50 |
+
$methodInstance = $payment->getMethodInstance();
|
51 |
+
if ($methodInstance->canRefund() == false) {
|
52 |
+
$package = $this->shipmentToPackage($shipment);
|
53 |
+
$client = Mage::getSingleton('cosmiccart_integration/oauth2client')->init();
|
54 |
+
try {
|
55 |
+
$client->shipAndSettle($package);
|
56 |
+
} catch (Exception $e) {
|
57 |
+
$this->_getSession()->addError($e->getMessage());
|
58 |
+
|
59 |
+
$subOrderId = $package['subOrder']['id'];
|
60 |
+
$shipDate = $package['shipDate'];
|
61 |
+
$json = json_encode($package, defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0);
|
62 |
+
Mage::getModel('cosmiccart_integration/mail')->sendEmail(
|
63 |
+
'cosmiccart_integration_package_shipped_tpl', 'api-fallback@cosmiccart.com', 'Cosmic Cart API Fallback Team', 'Package Shipped (Fallback Email)', array(
|
64 |
+
'exception' => $e,
|
65 |
+
'subOrderId' => $subOrderId,
|
66 |
+
'shipDate' => $shipDate,
|
67 |
+
'json' => $json
|
68 |
+
)
|
69 |
+
);
|
70 |
+
/*code added by vishal as per the kit suggesstions*/
|
71 |
+
$shipment->delete();
|
72 |
+
$items = $order->getAllVisibleItems();
|
73 |
+
foreach ($items as $item) {
|
74 |
+
$item->setQtyShipped(0);
|
75 |
+
$item->save();
|
76 |
+
}
|
77 |
+
$order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true, 'Undo Shipment');
|
78 |
+
$order->save();
|
79 |
+
/*code added by vishal as per the kit suggesstions ends*/
|
80 |
+
throw new Exception('Could not settle card for Cosmic Cart order id ' . $subOrderId . '.');
|
81 |
+
}
|
82 |
+
}
|
83 |
+
}
|
84 |
+
}
|
85 |
+
}
|
86 |
+
return $observer;
|
87 |
+
}
|
88 |
+
|
89 |
+
public function onSalesOrderCreditmemoRefund(Varien_Event_Observer $observer)
|
90 |
+
{
|
91 |
+
Mage::log('Observed credit memo!', null, 'cosmiccart.log', true);
|
92 |
+
if (Mage::getStoreConfigFlag('cosmiccart/options/debug') == false) {
|
93 |
+
/* We are observing all creditmemos, but we are really interested in only those resulting from a Cosmic Cart purchase. */
|
94 |
+
$creditMemo = $observer->getEvent()->getCreditmemo();
|
95 |
+
if (!$creditMemo) {
|
96 |
+
return $observer;
|
97 |
+
}
|
98 |
+
|
99 |
+
$order = $creditMemo->getOrder();
|
100 |
+
if (!$order) {
|
101 |
+
return $observer;
|
102 |
+
}
|
103 |
+
|
104 |
+
$cosmicOrderId = $order->getCosmicCartOrderId();
|
105 |
+
|
106 |
+
Mage::log('Refunding CC order:', null, 'cosmiccart.log', true);
|
107 |
+
|
108 |
+
if (!empty($cosmicOrderId)) {
|
109 |
+
$payment = $order->getPayment();
|
110 |
+
if (!empty($payment)) {
|
111 |
+
/* We must have a Payment and that Payment must have been with our custom "cosmiccart" method */
|
112 |
+
$methodInstance = $payment->getMethodInstance();
|
113 |
+
if ($methodInstance->canRefund() == false) {
|
114 |
+
$refundRequest = $this->getCcRequestObject($creditMemo);
|
115 |
+
$client = Mage::getSingleton('cosmiccart_integration/oauth2client')->init();
|
116 |
+
try {
|
117 |
+
$client->refund($cosmicOrderId, $refundRequest);
|
118 |
+
} catch (Exception $e) {
|
119 |
+
$this->_getSession()->addError($e->getMessage());
|
120 |
+
Mage::log('OOPS! ' . $e->getMessage(), null, 'cosmiccart.log', true);
|
121 |
+
|
122 |
+
$json = json_encode($refundRequest, defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0);
|
123 |
+
Mage::log($json, null, 'cosmiccart.log', true);
|
124 |
+
|
125 |
+
Mage::getModel('cosmiccart_integration/mail')->sendEmail(
|
126 |
+
'cosmiccart_integration_refund_exception_tpl', 'api-fallback@cosmiccart.com',
|
127 |
+
'Cosmic Cart API Fallback Team', 'Refund Exception (Fallback Email)',
|
128 |
+
array(
|
129 |
+
'exception' => $e,
|
130 |
+
'subOrderId' => $cosmicOrderId,
|
131 |
+
'json' => $json
|
132 |
+
)
|
133 |
+
);
|
134 |
+
throw new Exception('Could not issue refund for Cosmic Cart order id ' . $cosmicOrderId . '.');
|
135 |
+
}
|
136 |
+
}
|
137 |
+
}
|
138 |
+
}
|
139 |
+
}
|
140 |
+
return $this;
|
141 |
+
}
|
142 |
+
|
143 |
+
private function shipmentToPackage(Mage_Sales_Model_Order_Shipment $shipment)
|
144 |
+
{
|
145 |
+
$dateTime = DateTime::createFromFormat('Y-m-d H:i:s', $shipment->getCreatedAt());
|
146 |
+
$package = array(
|
147 |
+
'subOrder' => array('id' => (int)$shipment->getOrder()->getCosmicCartOrderId()),
|
148 |
+
'packageItems' => array(),
|
149 |
+
'shipDate' => $dateTime->format('c'),
|
150 |
+
'trackings' => array()
|
151 |
+
);
|
152 |
+
foreach ($shipment->getTracksCollection() as $track) {
|
153 |
+
$package['trackings'][] = $track->getNumber();
|
154 |
+
}
|
155 |
+
$packageItemNumber = 0;
|
156 |
+
foreach ($shipment->getItemsCollection() as $item) {
|
157 |
+
$orderItem = Mage::getModel('sales/order_item')->load($item->getOrderItemId());
|
158 |
+
for ($i = 0; $i < $item->getQty(); ++$i) {
|
159 |
+
$packageItem = array(
|
160 |
+
'orderItem' => array('id' => (int)$orderItem->getCosmicCartOrderItemId()),
|
161 |
+
'number' => $packageItemNumber
|
162 |
+
);
|
163 |
+
$package['packageItems'][] = $packageItem;
|
164 |
+
$packageItemNumber++;
|
165 |
+
}
|
166 |
+
}
|
167 |
+
return $package;
|
168 |
+
}
|
169 |
+
|
170 |
+
private function getCcRequestObject($creditmemo)
|
171 |
+
{
|
172 |
+
$items = array();
|
173 |
+
foreach ($creditmemo->getAllItems() as $item) {
|
174 |
+
$orderItem = Mage::getModel('sales/order_item')->load($item->getOrderItemId());
|
175 |
+
array_push($items, array(
|
176 |
+
'id' => $orderItem->getCosmicCartOrderItemId(),
|
177 |
+
'quantity' => $item->getQty()
|
178 |
+
));
|
179 |
+
}
|
180 |
+
return array(
|
181 |
+
'productAmount' => $creditmemo->getSubtotal(),
|
182 |
+
'shippingAmount' => $creditmemo->getBaseShippingAmount(),
|
183 |
+
'taxAmount' => $creditmemo->getBaseTaxAmount(),
|
184 |
+
'shippingTaxAmount' => $creditmemo->getBaseShippingTaxAmount(),
|
185 |
+
'adjustmentAmount' => $creditmemo->getBaseAdjustmentPositive(),
|
186 |
+
'feeAmount' => $creditmemo->getBaseAdjustmentNegative(),
|
187 |
+
'items' => $items
|
188 |
+
);
|
189 |
+
}
|
190 |
+
|
191 |
+
|
192 |
+
}
|
app/code/community/CosmicCart/Integration/Model/Order/Api/V2.php
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
/*
|
2 |
* NOTICE OF LICENSE
|
3 |
*
|
@@ -5,257 +6,367 @@
|
|
5 |
*
|
6 |
* @category CosmicCart
|
7 |
* @package Integration
|
8 |
-
* @copyright Copyright (c)
|
9 |
-
* @license
|
10 |
*/
|
11 |
|
12 |
-
<?
|
13 |
-
|
14 |
class CosmicCart_Integration_Model_Order_Api_V2 extends Mage_Sales_Model_Order_Api_V2
|
15 |
{
|
16 |
-
|
17 |
-
public function create($orderData)
|
18 |
{
|
|
|
19 |
$response = null;
|
20 |
try {
|
21 |
-
|
22 |
-
$
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
} else {
|
|
|
50 |
$itemsToFail[] = $item;
|
51 |
}
|
52 |
} else {
|
|
|
53 |
$itemsToFail[] = $item;
|
54 |
}
|
|
|
|
|
|
|
55 |
}
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
$
|
60 |
-
|
61 |
-
/*
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
foreach ($quoteItems as &$quoteItem) {
|
76 |
-
foreach ($itemsToAdd as $item) {
|
77 |
-
if ($item->sku == $quoteItem->getSku()) {
|
78 |
-
$quoteItem->setCosmicCartOrderItemId($item->orderItemId);
|
79 |
-
$quoteItem->setOriginalCustomPrice($item->price);
|
80 |
-
break;
|
81 |
-
}
|
82 |
-
}
|
83 |
-
}
|
84 |
-
$quote->setTotalsCollectedFlag(false)->collectTotals();
|
85 |
-
$quote->save();
|
86 |
-
|
87 |
-
/* Set the customer */
|
88 |
-
$cartCustomerApi = Mage::getSingleton("Mage_Checkout_Model_Cart_Customer_Api_V2");
|
89 |
-
$cartCustomerApi->set($quoteId, $orderData->customer);
|
90 |
-
$cartCustomerApi->setAddresses($quoteId, $orderData->customer_addresses);
|
91 |
-
|
92 |
-
/*
|
93 |
-
Set the shipping method.
|
94 |
-
|
95 |
-
What happens here is that Cosmic Cart has set a ShippingOption on each OrderItem in the Order.
|
96 |
-
However, we must currently use the same ShippingOption for all OrderItems. #businessrule
|
97 |
-
*/
|
98 |
-
$cartShippingApi = Mage::getSingleton("Mage_Checkout_Model_Cart_Shipping_Api_V2");
|
99 |
-
$cartShippingApi->setShippingMethod($quoteId, $itemsToAdd[0]->shippingOption);
|
100 |
-
|
101 |
-
/* Set our custom payment method */
|
102 |
-
$cartPaymentApi = Mage::getSingleton("Mage_Checkout_Model_Cart_Payment_Api");
|
103 |
-
$cartPaymentApi->setPaymentMethod($quoteId, array("method" => "cosmiccart"));
|
104 |
-
|
105 |
-
/* Convert our cart to an order */
|
106 |
-
$orderId = $cartApi->createOrder($quoteId);
|
107 |
-
$order = $this->_initOrder($orderId);
|
108 |
-
$order->setCustomerEmail($orderData->customer->email);
|
109 |
-
$order->setCosmicCartOrderId($orderData->orderId);
|
110 |
-
$order->save();
|
111 |
-
|
112 |
-
/* Invoice (pay for) our order. */
|
113 |
-
$salesOrderInvoiceApi = Mage::getSingleton("Mage_Sales_Model_Order_Invoice_Api_V2");
|
114 |
-
$invoiceId = $salesOrderInvoiceApi->create($orderId, array(), "Payment authorized. Awaiting settlement via Cosmic Cart when items ship.");
|
115 |
-
$invoice = Mage::getModel('sales/order_invoice')->load($invoiceId);
|
116 |
-
$invoice->pay();
|
117 |
-
$transactionSave = Mage::getModel('core/resource_transaction')
|
118 |
-
->addObject($invoice)
|
119 |
-
->addObject($invoice->getOrder())
|
120 |
-
->save();
|
121 |
-
|
122 |
-
/* Gotta reload the order to get a version with all the updates performed by the invoicing. */
|
123 |
-
$order = $this->_initOrder($orderId);
|
124 |
-
|
125 |
-
foreach ($order->getItemsCollection() as $item) {
|
126 |
-
$itemStatus = new stdClass;
|
127 |
-
$itemStatus->qtyFailed = 0; // Default
|
128 |
-
$itemStatus->sku = $item->getSku();
|
129 |
-
foreach ($itemsToAdd as $itemRequested) {
|
130 |
-
if ($itemRequested->sku == $itemStatus->sku) {
|
131 |
-
$item->setCosmicCartOrderItemId($itemRequested->orderItemId);
|
132 |
-
$item->save();
|
133 |
-
$itemStatus->qtyRequested = $itemRequested->originalQty;
|
134 |
-
break;
|
135 |
-
}
|
136 |
-
}
|
137 |
-
$itemStatus->tax = $item->getTaxAmount();
|
138 |
-
$itemStatus->qtyBackordered = $item->getQtyBackordered();
|
139 |
-
foreach ($itemsToFail as $itemToFail) {
|
140 |
-
if ($itemToFail->sku == $itemStatus->sku) {
|
141 |
-
$itemStatus->qtyFailed = $itemToFail->qty;
|
142 |
-
$itemsFailed[] = $itemStatus;
|
143 |
-
break;
|
144 |
-
}
|
145 |
-
}
|
146 |
-
$itemStatus->qtyAllocated = $itemStatus->qtyRequested - $itemStatus->qtyBackordered - $itemStatus->qtyFailed;
|
147 |
-
$itemStatuses[] = $itemStatus;
|
148 |
-
}
|
149 |
-
}
|
150 |
-
/* Completely failed items won't be returned by the other API calls, but we still need to return a status for them. */
|
151 |
-
foreach ($itemsToFail as $itemToFail) {
|
152 |
-
$yetToFail = true;
|
153 |
-
foreach ($itemsFailed as $itemAlreadyFailed) {
|
154 |
-
if ($itemAlreadyFailed->sku == $itemToFail->sku) {
|
155 |
-
$yetToFail = false;
|
156 |
break;
|
157 |
}
|
158 |
}
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
}
|
168 |
}
|
|
|
169 |
|
170 |
-
|
171 |
-
|
172 |
-
'items' => $itemStatuses
|
173 |
-
);
|
174 |
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
|
|
|
|
|
|
179 |
|
180 |
-
|
181 |
-
|
182 |
|
183 |
-
|
184 |
-
|
185 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
|
187 |
-
|
188 |
-
$results = $cartShippingApi->getShippingMethodsList($quote->getId());
|
189 |
|
190 |
-
|
191 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
192 |
|
193 |
-
|
|
|
|
|
|
|
|
|
|
|
194 |
}
|
195 |
|
196 |
-
protected function
|
197 |
{
|
198 |
-
|
199 |
-
|
200 |
-
$
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
$quote = Mage::getModel('sales/quote')->load($quoteId);
|
206 |
-
$quote->getBillingAddress();
|
207 |
-
$quoteItems = $quote->getItemsCollection();
|
208 |
-
foreach ($quoteItems as &$quoteItem) {
|
209 |
-
foreach ($orderItemsData as $item) {
|
210 |
-
if ($item->sku == $quoteItem->getSku()) {
|
211 |
-
$quoteItem->setOriginalCustomPrice($item->price);
|
212 |
break;
|
213 |
}
|
214 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
215 |
}
|
|
|
|
|
216 |
|
217 |
-
|
218 |
-
|
219 |
-
$
|
220 |
-
$
|
221 |
-
$
|
222 |
-
|
223 |
-
$
|
224 |
-
$
|
225 |
-
|
226 |
-
$quote
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
231 |
}
|
232 |
-
|
|
|
|
|
|
|
|
|
233 |
}
|
234 |
|
235 |
-
public function
|
236 |
{
|
237 |
-
$
|
238 |
-
$
|
239 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
240 |
}
|
241 |
|
242 |
-
|
243 |
{
|
244 |
-
$
|
245 |
-
$
|
|
|
|
|
246 |
|
247 |
-
|
|
|
|
|
248 |
|
249 |
-
|
250 |
-
|
251 |
-
$
|
252 |
-
$
|
253 |
-
|
254 |
|
255 |
-
|
256 |
-
|
|
|
|
|
|
|
|
|
257 |
|
258 |
-
|
|
|
|
|
259 |
}
|
260 |
|
261 |
-
}
|
1 |
+
<?php
|
2 |
/*
|
3 |
* NOTICE OF LICENSE
|
4 |
*
|
6 |
*
|
7 |
* @category CosmicCart
|
8 |
* @package Integration
|
9 |
+
* @copyright Copyright (c) 2015 Cosmic Cart, Inc.
|
10 |
+
* @license CosmicCart Software License https://cosmiccart.com/help/license/software
|
11 |
*/
|
12 |
|
|
|
|
|
13 |
class CosmicCart_Integration_Model_Order_Api_V2 extends Mage_Sales_Model_Order_Api_V2
|
14 |
{
|
15 |
+
public function create($orderData, $store)
|
|
|
16 |
{
|
17 |
+
$this->initErrorHandler($store);
|
18 |
$response = null;
|
19 |
try {
|
20 |
+
|
21 |
+
$orderDataItems = isset($orderData['items']) ? $orderData['items'] : null;
|
22 |
+
if (!$orderDataItems) {
|
23 |
+
Mage::throwException('Order data items are missing!');
|
24 |
+
}
|
25 |
+
|
26 |
+
$ccOrderId = isset($orderData['order_id']) ? $orderData['order_id'] : null;
|
27 |
+
$quoteInfo = $this->_createQuoteInfo($store, $orderDataItems, $ccOrderId);
|
28 |
+
|
29 |
+
$response = $this->_createOrder($store, $orderData, $quoteInfo);
|
30 |
+
|
31 |
+
} catch (Mage_Core_Exception $e) {
|
32 |
+
throw $e;
|
33 |
+
}
|
34 |
+
return $response;
|
35 |
+
}
|
36 |
+
|
37 |
+
private function _createQuoteInfo($store, $orderItemsData, $cosmicCartOrderId = null)
|
38 |
+
{
|
39 |
+
/* Determine stock status for each requested item and make adjustments if necessary. */
|
40 |
+
$itemsToAdd = array();
|
41 |
+
$itemsToFail = array();
|
42 |
+
$quote = null;
|
43 |
+
|
44 |
+
foreach ($orderItemsData as $item) {
|
45 |
+
|
46 |
+
$itemQty = isset($item['qty']) ? $item['qty'] : 0;
|
47 |
+
|
48 |
+
/* Check the stock level of each item and sort appropriately. */
|
49 |
+
$item['original_qty'] = $itemQty;
|
50 |
+
|
51 |
+
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $item['sku']);
|
52 |
+
if ($product AND $product->getId() AND $product->isSaleable()) {
|
53 |
+
|
54 |
+
$stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
|
55 |
+
if ($stockItem AND $stockItem->getId()) {
|
56 |
+
|
57 |
+
$inStock = $stockItem->getIsInStock();
|
58 |
+
$qtyInStock = $stockItem->getQty();
|
59 |
+
|
60 |
+
$isBackorderable = $stockItem->getBackorders() != Mage_CatalogInventory_Model_Stock::BACKORDERS_NO;
|
61 |
+
|
62 |
+
if ($inStock AND ($isBackorderable || $qtyInStock >= $item['qty'])) {
|
63 |
+
/* If we have plenty of stock or the item is backorderable, proceed as normal. */
|
64 |
+
$itemsToAdd[] = $item;
|
65 |
+
} else if ($inStock AND $qtyInStock > 0) {
|
66 |
+
/* If we only have a few we can allocate from our requested quantity, do that, and put the rest
|
67 |
+
in a failed item. */
|
68 |
+
$item['qty'] = $qtyInStock;
|
69 |
+
$itemsToAdd[] = $item;
|
70 |
+
|
71 |
+
$itemToFail = array();
|
72 |
+
$itemToFail['sku'] = $item['sku'];
|
73 |
+
$itemToFail['original_qty'] = $item['original_qty'];
|
74 |
+
$itemToFail['qty'] = $item['original_qty'] - $qtyInStock;
|
75 |
+
$itemToFail['qty_allocated'] = $itemToFail['original_qty'] - $itemToFail['qty'];
|
76 |
+
$itemsToFail[] = $itemToFail;
|
77 |
} else {
|
78 |
+
$item['qty_allocated'] = 0;
|
79 |
$itemsToFail[] = $item;
|
80 |
}
|
81 |
} else {
|
82 |
+
$item['qty_allocated'] = 0;
|
83 |
$itemsToFail[] = $item;
|
84 |
}
|
85 |
+
} else {
|
86 |
+
$item['qty_allocated'] = 0;
|
87 |
+
$itemsToFail[] = $item;
|
88 |
}
|
89 |
+
}
|
90 |
+
if (count($itemsToAdd) > 0) {
|
91 |
+
/* Create the quote */
|
92 |
+
$cartApi = Mage::getSingleton('checkout/cart_api_v2');
|
93 |
+
$quoteId = $cartApi->create($store);
|
94 |
+
/* Add the items to the quote */
|
95 |
+
$cartProductApi = Mage::getSingleton('checkout/cart_product_api_v2');
|
96 |
+
$cartProductApi->add($quoteId, $itemsToAdd, $store);
|
97 |
+
|
98 |
+
/* The default api does not allow us to set custom pricing. So let's do that ourselves. */
|
99 |
+
$quote = Mage::getModel('sales/quote')->loadByIdWithoutStore($quoteId);
|
100 |
+
$quote->setCosmicCartOrderId($cosmicCartOrderId);
|
101 |
+
|
102 |
+
$quoteItems = $quote->getItemsCollection();
|
103 |
+
foreach ($quoteItems as &$quoteItem) {
|
104 |
+
foreach ($itemsToAdd as $item) {
|
105 |
+
if ($item['sku'] == $quoteItem->getSku()) {
|
106 |
+
$quoteItem->setCosmicCartOrderItemId($item['order_item_id']);
|
107 |
+
$quoteItem->setOriginalCustomPrice($item['price']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
break;
|
109 |
}
|
110 |
}
|
111 |
+
}
|
112 |
+
$quote->setTotalsCollectedFlag(false)->collectTotals();
|
113 |
+
$quote->save();
|
114 |
+
}
|
115 |
+
$quoteInfo = array(
|
116 |
+
'quote' => $quote,
|
117 |
+
'itemsToAdd' => $itemsToAdd,
|
118 |
+
'itemsToFail' => $itemsToFail
|
119 |
+
);
|
120 |
+
return $quoteInfo;
|
121 |
+
}
|
122 |
+
|
123 |
+
private function _createOrder($store, $orderData, $quoteInfo)
|
124 |
+
{
|
125 |
+
$itemStatuses = array();
|
126 |
+
$quote = isset($quoteInfo['quote']) ? $quoteInfo['quote'] : null;
|
127 |
+
$itemsToAdd = $quoteInfo['itemsToAdd'];
|
128 |
+
$itemsToFail = $quoteInfo['itemsToFail'];
|
129 |
+
$orderId = null;
|
130 |
+
$orderIncrementId = null;
|
131 |
+
|
132 |
+
$customer = isset($orderData['customer']) ? $orderData['customer'] : null;
|
133 |
+
$customerAddresses = isset($orderData['customer_addresses']) ? $orderData['customer_addresses'] : null;
|
134 |
+
$customerEmail = isset($orderData['customer']['email']) ? $orderData['customer']['email'] : null;
|
135 |
+
|
136 |
+
$ccOrderId = isset($orderData['order_id']) ? $orderData['order_id'] : null;
|
137 |
+
|
138 |
+
if ($customerAddresses AND is_array($customerAddresses) AND count($customerAddresses)) {
|
139 |
+
foreach ($customerAddresses as $key => $val) {
|
140 |
+
if (is_array($val)) {
|
141 |
+
$customerAddresses[$key] = (object)$val;
|
142 |
}
|
143 |
}
|
144 |
+
}
|
145 |
|
146 |
+
/* Break our results into those added and those backordered. */
|
147 |
+
$itemsFailed = array();
|
|
|
|
|
148 |
|
149 |
+
/* Can't add any items if none are available. */
|
150 |
+
if ($quote AND count($itemsToAdd) > 0) {
|
151 |
+
$quoteId = $quote->getId();
|
152 |
+
/* Set the customer */
|
153 |
+
$cartCustomerApi = Mage::getSingleton('checkout/cart_customer_api_v2');
|
154 |
+
$cartCustomerApi->set($quoteId, (object)$customer, $store);
|
155 |
+
$cartCustomerApi->setAddresses($quoteId, $customerAddresses, $store);
|
156 |
|
157 |
+
/*
|
158 |
+
Set the shipping method.
|
159 |
|
160 |
+
What happens here is that Cosmic Cart has set a ShippingOption on each OrderItem in the Order.
|
161 |
+
However, we must currently use the same ShippingOption for all OrderItems. #businessrule
|
162 |
+
*/
|
163 |
+
$shippingOption = $itemsToAdd[0]['shipping_option'];
|
164 |
+
|
165 |
+
$cartShippingApi = Mage::getSingleton('checkout/cart_shipping_api_v2');
|
166 |
+
$cartShippingApi->setShippingMethod($quoteId, $shippingOption, $store);
|
167 |
+
|
168 |
+
/* Set our custom payment method */
|
169 |
+
$cartPaymentApi = Mage::getSingleton("checkout/cart_payment_api");
|
170 |
+
|
171 |
+
$methodCode = Mage::helper('cosmiccart_integration')->getCosmicCartPaymentMethod();
|
172 |
+
$methodCode = empty($methodCode) ? 'cosmiccart' : $methodCode;
|
173 |
|
174 |
+
$cartPaymentApi->setPaymentMethod($quoteId, array('method' => $methodCode, '0' => null), $store);
|
|
|
175 |
|
176 |
+
/* Due to interesting Magento API goings-on around guest customers, we have to set the billing email */
|
177 |
+
$quote = Mage::getModel('sales/quote')->loadByIdWithoutStore($quoteId);
|
178 |
+
$quote->getBillingAddress()->setEmail($customerEmail);
|
179 |
+
$quote->getBillingAddress()->save();
|
180 |
+
|
181 |
+
/* Convert our cart to an order */
|
182 |
+
$cartApi = Mage::getSingleton("checkout/cart_api_v2");
|
183 |
+
|
184 |
+
$orderId = $cartApi->createOrder($quoteId, $store);
|
185 |
+
$order = $this->_initOrder($orderId);
|
186 |
+
|
187 |
+
$order->setCustomerEmail($customerEmail);
|
188 |
+
$order->getBillingAddress()->setEmail($customerEmail);
|
189 |
+
|
190 |
+
$order->getShippingAddress()->setEmail($customerEmail);
|
191 |
+
$order->setCosmicCartOrderId($ccOrderId);
|
192 |
+
|
193 |
+
$order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true, 'Funds have been authorized via Cosmic Cart. Ship to settle.');
|
194 |
+
$order->save();
|
195 |
+
|
196 |
+
/* Invoice (pay for) our order. */
|
197 |
+
$salesOrderInvoiceApi = Mage::getSingleton('sales/order_invoice_api_v2');
|
198 |
+
$invoiceId = $salesOrderInvoiceApi->create($orderId, array(), 'Payment authorized. Awaiting settlement via Cosmic Cart when items ship.');
|
199 |
+
|
200 |
+
$invoice = Mage::getModel('sales/order_invoice')->loadByIncrementId($invoiceId);
|
201 |
+
$invoice->pay();
|
202 |
+
|
203 |
+
Mage::getModel('core/resource_transaction')
|
204 |
+
->addObject($invoice)
|
205 |
+
->addObject($invoice->getOrder())
|
206 |
+
->save();
|
207 |
+
|
208 |
+
/* Gotta reload the order to get a version with all the updates performed by the invoicing. */
|
209 |
+
$order = $this->_initOrder($orderId);
|
210 |
+
$orderIncrementId = $order->getIncrementId();
|
211 |
+
|
212 |
+
foreach ($order->getItemsCollection() as $item) {
|
213 |
+
$itemStatus = array();
|
214 |
+
$itemStatus['qty_failed'] = 0; // Default
|
215 |
+
$itemStatus['sku'] = $item->getSku();
|
216 |
+
|
217 |
+
foreach ($itemsToAdd as $itemRequested) {
|
218 |
+
|
219 |
+
if ($itemRequested['sku'] == $itemStatus['sku']) {
|
220 |
+
$orderItemId = isset($itemRequested['order_item_id']) ? $itemRequested['order_item_id'] : null;
|
221 |
+
|
222 |
+
$item->setCosmicCartOrderItemId($orderItemId);
|
223 |
+
$item->save();
|
224 |
+
|
225 |
+
$originalQty = isset($itemRequested['original_qty']) ? $itemRequested['original_qty'] : 0;
|
226 |
+
$itemStatus['qty_requested'] = $originalQty;
|
227 |
+
break;
|
228 |
+
}
|
229 |
+
|
230 |
+
}
|
231 |
+
|
232 |
+
$itemStatus['tax'] = $item->getTaxAmount();
|
233 |
+
$itemStatus['qty_backordered'] = $item->getQtyBackordered();
|
234 |
+
|
235 |
+
foreach ($itemsToFail as $itemToFail) {
|
236 |
+
if ($itemToFail['sku'] == $itemStatus['sku']) {
|
237 |
+
$itemStatus['qty_failed'] = $itemToFail['qty'];
|
238 |
+
$itemsFailed[] = $itemStatus;
|
239 |
+
break;
|
240 |
+
}
|
241 |
+
}
|
242 |
+
$itemStatus['qty_allocated'] = $itemStatus['qty_requested'] - $itemStatus['qty_backordered'] - $itemStatus['qty_failed'];
|
243 |
+
$itemStatuses[] = $itemStatus;
|
244 |
+
}
|
245 |
+
}
|
246 |
|
247 |
+
$itemStatuses = array_merge($itemStatuses, $this->_getStatusesForFailedItems($itemsToFail, $itemsFailed));
|
248 |
+
return array(
|
249 |
+
'order_id' => $orderId,
|
250 |
+
'customer_order_number' => $orderIncrementId,
|
251 |
+
'items' => $itemStatuses
|
252 |
+
);
|
253 |
}
|
254 |
|
255 |
+
protected function _getStatusesForFailedItems($itemsToFail = array(), $itemsAlreadyFailed = array())
|
256 |
{
|
257 |
+
$itemStatuses = array();
|
258 |
+
/* Completely failed items won't be returned by the other API calls, but we still need to return a status for them. */
|
259 |
+
foreach ($itemsToFail as $itemToFail) {
|
260 |
+
$yetToFail = true;
|
261 |
+
foreach ($itemsAlreadyFailed as $itemAlreadyFailed) {
|
262 |
+
if ($itemAlreadyFailed['sku'] == $itemToFail['sku']) {
|
263 |
+
$yetToFail = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
264 |
break;
|
265 |
}
|
266 |
}
|
267 |
+
if ($yetToFail) {
|
268 |
+
$itemStatus = array();
|
269 |
+
$itemStatus['sku'] = $itemToFail['sku'];
|
270 |
+
$itemStatus['qty_requested'] = $itemToFail['original_qty'];
|
271 |
+
$itemStatus['qty_allocated'] = $itemToFail['qty_allocated'];
|
272 |
+
$itemStatus['qty_backordered'] = 0;
|
273 |
+
$itemStatus['qty_failed'] = $itemToFail['qty'];
|
274 |
+
$itemStatus['tax'] = 0;
|
275 |
+
$itemStatuses[] = $itemStatus;
|
276 |
+
}
|
277 |
}
|
278 |
+
return $itemStatuses;
|
279 |
+
}
|
280 |
|
281 |
+
public function getSalesTax($addressData, $orderItemsData, $store)
|
282 |
+
{
|
283 |
+
$this->initErrorHandler($store);
|
284 |
+
$salesTax = 0.0;
|
285 |
+
$shippingTax = 0.0;
|
286 |
+
|
287 |
+
$quoteInfo = $this->_createTemporaryQuote($store, $addressData, $orderItemsData);
|
288 |
+
$quote = isset($quoteInfo['quote']) ? $quoteInfo['quote'] : null;
|
289 |
+
|
290 |
+
if (!empty($quote) AND $quoteId = $quote->getId()) {
|
291 |
+
$shippingAddress = $quote->getShippingAddress();
|
292 |
+
$salesTax = $shippingAddress->getTaxAmount();
|
293 |
+
if (!isset($salesTax)) {
|
294 |
+
$salesTax = 0.0;
|
295 |
+
}
|
296 |
+
$shippingTax = $shippingAddress->getShippingTaxAmount();
|
297 |
+
if (!isset($shippingTax)) {
|
298 |
+
$shippingTax = 0.0;
|
299 |
+
}
|
300 |
+
$quote->getShippingAddress()->delete();
|
301 |
+
$quote->delete();
|
302 |
}
|
303 |
+
$response = array();
|
304 |
+
$response['sales_tax'] = $salesTax;
|
305 |
+
$response['shipping_tax'] = $shippingTax;
|
306 |
+
$response['failed_items'] = $this->_getStatusesForFailedItems($quoteInfo['itemsToFail']);
|
307 |
+
return $response;
|
308 |
}
|
309 |
|
310 |
+
public function getShippingMethodsList($addressData, $orderItemsData, $store)
|
311 |
{
|
312 |
+
$this->initErrorHandler($store);
|
313 |
+
$response = array();
|
314 |
+
|
315 |
+
$quoteInfo = $this->_createTemporaryQuote($store, $addressData, $orderItemsData);
|
316 |
+
$quote = isset($quoteInfo['quote']) ? $quoteInfo['quote'] : null;
|
317 |
+
|
318 |
+
if (!empty($quote) AND $quoteId = $quote->getId()) {
|
319 |
+
$cartShippingApi = Mage::getSingleton('checkout/cart_shipping_api_v2');
|
320 |
+
$response['result'] = $cartShippingApi->getShippingMethodsList($quoteId, $store);
|
321 |
+
$response['result'] = $this->_filterInvalidShippingMethods($response['result']);
|
322 |
+
// Clean up anything we saved to the db.
|
323 |
+
$quote->delete();
|
324 |
+
} else {
|
325 |
+
$response['result'] = array();
|
326 |
+
}
|
327 |
+
$response['failed_items'] = $this->_getStatusesForFailedItems($quoteInfo['itemsToFail']);
|
328 |
+
return $response;
|
329 |
+
}
|
330 |
+
|
331 |
+
private function _filterInvalidShippingMethods($result) {
|
332 |
+
$filteredResult = array();
|
333 |
+
|
334 |
+
foreach ($result as $method) {
|
335 |
+
if (strpos($method['code'], 'error') === false) {
|
336 |
+
$filteredResult[] = $method;
|
337 |
+
}
|
338 |
+
}
|
339 |
+
|
340 |
+
return $filteredResult;
|
341 |
}
|
342 |
|
343 |
+
private function _createTemporaryQuote($store, $addressData, $orderItemsData)
|
344 |
{
|
345 |
+
$quoteInfo = $this->_createQuoteInfo($store, $orderItemsData);
|
346 |
+
$quote = isset($quoteInfo['quote']) ? $quoteInfo['quote'] : null;
|
347 |
+
if (!empty($quote)) {
|
348 |
+
$quote->getBillingAddress();
|
349 |
|
350 |
+
// Create shipping address model
|
351 |
+
$shippingAddress = Mage::getModel('sales/quote_address');
|
352 |
+
$shippingAddress->addData($addressData);
|
353 |
|
354 |
+
$shippingAddress->setAddressType('shipping');
|
355 |
+
|
356 |
+
$shippingAddress->setCollectShippingRates(true);
|
357 |
+
$quote->setShippingAddress($shippingAddress)->setCollectShippingRates(true);
|
358 |
+
$quote->getShippingAddress()->save();
|
359 |
|
360 |
+
$quote->setTotalsCollectedFlag(false)->collectTotals();
|
361 |
+
$quote->save();
|
362 |
+
}
|
363 |
+
$quoteInfo['quote'] = $quote;
|
364 |
+
return $quoteInfo;
|
365 |
+
}
|
366 |
|
367 |
+
private function initErrorHandler($store)
|
368 |
+
{
|
369 |
+
Mage::getSingleton('cosmiccart_integration/errorHandler')->initErrorHandler($store);
|
370 |
}
|
371 |
|
372 |
+
}
|
app/code/community/CosmicCart/Integration/Model/Pay.php
CHANGED
@@ -1,81 +1,81 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
* NOTICE OF LICENSE
|
4 |
-
*
|
5 |
-
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
-
*
|
7 |
-
* @category CosmicCart
|
8 |
-
* @package Integration
|
9 |
-
* @copyright Copyright (c)
|
10 |
-
* @license
|
11 |
-
*/
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Created by IntelliJ IDEA.
|
15 |
-
* User: mcsenter
|
16 |
-
* Date: 9/7/13
|
17 |
-
* Time: 9:24 PM
|
18 |
-
* To change this template use File | Settings | File Templates.
|
19 |
-
*/
|
20 |
-
class CosmicCart_Integration_Model_Pay extends Mage_Payment_Model_Method_Abstract
|
21 |
-
{
|
22 |
-
protected $_code = 'cosmiccart';
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Is this payment method a gateway (online auth/charge) ?
|
26 |
-
*/
|
27 |
-
protected $_isGateway = true;
|
28 |
-
|
29 |
-
/**
|
30 |
-
* Can authorize online?
|
31 |
-
*/
|
32 |
-
protected $_canAuthorize = false;
|
33 |
-
|
34 |
-
/**
|
35 |
-
* Can capture funds online?
|
36 |
-
*/
|
37 |
-
protected $_canCapture = false;
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Can capture partial amounts online?
|
41 |
-
*/
|
42 |
-
protected $_canCapturePartial = false;
|
43 |
-
|
44 |
-
/**
|
45 |
-
* Can refund online?
|
46 |
-
*/
|
47 |
-
protected $_canRefund = false;
|
48 |
-
|
49 |
-
/**
|
50 |
-
* Can void transactions online?
|
51 |
-
*/
|
52 |
-
protected $_canVoid = false;
|
53 |
-
|
54 |
-
/**
|
55 |
-
* Can use this payment method in administration panel?
|
56 |
-
*/
|
57 |
-
protected $_canUseInternal = false;
|
58 |
-
|
59 |
-
/**
|
60 |
-
* Can show this payment method as an option on checkout payment page?
|
61 |
-
*/
|
62 |
-
protected $_canUseCheckout = false;
|
63 |
-
|
64 |
-
/**
|
65 |
-
* Is this payment method suitable for multi-shipping checkout?
|
66 |
-
*/
|
67 |
-
protected $_canUseForMultishipping = false;
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Can save credit card information for future processing?
|
71 |
-
*/
|
72 |
-
protected $_canSaveCc = false;
|
73 |
-
|
74 |
-
public function canUseForCountry($country) {
|
75 |
-
return 'US' === $country;
|
76 |
-
}
|
77 |
-
|
78 |
-
public function canUseForCurrency($currencyCode) {
|
79 |
-
return 'USD' === $currencyCode;
|
80 |
-
}
|
81 |
}
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
+
*
|
7 |
+
* @category CosmicCart
|
8 |
+
* @package Integration
|
9 |
+
* @copyright Copyright (c) 2015 Cosmic Cart, Inc.
|
10 |
+
* @license CosmicCart Software License https://cosmiccart.com/help/license/software
|
11 |
+
*/
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Created by IntelliJ IDEA.
|
15 |
+
* User: mcsenter
|
16 |
+
* Date: 9/7/13
|
17 |
+
* Time: 9:24 PM
|
18 |
+
* To change this template use File | Settings | File Templates.
|
19 |
+
*/
|
20 |
+
class CosmicCart_Integration_Model_Pay extends Mage_Payment_Model_Method_Abstract
|
21 |
+
{
|
22 |
+
protected $_code = 'cosmiccart';
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Is this payment method a gateway (online auth/charge) ?
|
26 |
+
*/
|
27 |
+
protected $_isGateway = true;
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Can authorize online?
|
31 |
+
*/
|
32 |
+
protected $_canAuthorize = false;
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Can capture funds online?
|
36 |
+
*/
|
37 |
+
protected $_canCapture = false;
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Can capture partial amounts online?
|
41 |
+
*/
|
42 |
+
protected $_canCapturePartial = false;
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Can refund online?
|
46 |
+
*/
|
47 |
+
protected $_canRefund = false;
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Can void transactions online?
|
51 |
+
*/
|
52 |
+
protected $_canVoid = false;
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Can use this payment method in administration panel?
|
56 |
+
*/
|
57 |
+
protected $_canUseInternal = false;
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Can show this payment method as an option on checkout payment page?
|
61 |
+
*/
|
62 |
+
protected $_canUseCheckout = false;
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Is this payment method suitable for multi-shipping checkout?
|
66 |
+
*/
|
67 |
+
protected $_canUseForMultishipping = false;
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Can save credit card information for future processing?
|
71 |
+
*/
|
72 |
+
protected $_canSaveCc = false;
|
73 |
+
|
74 |
+
public function canUseForCountry($country) {
|
75 |
+
return 'US' === $country;
|
76 |
+
}
|
77 |
+
|
78 |
+
public function canUseForCurrency($currencyCode) {
|
79 |
+
return 'USD' === $currencyCode;
|
80 |
+
}
|
81 |
}
|
app/code/community/CosmicCart/Integration/Model/Product/Api/V2.php
DELETED
@@ -1,83 +0,0 @@
|
|
1 |
-
/*
|
2 |
-
* NOTICE OF LICENSE
|
3 |
-
*
|
4 |
-
* This source file is subject to the Cosmic Cart license, a commercial license.
|
5 |
-
*
|
6 |
-
* @category CosmicCart
|
7 |
-
* @package Integration
|
8 |
-
* @copyright Copyright (c) 2014 Cosmic Cart, Inc.
|
9 |
-
* @license Proprietary
|
10 |
-
*/
|
11 |
-
|
12 |
-
<?
|
13 |
-
class CosmicCart_Integration_Model_Product_Api_V2 extends Mage_Catalog_Model_Product_Api_V2
|
14 |
-
{
|
15 |
-
|
16 |
-
public function listPageable($filters = null, $store = null, $page = 0, $pageSize = 50)
|
17 |
-
{
|
18 |
-
$collection = Mage::getModel('catalog/product')->getCollection()
|
19 |
-
->addStoreFilter($this->_getStoreId($store))
|
20 |
-
->addFilter('type_id', 'simple') // We don't want groups or configurables
|
21 |
-
// ->addAttributeToSelect('name')
|
22 |
-
->setPage($page, $pageSize);
|
23 |
-
|
24 |
-
/** @var $apiHelper Mage_Api_Helper_Data */
|
25 |
-
$apiHelper = Mage::helper('api');
|
26 |
-
$filters = $apiHelper->parseFilters($filters, $this->_filtersMap);
|
27 |
-
try {
|
28 |
-
foreach ($filters as $field => $value) {
|
29 |
-
$collection->addFieldToFilter($field, $value);
|
30 |
-
}
|
31 |
-
} catch (Mage_Core_Exception $e) {
|
32 |
-
$this->_fault('filters_invalid', $e->getMessage());
|
33 |
-
}
|
34 |
-
$result = array();
|
35 |
-
$catalogInventoryApi = Mage::getSingleton("Mage_CatalogInventory_Model_Stock_Item_Api_V2");
|
36 |
-
foreach ($collection as $product) {
|
37 |
-
$productId = $product->getId();
|
38 |
-
$data = $this->info($productId);
|
39 |
-
$data['manufacturer'] = $product->getAttributeText('manufacturer');
|
40 |
-
$inventoryData = $catalogInventoryApi->items($productId);
|
41 |
-
foreach ($inventoryData[0] as $key => $value) {
|
42 |
-
$data[$key] = $value;
|
43 |
-
}
|
44 |
-
|
45 |
-
/* Find parents, if any. */
|
46 |
-
$parentIds = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($productId);
|
47 |
-
$parentCollection = Mage::getResourceModel('catalog/product_collection')
|
48 |
-
->addFieldToFilter('entity_id', array('in' => $parentIds))
|
49 |
-
->addAttributeToSelect('sku');
|
50 |
-
$parentSkus = $parentCollection->getColumnValues('sku');
|
51 |
-
foreach ($parentSkus as $parentSku) {
|
52 |
-
$data['parentSku'] = $parentSku;
|
53 |
-
break;
|
54 |
-
}
|
55 |
-
|
56 |
-
/* Find attributes */
|
57 |
-
foreach ($parentCollection as $parent) {
|
58 |
-
$data['attributes'] = array();
|
59 |
-
$eavProduct = Mage::getModel('catalog/product')->load($productId);
|
60 |
-
$configurableAttributes = $parent->getTypeInstance(true)->getConfigurableAttributesAsArray($parent);
|
61 |
-
foreach ($configurableAttributes as $attribute) {
|
62 |
-
$label = $attribute['frontend_label'];
|
63 |
-
$attributeCode = $attribute['attribute_code'];
|
64 |
-
$value = $eavProduct->getAttributeText($attributeCode);
|
65 |
-
$data['attributes'][] = array(
|
66 |
-
'attribute' => $label,
|
67 |
-
'value' => $value
|
68 |
-
);
|
69 |
-
}
|
70 |
-
break;
|
71 |
-
}
|
72 |
-
|
73 |
-
/* Images */
|
74 |
-
$mediaApi = Mage::getSingleton('Mage_Catalog_Model_Product_Attribute_Media_Api_V2');
|
75 |
-
$data['images'] = $mediaApi->items($productId, $store);
|
76 |
-
|
77 |
-
/* Add to result. */
|
78 |
-
$result[] = $data;
|
79 |
-
}
|
80 |
-
return $result;
|
81 |
-
}
|
82 |
-
|
83 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/CosmicCart/Integration/Model/Resource/AccessToken.php
CHANGED
@@ -1,57 +1,57 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
* NOTICE OF LICENSE
|
4 |
-
*
|
5 |
-
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
-
*
|
7 |
-
* @category CosmicCart
|
8 |
-
* @package Integration
|
9 |
-
* @copyright Copyright (c)
|
10 |
-
* @license
|
11 |
-
*/
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Created by IntelliJ IDEA.
|
15 |
-
* User: mcsenter
|
16 |
-
* Date: 9/11/13
|
17 |
-
* Time: 1:42 PM
|
18 |
-
* To change this template use File | Settings | File Templates.
|
19 |
-
*/
|
20 |
-
class CosmicCart_Integration_Model_Resource_AccessToken extends Mage_Core_Model_Resource_Db_Abstract
|
21 |
-
{
|
22 |
-
/**
|
23 |
-
* Event prefix
|
24 |
-
*
|
25 |
-
* @var string
|
26 |
-
*/
|
27 |
-
protected $_eventPrefix = 'cosmiccart_accessToken';
|
28 |
-
/**
|
29 |
-
* Event object
|
30 |
-
*
|
31 |
-
* @var string
|
32 |
-
*/
|
33 |
-
protected $_eventObject = 'resource';
|
34 |
-
/**
|
35 |
-
* Is grid
|
36 |
-
*
|
37 |
-
* @var boolean
|
38 |
-
*/
|
39 |
-
protected $_grid = false;
|
40 |
-
/**
|
41 |
-
* Use increment id
|
42 |
-
*
|
43 |
-
* @var boolean
|
44 |
-
*/
|
45 |
-
protected $_useIncrementId = false;
|
46 |
-
/**
|
47 |
-
* Primery key auto increment flag
|
48 |
-
*
|
49 |
-
* @var bool
|
50 |
-
*/
|
51 |
-
protected $_isPkAutoIncrement = false;
|
52 |
-
|
53 |
-
public function _construct()
|
54 |
-
{
|
55 |
-
$this->_init('cosmiccart_integration/accessToken', 'access_token');
|
56 |
-
}
|
57 |
}
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
+
*
|
7 |
+
* @category CosmicCart
|
8 |
+
* @package Integration
|
9 |
+
* @copyright Copyright (c) 2015 Cosmic Cart, Inc.
|
10 |
+
* @license CosmicCart Software License https://cosmiccart.com/help/license/software
|
11 |
+
*/
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Created by IntelliJ IDEA.
|
15 |
+
* User: mcsenter
|
16 |
+
* Date: 9/11/13
|
17 |
+
* Time: 1:42 PM
|
18 |
+
* To change this template use File | Settings | File Templates.
|
19 |
+
*/
|
20 |
+
class CosmicCart_Integration_Model_Resource_AccessToken extends Mage_Core_Model_Resource_Db_Abstract
|
21 |
+
{
|
22 |
+
/**
|
23 |
+
* Event prefix
|
24 |
+
*
|
25 |
+
* @var string
|
26 |
+
*/
|
27 |
+
protected $_eventPrefix = 'cosmiccart_accessToken';
|
28 |
+
/**
|
29 |
+
* Event object
|
30 |
+
*
|
31 |
+
* @var string
|
32 |
+
*/
|
33 |
+
protected $_eventObject = 'resource';
|
34 |
+
/**
|
35 |
+
* Is grid
|
36 |
+
*
|
37 |
+
* @var boolean
|
38 |
+
*/
|
39 |
+
protected $_grid = false;
|
40 |
+
/**
|
41 |
+
* Use increment id
|
42 |
+
*
|
43 |
+
* @var boolean
|
44 |
+
*/
|
45 |
+
protected $_useIncrementId = false;
|
46 |
+
/**
|
47 |
+
* Primery key auto increment flag
|
48 |
+
*
|
49 |
+
* @var bool
|
50 |
+
*/
|
51 |
+
protected $_isPkAutoIncrement = false;
|
52 |
+
|
53 |
+
public function _construct()
|
54 |
+
{
|
55 |
+
$this->_init('cosmiccart_integration/accessToken', 'access_token');
|
56 |
+
}
|
57 |
}
|
app/code/community/CosmicCart/Integration/Model/Resource/AccessToken/Collection.php
CHANGED
@@ -1,20 +1,20 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
* NOTICE OF LICENSE
|
4 |
-
*
|
5 |
-
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
-
*
|
7 |
-
* @category CosmicCart
|
8 |
-
* @package Integration
|
9 |
-
* @copyright Copyright (c)
|
10 |
-
* @license
|
11 |
-
*/
|
12 |
-
|
13 |
-
|
14 |
-
class CosmicCart_Integration_Model_Resource_AccessToken_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
15 |
-
{
|
16 |
-
public function _construct()
|
17 |
-
{
|
18 |
-
$this->_init('cosmiccart_integration/accessToken');
|
19 |
-
}
|
20 |
}
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
+
*
|
7 |
+
* @category CosmicCart
|
8 |
+
* @package Integration
|
9 |
+
* @copyright Copyright (c) 2015 Cosmic Cart, Inc.
|
10 |
+
* @license CosmicCart Software License https://cosmiccart.com/help/license/software
|
11 |
+
*/
|
12 |
+
|
13 |
+
|
14 |
+
class CosmicCart_Integration_Model_Resource_AccessToken_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
15 |
+
{
|
16 |
+
public function _construct()
|
17 |
+
{
|
18 |
+
$this->_init('cosmiccart_integration/accessToken');
|
19 |
+
}
|
20 |
}
|
app/code/community/CosmicCart/Integration/Model/Resource/Batch.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
+
*
|
7 |
+
* @category CosmicCart
|
8 |
+
* @package Integration
|
9 |
+
* @copyright Copyright (c) 2015 Cosmic Cart, Inc.
|
10 |
+
* @license CosmicCart Software License https://cosmiccart.com/help/license/software
|
11 |
+
*/
|
12 |
+
|
13 |
+
|
14 |
+
class CosmicCart_Integration_Model_Resource_Batch extends Mage_Core_Model_Resource_Db_Abstract
|
15 |
+
{
|
16 |
+
public function _construct()
|
17 |
+
{
|
18 |
+
$this->_init('cosmiccart_integration/batch', 'batch_id');
|
19 |
+
}
|
20 |
+
}
|
app/code/community/CosmicCart/Integration/Model/Resource/Batch/Collection.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
+
*
|
7 |
+
* @category CosmicCart
|
8 |
+
* @package Integration
|
9 |
+
* @copyright Copyright (c) 2015 Cosmic Cart, Inc.
|
10 |
+
* @license CosmicCart Software License https://cosmiccart.com/help/license/software
|
11 |
+
*/
|
12 |
+
|
13 |
+
|
14 |
+
class CosmicCart_Integration_Model_Resource_Batch_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
15 |
+
{
|
16 |
+
public function _construct()
|
17 |
+
{
|
18 |
+
parent::_construct();
|
19 |
+
$this->_init('cosmiccart_integration/batch');
|
20 |
+
}
|
21 |
+
}
|
app/code/community/CosmicCart/Integration/Model/Resource/Client.php
CHANGED
@@ -1,57 +1,57 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
* NOTICE OF LICENSE
|
4 |
-
*
|
5 |
-
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
-
*
|
7 |
-
* @category CosmicCart
|
8 |
-
* @package Integration
|
9 |
-
* @copyright Copyright (c)
|
10 |
-
* @license
|
11 |
-
*/
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Created by IntelliJ IDEA.
|
15 |
-
* User: mcsenter
|
16 |
-
* Date: 3/19/14
|
17 |
-
* Time: 9:50 AM
|
18 |
-
* To change this template use File | Settings | File Templates.
|
19 |
-
*/
|
20 |
-
class CosmicCart_Integration_Model_Resource_Client extends Mage_Core_Model_Resource_Db_Abstract
|
21 |
-
{
|
22 |
-
/**
|
23 |
-
* Event prefix
|
24 |
-
*
|
25 |
-
* @var string
|
26 |
-
*/
|
27 |
-
protected $_eventPrefix = 'cosmiccart_client';
|
28 |
-
/**
|
29 |
-
* Event object
|
30 |
-
*
|
31 |
-
* @var string
|
32 |
-
*/
|
33 |
-
protected $_eventObject = 'resource';
|
34 |
-
/**
|
35 |
-
* Is grid
|
36 |
-
*
|
37 |
-
* @var boolean
|
38 |
-
*/
|
39 |
-
protected $_grid = false;
|
40 |
-
/**
|
41 |
-
* Use increment id
|
42 |
-
*
|
43 |
-
* @var boolean
|
44 |
-
*/
|
45 |
-
protected $_useIncrementId = false;
|
46 |
-
/**
|
47 |
-
* Primery key auto increment flag
|
48 |
-
*
|
49 |
-
* @var bool
|
50 |
-
*/
|
51 |
-
protected $_isPkAutoIncrement = false;
|
52 |
-
|
53 |
-
public function _construct()
|
54 |
-
{
|
55 |
-
$this->_init('cosmiccart_integration/client', 'client_id');
|
56 |
-
}
|
57 |
}
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
+
*
|
7 |
+
* @category CosmicCart
|
8 |
+
* @package Integration
|
9 |
+
* @copyright Copyright (c) 2015 Cosmic Cart, Inc.
|
10 |
+
* @license CosmicCart Software License https://cosmiccart.com/help/license/software
|
11 |
+
*/
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Created by IntelliJ IDEA.
|
15 |
+
* User: mcsenter
|
16 |
+
* Date: 3/19/14
|
17 |
+
* Time: 9:50 AM
|
18 |
+
* To change this template use File | Settings | File Templates.
|
19 |
+
*/
|
20 |
+
class CosmicCart_Integration_Model_Resource_Client extends Mage_Core_Model_Resource_Db_Abstract
|
21 |
+
{
|
22 |
+
/**
|
23 |
+
* Event prefix
|
24 |
+
*
|
25 |
+
* @var string
|
26 |
+
*/
|
27 |
+
protected $_eventPrefix = 'cosmiccart_client';
|
28 |
+
/**
|
29 |
+
* Event object
|
30 |
+
*
|
31 |
+
* @var string
|
32 |
+
*/
|
33 |
+
protected $_eventObject = 'resource';
|
34 |
+
/**
|
35 |
+
* Is grid
|
36 |
+
*
|
37 |
+
* @var boolean
|
38 |
+
*/
|
39 |
+
protected $_grid = false;
|
40 |
+
/**
|
41 |
+
* Use increment id
|
42 |
+
*
|
43 |
+
* @var boolean
|
44 |
+
*/
|
45 |
+
protected $_useIncrementId = false;
|
46 |
+
/**
|
47 |
+
* Primery key auto increment flag
|
48 |
+
*
|
49 |
+
* @var bool
|
50 |
+
*/
|
51 |
+
protected $_isPkAutoIncrement = false;
|
52 |
+
|
53 |
+
public function _construct()
|
54 |
+
{
|
55 |
+
$this->_init('cosmiccart_integration/client', 'client_id');
|
56 |
+
}
|
57 |
}
|
app/code/community/CosmicCart/Integration/Model/Resource/Client/Collection.php
CHANGED
@@ -1,20 +1,20 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
* NOTICE OF LICENSE
|
4 |
-
*
|
5 |
-
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
-
*
|
7 |
-
* @category CosmicCart
|
8 |
-
* @package Integration
|
9 |
-
* @copyright Copyright (c)
|
10 |
-
* @license
|
11 |
-
*/
|
12 |
-
|
13 |
-
|
14 |
-
class CosmicCart_Integration_Model_Resource_Client_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
15 |
-
{
|
16 |
-
public function _construct()
|
17 |
-
{
|
18 |
-
$this->_init('cosmiccart_integration/client');
|
19 |
-
}
|
20 |
}
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
+
*
|
7 |
+
* @category CosmicCart
|
8 |
+
* @package Integration
|
9 |
+
* @copyright Copyright (c) 2015 Cosmic Cart, Inc.
|
10 |
+
* @license CosmicCart Software License https://cosmiccart.com/help/license/software
|
11 |
+
*/
|
12 |
+
|
13 |
+
|
14 |
+
class CosmicCart_Integration_Model_Resource_Client_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
15 |
+
{
|
16 |
+
public function _construct()
|
17 |
+
{
|
18 |
+
$this->_init('cosmiccart_integration/client');
|
19 |
+
}
|
20 |
}
|
app/code/community/CosmicCart/Integration/Model/Resource/Setup.php
CHANGED
@@ -1,16 +1,16 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
* NOTICE OF LICENSE
|
4 |
-
*
|
5 |
-
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
-
*
|
7 |
-
* @category CosmicCart
|
8 |
-
* @package Integration
|
9 |
-
* @copyright Copyright (c)
|
10 |
-
* @license
|
11 |
-
*/
|
12 |
-
|
13 |
-
|
14 |
-
class CosmicCart_Integration_Model_Resource_Setup extends Mage_Sales_Model_Resource_Setup
|
15 |
-
{
|
16 |
}
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
+
*
|
7 |
+
* @category CosmicCart
|
8 |
+
* @package Integration
|
9 |
+
* @copyright Copyright (c) 2015 Cosmic Cart, Inc.
|
10 |
+
* @license CosmicCart Software License https://cosmiccart.com/help/license/software
|
11 |
+
*/
|
12 |
+
|
13 |
+
|
14 |
+
class CosmicCart_Integration_Model_Resource_Setup extends Mage_Sales_Model_Resource_Setup
|
15 |
+
{
|
16 |
}
|
app/code/community/CosmicCart/Integration/Model/Shipment/Observer.php
DELETED
@@ -1,79 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
* NOTICE OF LICENSE
|
4 |
-
*
|
5 |
-
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
-
*
|
7 |
-
* @category CosmicCart
|
8 |
-
* @package Integration
|
9 |
-
* @copyright Copyright (c) 2014 Cosmic Cart, Inc.
|
10 |
-
* @license Proprietary
|
11 |
-
*/
|
12 |
-
|
13 |
-
require_once('CosmicCart/Integration/OAuth2Client.php');
|
14 |
-
/**
|
15 |
-
* Created by IntelliJ IDEA.
|
16 |
-
* User: mcsenter
|
17 |
-
* Date: 9/30/13
|
18 |
-
* Time: 10:50 AM
|
19 |
-
* To change this template use File | Settings | File Templates.
|
20 |
-
*/
|
21 |
-
class CosmicCart_Integration_Model_Shipment_Observer
|
22 |
-
{
|
23 |
-
public function onSalesOrderShipmentSaveAfter(Varien_Event_Observer $observer)
|
24 |
-
{
|
25 |
-
error_log("Shipment was saved!");
|
26 |
-
/* We are observing all shipments, but we are really interested in only those resulting from a Cosmic Cart purchase. */
|
27 |
-
$shipment = $observer->getEvent()->getShipment();
|
28 |
-
$order = $shipment->getOrder();
|
29 |
-
error_log("Getting orderId from order...");
|
30 |
-
$cosmicOrderId = $order->getCosmicCartOrderId();
|
31 |
-
error_log("Cosmic cart Order Id: $cosmicOrderId");
|
32 |
-
if (!empty($cosmicOrderId)) {
|
33 |
-
$payment = $order->getPayment();
|
34 |
-
if (!empty($payment)) {
|
35 |
-
/* We must have a Payment and that Payment must have been with our custom "cosmiccart" method */
|
36 |
-
$method = $payment->getMethod();
|
37 |
-
error_log("payment method: $method");
|
38 |
-
if ('cosmiccart' == $method) {
|
39 |
-
$package = $this->shipmentToPackage($shipment);
|
40 |
-
$client = new OAuth2Client();
|
41 |
-
error_log("shipandsettle()");
|
42 |
-
$package = $client->shipAndSettle($package);
|
43 |
-
}
|
44 |
-
}
|
45 |
-
}
|
46 |
-
|
47 |
-
return $this;
|
48 |
-
}
|
49 |
-
|
50 |
-
private function shipmentToPackage(Mage_Sales_Model_Order_Shipment $shipment)
|
51 |
-
{
|
52 |
-
$dateTime = DateTime::createFromFormat('Y-m-d H:i:s', $shipment->getCreatedAt());
|
53 |
-
ob_start();
|
54 |
-
var_dump(DateTime::getLastErrors());
|
55 |
-
$contents = ob_get_contents();
|
56 |
-
ob_end_clean();
|
57 |
-
error_log($contents);
|
58 |
-
$package = array(
|
59 |
-
'subOrder' => array('id' => (int) $shipment->getOrder()->getCosmicCartOrderId()),
|
60 |
-
'packageItems' => array(),
|
61 |
-
'shipDate' => $dateTime->format('c'),
|
62 |
-
'trackings' => array()
|
63 |
-
);
|
64 |
-
foreach ($shipment->getTracksCollection() as $track) {
|
65 |
-
$package['trackings'][] = $track->getNumber();
|
66 |
-
}
|
67 |
-
foreach ($shipment->getItemsCollection() as $item) {
|
68 |
-
$orderItem = Mage::getModel('sales/order_item')->load($item->getOrderItemId());
|
69 |
-
for ($i = 0; $i < $item->getQty(); ++$i) {
|
70 |
-
$packageItem = array(
|
71 |
-
'orderItem' => array('id' => (int) $orderItem->getCosmicCartOrderItemId()),
|
72 |
-
'number' => $i
|
73 |
-
);
|
74 |
-
$package['packageItems'][] = $packageItem;
|
75 |
-
}
|
76 |
-
}
|
77 |
-
return $package;
|
78 |
-
}
|
79 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/CosmicCart/Integration/Model/System/Config/Source/Environment.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
+
*
|
7 |
+
* @category CosmicCart
|
8 |
+
* @package Integration
|
9 |
+
* @copyright Copyright (c) 2015 Cosmic Cart, Inc.
|
10 |
+
* @license CosmicCart Software License https://cosmiccart.com/help/license/software
|
11 |
+
*/
|
12 |
+
|
13 |
+
|
14 |
+
class CosmicCart_Integration_Model_System_Config_Source_Environment
|
15 |
+
{
|
16 |
+
const COSMICCART_ENV_STAGING = 1;
|
17 |
+
const COSMICCART_ENV_PRODUCTION = 2;
|
18 |
+
const COSMICCART_ENV_LOCAL = 3;
|
19 |
+
|
20 |
+
public function toOptionArray()
|
21 |
+
{
|
22 |
+
return array(
|
23 |
+
array('value' => self::COSMICCART_ENV_STAGING, 'label' => Mage::helper('cosmiccart_integration')->__('Staging')),
|
24 |
+
array('value' => self::COSMICCART_ENV_PRODUCTION, 'label' => Mage::helper('cosmiccart_integration')->__('Production')),
|
25 |
+
array('value' => self::COSMICCART_ENV_LOCAL, 'label' => Mage::helper('cosmiccart_integration')->__('Local (Dev only)')),
|
26 |
+
);
|
27 |
+
}
|
28 |
+
|
29 |
+
}
|
app/code/community/CosmicCart/Integration/controllers/Adminhtml/ActivationController.php
DELETED
@@ -1,118 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
* NOTICE OF LICENSE
|
4 |
-
*
|
5 |
-
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
-
*
|
7 |
-
* @category CosmicCart
|
8 |
-
* @package Integration
|
9 |
-
* @copyright Copyright (c) 2014 Cosmic Cart, Inc.
|
10 |
-
* @license Proprietary
|
11 |
-
*/
|
12 |
-
|
13 |
-
require_once('CosmicCart/Integration/OAuth2Client.php');
|
14 |
-
|
15 |
-
class CosmicCart_Integration_Adminhtml_ActivationController extends Mage_Adminhtml_Controller_Action
|
16 |
-
{
|
17 |
-
// default action
|
18 |
-
public function indexAction()
|
19 |
-
{
|
20 |
-
$this->loadLayout();
|
21 |
-
$this->_setActiveMenu('cosmiccart');
|
22 |
-
$block = $this->getLayout()->getBlock('activation');
|
23 |
-
$block->setData('activated', Mage::getModel('cosmiccart_integration/accessToken')->exists());
|
24 |
-
$this->renderLayout();
|
25 |
-
}
|
26 |
-
|
27 |
-
public function postAction()
|
28 |
-
{
|
29 |
-
$post = $this->getRequest()->getPost();
|
30 |
-
try {
|
31 |
-
if (empty($post)) {
|
32 |
-
Mage::throwException($this->__('Invalid form data.'));
|
33 |
-
}
|
34 |
-
|
35 |
-
/* Configure our client. */
|
36 |
-
$client = new OAuth2Client($post['clientId'], $post['clientSecret']);
|
37 |
-
|
38 |
-
/* Request an access token */
|
39 |
-
$accessToken = $client->getAccessToken($post['username'], $post['password']);
|
40 |
-
|
41 |
-
/* Register our stores with Cosmic Cart. */
|
42 |
-
$stores = array();
|
43 |
-
foreach (Mage::getModel('core/store')->getCollection() as $store) {
|
44 |
-
$stores[] = array(
|
45 |
-
'remoteId' => $store->getId(),
|
46 |
-
'locale' => $store->getConfig('general/locale/code'),
|
47 |
-
'active' => ($store->getIsActive() == 1)
|
48 |
-
);
|
49 |
-
}
|
50 |
-
$registerStoresResponse = $client->registerStores($stores, $accessToken);
|
51 |
-
if (empty($registerStoresResponse)) {
|
52 |
-
throw new Exception('Could not connect to Cosmic Cart to register store(s).');
|
53 |
-
}
|
54 |
-
$apiUsername = $registerStoresResponse->apiUsername;
|
55 |
-
$apiKey = $registerStoresResponse->apiKey;
|
56 |
-
|
57 |
-
/* Find or create a CosmicCartIntegration API Role and User */
|
58 |
-
$role = Mage::getModel('api/roles')->getCollection()
|
59 |
-
->addFieldToFilter('role_name', 'CosmicCartIntegration')
|
60 |
-
->addFieldToFilter('role_type', 'G')
|
61 |
-
->getFirstItem();
|
62 |
-
if (!$role->getId()) {
|
63 |
-
/* Create our API Role */
|
64 |
-
error_log("Creating role...");
|
65 |
-
$role = Mage::getModel('api/roles')
|
66 |
-
->setName('CosmicCartIntegration')
|
67 |
-
->setPid(false)
|
68 |
-
->setRoleType('G')
|
69 |
-
->save();
|
70 |
-
/* Add permission to our API Role. */
|
71 |
-
error_log("Adding permissions to role: " . $role->getId());
|
72 |
-
Mage::getModel('api/rules')
|
73 |
-
->setRoleId($role->getId())
|
74 |
-
->setResources(array('all'))
|
75 |
-
->saveRel();
|
76 |
-
}
|
77 |
-
$user = Mage::getModel('api/user')->getCollection()
|
78 |
-
->addFieldToFilter('email', 'integration@cosmiccart.com')
|
79 |
-
->getFirstItem();
|
80 |
-
if ($user->getId()) {
|
81 |
-
/* Remove the old user. */
|
82 |
-
error_log("Deleting previous user");
|
83 |
-
$user->delete();
|
84 |
-
}
|
85 |
-
/* Create our API User. */
|
86 |
-
error_log("Creating user...");
|
87 |
-
$user = Mage::getModel('api/user')
|
88 |
-
->setData(array(
|
89 |
-
'username' => $apiUsername,
|
90 |
-
'firstname' => 'Cosmic',
|
91 |
-
'lastname' => 'Cart',
|
92 |
-
'email' => 'integration@cosmiccart.com',
|
93 |
-
'api_key' => $apiKey,
|
94 |
-
'api_key_confirmation' => $apiKey,
|
95 |
-
'is_active' => 1,
|
96 |
-
'user_roles' => '',
|
97 |
-
'assigned_user_role' => '',
|
98 |
-
'role_name' => '',
|
99 |
-
'roles' => array($role->getId())
|
100 |
-
));
|
101 |
-
$user->save()->load($user->getId());
|
102 |
-
/* Assign our API Role to our API User. */
|
103 |
-
error_log("Adding our role to our user " . $user->getId());
|
104 |
-
$user->setRoleIds(array($role->getId()))
|
105 |
-
->setRoleUserId($user->getId())
|
106 |
-
->saveRelations();
|
107 |
-
|
108 |
-
$client->saveClient();
|
109 |
-
|
110 |
-
$message = $this->__('activation.success');
|
111 |
-
Mage::getSingleton('adminhtml/session')->addSuccess($message);
|
112 |
-
} catch (Exception $e) {
|
113 |
-
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
114 |
-
}
|
115 |
-
$this->_redirect('*/*');
|
116 |
-
}
|
117 |
-
|
118 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/CosmicCart/Integration/controllers/Adminhtml/Integration/ActivationController.php
ADDED
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
+
*
|
7 |
+
* @category CosmicCart
|
8 |
+
* @package Integration
|
9 |
+
* @copyright Copyright (c) 2015 Cosmic Cart, Inc.
|
10 |
+
* @license CosmicCart Software License https://cosmiccart.com/help/license/software
|
11 |
+
*/
|
12 |
+
|
13 |
+
class CosmicCart_Integration_Adminhtml_Integration_ActivationController extends Mage_Adminhtml_Controller_Action
|
14 |
+
{
|
15 |
+
public function indexAction()
|
16 |
+
{
|
17 |
+
$this->loadLayout();
|
18 |
+
$this->_setActiveMenu('cosmiccart');
|
19 |
+
$block = $this->getLayout()->getBlock('activation');
|
20 |
+
$block->setData('activated', Mage::getModel('cosmiccart_integration/accessToken')->exists());
|
21 |
+
$this->renderLayout();
|
22 |
+
}
|
23 |
+
|
24 |
+
public function postAction()
|
25 |
+
{
|
26 |
+
if (Mage::getStoreConfig('cosmiccart/options/debug') == 1) {
|
27 |
+
$message = $this->__('debug.prefix') . $this->__('activation.success');
|
28 |
+
Mage::getSingleton('adminhtml/session')->addSuccess($message);
|
29 |
+
} else {
|
30 |
+
$post = $this->getRequest()->getPost();
|
31 |
+
|
32 |
+
try {
|
33 |
+
if (empty($post)) {
|
34 |
+
Mage::throwException($this->__('Invalid form data.'));
|
35 |
+
}
|
36 |
+
|
37 |
+
/* Configure our client. */
|
38 |
+
$client = Mage::getModel('cosmiccart_integration/oauth2client')->init($post['clientId'], $post['clientSecret']);
|
39 |
+
|
40 |
+
/* Request an access token */
|
41 |
+
$accessToken = $client->getAccessToken($post['username'], $post['password']);
|
42 |
+
/*
|
43 |
+
* Register our stores with Cosmic Cart.
|
44 |
+
* For now, let's just return the default store. One store per Seller. Later we will expand this to include
|
45 |
+
* all possible stores, but the Cosmic Cart side will need to be modified to support it.
|
46 |
+
*/
|
47 |
+
$storeId = $post['store'];
|
48 |
+
$stores = array();
|
49 |
+
$store = Mage::getModel('core/store')->load($storeId);
|
50 |
+
$stores[] = array(
|
51 |
+
'remoteId' => $store->getId(),
|
52 |
+
'locale' => $store->getConfig('general/locale/code'),
|
53 |
+
'active' => ($store->getIsActive() == 1),
|
54 |
+
'name' => $store->getGroup()->getName(),
|
55 |
+
'url' => Mage::getStoreConfig('web/secure/base_url', $store->getId())
|
56 |
+
);
|
57 |
+
$registerStoresResponse = $client->registerStores($stores, $accessToken);
|
58 |
+
if (empty($registerStoresResponse)) {
|
59 |
+
throw new Exception('Could not connect to Cosmic Cart to register store(s).');
|
60 |
+
}
|
61 |
+
$apiUsername = $registerStoresResponse->apiUsername;
|
62 |
+
$apiKey = $registerStoresResponse->apiKey;
|
63 |
+
|
64 |
+
/* Find or create a CosmicCartIntegration API Role and User */
|
65 |
+
$role = Mage::getModel('api/roles')->getCollection()
|
66 |
+
->addFieldToFilter('role_name', 'CosmicCartIntegration')
|
67 |
+
->addFieldToFilter('role_type', 'G')
|
68 |
+
->getFirstItem();
|
69 |
+
if (!$role->getId()) {
|
70 |
+
/* Create our API Role */
|
71 |
+
$role = Mage::getModel('api/roles')
|
72 |
+
->setName('CosmicCartIntegration')
|
73 |
+
->setPid(false)
|
74 |
+
->setRoleType('G')
|
75 |
+
->save();
|
76 |
+
/* Add permission to our API Role. */
|
77 |
+
Mage::getModel('api/rules')
|
78 |
+
->setRoleId($role->getId())
|
79 |
+
->setResources(array('all'))
|
80 |
+
->saveRel();
|
81 |
+
}
|
82 |
+
$user = Mage::getModel('api/user')->getCollection()
|
83 |
+
->addFieldToFilter('email', 'integration@cosmiccart.com')
|
84 |
+
->getFirstItem();
|
85 |
+
if ($user->getId()) {
|
86 |
+
/* Remove the old user. */
|
87 |
+
$user->delete();
|
88 |
+
}
|
89 |
+
/* Create our API User. */
|
90 |
+
$user = Mage::getModel('api/user')
|
91 |
+
->setData(array(
|
92 |
+
'username' => $apiUsername,
|
93 |
+
'firstname' => 'Cosmic',
|
94 |
+
'lastname' => 'Cart',
|
95 |
+
'email' => 'integration@cosmiccart.com',
|
96 |
+
'api_key' => $apiKey,
|
97 |
+
'api_key_confirmation' => $apiKey,
|
98 |
+
'is_active' => 1,
|
99 |
+
'user_roles' => '',
|
100 |
+
'assigned_user_role' => '',
|
101 |
+
'role_name' => '',
|
102 |
+
'roles' => array($role->getId())
|
103 |
+
));
|
104 |
+
$user->save()->load($user->getId());
|
105 |
+
/* Assign our API Role to our API User. */
|
106 |
+
$user->setRoleIds(array($role->getId()))
|
107 |
+
->setRoleUserId($user->getId())
|
108 |
+
->saveRelations();
|
109 |
+
|
110 |
+
$client->saveClient();
|
111 |
+
|
112 |
+
Mage::getModel('core/config')->saveConfig('cosmiccart/store', $storeId);
|
113 |
+
|
114 |
+
$message = $this->__('activation.success') . '<ul>';
|
115 |
+
$registeredStores = $registerStoresResponse->stores;
|
116 |
+
foreach ($registeredStores as $registeredStore) {
|
117 |
+
$message .= '<li>"'.$registeredStore->name.'"</li>';
|
118 |
+
}
|
119 |
+
$message .= '</ul>';
|
120 |
+
|
121 |
+
Mage::getSingleton('adminhtml/session')->addSuccess($message);
|
122 |
+
} catch (Exception $e) {
|
123 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
124 |
+
}
|
125 |
+
}
|
126 |
+
$this->_redirect('*/*');
|
127 |
+
}
|
128 |
+
|
129 |
+
}
|
app/code/community/CosmicCart/Integration/controllers/Adminhtml/Integration/BatchController.php
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
+
*
|
7 |
+
* @category CosmicCart
|
8 |
+
* @package Integration
|
9 |
+
* @copyright Copyright (c) 2015 Cosmic Cart, Inc.
|
10 |
+
* @license CosmicCart Software License https://cosmiccart.com/help/license/software
|
11 |
+
*/
|
12 |
+
|
13 |
+
class CosmicCart_Integration_Adminhtml_Integration_BatchController extends Mage_Adminhtml_Controller_Action
|
14 |
+
{
|
15 |
+
// default action
|
16 |
+
public function indexAction()
|
17 |
+
{
|
18 |
+
$this->loadLayout();
|
19 |
+
$this->_setActiveMenu('cosmiccart');
|
20 |
+
$this->renderLayout();
|
21 |
+
}
|
22 |
+
|
23 |
+
public function newAction()
|
24 |
+
{
|
25 |
+
$response = $this->getResponse();
|
26 |
+
$model = Mage::getSingleton('cosmiccart_integration/exporter');
|
27 |
+
|
28 |
+
//check if batch is already running
|
29 |
+
$batchCollection = Mage::getResourceModel('cosmiccart_integration/batch_collection');
|
30 |
+
$batchCollection->addFieldToFilter('current_stage', array('nin' => array('5', '6')));
|
31 |
+
|
32 |
+
try {
|
33 |
+
|
34 |
+
$hasRunning = $batchCollection->getSize();
|
35 |
+
if ($hasRunning) {
|
36 |
+
Mage::throwException('Can not start new batch while one is still running. Please try again later!');
|
37 |
+
return;
|
38 |
+
}
|
39 |
+
|
40 |
+
$model->exportCatalog('new');
|
41 |
+
$message = Mage::helper('cosmiccart_integration')->__('A new batch has been scheduled successfully and will begin within 5 minutes.');
|
42 |
+
Mage::getSingleton('adminhtml/session')->addSuccess($message);
|
43 |
+
} catch (Exception $e) {
|
44 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
45 |
+
}
|
46 |
+
|
47 |
+
$_url = Mage::getModel('adminhtml/url')->getUrl(
|
48 |
+
'adminhtml/integration_batch',
|
49 |
+
null
|
50 |
+
);
|
51 |
+
|
52 |
+
$response->setRedirect($_url);
|
53 |
+
return;
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Mass Delete Actions function
|
58 |
+
*
|
59 |
+
* @return void
|
60 |
+
*/
|
61 |
+
public function massDeleteAction()
|
62 |
+
{
|
63 |
+
$cosmiccartIds = $this->getRequest()->getParam('cosmiccart', null);
|
64 |
+
if (is_null($cosmiccartIds) OR !is_array($cosmiccartIds) OR count($cosmiccartIds) < 1) {
|
65 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select batch(s)'));
|
66 |
+
} else {
|
67 |
+
try {
|
68 |
+
foreach ($cosmiccartIds as $cosmiccartId) {
|
69 |
+
$_batch = Mage::getModel('cosmiccart_integration/batch')->load($cosmiccartId);
|
70 |
+
if ($_batch AND $_batch->getId()) {
|
71 |
+
$_batch->delete();
|
72 |
+
}
|
73 |
+
}
|
74 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
75 |
+
Mage::helper('adminhtml')->__(
|
76 |
+
'Total of %d record(s) were successfully deleted', count($cosmiccartIds)
|
77 |
+
)
|
78 |
+
);
|
79 |
+
} catch (Exception $e) {
|
80 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
81 |
+
}
|
82 |
+
}
|
83 |
+
$this->_redirect('*/*/index');
|
84 |
+
}
|
85 |
+
}
|
app/code/community/CosmicCart/Integration/etc/api.xml
DELETED
@@ -1,41 +0,0 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<config>
|
3 |
-
<api>
|
4 |
-
<resources>
|
5 |
-
<sales_order translate="title" module="sales">
|
6 |
-
<title>Create Order API</title>
|
7 |
-
<model>CosmicCart_Integration_Model_Order_Api</model>
|
8 |
-
<acl>sales/order</acl>
|
9 |
-
<methods>
|
10 |
-
<create translate="title" module="sales">
|
11 |
-
<title>Create Order</title>
|
12 |
-
<acl>sales/order/create</acl>
|
13 |
-
</create>
|
14 |
-
<getShippingMethodsList translate="title" module="sales">
|
15 |
-
<title>Get Shipping Methods List</title>
|
16 |
-
<acl>sales/order/getShippingMethodsList</acl>
|
17 |
-
</getShippingMethodsList>
|
18 |
-
<getSalesTax translate="title" module="sales">
|
19 |
-
<title>Get Sales Tax</title>
|
20 |
-
<acl>sales/order/getSalesTax</acl>
|
21 |
-
</getSalesTax>>
|
22 |
-
<getShippingCost translate="title" module="sales">
|
23 |
-
<title>Get Shipping Cost</title>
|
24 |
-
<acl>sales/order/getShippingCost</acl>
|
25 |
-
</getShippingCost>>
|
26 |
-
</methods>
|
27 |
-
</sales_order>
|
28 |
-
<catalog_product translate="title" module="catalog">
|
29 |
-
<title>Catalog Product API</title>
|
30 |
-
<model>CosmicCart_Integration_Model_Product_Api</model>
|
31 |
-
<acl>catalog/product</acl>
|
32 |
-
<methods>
|
33 |
-
<listPageable translate="title" module="catalog">
|
34 |
-
<title>Retrieve pageable product list by features</title>
|
35 |
-
<acl>catalog/product/info</acl>
|
36 |
-
</listPageable>
|
37 |
-
</methods>
|
38 |
-
</catalog_product>
|
39 |
-
</resources>
|
40 |
-
</api>
|
41 |
-
</config>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/CosmicCart/Integration/etc/config.xml
CHANGED
@@ -1,35 +1,13 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<config>
|
3 |
-
|
4 |
-
<!-- ecomdev phpunit config -->
|
5 |
-
<phpunit>
|
6 |
-
<suite>
|
7 |
-
<modules>
|
8 |
-
<CosmicCart_Integration/>
|
9 |
-
</modules>
|
10 |
-
</suite>
|
11 |
-
</phpunit>
|
12 |
-
|
13 |
-
<!-- define the module, version and dependencies -->
|
14 |
<modules>
|
15 |
<CosmicCart_Integration>
|
16 |
-
<version>
|
17 |
</CosmicCart_Integration>
|
18 |
</modules>
|
19 |
|
20 |
<global>
|
21 |
-
<!-- model configuration -->
|
22 |
<models>
|
23 |
-
<sales>
|
24 |
-
<rewrite>
|
25 |
-
<order_api_v2>CosmicCart_Integration_Model_Order_Api_V2</order_api_v2>
|
26 |
-
</rewrite>
|
27 |
-
</sales>
|
28 |
-
<catalog>
|
29 |
-
<rewrite>
|
30 |
-
<product_api_v2>CosmicCart_Integration_Model_Product_Api_V2</product_api_v2>
|
31 |
-
</rewrite>
|
32 |
-
</catalog>
|
33 |
<cosmiccart_integration>
|
34 |
<class>CosmicCart_Integration_Model</class>
|
35 |
<resourceModel>cosmiccart_integration_resource</resourceModel>
|
@@ -40,128 +18,150 @@
|
|
40 |
<accessToken>
|
41 |
<table>cosmiccart_integration_access_token</table>
|
42 |
</accessToken>
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
46 |
</entities>
|
47 |
</cosmiccart_integration_resource>
|
48 |
-
<events>
|
49 |
-
</events>
|
50 |
</models>
|
51 |
-
|
52 |
-
<!-- resource model configuration -->
|
53 |
<resources>
|
54 |
<cosmiccart_integration_setup>
|
55 |
<setup>
|
56 |
<module>CosmicCart_Integration</module>
|
57 |
<class>CosmicCart_Integration_Model_Resource_Setup</class>
|
58 |
</setup>
|
59 |
-
<connection>
|
60 |
-
<use>core_setup</use>
|
61 |
-
</connection>
|
62 |
</cosmiccart_integration_setup>
|
63 |
-
<integration_write>
|
64 |
-
<connection>
|
65 |
-
<use>core_write</use>
|
66 |
-
</connection>
|
67 |
-
</integration_write>
|
68 |
-
<integration_read>
|
69 |
-
<connection>
|
70 |
-
<use>core_read</use>
|
71 |
-
</connection>
|
72 |
-
</integration_read>
|
73 |
</resources>
|
74 |
-
|
75 |
-
<!-- helper classes -->
|
76 |
<helpers>
|
77 |
-
<
|
78 |
<class>CosmicCart_Integration_Helper</class>
|
79 |
-
</
|
80 |
</helpers>
|
81 |
-
|
82 |
-
|
|
|
|
|
|
|
83 |
<events>
|
84 |
<sales_order_shipment_save_after>
|
85 |
<observers>
|
86 |
<cosmiccart_integration_shipment_observer>
|
87 |
-
<
|
88 |
-
<class>CosmicCart_Integration_Model_Shipment_Observer</class>
|
89 |
<method>onSalesOrderShipmentSaveAfter</method>
|
90 |
</cosmiccart_integration_shipment_observer>
|
91 |
</observers>
|
92 |
</sales_order_shipment_save_after>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
</events>
|
94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
</global>
|
96 |
-
|
97 |
-
<!-- backend routing -->
|
98 |
<admin>
|
99 |
<routers>
|
100 |
-
<
|
101 |
-
<use>admin</use>
|
102 |
<args>
|
103 |
-
<
|
104 |
-
|
|
|
105 |
</args>
|
106 |
-
</
|
107 |
</routers>
|
108 |
</admin>
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
</
|
164 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
<default>
|
166 |
<payment>
|
167 |
<cosmiccart>
|
@@ -173,4 +173,57 @@
|
|
173 |
</cosmiccart>
|
174 |
</payment>
|
175 |
</default>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
</config>
|
1 |
<?xml version="1.0"?>
|
2 |
<config>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
<modules>
|
4 |
<CosmicCart_Integration>
|
5 |
+
<version>2.0.5</version>
|
6 |
</CosmicCart_Integration>
|
7 |
</modules>
|
8 |
|
9 |
<global>
|
|
|
10 |
<models>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
<cosmiccart_integration>
|
12 |
<class>CosmicCart_Integration_Model</class>
|
13 |
<resourceModel>cosmiccart_integration_resource</resourceModel>
|
18 |
<accessToken>
|
19 |
<table>cosmiccart_integration_access_token</table>
|
20 |
</accessToken>
|
21 |
+
<client>
|
22 |
+
<table>cosmiccart_integration_client</table>
|
23 |
+
</client>
|
24 |
+
<batch>
|
25 |
+
<table>cosmiccart_batch_status</table>
|
26 |
+
</batch>
|
27 |
</entities>
|
28 |
</cosmiccart_integration_resource>
|
|
|
|
|
29 |
</models>
|
|
|
|
|
30 |
<resources>
|
31 |
<cosmiccart_integration_setup>
|
32 |
<setup>
|
33 |
<module>CosmicCart_Integration</module>
|
34 |
<class>CosmicCart_Integration_Model_Resource_Setup</class>
|
35 |
</setup>
|
|
|
|
|
|
|
36 |
</cosmiccart_integration_setup>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
</resources>
|
|
|
|
|
38 |
<helpers>
|
39 |
+
<cosmiccart_integration>
|
40 |
<class>CosmicCart_Integration_Helper</class>
|
41 |
+
</cosmiccart_integration>
|
42 |
</helpers>
|
43 |
+
<blocks>
|
44 |
+
<cosmiccart_integration>
|
45 |
+
<class>CosmicCart_Integration_Block</class>
|
46 |
+
</cosmiccart_integration>
|
47 |
+
</blocks>
|
48 |
<events>
|
49 |
<sales_order_shipment_save_after>
|
50 |
<observers>
|
51 |
<cosmiccart_integration_shipment_observer>
|
52 |
+
<class>cosmiccart_integration/observer</class>
|
|
|
53 |
<method>onSalesOrderShipmentSaveAfter</method>
|
54 |
</cosmiccart_integration_shipment_observer>
|
55 |
</observers>
|
56 |
</sales_order_shipment_save_after>
|
57 |
+
<sales_order_creditmemo_refund>
|
58 |
+
<observers>
|
59 |
+
<cosmiccart_integration_creditmemo_observer>
|
60 |
+
<class>cosmiccart_integration/observer</class>
|
61 |
+
<method>onSalesOrderCreditmemoRefund</method>
|
62 |
+
</cosmiccart_integration_creditmemo_observer>
|
63 |
+
</observers>
|
64 |
+
</sales_order_creditmemo_refund>
|
65 |
</events>
|
66 |
+
<template>
|
67 |
+
<email>
|
68 |
+
<cosmiccart_integration_package_shipped_tpl translate="label" module="cosmiccart_integration">
|
69 |
+
<label>Package Shipped Email</label>
|
70 |
+
<file>cosmiccart/package_shipped.html</file>
|
71 |
+
<type>html</type>
|
72 |
+
</cosmiccart_integration_package_shipped_tpl>
|
73 |
+
<cosmiccart_integration_refund_exception_tpl translate="label" module="cosmiccart_integration">
|
74 |
+
<label>Refund Exception Email</label>
|
75 |
+
<file>cosmiccart/refund_exception.html</file>
|
76 |
+
<type>html</type>
|
77 |
+
</cosmiccart_integration_refund_exception_tpl>
|
78 |
+
<cosmiccart_integration_import_exception_tpl translate="label" module="cosmiccart_integration">
|
79 |
+
<label>Catalog Import Exception Email</label>
|
80 |
+
<file>cosmiccart/import_exception.html</file>
|
81 |
+
<type>html</type>
|
82 |
+
</cosmiccart_integration_import_exception_tpl>
|
83 |
+
<cosmiccart_integration_generic_error_tpl translate="label" module="cosmiccart_integration">
|
84 |
+
<label>Generic Error Email</label>
|
85 |
+
<file>cosmiccart/generic_error.html</file>
|
86 |
+
<type>html</type>
|
87 |
+
</cosmiccart_integration_generic_error_tpl>
|
88 |
+
</email>
|
89 |
+
</template>
|
90 |
</global>
|
|
|
|
|
91 |
<admin>
|
92 |
<routers>
|
93 |
+
<adminhtml>
|
|
|
94 |
<args>
|
95 |
+
<modules>
|
96 |
+
<integration before="Mage_Adminhtml">CosmicCart_Integration_Adminhtml</integration>
|
97 |
+
</modules>
|
98 |
</args>
|
99 |
+
</adminhtml>
|
100 |
</routers>
|
101 |
</admin>
|
102 |
+
<adminhtml>
|
103 |
+
<acl>
|
104 |
+
<resources>
|
105 |
+
<admin>
|
106 |
+
<children>
|
107 |
+
<integration translate="title" module="cosmiccart_integration">
|
108 |
+
<children>
|
109 |
+
<integration_activation>
|
110 |
+
<title>Activation</title>
|
111 |
+
</integration_activation>
|
112 |
+
</children>
|
113 |
+
<sort_order>1</sort_order>
|
114 |
+
</integration>
|
115 |
+
<system>
|
116 |
+
<children>
|
117 |
+
<config>
|
118 |
+
<children>
|
119 |
+
<cosmiccart>
|
120 |
+
<title>Cosmic Cart Section</title>
|
121 |
+
</cosmiccart>
|
122 |
+
</children>
|
123 |
+
</config>
|
124 |
+
</children>
|
125 |
+
</system>
|
126 |
+
</children>
|
127 |
+
</admin>
|
128 |
+
</resources>
|
129 |
+
</acl>
|
130 |
+
<menu>
|
131 |
+
<cosmiccart module="cosmiccart_integration">
|
132 |
+
<title>Cosmic Cart</title>
|
133 |
+
<sort_order>100</sort_order>
|
134 |
+
<children>
|
135 |
+
<integration_activation module="cosmiccart_integration">
|
136 |
+
<title>Activation</title>
|
137 |
+
<sort_order>1</sort_order>
|
138 |
+
<action>adminhtml/integration_activation</action>
|
139 |
+
</integration_activation>
|
140 |
+
<integration_batch module="cosmiccart_integration">
|
141 |
+
<title>Batch Process</title>
|
142 |
+
<sort_order>2</sort_order>
|
143 |
+
<action>adminhtml/integration_batch</action>
|
144 |
+
</integration_batch>
|
145 |
+
</children>
|
146 |
+
</cosmiccart>
|
147 |
+
</menu>
|
148 |
+
<translate>
|
149 |
+
<modules>
|
150 |
+
<integration>
|
151 |
+
<files>
|
152 |
+
<default>CosmicCart_Integration.csv</default>
|
153 |
+
</files>
|
154 |
+
</integration>
|
155 |
+
</modules>
|
156 |
+
</translate>
|
157 |
+
<layout>
|
158 |
+
<updates>
|
159 |
+
<integration>
|
160 |
+
<file>cosmiccart/integration.xml</file>
|
161 |
+
</integration>
|
162 |
+
</updates>
|
163 |
+
</layout>
|
164 |
+
</adminhtml>
|
165 |
<default>
|
166 |
<payment>
|
167 |
<cosmiccart>
|
173 |
</cosmiccart>
|
174 |
</payment>
|
175 |
</default>
|
176 |
+
<crontab>
|
177 |
+
<jobs>
|
178 |
+
<integration_cosmiccart_generate_batch>
|
179 |
+
<run>
|
180 |
+
<model>cosmiccart_integration/exporter::generateBatch</model>
|
181 |
+
</run>
|
182 |
+
</integration_cosmiccart_generate_batch>
|
183 |
+
<integration_cosmiccart_export>
|
184 |
+
<schedule>
|
185 |
+
<cron_expr>*/5 * * * *</cron_expr>
|
186 |
+
</schedule>
|
187 |
+
<run>
|
188 |
+
<model>cosmiccart_integration/exporter::cronprocess</model>
|
189 |
+
</run>
|
190 |
+
</integration_cosmiccart_export>
|
191 |
+
</jobs>
|
192 |
+
</crontab>
|
193 |
+
<default>
|
194 |
+
<cosmiccart>
|
195 |
+
<configurable_cron>
|
196 |
+
<enable>1</enable>
|
197 |
+
<time>01,00,00</time>
|
198 |
+
</configurable_cron>
|
199 |
+
<options>
|
200 |
+
<debug>0</debug>
|
201 |
+
<payment_method>cosmiccart</payment_method>
|
202 |
+
<environment>1</environment>
|
203 |
+
<staging_api_url><![CDATA[https://staging.cosmiccart.com/api]]></staging_api_url>
|
204 |
+
<staging_api_sftp><![CDATA[sftp.staging.cosmiccart.com]]></staging_api_sftp>
|
205 |
+
<production_api_url><![CDATA[https://cosmiccart.com/api]]></production_api_url>
|
206 |
+
<production_api_sftp><![CDATA[sftp.cosmiccart.com]]></production_api_sftp>
|
207 |
+
<local_api_url><![CDATA[https://local.cosmiccart.com/api]]></local_api_url>
|
208 |
+
<local_api_sftp><![CDATA[sftp.staging.cosmiccart.com]]></local_api_sftp>
|
209 |
+
</options>
|
210 |
+
<export_opt>
|
211 |
+
<max_batch_size>3000</max_batch_size>
|
212 |
+
</export_opt>
|
213 |
+
</cosmiccart>
|
214 |
+
<crontab>
|
215 |
+
<jobs>
|
216 |
+
<integration_cosmiccart_generate_batch>
|
217 |
+
<schedule>
|
218 |
+
<cron_expr>0 1 * * *</cron_expr>
|
219 |
+
</schedule>
|
220 |
+
</integration_cosmiccart_generate_batch>
|
221 |
+
</jobs>
|
222 |
+
</crontab>
|
223 |
+
<payment>
|
224 |
+
<cosmiccart>
|
225 |
+
<order_status>pending</order_status>
|
226 |
+
</cosmiccart>
|
227 |
+
</payment>
|
228 |
+
</default>
|
229 |
</config>
|
app/code/community/CosmicCart/Integration/etc/cosmiccart.ini
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
base_api_url=https://cosmiccart.com/api
|
|
app/code/community/CosmicCart/Integration/etc/system.xml
CHANGED
@@ -1,16 +1,151 @@
|
|
1 |
-
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
-
<config>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
</
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<tabs>
|
4 |
+
<cosmiccart translate="label" module="cosmiccart_integration">
|
5 |
+
<label>Cosmic Cart</label>
|
6 |
+
<sort_order>100</sort_order>
|
7 |
+
</cosmiccart>
|
8 |
+
</tabs>
|
9 |
+
<sections>
|
10 |
+
<payment>
|
11 |
+
<groups>
|
12 |
+
<cosmiccart translate="label" module="cosmiccart_integration">
|
13 |
+
<label>Cosmic Cart Payment</label>
|
14 |
+
<sort_order>670</sort_order>
|
15 |
+
<show_in_default>1</show_in_default>
|
16 |
+
<show_in_website>1</show_in_website>
|
17 |
+
<show_in_store>0</show_in_store>
|
18 |
+
<fields>
|
19 |
+
<order_status translate="label">
|
20 |
+
<label>New Order Status</label>
|
21 |
+
<frontend_type>select</frontend_type>
|
22 |
+
<source_model>adminhtml/system_config_source_order_status_new</source_model>
|
23 |
+
<sort_order>2</sort_order>
|
24 |
+
<show_in_default>1</show_in_default>
|
25 |
+
<show_in_website>1</show_in_website>
|
26 |
+
<show_in_store>0</show_in_store>
|
27 |
+
</order_status>
|
28 |
+
</fields>
|
29 |
+
</cosmiccart>
|
30 |
+
</groups>
|
31 |
+
</payment>
|
32 |
+
<cosmiccart translate="label" module="cosmiccart_integration">
|
33 |
+
<label>Cosmic Cart Options</label>
|
34 |
+
<tab>cosmiccart</tab>
|
35 |
+
<sort_order>1000</sort_order>
|
36 |
+
<show_in_default>1</show_in_default>
|
37 |
+
<show_in_website>0</show_in_website>
|
38 |
+
<show_in_store>0</show_in_store>
|
39 |
+
<groups>
|
40 |
+
<configurable_cron translate="label">
|
41 |
+
<label>Cron Schedule</label>
|
42 |
+
<sort_order>10</sort_order>
|
43 |
+
<show_in_default>1</show_in_default>
|
44 |
+
<show_in_website>0</show_in_website>
|
45 |
+
<show_in_store>0</show_in_store>
|
46 |
+
<fields>
|
47 |
+
<enable>
|
48 |
+
<label>Enable daily export</label>
|
49 |
+
<frontend_type>select</frontend_type>
|
50 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
51 |
+
<sort_order>5</sort_order>
|
52 |
+
<show_in_default>1</show_in_default>
|
53 |
+
<show_in_website>0</show_in_website>
|
54 |
+
<show_in_store>0</show_in_store>
|
55 |
+
</enable>
|
56 |
+
<time translate="label">
|
57 |
+
<label>Start Time</label>
|
58 |
+
<frontend_type>time</frontend_type>
|
59 |
+
<backend_model>cosmiccart_integration/adminhtml_system_config_backend_dynamic_cron
|
60 |
+
</backend_model>
|
61 |
+
<sort_order>10</sort_order>
|
62 |
+
<show_in_default>1</show_in_default>
|
63 |
+
<show_in_website>0</show_in_website>
|
64 |
+
<show_in_store>0</show_in_store>
|
65 |
+
<comment>Daily time when new export batch will be generated</comment>
|
66 |
+
</time>
|
67 |
+
</fields>
|
68 |
+
</configurable_cron>
|
69 |
+
<options translate="label" module="cosmiccart_integration">
|
70 |
+
<label>Cosmic Cart Options</label>
|
71 |
+
<frontend_type>text</frontend_type>
|
72 |
+
<sort_order>20</sort_order>
|
73 |
+
<show_in_default>1</show_in_default>
|
74 |
+
<show_in_website>0</show_in_website>
|
75 |
+
<show_in_store>0</show_in_store>
|
76 |
+
<fields>
|
77 |
+
<payment_method translate="label">
|
78 |
+
<label>Payment method</label>
|
79 |
+
<frontend_type>select</frontend_type>
|
80 |
+
<source_model>cosmiccart_integration/adminhtml_system_config_source_payment</source_model>
|
81 |
+
<comment>Payment method that will be used for CosmicCart transactions</comment>
|
82 |
+
<sort_order>10</sort_order>
|
83 |
+
<show_in_default>1</show_in_default>
|
84 |
+
<show_in_website>0</show_in_website>
|
85 |
+
<show_in_store>0</show_in_store>
|
86 |
+
</payment_method>
|
87 |
+
<debug translate="label">
|
88 |
+
<label>Debug Mode</label>
|
89 |
+
<comment>Enables debug mode for installations where you are either unable or do not wish to
|
90 |
+
connect to Cosmic Cart's production server. NOTE: Activations from a non-production
|
91 |
+
Magento environment will be rejected by Cosmic Cart's production server.
|
92 |
+
</comment>
|
93 |
+
<frontend_type>select</frontend_type>
|
94 |
+
<sort_order>20</sort_order>
|
95 |
+
<show_in_default>1</show_in_default>
|
96 |
+
<show_in_website>0</show_in_website>
|
97 |
+
<show_in_store>0</show_in_store>
|
98 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
99 |
+
</debug>
|
100 |
+
<environment translate="label">
|
101 |
+
<label>Environment</label>
|
102 |
+
<frontend_type>select</frontend_type>
|
103 |
+
<sort_order>30</sort_order>
|
104 |
+
<show_in_default>1</show_in_default>
|
105 |
+
<show_in_website>0</show_in_website>
|
106 |
+
<show_in_store>0</show_in_store>
|
107 |
+
<source_model>cosmiccart_integration/system_config_source_environment</source_model>
|
108 |
+
</environment>
|
109 |
+
</fields>
|
110 |
+
</options>
|
111 |
+
<export_opt translate="label" module="cosmiccart_integration">
|
112 |
+
<label>Export Options</label>
|
113 |
+
<frontend_type>text</frontend_type>
|
114 |
+
<sort_order>100</sort_order>
|
115 |
+
<show_in_default>1</show_in_default>
|
116 |
+
<show_in_website>0</show_in_website>
|
117 |
+
<show_in_store>0</show_in_store>
|
118 |
+
<fields>
|
119 |
+
<max_batch_size translate="label">
|
120 |
+
<label>Max Batch Size</label>
|
121 |
+
<frontend_type>text</frontend_type>
|
122 |
+
<sort_order>100</sort_order>
|
123 |
+
<show_in_default>1</show_in_default>
|
124 |
+
<show_in_website>0</show_in_website>
|
125 |
+
<show_in_store>0</show_in_store>
|
126 |
+
</max_batch_size>
|
127 |
+
<brand_attr_code translate="label">
|
128 |
+
<label>"Brand" attribute code</label>
|
129 |
+
<frontend_type>text</frontend_type>
|
130 |
+
<sort_order>110</sort_order>
|
131 |
+
<show_in_default>1</show_in_default>
|
132 |
+
<show_in_website>0</show_in_website>
|
133 |
+
<show_in_store>0</show_in_store>
|
134 |
+
<comment>Code of attribute which represents product brand</comment>
|
135 |
+
</brand_attr_code>
|
136 |
+
<ean_attr_code translate="label">
|
137 |
+
<label>"UPC/EAN" attribute code</label>
|
138 |
+
<frontend_type>text</frontend_type>
|
139 |
+
<sort_order>120</sort_order>
|
140 |
+
<show_in_default>1</show_in_default>
|
141 |
+
<show_in_website>0</show_in_website>
|
142 |
+
<show_in_store>0</show_in_store>
|
143 |
+
<comment>Code of attribute which represents UPC/EAN</comment>
|
144 |
+
<backend_model>cosmiccart_integration/adminhtml_system_config_ean</backend_model>
|
145 |
+
</ean_attr_code>
|
146 |
+
</fields>
|
147 |
+
</export_opt>
|
148 |
+
</groups>
|
149 |
+
</cosmiccart>
|
150 |
+
</sections>
|
151 |
+
</config>
|
app/code/community/CosmicCart/Integration/etc/wsdl.xml
DELETED
@@ -1,44 +0,0 @@
|
|
1 |
-
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
-
<definitions xmlns:typens="urn:{{var wsdl.name}}" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
3 |
-
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns="http://schemas.xmlsoap.org/wsdl/" name="{{var wsdl.name}}"
|
4 |
-
targetNamespace="urn:{{var wsdl.name}}">
|
5 |
-
<types>
|
6 |
-
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:Magento">
|
7 |
-
<import namespace="http://schemas.xmlsoap.org/soap/encoding/"
|
8 |
-
schemaLocation="http://schemas.xmlsoap.org/soap/encoding/"/>
|
9 |
-
<complexType name="salesOrderEntityToCreate">
|
10 |
-
<all>
|
11 |
-
<element name="customer_id" type="xsd:int"/>
|
12 |
-
</all>
|
13 |
-
</complexType>
|
14 |
-
</schema>
|
15 |
-
</types>
|
16 |
-
<message name="salesOrderCreateRequest">
|
17 |
-
<part name="sessionId" type="xsd:string"/>
|
18 |
-
<part name="orderData" type="typens:salesOrderEntityToCreate"/>
|
19 |
-
</message>
|
20 |
-
<message name="salesOrderCreateResponse">
|
21 |
-
<part name="result" type="xsd:int"/>
|
22 |
-
</message>
|
23 |
-
<portType name="{{var wsdl.handler}}PortType">
|
24 |
-
<operation name="salesOrderCreate">
|
25 |
-
<documentation>Create sales order</documentation>
|
26 |
-
<input message="typens:salesOrderCreateRequest"/>
|
27 |
-
<output message="typens:salesOrderCreateResponse"/>
|
28 |
-
</operation>
|
29 |
-
</portType>
|
30 |
-
<binding name="{{var wsdl.handler}}Binding" type="typens:{{var wsdl.handler}}PortType">
|
31 |
-
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
|
32 |
-
<operation name="salesOrderCreate">
|
33 |
-
<soap:operation soapAction="urn:{{var wsdl.handler}}Action"/>
|
34 |
-
<input>
|
35 |
-
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
|
36 |
-
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
|
37 |
-
</input>
|
38 |
-
<output>
|
39 |
-
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
|
40 |
-
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
|
41 |
-
</output>
|
42 |
-
</operation>
|
43 |
-
</binding>
|
44 |
-
</definitions>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/CosmicCart/Integration/etc/wsi.xml
DELETED
@@ -1,359 +0,0 @@
|
|
1 |
-
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
-
<wsdl:definitions xmlns:typens="urn:{{var wsdl.name}}" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
3 |
-
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
|
4 |
-
name="{{var wsdl.name}}" targetNamespace="urn:{{var wsdl.name}}">
|
5 |
-
<wsdl:types>
|
6 |
-
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:{{var wsdl.name}}">
|
7 |
-
<xsd:complexType name="salesOrderEntityToCreate">
|
8 |
-
<xsd:sequence>
|
9 |
-
<xsd:element name="orderId" type="xsd:string" minOccurs="1"></xsd:element>
|
10 |
-
<xsd:element name="customer" type="typens:shoppingCartCustomerEntity" minOccurs="1"></xsd:element>
|
11 |
-
<xsd:element name="customer_addresses" type="typens:shoppingCartCustomerAddressEntityArray"
|
12 |
-
minOccurs="1"></xsd:element>
|
13 |
-
<xsd:element name="items" type="typens:salesOrderCreateProductEntityArray"
|
14 |
-
minOccurs="1"></xsd:element>
|
15 |
-
</xsd:sequence>
|
16 |
-
</xsd:complexType>
|
17 |
-
<xsd:complexType name="salesOrderCreateProductEntityArray">
|
18 |
-
<xsd:sequence>
|
19 |
-
<xsd:element minOccurs="0" maxOccurs="unbounded" name="complexObjectArray"
|
20 |
-
type="typens:salesOrderCreateProductEntity"/>
|
21 |
-
</xsd:sequence>
|
22 |
-
</xsd:complexType>
|
23 |
-
<xsd:complexType name="salesOrderCreateProductEntity">
|
24 |
-
<xsd:sequence>
|
25 |
-
<xsd:element name="orderItemId" type="xsd:string" minOccurs="1"/>
|
26 |
-
<xsd:element name="sku" type="xsd:string" minOccurs="1"/>
|
27 |
-
<xsd:element name="qty" type="xsd:double" minOccurs="1"/>
|
28 |
-
<xsd:element name="price" type="xsd:double" minOccurs="1"/>
|
29 |
-
<xsd:element name="shippingOption" type="xsd:string" minOccurs="1"/>
|
30 |
-
</xsd:sequence>
|
31 |
-
</xsd:complexType>
|
32 |
-
<xsd:element name="salesOrderCreateRequestParam">
|
33 |
-
<xsd:complexType>
|
34 |
-
<xsd:sequence>
|
35 |
-
<xsd:element minOccurs="1" maxOccurs="1" name="sessionId" type="xsd:string"/>
|
36 |
-
<xsd:element minOccurs="1" maxOccurs="1" name="orderData"
|
37 |
-
type="typens:salesOrderEntityToCreate"/>
|
38 |
-
</xsd:sequence>
|
39 |
-
</xsd:complexType>
|
40 |
-
</xsd:element>
|
41 |
-
<xsd:element name="salesOrderCreateResponseParam">
|
42 |
-
<xsd:complexType>
|
43 |
-
<xsd:sequence>
|
44 |
-
<xsd:element minOccurs="1" maxOccurs="1" name="result"
|
45 |
-
type="typens:salesOrderCreateResponseStatus"/>
|
46 |
-
</xsd:sequence>
|
47 |
-
</xsd:complexType>
|
48 |
-
</xsd:element>
|
49 |
-
<xsd:complexType name="salesOrderCreateResponseStatus">
|
50 |
-
<xsd:sequence>
|
51 |
-
<xsd:element minOccurs="1" maxOccurs="1" name="orderId" type="xsd:int"/>
|
52 |
-
<xsd:element name="items" type="typens:salesOrderCreateResponseProductArray"
|
53 |
-
minOccurs="1"></xsd:element>
|
54 |
-
</xsd:sequence>
|
55 |
-
</xsd:complexType>
|
56 |
-
<xsd:complexType name="salesOrderCreateResponseProductArray">
|
57 |
-
<xsd:sequence>
|
58 |
-
<xsd:element minOccurs="0" maxOccurs="unbounded" name="complexObjectArray"
|
59 |
-
type="typens:salesOrderCreateResponseProduct"/>
|
60 |
-
</xsd:sequence>
|
61 |
-
</xsd:complexType>
|
62 |
-
<xsd:complexType name="salesOrderCreateResponseProduct">
|
63 |
-
<xsd:sequence>
|
64 |
-
<xsd:element name="sku" type="xsd:string" minOccurs="1"/>
|
65 |
-
<xsd:element name="qtyRequested" type="xsd:double" minOccurs="1"/>
|
66 |
-
<xsd:element name="qtyAllocated" type="xsd:double" minOccurs="1"/>
|
67 |
-
<xsd:element name="qtyBackordered" type="xsd:double" minOccurs="1"/>
|
68 |
-
<xsd:element name="qtyFailed" type="xsd:double" minOccurs="1"/>
|
69 |
-
<xsd:element name="tax" type="xsd:double" minOccurs="1"/>
|
70 |
-
</xsd:sequence>
|
71 |
-
</xsd:complexType>
|
72 |
-
<!--
|
73 |
-
The existing Magento endpoint for fetching shipping methods and rates is based on an existing cart,
|
74 |
-
but we aren't doing cart sync (yet,) so we need a custom endpoint that allows us to do the same
|
75 |
-
operation based on address.
|
76 |
-
-->
|
77 |
-
<xsd:element name="salesOrderGetShippingMethodsListRequestParam">
|
78 |
-
<xsd:complexType>
|
79 |
-
<xsd:sequence>
|
80 |
-
<xsd:element minOccurs="1" maxOccurs="1" name="sessionId" type="xsd:string"/>
|
81 |
-
<xsd:element minOccurs="1" maxOccurs="1" name="addressData"
|
82 |
-
type="typens:shoppingCartAddressEntity"/>
|
83 |
-
<xsd:element minOccurs="1" name="orderItemsData"
|
84 |
-
type="typens:salesOrderCreateProductEntityArray"/>
|
85 |
-
</xsd:sequence>
|
86 |
-
</xsd:complexType>
|
87 |
-
</xsd:element>
|
88 |
-
<!--
|
89 |
-
Custom request/response for fetching sales tax.
|
90 |
-
-->
|
91 |
-
<xsd:element name="salesOrderGetSalesTaxRequestParam">
|
92 |
-
<xsd:complexType>
|
93 |
-
<xsd:sequence>
|
94 |
-
<xsd:element minOccurs="1" maxOccurs="1" name="sessionId" type="xsd:string"/>
|
95 |
-
<xsd:element minOccurs="1" maxOccurs="1" name="addressData"
|
96 |
-
type="typens:shoppingCartAddressEntity"/>
|
97 |
-
<xsd:element minOccurs="1" name="orderItemsData"
|
98 |
-
type="typens:salesOrderCreateProductEntityArray"/>
|
99 |
-
</xsd:sequence>
|
100 |
-
</xsd:complexType>
|
101 |
-
</xsd:element>
|
102 |
-
<xsd:element name="salesOrderGetSalesTaxResponseParam">
|
103 |
-
<xsd:complexType>
|
104 |
-
<xsd:sequence>
|
105 |
-
<xsd:element minOccurs="1" maxOccurs="1" name="result" type="xsd:float"/>
|
106 |
-
</xsd:sequence>
|
107 |
-
</xsd:complexType>
|
108 |
-
</xsd:element>
|
109 |
-
<!--
|
110 |
-
Custom request/response for fetching shipping cost.
|
111 |
-
-->
|
112 |
-
<xsd:element name="salesOrderGetShippingCostRequestParam">
|
113 |
-
<xsd:complexType>
|
114 |
-
<xsd:sequence>
|
115 |
-
<xsd:element minOccurs="1" maxOccurs="1" name="sessionId" type="xsd:string"/>
|
116 |
-
<xsd:element minOccurs="1" maxOccurs="1" name="addressData"
|
117 |
-
type="typens:shoppingCartAddressEntity"/>
|
118 |
-
<xsd:element minOccurs="1" name="orderItemsData"
|
119 |
-
type="typens:salesOrderCreateProductEntityArray"/>
|
120 |
-
</xsd:sequence>
|
121 |
-
</xsd:complexType>
|
122 |
-
</xsd:element>
|
123 |
-
<xsd:element name="salesOrderGetShippingCostResponseParam">
|
124 |
-
<xsd:complexType>
|
125 |
-
<xsd:sequence>
|
126 |
-
<xsd:element minOccurs="1" maxOccurs="1" name="result" type="xsd:float"/>
|
127 |
-
</xsd:sequence>
|
128 |
-
</xsd:complexType>
|
129 |
-
</xsd:element>
|
130 |
-
<!--
|
131 |
-
Catalog Products
|
132 |
-
-->
|
133 |
-
<xsd:element name="catalogProductListPageableRequestParam">
|
134 |
-
<xsd:complexType>
|
135 |
-
<xsd:sequence>
|
136 |
-
<xsd:element minOccurs="1" maxOccurs="1" name="sessionId" type="xsd:string"/>
|
137 |
-
<xsd:element minOccurs="1" maxOccurs="1" name="filters" type="typens:filters"/>
|
138 |
-
<xsd:element minOccurs="0" maxOccurs="1" name="store" type="xsd:string"/>
|
139 |
-
<xsd:element minOccurs="0" maxOccurs="1" name="page" type="xsd:int"/>
|
140 |
-
<xsd:element minOccurs="0" maxOccurs="1" name="pageSize" type="xsd:int"/>
|
141 |
-
</xsd:sequence>
|
142 |
-
</xsd:complexType>
|
143 |
-
</xsd:element>
|
144 |
-
<xsd:element name="catalogProductListPageableResponseParam">
|
145 |
-
<xsd:complexType>
|
146 |
-
<xsd:sequence>
|
147 |
-
<xsd:element minOccurs="1" maxOccurs="1" name="result"
|
148 |
-
type="typens:catalogProductInventoryReturnEntityArray"/>
|
149 |
-
</xsd:sequence>
|
150 |
-
</xsd:complexType>
|
151 |
-
</xsd:element>
|
152 |
-
<xsd:complexType name="catalogProductInventoryReturnEntityArray">
|
153 |
-
<xsd:sequence>
|
154 |
-
<xsd:element minOccurs="0" maxOccurs="unbounded" name="complexObjectArray"
|
155 |
-
type="typens:catalogProductInventoryReturnEntity"/>
|
156 |
-
</xsd:sequence>
|
157 |
-
</xsd:complexType>
|
158 |
-
<xsd:complexType name="catalogProductInventoryReturnEntity">
|
159 |
-
<xsd:sequence>
|
160 |
-
<xsd:element name="product_id" type="xsd:string" minOccurs="0"/>
|
161 |
-
<xsd:element name="sku" type="xsd:string" minOccurs="0"/>
|
162 |
-
<xsd:element name="set" type="xsd:string" minOccurs="0"/>
|
163 |
-
<xsd:element name="type" type="xsd:string" minOccurs="0"/>
|
164 |
-
<xsd:element name="categories" type="typens:ArrayOfString" minOccurs="0"/>
|
165 |
-
<xsd:element name="websites" type="typens:ArrayOfString" minOccurs="0"/>
|
166 |
-
<xsd:element name="created_at" type="xsd:string" minOccurs="0"/>
|
167 |
-
<xsd:element name="updated_at" type="xsd:string" minOccurs="0"/>
|
168 |
-
<xsd:element name="type_id" type="xsd:string" minOccurs="0"/>
|
169 |
-
<xsd:element name="name" type="xsd:string" minOccurs="0"/>
|
170 |
-
<xsd:element name="description" type="xsd:string" minOccurs="0"/>
|
171 |
-
<xsd:element name="short_description" type="xsd:string" minOccurs="0"/>
|
172 |
-
<xsd:element name="weight" type="xsd:string" minOccurs="0"/>
|
173 |
-
<xsd:element name="status" type="xsd:string" minOccurs="0"/>
|
174 |
-
<xsd:element name="url_key" type="xsd:string" minOccurs="0"/>
|
175 |
-
<xsd:element name="url_path" type="xsd:string" minOccurs="0"/>
|
176 |
-
<xsd:element name="visibility" type="xsd:string" minOccurs="0"/>
|
177 |
-
<xsd:element name="category_ids" type="typens:ArrayOfString" minOccurs="0"/>
|
178 |
-
<xsd:element name="website_ids" type="typens:ArrayOfString" minOccurs="0"/>
|
179 |
-
<xsd:element name="has_options" type="xsd:string" minOccurs="0"/>
|
180 |
-
<xsd:element name="gift_message_available" type="xsd:string" minOccurs="0"/>
|
181 |
-
<xsd:element name="price" type="xsd:string" minOccurs="0"/>
|
182 |
-
<xsd:element name="special_price" type="xsd:string" minOccurs="0"/>
|
183 |
-
<xsd:element name="special_from_date" type="xsd:string" minOccurs="0"/>
|
184 |
-
<xsd:element name="special_to_date" type="xsd:string" minOccurs="0"/>
|
185 |
-
<xsd:element name="tax_class_id" type="xsd:string" minOccurs="0"/>
|
186 |
-
<xsd:element name="tier_price" type="typens:catalogProductTierPriceEntityArray" minOccurs="0"/>
|
187 |
-
<xsd:element name="meta_title" type="xsd:string" minOccurs="0"/>
|
188 |
-
<xsd:element name="meta_keyword" type="xsd:string" minOccurs="0"/>
|
189 |
-
<xsd:element name="meta_description" type="xsd:string" minOccurs="0"/>
|
190 |
-
<xsd:element name="custom_design" type="xsd:string" minOccurs="0"/>
|
191 |
-
<xsd:element name="custom_layout_update" type="xsd:string" minOccurs="0"/>
|
192 |
-
<xsd:element name="options_container" type="xsd:string" minOccurs="0"/>
|
193 |
-
<xsd:element name="additional_attributes" type="typens:associativeArray" minOccurs="0"/>
|
194 |
-
<xsd:element name="qty" type="xsd:string" minOccurs="0"/>
|
195 |
-
<xsd:element name="is_in_stock" type="xsd:string" minOccurs="0"/>
|
196 |
-
<xsd:element name="manufacturer" type="xsd:string" minOccurs="0"/>
|
197 |
-
<xsd:element name="parentSku" type="xsd:string" minOccurs="0"/>
|
198 |
-
<xsd:element name="attributes" type="typens:catalogProductConfigurableAttributeArray" minOccurs="0"
|
199 |
-
maxOccurs="1"/>
|
200 |
-
<xsd:element name="images" type="typens:catalogProductImageEntityArray" minOccurs="0"
|
201 |
-
maxOccurs="1"/>
|
202 |
-
</xsd:sequence>
|
203 |
-
</xsd:complexType>
|
204 |
-
<xsd:complexType name="catalogProductConfigurableAttributeArray">
|
205 |
-
<xsd:sequence>
|
206 |
-
<xsd:element minOccurs="0" maxOccurs="unbounded" name="complexObjectArray"
|
207 |
-
type="typens:catalogProductConfigurableAttribute"/>
|
208 |
-
</xsd:sequence>
|
209 |
-
</xsd:complexType>
|
210 |
-
<xsd:complexType name="catalogProductConfigurableAttribute">
|
211 |
-
<xsd:sequence>
|
212 |
-
<xsd:element name="attribute" type="xsd:string" minOccurs="1"/>
|
213 |
-
<xsd:element name="value" type="xsd:string" minOccurs="1"/>
|
214 |
-
</xsd:sequence>
|
215 |
-
</xsd:complexType>
|
216 |
-
<!-- Fix Magento Bugs -->
|
217 |
-
<xsd:element name="catalogProductAttributeRemoveRequestParam">
|
218 |
-
<xsd:complexType>
|
219 |
-
<xsd:sequence>
|
220 |
-
<xsd:element minOccurs="1" maxOccurs="1" name="sessionId" type="xsd:string"/>
|
221 |
-
<xsd:element minOccurs="1" maxOccurs="1" name="attribute" type="xsd:string"/>
|
222 |
-
</xsd:sequence>
|
223 |
-
</xsd:complexType>
|
224 |
-
</xsd:element>
|
225 |
-
<xsd:element name="catalogProductAttributeRemoveResponseParam">
|
226 |
-
<xsd:complexType>
|
227 |
-
<xsd:sequence>
|
228 |
-
<xsd:element minOccurs="1" maxOccurs="1" name="result" type="xsd:boolean"/>
|
229 |
-
</xsd:sequence>
|
230 |
-
</xsd:complexType>
|
231 |
-
</xsd:element>
|
232 |
-
<!-- END Fix Magento Bugs -->
|
233 |
-
</xsd:schema>
|
234 |
-
</wsdl:types>
|
235 |
-
<wsdl:message name="salesOrderCreateRequest">
|
236 |
-
<wsdl:part name="parameters" element="typens:salesOrderCreateRequestParam"/>
|
237 |
-
</wsdl:message>
|
238 |
-
<wsdl:message name="salesOrderCreateResponse">
|
239 |
-
<wsdl:part name="parameters" element="typens:salesOrderCreateResponseParam"/>
|
240 |
-
</wsdl:message>
|
241 |
-
<wsdl:message name="salesOrderGetShippingMethodsListRequest">
|
242 |
-
<wsdl:part name="parameters" element="typens:salesOrderGetShippingMethodsListRequestParam"/>
|
243 |
-
</wsdl:message>
|
244 |
-
<wsdl:message name="salesOrderGetShippingMethodsListResponse">
|
245 |
-
<wsdl:part name="parameters" element="typens:shoppingCartShippingListResponseParam"/>
|
246 |
-
</wsdl:message>
|
247 |
-
<wsdl:message name="salesOrderGetSalesTaxRequest">
|
248 |
-
<wsdl:part name="parameters" element="typens:salesOrderGetSalesTaxRequestParam"/>
|
249 |
-
</wsdl:message>
|
250 |
-
<wsdl:message name="salesOrderGetSalesTaxResponse">
|
251 |
-
<wsdl:part name="parameters" element="typens:salesOrderGetSalesTaxResponseParam"/>
|
252 |
-
</wsdl:message>
|
253 |
-
<wsdl:message name="salesOrderGetShippingCostRequest">
|
254 |
-
<wsdl:part name="parameters" element="typens:salesOrderGetShippingCostRequestParam"/>
|
255 |
-
</wsdl:message>
|
256 |
-
<wsdl:message name="salesOrderGetShippingCostResponse">
|
257 |
-
<wsdl:part name="parameters" element="typens:salesOrderGetShippingCostResponseParam"/>
|
258 |
-
</wsdl:message>
|
259 |
-
<wsdl:message name="catalogProductListPageableRequest">
|
260 |
-
<wsdl:part name="parameters" element="typens:catalogProductListPageableRequestParam"/>
|
261 |
-
</wsdl:message>
|
262 |
-
<wsdl:message name="catalogProductListPageableResponse">
|
263 |
-
<wsdl:part name="parameters" element="typens:catalogProductListPageableResponseParam"/>
|
264 |
-
</wsdl:message>
|
265 |
-
<!--Fix Magento Bugs -->
|
266 |
-
<wsdl:message name="catalogProductAttributeRemoveRequest">
|
267 |
-
<wsdl:part name="parameters" element="typens:catalogProductAttributeRemoveRequestParam"/>
|
268 |
-
</wsdl:message>
|
269 |
-
<wsdl:message name="catalogProductAttributeRemoveResponse">
|
270 |
-
<wsdl:part name="parameters" element="typens:catalogProductAttributeRemoveResponseParam"/>
|
271 |
-
</wsdl:message>
|
272 |
-
<!-- END Fix Magento Bugs -->
|
273 |
-
<wsdl:portType name="{{var wsdl.handler}}PortType">
|
274 |
-
<wsdl:operation name="salesOrderCreate">
|
275 |
-
<wsdl:documentation>Create sales order</wsdl:documentation>
|
276 |
-
<wsdl:input message="typens:salesOrderCreateRequest"/>
|
277 |
-
<wsdl:output message="typens:salesOrderCreateResponse"/>
|
278 |
-
</wsdl:operation>
|
279 |
-
<wsdl:operation name="salesOrderGetShippingMethodsList">
|
280 |
-
<wsdl:documentation>Create sales order</wsdl:documentation>
|
281 |
-
<wsdl:input message="typens:salesOrderGetShippingMethodsListRequest"/>
|
282 |
-
<wsdl:output message="typens:salesOrderGetShippingMethodsListResponse"/>
|
283 |
-
</wsdl:operation>
|
284 |
-
<wsdl:operation name="salesOrderGetSalesTax">
|
285 |
-
<wsdl:documentation>Create sales order</wsdl:documentation>
|
286 |
-
<wsdl:input message="typens:salesOrderGetSalesTaxRequest"/>
|
287 |
-
<wsdl:output message="typens:salesOrderGetSalesTaxResponse"/>
|
288 |
-
</wsdl:operation>
|
289 |
-
<wsdl:operation name="salesOrderGetShippingCost">
|
290 |
-
<wsdl:documentation>Create sales order</wsdl:documentation>
|
291 |
-
<wsdl:input message="typens:salesOrderGetShippingCostRequest"/>
|
292 |
-
<wsdl:output message="typens:salesOrderGetShippingCostResponse"/>
|
293 |
-
</wsdl:operation>
|
294 |
-
<wsdl:operation name="catalogProductListPageable">
|
295 |
-
<wsdl:documentation>Retrive pageable products list by filters</wsdl:documentation>
|
296 |
-
<wsdl:input message="typens:catalogProductListPageableRequest"/>
|
297 |
-
<wsdl:output message="typens:catalogProductListPageableResponse"/>
|
298 |
-
</wsdl:operation>
|
299 |
-
</wsdl:portType>
|
300 |
-
<wsdl:binding name="{{var wsdl.handler}}Binding" type="typens:{{var wsdl.handler}}PortType">
|
301 |
-
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
|
302 |
-
<wsdl:operation name="salesOrderCreate">
|
303 |
-
<soap:operation soapAction=""/>
|
304 |
-
<wsdl:input>
|
305 |
-
<soap:body use="literal"/>
|
306 |
-
</wsdl:input>
|
307 |
-
<wsdl:output>
|
308 |
-
<soap:body use="literal"/>
|
309 |
-
</wsdl:output>
|
310 |
-
</wsdl:operation>
|
311 |
-
<wsdl:operation name="salesOrderGetShippingMethodsList">
|
312 |
-
<soap:operation soapAction=""/>
|
313 |
-
<wsdl:input>
|
314 |
-
<soap:body use="literal"/>
|
315 |
-
</wsdl:input>
|
316 |
-
<wsdl:output>
|
317 |
-
<soap:body use="literal"/>
|
318 |
-
</wsdl:output>
|
319 |
-
</wsdl:operation>
|
320 |
-
<wsdl:operation name="salesOrderGetSalesTax">
|
321 |
-
<soap:operation soapAction=""/>
|
322 |
-
<wsdl:input>
|
323 |
-
<soap:body use="literal"/>
|
324 |
-
</wsdl:input>
|
325 |
-
<wsdl:output>
|
326 |
-
<soap:body use="literal"/>
|
327 |
-
</wsdl:output>
|
328 |
-
</wsdl:operation>
|
329 |
-
<wsdl:operation name="salesOrderGetShippingCost">
|
330 |
-
<soap:operation soapAction=""/>
|
331 |
-
<wsdl:input>
|
332 |
-
<soap:body use="literal"/>
|
333 |
-
</wsdl:input>
|
334 |
-
<wsdl:output>
|
335 |
-
<soap:body use="literal"/>
|
336 |
-
</wsdl:output>
|
337 |
-
</wsdl:operation>
|
338 |
-
<wsdl:operation name="catalogProductListPageable">
|
339 |
-
<soap:operation soapAction=""/>
|
340 |
-
<wsdl:input>
|
341 |
-
<soap:body use="literal"/>
|
342 |
-
</wsdl:input>
|
343 |
-
<wsdl:output>
|
344 |
-
<soap:body use="literal"/>
|
345 |
-
</wsdl:output>
|
346 |
-
</wsdl:operation>
|
347 |
-
<!-- Fix Magento Bugs -->
|
348 |
-
<wsdl:operation name="catalogProductAttributeRemove">
|
349 |
-
<soap:operation soapAction=""/>
|
350 |
-
<wsdl:input>
|
351 |
-
<soap:body use="literal"/>
|
352 |
-
</wsdl:input>
|
353 |
-
<wsdl:output>
|
354 |
-
<soap:body use="literal"/>
|
355 |
-
</wsdl:output>
|
356 |
-
</wsdl:operation>
|
357 |
-
<!-- END Fix Magento Bugs -->
|
358 |
-
</wsdl:binding>
|
359 |
-
</wsdl:definitions>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/CosmicCart/Integration/sql/cosmiccart_integration_setup/install-1.0.0.php
CHANGED
@@ -1,68 +1,60 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
* NOTICE OF LICENSE
|
4 |
-
*
|
5 |
-
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
-
*
|
7 |
-
* @category CosmicCart
|
8 |
-
* @package Integration
|
9 |
-
* @copyright Copyright (c)
|
10 |
-
* @license
|
11 |
-
*/
|
12 |
-
|
13 |
-
|
14 |
-
$installer
|
15 |
-
$
|
16 |
-
|
17 |
-
|
18 |
-
'
|
19 |
-
|
20 |
-
|
21 |
-
);
|
22 |
-
|
23 |
-
$installer->addAttribute('
|
24 |
-
|
25 |
-
|
26 |
-
$installer->
|
27 |
-
$installer->
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
->
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
));
|
62 |
-
$installer->getConnection()->createTable($table);
|
63 |
-
|
64 |
-
error_log("Cleaning cache...");
|
65 |
-
Mage::app()->cleanCache();
|
66 |
-
|
67 |
-
error_log("ENDING INSTALLATION!!");
|
68 |
-
$installer->endSetup();
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
+
*
|
7 |
+
* @category CosmicCart
|
8 |
+
* @package Integration
|
9 |
+
* @copyright Copyright (c) 2015 Cosmic Cart, Inc.
|
10 |
+
* @license CosmicCart Software License https://cosmiccart.com/help/license/software
|
11 |
+
*/
|
12 |
+
|
13 |
+
$installer = $this;
|
14 |
+
$installer->startSetup();
|
15 |
+
$cosmicCartOrderIdAttr = array(
|
16 |
+
'type' => 'varchar',
|
17 |
+
'label' => "Cosmic Cart Id",
|
18 |
+
'required' => false
|
19 |
+
);
|
20 |
+
$installer->addAttribute('quote', 'cosmic_cart_order_id', $cosmicCartOrderIdAttr);
|
21 |
+
$installer->addAttribute('order', 'cosmic_cart_order_id', $cosmicCartOrderIdAttr);
|
22 |
+
|
23 |
+
$installer->addAttribute('order_item', 'cosmic_cart_order_item_id', $cosmicCartOrderIdAttr);
|
24 |
+
$installer->addAttribute('quote_item', 'cosmic_cart_order_item_id', $cosmicCartOrderIdAttr);
|
25 |
+
|
26 |
+
$table = $installer->getConnection()
|
27 |
+
->newTable($installer->getTable('cosmiccart_integration_access_token'))
|
28 |
+
->addColumn('access_token', Varien_Db_Ddl_Table::TYPE_CHAR, 36, array(
|
29 |
+
'nullable' => false,
|
30 |
+
'primary' => true
|
31 |
+
))
|
32 |
+
->addColumn('token_type', Varien_Db_Ddl_Table::TYPE_VARCHAR, 32, array(
|
33 |
+
'nullable' => false
|
34 |
+
))
|
35 |
+
->addColumn('refresh_token', Varien_Db_Ddl_Table::TYPE_CHAR, 36, array(
|
36 |
+
'nullable' => false
|
37 |
+
))
|
38 |
+
->addColumn('expires', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
39 |
+
'nullable' => false,
|
40 |
+
'unsigned' => true
|
41 |
+
))
|
42 |
+
->addColumn('scope', Varien_Db_Ddl_Table::TYPE_VARCHAR, 32, array(
|
43 |
+
'nullable' => false
|
44 |
+
));
|
45 |
+
$installer->getConnection()->createTable($table);
|
46 |
+
|
47 |
+
$table = $installer->getConnection()
|
48 |
+
->newTable($installer->getTable('cosmiccart_integration_client'))
|
49 |
+
->addColumn('client_id', Varien_Db_Ddl_Table::TYPE_VARCHAR, 64, array(
|
50 |
+
'nullable' => false,
|
51 |
+
'primary' => true
|
52 |
+
))
|
53 |
+
->addColumn('client_secret', Varien_Db_Ddl_Table::TYPE_VARCHAR, 64, array(
|
54 |
+
'nullable' => false
|
55 |
+
));
|
56 |
+
$installer->getConnection()->createTable($table);
|
57 |
+
|
58 |
+
Mage::app()->cleanCache();
|
59 |
+
|
60 |
+
$installer->endSetup();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/CosmicCart/Integration/sql/cosmiccart_integration_setup/upgrade-1.0.0-1.0.1.php
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
+
*
|
7 |
+
* @category CosmicCart
|
8 |
+
* @package Integration
|
9 |
+
* @copyright Copyright (c) 2015 Cosmic Cart, Inc.
|
10 |
+
* @license CosmicCart Software License https://cosmiccart.com/help/license/software
|
11 |
+
*/
|
12 |
+
|
13 |
+
$installer = $this;
|
14 |
+
$installer->startSetup();
|
15 |
+
|
16 |
+
$table = $installer->getConnection()
|
17 |
+
->newTable($installer->getTable('cosmiccart_batch_status'))
|
18 |
+
->addColumn('batch_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
19 |
+
'identity' => true,
|
20 |
+
'unsigned' => true,
|
21 |
+
'nullable' => false,
|
22 |
+
'primary' => true
|
23 |
+
))
|
24 |
+
->addColumn('start_time', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
|
25 |
+
), 'Start Time')
|
26 |
+
->addColumn('end_time', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
|
27 |
+
), 'End Time')
|
28 |
+
->addColumn('total_row_count', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
29 |
+
'nullable' => false
|
30 |
+
))
|
31 |
+
->addColumn('config_total_row_count', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
32 |
+
'nullable' => false
|
33 |
+
))
|
34 |
+
->addColumn('number_of_processed_row', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
35 |
+
'nullable' => false
|
36 |
+
))
|
37 |
+
->addColumn('config_number_of_processed_row', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
38 |
+
'nullable' => false
|
39 |
+
))
|
40 |
+
->addColumn('current_stage', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
41 |
+
'nullable' => false,
|
42 |
+
'default' => '0'
|
43 |
+
))
|
44 |
+
->addColumn('comment', Varien_Db_Ddl_Table::TYPE_TEXT, 32, array(
|
45 |
+
'nullable' => false
|
46 |
+
))
|
47 |
+
->addColumn('num_of_times_retried', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
48 |
+
'nullable' => false
|
49 |
+
));
|
50 |
+
$installer->getConnection()->createTable($table);
|
51 |
+
|
52 |
+
$installer->endSetup();
|
app/code/community/CosmicCart/Integration/sql/cosmiccart_integration_setup/upgrade-2.0.0-2.0.1.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* This source file is subject to the Cosmic Cart license, a commercial license.
|
6 |
+
*
|
7 |
+
* @category CosmicCart
|
8 |
+
* @package Integration
|
9 |
+
* @copyright Copyright (c) 2015 Cosmic Cart, Inc.
|
10 |
+
* @license CosmicCart Software License https://cosmiccart.com/help/license/software
|
11 |
+
*/
|
12 |
+
|
13 |
+
|
14 |
+
$installer = $this;
|
15 |
+
$installer->startSetup();
|
16 |
+
|
17 |
+
$installer->getConnection()
|
18 |
+
->addColumn(
|
19 |
+
$installer->getTable('sales/shipment'),
|
20 |
+
'cosmiccart_processed',
|
21 |
+
array(
|
22 |
+
'type' => Varien_Db_Ddl_Table::TYPE_SMALLINT,
|
23 |
+
'nullable' => false,
|
24 |
+
'default' => '0',
|
25 |
+
'comment' => 'Cosmiccart processed'
|
26 |
+
)
|
27 |
+
);
|
28 |
+
|
29 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/layout/cosmiccart/integration.xml
CHANGED
@@ -1,9 +1,13 @@
|
|
1 |
<layout>
|
2 |
-
<
|
3 |
-
|
4 |
<reference name="content">
|
5 |
-
<block type="
|
6 |
-
</block>
|
7 |
</reference>
|
8 |
-
</
|
|
|
|
|
|
|
|
|
|
|
9 |
</layout>
|
1 |
<layout>
|
2 |
+
<adminhtml_integration_activation_index>
|
3 |
+
<!--<update handle="integration_activation_index"/>-->
|
4 |
<reference name="content">
|
5 |
+
<block type="cosmiccart_integration/adminhtml_storeselect" name="activation" template="cosmiccart/activation.phtml"/>
|
|
|
6 |
</reference>
|
7 |
+
</adminhtml_integration_activation_index>
|
8 |
+
<adminhtml_integration_batch_index>
|
9 |
+
<reference name="content">
|
10 |
+
<block type="cosmiccart_integration/adminhtml_cosmiccart" name="cosmiccart"/>
|
11 |
+
</reference>
|
12 |
+
</adminhtml_integration_batch_index>
|
13 |
</layout>
|
app/design/adminhtml/default/default/template/cosmiccart/activation.phtml
CHANGED
@@ -1,38 +1,67 @@
|
|
1 |
<div class="content-header">
|
2 |
<table cellspacing="0" class="grid-header">
|
3 |
<tr>
|
4 |
-
<td><h3
|
5 |
<td class="a-right">
|
6 |
-
<button onclick="editForm.submit()" class="scalable save" type="button"><span
|
7 |
</td>
|
8 |
</tr>
|
9 |
</table>
|
10 |
</div>
|
11 |
<div class="entry-edit">
|
12 |
-
<? if ($this->getData('activated')) { ?>
|
13 |
-
<div style="color:#009900;font-size:16px;margin-bottom:10px"
|
14 |
-
<? } ?>
|
15 |
-
<form id="edit_form" name="edit_form" method="post" action="
|
16 |
<input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
|
17 |
-
<h4 class="icon-head head-edit-form fieldset-legend"
|
18 |
<fieldset id="my-fieldset">
|
19 |
<table cellspacing="0" class="form-list">
|
20 |
<tr>
|
21 |
-
<td class="label"
|
22 |
<td class="input-ele"><input type="text" class="input-text required-entry" name="clientId" /></td>
|
23 |
</tr>
|
24 |
<tr>
|
25 |
-
<td class="label"
|
26 |
<td class="input-ele"><input type="text" class="input-text required-entry" name="clientSecret" /></td>
|
27 |
</tr>
|
28 |
<tr>
|
29 |
-
<td class="label"
|
30 |
<td class="input-ele"><input type="text" class="input-text required-entry" name="username" /></td>
|
31 |
</tr>
|
32 |
<tr>
|
33 |
-
<td class="label"
|
34 |
<td class="input-ele"><input type="password" class="input-text required-entry" name="password" /></td>
|
35 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
</table>
|
37 |
</fieldset>
|
38 |
</form>
|
1 |
<div class="content-header">
|
2 |
<table cellspacing="0" class="grid-header">
|
3 |
<tr>
|
4 |
+
<td><h3><?php echo $this->__('activation.title') ?></h3></td>
|
5 |
<td class="a-right">
|
6 |
+
<button onclick="editForm.submit()" class="scalable save" type="button"><span><?php echo $this->__('activation.submit') ?></span></button>
|
7 |
</td>
|
8 |
</tr>
|
9 |
</table>
|
10 |
</div>
|
11 |
<div class="entry-edit">
|
12 |
+
<?php if ($this->getData('activated')) { ?>
|
13 |
+
<div style="color:#009900;font-size:16px;margin-bottom:10px"><?php echo $this->__('activation.complete') ?></div>
|
14 |
+
<?php } ?>
|
15 |
+
<form id="edit_form" name="edit_form" method="post" action="<?php echo $this->getUrl('*/*/post') ?>">
|
16 |
<input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
|
17 |
+
<h4 class="icon-head head-edit-form fieldset-legend"><?php echo $this->__('activation.api.title') ?></h4>
|
18 |
<fieldset id="my-fieldset">
|
19 |
<table cellspacing="0" class="form-list">
|
20 |
<tr>
|
21 |
+
<td class="label"><?php echo $this->__('activation.api.client') ?> <span class="required">*</span></td>
|
22 |
<td class="input-ele"><input type="text" class="input-text required-entry" name="clientId" /></td>
|
23 |
</tr>
|
24 |
<tr>
|
25 |
+
<td class="label"><?php echo $this->__('activation.api.secret') ?> <span class="required">*</span></td>
|
26 |
<td class="input-ele"><input type="text" class="input-text required-entry" name="clientSecret" /></td>
|
27 |
</tr>
|
28 |
<tr>
|
29 |
+
<td class="label"><?php echo $this->__('activation.api.username') ?> <span class="required">*</span></td>
|
30 |
<td class="input-ele"><input type="text" class="input-text required-entry" name="username" /></td>
|
31 |
</tr>
|
32 |
<tr>
|
33 |
+
<td class="label"><?php echo $this->__('activation.api.password') ?> <span class="required">*</span></td>
|
34 |
<td class="input-ele"><input type="password" class="input-text required-entry" name="password" /></td>
|
35 |
</tr>
|
36 |
+
<tr>
|
37 |
+
<td class="label"><?php echo $this->__('activation.api.store') ?> <span class="required">*</span></td>
|
38 |
+
<td class="input-ele">
|
39 |
+
<div class="tree-store-scope">
|
40 |
+
<?php foreach ($this->getWebsiteCollection() as $_website): ?>
|
41 |
+
<?php $showWebsite = false; ?>
|
42 |
+
<?php foreach ($this->getGroupCollection($_website) as $_group): ?>
|
43 |
+
<?php $showGroup = false; ?>
|
44 |
+
<?php foreach ($this->getStoreCollection($_group) as $_store): ?>
|
45 |
+
<?php if ($showWebsite == false): ?>
|
46 |
+
<?php $showWebsite = true; ?>
|
47 |
+
<h3><?php echo $this->escapeHtml($_website->getName()) ?></h3>
|
48 |
+
<?php endif; ?>
|
49 |
+
<?php if ($showGroup == false): ?>
|
50 |
+
<?php $showGroup = true; ?>
|
51 |
+
<h4 style="margin-left:12px;"><?php echo $this->escapeHtml($_group->getName()) ?></h4>
|
52 |
+
<?php endif; ?>
|
53 |
+
<span class="field-row" style="margin-left:28px;">
|
54 |
+
<input type="radio" name='store' id="store_<?php echo $_store->getId() ?>" class="radio validate-one-required-by-name" value="<?php echo $_store->getId(); ?>"/>
|
55 |
+
<label for="store_<?php echo $_store->getId() ?>" class="inline"><?php echo $this->escapeHtml($_store->getName()) ?></label>
|
56 |
+
</span>
|
57 |
+
<?php endforeach; ?>
|
58 |
+
<?php if ($showGroup): ?>
|
59 |
+
<?php endif; ?>
|
60 |
+
<?php endforeach; ?>
|
61 |
+
<?php endforeach; ?>
|
62 |
+
</div>
|
63 |
+
</td>
|
64 |
+
</tr>
|
65 |
</table>
|
66 |
</fieldset>
|
67 |
</form>
|
app/etc/modules/CosmicCart_Cosmicapi.xml
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<CosmicCart_Cosmicapi>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
<version>0.1.0</version>
|
8 |
+
</CosmicCart_Cosmicapi>
|
9 |
+
</modules>
|
10 |
+
</config>
|
app/locale/en_US/CosmicCart_Integration.csv
CHANGED
@@ -5,6 +5,8 @@ activation.api.client, "Client ID"
|
|
5 |
activation.api.secret, "Client Secret"
|
6 |
activation.api.username, "Username"
|
7 |
activation.api.password, "Password"
|
8 |
-
activation.
|
|
|
9 |
activation.complete, "Activation complete. You need not use this form again unless you are experiencing authentication issues with Cosmic Cart."
|
10 |
-
Bad credentials, "Activation was not successful. Please check your credentials and try again."
|
|
5 |
activation.api.secret, "Client Secret"
|
6 |
activation.api.username, "Username"
|
7 |
activation.api.password, "Password"
|
8 |
+
activation.api.store, "Store"
|
9 |
+
activation.success, "The following stores have been successfully connected to Cosmic Cart:"
|
10 |
activation.complete, "Activation complete. You need not use this form again unless you are experiencing authentication issues with Cosmic Cart."
|
11 |
+
Bad credentials, "Activation was not successful. Please check your credentials and try again."
|
12 |
+
debug.prefix, "[DEBUG MODE] "
|
app/locale/en_US/template/email/cosmiccart/generic_error.html
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div>
|
2 |
+
<h1>Generic Error</h1>
|
3 |
+
|
4 |
+
<h2>Seller site: {{var siteUrl}}</h2>
|
5 |
+
|
6 |
+
<p>We encountered an unrecoverable error.</p>
|
7 |
+
|
8 |
+
<h3>The Error</h3>
|
9 |
+
|
10 |
+
<p>
|
11 |
+
<pre id="message" style="color:red">{{var message}}</pre>
|
12 |
+
</p>
|
13 |
+
<p>
|
14 |
+
<pre id="file" style="color:red">{{var file}}</pre>
|
15 |
+
</p>
|
16 |
+
<p>
|
17 |
+
<pre id="line" style="color:red">Line {{var line}}</pre>
|
18 |
+
</p>
|
19 |
+
</div>
|
app/locale/en_US/template/email/cosmiccart/import_exception.html
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div>
|
2 |
+
<h1>Catalog Export Exception</h1>
|
3 |
+
|
4 |
+
<h2>Seller site: {{var siteUrl}}</h2>
|
5 |
+
|
6 |
+
<p>There was a problem exporting the catalog at {{var pageSize}} products per page.</p>
|
7 |
+
|
8 |
+
<h3>The Exception</h3>
|
9 |
+
|
10 |
+
<p>
|
11 |
+
<pre id="exception" style="color:red">{{var exception}}</pre>
|
12 |
+
</p>
|
13 |
+
</div>
|
app/locale/en_US/template/email/cosmiccart/package_shipped.html
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div>
|
2 |
+
<h1>Fallback Email</h1>
|
3 |
+
|
4 |
+
<h2>Package Shipment Failure for SubOrder #{{var subOrderId}} on {{var shipDate}}</h2>
|
5 |
+
|
6 |
+
<p>The seller tried to ship the following package, but we couldn't reach the Cosmic Cart API.</p>
|
7 |
+
|
8 |
+
<h3>The Package</h3>
|
9 |
+
|
10 |
+
<p>
|
11 |
+
<pre id="json" style="color:#0000ff">{{var json}}</pre>
|
12 |
+
</p>
|
13 |
+
<h3>The Exception</h3>
|
14 |
+
|
15 |
+
<p>
|
16 |
+
<pre id="exception" style="color:red">{{var exception}}</pre>
|
17 |
+
</p>
|
18 |
+
</div>
|
app/locale/en_US/template/email/cosmiccart/refund_exception.html
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div>
|
2 |
+
<h1>Fallback Email</h1>
|
3 |
+
|
4 |
+
<h2>Refund Exception for SubOrder #{{var subOrderId}}</h2>
|
5 |
+
|
6 |
+
<p>The seller tried to issue the following refund, but we couldn't reach the Cosmic Cart API.</p>
|
7 |
+
|
8 |
+
<h3>The Refund</h3>
|
9 |
+
|
10 |
+
<p>
|
11 |
+
<pre id="json" style="color:#0000ff">{{var json}}</pre>
|
12 |
+
</p>
|
13 |
+
<h3>The Exception</h3>
|
14 |
+
|
15 |
+
<p>
|
16 |
+
<pre id="exception" style="color:red">{{var exception}}</pre>
|
17 |
+
</p>
|
18 |
+
</div>
|
package.xml
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
-
<name>
|
4 |
-
<version>
|
5 |
<stability>stable</stability>
|
6 |
-
<license uri="https://cosmiccart.com/license/
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
-
<summary>Cosmic Cart
|
10 |
-
<description>Cosmic Cart
|
11 |
-
<notes>
|
12 |
-
<authors><author><name>Cosmic Cart, Inc.</name><user>cosmiccart</user><email>
|
13 |
-
<date>
|
14 |
-
<time>
|
15 |
-
<contents><target name="magecommunity"><dir name="CosmicCart"><dir name="
|
16 |
<compatible/>
|
17 |
-
<dependencies><required><php><min>5.
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
+
<name>Cosmic_Cart</name>
|
4 |
+
<version>2.0.5</version>
|
5 |
<stability>stable</stability>
|
6 |
+
<license uri="https://cosmiccart.com/help/license/software">CosmicCart Software License</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
+
<summary>Cosmic Cart</summary>
|
10 |
+
<description>Cosmic Cart</description>
|
11 |
+
<notes>Version 2.0.5</notes>
|
12 |
+
<authors><author><name>Cosmic Cart, Inc.</name><user>cosmiccart</user><email>info@cosmiccart.com</email></author></authors>
|
13 |
+
<date>2016-03-15</date>
|
14 |
+
<time>16:53:35</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="CosmicCart"><dir name="Cosmicapi"><dir name="Helper"><file name="Data.php" hash="beb4f6961e2de95ee5c026e43981b7cb"/></dir><dir name="Model"><file name="Cosmicapi.php" hash="418a09523deb3a866c3556e450cb89f6"/><dir name="Resource"><dir name="Cosmicapi"><file name="Collection.php" hash="19ecabb6fbfbe4bbd7ccdfe3e1348c34"/></dir><file name="Cosmicapi.php" hash="600cc458f3b284c025fe0928082c65b3"/></dir></dir><dir name="controllers"><file name="RestController.php" hash="9eca60b458b1e26f9d247bc31010eb91"/></dir><dir name="etc"><file name="config.xml" hash="ea0a57474c5fa67d5effdaa9c78634ca"/></dir><dir name="sql"><dir name="cosmicapi_setup"><file name="install-0.1.0.php" hash="6ca54f01f2ff2da8dd15d2bc52d08032"/></dir></dir></dir><dir name="Integration"><dir name="Block"><dir name="Adminhtml"><dir name="Cosmiccart"><dir name="Edit"><file name="Form.php" hash="fb88468096b0d03ab57401789a1df184"/><dir name="Tab"><file name="Form.php" hash="9059e9b7007e7d19206ed8fd47a19d96"/></dir><file name="Tabs.php" hash="99bc110d5881c6a43bec9cc8d19f37e5"/></dir><file name="Edit.php" hash="04b9bccce57fe0f467c8ae2d2eb9520a"/><file name="Grid.php" hash="d14433b3c5a77d9714ad606d3480a183"/></dir><file name="Cosmiccart.php" hash="843445e1325c536a25944370aa0a1bef"/><file name="Storeselect.php" hash="66dd0f6eed12ea2966e6bf522aa2b1e4"/></dir><file name="Cosmiccart.php" hash="ba430aafc8a3859c921cb648a1a98856"/></dir><dir name="Helper"><file name="Data.php" hash="ba5bd526461db5ad6a2a615d3b7e214f"/></dir><dir name="Model"><file name="AccessToken.php" hash="a10013f841758229c6dc2e4a16a1b0bf"/><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Backend"><dir name="Dynamic"><file name="Cron.php" hash="8a50e02ba7d42f01b3287cc304578e40"/></dir></dir><file name="Ean.php" hash="323fa1b23ae4c5e5e794c81e8d79c00a"/><dir name="Source"><file name="Payment.php" hash="1fded50ba4959e53875f1dac03ce8309"/></dir></dir></dir></dir><file name="Batch.php" hash="07a37f12406ab16275e51331676b67e7"/><file name="Client.php" hash="3814db313c82812595e75d65cc854bc6"/><file name="ErrorHandler.php" hash="7550833e0c628a11984577227b4e4b12"/><file name="Exporter.php" hash="5091243d8d1bcaf394dbc95473dbcfdd"/><file name="Mail.php" hash="7d003fd58c43438362efe28a4a1380b6"/><file name="Oauth2client.php" hash="bd11c9ba42b69d3ad25153ed8c6d4df8"/><file name="Observer.php" hash="8c222a8dae1ed04c110ed0fefe3d3fae"/><dir name="Order"><dir name="Api"><file name="V2.php" hash="526ad61de3db04ee3e7da05bb68305bf"/></dir></dir><file name="Pay.php" hash="40dbd03250bea454ed54a69e09b577e6"/><dir name="Resource"><dir name="AccessToken"><file name="Collection.php" hash="d3a02ed68f823476ee9564c713bc65f3"/></dir><file name="AccessToken.php" hash="b26b20be7e18e8ff12260064daad5e0f"/><dir name="Batch"><file name="Collection.php" hash="1d441b30c548026dce0e9a120639f56e"/></dir><file name="Batch.php" hash="17f8761372d73307ce3826ea6cd2656f"/><dir name="Client"><file name="Collection.php" hash="d2fba20f90d6baaba572ae19f2f7888e"/></dir><file name="Client.php" hash="bff3e3025a5ff9bcff5c93394ab038f2"/><file name="Setup.php" hash="a209ae59d0f6f14055f47e1738fd970d"/></dir><dir name="System"><dir name="Config"><dir name="Source"><file name="Environment.php" hash="a39a92f32ba26e34cfc12b5b71cfa5c6"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Integration"><file name="ActivationController.php" hash="d30a8f5de9bea5f0185fd824941d07c6"/><file name="BatchController.php" hash="2e9dd8658dba3eec4e3bc42c368d6f58"/></dir></dir></dir><dir name="etc"><file name="config.xml" hash="888ce7c0d8291e2feb760d516d7bdff8"/><file name="system.xml" hash="d70649d44d07310a6f042ad8f7d47872"/></dir><dir name="sql"><dir name="cosmiccart_integration_setup"><file name="install-1.0.0.php" hash="c8efe70eabbb8aec987b0dea4b832627"/><file name="upgrade-1.0.0-1.0.1.php" hash="d319248b90cf192a7689cb2f853353fe"/><file name="upgrade-2.0.0-2.0.1.php" hash="8b3c1575b4c68e129877d758e3cb672b"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="cosmiccart"><file name="integration.xml" hash="58dc4554fd6770bd22091768253b4f7d"/></dir></dir><dir name="template"><dir name="cosmiccart"><file name="activation.phtml" hash="5381a2f847b707796b447365a14211f1"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="CosmicCart_Cosmicapi.xml" hash="b5437750840096c7ed1abc8bdced6443"/><file name="CosmicCart_Integration.xml" hash="b33d7bbfcd97eedaab65dfd8b6869de1"/></dir></target><target name="magelocale"><dir name="en_US"><dir name="template"><dir name="email"><dir name="cosmiccart"><file name="generic_error.html" hash="8458908bf29309629c3176f822c26ecb"/><file name="import_exception.html" hash="04aa8082317443692db7e7a42f84c1af"/><file name="package_shipped.html" hash="c57b318982b00b44e9279615d19455f6"/><file name="refund_exception.html" hash="488184cded40efd171cc9706c54ad8b0"/></dir></dir></dir></dir><dir><dir name="en_US"><file name="CosmicCart_Integration.csv" hash="b2a4c1b460ed259a6aaa41809cb49e77"/></dir></dir></target></contents>
|
16 |
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.4.0</min><max>5.6.0</max></php></required></dependencies>
|
18 |
</package>
|