eBay_Enterprise_Affiliate_Extension - Version 1.2.0.1

Version Notes

Changelog for 1.2.0.1
Incorrect key "TOTALAMOUNT" no longer submitted with tracking pixel for a bundle item
Categories with an index out of scope no longer being included for a bundle item

Download this release

Release Info

Developer Philip Preston
Extension eBay_Enterprise_Affiliate_Extension
Version 1.2.0.1
Comparing to
See all releases


Code changes from version 1.2.0.0 to 1.2.0.1

app/code/community/EbayEnterprise/Affiliate/Block/Beacon.php CHANGED
@@ -1,321 +1,328 @@
1
- <?php
2
- /**
3
- * Copyright (c) 2014 eBay Enterprise, Inc.
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the eBay Enterprise
8
- * Magento Extensions End User License Agreement
9
- * that is bundled with this package in the file LICENSE.md.
10
- * It is also available through the world-wide-web at this URL:
11
- * http://www.ebayenterprise.com/files/pdf/Magento_Connect_Extensions_EULA_050714.pdf
12
- *
13
- * @copyright Copyright (c) 2014 eBay Enterprise, Inc. (http://www.ebayenterprise.com/)
14
- * @license http://www.ebayenterprise.com/files/pdf/Magento_Connect_Extensions_EULA_050714.pdf eBay Enterprise Magento Extensions End User License Agreement
15
- *
16
- */
17
-
18
- class EbayEnterprise_Affiliate_Block_Beacon extends Mage_Core_Block_Template
19
- {
20
- /**
21
- * The 'PID' beacon URL querystring key
22
- */
23
- const KEY_PID = 'PID';
24
-
25
- /**
26
- * The 'OID' beacon URL querystring key
27
- */
28
- const KEY_OID = 'OID';
29
-
30
- /**
31
- * The 'AMOUNT' beacon URL querystring key
32
- */
33
- const KEY_AMOUNT = 'AMOUNT';
34
-
35
- /**
36
- * The 'TYPE' beacon URL querystring key
37
- */
38
- const KEY_TYPE = 'TYPE';
39
-
40
- /**
41
- * The 'QTY' beacon URL querystring key
42
- */
43
- const KEY_QTY = 'QTY';
44
-
45
- /**
46
- * The 'TOTALAMOUNT' beacon URL querystring key
47
- */
48
- const KEY_TOTALAMOUNT = 'TOTALAMOUNT';
49
-
50
- /**
51
- * The 'INT' beacon URL querystring key
52
- */
53
- const KEY_INT = 'INT';
54
-
55
- /**
56
- * The 'ITEM' beacon URL querystring key
57
- */
58
- const KEY_ITEM = 'ITEM';
59
-
60
- /**
61
- * The 'PROMOCODE' beacon URL querystring key
62
- */
63
- const KEY_PROMOCODE = 'PROMOCODE';
64
-
65
- /**
66
- * Dynamic query keys
67
- */
68
- const KEY_DYNAMIC_PROGRAM_ID = 'PROGRAM_ID';
69
- const KEY_DYNAMIC_ORDER_ID = 'ORDER_ID';
70
- const KEY_DYNAMIC_ITEM_ID = 'ITEM_ID';
71
- const KEY_DYNAMIC_ITEM_PRICE = 'ITEM_PRICE';
72
- const KEY_DYNAMIC_QUANTITY = 'QUANTITY';
73
- const KEY_DYNAMIC_CATEGORY = 'CATEGORY';
74
- const KEY_DYNAMIC_NEW_TO_FILE = 'NEW_TO_FILE';
75
- const KEY_DYNAMIC_COUPON = 'COUPON';
76
-
77
- /**
78
- * @var Mage_Sales_Model_Order
79
- * @see self::_getOrder
80
- */
81
- protected $_order;
82
-
83
- /** @var EbayEnterprise_Affiliate_Helper_Data */
84
- protected $_helper = null;
85
-
86
- /** @var EbayEnterprise_Affiliate_Helper_Config */
87
- protected $_configHelper = null;
88
-
89
- /**
90
- * @return EbayEnterprise_Affiliate_Helper_Data
91
- */
92
- protected function _getHelper()
93
- {
94
- if (!$this->_helper) {
95
- $this->_helper = Mage::helper('eems_affiliate');
96
- }
97
-
98
- return $this->_helper;
99
- }
100
-
101
- /**
102
- * @return EbayEnterprise_Affiliate_Helper_Config
103
- */
104
- protected function _getConfigHelper()
105
- {
106
- if (!$this->_configHelper) {
107
- $this->_configHelper = Mage::helper('eems_affiliate/config');
108
- }
109
-
110
- return $this->_configHelper;
111
- }
112
-
113
- /**
114
- * Get the last order.
115
- * @return Mage_Sales_Model_Order | null
116
- */
117
- protected function _getOrder()
118
- {
119
- if (!($this->_order instanceof Mage_Sales_Model_Order)) {
120
- $orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
121
- if ($orderId) {
122
- $this->_order = Mage::getModel('sales/order')->load($orderId);
123
- }
124
- }
125
- return $this->_order;
126
- }
127
-
128
- /**
129
- * Get the beacon URL.
130
- * @return string | null
131
- */
132
- public function getBeaconUrl()
133
- {
134
- $order = $this->_getOrder();
135
-
136
- $url = null;
137
-
138
- if ($order instanceof Mage_Sales_Model_Order) {
139
- if (Mage::helper('eems_affiliate/config')->isItemizedOrders()) {
140
- $params = $this->_buildItemizedParams($order);
141
- } elseif (Mage::helper('eems_affiliate/config')->isDynamicOrders()) {
142
- $params = $this->_buildDynamicParams($order);
143
- } else {
144
- $params = $this->_buildBasicParams($order);
145
- }
146
-
147
- $url = Mage::helper('eems_affiliate')->buildBeaconUrl($params);
148
- }
149
- return $url;
150
- }
151
-
152
- /**
153
- * build common params array
154
- * @param Mage_Sales_Model_Order $order
155
- * @return array
156
- */
157
- protected function _buildCommonParams(Mage_Sales_Model_Order $order)
158
- {
159
- $params = array(
160
- static::KEY_PID => Mage::helper('eems_affiliate/config')->getProgramId(),
161
- static::KEY_OID => $order->getIncrementId(),
162
- );
163
- $couponCode = trim($order->getCouponCode());
164
- return ($couponCode !== '')?
165
- array_merge($params, array(static::KEY_PROMOCODE => $couponCode)) : $params;
166
- }
167
-
168
- /**
169
- * build basic params array for non itemized beacon URL
170
- * @param Mage_Sales_Model_Order $order
171
- * @return array
172
- */
173
- protected function _buildBasicParams(Mage_Sales_Model_Order $order)
174
- {
175
- $params = $this->_buildCommonParams($order);
176
- $params[static::KEY_AMOUNT] = number_format($order->getSubtotal() + $order->getDiscountAmount() + $order->getShippingDiscountAmount(), 2, '.', '');
177
- $params[static::KEY_TYPE] = Mage::helper('eems_affiliate/config')->getTransactionType();
178
-
179
- return $params;
180
- }
181
-
182
- /**
183
- * build itemized order params array for itemized beacon URL
184
- * @param Mage_Sales_Model_Order $order
185
- * @return array
186
- */
187
- protected function _buildItemizedParams(Mage_Sales_Model_Order $order)
188
- {
189
- $params = $this->_buildCommonParams($order);
190
- $params[static::KEY_INT] = Mage::helper('eems_affiliate/config')->getInt();
191
- $increment = 1; // incrementer for the unique item keys
192
- foreach ($order->getAllItems() as $item) {
193
- // need to ignore the bundle parent as it will contain collected total
194
- // for children but not discounts
195
- $position = $this->_getDupePosition($params, $item);
196
- // ignore the parent configurable quantity - quantity of config products
197
- // will come from the simple used product with the same SKU
198
- $quantity = $item->getProductType() === Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE ?
199
- 0 : (int) $item->getQtyOrdered();
200
- // consider parent bundle products to be 0.00 total - total of the bundle
201
- // is the sum of all child products which are also included in the beacon
202
- // so including both totals would effectively double the price of the bundle
203
- //
204
- // Divide discount amount by quantity to get per item discount
205
- $total = $item->getProductType() === Mage_Catalog_Model_Product_Type::TYPE_BUNDLE ?
206
- 0.00 : $item->getPrice() - ($item->getDiscountAmount() / $item->getQtyOrdered());
207
- if ($position) {
208
- // we detected that the current item already exist in the params array
209
- // and have the key increment position let's simply adjust
210
- // the qty and total amount
211
- $params[static::KEY_QTY . $position] += $quantity;
212
- $amtKey = static::KEY_TOTALAMOUNT . $position;
213
- $params[$amtKey] = number_format($params[$amtKey] + $total, 2, '.', '');
214
- } else {
215
- $params = array_merge($params, array(
216
- static::KEY_ITEM . $increment => $item->getSku(),
217
- static::KEY_QTY . $increment => $quantity,
218
- static::KEY_AMOUNT . $increment => number_format($total, 2, '.', ''),
219
- ));
220
- $increment++; // only get incremented when a unique key have been appended
221
- }
222
- }
223
- return $params;
224
- }
225
-
226
- /**
227
- * build dynamic order params array for dynamic beacon URL
228
- * @param Mage_Sales_Model_Order $order
229
- * @return array
230
- */
231
- protected function _buildDynamicParams(Mage_Sales_Model_Order $order)
232
- {
233
- $helper = Mage::helper('eems_affiliate');
234
-
235
- $params = $this->_buildItemizedParams($order);
236
-
237
- // Swap query key names for dynamic versions
238
- $params[self::KEY_DYNAMIC_PROGRAM_ID] = $params[self::KEY_PID];
239
- $params[self::KEY_DYNAMIC_ORDER_ID] = $params[self::KEY_OID];
240
- unset($params[self::KEY_PID]);
241
- unset($params[self::KEY_OID]);
242
- if (isset($params[self::KEY_PROMOCODE])) {
243
- $params[self::KEY_DYNAMIC_COUPON] = $params[self::KEY_PROMOCODE];
244
- unset($params[self::KEY_PROMOCODE]);
245
- }
246
-
247
- // See if email has any history
248
- $params[self::KEY_DYNAMIC_NEW_TO_FILE] = (int)$helper->isNewToFile($order);
249
-
250
- $productIds = array();
251
- foreach($order->getAllItems() as $item) {
252
- $productIds[] = $item->getProduct()->getId();
253
- }
254
-
255
- $productCollection = Mage::getModel('catalog/product')->getCollection()
256
- ->addAttributeToFilter('entity_id', array('in', $productIds))
257
- ->addCategoryIds();
258
-
259
- // No need for increment, all items are in param already
260
- foreach($order->getAllItems() as $item) {
261
- // Every item should be found here
262
- $position = $this->_getDupePosition($params, $item);
263
-
264
- // Add category IDs
265
- $product = $productCollection->getItemById($item->getProduct()->getId());
266
- $item->getProduct()->setCategoryIds($product->getCategoryIds());
267
-
268
- // Get item's category
269
- $params[self::KEY_DYNAMIC_CATEGORY . $position] = $helper->getCommissioningCategory($item);
270
-
271
- // Replace query string keys
272
- $params[self::KEY_DYNAMIC_ITEM_ID . $position] = $params[self::KEY_ITEM . $position];
273
- $params[self::KEY_DYNAMIC_ITEM_PRICE . $position] = $params[self::KEY_AMOUNT . $position];
274
- $params[self::KEY_DYNAMIC_QUANTITY . $position] = $params[self::KEY_QTY . $position];
275
- unset($params[self::KEY_ITEM . $position]);
276
- unset($params[self::KEY_AMOUNT . $position]);
277
- unset($params[self::KEY_QTY . $position]);
278
- }
279
-
280
- return $params;
281
- }
282
-
283
- /**
284
- * check if the current sku already exists in the params data if so return
285
- * the position it is found in
286
- * @param array $params the given array of keys needed to build the beacon URL querystring
287
- * @param Mage_Sales_Model_Order_Item $item
288
- * @return int the item position where dupe found otherwise zero
289
- */
290
- protected function _getDupePosition(array $params, Mage_Sales_Model_Order_Item $item)
291
- {
292
- $key = array_search($item->getSku(), $params, true);
293
- return ($key !== false)?
294
- (int) str_replace(static::KEY_ITEM, '', $key) : 0;
295
- }
296
-
297
- /**
298
- * Whether or not to display the beacon.
299
- *
300
- * Show the pixel only if tracking is enabled and we have a valid order
301
- * AND either conditional pixel logic is OFF or it is ON and we have
302
- * a valid cookie.
303
- *
304
- * @return bool
305
- */
306
- public function showBeacon()
307
- {
308
- $config = $this->_getConfigHelper();
309
-
310
- return (
311
- (
312
- $config->isEnabled() &&
313
- $this->_getOrder() instanceof Mage_Sales_Model_Order
314
- ) &&
315
- (
316
- $this->_getHelper()->isValidCookie() ||
317
- !$config->isConditionalPixelEnabled()
318
- )
319
- );
320
- }
321
- }
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright (c) 2014 eBay Enterprise, Inc.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the eBay Enterprise
8
+ * Magento Extensions End User License Agreement
9
+ * that is bundled with this package in the file LICENSE.md.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://www.ebayenterprise.com/files/pdf/Magento_Connect_Extensions_EULA_050714.pdf
12
+ *
13
+ * @copyright Copyright (c) 2014 eBay Enterprise, Inc. (http://www.ebayenterprise.com/)
14
+ * @license http://www.ebayenterprise.com/files/pdf/Magento_Connect_Extensions_EULA_050714.pdf eBay Enterprise Magento Extensions End User License Agreement
15
+ *
16
+ */
17
+
18
+ class EbayEnterprise_Affiliate_Block_Beacon extends Mage_Core_Block_Template
19
+ {
20
+ /**
21
+ * The 'PID' beacon URL querystring key
22
+ */
23
+ const KEY_PID = 'PID';
24
+
25
+ /**
26
+ * The 'OID' beacon URL querystring key
27
+ */
28
+ const KEY_OID = 'OID';
29
+
30
+ /**
31
+ * The 'AMOUNT' beacon URL querystring key
32
+ */
33
+ const KEY_AMOUNT = 'AMOUNT';
34
+
35
+ /**
36
+ * The 'TYPE' beacon URL querystring key
37
+ */
38
+ const KEY_TYPE = 'TYPE';
39
+
40
+ /**
41
+ * The 'QTY' beacon URL querystring key
42
+ */
43
+ const KEY_QTY = 'QTY';
44
+
45
+ /**
46
+ * The 'TOTALAMOUNT' beacon URL querystring key
47
+ */
48
+ const KEY_TOTALAMOUNT = 'TOTALAMOUNT';
49
+
50
+ /**
51
+ * The 'INT' beacon URL querystring key
52
+ */
53
+ const KEY_INT = 'INT';
54
+
55
+ /**
56
+ * The 'ITEM' beacon URL querystring key
57
+ */
58
+ const KEY_ITEM = 'ITEM';
59
+
60
+ /**
61
+ * The 'PROMOCODE' beacon URL querystring key
62
+ */
63
+ const KEY_PROMOCODE = 'PROMOCODE';
64
+
65
+ /**
66
+ * Dynamic query keys
67
+ */
68
+ const KEY_DYNAMIC_PROGRAM_ID = 'PROGRAM_ID';
69
+ const KEY_DYNAMIC_ORDER_ID = 'ORDER_ID';
70
+ const KEY_DYNAMIC_ITEM_ID = 'ITEM_ID';
71
+ const KEY_DYNAMIC_ITEM_PRICE = 'ITEM_PRICE';
72
+ const KEY_DYNAMIC_QUANTITY = 'QUANTITY';
73
+ const KEY_DYNAMIC_CATEGORY = 'CATEGORY';
74
+ const KEY_DYNAMIC_NEW_TO_FILE = 'NEW_TO_FILE';
75
+ const KEY_DYNAMIC_COUPON = 'COUPON';
76
+
77
+ /**
78
+ * @var Mage_Sales_Model_Order
79
+ * @see self::_getOrder
80
+ */
81
+ protected $_order;
82
+
83
+ /** @var EbayEnterprise_Affiliate_Helper_Data */
84
+ protected $_helper = null;
85
+
86
+ /** @var EbayEnterprise_Affiliate_Helper_Config */
87
+ protected $_configHelper = null;
88
+
89
+ /**
90
+ * @return EbayEnterprise_Affiliate_Helper_Data
91
+ */
92
+ protected function _getHelper()
93
+ {
94
+ if (!$this->_helper) {
95
+ $this->_helper = Mage::helper('eems_affiliate');
96
+ }
97
+
98
+ return $this->_helper;
99
+ }
100
+
101
+ /**
102
+ * @return EbayEnterprise_Affiliate_Helper_Config
103
+ */
104
+ protected function _getConfigHelper()
105
+ {
106
+ if (!$this->_configHelper) {
107
+ $this->_configHelper = Mage::helper('eems_affiliate/config');
108
+ }
109
+
110
+ return $this->_configHelper;
111
+ }
112
+
113
+ /**
114
+ * Get the last order.
115
+ * @return Mage_Sales_Model_Order | null
116
+ */
117
+ protected function _getOrder()
118
+ {
119
+ if (!($this->_order instanceof Mage_Sales_Model_Order)) {
120
+ $orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
121
+ if ($orderId) {
122
+ $this->_order = Mage::getModel('sales/order')->load($orderId);
123
+ }
124
+ }
125
+ return $this->_order;
126
+ }
127
+
128
+ /**
129
+ * Get the beacon URL.
130
+ * @return string | null
131
+ */
132
+ public function getBeaconUrl()
133
+ {
134
+ $order = $this->_getOrder();
135
+
136
+ $url = null;
137
+
138
+ if ($order instanceof Mage_Sales_Model_Order) {
139
+ if (Mage::helper('eems_affiliate/config')->isItemizedOrders()) {
140
+ $params = $this->_buildItemizedParams($order);
141
+ } elseif (Mage::helper('eems_affiliate/config')->isDynamicOrders()) {
142
+ $params = $this->_buildDynamicParams($order);
143
+ } else {
144
+ $params = $this->_buildBasicParams($order);
145
+ }
146
+
147
+ $url = Mage::helper('eems_affiliate')->buildBeaconUrl($params);
148
+ }
149
+ return $url;
150
+ }
151
+
152
+ /**
153
+ * build common params array
154
+ * @param Mage_Sales_Model_Order $order
155
+ * @return array
156
+ */
157
+ protected function _buildCommonParams(Mage_Sales_Model_Order $order)
158
+ {
159
+ $params = array(
160
+ static::KEY_PID => Mage::helper('eems_affiliate/config')->getProgramId(),
161
+ static::KEY_OID => $order->getIncrementId(),
162
+ );
163
+ $couponCode = trim($order->getCouponCode());
164
+ return ($couponCode !== '')?
165
+ array_merge($params, array(static::KEY_PROMOCODE => $couponCode)) : $params;
166
+ }
167
+
168
+ /**
169
+ * build basic params array for non itemized beacon URL
170
+ * @param Mage_Sales_Model_Order $order
171
+ * @return array
172
+ */
173
+ protected function _buildBasicParams(Mage_Sales_Model_Order $order)
174
+ {
175
+ $params = $this->_buildCommonParams($order);
176
+ $params[static::KEY_AMOUNT] = number_format($order->getSubtotal() + $order->getDiscountAmount() + $order->getShippingDiscountAmount(), 2, '.', '');
177
+ $params[static::KEY_TYPE] = Mage::helper('eems_affiliate/config')->getTransactionType();
178
+
179
+ return $params;
180
+ }
181
+
182
+ /**
183
+ * build itemized order params array for itemized beacon URL
184
+ * @param Mage_Sales_Model_Order $order
185
+ * @return array
186
+ */
187
+ protected function _buildItemizedParams(Mage_Sales_Model_Order $order)
188
+ {
189
+ $params = $this->_buildCommonParams($order);
190
+ $params[static::KEY_INT] = Mage::helper('eems_affiliate/config')->getInt();
191
+ $increment = 1; // incrementer for the unique item keys
192
+ foreach ($order->getAllItems() as $item) {
193
+ // need to ignore the bundle parent as it will contain collected total
194
+ // for children but not discounts
195
+ $position = $this->_getDupePosition($params, $item);
196
+ // ignore the parent configurable quantity - quantity of config products
197
+ // will come from the simple used product with the same SKU
198
+ $quantity = $item->getProductType() === Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE ?
199
+ 0 : (int) $item->getQtyOrdered();
200
+ // consider parent bundle products to be 0.00 total - total of the bundle
201
+ // is the sum of all child products which are also included in the beacon
202
+ // so including both totals would effectively double the price of the bundle
203
+ //
204
+ // Divide discount amount by quantity to get per item discount
205
+ $total = $item->getProductType() === Mage_Catalog_Model_Product_Type::TYPE_BUNDLE ?
206
+ 0.00 : $item->getPrice() - ($item->getDiscountAmount() / $item->getQtyOrdered());
207
+ if ($position) {
208
+ // we detected that the current item already exist in the params array
209
+ // and have the key increment position let's simply adjust
210
+ // the qty and total amount
211
+ $params[static::KEY_QTY . $position] += $quantity;
212
+ $amtKey = static::KEY_AMOUNT . $position;
213
+ $params[$amtKey] = number_format($params[$amtKey] + $total, 2, '.', '');
214
+ } else {
215
+ $params = array_merge($params, array(
216
+ static::KEY_ITEM . $increment => $item->getSku(),
217
+ static::KEY_QTY . $increment => $quantity,
218
+ static::KEY_AMOUNT . $increment => number_format($total, 2, '.', ''),
219
+ ));
220
+ $increment++; // only get incremented when a unique key have been appended
221
+ }
222
+ }
223
+ return $params;
224
+ }
225
+
226
+ /**
227
+ * build dynamic order params array for dynamic beacon URL
228
+ * @param Mage_Sales_Model_Order $order
229
+ * @return array
230
+ */
231
+ protected function _buildDynamicParams(Mage_Sales_Model_Order $order)
232
+ {
233
+ $helper = Mage::helper('eems_affiliate');
234
+
235
+ $params = $this->_buildItemizedParams($order);
236
+
237
+ // Swap query key names for dynamic versions
238
+ $params[self::KEY_DYNAMIC_PROGRAM_ID] = $params[self::KEY_PID];
239
+ $params[self::KEY_DYNAMIC_ORDER_ID] = $params[self::KEY_OID];
240
+ unset($params[self::KEY_PID]);
241
+ unset($params[self::KEY_OID]);
242
+ if (isset($params[self::KEY_PROMOCODE])) {
243
+ $params[self::KEY_DYNAMIC_COUPON] = $params[self::KEY_PROMOCODE];
244
+ unset($params[self::KEY_PROMOCODE]);
245
+ }
246
+
247
+ // See if email has any history
248
+ $params[self::KEY_DYNAMIC_NEW_TO_FILE] = (int)$helper->isNewToFile($order);
249
+
250
+ $productIds = array();
251
+ foreach($order->getAllItems() as $item) {
252
+ $productIds[] = $item->getProduct()->getId();
253
+ }
254
+
255
+ $productCollection = Mage::getModel('catalog/product')->getCollection()
256
+ ->addAttributeToFilter('entity_id', array('in', $productIds))
257
+ ->addCategoryIds();
258
+
259
+ // No need for increment, all items are in param already
260
+ $lastPosition = 0;
261
+ foreach($order->getAllItems() as $item) {
262
+ // Every item should be found here
263
+ $position = $this->_getDupePosition($params, $item);
264
+
265
+ // Add category IDs
266
+ $product = $productCollection->getItemById($item->getProduct()->getId());
267
+ $item->getProduct()->setCategoryIds($product->getCategoryIds());
268
+
269
+ // Get item's category
270
+ $params[self::KEY_DYNAMIC_CATEGORY . $position] = $helper->getCommissioningCategory($item);
271
+
272
+ // Update last position
273
+ $lastPosition = max($lastPosition, $position);
274
+ }
275
+
276
+ // Swap key names for dynamic versions
277
+ for($position = 1; $position <= $lastPosition; $position += 1) {
278
+ // Replace query string keys
279
+ $params[self::KEY_DYNAMIC_ITEM_ID . $position] = $params[self::KEY_ITEM . $position];
280
+ $params[self::KEY_DYNAMIC_ITEM_PRICE . $position] = $params[self::KEY_AMOUNT . $position];
281
+ $params[self::KEY_DYNAMIC_QUANTITY . $position] = $params[self::KEY_QTY . $position];
282
+ unset($params[self::KEY_ITEM . $position]);
283
+ unset($params[self::KEY_AMOUNT . $position]);
284
+ unset($params[self::KEY_QTY . $position]);
285
+ }
286
+
287
+ return $params;
288
+ }
289
+
290
+ /**
291
+ * check if the current sku already exists in the params data if so return
292
+ * the position it is found in
293
+ * @param array $params the given array of keys needed to build the beacon URL querystring
294
+ * @param Mage_Sales_Model_Order_Item $item
295
+ * @return int the item position where dupe found otherwise zero
296
+ */
297
+ protected function _getDupePosition(array $params, Mage_Sales_Model_Order_Item $item)
298
+ {
299
+ $key = array_search($item->getSku(), $params, true);
300
+ return ($key !== false)?
301
+ (int) str_replace(static::KEY_ITEM, '', $key) : 0;
302
+ }
303
+
304
+ /**
305
+ * Whether or not to display the beacon.
306
+ *
307
+ * Show the pixel only if tracking is enabled and we have a valid order
308
+ * AND either conditional pixel logic is OFF or it is ON and we have
309
+ * a valid cookie.
310
+ *
311
+ * @return bool
312
+ */
313
+ public function showBeacon()
314
+ {
315
+ $config = $this->_getConfigHelper();
316
+
317
+ return (
318
+ (
319
+ $config->isEnabled() &&
320
+ $this->_getOrder() instanceof Mage_Sales_Model_Order
321
+ ) &&
322
+ (
323
+ $this->_getHelper()->isValidCookie() ||
324
+ !$config->isConditionalPixelEnabled()
325
+ )
326
+ );
327
+ }
328
+ }
app/code/community/EbayEnterprise/Affiliate/etc/config.xml CHANGED
@@ -16,7 +16,7 @@ http://www.ebayenterprise.com/files/pdf/Magento_Connect_Extensions_EULA_050714.p
16
  <config>
17
  <modules>
18
  <EbayEnterprise_Affiliate>
19
- <version>1.2.0.0</version>
20
  </EbayEnterprise_Affiliate>
21
  </modules>
22
  <global>
16
  <config>
17
  <modules>
18
  <EbayEnterprise_Affiliate>
19
+ <version>1.2.0.1</version>
20
  </EbayEnterprise_Affiliate>
21
  </modules>
22
  <global>
app/code/community/EbayEnterprise/Affiliate/sql/eems_affiliate_setup/mysql4-upgrade-1.2.0.1-1.3.0.0.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ $installer->startSetup();
5
+
6
+ $orderTable = $installer->getTable('sales/order');
7
+
8
+ $installer->getConnection()
9
+ ->addColumn($orderTable, 'affiliate_source', array(
10
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
11
+ 'length' => 20,
12
+ 'nullable' => TRUE,
13
+ 'unsigned' => TRUE,
14
+ 'comment' => "Affiliate Source"
15
+ ));
16
+
17
+ $installer->getConnection()
18
+ ->addColumn($orderTable, 'affiliate_click_id', array(
19
+ 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
20
+ 'nullable' => TRUE,
21
+ 'unsigned' => TRUE,
22
+ 'comment' => "Affiliate Click ID"
23
+ ));
24
+
25
+ $installer->getConnection()
26
+ ->addColumn($orderTable, 'affiliate_publisher_id', array(
27
+ 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
28
+ 'nullable' => TRUE,
29
+ 'unsigned' => TRUE,
30
+ 'comment' => "Affiliate Publisher ID"
31
+ ));
32
+
33
+ $installer->setConfigData('marketing_solutions/eems_affiliate/order_feed/last_run_time', time());
34
+ $installer->setConfigData('marketing_solutions/eems_affiliate/order_correction_feed/last_run_time', Mage::getStoreConfig('marketing_solutions/eems_affiliate/feed/last_run_time'));
35
+ $installer->deleteConfigData('marketing_solutions/eems_affiliate/feed/last_run_time');
36
+
37
+ $installer->endSetup();
package.xml CHANGED
@@ -1,22 +1,20 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>eBay_Enterprise_Affiliate_Extension</name>
4
- <version>1.2.0.0</version>
5
  <stability>stable</stability>
6
  <license>EULA</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>eBay Enterprise Affiliate Extension.</summary>
10
  <description>eBay Enterprise Affiliate Extension.</description>
11
- <notes>Changelog for 1.2.0.0&#xD;
12
- Options to disable feeds&#xD;
13
- Feeds now set to run daily at 3:00am&#xD;
14
- Support for dynamic commissioning&#xD;
15
- Cookies increased to 365 days</notes>
16
- <authors><author><name>Michael A. Smith</name><user>msmith3</user><email>msmith3@ebay.com</email></author><author><name>Philip Preston</name><user>phpreston</user><email>phpreston@ebay.com</email></author></authors>
17
- <date>2016-02-19</date>
18
- <time>19:53:27</time>
19
- <contents><target name="mageetc"><dir name="modules"><file name="EbayEnterprise_Affiliate.xml" hash="c67e54262d466adebba66b7cc0e2df8f"/></dir></target><target name="magecommunity"><dir name="EbayEnterprise"><dir name="Affiliate"><dir name="Block"><file name="Beacon.php" hash="74bafb19d4753d599f71ed80790df8c1"/><file name="Tracking.php" hash="b8e8a1126f487f69dd575f5e14b630b9"/></dir><dir name="Exception"><file name="Configuration.php" hash="a5164f37b8e5e13dfc20561e13ec6c54"/></dir><dir name="Helper"><file name="Config.php" hash="166c7a5a4c3c7955ebf441e2a3d1bbc8"/><file name="Data.php" hash="04c3cf34e7a67ffc330607a4e16e91d5"/><dir name="Map"><file name="Order.php" hash="a53b5894c45d37b10eb50fa8f6c6c350"/><file name="Product.php" hash="f9f4b1337e040d52971fc7f669287c79"/></dir><file name="Map.php" hash="5329d762e01ed3cfe34dad14a9a59c01"/></dir><dir name="Model"><dir name="Feed"><file name="Abstract.php" hash="546bb078e115f4319a7e6052a4feaf4a"/><dir name="Order"><file name="Abstract.php" hash="676d28e0fa5677f70470eb7b32b45c16"/><file name="Basic.php" hash="a06460810245f18d4905dcf9a7bf5220"/><file name="Dynamic.php" hash="44601d213d1823d11d1598da7cab38b5"/><file name="Itemized.php" hash="f5ecb6e8b8f603a4717906aa4f130365"/></dir><file name="Product.php" hash="ecd0ac9efb2fd8feab577b888f8d55d7"/></dir><file name="Observer.php" hash="723ea0e39203210352ea3198b2840bce"/><dir name="Product"><dir name="Attribute"><dir name="Source"><file name="CommissioningCategory.php" hash="0dd81e0901e6519043b31c322516a977"/></dir></dir></dir><dir name="System"><dir name="Config"><dir name="Source"><file name="Attributes.php" hash="079b340ac5e2daa5197268c4464d2505"/><file name="Categories.php" hash="c412da8de21424e65628958a92eaa1c0"/><file name="Ordertypes.php" hash="bfa02f2a94175d49f192d77b9523e717"/><file name="Stockquantity.php" hash="0e4c5b6f0e45b10403c00660b54f3057"/><file name="Stockyesno.php" hash="154bedd15209f8110e69c80b207e7a68"/><file name="Transactiontype.php" hash="cd892832b62349c399ad147ba7217885"/><file name="Visibilityyesno.php" hash="b6de9a44184c9158d3be097b8cb4cec2"/></dir></dir></dir></dir><dir name="Test"><dir name="Block"><file name="BeaconTest.php" hash="c127f7453ab7ee6163760c518c698221"/><dir name="providers"><file name="testShowBeacon.yaml" hash="5b7a80f1de1e4196a9e56f9a71cb51a2"/></dir></dir><dir name="Helper"><file name="DataTest.php" hash="52be41226b17cd44eb29d97ec3ab4612"/><dir name="Map"><file name="ProductTest.php" hash="936eb3b538bd8c9ddc6a65c48a9df4d9"/></dir><dir name="providers"><file name="testIsValidCookie.yaml" hash="b3eb3eb30d78c7e67b7af51768b88492"/></dir></dir><dir name="Model"><dir name="Feed"><file name="AbstractTest.php" hash="98d14d1808a67917ce37fb4ba3b6c3cf"/><dir name="Order"><file name="AbstractTest.php" hash="83c0331bcc04784713ba55c7bad13c81"/><file name="BasicTest.php" hash="eea42c1eb603764f8332bbb4acf00ea5"/><file name="ItemizedTest.php" hash="c81153a22303700811670d0e912431c6"/></dir><file name="ProductTest.php" hash="2b33598eea0fab35aae2c0318d89de57"/></dir><file name="ObserverTest.php" hash="e0e1cd8b8170561513715ef9bbf64942"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="fccf9b602bb22175bfb81148cb216644"/><file name="config.xml" hash="c1d6b9a4d3f79312f331213c63a2e4b9"/><file name="system.xml" hash="ae97dcdaebedcdb3416a18584cd609c8"/></dir><dir name="sql"><dir name="eems_affiliate_setup"><file name="install-1.0.0.1.php" hash="1872e6830dc200364c24f76841b41832"/><file name="mysql4-install-1.0.0.1.php" hash="1872e6830dc200364c24f76841b41832"/><file name="mysql4-upgrade-1.0.0.1-1.2.0.0.php" hash="483d015528132052ad8ca0a07ea8efed"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="eems_affiliate.xml" hash="7d0b7b9a18086a9a61099a753d82f4fc"/></dir><dir name="template"><dir name="eems_affiliate"><file name="beacon.phtml" hash="40d3b19edc66bc22b5dc5ffbeec2507a"/><file name="tracking.phtml" hash="44fb259a8e0e0cf33c7b042976a325c3"/></dir></dir></dir></dir></dir></target></contents>
20
  <compatible/>
21
  <dependencies><required><php><min>5.3.0</min><max>5.6.99</max></php></required></dependencies>
22
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>eBay_Enterprise_Affiliate_Extension</name>
4
+ <version>1.2.0.1</version>
5
  <stability>stable</stability>
6
  <license>EULA</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>eBay Enterprise Affiliate Extension.</summary>
10
  <description>eBay Enterprise Affiliate Extension.</description>
11
+ <notes>Changelog for 1.2.0.1&#xD;
12
+ Incorrect key "TOTALAMOUNT" no longer submitted with tracking pixel for a bundle item&#xD;
13
+ Categories with an index out of scope no longer being included for a bundle item</notes>
14
+ <authors><author><name>Philip Preston</name><user>phpreston</user><email>phpreston@pepperjam.com</email></author><author><name>Michael A. Smith</name><user>msmith3</user><email>msmith3@ebay.com</email></author></authors>
15
+ <date>2016-04-12</date>
16
+ <time>22:39:34</time>
17
+ <contents><target name="mageetc"><dir name="modules"><file name="EbayEnterprise_Affiliate.xml" hash="c67e54262d466adebba66b7cc0e2df8f"/></dir></target><target name="magecommunity"><dir name="EbayEnterprise"><dir name="Affiliate"><dir name="Block"><file name="Beacon.php" hash="70470acf0e484d5a184b9b10e5043d82"/><file name="Tracking.php" hash="b8e8a1126f487f69dd575f5e14b630b9"/></dir><dir name="Exception"><file name="Configuration.php" hash="a5164f37b8e5e13dfc20561e13ec6c54"/></dir><dir name="Helper"><file name="Config.php" hash="166c7a5a4c3c7955ebf441e2a3d1bbc8"/><file name="Data.php" hash="04c3cf34e7a67ffc330607a4e16e91d5"/><dir name="Map"><file name="Order.php" hash="a53b5894c45d37b10eb50fa8f6c6c350"/><file name="Product.php" hash="f9f4b1337e040d52971fc7f669287c79"/></dir><file name="Map.php" hash="5329d762e01ed3cfe34dad14a9a59c01"/></dir><dir name="Model"><dir name="Feed"><file name="Abstract.php" hash="546bb078e115f4319a7e6052a4feaf4a"/><dir name="Order"><file name="Abstract.php" hash="676d28e0fa5677f70470eb7b32b45c16"/><file name="Basic.php" hash="a06460810245f18d4905dcf9a7bf5220"/><file name="Dynamic.php" hash="44601d213d1823d11d1598da7cab38b5"/><file name="Itemized.php" hash="f5ecb6e8b8f603a4717906aa4f130365"/></dir><file name="Product.php" hash="ecd0ac9efb2fd8feab577b888f8d55d7"/></dir><file name="Observer.php" hash="723ea0e39203210352ea3198b2840bce"/><dir name="Product"><dir name="Attribute"><dir name="Source"><file name="CommissioningCategory.php" hash="0dd81e0901e6519043b31c322516a977"/></dir></dir></dir><dir name="System"><dir name="Config"><dir name="Source"><file name="Attributes.php" hash="079b340ac5e2daa5197268c4464d2505"/><file name="Categories.php" hash="c412da8de21424e65628958a92eaa1c0"/><file name="Ordertypes.php" hash="bfa02f2a94175d49f192d77b9523e717"/><file name="Stockquantity.php" hash="0e4c5b6f0e45b10403c00660b54f3057"/><file name="Stockyesno.php" hash="154bedd15209f8110e69c80b207e7a68"/><file name="Transactiontype.php" hash="cd892832b62349c399ad147ba7217885"/><file name="Visibilityyesno.php" hash="b6de9a44184c9158d3be097b8cb4cec2"/></dir></dir></dir></dir><dir name="Test"><dir name="Block"><file name="BeaconTest.php" hash="c127f7453ab7ee6163760c518c698221"/><dir name="providers"><file name="testShowBeacon.yaml" hash="5b7a80f1de1e4196a9e56f9a71cb51a2"/></dir></dir><dir name="Helper"><file name="DataTest.php" hash="52be41226b17cd44eb29d97ec3ab4612"/><dir name="Map"><file name="ProductTest.php" hash="936eb3b538bd8c9ddc6a65c48a9df4d9"/></dir><dir name="providers"><file name="testIsValidCookie.yaml" hash="b3eb3eb30d78c7e67b7af51768b88492"/></dir></dir><dir name="Model"><dir name="Feed"><file name="AbstractTest.php" hash="98d14d1808a67917ce37fb4ba3b6c3cf"/><dir name="Order"><file name="AbstractTest.php" hash="83c0331bcc04784713ba55c7bad13c81"/><file name="BasicTest.php" hash="eea42c1eb603764f8332bbb4acf00ea5"/><file name="ItemizedTest.php" hash="c81153a22303700811670d0e912431c6"/></dir><file name="ProductTest.php" hash="2b33598eea0fab35aae2c0318d89de57"/></dir><file name="ObserverTest.php" hash="e0e1cd8b8170561513715ef9bbf64942"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="fccf9b602bb22175bfb81148cb216644"/><file name="config.xml" hash="15897982c1d9e351d4cdeebd0b8bec1f"/><file name="system.xml" hash="ae97dcdaebedcdb3416a18584cd609c8"/></dir><dir name="sql"><dir name="eems_affiliate_setup"><file name="install-1.0.0.1.php" hash="1872e6830dc200364c24f76841b41832"/><file name="mysql4-install-1.0.0.1.php" hash="1872e6830dc200364c24f76841b41832"/><file name="mysql4-upgrade-1.0.0.1-1.2.0.0.php" hash="483d015528132052ad8ca0a07ea8efed"/><file name="mysql4-upgrade-1.2.0.1-1.3.0.0.php" hash="8ba13713daa1f01a45e2ad49361687d3"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="eems_affiliate.xml" hash="7d0b7b9a18086a9a61099a753d82f4fc"/></dir><dir name="template"><dir name="eems_affiliate"><file name="beacon.phtml" hash="40d3b19edc66bc22b5dc5ffbeec2507a"/><file name="tracking.phtml" hash="44fb259a8e0e0cf33c7b042976a325c3"/></dir></dir></dir></dir></dir></target></contents>
 
 
18
  <compatible/>
19
  <dependencies><required><php><min>5.3.0</min><max>5.6.99</max></php></required></dependencies>
20
  </package>