Tritac_ChannelEngine - Version 2.0.4

Version Notes

* Better support for multistore setups

Download this release

Release Info

Developer Christiaan de Ridder
Extension Tritac_ChannelEngine
Version 2.0.4
Comparing to
See all releases


Version 2.0.4

Files changed (49) hide show
  1. app/code/community/Tritac/ChannelEngine/Block/Adminhtml/System/Config/Feed.php +53 -0
  2. app/code/community/Tritac/ChannelEngine/Block/Head.php +11 -0
  3. app/code/community/Tritac/ChannelEngine/Block/Sales/Order/Grid.php +204 -0
  4. app/code/community/Tritac/ChannelEngine/Helper/Data.php +94 -0
  5. app/code/community/Tritac/ChannelEngine/Model/Carrier/Channelengine.php +56 -0
  6. app/code/community/Tritac/ChannelEngine/Model/Observer.php +673 -0
  7. app/code/community/Tritac/ChannelEngine/Model/Order.php +32 -0
  8. app/code/community/Tritac/ChannelEngine/Model/Payment/Method/Channelengine.php +22 -0
  9. app/code/community/Tritac/ChannelEngine/Model/Resource/Order.php +60 -0
  10. app/code/community/Tritac/ChannelEngine/Model/Resource/Order/Collection.php +7 -0
  11. app/code/community/Tritac/ChannelEngine/Model/Resource/Setup.php +4 -0
  12. app/code/community/Tritac/ChannelEngine/Model/System/Config/Source/Shipping.php +40 -0
  13. app/code/community/Tritac/ChannelEngine/controllers/Adminhtml/GenerateController.php +12 -0
  14. app/code/community/Tritac/ChannelEngine/controllers/TestController.php +372 -0
  15. app/code/community/Tritac/ChannelEngine/etc/adminhtml.xml +25 -0
  16. app/code/community/Tritac/ChannelEngine/etc/config.xml +170 -0
  17. app/code/community/Tritac/ChannelEngine/etc/system.xml +133 -0
  18. app/code/community/Tritac/ChannelEngine/sql/channelengine_setup/mysql4-install-0.1.0.0.php +67 -0
  19. app/code/community/Tritac/ChannelEngine/sql/channelengine_setup/mysql4-install-1.0.0.php +56 -0
  20. app/etc/modules/Tritac_ChannelEngine.xml +9 -0
  21. lib/Tritac/ChannelEngineApiClient/AddTrustExternalCARoot.crt +25 -0
  22. lib/Tritac/ChannelEngineApiClient/Client.php +262 -0
  23. lib/Tritac/ChannelEngineApiClient/Enums/CancellationLineStatus.php +8 -0
  24. lib/Tritac/ChannelEngineApiClient/Enums/CancellationStatus.php +9 -0
  25. lib/Tritac/ChannelEngineApiClient/Enums/Gender.php +8 -0
  26. lib/Tritac/ChannelEngineApiClient/Enums/MancoReason.php +8 -0
  27. lib/Tritac/ChannelEngineApiClient/Enums/OrderStatus.php +13 -0
  28. lib/Tritac/ChannelEngineApiClient/Enums/ReturnAcceptStatus.php +6 -0
  29. lib/Tritac/ChannelEngineApiClient/Enums/ReturnReason.php +10 -0
  30. lib/Tritac/ChannelEngineApiClient/Enums/ReturnStatus.php +6 -0
  31. lib/Tritac/ChannelEngineApiClient/Enums/ShipmentLineStatus.php +8 -0
  32. lib/Tritac/ChannelEngineApiClient/Enums/ShipmentStatus.php +5 -0
  33. lib/Tritac/ChannelEngineApiClient/Helpers/Collection.php +49 -0
  34. lib/Tritac/ChannelEngineApiClient/Helpers/HttpMethod.php +9 -0
  35. lib/Tritac/ChannelEngineApiClient/Helpers/JsonMapper.php +91 -0
  36. lib/Tritac/ChannelEngineApiClient/Models/Address.php +97 -0
  37. lib/Tritac/ChannelEngineApiClient/Models/BaseModel.php +23 -0
  38. lib/Tritac/ChannelEngineApiClient/Models/Cancellation.php +39 -0
  39. lib/Tritac/ChannelEngineApiClient/Models/CancellationLine.php +33 -0
  40. lib/Tritac/ChannelEngineApiClient/Models/Message.php +12 -0
  41. lib/Tritac/ChannelEngineApiClient/Models/Order.php +154 -0
  42. lib/Tritac/ChannelEngineApiClient/Models/OrderExtraDataItem.php +19 -0
  43. lib/Tritac/ChannelEngineApiClient/Models/OrderLine.php +146 -0
  44. lib/Tritac/ChannelEngineApiClient/Models/ReturnLine.php +46 -0
  45. lib/Tritac/ChannelEngineApiClient/Models/ReturnObject.php +64 -0
  46. lib/Tritac/ChannelEngineApiClient/Models/Shipment.php +73 -0
  47. lib/Tritac/ChannelEngineApiClient/Models/ShipmentLine.php +48 -0
  48. lib/Tritac/ChannelEngineApiClient/loader.php +14 -0
  49. package.xml +18 -0
