BeezUP_Module_feed_and_tracker - Version 4.0.0

Version Notes

New features :
> Export Orders from Marketplaces
> Fixed bug in category management

Download this release

Release Info

Developer BeezUP
Extension BeezUP_Module_feed_and_tracker
Version 4.0.0
Comparing to
See all releases


Code changes from version 3.2.0 to 4.0.0

Files changed (114) hide show
  1. app/code/community/BeezUp/Block/Adminhtml/Sales/Order/Creditmemo/Totals.php +51 -0
  2. app/code/community/BeezUp/Block/Adminhtml/Sales/Order/Grid.php +235 -0
  3. app/code/community/BeezUp/Block/Adminhtml/Sales/Order/Invoice/Totals.php +57 -0
  4. app/code/community/BeezUp/Block/Adminhtml/Sales/Order/Totals.php +55 -0
  5. app/code/community/BeezUp/Block/Adminhtml/Sales/Order/View/Tab/Custom.php +36 -0
  6. app/code/community/BeezUp/Block/Adminhtml/System/Config/Attributes.php +166 -0
  7. app/code/community/BeezUp/Block/Adminhtml/System/Config/Button.php +56 -0
  8. app/code/community/BeezUp/Block/Adminhtml/System/Config/Childgroup.php +33 -0
  9. app/code/community/BeezUp/Block/Adminhtml/System/Config/Credentials.php +48 -0
  10. app/code/community/BeezUp/Block/Adminhtml/System/Config/Cron.php +16 -0
  11. app/code/community/BeezUp/Block/Adminhtml/System/Config/Filter.php +163 -0
  12. app/code/community/BeezUp/Block/Adminhtml/System/Config/Log.php +65 -0
  13. app/code/community/BeezUp/Block/Adminhtml/System/Config/Manualcron.php +14 -0
  14. app/code/community/BeezUp/Block/Adminhtml/System/Config/Stores.php +69 -0
  15. app/code/community/BeezUp/Block/Adminhtml/System/Config/Syncstatus.php +26 -0
  16. app/code/community/BeezUp/Block/Adminhtml/System/Config/Time.php +24 -0
  17. app/code/community/BeezUp/Block/Order.php +1143 -0
  18. app/code/community/BeezUp/Block/Tracking.php +96 -96
  19. app/code/community/BeezUp/Block/Xml.php +745 -727
  20. app/code/community/BeezUp/Helper/Data.php +67 -67
  21. app/code/community/BeezUp/Model/Flatrate.php +91 -0
  22. app/code/community/BeezUp/Model/Observer.php +31 -31
  23. app/code/community/BeezUp/Model/Products.php +320 -291
  24. app/code/community/BeezUp/Model/Quote/Item.php +115 -0
  25. app/code/community/BeezUp/Model/Sales/Order/Pdf/Invoice.php +87 -0
  26. app/code/community/BeezUp/Model/System/Config/Backend/Attributes.php +26 -0
  27. app/code/community/BeezUp/Model/System/Config/Backend/Credentials.php +32 -0
  28. app/code/community/BeezUp/Model/System/Config/Backend/Time.php +23 -0
  29. app/code/community/BeezUp/Model/System/Config/Backend/Token.php +28 -0
  30. app/code/community/BeezUp/Model/System/Config/Source/Attributes.php +20 -20
  31. app/code/community/BeezUp/Model/System/Config/Source/Availableproducts.php +14 -0
  32. app/code/community/BeezUp/Model/System/Config/Source/Cache.php +19 -19
  33. app/code/community/BeezUp/Model/System/Config/Source/Debug.php +13 -0
  34. app/code/community/BeezUp/Model/System/Config/Source/Description.php +14 -14
  35. app/code/community/BeezUp/Model/System/Config/Source/Images.php +13 -13
  36. app/code/community/BeezUp/Model/System/Config/Source/Montant.php +15 -15
  37. app/code/community/BeezUp/Model/System/Config/Source/Payment.php +22 -0
  38. app/code/community/BeezUp/Model/System/Config/Source/Position.php +13 -13
  39. app/code/community/BeezUp/Model/System/Config/Source/Price.php +13 -13
  40. app/code/community/BeezUp/Model/System/Config/Source/Shipping.php +39 -0
  41. app/code/community/BeezUp/Model/System/Config/Source/Status.php +23 -0
  42. app/code/community/BeezUp/Model/System/Config/Source/Userid.php +10 -0
  43. app/code/community/BeezUp/controllers/CacheController.php +21 -0
  44. app/code/community/BeezUp/controllers/CatalogController.php +35 -35
  45. app/code/community/BeezUp/controllers/CronController.php +23 -0
  46. app/code/community/BeezUp/controllers/LogController.php +19 -0
  47. app/code/community/BeezUp/controllers/Sales/OrderController.php +68 -0
  48. app/code/community/BeezUp/etc/adminhtml.xml +60 -0
  49. app/code/community/BeezUp/etc/config.xml +198 -123
  50. app/code/community/BeezUp/etc/system.xml +573 -244
  51. app/code/community/BeezUp/lib/BeezupMageOrders.php +301 -0
  52. app/code/community/BeezUp/lib/BeezupOMDataHandler.php +68 -0
  53. app/code/community/BeezUp/lib/BeezupOMOrderService.php +613 -0
  54. app/code/community/BeezUp/lib/BeezupOMOrderServiceInterface.php +10 -0
  55. app/code/community/BeezUp/lib/BeezupOMRepositoryInterface.php +103 -0
  56. app/code/community/BeezUp/lib/BeezupOMRequestData.php +112 -0
  57. app/code/community/BeezUp/lib/BeezupOMResponseData.php +88 -0
  58. app/code/community/BeezUp/lib/BeezupOMServiceClientProxy.php +671 -0
  59. app/code/community/BeezUp/lib/BeezupRepository.php +317 -0
  60. app/code/community/BeezUp/lib/Common/BeezupOMCredential.php +62 -0
  61. app/code/community/BeezUp/lib/Common/BeezupOMErrorSummary.php +3 -0
  62. app/code/community/BeezUp/lib/Common/BeezupOMExpectedOrderChangeMetaInfo.php +133 -0
  63. app/code/community/BeezUp/lib/Common/BeezupOMInfoSummaries.php +111 -0
  64. app/code/community/BeezUp/lib/Common/BeezupOMInfoSummary.php +3 -0
  65. app/code/community/BeezUp/lib/Common/BeezupOMLink.php +183 -0
  66. app/code/community/BeezUp/lib/Common/BeezupOMOrderIdentifier.php +159 -0
  67. app/code/community/BeezUp/lib/Common/BeezupOMProcessingStatus.php +10 -0
  68. app/code/community/BeezUp/lib/Common/BeezupOMRequest.php +33 -0
  69. app/code/community/BeezUp/lib/Common/BeezupOMResponse.php +105 -0
  70. app/code/community/BeezUp/lib/Common/BeezupOMResult.php +7 -0
  71. app/code/community/BeezUp/lib/Common/BeezupOMSuccessSummary.php +3 -0
  72. app/code/community/BeezUp/lib/Common/BeezupOMSummary.php +41 -0
  73. app/code/community/BeezUp/lib/Common/BeezupOMWarningSummary.php +3 -0
  74. app/code/community/BeezUp/lib/Harvest/BeezupOMHarvestAbstractReporting.php +3 -0
  75. app/code/community/BeezUp/lib/Harvest/BeezupOMHarvestClientReporting.php +239 -0
  76. app/code/community/BeezUp/lib/Harvest/BeezupOMHarvestOrderReporting.php +291 -0
  77. app/code/community/BeezUp/lib/KLogger.php +148 -0
  78. app/code/community/BeezUp/lib/LOV/BeezupOMLOVRequest.php +43 -0
  79. app/code/community/BeezUp/lib/LOV/BeezupOMLOVResponse.php +14 -0
  80. app/code/community/BeezUp/lib/LOV/BeezupOMLOVResult.php +61 -0
  81. app/code/community/BeezUp/lib/LOV/BeezupOMLOVValue.php +104 -0
  82. app/code/community/BeezUp/lib/Order/BeezupOMOrderItem.php +332 -0
  83. app/code/community/BeezUp/lib/Order/BeezupOMOrderRequest.php +132 -0
  84. app/code/community/BeezUp/lib/Order/BeezupOMOrderResponse.php +78 -0
  85. app/code/community/BeezUp/lib/Order/BeezupOMOrderResult.php +1176 -0
  86. app/code/community/BeezUp/lib/OrderChange/BeezupOMOrderChangeMetaInfo.php +86 -0
  87. app/code/community/BeezUp/lib/OrderChange/BeezupOMOrderChangeRequest.php +117 -0
  88. app/code/community/BeezUp/lib/OrderChange/BeezupOMOrderChangeResponse.php +88 -0
  89. app/code/community/BeezUp/lib/OrderChange/BeezupOMOrderChangeResult.php +75 -0
  90. app/code/community/BeezUp/lib/OrderHistory/BeezupOMOrderChangeReporting.php +231 -0
  91. app/code/community/BeezUp/lib/OrderHistory/BeezupOMOrderHarvestReporting.php +172 -0
  92. app/code/community/BeezUp/lib/OrderHistory/BeezupOMOrderHistoryRequest.php +69 -0
  93. app/code/community/BeezUp/lib/OrderHistory/BeezupOMOrderHistoryResponse.php +49 -0
  94. app/code/community/BeezUp/lib/OrderHistory/BeezupOMOrderHistoryResult.php +103 -0
  95. app/code/community/BeezUp/lib/OrderList/BeezupOMOrderHeader.php +351 -0
  96. app/code/community/BeezUp/lib/OrderList/BeezupOMOrderListRequest.php +140 -0
  97. app/code/community/BeezUp/lib/OrderList/BeezupOMOrderListResponse.php +23 -0
  98. app/code/community/BeezUp/lib/OrderList/BeezupOMOrderListResult.php +63 -0
  99. app/code/community/BeezUp/lib/OrderList/BeezupOMPaginationResult.php +91 -0
  100. app/code/community/BeezUp/lib/SetOrderId/BeezupOMSetOrderIdRequest.php +54 -0
  101. app/code/community/BeezUp/lib/SetOrderId/BeezupOMSetOrderIdResponse.php +11 -0
  102. app/code/community/BeezUp/lib/SetOrderId/BeezupOMSetOrderIdResult.php +3 -0
  103. app/code/community/BeezUp/lib/SetOrderId/BeezupOMSetOrderIdValues.php +81 -0
  104. app/code/community/BeezUp/lib/Stores/BeezupOMStore.php +57 -0
  105. app/code/community/BeezUp/lib/Stores/BeezupOMStoresRequest.php +3 -0
  106. app/code/community/BeezUp/lib/Stores/BeezupOMStoresResponse.php +12 -0
  107. app/code/community/BeezUp/lib/Stores/BeezupOMStoresResult.php +43 -0
  108. app/code/community/BeezUp/lib/bootstrap.php +72 -0
  109. app/code/community/BeezUp/sql/beezup_setup/mysql4-install-4.0.0.php +125 -0
  110. app/design/adminhtml/default/default/layout/beezup_salestab.xml +8 -0
  111. app/design/adminhtml/default/default/template/beezup/custom.phtml +50 -0
  112. app/locale/en_US/BeezUp.csv +109 -70
  113. app/locale/fr_FR/BeezUp.csv +122 -60
  114. package.xml +10 -7