app/code/community/Tritac/ChannelEngine/Block/Adminhtml/System/Config/Feed.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Adminhtml system "generate feed" button
4
+ *
5
+ * @category Tritac
6
+ * @package Tritac_ChannelEngine
7
+ */
8
+ class Tritac_ChannelEngine_Block_Adminhtml_System_Config_Feed extends Mage_Adminhtml_Block_System_Config_Form_Field
9
+ {
10
+ /**
11
+ * Set template block template
12
+ *
13
+ * @return Tritac_ChannelEngine_Block_Adminhtml_System_Config_Feed
14
+ */
15
+ protected function _prepareLayout()
16
+ {
17
+ parent::_prepareLayout();
18
+ if (!$this->getTemplate()) {
19
+ $this->setTemplate('channelengine/system/config/feed/generate_button.phtml');
20
+ }
21
+ return $this;
22
+ }
23
+
24
+ /**
25
+ * Disable website scope
26
+ *
27
+ * @param Varien_Data_Form_Element_Abstract $element
28
+ * @return string
29
+ */
30
+ public function render(Varien_Data_Form_Element_Abstract $element)
31
+ {
32
+ $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
33
+ return parent::render($element);
34
+ }
35
+
36
+ /**
37
+ * Get the button and scripts contents
38
+ *
39
+ * @param Varien_Data_Form_Element_Abstract $element
40
+ * @return string
41
+ */
42
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
43
+ {
44
+ $originalData = $element->getOriginalData();
45
+ $this->addData(array(
46
+ 'button_label' => Mage::helper('channelengine')->__($originalData['button_label']),
47
+ 'html_id' => $element->getHtmlId(),
48
+ 'ajax_url' => Mage::getSingleton('adminhtml/url')->getUrl('channelengine/adminhtml_generate/ajax')
49
+ ));
50
+
51
+ return $this->_toHtml();
52
+ }
53
+ }
app/code/community/Tritac/ChannelEngine/Block/Head.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tritac_ChannelEngine_Block_Head extends Mage_Core_Block_Template
3
+ {
4
+ public function getAccountName() {
5
+
6
+ $storeId = Mage::app()->getStore()->getId();
7
+ $config = Mage::helper('channelengine')->getGeneralConfig();
8
+
9
+ return $config[$storeId]['tenant'];
10
+ }
11
+ }
app/code/community/Tritac/ChannelEngine/Block/Sales/Order/Grid.php ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tritac_ChannelEngine_Block_Sales_Order_Grid extends Mage_Adminhtml_Block_Widget_Grid {
3
+
4
+ public function __construct()
5
+ {
6
+ parent::__construct();
7
+ $this->setId('sales_order_grid');
8
+ $this->setUseAjax(true);
9
+ $this->setDefaultSort('created_at');
10
+ $this->setDefaultDir('DESC');
11
+ $this->setSaveParametersInSession(true);
12
+ }
13
+
14
+ /**
15
+ * Retrieve collection class
16
+ *
17
+ * @return string
18
+ */
19
+ protected function _getCollectionClass()
20
+ {
21
+ return 'sales/order_grid_collection';
22
+ }
23
+
24
+ protected function _prepareCollection()
25
+ {
26
+ $collection = Mage::getResourceModel($this->_getCollectionClass());
27
+ $joinTableName = Mage::getSingleton('core/resource')->getTableName('channelengine/order');
28
+ $collection->getSelect()->joinLeft(
29
+ array('channel_order_table' => $joinTableName),
30
+ 'channel_order_table.order_id=main_table.entity_id',
31
+ array('channel_name', 'channel_order_id')
32
+ );
33
+ $this->setCollection($collection);
34
+ return parent::_prepareCollection();
35
+ }
36
+
37
+ protected function _prepareColumns()
38
+ {
39
+ $this->addColumn('real_order_id', array(
40
+ 'header'=> Mage::helper('sales')->__('Order #'),
41
+ 'width' => '80px',
42
+ 'type' => 'text',
43
+ 'index' => 'increment_id',
44
+ ));
45
+
46
+ $this->addColumn('channel_order_id', array(
47
+ 'header'=> Mage::helper('sales')->__('ChannelEngine Order ID'),
48
+ 'width' => '80px',
49
+ 'type' => 'text',
50
+ 'index' => 'channel_order_id',
51
+ ));
52
+
53
+ $this->addColumn('channel_name', array(
54
+ 'header'=> Mage::helper('sales')->__('Channel Name'),
55
+ 'width' => '80px',
56
+ 'type' => 'text',
57
+ 'index' => 'channel_name',
58
+ ));
59
+
60
+ if (!Mage::app()->isSingleStoreMode()) {
61
+ $this->addColumn('store_id', array(
62
+ 'header' => Mage::helper('sales')->__('Purchased From (Store)'),
63
+ 'index' => 'store_id',
64
+ 'type' => 'store',
65
+ 'store_view'=> true,
66
+ 'display_deleted' => true,
67
+ ));
68
+ }
69
+
70
+ $this->addColumn('created_at', array(
71
+ 'header' => Mage::helper('sales')->__('Purchased On'),
72
+ 'index' => 'created_at',
73
+ 'type' => 'datetime',
74
+ 'width' => '100px',
75
+ ));
76
+
77
+ $this->addColumn('billing_name', array(
78
+ 'header' => Mage::helper('sales')->__('Bill to Name'),
79
+ 'index' => 'billing_name',
80
+ ));
81
+
82
+ $this->addColumn('shipping_name', array(
83
+ 'header' => Mage::helper('sales')->__('Ship to Name'),
84
+ 'index' => 'shipping_name',
85
+ ));
86
+
87
+ $this->addColumn('base_grand_total', array(
88
+ 'header' => Mage::helper('sales')->__('G.T. (Base)'),
89
+ 'index' => 'base_grand_total',
90
+ 'type' => 'currency',
91
+ 'currency' => 'base_currency_code',
92
+ ));
93
+
94
+ $this->addColumn('grand_total', array(
95
+ 'header' => Mage::helper('sales')->__('G.T. (Purchased)'),
96
+ 'index' => 'grand_total',
97
+ 'type' => 'currency',
98
+ 'currency' => 'order_currency_code',
99
+ ));
100
+
101
+ $this->addColumn('status', array(
102
+ 'header' => Mage::helper('sales')->__('Status'),
103
+ 'index' => 'status',
104
+ 'type' => 'options',
105
+ 'width' => '70px',
106
+ 'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
107
+ ));
108
+
109
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
110
+ $this->addColumn('action',
111
+ array(
112
+ 'header' => Mage::helper('sales')->__('Action'),
113
+ 'width' => '50px',
114
+ 'type' => 'action',
115
+ 'getter' => 'getId',
116
+ 'actions' => array(
117
+ array(
118
+ 'caption' => Mage::helper('sales')->__('View'),
119
+ 'url' => array('base'=>'*/sales_order/view'),
120
+ 'field' => 'order_id'
121
+ )
122
+ ),
123
+ 'filter' => false,
124
+ 'sortable' => false,
125
+ 'index' => 'stores',
126
+ 'is_system' => true,
127
+ ));
128
+ }
129
+ $this->addRssList('rss/order/new', Mage::helper('sales')->__('New Order RSS'));
130
+
131
+ $this->addExportType('*/*/exportCsv', Mage::helper('sales')->__('CSV'));
132
+ $this->addExportType('*/*/exportExcel', Mage::helper('sales')->__('Excel XML'));
133
+
134
+ return parent::_prepareColumns();
135
+ }
136
+
137
+ protected function _prepareMassaction()
138
+ {
139
+ $this->setMassactionIdField('entity_id');
140
+ $this->getMassactionBlock()->setFormFieldName('order_ids');
141
+ $this->getMassactionBlock()->setUseSelectAll(false);
142
+
143
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/cancel')) {
144
+ $this->getMassactionBlock()->addItem('cancel_order', array(
145
+ 'label'=> Mage::helper('sales')->__('Cancel'),
146
+ 'url' => $this->getUrl('*/sales_order/massCancel'),
147
+ ));
148
+ }
149
+
150
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/hold')) {
151
+ $this->getMassactionBlock()->addItem('hold_order', array(
152
+ 'label'=> Mage::helper('sales')->__('Hold'),
153
+ 'url' => $this->getUrl('*/sales_order/massHold'),
154
+ ));
155
+ }
156
+
157
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/unhold')) {
158
+ $this->getMassactionBlock()->addItem('unhold_order', array(
159
+ 'label'=> Mage::helper('sales')->__('Unhold'),
160
+ 'url' => $this->getUrl('*/sales_order/massUnhold'),
161
+ ));
162
+ }
163
+
164
+ $this->getMassactionBlock()->addItem('pdfinvoices_order', array(
165
+ 'label'=> Mage::helper('sales')->__('Print Invoices'),
166
+ 'url' => $this->getUrl('*/sales_order/pdfinvoices'),
167
+ ));
168
+
169
+ $this->getMassactionBlock()->addItem('pdfshipments_order', array(
170
+ 'label'=> Mage::helper('sales')->__('Print Packingslips'),
171
+ 'url' => $this->getUrl('*/sales_order/pdfshipments'),
172
+ ));
173
+
174
+ $this->getMassactionBlock()->addItem('pdfcreditmemos_order', array(
175
+ 'label'=> Mage::helper('sales')->__('Print Credit Memos'),
176
+ 'url' => $this->getUrl('*/sales_order/pdfcreditmemos'),
177
+ ));
178
+
179
+ $this->getMassactionBlock()->addItem('pdfdocs_order', array(
180
+ 'label'=> Mage::helper('sales')->__('Print All'),
181
+ 'url' => $this->getUrl('*/sales_order/pdfdocs'),
182
+ ));
183
+
184
+ $this->getMassactionBlock()->addItem('print_shipping_label', array(
185
+ 'label'=> Mage::helper('sales')->__('Print Shipping Labels'),
186
+ 'url' => $this->getUrl('*/sales_order_shipment/massPrintShippingLabel'),
187
+ ));
188
+
189
+ return $this;
190
+ }
191
+
192
+ public function getRowUrl($row)
193
+ {
194
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
195
+ return $this->getUrl('*/sales_order/view', array('order_id' => $row->getId()));
196
+ }
197
+ return false;
198
+ }
199
+
200
+ public function getGridUrl()
201
+ {
202
+ return $this->getUrl('*/*/grid', array('_current'=>true));
203
+ }
204
+ }
app/code/community/Tritac/ChannelEngine/Helper/Data.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tritac_ChannelEngine_Helper_Data extends Mage_Core_Helper_Abstract {
3
+
4
+ protected $_config = null;
5
+
6
+ /**
7
+ * Default expected shipment time (in weekdays)
8
+ *
9
+ * @var int
10
+ */
11
+ protected $_defaultTimeToShip = 5;
12
+
13
+ /**
14
+ * Get extension general config
15
+ *
16
+ * @param null $storeId
17
+ * @return array
18
+ */
19
+ public function getConfig($storeId = null)
20
+ {
21
+ if(empty($this->_config)) {
22
+ foreach(Mage::app()->getStores() as $_store) {
23
+ $this->_config[$_store->getId()] = Mage::getStoreConfig('channelengine', $_store->getId());
24
+ }
25
+ }
26
+
27
+ if($storeId) {
28
+ if(!isset($this->_config[$storeId])) {
29
+ return false;
30
+ }else{
31
+ return $this->_config[$storeId];
32
+ }
33
+ }
34
+
35
+ return $this->_config;
36
+ }
37
+
38
+ /**
39
+ * Get extension general config
40
+ *
41
+ * @return array
42
+ */
43
+ public function getGeneralConfig()
44
+ {
45
+ $result = array();
46
+
47
+ foreach($this->getConfig() as $storeId => $storeConfig) {
48
+ $result[$storeId] = $storeConfig['general'];
49
+ }
50
+
51
+ return $result;
52
+ }
53
+
54
+ /**
55
+ * Check required general config data
56
+ *
57
+ * @param null $storeId
58
+ * @return bool
59
+ */
60
+ public function checkGeneralConfig($storeId = null)
61
+ {
62
+ $config = Mage::getStoreConfig('channelengine/general', $storeId);
63
+
64
+ if(empty($config['api_key']) || empty($config['api_secret']) || empty($config['tenant'])) {
65
+ $storeMsg = ($storeId) ? 'for store '.$storeId : '';
66
+ Mage::log(
67
+ "Couldn't connect to ChannelEngine.
68
+ Please specify account keys {$storeMsg}
69
+ (System/Configuration/Tritac ChannelEngine/Settings/General)"
70
+ );
71
+ return false;
72
+ }
73
+
74
+ return true;
75
+ }
76
+
77
+ /**
78
+ * Get store expected shipment text
79
+ *
80
+ * @param $store_id
81
+ * @return DateTime
82
+ */
83
+ public function getExpectedShipmentDate($store_id)
84
+ {
85
+ $config = $this->getConfig($store_id);
86
+
87
+ $weekdays = (int) $config['shipping']['expected_date'];
88
+ if($weekdays <= 0)
89
+ $weekdays = $this->_defaultTimeToShip;
90
+
91
+ $expectedDate = date("Y-m-d", strtotime("{$weekdays} weekdays"));
92
+ return new DateTime($expectedDate);
93
+ }
94
+ }
app/code/community/Tritac/ChannelEngine/Model/Carrier/Channelengine.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tritac_ChannelEngine_Model_Carrier_Channelengine
3
+ extends Mage_Shipping_Model_Carrier_Abstract
4
+ implements Mage_Shipping_Model_Carrier_Interface
5
+ {
6
+
7
+ /** @var string Shipping method system code*/
8
+ protected $_code = 'channelengine';
9
+
10
+ protected $_isFixed = true;
11
+
12
+ /**
13
+ * Collect and get shipping rates
14
+ *
15
+ * @param Mage_Shipping_Model_Rate_Request $request
16
+ * @return bool|false|Mage_Core_Model_Abstract|Mage_Shipping_Model_Rate_Result|null
17
+ */
18
+ public function collectRates(Mage_Shipping_Model_Rate_Request $request)
19
+ {
20
+ if (!$this->getConfigFlag('active')) {
21
+ return false;
22
+ }
23
+
24
+ $result = Mage::getModel('shipping/rate_result');
25
+
26
+ $shippingPrice = false;
27
+
28
+ if(Mage::registry('channelengine_shipping_amount')) {
29
+ $shippingPrice = Mage::registry('channelengine_shipping_amount');
30
+ Mage::unregister('channelengine_shipping_amount');
31
+ }
32
+
33
+ if ($shippingPrice !== false) {
34
+ $method = Mage::getModel('shipping/rate_result_method');
35
+
36
+ $method->setCarrier($this->_code);
37
+ $method->setCarrierTitle($this->getConfigData('title'));
38
+
39
+ $method->setMethod($this->_code);
40
+ $method->setMethodTitle($this->getConfigData('name'));
41
+
42
+ $method->setPrice($shippingPrice);
43
+ $method->setCost($shippingPrice);
44
+
45
+ $result->append($method);
46
+ }
47
+
48
+ return $result;
49
+ }
50
+
51
+ public function getAllowedMethods()
52
+ {
53
+ return array('channelengine'=>'ChannelEngine');
54
+ }
55
+
56
+ }
app/code/community/Tritac/ChannelEngine/Model/Observer.php ADDED
@@ -0,0 +1,673 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Observer model
4
+ */
5
+ class Tritac_ChannelEngine_Model_Observer
6
+ {
7
+
8
+ /**
9
+ * API client
10
+ *
11
+ * @var Tritac_ChannelEngineApiClient_Client
12
+ */
13
+ protected $_client = null;
14
+
15
+ /**
16
+ * API config. API key, API secret, API tenant
17
+ *
18
+ * @var array
19
+ */
20
+ protected $_config = null;
21
+
22
+ /**
23
+ * ChannelEngine helper
24
+ *
25
+ * @var Tritac_ChannelEngine_Helper_Data
26
+ */
27
+ protected $_helper = null;
28
+
29
+ /**
30
+ * Retrieve and validate API config
31
+ * Initialize API client
32
+ */
33
+ public function __construct()
34
+ {
35
+ $this->_helper = Mage::helper('channelengine');
36
+ $this->_config = $this->_helper->getConfig();
37
+ /**
38
+ * Check required config parameters. Initialize API client.
39
+ */
40
+ foreach($this->_config as $storeId => $storeConfig) {
41
+ if($this->_helper->checkGeneralConfig($storeId)) {
42
+ $this->_client[$storeId] = new Tritac_ChannelEngineApiClient_Client(
43
+ $storeConfig['general']['api_key'],
44
+ $storeConfig['general']['api_secret'],
45
+ $storeConfig['general']['tenant']
46
+ );
47
+ }
48
+ }
49
+ }
50
+
51
+ public function getClients() {
52
+ var_export($this->_client);
53
+ die();
54
+ }
55
+
56
+ /**
57
+ * Fetch new orders from ChannelEngine.
58
+ * Uses for cronjob. Cronjob is set in extension config file.
59
+ *
60
+ * @return bool
61
+ */
62
+ public function fetchNewOrders()
63
+ {
64
+ /**
65
+ * Check if client is initialized
66
+ */
67
+ if(is_null($this->_client))
68
+ return false;
69
+
70
+ foreach($this->_client as $storeId => $_client) {
71
+ /**
72
+ * Retrieve new orders
73
+ */
74
+ $orders = $_client->getOrders(array(
75
+ Tritac_ChannelEngineApiClient_Enums_OrderStatus::NEW_ORDER
76
+ ));
77
+
78
+ /**
79
+ * Check new orders existing
80
+ */
81
+ if(is_null($orders) || $orders->count() == 0)
82
+ continue;
83
+
84
+ foreach($orders as $order) {
85
+
86
+ $billingAddress = $order->getBillingAddress();
87
+ $shippingAddress = $order->getShippingAddress();
88
+ if(empty($billingAddress)) continue;
89
+
90
+ $lines = $order->getLines();
91
+
92
+ if(!empty($lines)) {
93
+
94
+ // Initialize new quote
95
+ $quote = Mage::getModel('sales/quote')->setStoreId($storeId);
96
+
97
+ foreach($lines as $item) {
98
+
99
+ $productNo = $item->getMerchantProductNo();
100
+ $ids = explode('_', $productNo);
101
+ $productId = $ids[0];
102
+ // Load magento product
103
+ $_product = Mage::getModel('catalog/product')
104
+ ->setStoreId($storeId);
105
+ $productOptions = array();
106
+ $_product->load($productId);
107
+ if(count($ids) == 3) {
108
+ $productOptions = array($ids[1] => intval($ids[2]));
109
+ }
110
+
111
+ // Prepare product parameters for quote
112
+ $params = new Varien_Object();
113
+ $params->setQty($item->getQuantity());
114
+ $params->setOptions($productOptions);
115
+
116
+ // Add product to quote
117
+ try {
118
+ $_quoteItem = $quote->addProduct($_product, $params);
119
+ $_quoteItem->setChannelengineOrderLineId($item->getId());
120
+
121
+ } catch (Exception $e) {
122
+
123
+ Mage::getModel('adminnotification/inbox')->addCritical(
124
+ "An order (#{$order->getId()}) could not be imported",
125
+ "Reason: {$e->getMessage()} Please contact ChannelEngine support at <a href='mailto:support@channelengine.com'>support@channelengine.com</a> or +31(0)71-5288792"
126
+ );
127
+ Mage::logException($e);
128
+ continue 2;
129
+ }
130
+ }
131
+ }
132
+
133
+ $phone = $order->getPhone();
134
+ if(empty($phone))
135
+ $phone = '-';
136
+ // Prepare billing and shipping addresses
137
+ $billingData = array(
138
+ 'firstname' => $billingAddress->getFirstName(),
139
+ 'lastname' => $billingAddress->getLastName(),
140
+ 'email' => $order->getEmail(),
141
+ 'telephone' => $phone,
142
+ 'country_id' => $billingAddress->getCountryIso(),
143
+ 'postcode' => $billingAddress->getZipCode(),
144
+ 'city' => $billingAddress->getCity(),
145
+ 'street' =>
146
+ $billingAddress->getStreetName().' '.
147
+ $billingAddress->getHouseNr().
148
+ $billingAddress->getHouseNrAddition()
149
+ );
150
+ $shippingData = array(
151
+ 'firstname' => $shippingAddress->getFirstName(),
152
+ 'lastname' => $shippingAddress->getLastName(),
153
+ 'email' => $order->getEmail(),
154
+ 'telephone' => $phone,
155
+ 'country_id' => $shippingAddress->getCountryIso(),
156
+ 'postcode' => $shippingAddress->getZipCode(),
157
+ 'city' => $shippingAddress->getCity(),
158
+ 'street' =>
159
+ $shippingAddress->getStreetName().' '.
160
+ $shippingAddress->getHouseNr().
161
+ $shippingAddress->getHouseNrAddition()
162
+ );
163
+
164
+ // Register shipping cost. See Tritac_ChannelEngine_Model_Carrier_Channelengine::collectrates();
165
+ if($order->getShippingCostsInclVat() && floatval($order->getShippingCostsInclVat()) > 0) {
166
+ Mage::register('channelengine_shipping_amount', floatval($order->getShippingCostsInclVat()));
167
+ }
168
+
169
+ $quote->getBillingAddress()
170
+ ->addData($billingData);
171
+ $quote->getShippingAddress()
172
+ ->addData($shippingData)
173
+ ->setSaveInAddressBook(0)
174
+ ->setCollectShippingRates(true)
175
+ ->setShippingMethod('channelengine_channelengine');
176
+
177
+ $quote->collectTotals();
178
+
179
+ // Set guest customer
180
+ $quote->setCustomerId(null)
181
+ ->setCustomerEmail($quote->getBillingAddress()->getEmail())
182
+ ->setCustomerIsGuest(true)
183
+ ->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
184
+
185
+ // Set custom payment method
186
+ $quote->setIsSystem(true);
187
+ $quote->getPayment()->importData(array('method' => 'channelengine'));
188
+
189
+ // Save quote and convert it to new order
190
+ try {
191
+
192
+ $quote->save();
193
+
194
+ $service = Mage::getModel('sales/service_quote', $quote);
195
+
196
+ $service->submitAll();
197
+
198
+ } catch (Exception $e) {
199
+ Mage::getModel('adminnotification/inbox')->addCritical(
200
+ "An order (#{$order->getId()}) could not be imported",
201
+ "Reason: {$e->getMessage()} Please contact ChannelEngine support at <a href='mailto:support@channelengine.com'>support@channelengine.com</a> or +31(0)71-5288792"
202
+ );
203
+ Mage::logException($e);
204
+ continue;
205
+ }
206
+
207
+ $_order = $service->getOrder();
208
+
209
+
210
+ if($_order->getIncrementId()) {
211
+
212
+ /**
213
+ * Create new invoice and save channel order
214
+ */
215
+ try {
216
+ // Initialize new invoice model
217
+ $invoice = Mage::getModel('sales/service_order', $_order)->prepareInvoice();
218
+ // Add comment to invoice
219
+ $invoice->addComment(
220
+ "Order paid on the marketplace.",
221
+ false,
222
+ true
223
+ );
224
+
225
+ // Register invoice. Register invoice items. Collect invoice totals.
226
+ $invoice->register();
227
+ $invoice->getOrder()->setIsInProcess(true);
228
+
229
+ // Initialize new channel order
230
+ $_channelOrder = Mage::getModel('channelengine/order');
231
+ $_channelOrder->setOrderId($_order->getId())
232
+ ->setChannelOrderId($order->getId())
233
+ ->setChannelName($order->getChannelName())
234
+ ->setDoSendMails($order->getDoSendMails())
235
+ ->setCanShipPartial($order->getCanShipPartialOrderLines());
236
+
237
+ $invoice->getOrder()
238
+ ->setCanShipPartiallyItem($order->getCanShipPartialOrderLines())
239
+ ->setCanShipPartially($order->getCanShipPartialOrderLines());
240
+
241
+ // Start new transaction
242
+ $transactionSave = Mage::getModel('core/resource_transaction')
243
+ ->addObject($invoice)
244
+ ->addObject($invoice->getOrder())
245
+ ->addObject($_channelOrder);
246
+ $transactionSave->save();
247
+
248
+ } catch (Exception $e) {
249
+ Mage::getModel('adminnotification/inbox')->addCritical(
250
+ "An invoice could not be created (order #{$_order->getIncrementId()}, channel order #{$order->getId()})",
251
+ "Reason: {$e->getMessage()} Please contact ChannelEngine support at <a href='mailto:support@channelengine.com'>support@channelengine.com</a> or +31(0)71-5288792"
252
+ );
253
+ Mage::logException($e);
254
+ continue;
255
+ }
256
+ Mage::log("Order #{$_order->getIncrementId()} was imported successfully.");
257
+ } else {
258
+ Mage::log("An order (#{$order->getId()}) could not be imported");
259
+ }
260
+ }
261
+ }
262
+
263
+ return true;
264
+ }
265
+
266
+ /**
267
+ * Post new shipment to ChannelEngine. This function is set in extension config file.
268
+ *
269
+ * @param Varien_Event_Observer $observer
270
+ * @return bool
271
+ * @throws Exception
272
+ */
273
+ public function saveShipment(Varien_Event_Observer $observer)
274
+ {
275
+ $event = $observer->getEvent();
276
+ /** @var $_shipment Mage_Sales_Model_Order_Shipment */
277
+ $_shipment = $event->getShipment();
278
+ /** @var $_order Mage_Sales_Model_Order */
279
+ $_order = $_shipment->getOrder();
280
+ $storeId = $_order->getStoreId();
281
+ $channelOrder = Mage::getModel('channelengine/order')->loadByOrderId($_order->getId());
282
+ $channelOrderId = $channelOrder->getChannelOrderId();
283
+
284
+ /**
285
+ * Check ChannelEngine order
286
+ */
287
+ if(!$channelOrderId)
288
+ return false;
289
+
290
+ /**
291
+ * Check if client is initialized
292
+ */
293
+ if(!isset($this->_client[$storeId]))
294
+ return false;
295
+
296
+ /**
297
+ * Throw new exception if user not added tracking information
298
+ */
299
+ if(!$_shipment->getAllTracks()) {
300
+ Mage::getSingleton('adminhtml/session')->addError(
301
+ $this->_helper->__("Tracking information can not be empty")
302
+ );
303
+ throw new Exception(
304
+ $this->_helper->__("Cannot save shipment without tracking information.")
305
+ );
306
+ }
307
+
308
+ foreach($_shipment->getAllTracks() as $_track) {
309
+ // Initialize new ChannelEngine shipment object
310
+ $shipment = new Tritac_ChannelEngineApiClient_Models_Shipment();
311
+ $shipment->setOrderId($channelOrderId);
312
+ $shipment->setMerchantShipmentNo($_shipment->getId());
313
+ $shipment->setTrackTraceNo($_track->getNumber());
314
+ $shipment->setMethod($_track->getTitle());
315
+
316
+ // Initialize new ChannelEngine collection of shipments
317
+ $linesCollection = new Tritac_ChannelEngineApiClient_Helpers_Collection('Tritac_ChannelEngineApiClient_Models_ShipmentLine');
318
+
319
+ foreach($_order->getAllItems() as $_orderItem) {
320
+
321
+ // Load saved order item from db, because current items changed but still not saved
322
+ $_orderItemOrigin = Mage::getModel('sales/order_item')->load($_orderItem->getId());
323
+
324
+ // Get shipment item that contains required qty to ship.
325
+ $_shipmentItem = null;
326
+ foreach ($_shipment->getItemsCollection() as $item) {
327
+ if ($item->getOrderItemId()==$_orderItem->getId()) {
328
+ $_shipmentItem = $item;
329
+ break;
330
+ }
331
+ }
332
+
333
+ if(is_null($_shipmentItem)) {
334
+ continue;
335
+ }
336
+
337
+ $qtyToShip = (int) $_shipmentItem->getQty();
338
+ $orderedQty = (int) $_orderItem->getQtyOrdered();
339
+ $shippedQty = (int) $_orderItemOrigin->getQtyShipped();
340
+
341
+ // Skip item if all qty already shipped
342
+ if($orderedQty == $shippedQty)
343
+ continue;
344
+
345
+ // If we send a part of an order, post with status IN_BACKORDER
346
+ if($qtyToShip < $orderedQty - $shippedQty) {
347
+ $shipmentLine = new Tritac_ChannelEngineApiClient_Models_ShipmentLine();
348
+ // Fill required data
349
+ $shipmentLine->setShipmentId($_shipment->getId());
350
+ $shipmentLine->setOrderLineId($_orderItem->getChannelengineOrderLineId());
351
+ $shipmentLine->setQuantity($orderedQty - $qtyToShip - $shippedQty);
352
+ $shipmentLine->setStatus(Tritac_ChannelEngineApiClient_Enums_ShipmentLineStatus::IN_BACKORDER);
353
+ $expectedDate = $this->_helper->getExpectedShipmentDate($storeId);
354
+ $shipmentLine->setExpectedDate($expectedDate->format('Y-m-d'));
355
+ $shipmentLines[] = $shipmentLine;
356
+ // Put shipment line to shipments collection
357
+ $linesCollection->append($shipmentLine);
358
+ }
359
+ // Initialize new ChannelEngine Shipment Line
360
+ if($qtyToShip > 0) {
361
+ $shipmentLine = new Tritac_ChannelEngineApiClient_Models_ShipmentLine();
362
+ // Fill required data
363
+ $shipmentLine->setShipmentId($_shipment->getId());
364
+ $shipmentLine->setOrderLineId($_orderItem->getChannelengineOrderLineId());
365
+ $shipmentLine->setQuantity($qtyToShip);
366
+ $shipmentLine->setStatus(Tritac_ChannelEngineApiClient_Enums_ShipmentLineStatus::SHIPPED);
367
+ $shipmentLines[] = $shipmentLine;
368
+ // Put shipment line to shipments collection
369
+ $linesCollection->append($shipmentLine);
370
+ }
371
+ }
372
+
373
+ $shipment->setLines($linesCollection);
374
+ // Post shipment to ChannelEngine
375
+ $this->_client[$storeId]->postShipment($shipment);
376
+
377
+ Mage::log("Shippment #{$_shipment->getId()} was placed successfully.");
378
+
379
+ return true;
380
+ }
381
+ }
382
+
383
+ /**
384
+ * Fetch new returns from channelengine
385
+ *
386
+ * @return bool
387
+ */
388
+ public function fetchReturns()
389
+ {
390
+ /**
391
+ * Check if client is initialized
392
+ */
393
+ if(is_null($this->_client))
394
+ return false;
395
+
396
+ foreach($this->_client as $storeId => $_client) {
397
+ /**
398
+ * Retrieve returns
399
+ */
400
+ $returns = $_client->getReturns(array(
401
+ Tritac_ChannelEngineApiClient_Enums_ReturnStatus::DECLARED
402
+ ));
403
+
404
+ /**
405
+ * Check declared returns
406
+ */
407
+ if(is_null($returns) || $returns->count() == 0)
408
+ return false;
409
+
410
+ foreach($returns as $return) {
411
+ $_channelOrder = Mage::getModel('channelengine/order')->loadByChannelOrderId($return->getOrderId());
412
+ $_order = Mage::getModel('sales/order')->load($_channelOrder->getOrderId());
413
+
414
+ if(!$_order->getIncrementId()) {
415
+ continue;
416
+ }
417
+
418
+
419
+ $link = "https://". $this->_config[$storeId]['general']['tenant'] .".channelengine.net/orders/view/". $return->getOrderId();
420
+ $status = $return->getStatus(); // Get return status
421
+ $reason = $return->getReason(); // Get return reason
422
+ $title = "A new return was declared in ChannelEngine (ChannelEngine Order #{$return->getOrderId()})";
423
+ $message = "Magento Order #: <a href='".
424
+ Mage::helper('adminhtml')->getUrl('adminhtml/sales_order/view', array('order_id'=>$_order->getOrderId())).
425
+ "'>".
426
+ $_order->getIncrementId().
427
+ "</a><br />";
428
+ $message .= "Status: {$status}<br />";
429
+ $message .= "Reason: {$reason}<br />";
430
+ $message .= "For more details visit ChannelEngine your <a href='".$link."' target='_blank'>account</a>";
431
+
432
+ // Check if notification is already exist
433
+ $_resource = Mage::getSingleton('core/resource');
434
+ $_connectionRead = $_resource->getConnection('core_read');
435
+ $select = $_connectionRead->select()
436
+ ->from($_resource->getTableName('adminnotification/inbox'))
437
+ ->where('title = ?', $title)
438
+ ->where('is_remove != 1')
439
+ ->limit(1);
440
+ $data = $_connectionRead->fetchRow($select);
441
+
442
+ if ($data) {
443
+ continue;
444
+ }
445
+
446
+ // Add new notification
447
+ Mage::getModel('adminnotification/inbox')->addCritical(
448
+ $title,
449
+ $message,
450
+ $link
451
+ );
452
+ }
453
+ }
454
+ }
455
+
456
+ /**
457
+ * Generate products feed for ChannelEngine
458
+ */
459
+ public function generateFeed()
460
+ {
461
+ $start_memory = memory_get_usage();
462
+
463
+ /**
464
+ * Prepare categories array
465
+ */
466
+ $categoryArray = array();
467
+ $parent = Mage::app()->getWebsite(true)->getDefaultStore()->getRootCategoryId();
468
+ $category = Mage::getModel('catalog/category');
469
+ if ($category->checkId($parent)) {
470
+ $storeCategories = $category->getCategories($parent, 0, true, true, true);
471
+ foreach($storeCategories as $_category) {
472
+ $categoryArray[$_category->getId()] = $_category->getData();
473
+ }
474
+ }
475
+
476
+ /**
477
+ * Export products from each store.
478
+ * Note: products with undefined website id will not be export.
479
+ */
480
+ foreach(Mage::app()->getStores() as $_store) {
481
+
482
+ $path = Mage::getBaseDir('media') . DS . 'channelengine' . DS;
483
+ $storeConfig = $this->_helper->getConfig($_store->getId());
484
+ $name = $storeConfig['general']['tenant'].'_products.xml';
485
+ $file = $path . DS . $name;
486
+
487
+ $io = new Varien_Io_File();
488
+ $io->setAllowCreateFolders(true);
489
+ $io->open(array('path' => $path));
490
+ $io->streamOpen($file, 'w+');
491
+ $io->streamLock(true);
492
+ $io->streamWrite('<?xml version="1.0" encoding="UTF-8"?>' . "\n");
493
+ $io->streamWrite('<Products xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' . "\n");
494
+
495
+ /**
496
+ * Prepare custom options array
497
+ */
498
+ $storeId = $_store->getId();
499
+ $optionsArray = array();
500
+ $_options = Mage::getModel('catalog/product_option')
501
+ ->getCollection()
502
+ ->addTitleToResult($storeId)
503
+ ->addPriceToResult($storeId)
504
+ ->addValuesToResult($storeId)
505
+ ->setOrder('sort_order', 'asc');
506
+ foreach($_options as $_option) {
507
+ $productId = $_option->getProductId();
508
+ $optionId = $_option->getOptionId();
509
+ $optionsArray[$productId][$optionId] = $_option->getData();
510
+ if($_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_DROP_DOWN) {
511
+ $optionsArray[$productId][$optionId]['values'] = $_option->getValues();
512
+ }
513
+ }
514
+
515
+ /**
516
+ * Retrieve product collection
517
+ */
518
+ $collection = Mage::getModel('catalog/product')->getCollection()
519
+ ->addAttributeToSelect(array('name', 'description', 'image', 'url_key', 'price', 'cost', 'visibility', 'msrp'), 'left')
520
+ ->addFieldToFilter('type_id', 'simple')
521
+ ->addStoreFilter($_store)
522
+ ->addAttributeToFilter('status', 1)
523
+ ->addAttributeToSort('entity_id', 'DESC');
524
+
525
+ // Add qty and category fields to select
526
+ $collection->getSelect()
527
+ ->joinLeft(
528
+ array('csi' => Mage::getSingleton('core/resource')->getTableName('cataloginventory/stock_item')),
529
+ '`e`.`entity_id` = `csi`.`product_id`',
530
+ array('qty' => 'COALESCE(`qty`, 0)')
531
+ )
532
+ ->joinLeft(
533
+ array('ccp' => Mage::getSingleton('core/resource')->getTableName('catalog/category_product')),
534
+ '`e`.`entity_id` = `ccp`.`product_id`',
535
+ array('category_id' => 'MAX(`ccp`.`category_id`)')
536
+ )
537
+ ->group('e.entity_id');
538
+
539
+ Mage::getSingleton('core/resource_iterator')->walk(
540
+ $collection->getSelect(),
541
+ array(array($this, 'callbackGenerateFeed')),
542
+ array(
543
+ 'io' => $io,
544
+ 'categories' => $categoryArray,
545
+ 'options' => $optionsArray,
546
+ 'store' => $_store,
547
+ 'startMemory' => $start_memory,
548
+ )
549
+ );
550
+
551
+ $io->streamWrite('</Products>');
552
+ $io->streamUnlock();
553
+ $io->streamClose();
554
+
555
+ Mage::log("Product feed {$name} was generated successfully");
556
+ }
557
+
558
+ return true;
559
+ }
560
+
561
+ public function callbackGenerateFeed($args)
562
+ {
563
+ $io = $args['io'];
564
+ $product = $args['row'];
565
+ $categories = $args['categories'];
566
+ $options = $args['options'];
567
+ $_store = $args['store'];
568
+
569
+ $xml = '';
570
+
571
+ $product['store_id'] = $_store->getId();
572
+ /**
573
+ * Add product custom options to feed.
574
+ * Each option value will generate new product row
575
+ */
576
+ if(isset($options[$product['entity_id']])) {
577
+ $product['group_code'] = $product['entity_id'];
578
+ foreach($options[$product['entity_id']] as $option) {
579
+ if(isset($option['values'])) {
580
+ foreach($option['values'] as $_value) {
581
+ $product['id'] = $product['entity_id'].'_'.$option['option_id'].'_'.$_value->getId();
582
+ $additional['title'] = str_replace(' ', '_', $option['default_title']);
583
+ $additional['value'] = $_value->getDefaultTitle();
584
+ $xml .= $this->_getProductXml($product, $categories, $additional);
585
+ }
586
+ } else {
587
+ $product['id'] = $product['entity_id'].'_'.$option['option_id'];
588
+ $additional['title'] = str_replace(' ', '_', $option['default_title']);
589
+ $additional['value'] = '';
590
+ $xml .= $this->_getProductXml($product, $categories, $additional);
591
+ }
592
+ }
593
+ }else {
594
+ $product['id'] = $product['entity_id'];
595
+ $xml .= $this->_getProductXml($product, $categories);
596
+ }
597
+
598
+ $io->streamWrite($xml);
599
+ }
600
+
601
+ protected function _getProductXml($product, $categories, $additional = null)
602
+ {
603
+ $xml = "<Product>";
604
+ $xml .= "<Id>".$product['id']."</Id>";
605
+
606
+ // Add group code with product id if product have custom options
607
+ if(isset($product['group_code'])) {
608
+ $xml .= "<GroupCode><![CDATA[".$product['group_code']."]]></GroupCode>";
609
+ }
610
+ $xml .= "<Name><![CDATA[".$product['name']."]]></Name>";
611
+ $xml .= "<Description><![CDATA[".$product['description']."]]></Description>";
612
+ $xml .= "<Price><![CDATA[".$product['price']."]]></Price>";
613
+ $xml .= "<ListPrice><![CDATA[".$product['msrp']."]]></ListPrice>";
614
+ $xml .= "<PurchasePrice><![CDATA[".$product['cost']."]]></PurchasePrice>";
615
+
616
+ // Retrieve product stock qty
617
+ $xml .= "<Stock><![CDATA[".$product['qty']."]]></Stock>";
618
+ $xml .= "<SKU><![CDATA[".$product['sku']."]]></SKU>";
619
+
620
+ // VAT and Shipping Time are pre configured in extension settings
621
+ if(!empty($this->_config[$product['store_id']]['feed']['vat_rate'])) {
622
+ $vat = $this->_config[$product['store_id']]['feed']['vat_rate'];
623
+ $xml .= "<VAT><![CDATA[".$vat."]]></VAT>";
624
+ }
625
+
626
+ $shippingTime = ($product['qty'] > 0) ? $this->_config[$product['store_id']]['feed']['shipping_time'] : $this->_config[$product['store_id']]['feed']['shipping_time_oos'];
627
+
628
+ if($shippingTime) {
629
+ $xml .= "<ShippingTime><![CDATA[".$shippingTime."]]></ShippingTime>";
630
+ }
631
+
632
+ // Retrieve product url
633
+ $productModel = Mage::getModel('catalog/product');
634
+ $productModel->setData('entity_id', $product['entity_id']);
635
+ $productModel->setData('url_key', $product['url_key']);
636
+ $productModel->setData('store_id', Mage::app()->getWebsite(true)->getDefaultStore()->getId());
637
+ $url = $productModel->getProductUrl();
638
+ $xml .= "<Url><![CDATA[".$url."]]></Url>";
639
+
640
+ if(isset($product['image']) && $product['image'] != 'no_selection') {
641
+ $imgUrl = Mage::getSingleton('catalog/product_media_config')->getMediaUrl($product['image']);
642
+ $xml .= "<ImageUrl><![CDATA[".$imgUrl."]]></ImageUrl>";
643
+ }
644
+
645
+ // Prepare category path
646
+ if(!empty($product['category_id']) && !empty($categories)) {
647
+ $categoryId = $product['category_id'];
648
+ $categoryPathIds = explode('/', $categories[$categoryId]['path']);
649
+ $categoryPath = null;
650
+ foreach($categoryPathIds as $id) {
651
+ if($id > 2) {
652
+ $categoryPath .= ($categoryPath) ? ' > ':'';
653
+ $categoryPath .= $categories[$id]['name'];
654
+ }
655
+ }
656
+ if($categoryPath) {
657
+ $xml .= "<Category><![CDATA[".$categoryPath."]]></Category>";
658
+ }
659
+ }
660
+
661
+ if(isset($additional['title']) && isset($additional['value'])) {
662
+ $title = preg_replace("/[^a-zA-Z0-9]/", "", $additional['title']);
663
+ $xml .= sprintf("<%1\$s><![CDATA[%2\$s]]></%1\$s>",
664
+ $title,
665
+ $additional['value']
666
+ );
667
+ }
668
+
669
+ $xml .= "</Product>\n";
670
+
671
+ return $xml;
672
+ }
673
+ }
app/code/community/Tritac/ChannelEngine/Model/Order.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tritac_ChannelEngine_Model_Order extends Mage_Core_Model_Abstract {
3
+
4
+ protected function _construct()
5
+ {
6
+ $this->_init('channelengine/order');
7
+ }
8
+
9
+ /**
10
+ * Load channel order by magento order ID
11
+ *
12
+ * @param $orderId
13
+ * @return Tritac_ChannelEngine_Model_Order
14
+ */
15
+ public function loadByOrderId($orderId)
16
+ {
17
+ $this->_getResource()->loadByOrderId($this, $orderId);
18
+ return $this;
19
+ }
20
+
21
+ /**
22
+ * Load channel order by channel order ID
23
+ *
24
+ * @param $orderId
25
+ * @return Tritac_ChannelEngine_Model_Order
26
+ */
27
+ public function loadByChannelOrderId($orderId)
28
+ {
29
+ $this->_getResource()->loadByChannelOrderId($this, $orderId);
30
+ return $this;
31
+ }
32
+ }
app/code/community/Tritac/ChannelEngine/Model/Payment/Method/Channelengine.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ChannelEngine Payment Method
4
+ */
5
+ class Tritac_ChannelEngine_Model_Payment_Method_Channelengine extends Mage_Payment_Model_Method_Abstract {
6
+
7
+ /**
8
+ * System payment method code
9
+ *
10
+ * @var string
11
+ */
12
+ protected $_code = 'channelengine';
13
+
14
+ public function isAvailable($quote = null)
15
+ {
16
+ if($quote->getIsSystem() && $quote->getPayment()->getMethod() == $this->_code) {
17
+ return true;
18
+ }
19
+
20
+ return false;
21
+ }
22
+ }
app/code/community/Tritac/ChannelEngine/Model/Resource/Order.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tritac_ChannelEngine_Model_Resource_Order extends Mage_Core_Model_Resource_Db_Abstract {
3
+
4
+ protected function _construct()
5
+ {
6
+ $this->_init('channelengine/order', 'entity_id');
7
+ }
8
+
9
+ /**
10
+ * Load channel order by magento order ID
11
+ *
12
+ * @param Tritac_ChannelEngine_Model_Order $order
13
+ * @param int $orderId
14
+ * @return Tritac_ChannelEngine_Model_Resource_Order
15
+ */
16
+ public function loadByOrderId(Tritac_ChannelEngine_Model_Order $order, $orderId)
17
+ {
18
+
19
+ $adapter = $this->_getReadAdapter();
20
+ $bind = array('order_id' => $orderId);
21
+ $select = $adapter->select()
22
+ ->from($this->getMainTable(), array($this->getIdFieldName()))
23
+ ->where('order_id = :order_id');
24
+
25
+ $entityId = $adapter->fetchOne($select, $bind);
26
+ if ($entityId) {
27
+ $this->load($order, $entityId );
28
+ } else {
29
+ $order->setData(array());
30
+ }
31
+
32
+ return $this;
33
+ }
34
+
35
+ /**
36
+ * Load channel order by channel order ID
37
+ *
38
+ * @param Tritac_ChannelEngine_Model_Order $order
39
+ * @param int $orderId
40
+ * @return Tritac_ChannelEngine_Model_Resource_Order
41
+ */
42
+ public function loadByChannelOrderId(Tritac_ChannelEngine_Model_Order $order, $orderId)
43
+ {
44
+
45
+ $adapter = $this->_getReadAdapter();
46
+ $bind = array('channel_order_id' => $orderId);
47
+ $select = $adapter->select()
48
+ ->from($this->getMainTable(), array($this->getIdFieldName()))
49
+ ->where('channel_order_id = :channel_order_id');
50
+
51
+ $entityId = $adapter->fetchOne($select, $bind);
52
+ if ($entityId) {
53
+ $this->load($order, $entityId );
54
+ } else {
55
+ $order->setData(array());
56
+ }
57
+
58
+ return $this;
59
+ }
60
+ }
app/code/community/Tritac/ChannelEngine/Model/Resource/Order/Collection.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tritac_ChannelEngine_Model_Resource_Order_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract {
3
+
4
+ protected function _construct() {
5
+ $this->_init('channelengine/order');
6
+ }
7
+ }
app/code/community/Tritac/ChannelEngine/Model/Resource/Setup.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+
3
+ class Tritac_ChannelEngine_Model_Resource_Setup extends Mage_Catalog_Model_Resource_Setup {
4
+ }
app/code/community/Tritac/ChannelEngine/Model/System/Config/Source/Shipping.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tritac_ChannelEngine_Model_System_Config_Source_Shipping {
3
+
4
+ protected $_options = null;
5
+
6
+ public function toOptionArray() {
7
+
8
+ if(is_null($this->_options)) {
9
+ $_activeCarriers = Mage::getModel('shipping/config')->getActiveCarriers();
10
+
11
+ foreach($_activeCarriers as $carrierCode => $_carrier) {
12
+
13
+ if($_methods = $_carrier->getAllowedMethods()) {
14
+
15
+ if(!$title = Mage::getStoreConfig("carriers/{$_carrier->getId()}/title")) {
16
+ $title = $carrierCode;
17
+ }
18
+
19
+ $methods = array();
20
+
21
+ foreach($_methods as $methodCode => $method) {
22
+
23
+ $methods[] = array(
24
+ 'label' => $title.' – '.$method,
25
+ 'value' => $carrierCode.'_'.$methodCode
26
+ );
27
+ }
28
+
29
+ $this->_options[] = array(
30
+ 'label' => $title,
31
+ 'value' => $methods
32
+ );
33
+ }
34
+ }
35
+ }
36
+
37
+ return $this->_options;
38
+
39
+ }
40
+ }
app/code/community/Tritac/ChannelEngine/controllers/Adminhtml/GenerateController.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tritac_ChannelEngine_Adminhtml_GenerateController extends Mage_Adminhtml_Controller_Action
3
+ {
4
+ public function ajaxAction() {
5
+
6
+ $observer = Mage::getModel('channelengine/observer');
7
+
8
+ if($observer->generateFeed()) {
9
+ $this->getResponse()->setBody(1);
10
+ }
11
+ }
12
+ }
app/code/community/Tritac/ChannelEngine/controllers/TestController.php ADDED
@@ -0,0 +1,372 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Test Controller
4
+ */
5
+ class Tritac_ChannelEngine_TestController extends Mage_Core_Controller_Front_Action {
6
+
7
+ /**
8
+ * Index action
9
+ */
10
+ public function indexAction(){
11
+
12
+ $apiKey = Mage::getStoreConfig('channelengine/general/api_key');
13
+ $apiSecret = Mage::getStoreConfig('channelengine/general/api_secret');
14
+
15
+ $this->client = new Tritac_ChannelEngineApiClient_Client($apiKey, $apiSecret, 'plugindev');
16
+
17
+ $orders = $this->client->getOrders(array(Tritac_ChannelEngineApiClient_Enums_OrderStatus::IN_PROGRESS));
18
+
19
+ if(!is_null($orders))
20
+ {
21
+ foreach($orders as $order)
22
+ {
23
+ $billingAddress = $order->getBillingAddress();
24
+ if(empty($billingAddress)) continue;
25
+
26
+ $quote = Mage::getModel('sales/quote')->setStoreId(Mage::app()->getStore()->getId());
27
+
28
+ $lines = $order->getLines();
29
+ if(!empty($lines)){
30
+ foreach($lines as $item){
31
+ // Load magento product
32
+ $_product = Mage::getModel('catalog/product')
33
+ ->setStoreId(Mage::app()->getStore()->getId());
34
+ $productNo = $item->getMerchantProductNo();
35
+ $ids = explode('_', $productNo);
36
+ $productOptions = array();
37
+ if(count($ids) == 3) {
38
+ $productOptions = array($ids[1] => $ids[2]);
39
+ }
40
+ //$productId = $_product->getIdBySku();
41
+ $_product->load($ids[0]);
42
+
43
+ // Prepare product parameters for quote
44
+ $params = new Varien_Object();
45
+ $params->setQty($item->getQuantity());
46
+ $params->setOptions($productOptions);
47
+ try {
48
+ $quote->addProduct($_product, $params);
49
+ } catch (Mage_Core_Exception $e) {
50
+ echo $e->getMessage();
51
+ } catch (Exception $e) {
52
+ echo $e->getMessage();
53
+ Mage::logException($e);
54
+ }
55
+
56
+ }
57
+ }
58
+
59
+ $billingData = array(
60
+ 'firstname' => $billingAddress->getFirstName(),
61
+ 'lastname' => $billingAddress->getLastName(),
62
+ 'email' => $order->getEmail(),
63
+ 'telephone' => '1234567890',
64
+ 'country_id' => $billingAddress->getCountryIso(),
65
+ 'postcode' => $billingAddress->getZipCode(),
66
+ 'city' => $billingAddress->getCity(),
67
+ 'street' => array(
68
+ $billingAddress->getStreetName().' '.
69
+ $billingAddress->getHouseNr().
70
+ $billingAddress->getHouseNrAddition()
71
+ ),
72
+ 'save_in_address_book' => 0,
73
+ 'use_for_shipping' => 1
74
+ );
75
+
76
+ $quote->getBillingAddress()
77
+ ->addData($billingData);
78
+ $quote->getShippingAddress()
79
+ ->addData($billingData);
80
+
81
+ $quote->setCustomerId(null)
82
+ ->setCustomerEmail($quote->getBillingAddress()->getEmail())
83
+ ->setCustomerIsGuest(true)
84
+ ->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
85
+
86
+ $quote->getPayment()->importData(array('method' => 'checkmo'));
87
+ $quote->getShippingAddress()
88
+ ->setShippingMethod('freeshipping_freeshipping')
89
+ ->setCollectShippingRates(true)
90
+ ->collectTotals();
91
+
92
+
93
+ try {
94
+
95
+ $quote->save();
96
+
97
+ $service = Mage::getModel('sales/service_quote', $quote);
98
+ $service->submitAll();
99
+
100
+ } catch (Mage_Core_Exception $e) {
101
+ echo $e->getMessage();
102
+ } catch (Exception $e) {
103
+ echo $e->getMessage();
104
+ Mage::logException($e);
105
+ }
106
+
107
+ $_order = $service->getOrder();
108
+ var_export($_order->getIncrementId());
109
+ }
110
+ }
111
+ }
112
+
113
+ public function fetchAction()
114
+ {
115
+ $apiKey = Mage::getStoreConfig('channelengine/general/api_key');
116
+ $apiSecret = Mage::getStoreConfig('channelengine/general/api_secret');
117
+
118
+ $this->client = new Tritac_ChannelEngineApiClient_Client($apiKey, $apiSecret, 'plugindev');
119
+
120
+ /**
121
+ * Retrieve new orders
122
+ */
123
+ $orders = $this->client->getOrders(array(
124
+ Tritac_ChannelEngineApiClient_Enums_OrderStatus::NEW_ORDER
125
+ ));
126
+
127
+ /**
128
+ * Check new orders existing
129
+ */
130
+ if(is_null($orders) || $orders->count() == 0)
131
+ return false;
132
+
133
+ foreach($orders as $order) {
134
+
135
+ $billingAddress = $order->getBillingAddress();
136
+ $shippingAddress = $order->getShippingAddress();
137
+ if(empty($billingAddress)) continue;
138
+
139
+ // Initialize new quote
140
+ $quote = Mage::getModel('sales/quote')->setStoreId(Mage::app()->getDefaultStoreView()->getStoreId());
141
+ $lines = $order->getLines();
142
+
143
+ if(!empty($lines)) {
144
+
145
+ foreach($lines as $item) {
146
+
147
+ // Load magento product
148
+ $_product = Mage::getModel('catalog/product')
149
+ ->setStoreId(Mage::app()->getStore()->getId());
150
+ $productNo = $item->getMerchantProductNo();
151
+ $ids = explode('_', $productNo);
152
+ $productOptions = array();
153
+ if(count($ids) == 3) {
154
+ $productOptions = array($ids[1] => $ids[2]);
155
+ }
156
+ //$productId = $_product->getIdBySku();
157
+ $_product->load($ids[0]);
158
+
159
+ // Prepare product parameters for quote
160
+ $params = new Varien_Object();
161
+ $params->setQty($item->getQuantity());
162
+ $params->setOptions($productOptions);
163
+
164
+ // Add product to quote
165
+ try {
166
+ $_quoteItem = $quote->addProduct($_product, $params);
167
+ $_quoteItem->setChannelengineOrderLineId($item->getId());
168
+
169
+ } catch (Exception $e) {
170
+
171
+ Mage::getModel('adminnotification/inbox')->addCritical(
172
+ "An order (#{$order->getId()}) could not be imported",
173
+ "Reason: {$e->getMessage()} Please contact ChannelEngine support at <a href='mailto:support@channelengine.com'>support@channelengine.com</a> or +31(0)71-5288792"
174
+ );
175
+ Mage::logException($e);
176
+ continue 2;
177
+ }
178
+ }
179
+ }
180
+ $phone = $order->getPhone();
181
+ if(empty($phone))
182
+ $phone = '-';
183
+ // Prepare billing and shipping addresses
184
+ $billingData = array(
185
+ 'firstname' => $billingAddress->getFirstName(),
186
+ 'lastname' => $billingAddress->getLastName(),
187
+ 'email' => $order->getEmail(),
188
+ 'telephone' => $phone,
189
+ 'country_id' => $billingAddress->getCountryIso(),
190
+ 'postcode' => $billingAddress->getZipCode(),
191
+ 'city' => $billingAddress->getCity(),
192
+ 'street' =>
193
+ $billingAddress->getStreetName().' '.
194
+ $billingAddress->getHouseNr().
195
+ $billingAddress->getHouseNrAddition()
196
+ );
197
+ $shippingData = array(
198
+ 'firstname' => $shippingAddress->getFirstName(),
199
+ 'lastname' => $shippingAddress->getLastName(),
200
+ 'email' => $order->getEmail(),
201
+ 'telephone' => $phone,
202
+ 'country_id' => $shippingAddress->getCountryIso(),
203
+ 'postcode' => $shippingAddress->getZipCode(),
204
+ 'city' => $shippingAddress->getCity(),
205
+ 'street' =>
206
+ $shippingAddress->getStreetName().' '.
207
+ $shippingAddress->getHouseNr().
208
+ $shippingAddress->getHouseNrAddition()
209
+ );
210
+
211
+ // Register shipping cost. See Tritac_ChannelEngine_Model_Carrier_Channelengine::collectrates();
212
+ if($order->getShippingCostsInclVat() && floatval($order->getShippingCostsInclVat()) > 0) {
213
+ Mage::register('channelengine_shipping_amount', floatval($order->getShippingCostsInclVat()));
214
+ }
215
+
216
+ $quote->getBillingAddress()
217
+ ->addData($billingData);
218
+ $quote->getShippingAddress()
219
+ ->addData($shippingData)
220
+ ->setSaveInAddressBook(0)
221
+ ->setCollectShippingRates(true)
222
+ ->setShippingMethod('channelengine_channelengine');
223
+
224
+ $quote->collectTotals();
225
+
226
+ // Set guest customer
227
+ $quote->setCustomerId(null)
228
+ ->setCustomerEmail($quote->getBillingAddress()->getEmail())
229
+ ->setCustomerIsGuest(true)
230
+ ->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
231
+
232
+ // Set custom payment method
233
+ $quote->getPayment()->importData(array('method' => 'channelengine'));
234
+
235
+ // Save quote and convert it to new order
236
+ try {
237
+
238
+ $quote->save();
239
+
240
+ $service = Mage::getModel('sales/service_quote', $quote);
241
+
242
+ $service->submitAll();
243
+
244
+ } catch (Exception $e) {
245
+ Mage::getModel('adminnotification/inbox')->addCritical(
246
+ "An order (#{$order->getId()}) could not be imported",
247
+ "Reason: {$e->getMessage()} Please contact ChannelEngine support at <a href='mailto:support@channelengine.com'>support@channelengine.com</a> or +31(0)71-5288792"
248
+ );
249
+ Mage::logException($e);
250
+ continue;
251
+ }
252
+
253
+ $_order = $service->getOrder();
254
+
255
+ if($_order->getIncrementId()) {
256
+
257
+ /**
258
+ * Create new invoice and save channel order
259
+ */
260
+ try {
261
+ // Initialize new invoice model
262
+ $invoice = Mage::getModel('sales/service_order', $_order)->prepareInvoice();
263
+ // Add comment to invoice
264
+ $invoice->addComment(
265
+ "Order paid on the marketplace.",
266
+ false,
267
+ true
268
+ );
269
+
270
+ // Register invoice. Register invoice items. Collect invoice totals.
271
+ $invoice->register();
272
+ $invoice->getOrder()->setIsInProcess(true);
273
+
274
+ // Initialize new channel order
275
+ $_channelOrder = Mage::getModel('channelengine/order');
276
+ $_channelOrder->setOrderId($_order->getId())
277
+ ->setChannelOrderId($order->getId())
278
+ ->setChannelName($order->getChannelName())
279
+ ->setDoSendMails($order->getDoSendMails())
280
+ ->setCanShipPartial($order->getCanShipPartialOrderLines());
281
+
282
+ $invoice->getOrder()
283
+ ->setCanShipPartiallyItem($order->getCanShipPartialOrderLines())
284
+ ->setCanShipPartially($order->getCanShipPartialOrderLines());
285
+
286
+ // Start new transaction
287
+ $transactionSave = Mage::getModel('core/resource_transaction')
288
+ ->addObject($invoice)
289
+ ->addObject($invoice->getOrder())
290
+ ->addObject($_channelOrder);
291
+ $transactionSave->save();
292
+
293
+ } catch (Exception $e) {
294
+ Mage::getModel('adminnotification/inbox')->addCritical(
295
+ "An invoice could not be created (order #{$_order->getIncrementId()}, channel order #{$order->getId()})",
296
+ "Reason: {$e->getMessage()} Please contact ChannelEngine support at <a href='mailto:support@channelengine.com'>support@channelengine.com</a> or +31(0)71-5288792"
297
+ );
298
+ Mage::logException($e);
299
+ continue;
300
+ }
301
+ Mage::log("Order #{$_order->getIncrementId()} was imported successfully.");
302
+ } else {
303
+ Mage::log("An order (#{$order->getId()}) could not be imported");
304
+ }
305
+ }
306
+
307
+ return true;
308
+ }
309
+
310
+ public function returnAction() {
311
+
312
+ $apiKey = Mage::getStoreConfig('channelengine/general/api_key');
313
+ $apiSecret = Mage::getStoreConfig('channelengine/general/api_secret');
314
+
315
+ $this->client = new Tritac_ChannelEngineApiClient_Client($apiKey, $apiSecret, 'plugindev');
316
+
317
+ /**
318
+ * Retrieve returns
319
+ */
320
+ $returns = $this->client->getReturns(array(
321
+ Tritac_ChannelEngineApiClient_Enums_ReturnStatus::DECLARED
322
+ ));
323
+
324
+ /**
325
+ * Check declared returns
326
+ */
327
+ if(is_null($returns) || $returns->count() == 0)
328
+ return false;
329
+
330
+ foreach($returns as $return) {
331
+ $_channelOrder = Mage::getModel('channelengine/order')->loadByChannelOrderId($return->getOrderId());
332
+ $_order = Mage::getModel('sales/order')->load($_channelOrder->getOrderId());
333
+
334
+ if(!$_order->getIncrementId()) {
335
+ continue;
336
+ }
337
+
338
+ $status = $return->getStatus(); // Get return status
339
+ $reason = $return->getReason(); // Get return reason
340
+ $title = "You have new return from ChannelEngine (ChannelEngine Order #{$return->getOrderId()})";
341
+ $message = "Magento Order #: <a href='".
342
+ Mage::helper('adminhtml')->getUrl('adminhtml/sales_order/view', array('order_id'=>$_order->getOrderId())).
343
+ "'>".
344
+ $_order->getIncrementId().
345
+ "</a><br />";
346
+ $message .= "Status: {$status}<br />";
347
+ $message .= "Reason: {$reason}<br />";
348
+ $message .= "For more details visit your ChannelEngine <a href='http://www.channelengine.com' target='_blank'>account</a>";
349
+
350
+ // Check if notification is already exist
351
+ $_resource = Mage::getSingleton('core/resource');
352
+ $_connectionRead = $_resource->getConnection('core_read');
353
+ $select = $_connectionRead->select()
354
+ ->from($_resource->getTableName('adminnotification/inbox'))
355
+ ->where('title = ?', $title)
356
+ ->where('is_remove != 1')
357
+ ->limit(1);
358
+ $data = $_connectionRead->fetchRow($select);
359
+
360
+ if ($data) {
361
+ continue;
362
+ }
363
+
364
+ // Add new notification
365
+ Mage::getModel('adminnotification/inbox')->addCritical(
366
+ $title,
367
+ $message,
368
+ 'http://www.channelengine.com'
369
+ );
370
+ }
371
+ }
372
+ }
app/code/community/Tritac/ChannelEngine/etc/adminhtml.xml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <all>
6
+ <title>Allow Everything</title>
7
+ </all>
8
+ <admin>
9
+ <children>
10
+ <system>
11
+ <children>
12
+ <config>
13
+ <children>
14
+ <channelengine translate="title" module="channelengine">
15
+ <title>ChannelEngine.com</title>
16
+ </channelengine>
17
+ </children>
18
+ </config>
19
+ </children>
20
+ </system>
21
+ </children>
22
+ </admin>
23
+ </resources>
24
+ </acl>
25
+ </config>
app/code/community/Tritac/ChannelEngine/etc/config.xml ADDED
@@ -0,0 +1,170 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Tritac_ChannelEngine>
5
+ <version>2.0.4</version>
6
+ </Tritac_ChannelEngine>
7
+ </modules>
8
+
9
+ <global>
10
+ <blocks>
11
+ <adminhtml>
12
+ <rewrite>
13
+ <sales_order_grid>Tritac_ChannelEngine_Block_Sales_Order_Grid</sales_order_grid>
14
+ </rewrite>
15
+ </adminhtml>
16
+ <channelengine>
17
+ <class>Tritac_ChannelEngine_Block</class>
18
+ </channelengine>
19
+ </blocks>
20
+ <helpers>
21
+ <channelengine>
22
+ <class>Tritac_ChannelEngine_Helper</class>
23
+ </channelengine>
24
+ </helpers>
25
+ <models>
26
+ <channelengine>
27
+ <class>Tritac_ChannelEngine_Model</class>
28
+ <resourceModel>channelengine_resource</resourceModel>
29
+ </channelengine>
30
+ <channelengine_resource>
31
+ <class>Tritac_ChannelEngine_Model_Resource</class>
32
+ <entities>
33
+ <order>
34
+ <table>channelengine_order</table>
35
+ </order>
36
+ </entities>
37
+ </channelengine_resource>
38
+ </models>
39
+ <resources>
40
+ <channelengine_setup>
41
+ <setup>
42
+ <module>Tritac_ChannelEngine</module>
43
+ <class>Tritac_ChannelEngine_Model_Resource_Setup</class>
44
+ </setup>
45
+ <connection>
46
+ <use>core_setup</use>
47
+ </connection>
48
+ </channelengine_setup>
49
+ <channelengine_read>
50
+ <connection>
51
+ <use>core_read</use>
52
+ </connection>
53
+ </channelengine_read>
54
+ <channelengine_write>
55
+ <connection>
56
+ <use>core_write</use>
57
+ </connection>
58
+ </channelengine_write>
59
+ </resources>
60
+ <fieldsets>
61
+ <sales_convert_quote_item>
62
+ <channelengine_order_line_id>
63
+ <to_order_item>*</to_order_item>
64
+ </channelengine_order_line_id>
65
+ </sales_convert_quote_item>
66
+ <sales_convert_order_item>
67
+ <channelengine_order_line_id>
68
+ <to_quote_item>*</to_quote_item>
69
+ </channelengine_order_line_id>
70
+ </sales_convert_order_item>
71
+ </fieldsets>
72
+ </global>
73
+
74
+ <default>
75
+ <payment>
76
+ <channelengine>
77
+ <active>1</active>
78
+ <model>channelengine/payment_method_channelengine</model>
79
+ <name>ChannelEngine</name>
80
+ <title>Order paid on Marketplace Channel - ChannelEngine</title>
81
+ <allowspecific>0</allowspecific>
82
+ <order_status>pending</order_status>
83
+ </channelengine>
84
+ </payment>
85
+ <carriers>
86
+ <channelengine>
87
+ <active>1</active>
88
+ <sallowspecific>0</sallowspecific>
89
+ <model>channelengine/carrier_channelengine</model>
90
+ <title>Shipping paid on Marketplace Channel - ChannelEngine</title>
91
+ <price>0</price>
92
+ <specificerrmsg>This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us.</specificerrmsg>
93
+ </channelengine>
94
+ </carriers>
95
+ </default>
96
+
97
+ <frontend>
98
+ <routers>
99
+ <channelengine>
100
+ <use>standard</use>
101
+ <args>
102
+ <module>Tritac_ChannelEngine</module>
103
+ <frontName>channelengine</frontName>
104
+ </args>
105
+ </channelengine>
106
+ </routers>
107
+ <layout>
108
+ <updates>
109
+ <channelengine>
110
+ <file>channelengine.xml</file>
111
+ </channelengine>
112
+ </updates>
113
+ </layout>
114
+ </frontend>
115
+
116
+ <adminhtml>
117
+ <events>
118
+ <sales_order_shipment_save_after>
119
+ <observers>
120
+ <shipmentsave>
121
+ <type>singleton</type>
122
+ <class>channelengine/observer</class>
123
+ <method>saveShipment</method>
124
+ </shipmentsave>
125
+ </observers>
126
+ </sales_order_shipment_save_after>
127
+ </events>
128
+ </adminhtml>
129
+
130
+ <admin>
131
+ <routers>
132
+ <channelengine>
133
+ <use>admin</use>
134
+ <args>
135
+ <module>Tritac_ChannelEngine</module>
136
+ <frontName>channelengine</frontName>
137
+ </args>
138
+ </channelengine>
139
+ </routers>
140
+ </admin>
141
+
142
+ <crontab>
143
+ <jobs>
144
+ <fetch_channelengine_orders>
145
+ <schedule>
146
+ <cron_expr>*/15 * * * *</cron_expr>
147
+ </schedule>
148
+ <run>
149
+ <model>channelengine/observer::fetchNewOrders</model>
150
+ </run>
151
+ </fetch_channelengine_orders>
152
+ <fetch_channelengine_returns>
153
+ <schedule>
154
+ <cron_expr>*/15 * * * *</cron_expr>
155
+ </schedule>
156
+ <run>
157
+ <model>channelengine/observer::fetchReturns</model>
158
+ </run>
159
+ </fetch_channelengine_returns>
160
+ <generate_channelengine_feed>
161
+ <schedule>
162
+ <cron_expr>30 * * * *</cron_expr>
163
+ </schedule>
164
+ <run>
165
+ <model>channelengine/observer::generateFeed</model>
166
+ </run>
167
+ </generate_channelengine_feed>
168
+ </jobs>
169
+ </crontab>
170
+ </config>
app/code/community/Tritac/ChannelEngine/etc/system.xml ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+ <tabs>
5
+ <channelengine_com translate="label">
6
+ <label>ChannelEngine.com</label>
7
+ <sort_order>220</sort_order>
8
+ </channelengine_com>
9
+ </tabs>
10
+
11
+ <sections>
12
+ <channelengine translate="label" module="channelengine">
13
+ <label>Settings</label>
14
+ <tab>channelengine_com</tab>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+ <sort_order>1000</sort_order>
19
+ <groups>
20
+ <general translate="label">
21
+ <label>General</label>
22
+ <frontend_type>text</frontend_type>
23
+ <show_in_default>0</show_in_default>
24
+ <show_in_website>0</show_in_website>
25
+ <show_in_store>1</show_in_store>
26
+ <sort_order>1</sort_order>
27
+ <fields>
28
+ <api_key translate="label">
29
+ <label>Api Key</label>
30
+ <frontend_type>text</frontend_type>
31
+ <sort_order>1</sort_order>
32
+ <show_in_default>0</show_in_default>
33
+ <show_in_website>0</show_in_website>
34
+ <show_in_store>1</show_in_store>
35
+ </api_key>
36
+ <api_secret translate="label">
37
+ <label>Api Secret</label>
38
+ <frontend_type>text</frontend_type>
39
+ <sort_order>2</sort_order>
40
+ <show_in_default>0</show_in_default>
41
+ <show_in_website>0</show_in_website>
42
+ <show_in_store>1</show_in_store>
43
+ </api_secret>
44
+ <tenant translate="label">
45
+ <label>Account Name</label>
46
+ <frontend_type>text</frontend_type>
47
+ <comment>
48
+ <![CDATA[<span class="notice">Your account name can be found in the ChannelEngine address: <strong>your-account-name</strong>.channelengine.net</span>]]>
49
+ </comment>
50
+ <sort_order>3</sort_order>
51
+ <show_in_default>0</show_in_default>
52
+ <show_in_website>0</show_in_website>
53
+ <show_in_store>1</show_in_store>
54
+ </tenant>
55
+ </fields>
56
+ </general>
57
+ <shipping translate="label">
58
+ <label>Shipping</label>
59
+ <frontend_type>text</frontend_type>
60
+ <show_in_default>1</show_in_default>
61
+ <show_in_website>1</show_in_website>
62
+ <show_in_store>1</show_in_store>
63
+ <sort_order>2</sort_order>
64
+ <fields>
65
+ <expected_date translate="label">
66
+ <label>Expected Shipping Period (For backorders)</label>
67
+ <frontend_type>text</frontend_type>
68
+ <comment>
69
+ <![CDATA[<span class="notice">Please set the number of working days. Applies to order items with status "In Backorder"</span>]]>
70
+ </comment>
71
+ <sort_order>2</sort_order>
72
+ <show_in_default>1</show_in_default>
73
+ <show_in_website>1</show_in_website>
74
+ <show_in_store>1</show_in_store>
75
+ </expected_date>
76
+ </fields>
77
+ </shipping>
78
+ <feed translate="label">
79
+ <label>Product Feed</label>
80
+ <frontend_type>text</frontend_type>
81
+ <show_in_default>1</show_in_default>
82
+ <show_in_website>1</show_in_website>
83
+ <show_in_store>1</show_in_store>
84
+ <sort_order>3</sort_order>
85
+ <fields>
86
+ <vat_rate translate="label">
87
+ <label>Default Vat Rate (%)</label>
88
+ <frontend_type>text</frontend_type>
89
+ <sort_order>1</sort_order>
90
+ <show_in_default>1</show_in_default>
91
+ <show_in_website>1</show_in_website>
92
+ <show_in_store>1</show_in_store>
93
+ </vat_rate>
94
+ <shipping_time translate="label">
95
+ <label>Shipping Time (In Stock products)</label>
96
+ <frontend_type>text</frontend_type>
97
+ <comment>
98
+ <![CDATA[<span class="notice">For example: "Ordered before 9:00PM, Delivered tomorrow"</span>]]>
99
+ </comment>
100
+ <sort_order>2</sort_order>
101
+ <show_in_default>1</show_in_default>
102
+ <show_in_website>1</show_in_website>
103
+ <show_in_store>1</show_in_store>
104
+ </shipping_time>
105
+ <shipping_time_oos translate="label">
106
+ <label>Shipping Time (Out Of Stock products)</label>
107
+ <frontend_type>text</frontend_type>
108
+ <comment>
109
+ <![CDATA[<span class="notice">For example: "Ordered before 9:00PM, Delivered tomorrow"</span>]]>
110
+ </comment>
111
+ <sort_order>3</sort_order>
112
+ <show_in_default>1</show_in_default>
113
+ <show_in_website>1</show_in_website>
114
+ <show_in_store>1</show_in_store>
115
+ </shipping_time_oos>
116
+ <generate_product_feed translate="button_label">
117
+ <label>Generate product feed</label>
118
+ <button_label>Generate Product Feed</button_label>
119
+ <comment>
120
+ <![CDATA[<span class="notice">You need to configure cronjobs on your server to generate feeds automatically</span>]]>
121
+ </comment>
122
+ <frontend_model>channelengine/adminhtml_system_config_feed</frontend_model>
123
+ <sort_order>28</sort_order>
124
+ <show_in_default>1</show_in_default>
125
+ <show_in_website>1</show_in_website>
126
+ <show_in_store>1</show_in_store>
127
+ </generate_product_feed>
128
+ </fields>
129
+ </feed>
130
+ </groups>
131
+ </channelengine>
132
+ </sections>
133
+ </config>
app/code/community/Tritac/ChannelEngine/sql/channelengine_setup/mysql4-install-0.1.0.0.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ $installer->startSetup();
5
+
6
+ /**
7
+ * Create table 'channelengine/order'
8
+ */
9
+ $table = $installer->getConnection()
10
+ ->newTable($installer->getTable('channelengine/order'))
11
+ ->addColumn('entity_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
12
+ 'identity' => true,
13
+ 'nullable' => false,
14
+ 'primary' => true,
15
+ ), 'Entity ID')
16
+ ->addColumn('order_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
17
+ 'nullable' => false,
18
+ 'unsigned' => true,
19
+ ), 'Order ID')
20
+ ->addColumn('channel_order_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
21
+ 'nullable' => false,
22
+ 'unsigned' => true,
23
+ ), 'Channel Order ID')
24
+ ->addColumn('channel_name', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(), 'Channel Name')
25
+ ->addColumn('do_send_mails', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
26
+ 'nullable' => false,
27
+ 'default' => '0'
28
+ ), 'Do Send Mails')
29
+ ->addColumn('can_ship_partial', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
30
+ 'nullable' => false,
31
+ 'default' => '1'
32
+ ), 'Can Ship Partial Order Lines')
33
+ ->setComment('ChannelEngine Order Table');
34
+ $installer->getConnection()->createTable($table);
35
+
36
+ ///**
37
+ // * Add new column to table "sales_flat_order" that storage "ChannelEngine Order Id"
38
+ // */
39
+ //$installer->getConnection()->addColumn(
40
+ // $installer->getTable('sales/order'),
41
+ // 'channelengine_order_id',
42
+ // array(
43
+ // 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
44
+ // 'comment' => 'ChannelEngine Order Id'
45
+ // )
46
+ //);
47
+
48
+ /**
49
+ * Create new columns that storage "ChannelEngine Order Line Id"
50
+ */
51
+ $tables = array(
52
+ 'sales/quote_item',
53
+ 'sales/order_item'
54
+ );
55
+ $args = array(
56
+ 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
57
+ 'comment' => 'ChannelEngine Order Line Id'
58
+ );
59
+ foreach($tables as $tableName) {
60
+ $installer->getConnection()->addColumn(
61
+ $installer->getTable($tableName),
62
+ 'channelengine_order_line_id',
63
+ $args
64
+ );
65
+ }
66
+
67
+ $installer->endSetup();
app/code/community/Tritac/ChannelEngine/sql/channelengine_setup/mysql4-install-1.0.0.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ $installer->startSetup();
5
+
6
+ /**
7
+ * Create table 'channelengine/order'
8
+ */
9
+ $table = $installer->getConnection()
10
+ ->newTable($installer->getTable('channelengine/order'))
11
+ ->addColumn('entity_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
12
+ 'identity' => true,
13
+ 'nullable' => false,
14
+ 'primary' => true,
15
+ ), 'Entity ID')
16
+ ->addColumn('order_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
17
+ 'nullable' => false,
18
+ 'unsigned' => true,
19
+ ), 'Order ID')
20
+ ->addColumn('channel_order_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
21
+ 'nullable' => false,
22
+ 'unsigned' => true,
23
+ ), 'Channel Order ID')
24
+ ->addColumn('channel_name', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(), 'Channel Name')
25
+ ->addColumn('do_send_mails', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
26
+ 'nullable' => false,
27
+ 'default' => '0'
28
+ ), 'Do Send Mails')
29
+ ->addColumn('can_ship_partial', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
30
+ 'nullable' => false,
31
+ 'default' => '1'
32
+ ), 'Can Ship Partial Order Lines')
33
+ ->setComment('ChannelEngine Order Table');
34
+ $installer->getConnection()->createTable($table);
35
+
36
+
37
+ /**
38
+ * Create new columns that storage "ChannelEngine Order Line Id"
39
+ */
40
+ $tables = array(
41
+ 'sales/quote_item',
42
+ 'sales/order_item'
43
+ );
44
+ $args = array(
45
+ 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
46
+ 'comment' => 'ChannelEngine Order Line Id'
47
+ );
48
+ foreach($tables as $tableName) {
49
+ $installer->getConnection()->addColumn(
50
+ $installer->getTable($tableName),
51
+ 'channelengine_order_line_id',
52
+ $args
53
+ );
54
+ }
55
+
56
+ $installer->endSetup();
app/etc/modules/Tritac_ChannelEngine.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Tritac_ChannelEngine>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Tritac_ChannelEngine>
8
+ </modules>
9
+ </config>
lib/Tritac/ChannelEngineApiClient/AddTrustExternalCARoot.crt ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIENjCCAx6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBvMQswCQYDVQQGEwJTRTEU
3
+ MBIGA1UEChMLQWRkVHJ1c3QgQUIxJjAkBgNVBAsTHUFkZFRydXN0IEV4dGVybmFs
4
+ IFRUUCBOZXR3b3JrMSIwIAYDVQQDExlBZGRUcnVzdCBFeHRlcm5hbCBDQSBSb290
5
+ MB4XDTAwMDUzMDEwNDgzOFoXDTIwMDUzMDEwNDgzOFowbzELMAkGA1UEBhMCU0Ux
6
+ FDASBgNVBAoTC0FkZFRydXN0IEFCMSYwJAYDVQQLEx1BZGRUcnVzdCBFeHRlcm5h
7
+ bCBUVFAgTmV0d29yazEiMCAGA1UEAxMZQWRkVHJ1c3QgRXh0ZXJuYWwgQ0EgUm9v
8
+ dDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALf3GjPm8gAELTngTlvt
9
+ H7xsD821+iO2zt6bETOXpClMfZOfvUq8k+0DGuOPz+VtUFrWlymUWoCwSXrbLpX9
10
+ uMq/NzgtHj6RQa1wVsfwTz/oMp50ysiQVOnGXw94nZpAPA6sYapeFI+eh6FqUNzX
11
+ mk6vBbOmcZSccbNQYArHE504B4YCqOmoaSYYkKtMsE8jqzpPhNjfzp/haW+710LX
12
+ a0Tkx63ubUFfclpxCDezeWWkWaCUN/cALw3CknLa0Dhy2xSoRcRdKn23tNbE7qzN
13
+ E0S3ySvdQwAl+mG5aWpYIxG3pzOPVnVZ9c0p10a3CitlttNCbxWyuHv77+ldU9U0
14
+ WicCAwEAAaOB3DCB2TAdBgNVHQ4EFgQUrb2YejS0Jvf6xCZU7wO94CTLVBowCwYD
15
+ VR0PBAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wgZkGA1UdIwSBkTCBjoAUrb2YejS0
16
+ Jvf6xCZU7wO94CTLVBqhc6RxMG8xCzAJBgNVBAYTAlNFMRQwEgYDVQQKEwtBZGRU
17
+ cnVzdCBBQjEmMCQGA1UECxMdQWRkVHJ1c3QgRXh0ZXJuYWwgVFRQIE5ldHdvcmsx
18
+ IjAgBgNVBAMTGUFkZFRydXN0IEV4dGVybmFsIENBIFJvb3SCAQEwDQYJKoZIhvcN
19
+ AQEFBQADggEBALCb4IUlwtYj4g+WBpKdQZic2YR5gdkeWxQHIzZlj7DYd7usQWxH
20
+ YINRsPkyPef89iYTx4AWpb9a/IfPeHmJIZriTAcKhjW88t5RxNKWt9x+Tu5w/Rw5
21
+ 6wwCURQtjr0W4MHfRnXnJK3s9EK0hZNwEGe6nQY1ShjTK3rMUUKhemPR5ruhxSvC
22
+ Nr4TDea9Y355e6cJDUCrat2PisP29owaQgVR1EX1n6diIWgVIEM8med8vSTYqZEX
23
+ c4g/VhsxOBi0cQ+azcgOno4uG+GMmIPLHzHxREzGBHNJdmAPx/i9F4BrLunMTA5a
24
+ mnkPIAou1Z5jJh5VkpTYghdae9C8x49OhgQ=
25
+ -----END CERTIFICATE-----
lib/Tritac/ChannelEngineApiClient/Client.php ADDED
@@ -0,0 +1,262 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Tritac_ChannelEngineApiClient_Client {
4
+
5
+ private $environment;
6
+ private $tenant;
7
+ private $certificate;
8
+
9
+ private $apiUrl;
10
+ private $apiKey;
11
+ private $apiSecret;
12
+
13
+ const FIDDLER_PROXY = '127.0.0.1:8888';
14
+ const USE_FIDDLER = false;
15
+
16
+ const ENV_DEVELOPMENT = 'dev';
17
+ const ENV_ACCEPTATION = 'acc';
18
+ const ENV_PRODUCTION = 'prod';
19
+
20
+ const DEV_URL = 'http://%s-api.channelengine.local';
21
+ const ACC_URL = 'http://%s-api.channelengine-acc.nl';
22
+ const PROD_URL = 'https://%s-api.channelengine.net';
23
+
24
+ const BASE_PATH = '/v1/merchant/';
25
+ const CERTIFICATE_PATH = 'AddTrustExternalCARoot.crt';
26
+
27
+ const ORDERS_PATH = 'orders/';
28
+ const SHIPMENTS_PATH = 'shipments/';
29
+ const RETURNS_PATH = 'returns/';
30
+
31
+ /**
32
+ * Create a new instance of the Kieskeurig Api client.
33
+ * @param string $apiKey Your personal Api key
34
+ * @param string $apiSecret Your personal Api secret
35
+ * @param string $tenant Your personal ChannelEngine name. If your ChannelEngine Url is https://yourshop.channelengine.net your personal name is "yourshop"
36
+ */
37
+ public function __construct($apiKey, $apiSecret, $tenant, $environment = null)
38
+ {
39
+ if($environment == null || $environment == self::ENV_PRODUCTION){
40
+ $this->apiUrl = sprintf(self::PROD_URL, $tenant);
41
+ }elseif($environment == self::ENV_ACCEPTATION){
42
+ $this->apiUrl = sprintf(self::ACC_URL, $tenant);
43
+ }elseif($environment == self::ENV_DEVELOPMENT){
44
+ $this->apiUrl = sprintf(self::DEV_URL, $tenant);
45
+ }
46
+
47
+ $this->environment = $environment;
48
+ $this->tenant = $tenant;
49
+ $this->apiKey = $apiKey;
50
+ $this->apiSecret = $apiSecret;
51
+ $this->certificate = __DIR__ . DIRECTORY_SEPARATOR . self::CERTIFICATE_PATH;
52
+ }
53
+
54
+ /* Public API methods */
55
+
56
+ /* ORDERS */
57
+
58
+ /**
59
+ * Gets all orders with selected parameters
60
+ * @param array $statuses An array of ChannelEngineApiClient\Enums\OrderStatus or NULL for all new orders.
61
+ * @param DateTime $dateFrom Filter orders from the given date
62
+ * @param DateTime $dateTo Filter orders until the given date
63
+ * @return ChannelEngineApiClient\Helpers\MerchantOrderCollection The retrieved orders
64
+ */
65
+ public function getOrders(array $statuses = array(Tritac_ChannelEngineApiClient_Enums_OrderStatus::NEW_ORDER), DateTime $dateFrom = null, DateTime $dateTo = null)
66
+ {
67
+ $args = array();
68
+ $args['OrderStatus'] = $statuses;
69
+ $args = $this->addDateArgs($dateFrom, $dateTo, $args);
70
+
71
+ $url = self::BASE_PATH . self::ORDERS_PATH;
72
+ $result = $this->makeRequest(Tritac_ChannelEngineApiClient_Helpers_HttpMethod::GET, $url, $this->createQueryString($args));
73
+ return Tritac_ChannelEngineApiClient_Helpers_JsonMapper::fromJson($result, 'Tritac_ChannelEngineApiClient_Helpers_Collection(Tritac_ChannelEngineApiClient_Models_Order)');
74
+ }
75
+
76
+ /* SHIPMENTS */
77
+
78
+ /**
79
+ * Create a new shipment for the given order with the given lines
80
+ * @param ChannelEngineApiClient\Models\Shipment $shipment The shipment to send
81
+ */
82
+ public function postShipment(Tritac_ChannelEngineApiClient_Models_Shipment $shipment)
83
+ {
84
+ $url = self::BASE_PATH . self::SHIPMENTS_PATH;
85
+ $result = $this->makeRequest(Tritac_ChannelEngineApiClient_Helpers_HttpMethod::POST, $url, '', Tritac_ChannelEngineApiClient_Helpers_JsonMapper::toJson($shipment));
86
+ return Tritac_ChannelEngineApiClient_Helpers_JsonMapper::fromJson($result, 'Tritac_ChannelEngineApiClient_Models_Shipment');
87
+ }
88
+
89
+ /* RETURNS */
90
+
91
+ /**
92
+ * Gets all orders with selected parameters
93
+ * @param array $statuses An array of ChannelEngineApiClient\Enums\ReturnStatus or NULL for all declared returns
94
+ * @param DateTime $dateFrom Filter returns from the given date
95
+ * @param DateTime $dateTo Filter returns until the given date
96
+ * @return ChannelEngineApiClient\Helpers\ReturnCollection The retrieved returns
97
+ */
98
+ public function getReturns(array $statuses = array(Tritac_ChannelEngineApiClient_Enums_ReturnStatus::DECLARED), DateTime $dateFrom = null, DateTime $dateTo = null)
99
+ {
100
+ $args = array();
101
+ $args['Status'] = $statuses;
102
+ $args = $this->addDateArgs($dateFrom, $dateTo, $args);
103
+
104
+ $url = self::BASE_PATH . self::RETURNS_PATH;
105
+ $result = $this->makeRequest(Tritac_ChannelEngineApiClient_Helpers_HttpMethod::GET, $url, $this->createQueryString($args));
106
+ return Tritac_ChannelEngineApiClient_Helpers_JsonMapper::fromJson($result, 'Tritac_ChannelEngineApiClient_Helpers_Collection(Tritac_ChannelEngineApiClient_Models_ReturnObject)');
107
+ }
108
+
109
+ /**
110
+ * Create a new return for the given shipment with the given lines
111
+ * @param ChannelEngineApiClient\Models\ReturnObject $return The shipment to send
112
+ */
113
+ public function postReturn(Tritac_ChannelEngineApiClient_Models_ReturnObject $return)
114
+ {
115
+ $url = self::BASE_PATH . self::RETURNS_PATH;
116
+ $result = $this->makeRequest(Tritac_ChannelEngineApiClient_Helpers_HttpMethod::POST, $url, '', Tritac_ChannelEngineApiClient_Helpers_JsonMapper::toJson($return));
117
+ return Tritac_ChannelEngineApiClient_Helpers_JsonMapper::fromJson($result, 'Tritac_ChannelEngineApiClient_Models_ReturnObject');
118
+ }
119
+
120
+ /**
121
+ * Updates the status of the given return
122
+ * @param ChannelEngineApiClient\Models\ReturnObject $return The return to update
123
+ */
124
+ public function putReturn(Tritac_ChannelEngineApiClient_Models_ReturnObject $return)
125
+ {
126
+ $url = self::BASE_PATH . self::RETURNS_PATH;
127
+ $result = $this->makeRequest(Tritac_ChannelEngineApiClient_Helpers_HttpMethod::PUT, $url, '', Tritac_ChannelEngineApiClient_Helpers_JsonMapper::toJson($return));
128
+ return Tritac_ChannelEngineApiClient_Helpers_JsonMapper::fromJson($result, 'Tritac_ChannelEngineApiClient_Models_ReturnObject');
129
+ }
130
+
131
+ /* Private methods */
132
+
133
+ private function makeRequest($method, $url, $queryString = '', $content = null)
134
+ {
135
+ $request = curl_init();
136
+
137
+ // Create the required Http headers and Hmac signature
138
+ $headers = $this->buildHeaders($method, $url, $content);
139
+
140
+ if($this->environment == self::ENV_DEVELOPMENT && self::USE_FIDDLER)
141
+ {
142
+ // We use this to redirect the request through a local proxy and trace it with fiddler
143
+ curl_setopt($request, CURLOPT_PROXY, self::FIDDLER_PROXY);
144
+ }
145
+
146
+ // Set the Url
147
+ curl_setopt($request, CURLOPT_URL, $this->apiUrl . $url . $queryString);
148
+
149
+ // Add the headers and hmac auth.
150
+ curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
151
+
152
+ // Return the response as a string
153
+ curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
154
+
155
+ // Set custom request method because curl has no setting for PUT and DELETE
156
+ curl_setopt($request, CURLOPT_CUSTOMREQUEST, $method);
157
+
158
+ // Make the headers accessible for debugging purposes
159
+ curl_setopt($request, CURLINFO_HEADER_OUT, true);
160
+
161
+ // Point curl to the correct certificate.
162
+ // See: http://stackoverflow.com/questions/6400300/php-curl-https-causing-exception-ssl-certificate-problem-verify-that-the-ca-cer
163
+ curl_setopt($request, CURLOPT_SSL_VERIFYPEER, true);
164
+ curl_setopt($request, CURLOPT_CAINFO, $this->certificate);
165
+
166
+ // If we have a request body send it too
167
+ if(strlen($content) > 0)
168
+ curl_setopt($request, CURLOPT_POSTFIELDS, $content);
169
+
170
+ // Make the request
171
+ $response = curl_exec($request);
172
+
173
+ // Get the status code
174
+ $status = curl_getinfo($request, CURLINFO_HTTP_CODE);
175
+
176
+ // Check for errors
177
+ // First we check if the response is missing which will probably be caused by a cURL error
178
+ // After this the check if there are not HTTP errors (status codes other than 200-206)
179
+ if ($response === false)
180
+ {
181
+ $error = curl_error($request);
182
+ curl_close($request);
183
+ throw new Exception('cURL error: ' . $error);
184
+ }
185
+ else if($status < 200 || $status > 206)
186
+ {
187
+ $headers = curl_getinfo($request, CURLINFO_HEADER_OUT);
188
+ $message = Tritac_ChannelEngineApiClient_Helpers_JsonMapper::fromJson($response, 'Tritac_ChannelEngineApiClient_Models_Message');
189
+ curl_close($request);
190
+
191
+ throw new Exception('Output headers: '. "\n" . $headers ."\n\n".
192
+ 'Content: ' . $content ."\n\n".
193
+ 'Unexpected status code [' . $status . ']. The server returned the following message: "' . $message->getMessage() . '"');
194
+ }
195
+ else
196
+ {
197
+ curl_close($request);
198
+
199
+ return $response;
200
+ }
201
+ }
202
+
203
+ private function buildHeaders($method, $url, $content = null)
204
+ {
205
+ $date = time();
206
+ $headers = array(
207
+ 'Accept: application/json',
208
+ 'Authorization: HMAC ' . $this->apiKey . ':' . $this->calculateHmac($method, $url, $date, $content),
209
+ 'Content-Type: application/json; charset=utf-8',
210
+ 'Content-Length: ' . strlen($content),
211
+ 'Content-MD5: ' . ((strlen($content) > 0) ? base64_encode(md5($content, true)) : ''),
212
+ 'Date: ' . gmdate('D, d M Y H:i:s', $date) . ' GMT',
213
+ );
214
+
215
+ return $headers;
216
+ }
217
+
218
+ /*
219
+ Builds message representation as follows:
220
+
221
+ Timestamp\n +
222
+ HTTP METHOD\n +
223
+ Request URI
224
+ Content-MD5 (base64)\n +
225
+ apikey\n +
226
+
227
+ */
228
+ private function calculateHmac($method, $url, $date, $content = null)
229
+ {
230
+ $representation = array(
231
+ gmdate('m/d/Y H:i:s', $date),
232
+ $method,
233
+ $url,
234
+ (strlen($content) > 0) ? base64_encode(md5($content, true)) : '',
235
+ $this->apiKey
236
+ );
237
+
238
+
239
+ $representationString = implode("\n", $representation);
240
+
241
+ $hash = hash_hmac('sha256', utf8_encode($representationString), utf8_encode($this->apiSecret), true);
242
+ $signature = base64_encode($hash);
243
+
244
+ return $signature;
245
+ }
246
+
247
+ private function createQueryString(array $args)
248
+ {
249
+ $queryString = (count($args) > 0) ? '?' . http_build_query($args) : '';
250
+
251
+ // .Net does not seem to like the /?foo[0]=bar&foo[1]=baz notation so we
252
+ // convert it to /?foo=bar&foo=baz
253
+ return preg_replace('/%5B(?:[0-9]|[1-9][0-9]+)%5D=/', '=', $queryString);
254
+ }
255
+
256
+ private function addDateArgs(DateTime $dateFrom = null, DateTime $dateTo = null, array $args)
257
+ {
258
+ if(!is_null($dateFrom)) $args['FromDate'] = $dateFrom->format('Y-m-d H:i:s');
259
+ if(!is_null($dateTo)) $args['ToDate'] = $dateTo->format('Y-m-d H:i:s');
260
+ return $args;
261
+ }
262
+ }
lib/Tritac/ChannelEngineApiClient/Enums/CancellationLineStatus.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tritac_ChannelEngineApiClient_Enums_CancellationLineStatus {
3
+
4
+ const PENDING = 0;
5
+ const ACCEPTED = 1;
6
+ const REJECTED = 2;
7
+
8
+ }
lib/Tritac/ChannelEngineApiClient/Enums/CancellationStatus.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tritac_ChannelEngineApiClient_Enums_CancellationStatus {
3
+
4
+ const PENDING = 0;
5
+ const CLOSED = 2; // refunded or maybe not
6
+ const REFUND_STARTED = 3;
7
+ const REFUND_FAILED = 4;
8
+
9
+ }
lib/Tritac/ChannelEngineApiClient/Enums/Gender.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tritac_ChannelEngineApiClient_Enums_Gender {
3
+
4
+ const MALE = 1;
5
+ const FEMALE = 2;
6
+ const NOT_APPLICABLE = 3;
7
+
8
+ }
lib/Tritac/ChannelEngineApiClient/Enums/MancoReason.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tritac_ChannelEngineApiClient_Enums_MancoReason {
3
+ const NOT_IN_STOCK = 0;
4
+ const DAMAGED = 1;
5
+ const INCOMPLETE = 2;
6
+ const CLIENT_CANCELLED = 3;
7
+ const OTHER = 99;
8
+ }
lib/Tritac/ChannelEngineApiClient/Enums/OrderStatus.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tritac_ChannelEngineApiClient_Enums_OrderStatus {
3
+
4
+ const IN_PROGRESS = 0;
5
+ const SHIPPED = 1;
6
+ const IN_BACKORDER = 2;
7
+ const CANCELED = 3;
8
+ const MANCO = 4;
9
+ const IN_COMBI = 5; // combi: one or more not closed
10
+ const CLOSED = 6; // combi:closed
11
+ const NEW_ORDER = 7; // renamed NEW to NEW_ORDER because new is a protected keyword in php
12
+
13
+ }
lib/Tritac/ChannelEngineApiClient/Enums/ReturnAcceptStatus.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ class Tritac_ChannelEngineApiClient_Enums_ReturnAcceptStatus {
3
+ const PENDING = 0;
4
+ const ACCEPTED = 1;
5
+ const REJECTED = 2; // refunded
6
+ }
lib/Tritac/ChannelEngineApiClient/Enums/ReturnReason.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tritac_ChannelEngineApiClient_Enums_ReturnReason {
3
+ const PRODUCT_DEFECT = 0;
4
+ const PRODUCT_UNSATISFACTORY = 1;
5
+ const REFUSED = 4;
6
+ const REFUSED_DAMAGED = 5;
7
+ const WRONG_ADDRESS = 6;
8
+ const NOT_COLLECTED = 7;
9
+ const OTHER = 99;
10
+ }
lib/Tritac/ChannelEngineApiClient/Enums/ReturnStatus.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ class Tritac_ChannelEngineApiClient_Enums_ReturnStatus {
3
+ const DECLARED = 0;
4
+ const RECEIVED = 1;
5
+ const CLOSED = 2;
6
+ }
lib/Tritac/ChannelEngineApiClient/Enums/ShipmentLineStatus.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tritac_ChannelEngineApiClient_Enums_ShipmentLineStatus {
3
+
4
+ const SHIPPED = 1;
5
+ const IN_BACKORDER = 2;
6
+ const MANCO = 4;
7
+
8
+ }
lib/Tritac/ChannelEngineApiClient/Enums/ShipmentStatus.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class Tritac_ChannelEngineApiClient_Enums_ShipmentStatus {
3
+ const PENDING = 0;
4
+ const CLOSED = 2;
5
+ }
lib/Tritac/ChannelEngineApiClient/Helpers/Collection.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tritac_ChannelEngineApiClient_Helpers_Collection extends ArrayObject{
3
+
4
+ private $type;
5
+ private $test;
6
+
7
+
8
+
9
+ public function __construct($type = 'stdObject')
10
+ {
11
+ $matches = array();
12
+ if(preg_match('/Collection\(([\\\\\w]+)\)$/', $type, $matches))
13
+ {
14
+ $this->type = $matches[1];
15
+ }
16
+ else
17
+ {
18
+ $this->type = $type;
19
+ }
20
+
21
+ $this->test = new $this->type();
22
+ }
23
+
24
+ public function append($item)
25
+ {
26
+ $this->checkType($item);
27
+ parent::append($item);
28
+ }
29
+
30
+ public function offsetSet($idx, $item)
31
+ {
32
+ $this->checkType($item);
33
+ parent::offsetSet($idx, $item);
34
+ }
35
+
36
+ private function checkType($item)
37
+ {
38
+ if(!($item instanceof $this->test))
39
+ {
40
+ throw new Exception('Invalid type inserted in list with type ' . $this->type);
41
+ }
42
+ }
43
+
44
+ public function getTypeName()
45
+ {
46
+ return $this->type;
47
+ }
48
+
49
+ }
lib/Tritac/ChannelEngineApiClient/Helpers/HttpMethod.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tritac_ChannelEngineApiClient_Helpers_HttpMethod {
3
+
4
+ const GET = 'GET';
5
+ const POST = 'POST';
6
+ const PUT = 'PUT';
7
+ const DELETE = 'DELETE';
8
+
9
+ }
lib/Tritac/ChannelEngineApiClient/Helpers/JsonMapper.php ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tritac_ChannelEngineApiClient_Helpers_JsonMapper {
3
+
4
+ public static function fromJson($jsonString, $rootType)
5
+ {
6
+ $jsonRoot = json_decode($jsonString);
7
+ return self::convertToObject($jsonRoot, $rootType);
8
+ }
9
+
10
+ private static function convertToObject($jsonObject, $jsonType)
11
+ {
12
+ $rootObject = null;
13
+ if(preg_match('/Collection\(([\\\\\w]+)\)$/', $jsonType))
14
+ {
15
+ $rootObject = new Tritac_ChannelEngineApiClient_Helpers_Collection($jsonType);
16
+ if(is_array($jsonObject))
17
+ {
18
+ foreach ($jsonObject as $jsonChildObject)
19
+ {
20
+ $rootObject[] = self::convertToObject($jsonChildObject, $rootObject->getTypeName());
21
+ }
22
+ }
23
+ }
24
+ else
25
+ {
26
+ $rootObject = new $jsonType();
27
+ if($jsonObject != null){
28
+ foreach (get_object_vars($jsonObject) as $key => $value)
29
+ {
30
+ if(array_key_exists(lcfirst($key), $rootObject::$typeMap))
31
+ {
32
+ $value = self::convertToObject($value, $rootObject::$typeMap[lcfirst($key)]);
33
+ }
34
+ $action = 'set' . $key;
35
+ if(method_exists($rootObject, $action))
36
+ {
37
+ $rootObject->{$action}($value);
38
+ }
39
+ }
40
+ }
41
+ }
42
+ return $rootObject;
43
+ }
44
+
45
+ private static function isIterable($var)
46
+ {
47
+ return ($var !== null && (is_array($var) || $var instanceof Iterator || $var instanceof IteratorAggregate));
48
+ }
49
+
50
+ public static function toJson($object)
51
+ {
52
+ return json_encode(self::convertFromObject($object));
53
+ }
54
+
55
+ public static function convertFromObject($root, $d = 0, $mustexist = false)
56
+ {
57
+ if($root instanceof Tritac_ChannelEngineApiClient_Helpers_Collection)
58
+ {
59
+ $root = $root->getArrayCopy();
60
+ foreach($root as $key => $value)
61
+ {
62
+ if($value instanceof Tritac_ChannelEngineApiClient_Models_BaseModel || $value instanceof Tritac_ChannelEngineApiClient_Helpers_Collection)
63
+ $root[ucfirst($key)] = self::convertFromObject($value, $d+1, true);
64
+ }
65
+ return $root;
66
+ }
67
+ elseif($root instanceof Tritac_ChannelEngineApiClient_Models_BaseModel)
68
+ {
69
+ $newRoot = new stdClass();
70
+ foreach($root->getProperties() as $key => $value)
71
+ {
72
+ if($value instanceof Tritac_ChannelEngineApiClient_Models_BaseModel || $value instanceof Tritac_ChannelEngineApiClient_Helpers_Collection)
73
+ {
74
+ $newRoot->{ucfirst($key)} = self::convertFromObject($value, $d+1, true);
75
+ }
76
+ else
77
+ {
78
+ $newRoot->{ucfirst($key)} = $value;
79
+ }
80
+
81
+ }
82
+ return $newRoot;
83
+ }
84
+ elseif($mustexist)
85
+ {
86
+ throw new Exception('No or invalid object given to the function.');
87
+ }
88
+
89
+ return new stdClass();
90
+ }
91
+ }
lib/Tritac/ChannelEngineApiClient/Models/Address.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tritac_ChannelEngineApiClient_Models_Address extends Tritac_ChannelEngineApiClient_Models_BaseModel {
3
+
4
+ public static $typeMap = array(
5
+
6
+ );
7
+
8
+ // For non-vital fields, no string length errors, but they are silently truncated.
9
+ // salutation, companyName, firstName, lastName, streetName, city: 50 characters
10
+
11
+ protected $gender; // https://en.wikipedia.org/wiki/ISO/IEC_5218
12
+ protected $salutation;
13
+ protected $companyName;
14
+ protected $firstName;
15
+ protected $lastName;
16
+ protected $streetName;
17
+ protected $houseNr;
18
+ protected $houseNrAddition;
19
+ protected $zipCode;
20
+ protected $city;
21
+ protected $countryIso;
22
+
23
+ public function __construct()
24
+ {
25
+ self::$typeMap = array_merge(parent::$typeMap, self::$typeMap);
26
+
27
+ $this->gender = Tritac_ChannelEngineApiClient_Enums_Gender::NOT_APPLICABLE;
28
+ $this->salutation = '';
29
+ $this->companyName = '';
30
+ $this->firstName = '';
31
+ $this->lastName = '';
32
+ $this->streetName = '';
33
+ $this->houseNr = '';
34
+ $this->houseNrAddition = '';
35
+ $this->zipCode = '';
36
+ $this->city = '';
37
+ $this->countryIso = '';
38
+ }
39
+
40
+ function setGender($gender) { $this->gender = $gender; }
41
+ function getGender() { return $this->gender; }
42
+
43
+ function setSalutation($salutation) { $this->salutation = $salutation; }
44
+ function getSalutation() { return $this->salutation; }
45
+
46
+ function setCompanyName($companyName) { $this->companyName = $companyName; }
47
+ function getCompanyName() { return $this->companyName; }
48
+
49
+ function setFirstName($firstName) { $this->firstName = $firstName; }
50
+ function getFirstName() { return $this->firstName; }
51
+
52
+ function setLastName($lastName) { $this->lastName = $lastName; }
53
+ function getLastName() { return $this->lastName; }
54
+
55
+ function setStreetName($streetName) { $this->streetName = $streetName; }
56
+ function getStreetName() { return $this->streetName; }
57
+
58
+ function setHouseNr($houseNr) {
59
+
60
+ if(strlen($houseNr) > 50) {
61
+ throw new Exception('HouseNr may not exceed 50 characters');
62
+ }
63
+
64
+ $this->houseNr = $houseNr;
65
+ }
66
+ function getHouseNr() { return $this->houseNr; }
67
+
68
+ function setHouseNrAddition($houseNrAddition) {
69
+
70
+ if(strlen($houseNrAddition) > 50) {
71
+ throw new Exception('HouseNrAddition may not exceed 50 characters');
72
+ }
73
+
74
+ $this->houseNrAddition = $houseNrAddition;
75
+
76
+ }
77
+ function getHouseNrAddition() { return $this->houseNrAddition; }
78
+
79
+ function setZipCode($zipCode) { $this->zipCode = $zipCode; }
80
+ function getZipCode() { return $this->zipCode; }
81
+
82
+ function setCity($city) { $this->city = $city; }
83
+ function getCity() { return $this->city; }
84
+
85
+ function setCountryIso($countryIso) {
86
+
87
+ if(strlen($countryIso) > 2) {
88
+ throw new Exception('CountryIso may not exceed 2 characters');
89
+ }
90
+
91
+ $this->countryIso = $countryIso;
92
+
93
+ }
94
+ function getCountryIso() { return $this->countryIso; }
95
+
96
+ }
97
+ ?>
lib/Tritac/ChannelEngineApiClient/Models/BaseModel.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ abstract class Tritac_ChannelEngineApiClient_Models_BaseModel {
3
+
4
+ protected $id;
5
+
6
+ public static $typeMap = array(
7
+
8
+ );
9
+
10
+ public function getTypeName()
11
+ {
12
+ return get_called_class();
13
+ }
14
+
15
+ public function getProperties()
16
+ {
17
+ return get_object_vars($this);
18
+ }
19
+
20
+ function setId($id) { $this->id = $id; }
21
+ function getId() { return $this->id; }
22
+
23
+ }
lib/Tritac/ChannelEngineApiClient/Models/Cancellation.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tritac_ChannelEngineApiClient_Models_Cancellation extends Tritac_ChannelEngineApiClient_Models_BaseModel {
3
+
4
+ public static $typeMap = array(
5
+ 'lines' => 'Tritac_ChannelEngineApiClient_Helpers_Collection(Tritac_ChannelEngineApiClient_Models_CancellationLine)',
6
+ );
7
+
8
+ protected $orderId;
9
+ protected $checkoutOrderNo;
10
+ protected $lines;
11
+ protected $cancellationStatus;
12
+ protected $refundInclVat;
13
+ protected $refundExclVat;
14
+
15
+ public function __construct()
16
+ {
17
+ self::$typeMap = array_merge(parent::$typeMap, self::$typeMap);
18
+
19
+ $this->lines = new Tritac_ChannelEngineApiClient_Helpers_Collection('Tritac_ChannelEngineApiClient_Models_CancellationLine');
20
+ }
21
+
22
+ function setOrderId($orderId) { $this->orderId = $orderId; }
23
+ function getOrderId() { return $this->orderId; }
24
+
25
+ function setChannelOrderNo($checkoutOrderNo) { $this->checkoutOrderNo = $checkoutOrderNo; }
26
+ function getChannelOrderNo() { return $this->checkoutOrderNo; }
27
+
28
+ function setLines($lines) { $this->lines = $lines; }
29
+ function getLines() { return $this->lines; }
30
+
31
+ function setCancellationStatus($cancellationStatus) { $this->cancellationStatus = $cancellationStatus; }
32
+ function getCancellationStatus() { return $this->cancellationStatus; }
33
+
34
+ function setRefundInclVat($refundInclVat) { $this->refundInclVat = $refundInclVat; }
35
+ function getRefundInclVat() { return $this->refundInclVat; }
36
+
37
+ function setRefundExclVat($refundExclVat) { $this->refundExclVat = $refundExclVat; }
38
+ function getRefundExclVat() { return $this->refundExclVat; }
39
+ }
lib/Tritac/ChannelEngineApiClient/Models/CancellationLine.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tritac_ChannelEngineApiClient_Models_CancellationLine extends Tritac_ChannelEngineApiClient_Models_BaseModel {
3
+
4
+ public static $typeMap = array(
5
+
6
+ );
7
+
8
+ protected $cancellationId;
9
+ protected $orderLineId;
10
+ protected $quantity;
11
+ protected $status;
12
+ protected $refundInclVat;
13
+ protected $refundExclVat;
14
+
15
+ function setCancellationId($cancellationId) { $this->cancellationId = $cancellationId; }
16
+ function getCancellationId() { return $this->cancellationId; }
17
+
18
+ function setOrderLineId($orderLineId) { $this->orderLineId = $orderLineId; }
19
+ function getOrderLineId() { return $this->orderLineId; }
20
+
21
+ function setQuantity($quantity) { $this->quantity = $quantity; }
22
+ function getQuantity() { return $this->quantity; }
23
+
24
+ function setStatus($status) { $this->status = $status; }
25
+ function getStatus() { return $this->status; }
26
+
27
+ function setRefundInclVat($refundInclVat) { $this->refundInclVat = $refundInclVat; }
28
+ function getRefundInclVat() { return $this->refundInclVat; }
29
+
30
+ function setRefundExclVat($refundExclVat) { $this->refundExclVat = $refundExclVat; }
31
+ function getRefundExclVat() { return $this->refundExclVat; }
32
+
33
+ }
lib/Tritac/ChannelEngineApiClient/Models/Message.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tritac_ChannelEngineApiClient_Models_Message extends Tritac_ChannelEngineApiClient_Models_BaseModel {
3
+
4
+ public static $typeMap = array(
5
+
6
+ );
7
+
8
+ protected $message;
9
+
10
+ function setMessage($message) { $this->message = $message; }
11
+ function getMessage() { return $this->message; }
12
+ }
lib/Tritac/ChannelEngineApiClient/Models/Order.php ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tritac_ChannelEngineApiClient_Models_Order extends Tritac_ChannelEngineApiClient_Models_BaseModel {
3
+
4
+ public static $typeMap = array(
5
+ 'billingAddress' => 'Tritac_ChannelEngineApiClient_Models_Address',
6
+ 'cancellations' => 'Tritac_ChannelEngineApiClient_Helpers_Collection(Tritac_ChannelEngineApiClient_Models_Cancellation)',
7
+ 'extraData' => 'Tritac_ChannelEngineApiClient_Helpers_Collection(Tritac_ChannelEngineApiClient_Models_OrderExtraDataItem)',
8
+ 'shippingAddress' => 'Tritac_ChannelEngineApiClient_Models_Address',
9
+ 'lines' => 'Tritac_ChannelEngineApiClient_Helpers_Collection(Tritac_ChannelEngineApiClient_Models_OrderLine)',
10
+ 'shipments' => 'Tritac_ChannelEngineApiClient_Helpers_Collection(Tritac_ChannelEngineApiClient_Models_Shipment)',
11
+ );
12
+
13
+ protected $phone;
14
+ protected $email;
15
+ protected $cocNo;
16
+ protected $vatNo;
17
+ protected $paymentMethod;
18
+ protected $orderDate;
19
+ protected $createdDate;
20
+ protected $updatedDate;
21
+ protected $checkoutId;
22
+ protected $checkoutOrderNo;
23
+ protected $checkoutCustomerNo;
24
+ protected $billingAddress;
25
+ protected $cancellations;
26
+ protected $channelName;
27
+ protected $doSendMails;
28
+ protected $canShipPartialOrderLines;
29
+
30
+ protected $merchantId;
31
+ protected $checkoutMerchantNo;
32
+ protected $shippingCostsInclVat;
33
+ protected $shippingCostsVat;
34
+ protected $subTotalInclVat;
35
+ protected $subTotalVat;
36
+ protected $totalInclVat;
37
+ protected $totalVat;
38
+ protected $refundInclVat;
39
+ protected $refundExclVat;
40
+ protected $extraData;
41
+ protected $shippingAddress;
42
+ protected $status;
43
+ protected $closedDate;
44
+ protected $lines;
45
+ protected $shipments;
46
+ protected $maxVatRate;
47
+
48
+ public function __construct()
49
+ {
50
+ self::$typeMap = array_merge(parent::$typeMap, self::$typeMap);
51
+
52
+ $this->lines = new Tritac_ChannelEngineApiClient_Helpers_Collection('Tritac_ChannelEngineApiClient_Models_OrderLine');
53
+ }
54
+
55
+ function setPhone($phone) { $this->phone = $phone; }
56
+ function getPhone() { return $this->phone; }
57
+
58
+ function setEmail($email) { $this->email = $email; }
59
+ function getEmail() { return $this->email; }
60
+
61
+ function setCocNo($cocNo) { $this->cocNo = $cocNo; }
62
+ function getCocNo() { return $this->cocNo; }
63
+
64
+ function setVatNo($vatNo) { $this->vatNo = $vatNo; }
65
+ function getVatNo() { return $this->vatNo; }
66
+
67
+ function setPaymentMethod($paymentMethod) { $this->paymentMethod = $paymentMethod; }
68
+ function getPaymentMethod() { return $this->paymentMethod; }
69
+
70
+ function setOrderDate($orderDate) { $this->orderDate = $orderDate; }
71
+ function getOrderDate() { return $this->orderDate; }
72
+
73
+ function setCreatedDate( $createdDate) { $this->createdDate = $createdDate; }
74
+ function getCreatedDate() { return $this->createdDate; }
75
+
76
+ function setUpdatedDate( $updatedDate) { $this->updatedDate = $updatedDate; }
77
+ function getUpdatedDate() { return $this->updatedDate; }
78
+
79
+ function setChannelId($checkoutId) { $this->checkoutId = $checkoutId; }
80
+ function getChannelId() { return $this->checkoutId; }
81
+
82
+ function setChannelOrderNo($checkoutOrderNo) { $this->checkoutOrderNo = $checkoutOrderNo; }
83
+ function getChannelOrderNo() { return $this->checkoutOrderNo; }
84
+
85
+ function setChannelCustomerNo($checkoutCustomerNo) { $this->checkoutCustomerNo = $checkoutCustomerNo; }
86
+ function getChannelCustomerNo() { return $this->checkoutCustomerNo; }
87
+
88
+ function setBillingAddress(Tritac_ChannelEngineApiClient_Models_Address $billingAddress) { $this->billingAddress = $billingAddress; }
89
+ function getBillingAddress() { return $this->billingAddress; }
90
+
91
+ function setCancellations($cancellations) { $this->cancellations = $cancellations; }
92
+ function getCancellations() { return $this->cancellations; }
93
+
94
+ function setChannelName($channelName) { $this->channelName = $channelName; }
95
+ function getChannelName() { return $this->channelName; }
96
+
97
+ function setDoSendMails($doSendMails) { $this->doSendMails = $doSendMails; }
98
+ function getDoSendMails() { return $this->doSendMails; }
99
+
100
+ function setCanShipPartialOrderLines($canShipPartialOrderLines) { $this->canShipPartialOrderLines = $canShipPartialOrderLines; }
101
+ function getCanShipPartialOrderLines() { return $this->canShipPartialOrderLines; }
102
+
103
+ function setMerchantId($merchantId) { $this->merchantId = $merchantId; }
104
+ function getMerchantId() { return $this->merchantId; }
105
+
106
+ function setChannelMerchantNo($checkoutMerchantNo) { $this->checkoutMerchantNo = $checkoutMerchantNo; }
107
+ function getChannelMerchantNo() { return $this->checkoutMerchantNo; }
108
+
109
+ function setShippingCostsInclVat($shippingCostsInclVat) { $this->shippingCostsInclVat = $shippingCostsInclVat; }
110
+ function getShippingCostsInclVat() { return $this->shippingCostsInclVat; }
111
+
112
+ function setShippingCostsVat($shippingCostsVat) { $this->shippingCostsVat = $shippingCostsVat; }
113
+ function getShippingCostsVat() { return $this->shippingCostsVat; }
114
+
115
+ function setSubTotalInclVat($subTotalInclVat) { $this->subTotalInclVat = $subTotalInclVat; }
116
+ function getSubTotalInclVat() { return $this->subTotalInclVat; }
117
+
118
+ function setSubTotalVat($subTotalVat) { $this->subTotalVat = $subTotalVat; }
119
+ function getSubTotalVat() { return $this->subTotalVat; }
120
+
121
+ function setTotalInclVat($totalInclVat) { $this->totalInclVat = $totalInclVat; }
122
+ function getTotalInclVat() { return $this->totalInclVat; }
123
+
124
+ function setTotalVat($totalVat) { $this->totalVat = $totalVat; }
125
+ function getTotalVat() { return $this->totalVat; }
126
+
127
+ function setRefundInclVat($refundInclVat) { $this->refundInclVat = $refundInclVat; }
128
+ function getRefundInclVat() { return $this->refundInclVat; }
129
+
130
+ function setRefundExclVat($refundExclVat) { $this->refundExclVat = $refundExclVat; }
131
+ function getRefundExclVat() { return $this->refundExclVat; }
132
+
133
+ function setExtraData($extraData) { $this->extraData = $extraData; }
134
+ function getExtraData() { return $this->extraData; }
135
+
136
+ function setShippingAddress($shippingAddress) { $this->shippingAddress = $shippingAddress; }
137
+ function getShippingAddress() { return $this->shippingAddress; }
138
+
139
+ function setStatus($status) { $this->status = $status; }
140
+ function getStatus() { return $this->status; }
141
+
142
+ function setClosedDate( $closedDate) { $this->closedDate = $closedDate; }
143
+ function getClosedDate() { return $this->closedDate; }
144
+
145
+ function setLines($lines) { $this->lines = $lines; }
146
+ function getLines() { return $this->lines; }
147
+
148
+ function setShipments($shipments) { $this->shipments = $shipments; }
149
+ function getShipments() { return $this->shipments; }
150
+
151
+ function setMaxVatRate($maxVatRate) { $this->maxVatRate = $maxVatRate; }
152
+ function getMaxVatRate() { return $this->maxVatRate; }
153
+
154
+ }
lib/Tritac/ChannelEngineApiClient/Models/OrderExtraDataItem.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Tritac_ChannelEngineApiClient_Models_OrderExtraDataItem extends Tritac_ChannelEngineApiClient_Models_BaseModel{
4
+
5
+ public static $typeMap = array(
6
+
7
+ );
8
+
9
+ protected $key;
10
+ protected $value;
11
+
12
+
13
+ function setKey($key) { $this->key = $key; }
14
+ function getKey() { return $this->key; }
15
+
16
+ function setValue($value) { $this->value = $value; }
17
+ function getValue() { return $this->value; }
18
+
19
+ }
lib/Tritac/ChannelEngineApiClient/Models/OrderLine.php ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Tritac_ChannelEngineApiClient_Models_OrderLine extends Tritac_ChannelEngineApiClient_Models_BaseModel {
4
+
5
+ public static $typeMap = array(
6
+ );
7
+
8
+ protected $checkoutProductNo;
9
+ protected $merchantProductNo;
10
+ protected $productEan;
11
+ protected $productName;
12
+ protected $productBrand;
13
+ protected $productVariantColor;
14
+ protected $productVariantSize;
15
+ protected $quantity;
16
+ protected $unitPriceInclVat;
17
+ protected $lineTotalInclVat;
18
+ protected $vatRate;
19
+ protected $unitVat;
20
+ protected $lineVat;
21
+ protected $feeFixed;
22
+ protected $feeRate;
23
+ protected $deliveryTimeIndication;
24
+ protected $expectedDeliveryDate;
25
+ protected $status;
26
+ protected $closedDate;
27
+ protected $closedQuantity;
28
+ protected $cancelledQuantity;
29
+ protected $shippedQuantity;
30
+ protected $mancoQuantity;
31
+
32
+ public function __construct()
33
+ {
34
+ self::$typeMap = array_merge(parent::$typeMap, self::$typeMap);
35
+ }
36
+
37
+ function setChannelProductNo($checkoutProductNo) { $this->checkoutProductNo = $checkoutProductNo; }
38
+ function getChannelProductNo() { return $this->checkoutProductNo; }
39
+
40
+ function setMerchantProductNo($merchantProductNo) { $this->merchantProductNo = $merchantProductNo; }
41
+ function getMerchantProductNo() { return $this->merchantProductNo; }
42
+
43
+ function setProductEan($productEan) { $this->productEan = $productEan; }
44
+ function getProductEan() { return $this->productEan; }
45
+
46
+ function setProductName($productName) { $this->productName = $productName; }
47
+ function getProductName() { return $this->productName; }
48
+
49
+ function setProductBrand($productBrand) { $this->productBrand = $productBrand; }
50
+ function getProductBrand() { return $this->productBrand; }
51
+
52
+ function setProductVariantColor($productVariantColor) { $this->productVariantColor = $productVariantColor; }
53
+ function getProductVariantColor() { return $this->productVariantColor; }
54
+
55
+ function setProductVariantSize($productVariantSize) { $this->productVariantSize = $productVariantSize; }
56
+ function getProductVariantSize() { return $this->productVariantSize; }
57
+
58
+ function setQuantity($quantity) { $this->quantity = $quantity; }
59
+ function getQuantity() { return $this->quantity; }
60
+
61
+ function setUnitPriceInclVat($unitPriceInclVat) { $this->unitPriceInclVat = $unitPriceInclVat; }
62
+ function getUnitPriceInclVat() { return $this->unitPriceInclVat; }
63
+
64
+ function setLineTotalInclVat($lineTotalInclVat) { $this->lineTotalInclVat = $lineTotalInclVat; }
65
+ function getLineTotalInclVat() { return $this->lineTotalInclVat; }
66
+
67
+ function setVatRate($vatRate) { $this->vatRate = $vatRate; }
68
+ function getVatRate() { return $this->vatRate; }
69
+
70
+ function setUnitVat($unitVat) { $this->unitVat = $unitVat; }
71
+ function getUnitVat() { return $this->unitVat; }
72
+
73
+ function setLineVat($lineVat) { $this->lineVat = $lineVat; }
74
+ function getLineVat() { return $this->lineVat; }
75
+
76
+ function setFeeFixed($feeFixed) { $this->feeFixed = $feeFixed; }
77
+ function getFeeFixed() { return $this->feeFixed; }
78
+
79
+ function setFeeRate($feeRate) { $this->feeRate = $feeRate; }
80
+ function getFeeRate() { return $this->feeRate; }
81
+
82
+ function setExpectedDeliveryDate( $expectedDeliveryDate) { $this->expectedDeliveryDate = $expectedDeliveryDate; }
83
+ function getExpectedDeliveryDate() { return $this->expectedDeliveryDate; }
84
+
85
+ function setDeliveryTimeIndication($deliveryTimeIndication) { $this->deliveryTimeIndication = $deliveryTimeIndication; }
86
+ function getDeliveryTimeIndication() { return $this->deliveryTimeIndication; }
87
+
88
+ function setStatus($status) { $this->status = $status; }
89
+ function getStatus() { return $this->status; }
90
+
91
+ function setClosedDate( $closedDate) { $this->closedDate = $closedDate; }
92
+ function getClosedDate() { return $this->closedDate; }
93
+
94
+ function setClosedQuantity($closedQuantity) { $this->closedQuantity = $closedQuantity; }
95
+ function getClosedQuantity() { return $this->closedQuantity; }
96
+
97
+ function setCancelledQuantity($cancelledQuantity) { $this->cancelledQuantity = $cancelledQuantity; }
98
+ function getCancelledQuantity() { return $this->cancelledQuantity; }
99
+
100
+ function setShippedQuantity($shippedQuantity) { $this->shippedQuantity = $shippedQuantity; }
101
+ function getShippedQuantity() { return $this->shippedQuantity; }
102
+
103
+ function setMancoQuantity($mancoQuantity) { $this->mancoQuantity = $mancoQuantity; }
104
+ function getMancoQuantity() { return $this->mancoQuantity; }
105
+ /*
106
+ [Required]
107
+ [StringLength(50)]
108
+ public string ChannelProductNo { get; set; }
109
+ // This one or ProductEan is required:
110
+ [StringLength(50)]
111
+ public string MerchantProductNo { get; set; }
112
+ [StringLength(20)]
113
+ public string ProductEan { get; set; }
114
+
115
+ // For non-vital fields, no string length errors, but they are silently truncated.
116
+ // productName, (100)
117
+ // productGroup, (50)
118
+ // productBrand,productVariantColor,productVariantSize (20)
119
+
120
+ [Required]
121
+ public string ProductName { get; set; }
122
+ public string ProductGroup { get; set; }
123
+ public string ProductBrand { get; set; }
124
+ public string ProductVariantColor { get; set; }
125
+ public string ProductVariantSize { get; set; }
126
+
127
+ public int Quantity { get; set; }
128
+ public decimal UnitPriceInclVat { get; set; }
129
+ public decimal? LineTotalInclVat { get; set; }
130
+ public decimal VatRate { get; set; }
131
+ public decimal? UnitVat { get; set; }
132
+ public decimal? LineVat { get; set; }
133
+ public decimal FeeFixed { get; set; }
134
+ public decimal FeeRate { get; set; }
135
+
136
+ public DateTime ExpectedDeliveryDate { get; set; }
137
+
138
+ public OrderStatus Status { get; set; }
139
+
140
+ public DateTime? ClosedDate { get; set; }
141
+ public int ClosedQuantity { get; set; }
142
+ public int CancelledQuantity { get; set; }
143
+ public int ShippedQuantity { get; set; }
144
+ public int MancoQuantity { get; set; }
145
+ */
146
+ }
lib/Tritac/ChannelEngineApiClient/Models/ReturnLine.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Tritac_ChannelEngineApiClient_Models_ReturnLine extends Tritac_ChannelEngineApiClient_Models_BaseModel {
4
+
5
+ public static $typeMap = array(
6
+ );
7
+
8
+ protected $returnId;
9
+ protected $orderLineId;
10
+ protected $shipmentLineId;
11
+ protected $quantity;
12
+ protected $acceptedQuantity;
13
+ protected $rejectedQuantity;
14
+ protected $refundInclVat;
15
+ protected $refundExclVat;
16
+
17
+ public function __construct()
18
+ {
19
+ self::$typeMap = array_merge(parent::$typeMap, self::$typeMap);
20
+ }
21
+
22
+ function setReturnId($returnId) { $this->returnId = $returnId; }
23
+ function getReturnId() { return $this->returnId; }
24
+
25
+ function setOrderLineId($orderLineId) { $this->orderLineId = $orderLineId; }
26
+ function getOrderLineId() { return $this->orderLineId; }
27
+
28
+ function setShipmentLineId($shipmentLineId) { $this->shipmentLineId = $shipmentLineId; }
29
+ function getShipmentLineId() { return $this->shipmentLineId; }
30
+
31
+ function setQuantity($quantity) { $this->quantity = $quantity; }
32
+ function getQuantity() { return $this->quantity; }
33
+
34
+ function setAcceptedQuantity($acceptedQuantity) { $this->acceptedQuantity = $acceptedQuantity; }
35
+ function getAcceptedQuantity() { return $this->acceptedQuantity; }
36
+
37
+ function setRejectedQuantity($rejectedQuantity) { $this->rejectedQuantity = $rejectedQuantity; }
38
+ function getRejectedQuantity() { return $this->rejectedQuantity; }
39
+
40
+ function setRefundInclVat($refundInclVat) { $this->refundInclVat = $refundInclVat; }
41
+ function getRefundInclVat() { return $this->refundInclVat; }
42
+
43
+ function setRefundExclVat($refundExclVat) { $this->refundExclVat = $refundExclVat; }
44
+ function getRefundExclVat() { return $this->refundExclVat; }
45
+
46
+ }
lib/Tritac/ChannelEngineApiClient/Models/ReturnObject.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Tritac_ChannelEngineApiClient_Models_ReturnObject extends Tritac_ChannelEngineApiClient_Models_BaseModel {
4
+
5
+ public static $typeMap = array(
6
+ 'lines' => 'Tritac_ChannelEngineApiClient_Helpers_Collection(Tritac_ChannelEngineApiClient_Models_ReturnLine)'
7
+ );
8
+
9
+ protected $orderId;
10
+ protected $shipmentId;
11
+ protected $merchantReturnNo;
12
+ protected $createdDate;
13
+ protected $updatedDate;
14
+ protected $status;
15
+ protected $reason;
16
+ protected $comment;
17
+ protected $merchantComment;
18
+ protected $refundInclVat;
19
+ protected $refundExclVat;
20
+ protected $lines;
21
+
22
+ public function __construct()
23
+ {
24
+ self::$typeMap = array_merge(parent::$typeMap, self::$typeMap);
25
+
26
+ $this->lines = new Tritac_ChannelEngineApiClient_Helpers_Collection('Tritac_ChannelEngineApiClient_Models_ReturnLine');
27
+ }
28
+
29
+ function setOrderId($orderId) { $this->orderId = $orderId; }
30
+ function getOrderId() { return $this->orderId; }
31
+
32
+ function setShipmentId($shipmentId) { $this->shipmentId = $shipmentId; }
33
+ function getShipmentId() { return $this->shipmentId; }
34
+
35
+ function setMerchantReturnNo($merchantReturnNo) { $this->merchantReturnNo = $merchantReturnNo; }
36
+ function getMerchantReturnNo() { return $this->merchantReturnNo; }
37
+
38
+ function setCreatedDate( $createdDate) { $this->createdDate = $createdDate; }
39
+ function getCreatedDate() { return $this->createdDate; }
40
+
41
+ function setUpdatedDate( $updatedDate) { $this->updatedDate = $updatedDate; }
42
+ function getUpdatedDate() { return $this->updatedDate; }
43
+
44
+ function setStatus($status) { $this->status = $status; }
45
+ function getStatus() { return $this->status; }
46
+
47
+ function setReason($reason) { $this->reason = $reason; }
48
+ function getReason() { return $this->reason; }
49
+
50
+ function setComment($comment) { $this->comment = $comment; }
51
+ function getComment() { return $this->comment; }
52
+
53
+ function setMerchantComment($merchantComment) { $this->merchantComment = $merchantComment; }
54
+ function getMerchantComment() { return $this->merchantComment; }
55
+
56
+ function setRefundInclVat($refundInclVat) { $this->refundInclVat = $refundInclVat; }
57
+ function getRefundInclVat() { return $this->refundInclVat; }
58
+
59
+ function setRefundExclVat($refundExclVat) { $this->refundExclVat = $refundExclVat; }
60
+ function getRefundExclVat() { return $this->refundExclVat; }
61
+
62
+ function setLines($lines) { $this->lines = $lines; }
63
+ function getLines() { return $this->lines; }
64
+ }
lib/Tritac/ChannelEngineApiClient/Models/Shipment.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Tritac_ChannelEngineApiClient_Models_Shipment extends Tritac_ChannelEngineApiClient_Models_BaseModel {
4
+
5
+ public static $typeMap = array(
6
+ 'lines' => 'Tritac_ChannelEngineApiClient_Helpers_Collection(Tritac_ChannelEngineApiClient_Models_ShipmentLine)',
7
+ );
8
+
9
+ protected $orderId;
10
+ protected $createdDate;
11
+ protected $updatedDate;
12
+ protected $trackTraceNo;
13
+ protected $trackTraceUrl;
14
+ protected $method;
15
+ protected $merchantShipmentNo;
16
+ protected $lines;
17
+ protected $refundInclVat;
18
+ protected $refundExclVat;
19
+ protected $status;
20
+ protected $mancoReason;
21
+ protected $mancoComment;
22
+
23
+ public function __construct()
24
+ {
25
+ self::$typeMap = array_merge(parent::$typeMap, self::$typeMap);
26
+ $date = new DateTime();
27
+ $this->orderId = null;
28
+ $this->trackTraceNo = '';
29
+ $this->trackTraceUrl = '';
30
+ $this->method = '';
31
+ $this->merchantShipmentNo = '';
32
+ $this->lines = new Tritac_ChannelEngineApiClient_Helpers_Collection('Tritac_ChannelEngineApiClient_Models_ShipmentLine');
33
+ $this->refundInclVat = null;
34
+ $this->refundExclVat = null;
35
+ $this->status = Tritac_ChannelEngineApiClient_Enums_ShipmentStatus::PENDING;
36
+ $this->mancoReason = Tritac_ChannelEngineApiClient_Enums_MancoReason::NOT_IN_STOCK;
37
+ $this->mancoComment = '';
38
+
39
+ }
40
+
41
+ function setOrderId($orderId) { $this->orderId = $orderId; }
42
+ function getOrderId() { return $this->orderId; }
43
+
44
+ function setTrackTraceNo($trackTraceNo) { $this->trackTraceNo = $trackTraceNo; }
45
+ function getTrackTraceNo() { return $this->trackTraceNo; }
46
+
47
+ function setTrackTraceUrl($trackTraceUrl) { $this->trackTraceUrl = $trackTraceUrl; }
48
+ function getTrackTraceUrl() { return $this->trackTraceUrl; }
49
+
50
+ function setMethod($method) { $this->method = $method; }
51
+ function getMethod() { return $this->method; }
52
+
53
+ function setMerchantShipmentNo($merchantShipmentNo) { $this->merchantShipmentNo = $merchantShipmentNo; }
54
+ function getMerchantShipmentNo() { return $this->merchantShipmentNo; }
55
+
56
+ function setLines($lines) { $this->lines = $lines; }
57
+ function getLines() { return $this->lines; }
58
+
59
+ function setRefundInclVat($refundInclVat) { $this->refundInclVat = $refundInclVat; }
60
+ function getRefundInclVat() { return $this->refundInclVat; }
61
+
62
+ function setRefundExclVat($refundExclVat) { $this->refundExclVat = $refundExclVat; }
63
+ function getRefundExclVat() { return $this->refundExclVat; }
64
+
65
+ function setStatus($status) { $this->status = $status; }
66
+ function getStatus() { return $this->status; }
67
+
68
+ function setMancoReason($mancoReason) { $this->mancoReason = $mancoReason; }
69
+ function getMancoReason() { return $this->mancoReason; }
70
+
71
+ function setMancoComment($mancoComment) { $this->mancoComment = $mancoComment; }
72
+ function getMancoComment() { return $this->mancoComment; }
73
+ }
lib/Tritac/ChannelEngineApiClient/Models/ShipmentLine.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Tritac_ChannelEngineApiClient_Models_ShipmentLine extends Tritac_ChannelEngineApiClient_Models_BaseModel {
4
+
5
+ public static $typeMap = array(
6
+ );
7
+
8
+ protected $shipmentId;
9
+ protected $orderLineId;
10
+ protected $status;
11
+ protected $quantity;
12
+ protected $expectedDate;
13
+ protected $refundInclVat;
14
+ protected $refundExclVat;
15
+
16
+ public function __construct()
17
+ {
18
+ self::$typeMap = array_merge(parent::$typeMap, self::$typeMap);
19
+ $this->shipmentId = null;
20
+ $this->orderLineId = 0;
21
+ $this->status = Tritac_ChannelEngineApiClient_Enums_ShipmentLineStatus::SHIPPED;
22
+ $this->quantity = 0;
23
+ $this->expectedDate = null;
24
+ $this->refundInclVat = 0;
25
+ $this->refundExclVat = 0;
26
+ }
27
+
28
+ function setShipmentId($shipmentId) { $this->shipmentId = $shipmentId; }
29
+ function getShipmentId() { return $this->shipmentId; }
30
+
31
+ function setOrderLineId($orderLineId) { $this->orderLineId = $orderLineId; }
32
+ function getOrderLineId() { return $this->orderLineId; }
33
+
34
+ function setStatus($status) { $this->status = $status; }
35
+ function getStatus() { return $this->status; }
36
+
37
+ function setQuantity($quantity) { $this->quantity = $quantity; }
38
+ function getQuantity() { return $this->quantity; }
39
+
40
+ function setExpectedDate( $expectedDate) { $this->expectedDate = $expectedDate; }
41
+ function getExpectedDate() { return $this->expectedDate; }
42
+
43
+ function setRefundInclVat($refundInclVat) { $this->refundInclVat = $refundInclVat; }
44
+ function getRefundInclVat() { return $this->refundInclVat; }
45
+
46
+ function setRefundExclVat($refundExclVat) { $this->refundExclVat = $refundExclVat; }
47
+ function getRefundExclVat() { return $this->refundExclVat; }
48
+ }
lib/Tritac/ChannelEngineApiClient/loader.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // This loader is required to make use of the php __autoload functionality.
4
+
5
+ /*function __autoload($class) {
6
+ $class = str_replace('\\', '/', $class) . '.php';
7
+ require_once($class);
8
+ }*/
9
+
10
+ // Add your class dir to include path
11
+ set_include_path(get_include_path() . PATH_SEPARATOR);
12
+
13
+ // Use default autoload implementation
14
+ spl_autoload_register();
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Tritac_ChannelEngine</name>
4
+ <version>2.0.4</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Connect your Magento shop to the ChannelEngine platform.</summary>
10
+ <description>Easily offer your products on comparison websites and marketplaces using the ChannelEngine platform.</description>
11
+ <notes>* Better support for multistore setups</notes>
12
+ <authors><author><name>ChannelEngine</name><user>christiaander</user><email>christiaan@tritac.com</email></author></authors>
13
+ <date>2014-04-17</date>
14
+ <time>14:17:18</time>
15
+ <contents><target name="mageetc"><dir name="modules"><file name="Tritac_ChannelEngine.xml" hash="014b02d581d1039764cdc422e8f86643"/></dir></target><target name="magecommunity"><dir name="Tritac"><dir name="ChannelEngine"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><file name="Feed.php" hash="cbc5bf15ab9cd9bb5b2bc97375db3eb2"/></dir></dir></dir><file name="Head.php" hash="98a65067f1ae6074f2c276624164c183"/><dir name="Sales"><dir name="Order"><file name="Grid.php" hash="097e10d1e9e6dd8c5aee66124376cae4"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="bf1203d5f080b340404f02c51967f328"/></dir><dir name="Model"><dir name="Carrier"><file name="Channelengine.php" hash="d93ca824330b2e0eff034009c7e333c2"/></dir><file name="Observer.php" hash="7395630f8144276f479fdc5cd67a4012"/><file name="Order.php" hash="66c8e7c0ac47f9dbabb156eaa8c97f1e"/><dir name="Payment"><dir name="Method"><file name="Channelengine.php" hash="49ef02953b486cfbf813d37e681172a3"/></dir></dir><dir name="Resource"><dir name="Order"><file name="Collection.php" hash="989bbd95481d2954d7813e19d8c27d18"/></dir><file name="Order.php" hash="3813fe3ad637daf069d79bca1feea540"/><file name="Setup.php" hash="24934fe022e3bb93331fcbfb7a116d37"/></dir><dir name="System"><dir name="Config"><dir name="Source"><file name="Shipping.php" hash="103486f575dcd6205fc9cfd40f2fa5ea"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="GenerateController.php" hash="edde582db1fbb091e14396b247cd0d45"/></dir><file name="TestController.php" hash="1f579ff8fd8ffeb9a8ce25dde0d0fc11"/></dir><dir name="etc"><file name="adminhtml.xml" hash="5a976b638c6ad66287ba3084fdbfc157"/><file name="config.xml" hash="aced0ba095aa2196790a64ba8fac646c"/><file name="system.xml" hash="6b44934dfc998680e067da9360dcd0a3"/></dir><dir name="sql"><dir name="channelengine_setup"><file name="mysql4-install-0.1.0.0.php" hash="312e7c69f98c8d13d251b8ed1ca93448"/><file name="mysql4-install-1.0.0.php" hash="3664f3c5b6e01db69cbea8b4b0beb9ab"/></dir></dir></dir></dir></target><target name="magelib"><dir name="Tritac"><dir name="ChannelEngineApiClient"><file name="AddTrustExternalCARoot.crt" hash="f85d1ff17b0079709f131f3ce3f288d2"/><file name="Client.php" hash="cbfd5ff092ffb201426146d02e6316b4"/><dir name="Enums"><file name="CancellationLineStatus.php" hash="0fe455ad75e49b2796d4bcd1230a3c0d"/><file name="CancellationStatus.php" hash="e4a26c1a29afe02d92320187277f5d03"/><file name="Gender.php" hash="49645506c67b6ad530e1463da256d403"/><file name="MancoReason.php" hash="80388c0545fa091fd9e651fc1284b77d"/><file name="OrderStatus.php" hash="855341235149ff3c9d3a36a5a23f8db0"/><file name="ReturnAcceptStatus.php" hash="de4252a8f9d7b94493b470cccd9feaec"/><file name="ReturnReason.php" hash="05d5fd5b23af84508b8bec92137c421d"/><file name="ReturnStatus.php" hash="ba9350e9ba015ec9cac4b1ab7702333c"/><file name="ShipmentLineStatus.php" hash="8329dce7182fc7705bb8008da6a7e26f"/><file name="ShipmentStatus.php" hash="d73e4a5b58487c7b0c80b114601d3279"/></dir><dir name="Helpers"><file name="Collection.php" hash="2278a5e6d8d65ebca92ba1e968680315"/><file name="HttpMethod.php" hash="4949b2cfe4a309a54b1642fa09bda53b"/><file name="JsonMapper.php" hash="f8e30cab83a2f2ccfdb2a64636c2346b"/></dir><dir name="Models"><file name="Address.php" hash="543aff76425e3335cbba2a1cdd25564d"/><file name="BaseModel.php" hash="65f09d298baa6496807a2f71ea93a8f8"/><file name="Cancellation.php" hash="2fc15d3d2a8f7e21d6f6000bffb77722"/><file name="CancellationLine.php" hash="e8820be847e77d5f77a2de8cb551a8a0"/><file name="Message.php" hash="e0cea12494684d58abea051958082036"/><file name="Order.php" hash="e2a36b36a58607cc460c712979213e54"/><file name="OrderExtraDataItem.php" hash="eaf59ef83070360c4c7bb2c3f5c5633a"/><file name="OrderLine.php" hash="63451a19448eddb6eecf8eca959f9fcb"/><file name="ReturnLine.php" hash="c1cbf7c45a85280782955be400c478e6"/><file name="ReturnObject.php" hash="32d035ba6b448958bb43eac6bf286d6e"/><file name="Shipment.php" hash="8f027c770d98cdb5bc74005ec9310e1c"/><file name="ShipmentLine.php" hash="5c738023584cd6513940be54b8f8dc60"/></dir><file name="loader.php" hash="3daea8be627858c27383a79a29663c82"/></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.13</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>