app/code/community/BeezUp/Block/Adminhtml/Sales/Order/Creditmemo/Totals.php ADDED
@@ -0,0 +1,51 @@
1
+ <?php
2
+
3
+ class BeezUp_Block_Adminhtml_Sales_Order_Creditmemo_Totals extends Mage_Adminhtml_Block_Sales_Order_Creditmemo_Totals
4
+ {
5
+ /**
6
+ * Initialize order totals array
7
+ *
8
+ * @return Mage_Sales_Block_Order_Totals
9
+ */
10
+ protected function _initTotals()
11
+ {
12
+
13
+ $id =$this->getSource()->getQuoteId();
14
+ $resource = Mage::getSingleton('core/resource');
15
+ $readConnection = $resource->getConnection('core_read');
16
+ $table = $resource->getTableName('sales/quote_address');
17
+ $query = 'SELECT beezup_fee FROM ' . $table . ' WHERE quote_id = '.$id.' and address_type = \'shipping\' LIMIT 1';
18
+ $fee = $readConnection->fetchOne($query);
19
+ parent::_initTotals();
20
+ $amount = 20;
21
+
22
+ if ($fee>0) {
23
+ $this->addTotalBefore(new Varien_Object(array(
24
+ 'code' => 'turnkeye_insurance',
25
+ 'value' => $fee,
26
+ 'base_value'=> $fee,
27
+ 'label' => $this->helper('beezup')->__('Special Fee'),
28
+ ), array('shipping', 'tax')));
29
+ }
30
+ $this->_totals['paid'] = new Varien_Object(array(
31
+ 'code' => 'paid',
32
+ 'strong' => true,
33
+ 'value' => $this->getSource()->getTotalPaid() +$fee,
34
+ 'base_value'=> $this->getSource()->getBaseTotalPaid() + $fee,
35
+ 'label' => $this->helper('sales')->__('Total Paid'),
36
+ 'area' => 'footer'
37
+ ));
38
+
39
+ $this->_totals['grand_total'] = new Varien_Object(array(
40
+ 'code' => 'grand_total',
41
+ 'strong' => true,
42
+ 'value' => $this->getSource()->getGrandTotal() +$fee,
43
+ 'base_value'=> $this->getSource()->getBaseGrandTotal() +$fee,
44
+ 'label' => $this->helper('sales')->__('Grand Total'),
45
+ 'area' => 'footer'
46
+ ));
47
+
48
+ // $this->setGrandTotal($this->getGrandTotal() + 20);
49
+ return $this;
50
+ }
51
+ }
app/code/community/BeezUp/Block/Adminhtml/Sales/Order/Grid.php ADDED
@@ -0,0 +1,235 @@
1
+ <?php
2
+
3
+ /**
4
+ * Adminhtml sales orders grid
5
+ *
6
+ * @author Inchoo <ivan.galambos@inchoo.net>
7
+ */
8
+ class BeezUp_Block_Adminhtml_Sales_Order_Grid extends Mage_Adminhtml_Block_Widget_Grid
9
+ {
10
+
11
+ public function __construct()
12
+ {
13
+
14
+ parent::__construct();
15
+
16
+ $this->setId('sales_order_grid');
17
+ $this->setUseAjax(true);
18
+ $this->setDefaultSort('created_at');
19
+ $this->setDefaultSort('entity_id');
20
+ $this->setDefaultDir('DESC');
21
+ $this->setSaveParametersInSession(true);
22
+
23
+ if ($this->getRequest()->getParam('prepared') === 'beezup') {
24
+ $this->setDefaultFilter( array(
25
+ 'beezup_order' => '1'
26
+ ) );
27
+ }
28
+ }
29
+
30
+ /**
31
+ * Modify column filter if needed by custom implementation of IN() and NOT IN() MySQL statement + prepared filter functionality
32
+ *
33
+ */
34
+ protected function _addColumnFilterToCollection($column)
35
+ {
36
+ $filterArr = Mage::registry('preparedFilter');
37
+
38
+ if (($column->getId() === 'store_id' || $column->getId() === 'status') && $column->getFilter()->getValue() && strpos($column->getFilter()->getValue(), ',')) {
39
+
40
+ $_inNin = explode(',', $column->getFilter()->getValue());
41
+ $inNin = array();
42
+
43
+ foreach ($_inNin as $k => $v) {
44
+ if (is_string($v) && strlen(trim($v))) {
45
+ $inNin[] = trim($v);
46
+ }
47
+ }
48
+
49
+ if (count($inNin)>1 && in_array($inNin[0], array('in', 'nin'))) {
50
+ $in = $inNin[0];
51
+ $values = array_slice($inNin, 1);
52
+ $this->getCollection()->addFieldToFilter($column->getId(), array($in => $values));
53
+ } else {
54
+ parent::_addColumnFilterToCollection($column);
55
+
56
+ }
57
+ } elseif (is_array($filterArr) && array_key_exists($column->getId(), $filterArr) && isset($filterArr[$column->getId()])) {
58
+ $this->getCollection()->addFieldToFilter($column->getId(), $filterArr[$column->getId()]);
59
+
60
+ } else {
61
+ parent::_addColumnFilterToCollection($column);
62
+
63
+ }
64
+ // Zend_Debug::dump((string)$this->getCollection()->getSelect(), 'Prepared filter:');
65
+ return $this;
66
+ }
67
+ /**
68
+ * Retrieve collection class
69
+ *
70
+ * @return string
71
+ */
72
+ protected function _getCollectionClass()
73
+ {
74
+ return 'sales/order_grid_collection';
75
+ }
76
+
77
+ protected function _prepareCollection()
78
+ {
79
+ $collection = Mage::getResourceModel($this->_getCollectionClass());
80
+ $this->setCollection($collection);
81
+ return parent::_prepareCollection();
82
+ }
83
+
84
+ protected function _prepareColumns()
85
+ {
86
+ $this->addColumn('real_order_id', array(
87
+ 'header'=> Mage::helper('sales')->__('Order #'),
88
+ 'width' => '80px',
89
+ 'type' => 'text',
90
+ 'index' => 'increment_id',
91
+ ));
92
+ if (!Mage::app()->isSingleStoreMode()) {
93
+ $this->addColumn('store_id', array(
94
+ 'header' => Mage::helper('sales')->__('Purchased From (Store)'),
95
+ 'index' => 'store_id',
96
+ // 'type' => 'store',
97
+ // 'store_view'=> true,
98
+ // 'display_deleted' => true,
99
+ ));
100
+ }
101
+ $this->addColumn('created_at', array(
102
+ 'header' => Mage::helper('sales')->__('Purchased On'),
103
+ 'index' => 'created_at',
104
+ 'type' => 'datetime',
105
+ 'width' => '100px',
106
+ ));
107
+ $this->addColumn('billing_name', array(
108
+ 'header' => Mage::helper('sales')->__('Bill to Name'),
109
+ 'index' => 'billing_name',
110
+ ));
111
+ $this->addColumn('shipping_name', array(
112
+ 'header' => Mage::helper('sales')->__('Ship to Name'),
113
+ 'index' => 'shipping_name',
114
+ ));
115
+
116
+ if ($this->getRequest()->getParam('prepared') === 'beezup') {
117
+ $this->addColumn('beezup_marketplace', array(
118
+ 'header' =>Mage::helper('beezup')->__('Marketplace'),
119
+ 'index' => 'beezup_marketplace',
120
+ ));
121
+
122
+
123
+ $this->addColumn('beezup_order', array(
124
+ 'header' => Mage::helper('beezup')->__('Beezup Order'),
125
+ 'index' => 'beezup_order',
126
+ 'column_css_class'=>'no-display',//this sets a css class to the column row item
127
+ 'header_css_class'=>'no-display',//this sets a css class to the column header
128
+ ));
129
+
130
+ $this->addColumn('beezup_market_order_id', array(
131
+ 'header' => Mage::helper('beezup')->__('Marketplace Order Id'),
132
+ 'index' => 'beezup_market_order_id',
133
+ ));
134
+
135
+ }
136
+ $this->addColumn('base_grand_total', array(
137
+ 'header' => Mage::helper('sales')->__('G.T. (Base)'),
138
+ 'index' => 'base_grand_total',
139
+ 'type' => 'currency',
140
+ 'currency' => 'base_currency_code',
141
+ ));
142
+ $this->addColumn('grand_total', array(
143
+ 'header' => Mage::helper('sales')->__('G.T. (Purchased)'),
144
+ 'index' => 'grand_total',
145
+ 'type' => 'currency',
146
+ 'currency' => 'order_currency_code',
147
+ ));
148
+ $this->addColumn('status', array(
149
+ 'header' => Mage::helper('sales')->__('Status'),
150
+ 'index' => 'status',
151
+ 'type' => 'options',
152
+ 'width' => '100px',
153
+ 'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
154
+ ));
155
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
156
+ $this->addColumn('action',
157
+ array(
158
+ 'header' => Mage::helper('sales')->__('Action'),
159
+ 'width' => '50px',
160
+ 'type' => 'action',
161
+ 'getter' => 'getId',
162
+ 'actions' => array(
163
+ array(
164
+ 'caption' => Mage::helper('sales')->__('View'),
165
+ 'url' => array('base'=>'*/sales_order/view'),
166
+ 'field' => 'order_id'
167
+ )
168
+ ),
169
+ 'filter' => false,
170
+ 'sortable' => false,
171
+ 'index' => 'stores',
172
+ 'is_system' => true,
173
+ ));
174
+ }
175
+ $this->addRssList('rss/order/new', Mage::helper('sales')->__('New Order RSS'));
176
+ $this->addExportType('*/*/exportCsv', Mage::helper('sales')->__('CSV'));
177
+ $this->addExportType('*/*/exportExcel', Mage::helper('sales')->__('Excel XML'));
178
+ return parent::_prepareColumns();
179
+ }
180
+
181
+ protected function _prepareMassaction()
182
+ {
183
+ $this->setMassactionIdField('entity_id');
184
+ $this->getMassactionBlock()->setFormFieldName('order_ids');
185
+ $this->getMassactionBlock()->setUseSelectAll(false);
186
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/cancel')) {
187
+ $this->getMassactionBlock()->addItem('cancel_order', array(
188
+ 'label'=> Mage::helper('sales')->__('Cancel'),
189
+ 'url' => $this->getUrl('*/sales_order/massCancel'),
190
+ ));
191
+ }
192
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/hold')) {
193
+ $this->getMassactionBlock()->addItem('hold_order', array(
194
+ 'label'=> Mage::helper('sales')->__('Hold'),
195
+ 'url' => $this->getUrl('*/sales_order/massHold'),
196
+ ));
197
+ }
198
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/unhold')) {
199
+ $this->getMassactionBlock()->addItem('unhold_order', array(
200
+ 'label'=> Mage::helper('sales')->__('Unhold'),
201
+ 'url' => $this->getUrl('*/sales_order/massUnhold'),
202
+ ));
203
+ }
204
+ $this->getMassactionBlock()->addItem('pdfinvoices_order', array(
205
+ 'label'=> Mage::helper('sales')->__('Print Invoices'),
206
+ 'url' => $this->getUrl('*/sales_order/pdfinvoices'),
207
+ ));
208
+ $this->getMassactionBlock()->addItem('pdfshipments_order', array(
209
+ 'label'=> Mage::helper('sales')->__('Print Packingslips'),
210
+ 'url' => $this->getUrl('*/sales_order/pdfshipments'),
211
+ ));
212
+ $this->getMassactionBlock()->addItem('pdfcreditmemos_order', array(
213
+ 'label'=> Mage::helper('sales')->__('Print Credit Memos'),
214
+ 'url' => $this->getUrl('*/sales_order/pdfcreditmemos'),
215
+ ));
216
+ $this->getMassactionBlock()->addItem('pdfdocs_order', array(
217
+ 'label'=> Mage::helper('sales')->__('Print All'),
218
+ 'url' => $this->getUrl('*/sales_order/pdfdocs'),
219
+ ));
220
+ return $this;
221
+ }
222
+
223
+ public function getRowUrl($row)
224
+ {
225
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
226
+ return $this->getUrl('*/sales_order/view', array('order_id' => $row->getId()));
227
+ }
228
+ return false;
229
+ }
230
+
231
+ public function getGridUrl()
232
+ {
233
+ return $this->getUrl('*/*/grid', array('_current'=>true));
234
+ }
235
+ }
app/code/community/BeezUp/Block/Adminhtml/Sales/Order/Invoice/Totals.php ADDED
@@ -0,0 +1,57 @@
1
+ <?php
2
+
3
+ class BeezUp_Block_Adminhtml_Sales_Order_Invoice_Totals extends Mage_Adminhtml_Block_Sales_Order_Invoice_Totals
4
+ {
5
+ /**
6
+ * Initialize order totals array
7
+ *
8
+ * @return Mage_Sales_Block_Order_Totals
9
+ */
10
+ protected function _initTotals()
11
+ {
12
+
13
+ parent::_initTotals();
14
+
15
+
16
+ $order = $this->getOrder();
17
+ //$id =$this->getSource()->getQuoteId();
18
+ $id = $order->getQuoteId();
19
+ $resource = Mage::getSingleton('core/resource');
20
+ $readConnection = $resource->getConnection('core_read');
21
+ $table = $resource->getTableName('sales/quote_address');
22
+ $query = 'SELECT beezup_fee FROM ' . $table . ' WHERE quote_id = '.$id.' and address_type = \'shipping\' LIMIT 1';
23
+ $fee = $readConnection->fetchOne($query);
24
+ parent::_initTotals();
25
+ $amount = 20;
26
+
27
+ if ($fee>0) {
28
+ $this->addTotalBefore(new Varien_Object(array(
29
+ 'code' => 'turnkeye_insurance',
30
+ 'value' => $fee,
31
+ 'base_value'=> $fee,
32
+ 'label' => "Frais de Gestion Cdiscount",
33
+ ), array('shipping', 'tax')));
34
+ }
35
+ $this->_totals['paid'] = new Varien_Object(array(
36
+ 'code' => 'paid',
37
+ 'strong' => true,
38
+ 'value' => $order->getTotalPaid() +$fee,
39
+ 'base_value'=> $order->getBaseTotalPaid() + $fee,
40
+ 'label' => $this->helper('sales')->__('Total Paid'),
41
+ 'area' => 'footer'
42
+ ));
43
+
44
+ $this->_totals['grand_total'] = new Varien_Object(array(
45
+ 'code' => 'grand_total',
46
+ 'strong' => true,
47
+ 'value' => $order->getGrandTotal() +$fee,
48
+ 'base_value'=> $order->getBaseGrandTotal() +$fee,
49
+ 'label' => $this->helper('sales')->__('Grand Total'),
50
+ 'area' => 'footer'
51
+ ));
52
+
53
+ // $this->setGrandTotal($this->getGrandTotal() + 20);
54
+ return $this;
55
+ }
56
+
57
+ }
app/code/community/BeezUp/Block/Adminhtml/Sales/Order/Totals.php ADDED
@@ -0,0 +1,55 @@
1
+ <?php
2
+
3
+ class BeezUp_Block_Adminhtml_Sales_Order_Totals extends Mage_Adminhtml_Block_Sales_Order_Totals
4
+ {
5
+ /**
6
+ * Initialize order totals array
7
+ *
8
+ * @return Mage_Sales_Block_Order_Totals
9
+ */
10
+ protected function _initTotals()
11
+ {
12
+
13
+ $id =$this->getSource()->getQuoteId();
14
+ $fee = 0;
15
+ if(is_numeric($id) && $id > 0) {
16
+ $resource = Mage::getSingleton('core/resource');
17
+ $readConnection = $resource->getConnection('core_read');
18
+ $table = $resource->getTableName('sales/quote_address');
19
+ $query = 'SELECT beezup_fee FROM ' . $table . ' WHERE quote_id = '.$id.' and address_type = \'shipping\' LIMIT 1';
20
+ $fee = $readConnection->fetchOne($query);
21
+ }
22
+ parent::_initTotals();
23
+
24
+
25
+ if ($fee>0) {
26
+ $this->addTotalBefore(new Varien_Object(array(
27
+ 'code' => 'turnkeye_insurance',
28
+ 'value' => $fee,
29
+ 'base_value'=> $fee,
30
+ 'label' => 'Frais de Gestion Cdiscount',
31
+ ), array('shipping', 'tax')));
32
+ }
33
+ $this->_totals['paid'] = new Varien_Object(array(
34
+ 'code' => 'paid',
35
+ 'strong' => true,
36
+ 'value' => $this->getSource()->getTotalPaid() +$fee,
37
+ 'base_value'=> $this->getSource()->getBaseTotalPaid() + $fee,
38
+ 'label' => $this->helper('sales')->__('Total Paid'),
39
+ 'area' => 'footer'
40
+ ));
41
+
42
+ $this->_totals['grand_total'] = new Varien_Object(array(
43
+ 'code' => 'grand_total',
44
+ 'strong' => true,
45
+ 'value' => $this->getSource()->getGrandTotal() +$fee,
46
+ 'base_value'=> $this->getSource()->getBaseGrandTotal() +$fee,
47
+ 'label' => $this->helper('sales')->__('Grand Total'),
48
+ 'area' => 'footer'
49
+ ));
50
+
51
+ // $this->setGrandTotal($this->getGrandTotal() + 20);
52
+ return $this;
53
+ }
54
+
55
+ }
app/code/community/BeezUp/Block/Adminhtml/Sales/Order/View/Tab/Custom.php ADDED
@@ -0,0 +1,36 @@
1
+ <?php
2
+ ///app/design/adminhtml/default/default/layout/ beezup_salestab.xml
3
+ //app\design\adminhtml\default\default\template/beezup/custom.phtml
4
+ class BeezUp_Block_Adminhtml_Sales_Order_View_Tab_Custom
5
+ extends Mage_Adminhtml_Block_Template
6
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
7
+ {
8
+ protected $_chat = null;
9
+
10
+ protected function _construct()
11
+ {
12
+ parent::_construct();
13
+ $this->setTemplate('beezup/custom.phtml');
14
+ }
15
+
16
+ public function getTabLabel() {
17
+ return $this->__('BeezUP Info');
18
+ }
19
+
20
+ public function getTabTitle() {
21
+ return $this->__('BeezUP Info');
22
+ }
23
+
24
+ public function canShowTab() {
25
+ return true;
26
+ }
27
+
28
+ public function isHidden() {
29
+ return false;
30
+ }
31
+
32
+ public function getOrder(){
33
+ return Mage::registry('current_order');
34
+ }
35
+
36
+ }
app/code/community/BeezUp/Block/Adminhtml/System/Config/Attributes.php ADDED
@@ -0,0 +1,166 @@
1
+ <?php
2
+ class Beezup_Block_Adminhtml_System_Config_Attributes extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
3
+ {
4
+
5
+ protected $_addRowButtonHtml = array();
6
+ protected $_removeRowButtonHtml = array();
7
+
8
+ /**
9
+ * Returns html part of the setting
10
+ *
11
+ * @param Varien_Data_Form_Element_Abstract $element
12
+ * @return string
13
+ */
14
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
15
+ {
16
+
17
+
18
+
19
+ $this->setElement($element);
20
+
21
+
22
+ $repository = new BeezupRepository();
23
+ $stores = $repository->getStores();
24
+ $inc = 0;
25
+ $html = '';
26
+ foreach ($stores as $_eachStoreId => $val)
27
+ {
28
+ $html .= '<div id="attributes_template'.$inc.'" style="display:none">';
29
+ $html .= $this->_getRowTemplateHtml($_eachStoreId);
30
+ $html .= '</div>';
31
+ $html .= "<li style='margin-top:20px;'>".$val."</li>";
32
+ $html .= '<ul id="attributes_container'.$inc.'" >';
33
+ if ($this->_getValue('attributes/'.$_eachStoreId)) {
34
+ foreach ($this->_getValue('attributes/'.$_eachStoreId) as $i => $f) {
35
+ if ($i) {
36
+
37
+
38
+ $html .= $this->_getRowTemplateHtml($_eachStoreId, $i, $inc);
39
+
40
+ }
41
+ }
42
+ }
43
+ $html .= '</ul>';
44
+ $html .= $this->_getAddRowButtonHtml('attributes_container'.$inc,
45
+ 'attributes_template'.$inc, $this->__('Add New Attribute'));
46
+ $inc++; }
47
+
48
+
49
+ return $html;
50
+
51
+ }
52
+
53
+ /**
54
+ * Retrieve html template for setting
55
+ *
56
+ * @param int $rowIndex
57
+ * @return string
58
+ */
59
+ protected function _getRowTemplateHtml($storeid = "", $rowIndex = 0)
60
+ {
61
+ $html = '<li>';
62
+
63
+ $html .= '<div style="margin:5px 0 10px;">';
64
+
65
+ $attributes = $this->_getAttributes();
66
+
67
+ $html .= '<select style="width:70%;" name="'
68
+ . $this->getElement()->getName() . '[attributes]['.$storeid.'][]" '. $this->_getDisabled() . '/> ';
69
+
70
+ foreach ($attributes as $attribute){
71
+
72
+ IF($attribute['label']!=="" && !empty($attribute['label'])) {
73
+ $selected = "";
74
+
75
+ $datos = $this->_getValue('attributes/'.$storeid."/" . $rowIndex);
76
+ $data = explode("|" ,$datos);
77
+ $inc = 0;
78
+
79
+ if( $data[0]== $attribute['code'] && $data[1]==$storeid) {
80
+ $selected = "selected";
81
+ }
82
+
83
+ $html .= "<option value='".$attribute['code']."|".$storeid."' ".$selected.">".$attribute['label']."</option>";
84
+
85
+ }
86
+
87
+ }
88
+
89
+ $html .= "</select>";
90
+ $html .= $this->_getRemoveRowButtonHtml();
91
+ $html .= '</div>';
92
+ $html .= '</li>';
93
+
94
+ return $html;
95
+ }
96
+
97
+ public function _getAttributes() {
98
+ $atributos = array();
99
+ $attributes = Mage::getResourceModel('catalog/product_attribute_collection')
100
+ ->getItems();
101
+ foreach ($attributes as $attribute){
102
+
103
+ $atributos[] = array("code" => $attribute->getAttributecode(), "label" =>$attribute->getFrontendLabel()) ;
104
+
105
+
106
+
107
+ }
108
+
109
+ foreach ($atributos as $key => $att) {
110
+ if($att['code'] == "sku") {
111
+ unset($atributos[$key]); // unset the $array with id $id
112
+ array_unshift($atributos, $att); // unshift the array with $val to push in the beginning of array
113
+
114
+
115
+ // $atributos = array_merge(array($key => $att), $atributos);
116
+ }
117
+ }
118
+
119
+ return $atributos;
120
+ }
121
+
122
+
123
+ protected function _getDisabled()
124
+ {
125
+ return $this->getElement()->getDisabled() ? ' disabled' : '';
126
+ }
127
+
128
+ protected function _getValue($key)
129
+ {
130
+ return $this->getElement()->getData('value/' . $key);
131
+ }
132
+
133
+ protected function _getSelected($key, $value)
134
+ {
135
+ return $this->getElement()->getData('value/' . $key) == $value ? 'selected="selected"' : '';
136
+ }
137
+
138
+ protected function _getAddRowButtonHtml($container, $template, $title='Add')
139
+ {
140
+ if (!isset($this->_addRowButtonHtml[$container])) {
141
+ $this->_addRowButtonHtml[$container] = $this->getLayout()->createBlock('adminhtml/widget_button')
142
+ ->setType('button')
143
+ ->setClass('add ' . $this->_getDisabled())
144
+ ->setLabel($this->__($title))
145
+ ->setOnClick("Element.insert($('" . $container . "'), {bottom: $('" . $template . "').innerHTML})")
146
+ ->setDisabled($this->_getDisabled())
147
+ ->toHtml();
148
+ }
149
+ return $this->_addRowButtonHtml[$container];
150
+ }
151
+
152
+ protected function _getRemoveRowButtonHtml($selector = 'li', $title = 'Delete')
153
+ {
154
+ if (!$this->_removeRowButtonHtml) {
155
+ $this->_removeRowButtonHtml = $this->getLayout()->createBlock('adminhtml/widget_button')
156
+ ->setType('button')
157
+ ->setClass('delete v-middle ' . $this->_getDisabled())
158
+ ->setLabel($this->__($title))
159
+ ->setOnClick("Element.remove($(this).up('" . $selector . "'))")
160
+ ->setDisabled($this->_getDisabled())
161
+ ->toHtml();
162
+ }
163
+ return $this->_removeRowButtonHtml;
164
+ }
165
+
166
+ }
app/code/community/BeezUp/Block/Adminhtml/System/Config/Button.php ADDED
@@ -0,0 +1,56 @@
1
+ <?php
2
+ class Beezup_Block_Adminhtml_System_Config_Button extends Mage_Adminhtml_Block_System_Config_Form_Field
3
+ {
4
+
5
+ protected function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->setTemplate('beezup/system/config/button.phtml');
9
+ }
10
+
11
+ /**
12
+ * Return element html
13
+ *
14
+ * @param Varien_Data_Form_Element_Abstract $element
15
+ * @return string
16
+ */
17
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
18
+ {
19
+
20
+ return $this->_toHtml();
21
+ }
22
+
23
+ /**
24
+ * Return ajax url for button
25
+ *
26
+ * @return string
27
+ */
28
+ public function getAjaxCheckUrl()
29
+ {
30
+ return Mage::helper('adminhtml')->getUrl('adminhtml/adminhtml_beezup/check');
31
+ }
32
+
33
+ /**
34
+ * Generate button html
35
+ *
36
+ * @return string
37
+ */
38
+ public function getButtonHtml()
39
+ {
40
+ $button = $this->getLayout()->createBlock('adminhtml/widget_button')
41
+ ->setData(array(
42
+ 'id' => 'atwixtweaks_button',
43
+ 'label' => $this->helper('adminhtml')->__('Check'),
44
+ 'onclick' => 'javascript:check(); return false;'
45
+ ));
46
+
47
+ return $button->toHtml();
48
+ }
49
+
50
+
51
+
52
+
53
+
54
+ }
55
+
56
+
app/code/community/BeezUp/Block/Adminhtml/System/Config/Childgroup.php ADDED
@@ -0,0 +1,33 @@
1
+ <?php
2
+
3
+ class Beezup_Block_Adminhtml_System_Config_Childgroup extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+
6
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
7
+ {
8
+ $this->setElement($element);
9
+ $html = "<style>#row_".$this->getElement()->getId()." {
10
+ background:#6F8992;
11
+ }
12
+ #row_".$this->getElement()->getId()." td label {
13
+ color:white;
14
+ }
15
+ #row_".$this->getElement()->getId()." td .scope-label {
16
+ display:none;
17
+ }
18
+ #beezup_marketplace table {margin-top: -30px;}
19
+ </style>
20
+ <script>
21
+ var theParent = document.getElementById('row_".$this->getElement()->getId()."');
22
+ var table_row = document.createElement('tr');
23
+ table_row.innerHTML = '<td style=\'height:25px;\'></td>';
24
+ theParent.parentNode.insertBefore(table_row, theParent);
25
+
26
+ </script>
27
+ ";
28
+ return $html;
29
+
30
+ }
31
+
32
+
33
+ }
app/code/community/BeezUp/Block/Adminhtml/System/Config/Credentials.php ADDED
@@ -0,0 +1,48 @@
1
+ <?php
2
+
3
+ class Beezup_Block_Adminhtml_System_Config_Credentials extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+
6
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
7
+ {
8
+ $this->setElement($element);
9
+ $helper = Mage::helper('beezup');
10
+ $status = $helper->getConfig('beezup/marketplace/connection_status');
11
+ $lang = $this->__("NOT OK");
12
+ $color = "red";
13
+ $width = "45px";
14
+ $css_style = "";
15
+ if( $this->getElement()->getValue() == 1) {
16
+ $lang = $this->__("OK");
17
+ $color = "green";
18
+ $width = "18px";
19
+ } else {
20
+ $css_style = '<style>#row_beezup_marketplace_cron_call,
21
+ #row_beezup_marketplace_cron_url,
22
+ #row_beezup_marketplace_sync_status,
23
+ #row_beezup_marketplace_status_mapping,
24
+ #row_beezup_marketplace_status_new,
25
+ #row_beezup_marketplace_status_progress,
26
+ #row_beezup_marketplace_status_closed,
27
+ #row_beezup_marketplace_status_aborted,
28
+ #row_beezup_marketplace_status_shipped,
29
+ #row_beezup_marketplace_status_cancelled,
30
+ #row_beezup_marketplace_stores_mapping,
31
+ #row_beezup_marketplace_stores,
32
+ #row_beezup_marketplace_field_mapping,
33
+ #row_beezup_marketplace_attributes,
34
+ #row_beezup_marketplace_log_block,
35
+ #row_beezup_marketplace_log,
36
+ #marketPlaceLogBlock {
37
+ display:none;
38
+ }</style>';
39
+
40
+ }
41
+
42
+ return $css_style."<div style='width:". $width.";padding:7px;height:17px;border-radius:6px;cursor:pointer;background:".$color."; color:white;'>".$lang."</div><input id='".$this->getElement()->getId() ."' type='hidden' name='".$this->getElement()->getName() ."' value='". $this->getElement()->getValue()."' />";
43
+
44
+ }
45
+
46
+
47
+
48
+ }
app/code/community/BeezUp/Block/Adminhtml/System/Config/Cron.php ADDED
@@ -0,0 +1,16 @@
1
+ <?php
2
+
3
+ class Beezup_Block_Adminhtml_System_Config_Cron extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+
6
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
7
+ {
8
+ $sPhpBinary = defined('PHP_BINARY') ? PHP_BINARY : PHP_BINDIR;
9
+ $sPhpExecutable = ($sPhpBinary ? rtrim($sPhpBinary, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR : '' ) . 'php' . (DIRECTORY_SEPARATOR == '\\' ? '.exe' : '');
10
+ return "<p style='width:550px;background: #EFECEC;'><code>".sprintf('*/10 * * * * %s %s', $sPhpExecutable, Mage::getStoreConfig(Mage_Core_Model_Url::XML_PATH_SECURE_URL) . 'beezup/cron/execute')."</code></p>";
11
+
12
+ }
13
+
14
+
15
+
16
+ }
app/code/community/BeezUp/Block/Adminhtml/System/Config/Filter.php ADDED
@@ -0,0 +1,163 @@
1
+ <?php
2
+ class Beezup_Block_Adminhtml_System_Config_Filter extends Mage_Adminhtml_Block_System_Config_Form_Field
3
+ {
4
+ /*
5
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
6
+ {
7
+ $helper = Mage::helper('beezup');
8
+ $token = $helper->getConfig('beezup/marketplace/usertoken');
9
+ if($token == 2) {
10
+ return "Hola Mundo";
11
+ } else {
12
+ return "<style>#row_beezup_marketplace_new_value {display:none;}</style>";
13
+ }
14
+ $date = new Varien_Data_Form_Element_Date;
15
+ $format = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
16
+
17
+ $data = array(
18
+ 'name' => $element->getName(),
19
+ 'html_id' => $element->getId(),
20
+ 'image' => $this->getSkinUrl('images/grid-cal.gif'),
21
+ );
22
+ $date->setData($data);
23
+ $date->setValue($element->getValue(), $format);
24
+ $date->setFormat(Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT));
25
+ $date->setClass($element->getFieldConfig()->validate->asArray());
26
+ $date->setForm($element->getForm());
27
+
28
+ return $date->getElementHtml();
29
+ }
30
+ */
31
+
32
+
33
+ protected $_addRowButtonHtml = array();
34
+ protected $_removeRowButtonHtml = array();
35
+
36
+ /**
37
+ * Returns html part of the setting
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
+
45
+ $helper = Mage::helper('beezup');
46
+ $token = $helper->getConfig('beezup/marketplace/usertoken');
47
+ if(!empty($token)) {
48
+ return "<style>#row_".$element->getId()." {display:none;}</style>";
49
+ } else {
50
+
51
+
52
+
53
+ $this->setElement($element);
54
+
55
+ $html = '<div id="emailblocker_addresses_template" style="display:none">';
56
+ $html .= $this->_getRowTemplateHtml();
57
+ $html .= '</div>';
58
+
59
+ $html .= '<ul id="emailblocker_addresses_container">';
60
+ if ($this->_getValue('addresses')) {
61
+ foreach ($this->_getValue('addresses') as $i => $f) {
62
+ if ($i) {
63
+ $html .= $this->_getRowTemplateHtml($i);
64
+ }
65
+ }
66
+ }
67
+ $html .= '</ul>';
68
+ $html .= $this->_getAddRowButtonHtml('emailblocker_addresses_container',
69
+ 'emailblocker_addresses_template', $this->__('Add New Attribute'));
70
+
71
+ return $html;
72
+ }
73
+ }
74
+
75
+ /**
76
+ * Retrieve html template for setting
77
+ *
78
+ * @param int $rowIndex
79
+ * @return string
80
+ */
81
+ protected function _getRowTemplateHtml($rowIndex = 0)
82
+ {
83
+ $html = '<li>';
84
+
85
+ $html .= '<div style="margin:5px 0 10px;">';
86
+
87
+ $attributes = Mage::getResourceModel('catalog/product_attribute_collection')
88
+ ->getItems();
89
+ // $html .= '<select style="width:100px;" name="'
90
+ // . $this->getElement()->getName() . '[addresses][]" value="'
91
+ // . $this->_getValue('addresses/' . $rowIndex) . '" ' . $this->_getDisabled() . '/> ';
92
+
93
+ $html .= '<select style="width:70%;" name="'
94
+ . $this->getElement()->getName() . '[addresses][]" '. $this->_getDisabled() . '/> ';
95
+
96
+ foreach ($attributes as $attribute){
97
+ $selected = "";
98
+ if(!empty($attribute->getFrontendLabel()) && $attribute->getFrontendLabel() !== "") {
99
+ if($this->_getValue('addresses/' . $rowIndex) == $attribute->getAttributecode()) {
100
+ $selected = "selected";
101
+ }
102
+ $html .= "<option value='".$attribute->getAttributecode()."' ".$selected.">".$attribute->getFrontendLabel()."</option>";
103
+ }
104
+ // echo $attribute->getAttributecode();
105
+
106
+ // echo $attribute->getFrontendLabel();
107
+ }
108
+
109
+ $html .= "</select>";
110
+ $html .= $this->_getRemoveRowButtonHtml();
111
+ $html .= '</div>';
112
+ $html .= '</li>';
113
+
114
+ return $html;
115
+ }
116
+
117
+ protected function _getDisabled()
118
+ {
119
+ return $this->getElement()->getDisabled() ? ' disabled' : '';
120
+ }
121
+
122
+ protected function _getValue($key)
123
+ {
124
+ return $this->getElement()->getData('value/' . $key);
125
+ }
126
+
127
+ protected function _getSelected($key, $value)
128
+ {
129
+ return $this->getElement()->getData('value/' . $key) == $value ? 'selected="selected"' : '';
130
+ }
131
+
132
+ protected function _getAddRowButtonHtml($container, $template, $title='Add')
133
+ {
134
+ if (!isset($this->_addRowButtonHtml[$container])) {
135
+ $this->_addRowButtonHtml[$container] = $this->getLayout()->createBlock('adminhtml/widget_button')
136
+ ->setType('button')
137
+ ->setClass('add ' . $this->_getDisabled())
138
+ ->setLabel($this->__($title))
139
+ ->setOnClick("Element.insert($('" . $container . "'), {bottom: $('" . $template . "').innerHTML})")
140
+ ->setDisabled($this->_getDisabled())
141
+ ->toHtml();
142
+ }
143
+ return $this->_addRowButtonHtml[$container];
144
+ }
145
+
146
+ protected function _getRemoveRowButtonHtml($selector = 'li', $title = 'Delete')
147
+ {
148
+ if (!$this->_removeRowButtonHtml) {
149
+ $this->_removeRowButtonHtml = $this->getLayout()->createBlock('adminhtml/widget_button')
150
+ ->setType('button')
151
+ ->setClass('delete v-middle ' . $this->_getDisabled())
152
+ ->setLabel($this->__($title))
153
+ ->setOnClick("Element.remove($(this).up('" . $selector . "'))")
154
+ ->setDisabled($this->_getDisabled())
155
+ ->toHtml();
156
+ }
157
+ return $this->_removeRowButtonHtml;
158
+ }
159
+
160
+
161
+ }
162
+
163
+
app/code/community/BeezUp/Block/Adminhtml/System/Config/Log.php ADDED
@@ -0,0 +1,65 @@
1
+ <?php
2
+
3
+ class Beezup_Block_Adminhtml_System_Config_Log extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+
6
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
7
+ {
8
+
9
+ $logDir = Mage::getModuleDir('', 'BeezUp')."/log/";
10
+ // $log1 = file_get_contents();
11
+ $ret = array();
12
+ if (file_exists($logDir."/log.txt")) {
13
+ $f = fopen($logDir."/log.txt", 'r');
14
+
15
+ if ($f) {
16
+ while (!feof($f)) {
17
+ $ret[] = fgetcsv($f, 0, '|');
18
+ }
19
+ fclose($f);
20
+ }
21
+ }
22
+ array_slice(array_reverse($ret), 1, 10);
23
+
24
+ return $this->_getTable($ret);
25
+
26
+ }
27
+
28
+
29
+ public function _getTable($data) {
30
+ $url = Mage::getBaseUrl( Mage_Core_Model_Store::URL_TYPE_WEB, true );
31
+ $html = "<td></td><td></td><tr></tr></tbody></table>
32
+
33
+ <div class='grid' style=' height: 400px;overflow-y: scroll;padding: 16px;border: 3px solid #e6e6e6;' id='marketPlaceLogBlock'>";
34
+ $html .= '<p>'. Mage::helper('beezup')->__('For full logs see here:').' <a href="'.$url .'beezup/log/load" target="_blank">'.$url .'beezup/log/load</a></p>';
35
+ $html .= "<table class='data' style='margin-top:0px;'>";
36
+ $html .= "<tr class='headings'>";
37
+ $html .= '<th><span class="nobr">Time</span></th>';
38
+ $html .= '<th><span class="nobr">Type</span></th>';
39
+ $html .= '<th><span class="nobr">Order Id</span></th>';
40
+ $html .= '<th><span class="nobr">Message</span></th>';
41
+ $html .= "</tr>";
42
+ $html .= "<tbody>";
43
+ foreach($data as $d) {
44
+ $background = " background: rgb(240, 184, 184)";
45
+ if($d[1] == " INFO " ) {
46
+ $background = " background: rgb(210, 227, 253)";
47
+ }
48
+ $orderId = (isset($d[3])) ? $d[2] : "";
49
+ $message = (isset($d[3])) ? $d[3] : $d[2];
50
+ $html .= "<tr class='even pointer' style='".$background."'>";
51
+ $html .= "<td>".$d[0]."</td>";
52
+ $html .= "<td>".$d[1]."</td>";
53
+ $html .= "<td>".$orderId."</td>";
54
+ $html .= "<td>".$message."</td>";
55
+ $html .= "</tr>";
56
+
57
+ }
58
+
59
+ $html .= "<tbody>";
60
+ $html .= '</table>';
61
+ $html .= "</div>";
62
+
63
+ return $html;
64
+ }
65
+ }
app/code/community/BeezUp/Block/Adminhtml/System/Config/Manualcron.php ADDED
@@ -0,0 +1,14 @@
1
+ <?php
2
+
3
+ class Beezup_Block_Adminhtml_System_Config_Manualcron extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+
6
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
7
+ {
8
+ $url = Mage::getStoreConfig(Mage_Core_Model_Url::XML_PATH_SECURE_URL) . 'beezup/cron/execute';
9
+ return "<a href='".$url."' target='_blank'>".$url."</a>";
10
+ }
11
+
12
+
13
+
14
+ }
app/code/community/BeezUp/Block/Adminhtml/System/Config/Stores.php ADDED
@@ -0,0 +1,69 @@
1
+ <?php
2
+ require_once dirname ( __FILE__ ) . "/../../../../lib/bootstrap.php";
3
+ require_once dirname ( __FILE__ ) . "/../../../../lib/BeezupRepository.php";
4
+ class Beezup_Block_Adminhtml_System_Config_Stores extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
5
+ {
6
+
7
+
8
+
9
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
10
+ {
11
+ $this->setElement($element);
12
+ $html = "<div id='".$this->getElement()->getId()."'>";
13
+ $repository = new BeezupRepository();
14
+ $stores = $repository->getStores();
15
+ $i = 0;
16
+ foreach ($stores as $_eachStoreId => $val)
17
+ {
18
+ $html .= '<li>';
19
+ $html .= '<div style="margin:5px 0 10px;">';
20
+
21
+ $html .= "<label>".$val."</label>";
22
+ $html .= $this->_getBeezupStores( $_eachStoreId,$i);
23
+ $html .= '</div>';
24
+ $html .= '</li>';
25
+ $i++;
26
+ }
27
+ $html .= "</div>";
28
+ return $html;
29
+
30
+
31
+ }
32
+
33
+
34
+ protected function _getBeezupStores($bzupStore, $rowIndex =0)
35
+ {
36
+ $html = "";
37
+
38
+ $allStores = Mage::app()->getStores();
39
+ $html .= '<select style="width:100%;" name="'.$this->getElement()->getName() . '[stores]['.$bzupStore.']" /> ';
40
+ $html .= "<option value='0'>".$this->__("Select Value...")."</option>";
41
+ foreach($allStores as $key => $store) {
42
+ $selected = "";
43
+ $_storeName = Mage::app()->getStore($key)->getName();
44
+ $_storeId = Mage::app()->getStore($key)->getId();
45
+ $value = $this->_getValue('stores/' . $bzupStore);
46
+ if($value ==$_storeId) {
47
+ $selected = "selected";
48
+ }
49
+ $html .= "<option value='".$_storeId."' ".$selected.">".$_storeName."</option>";
50
+ }
51
+
52
+
53
+ $html .= "</select>";
54
+ $html .= '</div>';
55
+ $html .= '</li>';
56
+
57
+ return $html;
58
+ }
59
+
60
+ protected function _getValue($key)
61
+ {
62
+ return $this->getElement()->getData('value/' . $key);
63
+ }
64
+
65
+
66
+
67
+
68
+
69
+ }
app/code/community/BeezUp/Block/Adminhtml/System/Config/Syncstatus.php ADDED
@@ -0,0 +1,26 @@
1
+ <?php
2
+
3
+ class Beezup_Block_Adminhtml_System_Config_Syncstatus extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+
6
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
7
+ {
8
+ $this->setElement($element);
9
+ $helper = Mage::helper('beezup');
10
+ $status = $helper->getConfig('beezup/marketplace/connection_status');
11
+ $lang = $this->__("Not Syncing");
12
+ $color = "#666";
13
+ $width = "67px";
14
+ if( $this->getElement()->getValue() == 1) {
15
+ $lang = $this->__("Syncing");
16
+ $color = "green";
17
+ $width = "45px";
18
+ }
19
+
20
+ return "<div style='width:". $width.";padding:7px;height:17px;border-radius:6px;cursor:pointer;background:".$color."; color:white;'>".$lang."</div><input id='".$this->getElement()->getId() ."' type='hidden' name='".$this->getElement()->getName() ."' value='". $this->getElement()->getValue()."' />";
21
+
22
+ }
23
+
24
+
25
+
26
+ }
app/code/community/BeezUp/Block/Adminhtml/System/Config/Time.php ADDED
@@ -0,0 +1,24 @@
1
+ <?php
2
+
3
+ class Beezup_Block_Adminhtml_System_Config_Time extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+
6
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
7
+ {
8
+ $this->setElement($element);
9
+ $html = gmdate("Y-m-d H:i:s", $this->getElement()->getValue())." (UTC Time) <a class='form-button' style='padding:5px;margin-left:10px;'onclick='showInput()'>".$this->__("Change")."</a><br>";
10
+ $html .= "<input type='text' class='input-text' style='margin-top:7px;display:none;' id='".$this->getElement()->getId()."' name='".$this->getElement()->getName()."' value='".gmdate("Y-m-d H:i:s", $this->getElement()->getValue())."'/>";
11
+ $html .= '<script>
12
+ function showInput() {
13
+ var contentId = document.getElementById("'.$this->getElement()->getId().'");
14
+ contentId.style.display == "block" ? contentId.style.display = "none" :
15
+ contentId.style.display = "block";
16
+ }
17
+ </script>
18
+ ';
19
+ return $html;
20
+ }
21
+
22
+
23
+
24
+ }
app/code/community/BeezUp/Block/Order.php ADDED
@@ -0,0 +1,1143 @@
1
+ <?php
2
+ require_once dirname ( __FILE__ ) . "/../lib/KLogger.php";
3
+ require_once dirname ( __FILE__ ) . "/../lib/bootstrap.php";
4
+ require_once dirname ( __FILE__ ) . "/../lib/BeezupRepository.php";
5
+ require_once dirname ( __FILE__ ) . "/../lib/BeezupMageOrders.php";
6
+
7
+ class Beezup_Block_Order extends Mage_core_block_text {
8
+
9
+ protected $repository = null;
10
+ protected $oOrderService;
11
+ public $log = null;
12
+ public $log2 = null;
13
+ public $orderid = "";
14
+ public $debug = false;
15
+ public function executeCron() {
16
+
17
+
18
+
19
+ set_time_limit(0);
20
+ $logDir = Mage::getModuleDir('', 'BeezUp')."/log/";
21
+ if(file_exists($logDir."log2.txt")) {
22
+ if(filesize($logDir."/log2.txt") >=3000000) {
23
+ unlink($logDir."log2.txt");
24
+ }
25
+ }
26
+
27
+ $sync_end_date = new DateTime ( 'now', new DateTimeZone ( 'UTC' ));
28
+ $helper = Mage::helper('beezup');
29
+ $sync_status = $helper->getConfig('beezup/marketplace/sync_status');
30
+ $debug_mode = $helper->getConfig('beezup/marketplace/debug_mode');
31
+ if($debug_mode==1) {
32
+ $this->debug = true;
33
+ }
34
+
35
+ if($sync_status!==1) {
36
+ $configModel = Mage::getModel('core/config');
37
+ $configModel->saveConfig('beezup/marketplace/sync_status',1);
38
+
39
+
40
+
41
+ unlink($logDir."log.txt");
42
+ $this->log = new KLogger ( $logDir."log.txt" , KLogger::DEBUG );
43
+ $this->log2 = new KLogger ( $logDir."log2.txt" , KLogger::DEBUG );
44
+ $this->debugLog("Initializing OM Importation");
45
+ $shiiping_disabled = Mage::getStoreConfig('carriers/flatrate/active');
46
+ if($shiiping_disabled == 0) {
47
+ $this->enableFlatRate(true);
48
+ }
49
+ $this->getOrderList();
50
+ if($shiiping_disabled == 0) {
51
+ $this->enableFlatRate(false);
52
+ }
53
+ $this->repository->updateLastSynchronizationDate( $sync_end_date);
54
+ $this->orderid = "";
55
+ $this->debugLog("OM Importation finalized succesfully");
56
+ $configModel->saveConfig('beezup/marketplace/sync_status',0);
57
+ echo "OM Importation finalized succesfully";
58
+
59
+
60
+
61
+
62
+
63
+
64
+
65
+
66
+ } else {
67
+
68
+ echo "Order Importation is already being executed";
69
+ }
70
+
71
+ }
72
+
73
+
74
+ public function getLog() {
75
+ $logDir = Mage::getModuleDir('', 'BeezUp')."/log/";
76
+ $log1 = file_get_contents($logDir."/log2.txt");
77
+
78
+ echo "<pre>";
79
+ print_r($log1);
80
+ echo "</pre>";
81
+
82
+ }
83
+
84
+ public function getOrderList($orderList = null) {
85
+ if($orderList == null) {
86
+ $data = $this->createRepository()->createOrderListRequest();
87
+ $oRequest = $this->getOrderService()->getClientProxy()->getOrderList($data);
88
+ $orderList = $oRequest->getResult();
89
+ }
90
+ $oPagination = $orderList->getPaginationResult();
91
+ if(!empty($oPagination)) {
92
+ $oLinksTotal = $oPagination->getLinks();
93
+ } else {
94
+ $configModel = Mage::getModel('core/config');
95
+ $configModel->saveConfig('beezup/marketplace/sync_status',0);
96
+ die("No more orders to import");
97
+ }
98
+
99
+ //$header = $orderList->getOrderHeaders();
100
+ foreach($orderList->getOrderHeaders() as $order) {
101
+
102
+
103
+ $order_status = $order->getBeezupOrderState();
104
+ $orderLinks = $order->getLinks();
105
+ $etag = $order->getETag();
106
+ $beezup_order_id = $order->getBeezupOrderUUID();
107
+ // print_r($order);
108
+ // print_r($orderLinks[0]);
109
+ $account_id = $order->getAccountId();
110
+ $orderdata = $this->getOrderService()->getClientProxy()->getOrderByLink($orderLinks[0]);
111
+ $final_order = $orderdata->getResult();
112
+ // $order_items = $final_order->getOrderItems();
113
+ $marketplace_mod_date = $order->getMarketPlaceLastModificationUtcDate();
114
+ $purchase_date = $order->getPurchaseUtcDate();
115
+ $last_mod_date = $order->getLastModificationUtcDate();
116
+ $orderid = $final_order->getOrderMarketPlaceOrderId();
117
+ $this->orderid = $orderid;
118
+ //customer Info
119
+ $order_address = $final_order->getOrderBuyerAddressCity();
120
+ $order_country = $final_order->getOrderBuyerAddressCountryName();
121
+ $order_country_iso = $final_order->getOrderBuyerAddressCountryIsoCodeAlpha2();
122
+ $order_address = $this->getBeezupBuyerAddress($final_order);
123
+ $order_postalCode = $final_order->getOrderBuyerAddressPostalCode();
124
+ $order_customer = $final_order->getOrderBuyerName();
125
+ $order_customer_email = $final_order->getOrderBuyerEmail();
126
+ $order_customer_phone = $final_order->getOrderBuyerPhone();
127
+ $order_customer_mobile = $final_order->getOrderBuyerMobilePhone();
128
+ $order_comment = $final_order->getOrderComment();
129
+ $order_company = $final_order->getOrderBuyerCompanyName();
130
+ $order_city = $final_order->getOrderBuyerAddressCity();
131
+ $order_region = $final_order->getOrderBuyerStateOrRegion();
132
+
133
+ //shipping information
134
+ $shipping_city = $final_order->getOrderShippingAddressCity();
135
+ $shipping_country = $final_order->getOrderShippingAddressCountryName();
136
+ $shipping_country_iso = $final_order->getOrderShippingAddressCountryIsoCodeAlpha2();
137
+ $shipping_address = $this->getBeezupShippingAddress($final_order);
138
+ $shipping_name = $final_order->getOrderShippingAddressName();
139
+ $shipping_postalCode = $final_order->getOrderShippingAddressPostalCode();
140
+ $shipping_email = $final_order->getOrderShippingEmail();
141
+ $shipping_phone = $final_order->getOrderShippingPhone();
142
+ $shipping_mobile = $final_order->getOrderShippingMobilePhone();
143
+ $shipping_company = $final_order->getOrderShippingCompanyName();
144
+ $shipping_region = $final_order->getOrderShippingAddressStateOrRegion();
145
+ $order_currency_code = $final_order->getOrderCurrencyCode();
146
+ //order Info
147
+ $order_totalPrice = $final_order->getOrderTotalPrice();
148
+ $order_shippingPrice = $final_order->getOrderShippingPrice();
149
+
150
+ $name_parts = explode(" ", $order_customer);
151
+ $order_first_name = array_shift( $name_parts);
152
+ $order_last_name = implode(" ", $name_parts);
153
+
154
+
155
+ $name_parts = explode(" ", $shipping_name);
156
+ $shipping_first_name = array_shift( $name_parts);
157
+ $shipping_last_name = implode(" ", $name_parts);
158
+
159
+
160
+ //marketplace information
161
+ $marketplace_order_id = $order->getMarketPlaceOrderId();
162
+ $marketplace = $final_order->getMarketPlaceTechnicalCode();
163
+ $this->debugLog("Initializing Order - Link: ".$orderLinks[0]->getHref());
164
+ //productInfo
165
+ if(!$this->checkEtagExists($etag)) {
166
+
167
+ $mage_productIds = $this->prescanOrder($final_order);
168
+ if($mage_productIds) {
169
+ $order_data = array(
170
+ "etag" => $etag,
171
+ "account_id" => $account_id,
172
+ "marketplace_mod_date" => $marketplace_mod_date,
173
+ "purchase_date" => $purchase_date ,
174
+ "last_mod_date" => $last_mod_date ,
175
+ "beezup_order_id" => $beezup_order_id,
176
+ "order_status" => $order_status,
177
+ "products" => $mage_productIds['products'],
178
+ "storeid" => $mage_productIds['store'],
179
+ "order_currency" => $order_currency_code ,
180
+ "order_address" => $order_adress,
181
+ "order_country" => $order_country,
182
+ "order_country_iso" => $order_country_iso ,
183
+ "order_address" => $order_address ,
184
+ "order_postalCode" => $order_postalCode ,
185
+ "order_customer" => $order_first_name ,
186
+ "order_lastname" => $order_last_name ,
187
+ "order_customer_email" => $order_customer_email ,
188
+ "order_customer_phone" => $this->getPhone($order_customer_phone, $order_customer_mobile) ,
189
+ "order_comment" => $order_comment ,
190
+ "order_company" => $order_company ,
191
+ "shipping_city" => $shipping_city ,
192
+ "shipping_country" => $shipping_country ,
193
+ "shipping_country_iso" => $shipping_country_iso ,
194
+ "shipping_address" => $shipping_address ,
195
+ "shipping_name" => $shipping_first_name ,
196
+ "shipping_lastname" => $shipping_last_name ,
197
+ "shipping_postalCode" => $shipping_postalCode ,
198
+ "shipping_region" =>$shipping_region,
199
+ "shipping_email" => $shipping_email ,
200
+ "shipping_phone" => $this->getPhone($shipping_phone, $shipping_mobile) ,
201
+ "shipping_company" => $shipping_company ,
202
+ "order_totalPrice" => $order_totalPrice ,
203
+ "order_shippingPrice" => $order_shippingPrice ,
204
+ "order_city" => $order_city,
205
+ "order_region" => $order_region,
206
+ "marketplace_order_id" => $marketplace_order_id,
207
+ "marketplace" => $marketplace,
208
+ "discounts" => $mage_productIds['discounts']
209
+ );
210
+
211
+
212
+
213
+ //check if order exists
214
+ $Mageorder = $this->loadMageOrder();
215
+ if ($Mageorder) {
216
+ //if order exists
217
+ $this->updateEtag($etag);
218
+ $this->updateBilling($Mageorder, $order_data );
219
+ $this->updateBeezupInfoTab($Mageorder, $final_order, $order_data);
220
+ $this->debugLog("Order Already exists Mage Order ID: " .$Mageorder->getId());
221
+ $status1 = $Mageorder->getStatusLabel();
222
+ $status = $this->getStatus($status1);
223
+ if($status !== $order_status) {
224
+ //if order exits and status has changed we update order status
225
+ $this->debugLog("Updating Order Status from: ".$status1." to: ".$order_status );
226
+ $this->setStatus( $order_status, $Mageorder);
227
+ }
228
+
229
+ $id_order = $Mageorder->getId();
230
+ $BeezupMageOrder = new BeezupMageOrders($id_order);
231
+ $BeezupMageOrder->setData(array("shipping" =>(float) $order_data['order_shippingPrice']));
232
+ $BeezupMageOrder->updateShippingInfo();
233
+ } else {
234
+ //if not we create order
235
+
236
+
237
+ $this->debugLog("Generating Order");
238
+ $this->addOrder($order_data,$final_order );
239
+
240
+
241
+ }
242
+
243
+
244
+ } else {
245
+ //order could not be imported
246
+
247
+
248
+ }
249
+
250
+
251
+ } else {
252
+ //etag has not changed
253
+ $this->debugLog("Order Etag has not changed");
254
+
255
+ }
256
+
257
+ }
258
+
259
+ if(!empty($oLinksTotal)) {
260
+ //we check if there is next link and get next orders
261
+ foreach($oLinksTotal as $link) {
262
+ if( $link->getRel() == "next") {
263
+
264
+ $this->log->LogInfo("Initializing New Order List ->". $link->getHref());
265
+ $this->log2->LogInfo("Initializing New Order List ->". $link->getHref());
266
+ $oRequest = $this->getOrderService()->getClientProxy()->getOrderListByLink($link);
267
+ $orderList = $oRequest->getResult();
268
+ $this->getOrderList($orderList);
269
+ }
270
+
271
+ }
272
+
273
+
274
+
275
+ }
276
+
277
+
278
+ }
279
+
280
+ public function updateBeezupInfoTab($order, $oLink, $data) {
281
+ $beezup_last_modification_date = $oLink->getOrderLastModificationUtcDate();
282
+ $beezup_last_modification_date = $beezup_last_modification_date->date;
283
+ $beezup_marketplace_last_modification_date = $oLink->getOrderMarketPlaceLastModificationUtcDate();
284
+ $beezup_marketplace_last_modification_date = $beezup_marketplace_last_modification_date->date;
285
+ $beezup_comission = $oLink->getOrderTotalCommission()." ".$data['order_currency'];
286
+ $tot_comm = $oLink->getOrderTotalCommission();
287
+ if(empty($tot_comm ) || $tot_comm == 0) {
288
+ $beezup_comission = 0;
289
+ }
290
+ $updateData = array("beezup_status" => $data['order_status'],
291
+ "beezup_last_modification_date" => $beezup_last_modification_date,
292
+ "beezup_marketplace_last_modification_date" => $beezup_marketplace_last_modification_date ,
293
+ "beezup_total_paid" => $oLink->getOrderTotalPrice()." ".$data['order_currency'],
294
+ "beezup_comission" => $beezup_comission,
295
+ "beezup_marketplace_status" => $oLink->getOrderStatusMarketPlaceStatus());
296
+ $orderId = $order->getId();
297
+ $beezupMageOrder = new BeezupMageOrders($orderId);
298
+ $beezupMageOrder->setData($updateData);
299
+ $beezupMageOrder->updateBeezupInfo();
300
+
301
+
302
+ }
303
+
304
+ public function getPhone($phone, $phone2) {
305
+ $retorno = "";
306
+ if(!empty($phone) && $phone !== "") {
307
+ $retorno .= $phone;
308
+ }
309
+ if(!empty($phone2) && $phone2 !=="") {
310
+ if(empty($phone) || $phone == "") {
311
+ $retorno = $phone2;
312
+
313
+ } else {
314
+ $retorno .= " - ".$phone2;
315
+ }
316
+ }
317
+ return $retorno;
318
+ }
319
+
320
+
321
+ public function getBeezupBuyerAddress($order) {
322
+ $add1=$order->getOrderBuyerAddressLine1();
323
+ $add2=$order->getOrderBuyerAddressLine2();
324
+ $add3=$order->getOrderBuyerAddressLine3();
325
+ $retorno = "";
326
+ if(!empty($add1)) {
327
+ $retorno = $order->getOrderBuyerAddressLine1();
328
+ }
329
+ if(!empty($add2)) {
330
+ if(empty($add1)) {
331
+ $retorno .= $order->getOrderBuyerAddressLine2();
332
+ } else {
333
+ $retorno .= " - ". $order->getOrderBuyerAddressLine2();
334
+ }
335
+ }
336
+ if(!empty($add3)){
337
+ if(empty($add1) && empty($add2)) {
338
+ $retorno .= $order->getOrderBuyerAddressLine3();
339
+ } else {
340
+ $retorno .= " - ". $order->getOrderBuyerAddressLine3();
341
+ }
342
+ }
343
+ return $retorno;
344
+ }
345
+
346
+
347
+ public function getBeezupShippingAddress($order) {
348
+ $add1 = $order->getOrderShippingAddressLine1();
349
+ $add2 = $order->getOrderShippingAddressLine2();
350
+ $add3=$order->getOrderBuyerAddressLine3();
351
+ $retorno = "";
352
+ if(!empty($add1 )) {
353
+ $retorno = $order->getOrderShippingAddressLine1();
354
+ }
355
+ if(!empty($add2)) {
356
+ if(empty($add1)) {
357
+ $retorno .= $order->getOrderShippingAddressLine2();
358
+ } else {
359
+ $retorno .= " - ". $order->getOrderShippingAddressLine2();
360
+ }
361
+ }
362
+ if(!empty($add3)){
363
+ if(empty($add1) && empty($add2)) {
364
+ $retorno .= $order->getOrderShippingAddressLine3();
365
+ } else {
366
+ $retorno .= " - ". $order->getOrderShippingAddressLine3();
367
+ }
368
+ }
369
+ return $retorno;
370
+ }
371
+
372
+ public function checkEtagExists($etag) {
373
+ $resource = Mage::getSingleton('core/resource');
374
+ $readConnection = $resource->getConnection('core_read');
375
+ $table = $resource->getTableName('sales/order_grid');
376
+ $query = 'SELECT increment_id FROM ' . $table . ' WHERE beezup_etag = \''
377
+ . $etag . '\' LIMIT 1';
378
+ $order = $readConnection->fetchOne($query);
379
+ if($order && !empty($order)) {
380
+ return true;
381
+ }
382
+ return false;
383
+
384
+ }
385
+
386
+
387
+ public function updateEtag($etag) {
388
+ $this->debugLog("Updating Etag");
389
+ $resource = Mage::getSingleton('core/resource');
390
+ $writeConnection = $resource->getConnection('core_write');
391
+ $table = $resource->getTableName('sales/order_grid');
392
+ $query = "UPDATE {$table} SET beezup_etag = '{$etag}' where beezup_market_order_id = '{$this->orderid}' ";
393
+ $writeConnection->query($query);
394
+
395
+ }
396
+
397
+
398
+
399
+ public function updateBilling($order, $data) {
400
+
401
+
402
+ $addressData = array(
403
+ 'billing_firstname' => ($data['order_customer']) ? $data['order_customer'] : "empty",
404
+ 'billing_lastname' => ($data['order_lastname']) ? $data['order_lastname'] : "empty",
405
+ 'billing_street' => ($data['order_address']) ? $data['order_address'] : "empty",
406
+ 'billing_city' => ($data['order_city']) ? $data['order_city'] : "empty",
407
+ 'billing_postcode' => ($data['order_postalCode']) ? $data['order_postalCode'] : "empty",
408
+ 'billing_telephone' => ($data['order_customer_phone']) ? $data['order_customer_phone'] : "empty",
409
+ 'billing_country_id' => ($data['order_country_iso']) ? $data['order_country_iso'] : "empty",
410
+ 'billing_region_id' => ($data['order_region ']) ? substr($data['order_region '], 0,2) : "EM",
411
+ 'shipping_firstname' => ($data['shipping_name']) ? $data['shipping_name'] : "empty",
412
+ 'shipping_lastname' => ($data['shipping_lastname']) ? $data['shipping_lastname'] : "empty",
413 <