eBay_Enterprise_Affiliate_Extension - Version 1.2.1.1

Version Notes

Changelog for 1.2.1.1
Products without all required data will no longer be included in the product feed

Download this release

Release Info

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


Code changes from version 1.2.1.0 to 1.2.1.1

Files changed (46) hide show
  1. app/code/community/EbayEnterprise/Affiliate/Block/Adminhtml/System/Config/Form/Button.php +32 -32
  2. app/code/community/EbayEnterprise/Affiliate/Block/Beacon.php +332 -332
  3. app/code/community/EbayEnterprise/Affiliate/Block/Tracking.php +44 -44
  4. app/code/community/EbayEnterprise/Affiliate/Exception/Configuration.php +21 -21
  5. app/code/community/EbayEnterprise/Affiliate/Helper/Config.php +323 -301
  6. app/code/community/EbayEnterprise/Affiliate/Helper/Data.php +178 -178
  7. app/code/community/EbayEnterprise/Affiliate/Helper/Map.php +112 -112
  8. app/code/community/EbayEnterprise/Affiliate/Helper/Map/Order.php +172 -172
  9. app/code/community/EbayEnterprise/Affiliate/Helper/Map/Product.php +135 -135
  10. app/code/community/EbayEnterprise/Affiliate/Model/Feed/Abstract.php +337 -337
  11. app/code/community/EbayEnterprise/Affiliate/Model/Feed/Order/Abstract.php +72 -72
  12. app/code/community/EbayEnterprise/Affiliate/Model/Feed/Order/Basic.php +75 -75
  13. app/code/community/EbayEnterprise/Affiliate/Model/Feed/Order/Dynamic.php +68 -68
  14. app/code/community/EbayEnterprise/Affiliate/Model/Feed/Order/Itemized.php +81 -81
  15. app/code/community/EbayEnterprise/Affiliate/Model/Feed/Product.php +110 -98
  16. app/code/community/EbayEnterprise/Affiliate/Model/Observer.php +76 -76
  17. app/code/community/EbayEnterprise/Affiliate/Model/Product/Attribute/Source/CommissioningCategory.php +29 -29
  18. app/code/community/EbayEnterprise/Affiliate/Model/System/Config/Source/Attributes.php +75 -75
  19. app/code/community/EbayEnterprise/Affiliate/Model/System/Config/Source/Categories.php +37 -37
  20. app/code/community/EbayEnterprise/Affiliate/Model/System/Config/Source/Ordertypes.php +24 -24
  21. app/code/community/EbayEnterprise/Affiliate/Model/System/Config/Source/Stockquantity.php +37 -37
  22. app/code/community/EbayEnterprise/Affiliate/Model/System/Config/Source/Stockyesno.php +37 -37
  23. app/code/community/EbayEnterprise/Affiliate/Model/System/Config/Source/Transactiontype.php +30 -30
  24. app/code/community/EbayEnterprise/Affiliate/Model/System/Config/Source/Visibilityyesno.php +37 -37
  25. app/code/community/EbayEnterprise/Affiliate/Test/Block/BeaconTest.php +254 -254
  26. app/code/community/EbayEnterprise/Affiliate/Test/Block/providers/testShowBeacon.yaml +99 -99
  27. app/code/community/EbayEnterprise/Affiliate/Test/Helper/DataTest.php +54 -54
  28. app/code/community/EbayEnterprise/Affiliate/Test/Helper/Map/ProductTest.php +174 -174
  29. app/code/community/EbayEnterprise/Affiliate/Test/Helper/providers/testIsValidCookie.yaml +12 -12
  30. app/code/community/EbayEnterprise/Affiliate/Test/Model/Feed/AbstractTest.php +293 -293
  31. app/code/community/EbayEnterprise/Affiliate/Test/Model/Feed/Order/AbstractTest.php +60 -60
  32. app/code/community/EbayEnterprise/Affiliate/Test/Model/Feed/Order/BasicTest.php +40 -40
  33. app/code/community/EbayEnterprise/Affiliate/Test/Model/Feed/Order/ItemizedTest.php +40 -40
  34. app/code/community/EbayEnterprise/Affiliate/Test/Model/Feed/ProductTest.php +169 -169
  35. app/code/community/EbayEnterprise/Affiliate/Test/Model/ObserverTest.php +62 -62
  36. app/code/community/EbayEnterprise/Affiliate/controllers/Adminhtml/EemsAffiliateController.php +85 -85
  37. app/code/community/EbayEnterprise/Affiliate/etc/adminhtml.xml +37 -37
  38. app/code/community/EbayEnterprise/Affiliate/etc/config.xml +1041 -1041
  39. app/code/community/EbayEnterprise/Affiliate/sql/eems_affiliate_setup/install-1.0.0.1.php +24 -24
  40. app/code/community/EbayEnterprise/Affiliate/sql/eems_affiliate_setup/mysql4-install-1.0.0.1.php +24 -24
  41. app/code/community/EbayEnterprise/Affiliate/sql/eems_affiliate_setup/mysql4-upgrade-1.0.0.1-1.2.0.0.php +36 -36
  42. app/design/frontend/base/default/layout/eems_affiliate.xml +35 -35
  43. app/design/frontend/base/default/template/eems_affiliate/beacon.phtml +35 -0
  44. app/design/frontend/base/default/template/eems_affiliate/tracking.phtml +97 -0
  45. app/etc/modules/EbayEnterprise_Affiliate.xml +23 -23
  46. package.xml +9 -9
app/code/community/EbayEnterprise/Affiliate/Block/Adminhtml/System/Config/Form/Button.php CHANGED
@@ -1,32 +1,32 @@
1
- <?php
2
-
3
- class EbayEnterprise_Affiliate_Block_Adminhtml_System_Config_Form_Button extends Mage_Adminhtml_Block_System_Config_Form_Field
4
- {
5
- protected function _construct()
6
- {
7
- parent::_construct();
8
- $this->setTemplate('eems_affiliate/system/config/button.phtml');
9
- }
10
-
11
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
12
- {
13
- return $this->_toHtml();
14
- }
15
-
16
- public function getAjaxUninstallUrl()
17
- {
18
- return Mage::helper('adminhtml')->getUrl('adminhtml/eemsAffiliate/uninstall');
19
- }
20
-
21
- public function getButtonHtml()
22
- {
23
- $button = $this->getLayout()->createBlock('adminhtml/widget_button')->setData(
24
- array(
25
- 'id' => 'eems_affiliate_uninstall',
26
- 'label' => $this->helper('adminhtml')->__('Uninstall'),
27
- 'onclick' => 'javascript:uninstall(); return false;',
28
- ));
29
-
30
- return $button->toHtml();
31
- }
32
- }
1
+ <?php
2
+
3
+ class EbayEnterprise_Affiliate_Block_Adminhtml_System_Config_Form_Button extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+ protected function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->setTemplate('eems_affiliate/system/config/button.phtml');
9
+ }
10
+
11
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
12
+ {
13
+ return $this->_toHtml();
14
+ }
15
+
16
+ public function getAjaxUninstallUrl()
17
+ {
18
+ return Mage::helper('adminhtml')->getUrl('adminhtml/eemsAffiliate/uninstall');
19
+ }
20
+
21
+ public function getButtonHtml()
22
+ {
23
+ $button = $this->getLayout()->createBlock('adminhtml/widget_button')->setData(
24
+ array(
25
+ 'id' => 'eems_affiliate_uninstall',
26
+ 'label' => $this->helper('adminhtml')->__('Uninstall'),
27
+ 'onclick' => 'javascript:uninstall(); return false;',
28
+ ));
29
+
30
+ return $button->toHtml();
31
+ }
32
+ }
app/code/community/EbayEnterprise/Affiliate/Block/Beacon.php CHANGED
@@ -1,332 +1,332 @@
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 (if the pricing is dynamic)
201
- // total of the bundleis the sum of all child products which are also included
202
- // in the beacon so including both totals would effectively double the price of
203
- // the bundle
204
- //
205
- // Divide discount amount by quantity to get per item discount
206
- $total = $item->getPrice() - ($item->getDiscountAmount() / $item->getQtyOrdered());
207
- if ($item->getProductType() === Mage_Catalog_Model_Product_Type::TYPE_BUNDLE && $item->getProduct()->getPriceType() == Mage_Bundle_Model_Product_Price::PRICE_TYPE_DYNAMIC) {
208
- $total = 0.00;
209
- }
210
-
211
- if ($position) {
212
- // we detected that the current item already exist in the params array
213
- // and have the key increment position let's simply adjust
214
- // the qty and total amount
215
- $params[static::KEY_QTY . $position] += $quantity;
216
- $amtKey = static::KEY_AMOUNT . $position;
217
- $params[$amtKey] = number_format($params[$amtKey] + $total, 2, '.', '');
218
- } else {
219
- $params = array_merge($params, array(
220
- static::KEY_ITEM . $increment => $item->getSku(),
221
- static::KEY_QTY . $increment => $quantity,
222
- static::KEY_AMOUNT . $increment => number_format($total, 2, '.', ''),
223
- ));
224
- $increment++; // only get incremented when a unique key have been appended
225
- }
226
- }
227
- return $params;
228
- }
229
-
230
- /**
231
- * build dynamic order params array for dynamic beacon URL
232
- * @param Mage_Sales_Model_Order $order
233
- * @return array
234
- */
235
- protected function _buildDynamicParams(Mage_Sales_Model_Order $order)
236
- {
237
- $helper = Mage::helper('eems_affiliate');
238
-
239
- $params = $this->_buildItemizedParams($order);
240
-
241
- // Swap query key names for dynamic versions
242
- $params[self::KEY_DYNAMIC_PROGRAM_ID] = $params[self::KEY_PID];
243
- $params[self::KEY_DYNAMIC_ORDER_ID] = $params[self::KEY_OID];
244
- unset($params[self::KEY_PID]);
245
- unset($params[self::KEY_OID]);
246
- if (isset($params[self::KEY_PROMOCODE])) {
247
- $params[self::KEY_DYNAMIC_COUPON] = $params[self::KEY_PROMOCODE];
248
- unset($params[self::KEY_PROMOCODE]);
249
- }
250
-
251
- // See if email has any history
252
- $params[self::KEY_DYNAMIC_NEW_TO_FILE] = (int)$helper->isNewToFile($order);
253
-
254
- $productIds = array();
255
- foreach($order->getAllItems() as $item) {
256
- $productIds[] = $item->getProduct()->getId();
257
- }
258
-
259
- $productCollection = Mage::getModel('catalog/product')->getCollection()
260
- ->addAttributeToFilter('entity_id', array('in', $productIds))
261
- ->addCategoryIds();
262
-
263
- // No need for increment, all items are in param already
264
- $lastPosition = 0;
265
- foreach($order->getAllItems() as $item) {
266
- // Every item should be found here
267
- $position = $this->_getDupePosition($params, $item);
268
-
269
- // Add category IDs
270
- $product = $productCollection->getItemById($item->getProduct()->getId());
271
- $item->getProduct()->setCategoryIds($product->getCategoryIds());
272
-
273
- // Get item's category
274
- $params[self::KEY_DYNAMIC_CATEGORY . $position] = $helper->getCommissioningCategory($item);
275
-
276
- // Update last position
277
- $lastPosition = max($lastPosition, $position);
278
- }
279
-
280
- // Swap key names for dynamic versions
281
- for($position = 1; $position <= $lastPosition; $position += 1) {
282
- // Replace query string keys
283
- $params[self::KEY_DYNAMIC_ITEM_ID . $position] = $params[self::KEY_ITEM . $position];
284
- $params[self::KEY_DYNAMIC_ITEM_PRICE . $position] = $params[self::KEY_AMOUNT . $position];
285
- $params[self::KEY_DYNAMIC_QUANTITY . $position] = $params[self::KEY_QTY . $position];
286
- unset($params[self::KEY_ITEM . $position]);
287
- unset($params[self::KEY_AMOUNT . $position]);
288
- unset($params[self::KEY_QTY . $position]);
289
- }
290
-
291
- return $params;
292
- }
293
-
294
- /**
295
- * check if the current sku already exists in the params data if so return
296
- * the position it is found in
297
- * @param array $params the given array of keys needed to build the beacon URL querystring
298
- * @param Mage_Sales_Model_Order_Item $item
299
- * @return int the item position where dupe found otherwise zero
300
- */
301
- protected function _getDupePosition(array $params, Mage_Sales_Model_Order_Item $item)
302
- {
303
- $key = array_search($item->getSku(), $params, true);
304
- return ($key !== false)?
305
- (int) str_replace(static::KEY_ITEM, '', $key) : 0;
306
- }
307
-
308
- /**
309
- * Whether or not to display the beacon.
310
- *
311
- * Show the pixel only if tracking is enabled and we have a valid order
312
- * AND either conditional pixel logic is OFF or it is ON and we have
313
- * a valid cookie.
314
- *
315
- * @return bool
316
- */
317
- public function showBeacon()
318
- {
319
- $config = $this->_getConfigHelper();
320
-
321
- return (
322
- (
323
- $config->isEnabled() &&
324
- $this->_getOrder() instanceof Mage_Sales_Model_Order
325
- ) &&
326
- (
327
- $this->_getHelper()->isValidCookie() ||
328
- !$config->isConditionalPixelEnabled()
329
- )
330
- );
331
- }
332
- }
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 (if the pricing is dynamic)
201
+ // total of the bundleis the sum of all child products which are also included
202
+ // in the beacon so including both totals would effectively double the price of
203
+ // the bundle
204
+ //
205
+ // Divide discount amount by quantity to get per item discount
206
+ $total = $item->getPrice() - ($item->getDiscountAmount() / $item->getQtyOrdered());
207
+ if ($item->getProductType() === Mage_Catalog_Model_Product_Type::TYPE_BUNDLE && $item->getProduct()->getPriceType() == Mage_Bundle_Model_Product_Price::PRICE_TYPE_DYNAMIC) {
208
+ $total = 0.00;
209
+ }
210
+
211
+ if ($position) {
212
+ // we detected that the current item already exist in the params array
213
+ // and have the key increment position let's simply adjust
214
+ // the qty and total amount
215
+ $params[static::KEY_QTY . $position] += $quantity;
216
+ $amtKey = static::KEY_AMOUNT . $position;
217
+ $params[$amtKey] = number_format($params[$amtKey] + $total, 2, '.', '');
218
+ } else {
219
+ $params = array_merge($params, array(
220
+ static::KEY_ITEM . $increment => $item->getSku(),
221
+ static::KEY_QTY . $increment => $quantity,
222
+ static::KEY_AMOUNT . $increment => number_format($total, 2, '.', ''),
223
+ ));
224
+ $increment++; // only get incremented when a unique key have been appended
225
+ }
226
+ }
227
+ return $params;
228
+ }
229
+
230
+ /**
231
+ * build dynamic order params array for dynamic beacon URL
232
+ * @param Mage_Sales_Model_Order $order
233
+ * @return array
234
+ */
235
+ protected function _buildDynamicParams(Mage_Sales_Model_Order $order)
236
+ {
237
+ $helper = Mage::helper('eems_affiliate');
238
+
239
+ $params = $this->_buildItemizedParams($order);
240
+
241
+ // Swap query key names for dynamic versions
242
+ $params[self::KEY_DYNAMIC_PROGRAM_ID] = $params[self::KEY_PID];
243
+ $params[self::KEY_DYNAMIC_ORDER_ID] = $params[self::KEY_OID];
244
+ unset($params[self::KEY_PID]);
245
+ unset($params[self::KEY_OID]);
246
+ if (isset($params[self::KEY_PROMOCODE])) {
247
+ $params[self::KEY_DYNAMIC_COUPON] = $params[self::KEY_PROMOCODE];
248
+ unset($params[self::KEY_PROMOCODE]);
249
+ }
250
+
251
+ // See if email has any history
252
+ $params[self::KEY_DYNAMIC_NEW_TO_FILE] = (int)$helper->isNewToFile($order);
253
+
254
+ $productIds = array();
255
+ foreach($order->getAllItems() as $item) {
256
+ $productIds[] = $item->getProduct()->getId();
257
+ }
258
+
259
+ $productCollection = Mage::getModel('catalog/product')->getCollection()
260
+ ->addAttributeToFilter('entity_id', array('in', $productIds))
261
+ ->addCategoryIds();
262
+
263
+ // No need for increment, all items are in param already
264
+ $lastPosition = 0;
265
+ foreach($order->getAllItems() as $item) {
266
+ // Every item should be found here
267
+ $position = $this->_getDupePosition($params, $item);
268
+
269
+ // Add category IDs
270
+ $product = $productCollection->getItemById($item->getProduct()->getId());
271
+ $item->getProduct()->setCategoryIds($product->getCategoryIds());
272
+
273
+ // Get item's category
274
+ $params[self::KEY_DYNAMIC_CATEGORY . $position] = $helper->getCommissioningCategory($item);
275
+
276
+ // Update last position
277
+ $lastPosition = max($lastPosition, $position);
278
+ }
279
+
280
+ // Swap key names for dynamic versions
281
+ for($position = 1; $position <= $lastPosition; $position += 1) {
282
+ // Replace query string keys
283
+ $params[self::KEY_DYNAMIC_ITEM_ID . $position] = $params[self::KEY_ITEM . $position];
284
+ $params[self::KEY_DYNAMIC_ITEM_PRICE . $position] = $params[self::KEY_AMOUNT . $position];
285
+ $params[self::KEY_DYNAMIC_QUANTITY . $position] = $params[self::KEY_QTY . $position];
286
+ unset($params[self::KEY_ITEM . $position]);
287
+ unset($params[self::KEY_AMOUNT . $position]);
288
+ unset($params[self::KEY_QTY . $position]);
289
+ }
290
+
291
+ return $params;
292
+ }
293
+
294
+ /**
295
+ * check if the current sku already exists in the params data if so return
296
+ * the position it is found in
297
+ * @param array $params the given array of keys needed to build the beacon URL querystring
298
+ * @param Mage_Sales_Model_Order_Item $item
299
+ * @return int the item position where dupe found otherwise zero
300
+ */
301
+ protected function _getDupePosition(array $params, Mage_Sales_Model_Order_Item $item)
302
+ {
303
+ $key = array_search($item->getSku(), $params, true);
304
+ return ($key !== false)?
305
+ (int) str_replace(static::KEY_ITEM, '', $key) : 0;
306
+ }
307
+
308
+ /**
309
+ * Whether or not to display the beacon.
310
+ *
311
+ * Show the pixel only if tracking is enabled and we have a valid order
312
+ * AND either conditional pixel logic is OFF or it is ON and we have
313
+ * a valid cookie.
314
+ *
315
+ * @return bool
316
+ */
317
+ public function showBeacon()
318
+ {
319
+ $config = $this->_getConfigHelper();
320
+
321
+ return (
322
+ (
323
+ $config->isEnabled() &&
324
+ $this->_getOrder() instanceof Mage_Sales_Model_Order
325
+ ) &&
326
+ (
327
+ $this->_getHelper()->isValidCookie() ||
328
+ !$config->isConditionalPixelEnabled()
329
+ )
330
+ );
331
+ }
332
+ }
app/code/community/EbayEnterprise/Affiliate/Block/Tracking.php CHANGED
@@ -1,44 +1,44 @@
1
- <?php
2
- /**
3
- * Copyright (c) 2013-2014 eBay Enterprise, Inc.
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.md.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- *
12
- * @copyright Copyright (c) 2013-2014 eBay Enterprise, Inc. (http://www.ebayenterprise.com/)
13
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
- */
15
-
16
-
17
- class EbayEnterprise_Affiliate_Block_Tracking extends Mage_Core_Block_Template
18
- {
19
- /**
20
- * @return string | null
21
- */
22
- public function getCookieName()
23
- {
24
- return Mage::helper('eems_affiliate')->getSourceCookieName();
25
- }
26
-
27
- /**
28
- * @return string | null
29
- */
30
- public function getQueryStringKeyName()
31
- {
32
- return Mage::helper('eems_affiliate/config')->getSourceKeyName();
33
- }
34
-
35
- /**
36
- * Whether or not to inject the javascript to set the tracking cookie
37
- *
38
- * @return bool
39
- */
40
- public function injectJavaScript()
41
- {
42
- return (Mage::helper('eems_affiliate/config')->isConditionalPixelEnabled());
43
- }
44
- }
1
+ <?php
2
+ /**
3
+ * Copyright (c) 2013-2014 eBay Enterprise, Inc.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.md.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * @copyright Copyright (c) 2013-2014 eBay Enterprise, Inc. (http://www.ebayenterprise.com/)
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ */
15
+
16
+
17
+ class EbayEnterprise_Affiliate_Block_Tracking extends Mage_Core_Block_Template
18
+ {
19
+ /**
20
+ * @return string | null
21
+ */
22
+ public function getCookieName()
23
+ {
24
+ return Mage::helper('eems_affiliate')->getSourceCookieName();
25
+ }
26
+
27
+ /**
28
+ * @return string | null
29
+ */
30
+ public function getQueryStringKeyName()
31
+ {
32
+ return Mage::helper('eems_affiliate/config')->getSourceKeyName();
33
+ }
34
+
35
+ /**
36
+ * Whether or not to inject the javascript to set the tracking cookie
37
+ *
38
+ * @return bool
39
+ */
40
+ public function injectJavaScript()
41
+ {
42
+ return (Mage::helper('eems_affiliate/config')->isConditionalPixelEnabled());
43
+ }
44
+ }
app/code/community/EbayEnterprise/Affiliate/Exception/Configuration.php CHANGED
@@ -1,21 +1,21 @@
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
-
19
- class EbayEnterprise_Affiliate_Exception_Configuration extends Mage_Core_Exception
20
- {
21
- }
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
+
19
+ class EbayEnterprise_Affiliate_Exception_Configuration extends Mage_Core_Exception
20
+ {
21
+ }
app/code/community/EbayEnterprise/Affiliate/Helper/Config.php CHANGED
@@ -1,301 +1,323 @@
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
- /**
19
- * @codeCoverageIgnore
20
- */
21
- class EbayEnterprise_Affiliate_Helper_Config
22
- {
23
- const BEACON_URL_PATH = 'marketing_solutions/eems_affiliate/beacon_url';
24
- const ENABLED_PATH = 'marketing_solutions/eems_affiliate/active';
25
- const ORDER_TYPE_PATH = 'marketing_solutions/eems_affiliate/order_type';
26
- const PROGRAM_ID_PATH = 'marketing_solutions/eems_affiliate/program_id';
27
- const TRANSACTION_TYPE_PATH = 'marketing_solutions/eems_affiliate/transaction_type';
28
- const EXPORT_FILE_PATH_CONFIG_PATH = 'marketing_solutions/eems_affiliate/export_path';
29
- const CALLBACK_MAPPINGS_PATH = 'marketing_solutions/eems_affiliate/feeds/callback_mappings';
30
- const PRODUCT_FEED_MAPPING_PATH = 'marketing_solutions/eems_affiliate_product_attribute_map';
31
- const PRODUCT_FEED_FILENAME_FORMAT_PATH = 'marketing_solutions/eems_affiliate/feeds/product/file_name_format';
32
- const DYNAMIC_ORDER_FEED_MAPPING_PATH = 'marketing_solutions/eems_affiliate/feeds/order_dynamic/fields';
33
- const ITEMIZED_ORDER_FEED_MAPPING_PATH = 'marketing_solutions/eems_affiliate/feeds/order_itemized/fields';
34
- const BASIC_ORDER_FEED_MAPPING_PATH = 'marketing_solutions/eems_affiliate/feeds/order_basic/fields';
35
- const DYNAMIC_ORDER_FEED_FILE_FORMAT_PATH = 'marketing_solutions/eems_affiliate/feeds/order_dynamic/file_name_format';
36
- const ITEMIZED_ORDER_FEED_FILE_FORMAT_PATH = 'marketing_solutions/eems_affiliate/feeds/order_itemized/file_name_format';
37
- const BASIC_ORDER_FEED_FILE_FORMAT_PATH = 'marketing_solutions/eems_affiliate/feeds/order_basic/file_name_format';
38
- const ORDER_LAST_RUN_PATH = 'marketing_solutions/eems_affiliate/feed/last_run_time';
39
- const JS_FILES = 'marketing_solutions/eems_affiliate/js_files';
40
- const CONDITIONAL_PIXEL_ENABLED = 'marketing_solutions/eems_affiliate/conditional_pixel_enabled';
41
- const SOURCE_KEY_NAME = 'marketing_solutions/eems_affiliate/source_key_name';
42
- const PRODUCT_FEED_ENABLED = 'marketing_solutions/eems_affiliate/product_feed_enabled';
43
- const ORDER_FEED_ENABLED = 'marketing_solutions/eems_affiliate/order_feed_enabled';
44
-
45
- const TRANSACTION_TYPE_SALE = '1';
46
- const TRANSACTION_TYPE_LEAD = '2';
47
-
48
- const ORDER_TYPE_BASIC = 'basic';
49
- const ORDER_TYPE_ITEMIZED = 'itemized';
50
- const ORDER_TYPE_DYNAMIC = 'dynamic';
51
-
52
- /**
53
- * retrieve the program id from store config
54
- * @param mixed $store
55
- * @return string
56
- */
57
- public function getProgramId($store = null)
58
- {
59
- return Mage::getStoreConfig(static::PROGRAM_ID_PATH, $store);
60
- }
61
-
62
- /**
63
- * retrieve the transaction type from store config
64
- * @param mixed $store
65
- * @return string
66
- */
67
- public function getTransactionType($store = null)
68
- {
69
- return Mage::getStoreConfig(static::TRANSACTION_TYPE_PATH, $store);
70
- }
71
-
72
- /**
73
- * retrieve the order type from store config
74
- * @param mixed $store
75
- * @return string
76
- */
77
- public function getOrderType($store = null)
78
- {
79
- return Mage::getStoreConfig(static::ORDER_TYPE_PATH, $store);
80
- }
81
-
82
- /**
83
- * determine if orders should be itemized
84
- * @param mixed $store
85
- * @return bool
86
- */
87
- public function isItemizedOrders($store = null)
88
- {
89
- return $this->getOrderType() == static::ORDER_TYPE_ITEMIZED;
90
- }
91
-
92
- /**
93
- * determine if orders should be dynamic
94
- * @param mixed $store
95
- * @return bool
96
- */
97
- public function isDynamicOrders($store = null)
98
- {
99
- return $this->getOrderType() == static::ORDER_TYPE_DYNAMIC;
100
- }
101
-
102
- /**
103
- * check if beacon pixel is enable in the store config
104
- * @param mixed $store
105
- * @return bool
106
- */
107
- public function isEnabled($store = null)
108
- {
109
- return Mage::getStoreConfigFlag(static::ENABLED_PATH, $store);
110
- }
111
-
112
- /**
113
- * retrieve the int from store config
114
- * @param mixed $store
115
- * @return string
116
- */
117
- public function getInt($store = null)
118
- {
119
- return strtoupper(self::getOrderType());
120
- }
121
-
122
- /**
123
- * retrieve the base url of the beacon from store config
124
- * @param mixed $store
125
- * @return string
126
- */
127
- public function getBeaconBaseUrl($store = null)
128
- {
129
- return Mage::getStoreConfig(static::BEACON_URL_PATH, $store);
130
- }
131
-
132
- /**
133
- * Get the configured export file path.
134
- * @param mixed $store
135
- * @return string
136
- */
137
- public function getExportFilePath($store = null)
138
- {
139
- return Mage::getStoreConfig(static::EXPORT_FILE_PATH_CONFIG_PATH, $store);
140
- }
141
-
142
- /**
143
- * Get the callback mappings from the config
144
- * @param mixed $store
145
- * @return array
146
- */
147
- public function getCallbackMappings($store = null)
148
- {
149
- return Mage::getStoreConfig(static::CALLBACK_MAPPINGS_PATH, $store);
150
- }
151
- /**
152
- * Get the configured feed mapping for the product feed.
153
- * @param mixed $store
154
- * @return array
155
- */
156
- public function getProductFeedFields($store = null)
157
- {
158
- return array_filter(Mage::getStoreConfig(static::PRODUCT_FEED_MAPPING_PATH, $store));
159
- }
160
-
161
- /**
162
- * Get the configured product feed file name format
163
- * @param mixed $store
164
- * @return string
165
- */
166
- public function getProductFeedFilenameFormat($store = null)
167
- {
168
- return Mage::getStoreConfig(static::PRODUCT_FEED_FILENAME_FORMAT_PATH, $store);
169
- }
170
-
171
- /**
172
- * Get the configured feed mapping for the dynamic orders feed.
173
- * @param mixed $store
174
- * @return array
175
- */
176
- public function getDynamicOrderFeedFields($store = null)
177
- {
178
- return Mage::getStoreConfig(static::DYNAMIC_ORDER_FEED_MAPPING_PATH, $store);
179
- }
180
-
181
- /**
182
- * Get the configured feed mapping for the itemized orders feed.
183
- * @param mixed $store
184
- * @return array
185
- */
186
- public function getItemizedOrderFeedFields($store = null)
187
- {
188
- return Mage::getStoreConfig(static::ITEMIZED_ORDER_FEED_MAPPING_PATH, $store);
189
- }
190
-
191
- /**
192
- * Get the configured feed mapping for the basic orders feed.
193
- * @param mixed $store
194
- * @return array
195
- */
196
- public function getBasicOrderFeedFields($store = null)
197
- {
198
- return Mage::getStoreConfig(static::BASIC_ORDER_FEED_MAPPING_PATH, $store);
199
- }
200
-
201
- /**
202
- * Get the configured dynamic order feed file format
203
- * @param mixed $store
204
- * @return string
205
- */
206
- public function getDynamicOrderFeedFileFormat($store = null)
207
- {
208
- return Mage::getStoreConfig(static::DYNAMIC_ORDER_FEED_FILE_FORMAT_PATH, $store);
209
- }
210
-
211
- /**
212
- * Get the configured itemized order feed file format
213
- * @param mixed $store
214
- * @return string
215
- */
216
- public function getItemizedOrderFeedFileFormat($store = null)
217
- {
218
- return Mage::getStoreConfig(static::ITEMIZED_ORDER_FEED_FILE_FORMAT_PATH, $store);
219
- }
220
-
221
- /**
222
- * Get the configured basic order feed file format
223
- * @param mixed $store
224
- * @return string
225
- */
226
- public function getBasicOrderFeedFileFormat($store = null)
227
- {
228
- return Mage::getStoreConfig(static::BASIC_ORDER_FEED_FILE_FORMAT_PATH, $store);
229
- }
230
-
231
- /**
232
- * Update the last run time of the order create feed to the specified time,
233
- * or the current time it no time is given. Always set globally so no need to
234
- * ever be given a store context.
235
- * @param string $time
236
- * @return self
237
- */
238
- public function updateOrderLastRunTime($time = null)
239
- {
240
- Mage::getConfig()->saveConfig(self::ORDER_LAST_RUN_PATH, $time ?: time());
241
- Mage::app()->getStore()->resetConfig();
242
- return $this;
243
- }
244
-
245
- /**
246
- * Get the last time the order corrections feed was run. Returns the string
247
- * value saved in config. Always set globally so no need for a store context.
248
- * @return string
249
- */
250
- public function getOrderLastRunTime()
251
- {
252
- return Mage::getStoreConfig(self::ORDER_LAST_RUN_PATH);
253
- }
254
-
255
- /**
256
- * Enable/disable conditional pixel logic
257
- *
258
- * @param null $store
259
- * @return bool
260
- */
261
- public function isConditionalPixelEnabled($store = null)
262
- {
263
- return Mage::getStoreConfig(self::CONDITIONAL_PIXEL_ENABLED, $store);
264
- }
265
-
266
- /**
267
- * Name of the affiliate source
268
- *
269
- * If conditional pixel logic is enabled then only display the pixel
270
- * if the query string contains a key with this name
271
- *
272
- * @param null $store
273
- * @return string
274
- */
275
- public function getSourceKeyName($store = null)
276
- {
277
- return Mage::getStoreConfig(self::SOURCE_KEY_NAME, $store);
278
- }
279
-
280
- /**
281
- * Enable/disable product feed
282
- *
283
- * @param null $store
284
- * @return boolean
285
- */
286
- public function isProductFeedEnabled($store = null)
287
- {
288
- return Mage::getStoreConfig(self::PRODUCT_FEED_ENABLED, $store);
289
- }
290
-
291
- /**
292
- * Enable/disable order feed
293
- *
294
- * @param null $store
295
- * @return boolean
296
- */
297
- public function isOrderFeedEnabled($store = null)
298
- {
299
- return Mage::getStoreConfig(self::ORDER_FEED_ENABLED, $store);
300
- }
301
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ /**
19
+ * @codeCoverageIgnore
20
+ */
21
+ class EbayEnterprise_Affiliate_Helper_Config
22
+ {
23
+ const BEACON_URL_PATH = 'marketing_solutions/eems_affiliate/beacon_url';
24
+ const ENABLED_PATH = 'marketing_solutions/eems_affiliate/active';
25
+ const ORDER_TYPE_PATH = 'marketing_solutions/eems_affiliate/order_type';
26
+ const PROGRAM_ID_PATH = 'marketing_solutions/eems_affiliate/program_id';
27
+ const TRANSACTION_TYPE_PATH = 'marketing_solutions/eems_affiliate/transaction_type';
28
+ const EXPORT_FILE_PATH_CONFIG_PATH = 'marketing_solutions/eems_affiliate/export_path';
29
+ const CALLBACK_MAPPINGS_PATH = 'marketing_solutions/eems_affiliate/feeds/callback_mappings';
30
+ const PRODUCT_FEED_MAPPING_PATH = 'marketing_solutions/eems_affiliate_product_attribute_map';
31
+ const PRODUCT_FEED_FILENAME_FORMAT_PATH = 'marketing_solutions/eems_affiliate/feeds/product/file_name_format';
32
+ const DYNAMIC_ORDER_FEED_MAPPING_PATH = 'marketing_solutions/eems_affiliate/feeds/order_dynamic/fields';
33
+ const ITEMIZED_ORDER_FEED_MAPPING_PATH = 'marketing_solutions/eems_affiliate/feeds/order_itemized/fields';
34
+ const BASIC_ORDER_FEED_MAPPING_PATH = 'marketing_solutions/eems_affiliate/feeds/order_basic/fields';
35
+ const DYNAMIC_ORDER_FEED_FILE_FORMAT_PATH = 'marketing_solutions/eems_affiliate/feeds/order_dynamic/file_name_format';
36
+ const ITEMIZED_ORDER_FEED_FILE_FORMAT_PATH = 'marketing_solutions/eems_affiliate/feeds/order_itemized/file_name_format';
37
+ const BASIC_ORDER_FEED_FILE_FORMAT_PATH = 'marketing_solutions/eems_affiliate/feeds/order_basic/file_name_format';
38
+ const ORDER_LAST_RUN_PATH = 'marketing_solutions/eems_affiliate/feed/last_run_time';
39
+ const JS_FILES = 'marketing_solutions/eems_affiliate/js_files';
40
+ const CONDITIONAL_PIXEL_ENABLED = 'marketing_solutions/eems_affiliate/conditional_pixel_enabled';
41
+ const SOURCE_KEY_NAME = 'marketing_solutions/eems_affiliate/source_key_name';
42
+ const PRODUCT_FEED_ENABLED = 'marketing_solutions/eems_affiliate/product_feed_enabled';
43
+ const ORDER_FEED_ENABLED = 'marketing_solutions/eems_affiliate/order_feed_enabled';
44
+
45
+ const TRANSACTION_TYPE_SALE = '1';
46
+ const TRANSACTION_TYPE_LEAD = '2';
47
+
48
+ const ORDER_TYPE_BASIC = 'basic';
49
+ const ORDER_TYPE_ITEMIZED = 'itemized';
50
+ const ORDER_TYPE_DYNAMIC = 'dynamic';
51
+
52
+ /**
53
+ * retrieve the program id from store config
54
+ * @param mixed $store
55
+ * @return string
56
+ */
57
+ public function getProgramId($store = null)
58
+ {
59
+ return Mage::getStoreConfig(static::PROGRAM_ID_PATH, $store);
60
+ }
61
+
62
+ /**
63
+ * retrieve the transaction type from store config
64
+ * @param mixed $store
65
+ * @return string
66
+ */
67
+ public function getTransactionType($store = null)
68
+ {
69
+ return Mage::getStoreConfig(static::TRANSACTION_TYPE_PATH, $store);
70
+ }
71
+
72
+ /**
73
+ * retrieve the order type from store config
74
+ * @param mixed $store
75
+ * @return string
76
+ */
77
+ public function getOrderType($store = null)
78
+ {
79
+ return Mage::getStoreConfig(static::ORDER_TYPE_PATH, $store);
80
+ }
81
+
82
+ /**
83
+ * determine if orders should be itemized
84
+ * @param mixed $store
85
+ * @return bool
86
+ */
87
+ public function isItemizedOrders($store = null)
88
+ {
89
+ return $this->getOrderType() == static::ORDER_TYPE_ITEMIZED;
90
+ }
91
+
92
+ /**
93
+ * determine if orders should be dynamic
94
+ * @param mixed $store
95
+ * @return bool
96
+ */
97
+ public function isDynamicOrders($store = null)
98
+ {
99
+ return $this->getOrderType() == static::ORDER_TYPE_DYNAMIC;
100
+ }
101
+
102
+ /**
103
+ * check if beacon pixel is enable in the store config
104
+ * @param mixed $store
105
+ * @return bool
106
+ */
107
+ public function isEnabled($store = null)
108
+ {
109
+ return Mage::getStoreConfigFlag(static::ENABLED_PATH, $store);
110
+ }
111
+
112
+ /**
113
+ * retrieve the int from store config
114
+ * @param mixed $store
115
+ * @return string
116
+ */
117
+ public function getInt($store = null)
118
+ {
119
+ return strtoupper(self::getOrderType());
120
+ }
121
+
122
+ /**
123
+ * retrieve the base url of the beacon from store config
124
+ * @param mixed $store
125
+ * @return string
126
+ */
127
+ public function getBeaconBaseUrl($store = null)
128
+ {
129
+ return Mage::getStoreConfig(static::BEACON_URL_PATH, $store);
130
+ }
131
+
132
+ /**
133
+ * Get the configured export file path.
134
+ * @param mixed $store
135
+ * @return string
136
+ */
137
+ public function getExportFilePath($store = null)
138
+ {
139
+ return Mage::getStoreConfig(static::EXPORT_FILE_PATH_CONFIG_PATH, $store);
140
+ }
141
+
142
+ /**
143
+ * Get the callback mappings from the config
144
+ * @param mixed $store
145
+ * @return array
146
+ */
147
+ public function getCallbackMappings($store = null)
148
+ {
149
+ return Mage::getStoreConfig(static::CALLBACK_MAPPINGS_PATH, $store);
150
+ }
151
+ /**
152
+ * Get the configured feed mapping for the product feed.
153
+ * @param mixed $store
154
+ * @return array
155
+ */
156
+ public function getProductFeedFields($store = null)
157
+ {
158
+ return array_filter(Mage::getStoreConfig(static::PRODUCT_FEED_MAPPING_PATH, $store));
159
+ }
160
+
161
+ /**
162
+ * Get the fields that are required for the product feed
163
+ * @param mixed
164
+ * @return array
165
+ */
166
+ public function getRequiredProductFeedFields($store = null)
167
+ {
168
+ // Following the same method magento uses to render the config page
169
+ $config = Mage::getSingleton('adminhtml/config');
170
+ $pepperjamConfig = $config->getSection('marketing_solutions', '', '');
171
+ $pepperjamConfig = $pepperjamConfig->groups->eems_affiliate_product_attribute_map->fields;
172
+ $pepperjamFields = $pepperjamConfig->asArray();
173
+ $requiredFields = array_keys(array_filter($pepperjamFields, function ($value) {
174
+ return isset($value['validate']) && in_array('required-entry', explode(' ', $value['validate']));
175
+ }));
176
+
177
+ $allMappedFields = $this->getProductFeedFields($store);
178
+ $requiredMappedFields = array_intersect_key($allMappedFields, array_flip($requiredFields));
179
+
180
+ return $requiredMappedFields;
181
+ }
182
+
183
+ /**
184
+ * Get the configured product feed file name format
185
+ * @param mixed $store
186
+ * @return string
187
+ */
188
+ public function getProductFeedFilenameFormat($store = null)
189
+ {
190
+ return Mage::getStoreConfig(static::PRODUCT_FEED_FILENAME_FORMAT_PATH, $store);
191
+ }
192
+
193
+ /**
194
+ * Get the configured feed mapping for the dynamic orders feed.
195
+ * @param mixed $store
196
+ * @return array
197
+ */
198
+ public function getDynamicOrderFeedFields($store = null)
199
+ {
200
+ return Mage::getStoreConfig(static::DYNAMIC_ORDER_FEED_MAPPING_PATH, $store);
201
+ }
202
+
203
+ /**
204
+ * Get the configured feed mapping for the itemized orders feed.
205
+ * @param mixed $store
206
+ * @return array
207
+ */
208
+ public function getItemizedOrderFeedFields($store = null)
209
+ {
210
+ return Mage::getStoreConfig(static::ITEMIZED_ORDER_FEED_MAPPING_PATH, $store);
211
+ }
212
+
213
+ /**
214
+ * Get the configured feed mapping for the basic orders feed.
215
+ * @param mixed $store
216
+ * @return array
217
+ */
218
+ public function getBasicOrderFeedFields($store = null)
219
+ {
220
+ return Mage::getStoreConfig(static::BASIC_ORDER_FEED_MAPPING_PATH, $store);
221
+ }
222
+
223
+ /**
224
+ * Get the configured dynamic order feed file format
225
+ * @param mixed $store
226
+ * @return string
227
+ */
228
+ public function getDynamicOrderFeedFileFormat($store = null)
229
+ {
230
+ return Mage::getStoreConfig(static::DYNAMIC_ORDER_FEED_FILE_FORMAT_PATH, $store);
231
+ }
232
+
233
+ /**
234
+ * Get the configured itemized order feed file format
235
+ * @param mixed $store
236
+ * @return string
237
+ */
238
+ public function getItemizedOrderFeedFileFormat($store = null)
239
+ {
240
+ return Mage::getStoreConfig(static::ITEMIZED_ORDER_FEED_FILE_FORMAT_PATH, $store);
241
+ }
242
+
243
+ /**
244
+ * Get the configured basic order feed file format
245
+ * @param mixed $store
246
+ * @return string
247
+ */
248
+ public function getBasicOrderFeedFileFormat($store = null)
249
+ {
250
+ return Mage::getStoreConfig(static::BASIC_ORDER_FEED_FILE_FORMAT_PATH, $store);
251
+ }
252
+
253
+ /**
254
+ * Update the last run time of the order create feed to the specified time,
255
+ * or the current time it no time is given. Always set globally so no need to
256
+ * ever be given a store context.
257
+ * @param string $time
258
+ * @return self
259
+ */
260
+ public function updateOrderLastRunTime($time = null)
261
+ {
262
+ Mage::getConfig()->saveConfig(self::ORDER_LAST_RUN_PATH, $time ?: time());
263
+ Mage::app()->getStore()->resetConfig();
264
+ return $this;
265
+ }
266
+
267
+ /**
268
+ * Get the last time the order corrections feed was run. Returns the string
269
+ * value saved in config. Always set globally so no need for a store context.
270
+ * @return string
271
+ */
272
+ public function getOrderLastRunTime()
273
+ {
274
+ return Mage::getStoreConfig(self::ORDER_LAST_RUN_PATH);
275
+ }
276
+
277
+ /**
278
+ * Enable/disable conditional pixel logic
279
+ *
280
+ * @param null $store
281
+ * @return bool
282
+ */
283
+ public function isConditionalPixelEnabled($store = null)
284
+ {
285
+ return Mage::getStoreConfig(self::CONDITIONAL_PIXEL_ENABLED, $store);
286
+ }
287
+
288
+ /**
289
+ * Name of the affiliate source
290
+ *
291
+ * If conditional pixel logic is enabled then only display the pixel
292
+ * if the query string contains a key with this name
293
+ *
294
+ * @param null $store
295
+ * @return string
296
+ */
297
+ public function getSourceKeyName($store = null)
298
+ {
299
+ return Mage::getStoreConfig(self::SOURCE_KEY_NAME, $store);
300
+ }
301
+
302
+ /**
303
+ * Enable/disable product feed
304
+ *
305
+ * @param null $store
306
+ * @return boolean
307
+ */
308
+ public function isProductFeedEnabled($store = null)
309
+ {
310
+ return Mage::getStoreConfig(self::PRODUCT_FEED_ENABLED, $store);
311
+ }
312
+
313
+ /**
314
+ * Enable/disable order feed
315
+ *
316
+ * @param null $store
317
+ * @return boolean
318
+ */
319
+ public function isOrderFeedEnabled($store = null)
320
+ {
321
+ return Mage::getStoreConfig(self::ORDER_FEED_ENABLED, $store);
322
+ }
323
+ }
app/code/community/EbayEnterprise/Affiliate/Helper/Data.php CHANGED
@@ -1,178 +1,178 @@
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
-
19
- class EbayEnterprise_Affiliate_Helper_Data extends Mage_Core_Helper_Abstract
20
- {
21
- /** value for the source cookie */
22
- const SOURCE_KEY_VALUE = 'eean';
23
- /** prefix added to the source key name set in the admin panel to create a unique cookie name */
24
- const SOURCE_COOKIE_PREFIX = 'ebay_enterprise_affiliate_';
25
-
26
- /**
27
- * Build the beacon url given an array keys
28
- * @param array $params
29
- * @return string
30
- */
31
- public function buildBeaconUrl(array $params)
32
- {
33
- return Mage::helper('eems_affiliate/config')->getBeaconBaseUrl() . '?' .
34
- http_build_query($params);
35
- }
36
-
37
- /**
38
- * Get all unique configured program ids. Program ids may only be set at the
39
- * website level, so only get the program id for the default store for
40
- * each website.
41
- * @return array
42
- */
43
- public function getAllProgramIds()
44
- {
45
- $config = Mage::helper('eems_affiliate/config');
46
- return array_unique(array_filter(array_map(
47
- function ($website) use ($config) {
48
- return $config->getProgramId($website->getDefaultStore());
49
- },
50
- Mage::app()->getWebsites()
51
- )));
52
- }
53
-
54
- /**
55
- * Get a single store view for a program id. As program ids are configured
56
- * only at the global or website level, the store view selecetd will be
57
- * the default store view for the scope the configuration is set at. When
58
- * set globally, the default store view for the Magento instance will be
59
- * selected. When set at a website level, the default store view for that
60
- * website will be used.
61
- * @param string $programId
62
- * @return Mage_Core_Model_Store|null
63
- */
64
- public function getStoreForProgramId($programId)
65
- {
66
- $config = Mage::helper('eems_affiliate/config');
67
- // Check for the default store view to be this program id first, will match
68
- // when the program id is set at the global level.
69
- $defaultStoreView = Mage::app()->getDefaultStoreView();
70
- $defaultProgramId = $config->getProgramId($defaultStoreView);
71
- if ($programId === $defaultProgramId) {
72
- return $defaultStoreView;
73
- }
74
- // When set at the website level, use the first website encountered
75
- // with a matching program id
76
- foreach (Mage::app()->getWebsites() as $website) {
77
- $storeView = $website->getDefaultStore();
78
- if ($config->getProgramId($storeView) === $programId) {
79
- return $storeView;
80
- }
81
- }
82
- return null;
83
- }
84
-
85
- /**
86
- * Get all store views that have a program id that matches the given
87
- * program id
88
- * @param string $programId
89
- * @return Mage_Core_Model_Store[]
90
- */
91
- public function getAllStoresForProgramId($programId)
92
- {
93
- $config = Mage::helper('eems_affiliate/config');
94
- return array_filter(
95
- Mage::app()->getStores(),
96
- function ($store) use ($config, $programId) {
97
- return $config->getProgramId($store) === $programId;
98
- }
99
- );
100
- }
101
-
102
- /**
103
- * take a boolean value and return the string 'yes' or 'no' when the boolean
104
- * value is true or false
105
- * @param bool $value
106
- * @return string
107
- * @codeCoverageIgnore
108
- */
109
- public function parseBoolToYesNo($value)
110
- {
111
- return $value?'yes':'no';
112
- }
113
-
114
- /**
115
- * helper function to take the source key name set in the admin panel
116
- * and prepend a string to create a unique name for the cookie
117
- *
118
- * @return string
119
- */
120
- public function getSourceCookieName()
121
- {
122
- $key = Mage::helper('eems_affiliate/config')->getSourceKeyName();
123
-
124
- return self::SOURCE_COOKIE_PREFIX.$key;
125
- }
126
-
127
- /**
128
- * True if the cookie exists and has a value of SOURCE_KEY_VALUE
129
- * False otherwise
130
- *
131
- * @return bool
132
- */
133
- public function isValidCookie()
134
- {
135
- $cookie = $this->getSourceCookieName();
136
- $value = Mage::getModel('core/cookie')->get($cookie);
137
- return ($value === self::SOURCE_KEY_VALUE);
138
- }
139
-
140
- /**
141
- * Check to see if any orders have been made by the customer before
142
- * @param Mage_Sales_Model_Order $order
143
- * @return boolean This is the first order by this customer (email address)
144
- */
145
- public function isNewToFile(Mage_Sales_Model_Order $order)
146
- {
147
- // Customers are being identified by emails
148
- $customerEmail = $order->getCustomerEmail();
149
-
150
- // Look up any orders that use the same email
151
- $orderCollection = Mage::getModel('sales/order')->getCollection();
152
- $orderCollection->addFieldToFilter('customer_email', $customerEmail);
153
-
154
- // Current order should be only order if new
155
- return $orderCollection->count() <= 1;
156
- }
157
-
158
- /**
159
- * Get Commissioning Category assigned to the item or pick one of the assigned categories if one isn't set
160
- * @param Mage_Sales_Model_Order_Item $item Order Item
161
- * @return int Category ID
162
- */
163
- public function getCommissioningCategory(Mage_Sales_Model_Order_Item $item)
164
- {
165
- $category = $item->getProduct()->getCommissioningCategory();
166
- if ($category == '' || $category == null) {
167
-
168
- $categoryIds = $item->getProduct()->getCategoryIds();
169
- // if there are any categories, grab the first
170
- if (count($categoryIds))
171
- $category = $categoryIds[0];
172
- else
173
- $category = 0;
174
- }
175
-
176
- return $category;
177
- }
178
- }
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
+
19
+ class EbayEnterprise_Affiliate_Helper_Data extends Mage_Core_Helper_Abstract
20
+ {
21
+ /** value for the source cookie */
22
+ const SOURCE_KEY_VALUE = 'eean';
23
+ /** prefix added to the source key name set in the admin panel to create a unique cookie name */
24
+ const SOURCE_COOKIE_PREFIX = 'ebay_enterprise_affiliate_';
25
+
26
+ /**
27
+ * Build the beacon url given an array keys
28
+ * @param array $params
29
+ * @return string
30
+ */
31
+ public function buildBeaconUrl(array $params)
32
+ {
33
+ return Mage::helper('eems_affiliate/config')->getBeaconBaseUrl() . '?' .
34
+ http_build_query($params);
35
+ }
36
+
37
+ /**
38
+ * Get all unique configured program ids. Program ids may only be set at the
39
+ * website level, so only get the program id for the default store for
40
+ * each website.
41
+ * @return array
42
+ */
43
+ public function getAllProgramIds()
44
+ {
45
+ $config = Mage::helper('eems_affiliate/config');
46
+ return array_unique(array_filter(array_map(
47
+ function ($website) use ($config) {
48
+ return $config->getProgramId($website->getDefaultStore());
49
+ },
50
+ Mage::app()->getWebsites()
51
+ )));
52
+ }
53
+
54
+ /**
55
+ * Get a single store view for a program id. As program ids are configured
56
+ * only at the global or website level, the store view selecetd will be
57
+ * the default store view for the scope the configuration is set at. When
58
+ * set globally, the default store view for the Magento instance will be
59
+ * selected. When set at a website level, the default store view for that
60
+ * website will be used.
61
+ * @param string $programId
62
+ * @return Mage_Core_Model_Store|null
63
+ */
64
+ public function getStoreForProgramId($programId)
65
+ {
66
+ $config = Mage::helper('eems_affiliate/config');
67
+ // Check for the default store view to be this program id first, will match
68
+ // when the program id is set at the global level.
69
+ $defaultStoreView = Mage::app()->getDefaultStoreView();
70
+ $defaultProgramId = $config->getProgramId($defaultStoreView);
71
+ if ($programId === $defaultProgramId) {
72
+ return $defaultStoreView;
73
+ }
74
+ // When set at the website level, use the first website encountered
75
+ // with a matching program id
76
+ foreach (Mage::app()->getWebsites() as $website) {
77
+ $storeView = $website->getDefaultStore();
78
+ if ($config->getProgramId($storeView) === $programId) {
79
+ return $storeView;
80
+ }
81
+ }
82
+ return null;
83
+ }
84
+
85
+ /**
86
+ * Get all store views that have a program id that matches the given
87
+ * program id
88
+ * @param string $programId
89
+ * @return Mage_Core_Model_Store[]
90
+ */
91
+ public function getAllStoresForProgramId($programId)
92
+ {
93
+ $config = Mage::helper('eems_affiliate/config');
94
+ return array_filter(
95
+ Mage::app()->getStores(),
96
+ function ($store) use ($config, $programId) {
97
+ return $config->getProgramId($store) === $programId;
98
+ }
99
+ );
100
+ }
101
+
102
+ /**
103
+ * take a boolean value and return the string 'yes' or 'no' when the boolean
104
+ * value is true or false
105
+ * @param bool $value
106
+ * @return string
107
+ * @codeCoverageIgnore
108
+ */
109
+ public function parseBoolToYesNo($value)
110
+ {
111
+ return $value?'yes':'no';
112
+ }
113
+
114
+ /**
115
+ * helper function to take the source key name set in the admin panel
116
+ * and prepend a string to create a unique name for the cookie
117
+ *
118
+ * @return string
119
+ */
120
+ public function getSourceCookieName()
121
+ {
122
+ $key = Mage::helper('eems_affiliate/config')->getSourceKeyName();
123
+
124
+ return self::SOURCE_COOKIE_PREFIX.$key;
125
+ }
126
+
127
+ /**
128
+ * True if the cookie exists and has a value of SOURCE_KEY_VALUE
129
+ * False otherwise
130
+ *
131
+ * @return bool
132
+ */
133
+ public function isValidCookie()
134
+ {
135
+ $cookie = $this->getSourceCookieName();
136
+ $value = Mage::getModel('core/cookie')->get($cookie);
137
+ return ($value === self::SOURCE_KEY_VALUE);
138
+ }
139
+
140
+ /**
141
+ * Check to see if any orders have been made by the customer before
142
+ * @param Mage_Sales_Model_Order $order
143
+ * @return boolean This is the first order by this customer (email address)
144
+ */
145
+ public function isNewToFile(Mage_Sales_Model_Order $order)
146
+ {
147
+ // Customers are being identified by emails
148
+ $customerEmail = $order->getCustomerEmail();
149
+
150
+ // Look up any orders that use the same email
151
+ $orderCollection = Mage::getModel('sales/order')->getCollection();
152
+ $orderCollection->addFieldToFilter('customer_email', $customerEmail);
153
+
154
+ // Current order should be only order if new
155
+ return $orderCollection->count() <= 1;
156
+ }
157
+
158
+ /**
159
+ * Get Commissioning Category assigned to the item or pick one of the assigned categories if one isn't set
160
+ * @param Mage_Sales_Model_Order_Item $item Order Item
161
+ * @return int Category ID
162
+ */
163
+ public function getCommissioningCategory(Mage_Sales_Model_Order_Item $item)
164
+ {
165
+ $category = $item->getProduct()->getCommissioningCategory();
166
+ if ($category == '' || $category == null) {
167
+
168
+ $categoryIds = $item->getProduct()->getCategoryIds();
169
+ // if there are any categories, grab the first
170
+ if (count($categoryIds))
171
+ $category = $categoryIds[0];
172
+ else
173
+ $category = 0;
174
+ }
175
+
176
+ return $category;
177
+ }
178
+ }
app/code/community/EbayEnterprise/Affiliate/Helper/Map.php CHANGED
@@ -1,112 +1,112 @@
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
- /**
19
- * This class is composed of methods used as callbacks to the feed generation
20
- * process. All methods accepting a generic `$params` argument are allowed to
21
- * make the following assumptions about the contents of the array:
22
- * 1. It will always include an "item" key with a value of the object
23
- * being prcessed.
24
- * 2. It will always include a "store" key with a value of the store context
25
- * in which the feed is being processed.
26
- * 3. Will contain additioanl key/value pairs set in the callback mappings
27
- * in config.xml
28
- *
29
- * Additional key/value pairs may be included but may not be guaranteed.
30
- * If the methods make any additional assumptions about the contents of the
31
- * `$params` array, they must be stated with the method. This should include
32
- * any additional key/value pairs expected to be set in the config.xml.
33
- *
34
- * All such mapping methods are expected to return a single value that can be
35
- * inserted directly into the resulting feed file.
36
- */
37
- class EbayEnterprise_Affiliate_Helper_Map
38
- {
39
- /**
40
- * Get the program id using the store passed in params. Pass through to the
41
- * config helper using the store included in the $params array as the store
42
- * context to get the config value from.
43
- * @param array $params
44
- * @return string
45
- */
46
- public function getProgramId($params)
47
- {
48
- return Mage::helper('eems_affiliate/config')->getProgramId($params['store']);
49
- }
50
- /**
51
- * Get data for the key from the item. Expects "item" to be a Varien_Object,
52
- * "key" must be set. Additionally, if "format" is also included, it must
53
- * be a valid string format and will be used to format the data before it is
54
- * returned from this method.
55
- * @param array $params
56
- * @return mixed
57
- * @throws Mage_Core_Exception If the value of the `item` key is not a Varien_Object or the `key` key/value pair is not set.
58
- */
59
- public function getDataValue($params)
60
- {
61
- if (!$params['item'] instanceof Varien_Object) {
62
- throw new Mage_Core_Exception(
63
- sprintf(
64
- 'Item of type %s not compatible with %s',
65
- get_class($params['item']),
66
- __METHOD__
67
- )
68
- );
69
- }
70
- if (!isset($params['key'])) {
71
- throw new Mage_Core_Exception(
72
- 'The data "key" must be provided in the configured params for this callback.'
73
- );
74
- }
75
- $helper = Mage::helper('core');
76
- return sprintf(
77
- isset($params['format']) ? $params['format'] : '%s',
78
- preg_replace('/\s\s+/', ' ', $helper->stripTags($params['item']->getDataUsingMethod($params['key'])))
79
- );
80
- }
81
- /**
82
- * Simply return the "value" included in the params.
83
- * @param array $params
84
- * @return string
85
- * @throws Mage_Core_Exception If the `value` key/value pair is not set.
86
- */
87
- public function passStatic($params)
88
- {
89
- if (!isset($params['value'])) {
90
- throw new Mage_Core_Exception(sprintf(
91
- 'No value provided to return from %s',
92
- __METHOD__
93
- ));
94
- }
95
- return $params['value'];
96
- }
97
- /**
98
- * check if an attribute has value then return 'yes' otherwise return
99
- * 'no'
100
- * @param array $params
101
- * @return string
102
- */
103
- public function getValueYesNo(array $params)
104
- {
105
- return sprintf(
106
- isset($params['format']) ? $params['format'] : '%s',
107
- Mage::helper('eems_affiliate')->parseBoolToYesNo(
108
- $params['item']->getDataUsingMethod($params['key'])
109
- )
110
- );
111
- }
112
- }
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
+ /**
19
+ * This class is composed of methods used as callbacks to the feed generation
20
+ * process. All methods accepting a generic `$params` argument are allowed to
21
+ * make the following assumptions about the contents of the array:
22
+ * 1. It will always include an "item" key with a value of the object
23
+ * being prcessed.
24
+ * 2. It will always include a "store" key with a value of the store context
25
+ * in which the feed is being processed.
26
+ * 3. Will contain additioanl key/value pairs set in the callback mappings
27
+ * in config.xml
28
+ *
29
+ * Additional key/value pairs may be included but may not be guaranteed.
30
+ * If the methods make any additional assumptions about the contents of the
31
+ * `$params` array, they must be stated with the method. This should include
32
+ * any additional key/value pairs expected to be set in the config.xml.
33
+ *
34
+ * All such mapping methods are expected to return a single value that can be
35
+ * inserted directly into the resulting feed file.
36
+ */
37
+ class EbayEnterprise_Affiliate_Helper_Map
38
+ {
39
+ /**
40
+ * Get the program id using the store passed in params. Pass through to the
41
+ * config helper using the store included in the $params array as the store
42
+ * context to get the config value from.
43
+ * @param array $params
44
+ * @return string
45
+ */
46
+ public function getProgramId($params)
47
+ {
48
+ return Mage::helper('eems_affiliate/config')->getProgramId($params['store']);
49
+ }
50
+ /**
51
+ * Get data for the key from the item. Expects "item" to be a Varien_Object,
52
+ * "key" must be set. Additionally, if "format" is also included, it must
53
+ * be a valid string format and will be used to format the data before it is
54
+ * returned from this method.
55
+ * @param array $params
56
+ * @return mixed
57
+ * @throws Mage_Core_Exception If the value of the `item` key is not a Varien_Object or the `key` key/value pair is not set.
58
+ */
59
+ public function getDataValue($params)
60
+ {
61
+ if (!$params['item'] instanceof Varien_Object) {
62
+ throw new Mage_Core_Exception(
63
+ sprintf(
64
+ 'Item of type %s not compatible with %s',
65
+ get_class($params['item']),
66
+ __METHOD__
67
+ )
68
+ );
69
+ }
70
+ if (!isset($params['key'])) {
71
+ throw new Mage_Core_Exception(
72
+ 'The data "key" must be provided in the configured params for this callback.'
73
+ );
74
+ }
75
+ $helper = Mage::helper('core');
76
+ return sprintf(
77
+ isset($params['format']) ? $params['format'] : '%s',
78
+ preg_replace('/\s\s+/', ' ', $helper->stripTags($params['item']->getDataUsingMethod($params['key'])))
79
+ );
80
+ }
81
+ /**
82
+ * Simply return the "value" included in the params.
83
+ * @param array $params
84
+ * @return string
85
+ * @throws Mage_Core_Exception If the `value` key/value pair is not set.
86
+ */
87
+ public function passStatic($params)
88
+ {
89
+ if (!isset($params['value'])) {
90
+ throw new Mage_Core_Exception(sprintf(
91
+ 'No value provided to return from %s',
92
+ __METHOD__
93
+ ));
94
+ }
95
+ return $params['value'];
96
+ }
97
+ /**
98
+ * check if an attribute has value then return 'yes' otherwise return
99
+ * 'no'
100
+ * @param array $params
101
+ * @return string
102
+ */
103
+ public function getValueYesNo(array $params)
104
+ {
105
+ return sprintf(
106
+ isset($params['format']) ? $params['format'] : '%s',
107
+ Mage::helper('eems_affiliate')->parseBoolToYesNo(
108
+ $params['item']->getDataUsingMethod($params['key'])
109
+ )
110
+ );
111
+ }
112
+ }
app/code/community/EbayEnterprise/Affiliate/Helper/Map/Order.php CHANGED
@@ -1,172 +1,172 @@
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
- /**
19
- * The public methods of this class are all expected to be used as callbacks
20
- * for building the Affiliate corrected orders feeds.
21
- * @see EbayEnterprise_Affiliate_Helper_Map
22
- */
23
- class EbayEnterprise_Affiliate_Helper_Map_Order
24
- {
25
- /**
26
- * Get the order increment id from the order the item was created for. Expects
27
- * the "item" to be a Mage_Sales_Model_Order_Item and the "format" to be a
28
- * valid string format.
29
- * @param array $params
30
- * @return string
31
- */
32
- public function getItemOrderId($params)
33
- {
34
- $item = $params['item'];
35
- return sprintf(
36
- $params['format'],
37
- $item->getOriginalIncrementId() ?: $item->getIncrementId()
38
- );
39
- }
40
- /**
41
- * Get the updated item quantity - original quantity less any refunded
42
- * or canceled. Expects the "item" to be a Mage_Sales_Model_Order_Item.
43
- * @param array $params
44
- * @return int
45
- */
46
- public function getItemQuantity($params)
47
- {
48
- $item = $params['item'];
49
- // field limit doesn't allow this to go above 99
50
- return (int) ($item->getQtyOrdered() - $item->getQtyRefunded() - $item->getQtyCanceled());
51
- }
52
- /**
53
- * Calculate a row total including discounts.
54
- * @param array $params
55
- * @return float
56
- */
57
- private function _calculateDiscountedItemPrice($params)
58
- {
59
- $item = $params['item'];
60
- // tread bundle items as 0.00 total as their total will be represented by
61
- // the total of their children products
62
- if ($item->getProductType() === Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {
63
- return 0.00;
64
- }
65
- // don't allow negative amounts - could happen if a discounted item was cancelled
66
- return max(
67
- 0,
68
- $item->getBasePrice() - (($item->getBaseDiscountAmount() - $item->getBaseDiscountRefunded()) / $this->getItemQuantity($params))
69
- );
70
- }
71
- /**
72
- * Get the corrected total for the row - price * corrected qty. Expects the
73
- * "item" to be a Mage_Sales_Model_Order_Item, "format" to be a valid
74
- * format string and "store" to be a Mage_Core_Model_Store or otherwise viable
75
- * store identifier.
76
- * @param array $params
77
- * @return string
78
- */
79
- public function getItemPrice($params)
80
- {
81
- $config = Mage::helper('eems_affiliate/config');
82
- // transaction type of Lead should always just be "0"
83
- if ($config->getTransactionType($params['store']) === $config::TRANSACTION_TYPE_LEAD) {
84
- return 0;
85
- }
86
- return sprintf(
87
- $params['format'],
88
- $this->_calculateDiscountedItemPrice($params)
89
- );
90
- }
91
- /**
92
- * Get the corrected amount of the order. Expects "item" to be a
93
- * Mage_Sales_Model_Order, "store" to be a Mage_Core_Model_Store or otherwise
94
- * valid store identifier, and "format" to be a valid format string.
95
- * @param array $params
96
- * @return string
97
- */
98
- public function getOrderAmount($params)
99
- {
100
- $config = Mage::helper('eems_affiliate/config');
101
- // transaction type of Lead should always just be "0"
102
- if ($config->getTransactionType($params['store']) === $config::TRANSACTION_TYPE_LEAD) {
103
- return 0;
104
- }
105
- $order = $params['item'];
106
- return sprintf(
107
- $params['format'],
108
- // prevent sub-zero amounts for canceled orders with discounts
109
- max(
110
- 0,
111
- ($order->getBaseSubtotal() + $order->getBaseDiscountAmount()) -
112
- ($order->getBaseSubtotalRefunded() + $order->getBaseDiscountRefunded()) -
113
- ($order->getBaseSubtotalCanceled() + $order->getBaseDiscountCanceled())
114
- )
115
- );
116
- }
117
- /**
118
- * Get the transaction type configured for the store the order was received
119
- * in. Expects "store" to be a Mage_Core_Model_Store or otherwise valid
120
- * store identifier.
121
- * @param array $params
122
- * @return int
123
- */
124
- public function getTransactionType($params)
125
- {
126
- return (int) Mage::helper('eems_affiliate/config')->getTransactionType($params['store']);
127
- }
128
- /**
129
- * Get the order item increment id. For orders that are the result of an edit,
130
- * get the increment id of the original order. Expects "item" to be a
131
- * Mage_Sales_Model_Oorder and "format" to be a valid format string.
132
- * @param array $params
133
- * @return string
134
- */
135
- public function getOrderId($params)
136
- {
137
- $order = $params['item'];
138
- return sprintf(
139
- $params['format'],
140
- $order->getOriginalIncrementId() ?: $order->getIncrementId()
141
- );
142
- }
143
- /**
144
- * Get the SKU of the item with any prohibited characters in the SKU removed.
145
- * Expects "format" to be a valid format string. As this method also passes
146
- * through to EbayEnterprise_Affiliate_Helper_Map::getDataValue, `$params`
147
- * must also adhere to the requirements of that method - "item" is a subclass
148
- * of Varien_Object, have a "key" value set.
149
- * @param array $params
150
- * @return string
151
- */
152
- public function getItemId($params)
153
- {
154
- return sprintf(
155
- $params['format'],
156
- preg_replace('/[^a-zA-Z0-9\-_]/', '', Mage::helper('eems_affiliate/map')->getDataValue($params))
157
- );
158
- }
159
-
160
- public function getCategory($params)
161
- {
162
- $item = $params['item'];
163
- return Mage::helper('eems_affiliate')->getCommissioningCategory($item);
164
- }
165
-
166
- public function getNewToFile($params)
167
- {
168
- $order = $params['item']->getOrder();
169
-
170
- return (int) Mage::helper('eems_affiliate')->isNewToFile($order);
171
- }
172
- }
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
+ /**
19
+ * The public methods of this class are all expected to be used as callbacks
20
+ * for building the Affiliate corrected orders feeds.
21
+ * @see EbayEnterprise_Affiliate_Helper_Map
22
+ */
23
+ class EbayEnterprise_Affiliate_Helper_Map_Order
24
+ {
25
+ /**
26
+ * Get the order increment id from the order the item was created for. Expects
27
+ * the "item" to be a Mage_Sales_Model_Order_Item and the "format" to be a
28
+ * valid string format.
29
+ * @param array $params
30
+ * @return string
31
+ */
32
+ public function getItemOrderId($params)
33
+ {
34
+ $item = $params['item'];
35
+ return sprintf(
36
+ $params['format'],
37
+ $item->getOriginalIncrementId() ?: $item->getIncrementId()
38
+ );
39
+ }
40
+ /**
41
+ * Get the updated item quantity - original quantity less any refunded
42
+ * or canceled. Expects the "item" to be a Mage_Sales_Model_Order_Item.
43
+ * @param array $params
44
+ * @return int
45
+ */
46
+ public function getItemQuantity($params)
47
+ {
48
+ $item = $params['item'];
49
+ // field limit doesn't allow this to go above 99
50
+ return (int) ($item->getQtyOrdered() - $item->getQtyRefunded() - $item->getQtyCanceled());
51
+ }
52
+ /**
53
+ * Calculate a row total including discounts.
54
+ * @param array $params
55
+ * @return float
56
+ */
57
+ private function _calculateDiscountedItemPrice($params)
58
+ {
59
+ $item = $params['item'];
60
+ // tread bundle items as 0.00 total as their total will be represented by
61
+ // the total of their children products
62
+ if ($item->getProductType() === Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {
63
+ return 0.00;
64
+ }
65
+ // don't allow negative amounts - could happen if a discounted item was cancelled
66
+ return max(
67
+ 0,
68
+ $item->getBasePrice() - (($item->getBaseDiscountAmount() - $item->getBaseDiscountRefunded()) / $this->getItemQuantity($params))
69
+ );
70
+ }
71
+ /**
72
+ * Get the corrected total for the row - price * corrected qty. Expects the
73
+ * "item" to be a Mage_Sales_Model_Order_Item, "format" to be a valid
74
+ * format string and "store" to be a Mage_Core_Model_Store or otherwise viable
75
+ * store identifier.
76
+ * @param array $params
77
+ * @return string
78
+ */
79
+ public function getItemPrice($params)
80
+ {
81
+ $config = Mage::helper('eems_affiliate/config');
82
+ // transaction type of Lead should always just be "0"
83
+ if ($config->getTransactionType($params['store']) === $config::TRANSACTION_TYPE_LEAD) {
84
+ return 0;
85
+ }
86
+ return sprintf(
87
+ $params['format'],
88
+ $this->_calculateDiscountedItemPrice($params)
89
+ );
90
+ }
91
+ /**
92
+ * Get the corrected amount of the order. Expects "item" to be a
93
+ * Mage_Sales_Model_Order, "store" to be a Mage_Core_Model_Store or otherwise
94
+ * valid store identifier, and "format" to be a valid format string.
95
+ * @param array $params
96
+ * @return string
97
+ */
98
+ public function getOrderAmount($params)
99
+ {
100
+ $config = Mage::helper('eems_affiliate/config');
101
+ // transaction type of Lead should always just be "0"
102
+ if ($config->getTransactionType($params['store']) === $config::TRANSACTION_TYPE_LEAD) {
103
+ return 0;
104
+ }
105
+ $order = $params['item'];
106
+ return sprintf(
107
+ $params['format'],
108
+ // prevent sub-zero amounts for canceled orders with discounts
109
+ max(
110
+ 0,
111
+ ($order->getBaseSubtotal() + $order->getBaseDiscountAmount()) -
112
+ ($order->getBaseSubtotalRefunded() + $order->getBaseDiscountRefunded()) -
113
+ ($order->getBaseSubtotalCanceled() + $order->getBaseDiscountCanceled())
114
+ )
115
+ );
116
+ }
117
+ /**
118
+ * Get the transaction type configured for the store the order was received
119
+ * in. Expects "store" to be a Mage_Core_Model_Store or otherwise valid
120
+ * store identifier.
121
+ * @param array $params
122
+ * @return int
123
+ */
124
+ public function getTransactionType($params)
125
+ {
126
+ return (int) Mage::helper('eems_affiliate/config')->getTransactionType($params['store']);
127
+ }
128
+ /**
129
+ * Get the order item increment id. For orders that are the result of an edit,
130
+ * get the increment id of the original order. Expects "item" to be a
131
+ * Mage_Sales_Model_Oorder and "format" to be a valid format string.
132
+ * @param array $params
133
+ * @return string
134
+ */
135
+ public function getOrderId($params)
136
+ {
137
+ $order = $params['item'];
138
+ return sprintf(
139
+ $params['format'],
140
+ $order->getOriginalIncrementId() ?: $order->getIncrementId()
141
+ );
142
+ }
143
+ /**
144
+ * Get the SKU of the item with any prohibited characters in the SKU removed.
145
+ * Expects "format" to be a valid format string. As this method also passes
146
+ * through to EbayEnterprise_Affiliate_Helper_Map::getDataValue, `$params`
147
+ * must also adhere to the requirements of that method - "item" is a subclass
148
+ * of Varien_Object, have a "key" value set.
149
+ * @param array $params
150
+ * @return string
151
+ */
152
+ public function getItemId($params)
153
+ {
154
+ return sprintf(
155
+ $params['format'],
156
+ preg_replace('/[^a-zA-Z0-9\-_]/', '', Mage::helper('eems_affiliate/map')->getDataValue($params))
157
+ );
158
+ }
159
+
160
+ public function getCategory($params)
161
+ {
162
+ $item = $params['item'];
163
+ return Mage::helper('eems_affiliate')->getCommissioningCategory($item);
164
+ }
165
+
166
+ public function getNewToFile($params)
167
+ {
168
+ $order = $params['item']->getOrder();
169
+
170
+ return (int) Mage::helper('eems_affiliate')->isNewToFile($order);
171
+ }
172
+ }
app/code/community/EbayEnterprise/Affiliate/Helper/Map/Product.php CHANGED
@@ -1,135 +1,135 @@
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
- /**
19
- * The public methods of this class are all expected to be used as callbacks
20
- * for building the Affiliate product feed.
21
- * @see EbayEnterprise_Affiliate_Helper_Map
22
- */
23
- class EbayEnterprise_Affiliate_Helper_Map_Product
24
- {
25
- const MEDIA_PATH = 'catalog/product';
26
- const NO_SELECTION = 'no_selection';
27
- /**
28
- * Get a product first chained categories meaning that a product can be
29
- * long to many chained of categories. Chained of categories here mean that
30
- * a category root to it's inner most leaf child. Expects "item" to be a
31
- * Mage_Catalog_Model_Product. If "format" is included in `$params`, it will
32
- * must be a valid format string and will be used to format the data returned
33
- * from this method.
34
- * @param array $params
35
- * @return string
36
- */
37
- public function getCategory(array $params)
38
- {
39
- $categories = $params['item']->getCategoryCollection();
40
- $category = $categories->getFirstItem();
41
- $format = isset($params['format']) ? $params['format'] : '%s';
42
- return !is_null($category) ?
43
- sprintf($format, $this->_buildCategoryTree($category)) : null;
44
- }
45
- /**
46
- * Take an array of category entity ids return a collection of categories
47
- * in this array of category ids
48
- * @param array $entityIds list of category ids
49
- * @return Mage_Catalog_Model_Resource_Category_Collection
50
- */
51
- protected function _getCategoriesByIds(array $entityIds)
52
- {
53
- return Mage::getResourceModel('catalog/category_collection')
54
- ->addAttributeToSelect(array('name', 'entity_id'))
55
- ->addAttributeToFilter(array(array('attribute' => 'entity_id', 'in' => $entityIds)))
56
- ->load();
57
- }
58
- /**
59
- * Take a Mage_Catalog_Model_Category object and build a category tree from
60
- * the child leaf to the root of the category (root > inner child > inner most child)
61
- * @param Mage_Catalog_Model_Category $category the inner most child
62
- * @return string
63
- */
64
- protected function _buildCategoryTree(Mage_Catalog_Model_Category $category)
65
- {
66
- $collecton = $this->_getCategoriesByIds(explode('/', $category->getPath()));
67
- $categories = array();
68
- foreach ($collecton as $cat) {
69
- $categories[] = $cat->getName();
70
- }
71
- return implode(' > ', array_filter($categories));
72
- }
73
- /**
74
- * get a product image view URL
75
- * Note: calling Mage_Catalog_Model_Product::getImageUrl, or getThumbnailUrl
76
- * will return the wrong URL when running the feed via CRONJOB will return
77
- * to something similar to this:
78
- * (http://<host>/skin/frontend/default/default/images/catalog/product/placeholder/image.jpg)
79
- * so this method will try to extrapolate as best it can the absolute path of
80
- * the image by calling getImage or getThumbnail which will give the
81
- * a relative path to the image in which we passed to a specialize method to try
82
- * to build the absolute URL path to the image
83
- * @param array $params
84
- * @return string
85
- */
86
- public function getImageUrl(array $params)
87
- {
88
- $item = $params['item'];
89
- // calling the getThumbnail or getImage will return a relative path
90
- // to where we think product image will live, see (self::MEDIA_PATH) constant
91
- $image = trim($item->getDataUsingMethod($params['key']));
92
- $format = isset($params['format']) ? $params['format'] : '%s';
93
- return ($image !== '' && $image !== static::NO_SELECTION)?
94
- sprintf($format, $this->_getAbsoluteImagePath($image)) : null;
95
- }
96
- /**
97
- * get the absolute URL product media path
98
- * @param string $image the relative image
99
- * @return string
100
- * @codeCoverageIgnore
101
- */
102
- protected function _getAbsoluteImagePath($image)
103
- {
104
- // concatenating magento absolute path to the media folder, with a class
105
- // constant base on observation of where we assume all product images stay
106
- // and along with the passed in image relative path
107
- return Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) .
108
- static::MEDIA_PATH . $image;
109
- }
110
- /**
111
- * get a product manage stock quantity
112
- * @param array $params
113
- * @return string
114
- */
115
- public function getInStockQty(array $params)
116
- {
117
- return (int) Mage::getModel('cataloginventory/stock_item')
118
- ->loadByProduct($params['item'])
119
- ->getQty();
120
- }
121
- /**
122
- * check if a product is in stock and return 'yes' or 'no' in respect to
123
- * the outcome
124
- * @param array $params
125
- * @return string
126
- */
127
- public function getInStockYesNo(array $params)
128
- {
129
- return Mage::helper('eems_affiliate')->parseBoolToYesNo(
130
- Mage::getModel('cataloginventory/stock_item')
131
- ->loadByProduct($params['item'])
132
- ->getIsInStock()
133
- );
134
- }
135
- }
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
+ /**
19
+ * The public methods of this class are all expected to be used as callbacks
20
+ * for building the Affiliate product feed.
21
+ * @see EbayEnterprise_Affiliate_Helper_Map
22
+ */
23
+ class EbayEnterprise_Affiliate_Helper_Map_Product
24
+ {
25
+ const MEDIA_PATH = 'catalog/product';
26
+ const NO_SELECTION = 'no_selection';
27
+ /**
28
+ * Get a product first chained categories meaning that a product can be
29
+ * long to many chained of categories. Chained of categories here mean that
30
+ * a category root to it's inner most leaf child. Expects "item" to be a
31
+ * Mage_Catalog_Model_Product. If "format" is included in `$params`, it will
32
+ * must be a valid format string and will be used to format the data returned
33
+ * from this method.
34
+ * @param array $params
35
+ * @return string
36
+ */
37
+ public function getCategory(array $params)
38
+ {
39
+ $categories = $params['item']->getCategoryCollection();
40
+ $category = $categories->getFirstItem();
41
+ $format = isset($params['format']) ? $params['format'] : '%s';
42
+ return !is_null($category) ?
43
+ sprintf($format, $this->_buildCategoryTree($category)) : null;
44
+ }
45
+ /**
46
+ * Take an array of category entity ids return a collection of categories
47
+ * in this array of category ids
48
+ * @param array $entityIds list of category ids
49
+ * @return Mage_Catalog_Model_Resource_Category_Collection
50
+ */
51
+ protected function _getCategoriesByIds(array $entityIds)
52
+ {
53
+ return Mage::getResourceModel('catalog/category_collection')
54
+ ->addAttributeToSelect(array('name', 'entity_id'))
55
+ ->addAttributeToFilter(array(array('attribute' => 'entity_id', 'in' => $entityIds)))
56
+ ->load();
57
+ }
58
+ /**
59
+ * Take a Mage_Catalog_Model_Category object and build a category tree from
60
+ * the child leaf to the root of the category (root > inner child > inner most child)
61
+ * @param Mage_Catalog_Model_Category $category the inner most child
62
+ * @return string
63
+ */
64
+ protected function _buildCategoryTree(Mage_Catalog_Model_Category $category)
65
+ {
66
+ $collecton = $this->_getCategoriesByIds(explode('/', $category->getPath()));
67
+ $categories = array();
68
+ foreach ($collecton as $cat) {
69
+ $categories[] = $cat->getName();
70
+ }
71
+ return implode(' > ', array_filter($categories));
72
+ }
73
+ /**
74
+ * get a product image view URL
75
+ * Note: calling Mage_Catalog_Model_Product::getImageUrl, or getThumbnailUrl
76
+ * will return the wrong URL when running the feed via CRONJOB will return
77
+ * to something similar to this:
78
+ * (http://<host>/skin/frontend/default/default/images/catalog/product/placeholder/image.jpg)
79
+ * so this method will try to extrapolate as best it can the absolute path of
80
+ * the image by calling getImage or getThumbnail which will give the
81
+ * a relative path to the image in which we passed to a specialize method to try
82
+ * to build the absolute URL path to the image
83
+ * @param array $params
84
+ * @return string
85
+ */
86
+ public function getImageUrl(array $params)
87
+ {
88
+ $item = $params['item'];
89
+ // calling the getThumbnail or getImage will return a relative path
90
+ // to where we think product image will live, see (self::MEDIA_PATH) constant
91
+ $image = trim($item->getDataUsingMethod($params['key']));
92
+ $format = isset($params['format']) ? $params['format'] : '%s';
93
+ return ($image !== '' && $image !== static::NO_SELECTION)?
94
+ sprintf($format, $this->_getAbsoluteImagePath($image)) : null;
95
+ }
96
+ /**
97
+ * get the absolute URL product media path
98
+ * @param string $image the relative image
99
+ * @return string
100
+ * @codeCoverageIgnore
101
+ */
102
+ protected function _getAbsoluteImagePath($image)
103
+ {
104
+ // concatenating magento absolute path to the media folder, with a class
105
+ // constant base on observation of where we assume all product images stay
106
+ // and along with the passed in image relative path
107
+ return Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) .
108
+ static::MEDIA_PATH . $image;
109
+ }
110
+ /**
111
+ * get a product manage stock quantity
112
+ * @param array $params
113
+ * @return string
114
+ */
115
+ public function getInStockQty(array $params)
116
+ {
117
+ return (int) Mage::getModel('cataloginventory/stock_item')
118
+ ->loadByProduct($params['item'])
119
+ ->getQty();
120
+ }
121
+ /**
122
+ * check if a product is in stock and return 'yes' or 'no' in respect to
123
+ * the outcome
124
+ * @param array $params
125
+ * @return string
126
+ */
127
+ public function getInStockYesNo(array $params)
128
+ {
129
+ return Mage::helper('eems_affiliate')->parseBoolToYesNo(
130
+ Mage::getModel('cataloginventory/stock_item')
131
+ ->loadByProduct($params['item'])
132
+ ->getIsInStock()
133
+ );
134
+ }
135
+ }
app/code/community/EbayEnterprise/Affiliate/Model/Feed/Abstract.php CHANGED
@@ -1,337 +1,337 @@
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
-
19
- abstract class EbayEnterprise_Affiliate_Model_Feed_Abstract
20
- {
21
- /**
22
- * The store context the feed is generated for. May be set to any viable store
23
- * identified.
24
- * @var Mage_Core_Model_Store
25
- */
26
- protected $_store;
27
- /**
28
- * Get a collection of items to be included in the feed.
29
- * @return Varien_Data_Collection
30
- */
31
- abstract protected function _getItems();
32
- /**
33
- * Get fields to include in the feed. Fields are expected to map to existing
34
- * callbacks defined in the config.xml.
35
- * @see self::_invokeCallback
36
- * @return array
37
- */
38
- abstract protected function _getFeedFields();
39
- /**
40
- * Gets the filename format for the feed from config for this feed.
41
- * @return string
42
- */
43
- abstract protected function _getFileName();
44
- /**
45
- * Get the delimiter to use in the csv file
46
- * @return string
47
- * @codeCoverageIgnore
48
- */
49
- protected function _getDelimiter()
50
- {
51
- return ',';
52
- }
53
- /**
54
- * Get the encolsure to use in the csv file
55
- * @return string
56
- * @codeCoverageIgnore
57
- */
58
- protected function _getEnclosure()
59
- {
60
- return '"';
61
- }
62
- /**
63
- * Set up the store property.
64
- */
65
- public function __construct($args = array())
66
- {
67
- // Set the store context to the given store or null which whill
68
- // result in the "current" store.
69
- $this->setStore(isset($args['store']) ? $args['store'] : null);
70
- }
71
- /**
72
- * Set the store context for the feed, converting whatever viable store
73
- * ID is passed in to an actual store instance.
74
- * @see Mage_Core_Model_App::getStore for how various identifiers may be used to represent a store
75
- * @param null|string|bool|int|Mage_Core_Model_Store
76
- * @codeCoverageIgnore
77
- */
78
- public function setStore($storeId)
79
- {
80
- $this->_store = Mage::app()->getStore($storeId);
81
- return $this;
82
- }
83
- /**
84
- * Get the store instance the feed is being executed within.
85
- * @return Mage_Core_Model_Store
86
- * @codeCoverageIgnore
87
- */
88
- public function getStore()
89
- {
90
- return $this->_store;
91
- }
92
- /**
93
- * Create the feed file and drop it in the configured export directory.
94
- * @return self
95
- */
96
- public function generateFeed()
97
- {
98
- $this->_generateFile($this->_buildFeedData());
99
- return $this;
100
- }
101
- /**
102
- * Create arrays of data that should be included in the feed file. Each array
103
- * should included a value for every field that is expected to be in the feed.
104
- * @return array
105
- */
106
- protected function _buildFeedData()
107
- {
108
- $items = $this->_getItems();
109
- Mage::log(sprintf('building feed for %d items', $items->count()));
110
- // array_map must be on an array - $items is a collection so need to get the
111
- // underlying array to pass to array_map
112
- return array_map(array($this, '_applyMapping'), $items->getItems());
113
- }
114
- /**
115
- * Use the callback mapping to create the data that represents the given item
116
- * in the feed.
117
- * @param mixed $item Likely a Varien_Object but could really be anything.
118
- * @return array
119
- */
120
- protected function _applyMapping($item)
121
- {
122
- $fields = array();
123
- $mappings = Mage::helper('eems_affiliate/config')->getCallbackMappings();
124
- foreach ($this->_getFeedFields() as $feedField) {
125
- // If the mapping doesn't exist, supplying an empty array will eventually
126
- // result in an exception for being an invalid config mapping.
127
- // @see self::_validateCallbackConfig
128
- $callback = isset($mappings[$feedField]) ? $mappings[$feedField] : array();
129
- // exclude any mappings that have a type of "disabled"
130
- if (!isset($callback['type']) || $callback['type'] !== 'disabled') {
131
- $fields[] = $this->_invokeCallback($callback, $item);
132
- }
133
- }
134
- return $fields;
135
- }
136
- /**
137
- * Given a set of callback configuration and an item, invoke the configured
138
- * callback and return the value. The callback configuration must meet the
139
- * following requirements:
140
- * - May contain a "type" key indicating the type of factory to use. May be
141
- * one of:
142
- * - "disabled" - will not be included in the feed
143
- * - "helper" - will use the Mage::helper factory
144
- * - "model" - will use the Mage::getModel factory
145
- * - "singleton" - will use the Mage::getSingleton factory
146
- * - If not included, will default to "singleton"
147
- * - When type is "disabled" no other key/value pairs are required.
148
- * - If type is not "disabled" the following must be included:
149
- * - "class" must be a valid class alias for the configured factory type
150
- * - "method" must be a valid method on the configured class
151
- * - A "params" key may also be included. If included, its value must be
152
- * an array of key/value pairs that will be included in the params array
153
- * passed to the callback method.
154
- * Every callback will be called with an array of params. The array will
155
- * contain any key/value pairs added in the config as well as an "item" key
156
- * which will have the item being mapped as the value and a "store" key which
157
- * will have the store instance representing the store view context the feed
158
- * is being generated for.
159
- *
160
- * Example configuration:
161
- * <code>
162
- * // This callback configuration array:
163
- * $cfg = array(
164
- * 'type' => 'helper',
165
- * 'class' => 'eems_affiliate/map',
166
- * 'column_name' => 'OID',
167
- * 'params' => array(
168
- * 'key' => 'increment_id',
169
- * ),
170
- * );
171
- * // Will result in the following invocation:
172
- * Mage::helper('eems_affiliate/map')->getDataValue(
173
- * array('key' => 'increment_id', 'item' => $item)
174
- * );
175
- * </code>
176
- *
177
- * @see src/app/code/community/EbayEnterprise/Affiliate/etc/config.xml marketing_solutions/eems_affiliate/feeds contains mappings used for the affiliate feeds
178
- * @param array $callbackConfig
179
- * @param mixed $item
180
- * @return mixed
181
- */
182
- protected function _invokeCallback($callbackConfig, $item)
183
- {
184
- $obj = $this->_getCallbackInstance($callbackConfig);
185
- $params = isset($callbackConfig['params']) ? $callbackConfig['params'] : array();
186
- $item->setStoreId($this->getStore()->getId());
187
- $params['item'] = $item;
188
- $params['store'] = $this->getStore();
189
- $method = $callbackConfig['method'];
190
- if (method_exists($obj, $method)) {
191
- return $obj->$method($params);
192
- } else {
193
- throw new EbayEnterprise_Affiliate_Exception_Configuration(
194
- sprintf(
195
- 'Configured callback method %s::%s does not exist',
196
- get_class($obj),
197
- $method
198
- )
199
- );
200
- }
201
- }
202
- /**
203
- * Get an instance of the configured callback.
204
- * @param array $callbackConfig
205
- * @return mixed
206
- */
207
- protected function _getCallbackInstance($callbackConfig)
208
- {
209
- $this->_validateCallbackConfig($callbackConfig);
210
- switch ($callbackConfig['type']) {
211
- // 'disabled' type callback mappings shouldn't pass through here under
212
- // "normal" circumstances (filtered out in apply mapping) but if they do,
213
- // do nothing and return null
214
- case 'disabled':
215
- return null;
216
- case 'helper':
217
- return Mage::helper($callbackConfig['class']);
218
- case 'model':
219
- return Mage::getModel($callbackConfig['class']);
220
- case 'singleton':
221
- default:
222
- return Mage::getSingleton($callbackConfig['class']);
223
- }
224
- }
225
- /**
226
- * Make sure the callback configuration is valid. If it isn't throw an
227
- * exception.
228
- * @param array $callbackConfig
229
- * @return self
230
- * @throws EbayEnterprise_Affiliate_Exception_Configuration If callback configuration is not valid
231
- */
232
- protected function _validateCallbackConfig($callbackConfig)
233
- {
234
- if (empty($callbackConfig)) {
235
- throw new EbayEnterprise_Affiliate_Exception_Configuration('Callback configuration is empty or missing.');
236
- }
237
- // When the callback is "disabled" no other configuration is necessary.
238
- if (isset($callbackConfig['type']) && $callbackConfig['type'] === 'disabled') {
239
- return $this;
240
- }
241
- // If not disabled, must have a class and method - separate checks for
242
- // more simply providing more useful error messages.
243
- $missingFields = array_diff(array('class', 'method', 'column_name'), array_keys($callbackConfig));
244
- if ($missingFields) {
245
- throw new EbayEnterprise_Affiliate_Exception_Configuration(
246
- sprintf('Callback missing %s configuration.', implode(', ', $missingFields))
247
- );
248
- }
249
- return $this;
250
- }
251
- /**
252
- * Create the file and drop it in the configured export directory.
253
- * @param array $feedData
254
- * @return self
255
- */
256
- protected function _generateFile($feedData)
257
- {
258
- if (empty($feedData)) {
259
- return $this;
260
- }
261
- $delimiter = $this->_getDelimiter();
262
- $enclosure = $this->_getEnclosure();
263
-
264
- $tmpFile = fopen('php://temp', 'r+');
265
- fputcsv($tmpFile, $this->_getHeaders(), $delimiter, $enclosure);
266
- foreach ($feedData as $row) {
267
- fputcsv($tmpFile, $row, $delimiter, $enclosure);
268
- }
269
- rewind($tmpFile);
270
-
271
- $targetPath = $this->_generateFilePath();
272
- $this->_checkAndCreateFolder(dirname($targetPath));
273
-
274
- // send the contents of the temp stream to the actual file
275
- file_put_contents(
276
- $targetPath,
277
- stream_get_contents($tmpFile)
278
- );
279
- return $this;
280
- }
281
- /**
282
- * Generate the full path to the location where the file should be created.
283
- * @return string
284
- */
285
- protected function _generateFilePath()
286
- {
287
- return self::normalPaths(
288
- Mage::getBaseDir(),
289
- Mage::helper('eems_affiliate/config', $this->getStore())->getExportFilePath(),
290
- $this->_getFileName()
291
- );
292
- }
293
- /**
294
- * The CSV file headers should be the keys used in the configured mappings.
295
- * @return array
296
- */
297
- protected function _getHeaders()
298
- {
299
- $mappings = Mage::helper('eems_affiliate/config')->getCallbackMappings();
300
- $headers = array();
301
- foreach ($this->_getFeedFields() as $field) {
302
- $callbackMapping = isset($mappings[$field]) ? $mappings[$field] : array();
303
- if (!isset($callbackMapping['type']) || $callbackMapping['type'] !== 'disabled') {
304
- $this->_validateCallbackConfig($callbackMapping);
305
- $headers[] = $callbackMapping['column_name'];
306
- }
307
- }
308
- return $headers;
309
- }
310
- /**
311
- * Make sure that all necessary directories in the given path exist. Create
312
- * any that do not.
313
- * @param string $dirPath
314
- * @return self
315
- */
316
- protected function _checkAndCreateFolder($dirPath)
317
- {
318
- // Use the model factory to allow for DI via the factory
319
- $fileIo = Mage::getModel('Varien_Io_File');
320
- $fileIo->open(array('path' => Mage::getBaseDir()));
321
- $fileIo->checkAndCreateFolder($dirPath);
322
- return $this;
323
- }
324
- /**
325
- * Given an arbitrary array of arguments, join them to make a valid path.
326
- * @param string $_,... Parts of the path to be joined
327
- * @return string
328
- */
329
- public static function normalPaths()
330
- {
331
- $paths = implode(DS, func_get_args());
332
- // Retain a single leading slash; otherwise remove all leading, trailing
333
- // and duplicate slashes.
334
- return ((substr($paths, 0, 1) === DS) ? DS : '') .
335
- implode(DS, array_filter(explode(DS, $paths)));
336
- }
337
- }
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
+
19
+ abstract class EbayEnterprise_Affiliate_Model_Feed_Abstract
20
+ {
21
+ /**
22
+ * The store context the feed is generated for. May be set to any viable store
23
+ * identified.
24
+ * @var Mage_Core_Model_Store
25
+ */
26
+ protected $_store;
27
+ /**
28
+ * Get a collection of items to be included in the feed.
29
+ * @return Varien_Data_Collection
30
+ */
31
+ abstract protected function _getItems();
32
+ /**
33
+ * Get fields to include in the feed. Fields are expected to map to existing
34
+ * callbacks defined in the config.xml.
35
+ * @see self::_invokeCallback
36
+ * @return array
37
+ */
38
+ abstract protected function _getFeedFields();
39
+ /**
40
+ * Gets the filename format for the feed from config for this feed.
41
+ * @return string
42
+ */
43
+ abstract protected function _getFileName();
44
+ /**
45
+ * Get the delimiter to use in the csv file
46
+ * @return string
47
+ * @codeCoverageIgnore
48
+ */
49
+ protected function _getDelimiter()
50
+ {
51
+ return ',';
52
+ }
53
+ /**
54
+ * Get the encolsure to use in the csv file
55
+ * @return string
56
+ * @codeCoverageIgnore
57
+ */
58
+ protected function _getEnclosure()
59
+ {
60
+ return '"';
61
+ }
62
+ /**
63
+ * Set up the store property.
64
+ */
65
+ public function __construct($args = array())
66
+ {
67
+ // Set the store context to the given store or null which whill
68
+ // result in the "current" store.
69
+ $this->setStore(isset($args['store']) ? $args['store'] : null);
70
+ }
71
+ /**
72
+ * Set the store context for the feed, converting whatever viable store
73
+ * ID is passed in to an actual store instance.
74
+ * @see Mage_Core_Model_App::getStore for how various identifiers may be used to represent a store
75
+ * @param null|string|bool|int|Mage_Core_Model_Store
76
+ * @codeCoverageIgnore
77
+ */
78
+ public function setStore($storeId)
79
+ {
80
+ $this->_store = Mage::app()->getStore($storeId);
81
+ return $this;
82
+ }
83
+ /**
84
+ * Get the store instance the feed is being executed within.
85
+ * @return Mage_Core_Model_Store
86
+ * @codeCoverageIgnore
87
+ */
88
+ public function getStore()
89
+ {
90
+ return $this->_store;
91
+ }
92
+ /**
93
+ * Create the feed file and drop it in the configured export directory.
94
+ * @return self
95
+ */
96
+ public function generateFeed()
97
+ {
98
+ $this->_generateFile($this->_buildFeedData());
99
+ return $this;
100
+ }
101
+ /**
102
+ * Create arrays of data that should be included in the feed file. Each array
103
+ * should included a value for every field that is expected to be in the feed.
104
+ * @return array
105
+ */
106
+ protected function _buildFeedData()
107
+ {
108
+ $items = $this->_getItems();
109
+ Mage::log(sprintf('building feed for %d items', $items->count()));
110
+ // array_map must be on an array - $items is a collection so need to get the
111
+ // underlying array to pass to array_map
112
+ return array_map(array($this, '_applyMapping'), $items->getItems());
113
+ }
114
+ /**
115
+ * Use the callback mapping to create the data that represents the given item
116
+ * in the feed.
117
+ * @param mixed $item Likely a Varien_Object but could really be anything.
118
+ * @return array
119
+ */
120
+ protected function _applyMapping($item)
121
+ {
122
+ $fields = array();
123
+ $mappings = Mage::helper('eems_affiliate/config')->getCallbackMappings();
124
+ foreach ($this->_getFeedFields() as $feedField) {
125
+ // If the mapping doesn't exist, supplying an empty array will eventually
126
+ // result in an exception for being an invalid config mapping.
127
+ // @see self::_validateCallbackConfig
128
+ $callback = isset($mappings[$feedField]) ? $mappings[$feedField] : array();
129
+ // exclude any mappings that have a type of "disabled"
130
+ if (!isset($callback['type']) || $callback['type'] !== 'disabled') {
131
+ $fields[] = $this->_invokeCallback($callback, $item);
132
+ }
133
+ }
134
+ return $fields;
135
+ }
136
+ /**
137
+ * Given a set of callback configuration and an item, invoke the configured
138
+ * callback and return the value. The callback configuration must meet the
139
+ * following requirements:
140
+ * - May contain a "type" key indicating the type of factory to use. May be
141
+ * one of:
142
+ * - "disabled" - will not be included in the feed
143
+ * - "helper" - will use the Mage::helper factory
144
+ * - "model" - will use the Mage::getModel factory
145
+ * - "singleton" - will use the Mage::getSingleton factory
146
+ * - If not included, will default to "singleton"
147
+ * - When type is "disabled" no other key/value pairs are required.
148
+ * - If type is not "disabled" the following must be included:
149
+ * - "class" must be a valid class alias for the configured factory type
150
+ * - "method" must be a valid method on the configured class
151
+ * - A "params" key may also be included. If included, its value must be
152
+ * an array of key/value pairs that will be included in the params array
153
+ * passed to the callback method.
154
+ * Every callback will be called with an array of params. The array will
155
+ * contain any key/value pairs added in the config as well as an "item" key
156
+ * which will have the item being mapped as the value and a "store" key which
157
+ * will have the store instance representing the store view context the feed
158
+ * is being generated for.
159
+ *
160
+ * Example configuration:
161
+ * <code>
162
+ * // This callback configuration array:
163
+ * $cfg = array(
164
+ * 'type' => 'helper',
165
+ * 'class' => 'eems_affiliate/map',
166
+ * 'column_name' => 'OID',
167
+ * 'params' => array(
168
+ * 'key' => 'increment_id',
169
+ * ),
170
+ * );
171
+ * // Will result in the following invocation:
172
+ * Mage::helper('eems_affiliate/map')->getDataValue(
173
+ * array('key' => 'increment_id', 'item' => $item)
174
+ * );
175
+ * </code>
176
+ *
177
+ * @see src/app/code/community/EbayEnterprise/Affiliate/etc/config.xml marketing_solutions/eems_affiliate/feeds contains mappings used for the affiliate feeds
178
+ * @param array $callbackConfig
179
+ * @param mixed $item
180
+ * @return mixed
181
+ */
182
+ protected function _invokeCallback($callbackConfig, $item)
183
+ {
184
+ $obj = $this->_getCallbackInstance($callbackConfig);
185
+ $params = isset($callbackConfig['params']) ? $callbackConfig['params'] : array();
186
+ $item->setStoreId($this->getStore()->getId());
187
+ $params['item'] = $item;
188
+ $params['store'] = $this->getStore();
189
+ $method = $callbackConfig['method'];
190
+ if (method_exists($obj, $method)) {
191
+ return $obj->$method($params);
192
+ } else {
193
+ throw new EbayEnterprise_Affiliate_Exception_Configuration(
194
+ sprintf(
195
+ 'Configured callback method %s::%s does not exist',
196
+ get_class($obj),
197
+ $method
198
+ )
199
+ );
200
+ }
201
+ }
202
+ /**
203
+ * Get an instance of the configured callback.
204
+ * @param array $callbackConfig
205
+ * @return mixed
206
+ */
207
+ protected function _getCallbackInstance($callbackConfig)
208
+ {
209
+ $this->_validateCallbackConfig($callbackConfig);
210
+ switch ($callbackConfig['type']) {
211
+ // 'disabled' type callback mappings shouldn't pass through here under
212
+ // "normal" circumstances (filtered out in apply mapping) but if they do,
213
+ // do nothing and return null
214
+ case 'disabled':
215
+ return null;
216
+ case 'helper':
217
+ return Mage::helper($callbackConfig['class']);
218
+ case 'model':
219
+ return Mage::getModel($callbackConfig['class']);
220
+ case 'singleton':
221
+ default:
222
+ return Mage::getSingleton($callbackConfig['class']);
223
+ }
224
+ }
225
+ /**
226
+ * Make sure the callback configuration is valid. If it isn't throw an
227
+ * exception.
228
+ * @param array $callbackConfig
229
+ * @return self
230
+ * @throws EbayEnterprise_Affiliate_Exception_Configuration If callback configuration is not valid
231
+ */
232
+ protected function _validateCallbackConfig($callbackConfig)
233
+ {
234
+ if (empty($callbackConfig)) {
235
+ throw new EbayEnterprise_Affiliate_Exception_Configuration('Callback configuration is empty or missing.');
236
+ }
237
+ // When the callback is "disabled" no other configuration is necessary.
238
+ if (isset($callbackConfig['type']) && $callbackConfig['type'] === 'disabled') {
239
+ return $this;
240
+ }
241
+ // If not disabled, must have a class and method - separate checks for
242
+ // more simply providing more useful error messages.
243
+ $missingFields = array_diff(array('class', 'method', 'column_name'), array_keys($callbackConfig));
244
+ if ($missingFields) {
245
+ throw new EbayEnterprise_Affiliate_Exception_Configuration(
246
+ sprintf('Callback missing %s configuration.', implode(', ', $missingFields))
247
+ );
248
+ }
249
+ return $this;
250
+ }
251
+ /**
252
+ * Create the file and drop it in the configured export directory.
253
+ * @param array $feedData
254
+ * @return self
255
+ */
256
+ protected function _generateFile($feedData)
257
+ {
258
+ if (empty($feedData)) {
259
+ return $this;
260
+ }
261
+ $delimiter = $this->_getDelimiter();
262
+ $enclosure = $this->_getEnclosure();
263
+
264
+ $tmpFile = fopen('php://temp', 'r+');
265
+ fputcsv($tmpFile, $this->_getHeaders(), $delimiter, $enclosure);
266
+ foreach ($feedData as $row) {
267
+ fputcsv($tmpFile, $row, $delimiter, $enclosure);
268
+ }
269
+ rewind($tmpFile);
270
+
271
+ $targetPath = $this->_generateFilePath();
272
+ $this->_checkAndCreateFolder(dirname($targetPath));
273
+
274
+ // send the contents of the temp stream to the actual file
275
+ file_put_contents(
276
+ $targetPath,
277
+ stream_get_contents($tmpFile)
278
+ );
279
+ return $this;
280
+ }
281
+ /**
282
+ * Generate the full path to the location where the file should be created.
283
+ * @return string
284
+ */
285
+ protected function _generateFilePath()
286
+ {
287
+ return self::normalPaths(
288
+ Mage::getBaseDir(),
289
+ Mage::helper('eems_affiliate/config', $this->getStore())->getExportFilePath(),
290
+ $this->_getFileName()
291
+ );
292
+ }
293
+ /**
294
+ * The CSV file headers should be the keys used in the configured mappings.
295
+ * @return array
296
+ */
297
+ protected function _getHeaders()
298
+ {
299
+ $mappings = Mage::helper('eems_affiliate/config')->getCallbackMappings();
300
+ $headers = array();
301
+ foreach ($this->_getFeedFields() as $field) {
302
+ $callbackMapping = isset($mappings[$field]) ? $mappings[$field] : array();
303
+ if (!isset($callbackMapping['type']) || $callbackMapping['type'] !== 'disabled') {
304
+ $this->_validateCallbackConfig($callbackMapping);
305
+ $headers[] = $callbackMapping['column_name'];
306
+ }
307
+ }
308
+ return $headers;
309
+ }
310
+ /**
311
+ * Make sure that all necessary directories in the given path exist. Create
312
+ * any that do not.
313
+ * @param string $dirPath
314
+ * @return self
315
+ */
316
+ protected function _checkAndCreateFolder($dirPath)
317
+ {
318
+ // Use the model factory to allow for DI via the factory
319
+ $fileIo = Mage::getModel('Varien_Io_File');
320
+ $fileIo->open(array('path' => Mage::getBaseDir()));
321
+ $fileIo->checkAndCreateFolder($dirPath);
322
+ return $this;
323
+ }
324
+ /**
325
+ * Given an arbitrary array of arguments, join them to make a valid path.
326
+ * @param string $_,... Parts of the path to be joined
327
+ * @return string
328
+ */
329
+ public static function normalPaths()
330
+ {
331
+ $paths = implode(DS, func_get_args());
332
+ // Retain a single leading slash; otherwise remove all leading, trailing
333
+ // and duplicate slashes.
334
+ return ((substr($paths, 0, 1) === DS) ? DS : '') .
335
+ implode(DS, array_filter(explode(DS, $paths)));
336
+ }
337
+ }
app/code/community/EbayEnterprise/Affiliate/Model/Feed/Order/Abstract.php CHANGED
@@ -1,72 +1,72 @@
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
-
19
- abstract class EbayEnterprise_Affiliate_Model_Feed_Order_Abstract extends EbayEnterprise_Affiliate_Model_Feed_Abstract
20
- {
21
- // Time format to use for the SQL statements
22
- const SELECT_TIME_FORMAT = 'Y-m-d H:i:s';
23
- const FILENAME_TIME_FORMAT = 'YmdHis';
24
- /**
25
- * Time stamp considered to be the time at which the feed runs - used for
26
- * generating the file name and the cutoff time for capturing order changes.
27
- * @var int
28
- */
29
- protected $_startTime;
30
- /**
31
- * Allow for the "start" time of the feed to be passed in the constructor
32
- * $args array. If given, this should be the time at which the feed is run.
33
- * @param array $args
34
- */
35
- public function __construct($args = array())
36
- {
37
- parent::__construct($args);
38
- $this->_startTime = isset($args['start_time']) ? $args['start_time'] : time();
39
- }
40
- /**
41
- * Get the ids of all stores that should be included in the feed. Only orders
42
- * placed for these stores will be included in the corrected feed.
43
- * @return array
44
- */
45
- protected function _getStoreIdsToInclude()
46
- {
47
- return array_map(
48
- function ($store) {
49
- return $store->getId();
50
- },
51
- Mage::helper('eems_affiliate')->getAllStoresForProgramId(
52
- Mage::helper('eems_affiliate/config')->getProgramId($this->_store)
53
- )
54
- );
55
- }
56
- /**
57
- * @see parent::_getFileName
58
- */
59
- protected function _getFileName()
60
- {
61
- return sprintf(
62
- $this->_getFileNameFormat(),
63
- Mage::helper('eems_affiliate/config')->getProgramId($this->getStore()),
64
- date(static::FILENAME_TIME_FORMAT, $this->_startTime)
65
- );
66
- }
67
- /**
68
- * Get the format string used to build the feed file name.
69
- * @return string
70
- */
71
- abstract protected function _getFileNameFormat();
72
- }
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
+
19
+ abstract class EbayEnterprise_Affiliate_Model_Feed_Order_Abstract extends EbayEnterprise_Affiliate_Model_Feed_Abstract
20
+ {
21
+ // Time format to use for the SQL statements
22
+ const SELECT_TIME_FORMAT = 'Y-m-d H:i:s';
23
+ const FILENAME_TIME_FORMAT = 'YmdHis';
24
+ /**
25
+ * Time stamp considered to be the time at which the feed runs - used for
26
+ * generating the file name and the cutoff time for capturing order changes.
27
+ * @var int
28
+ */
29
+ protected $_startTime;
30
+ /**
31
+ * Allow for the "start" time of the feed to be passed in the constructor
32
+ * $args array. If given, this should be the time at which the feed is run.
33
+ * @param array $args
34
+ */
35
+ public function __construct($args = array())
36
+ {
37
+ parent::__construct($args);
38
+ $this->_startTime = isset($args['start_time']) ? $args['start_time'] : time();
39
+ }
40
+ /**
41
+ * Get the ids of all stores that should be included in the feed. Only orders
42
+ * placed for these stores will be included in the corrected feed.
43
+ * @return array
44
+ */
45
+ protected function _getStoreIdsToInclude()
46
+ {
47
+ return array_map(
48
+ function ($store) {
49
+ return $store->getId();
50
+ },
51
+ Mage::helper('eems_affiliate')->getAllStoresForProgramId(
52
+ Mage::helper('eems_affiliate/config')->getProgramId($this->_store)
53
+ )
54
+ );
55
+ }
56
+ /**
57
+ * @see parent::_getFileName
58
+ */
59
+ protected function _getFileName()
60
+ {
61
+ return sprintf(
62
+ $this->_getFileNameFormat(),
63
+ Mage::helper('eems_affiliate/config')->getProgramId($this->getStore()),
64
+ date(static::FILENAME_TIME_FORMAT, $this->_startTime)
65
+ );
66
+ }
67
+ /**
68
+ * Get the format string used to build the feed file name.
69
+ * @return string
70
+ */
71
+ abstract protected function _getFileNameFormat();
72
+ }
app/code/community/EbayEnterprise/Affiliate/Model/Feed/Order/Basic.php CHANGED
@@ -1,75 +1,75 @@
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
-
19
- class EbayEnterprise_Affiliate_Model_Feed_Order_Basic extends EbayEnterprise_Affiliate_Model_Feed_Order_Abstract
20
- {
21
- /**
22
- * @see parent::_getItems
23
- */
24
- protected function _getItems()
25
- {
26
- $lastRunTime = date(static::SELECT_TIME_FORMAT, Mage::helper('eems_affiliate/config')->getOrderLastRunTime() ?: 0);
27
- $startTime = date(static::SELECT_TIME_FORMAT, $this->_startTime);
28
- $storeIds = $this->_getStoreIdsToInclude();
29
-
30
- $collection = Mage::getResourceModel('sales/order_collection');
31
- $select = $collection->getSelect();
32
- $select
33
- ->joinLeft(
34
- array('cmo' => $collection->getTable('sales/creditmemo')),
35
- 'main_table.entity_id = cmo.order_id',
36
- array()
37
- )
38
- // this is far more pure SQL than should be here but I don't see a way to
39
- // get the proper groupings of where clauses without doing this
40
- ->where(
41
- 'main_table.store_id IN (?)',
42
- $storeIds
43
- )
44
- ->where(
45
- "(main_table.original_increment_id IS NOT NULL AND main_table.created_at >= :lastRunTime AND main_table.created_at < :startTime) OR" .
46
- "(cmo.created_at IS NOT NULL AND cmo.created_at >= :lastRunTime AND cmo.created_at < :startTime) OR" .
47
- "(main_table.state = 'canceled' AND main_table.updated_at >= :lastRunTime AND main_table.updated_at < :startTime AND main_table.relation_child_id IS NULL)"
48
- );
49
-
50
- $collection->addBindParam(':lastRunTime', $lastRunTime)
51
- ->addBindParam(':startTime', $startTime);
52
-
53
- return $collection;
54
- }
55
- /**
56
- * Get an array of callback mappings for the feed. Should result in an array
57
- * with keys for the field in the CSV and a value of an array used to
58
- * represent a mapping callback.
59
- * @see parent::_invokeCallback
60
- */
61
- protected function _getFeedFields()
62
- {
63
- return explode(',', Mage::helper('eems_affiliate/config')->getBasicOrderFeedFields());
64
- }
65
- /**
66
- * Get the file name format from config. Doesn't pass store context as the
67
- * file name format should only ever exist at the global level.
68
- * @see parent::_getFileNameFormat
69
- * @codeCoverageIgnore
70
- */
71
- protected function _getFileNameFormat()
72
- {
73
- return Mage::helper('eems_affiliate/config')->getBasicOrderFeedFileFormat();
74
- }
75
- }
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
+
19
+ class EbayEnterprise_Affiliate_Model_Feed_Order_Basic extends EbayEnterprise_Affiliate_Model_Feed_Order_Abstract
20
+ {
21
+ /**
22
+ * @see parent::_getItems
23
+ */
24
+ protected function _getItems()
25
+ {
26
+ $lastRunTime = date(static::SELECT_TIME_FORMAT, Mage::helper('eems_affiliate/config')->getOrderLastRunTime() ?: 0);
27
+ $startTime = date(static::SELECT_TIME_FORMAT, $this->_startTime);
28
+ $storeIds = $this->_getStoreIdsToInclude();
29
+
30
+ $collection = Mage::getResourceModel('sales/order_collection');
31
+ $select = $collection->getSelect();
32
+ $select
33
+ ->joinLeft(
34
+ array('cmo' => $collection->getTable('sales/creditmemo')),
35
+ 'main_table.entity_id = cmo.order_id',
36
+ array()
37
+ )
38
+ // this is far more pure SQL than should be here but I don't see a way to
39
+ // get the proper groupings of where clauses without doing this
40
+ ->where(
41
+ 'main_table.store_id IN (?)',
42
+ $storeIds
43
+ )
44
+ ->where(
45
+ "(main_table.original_increment_id IS NOT NULL AND main_table.created_at >= :lastRunTime AND main_table.created_at < :startTime) OR" .
46
+ "(cmo.created_at IS NOT NULL AND cmo.created_at >= :lastRunTime AND cmo.created_at < :startTime) OR" .
47
+ "(main_table.state = 'canceled' AND main_table.updated_at >= :lastRunTime AND main_table.updated_at < :startTime AND main_table.relation_child_id IS NULL)"
48
+ );
49
+
50
+ $collection->addBindParam(':lastRunTime', $lastRunTime)
51
+ ->addBindParam(':startTime', $startTime);
52
+
53
+ return $collection;
54
+ }
55
+ /**
56
+ * Get an array of callback mappings for the feed. Should result in an array
57
+ * with keys for the field in the CSV and a value of an array used to
58
+ * represent a mapping callback.
59
+ * @see parent::_invokeCallback
60
+ */
61
+ protected function _getFeedFields()
62
+ {
63
+ return explode(',', Mage::helper('eems_affiliate/config')->getBasicOrderFeedFields());
64
+ }
65
+ /**
66
+ * Get the file name format from config. Doesn't pass store context as the
67
+ * file name format should only ever exist at the global level.
68
+ * @see parent::_getFileNameFormat
69
+ * @codeCoverageIgnore
70
+ */
71
+ protected function _getFileNameFormat()
72
+ {
73
+ return Mage::helper('eems_affiliate/config')->getBasicOrderFeedFileFormat();
74
+ }
75
+ }
app/code/community/EbayEnterprise/Affiliate/Model/Feed/Order/Dynamic.php CHANGED
@@ -1,68 +1,68 @@
1
- <?php
2
-
3
- class EbayEnterprise_Affiliate_Model_Feed_Order_Dynamic extends EbayEnterprise_Affiliate_Model_Feed_Order_Abstract
4
- {
5
- /**
6
- * @see parent::_getItems
7
- */
8
- protected function _getItems()
9
- {
10
- $lastRunTime = date(static::SELECT_TIME_FORMAT, Mage::helper('eems_affiliate/config')->getOrderLastRunTime() ?: 0);
11
- $startTime = date(static::SELECT_TIME_FORMAT, $this->_startTime);
12
- $storeIds = $this->_getStoreIdsToInclude();
13
-
14
- $collection = Mage::getResourceModel('sales/order_item_collection');
15
- $select = $collection->getSelect();
16
- $select
17
- ->joinLeft(
18
- array('o' => $collection->getTable('sales/order')),
19
- 'main_table.order_id = o.entity_id',
20
- array('o.increment_id', 'o.original_increment_id')
21
- )
22
- ->joinLeft(
23
- array('cmo' => $collection->getTable('sales/creditmemo')),
24
- 'main_table.order_id = cmo.order_id',
25
- array()
26
- )
27
- // this is far more pure SQL than should be here but I don't see a way to
28
- // get the proper groupings of where clauses without doing this
29
- ->where(
30
- // get only items within the correct store scope and filter out any
31
- // configurable used simple products
32
- 'main_table.store_id IN (?) AND NOT (main_table.product_type="simple" AND main_table.parent_item_id IS NOT NULL AND main_table.row_total=0)',
33
- $storeIds
34
- )
35
- ->where(
36
- "(o.original_increment_id IS NOT NULL AND o.created_at >= :lastRunTime AND o.created_at < :startTime) OR " .
37
- "(cmo.created_at IS NOT NULL AND cmo.created_at >= :lastRunTime AND cmo.created_at < :startTime) OR " .
38
- "(o.state = 'canceled' AND o.updated_at >= :lastRunTime AND o.updated_at < :startTime AND o.relation_child_id IS NULL)"
39
- )
40
- // The left joins can leave duplicate item rows
41
- // But the selected items will be identical, so we don't need them.
42
- ->distinct();
43
-
44
- $collection->addBindParam(':lastRunTime', $lastRunTime)
45
- ->addBindParam(':startTime', $startTime);
46
-
47
- return $collection;
48
- }
49
-
50
- /**
51
- * @see parent::_getFeedFields
52
- */
53
- protected function _getFeedFields()
54
- {
55
- return explode(',', Mage::helper('eems_affiliate/config')->getDynamicOrderFeedFields());
56
- }
57
-
58
- /**
59
- * Get the file name format from config. Doesn't pass store context as the
60
- * file name format should only ever exist at the global level.
61
- * @see parent::_getFileNameFormat
62
- * @codeCoverageIgnore
63
- */
64
- protected function _getFileNameFormat()
65
- {
66
- return Mage::helper('eems_affiliate/config')->getDynamicOrderFeedFileFormat();
67
- }
68
- }
1
+ <?php
2
+
3
+ class EbayEnterprise_Affiliate_Model_Feed_Order_Dynamic extends EbayEnterprise_Affiliate_Model_Feed_Order_Abstract
4
+ {
5
+ /**
6
+ * @see parent::_getItems
7
+ */
8
+ protected function _getItems()
9
+ {
10
+ $lastRunTime = date(static::SELECT_TIME_FORMAT, Mage::helper('eems_affiliate/config')->getOrderLastRunTime() ?: 0);
11
+ $startTime = date(static::SELECT_TIME_FORMAT, $this->_startTime);
12
+ $storeIds = $this->_getStoreIdsToInclude();
13
+
14
+ $collection = Mage::getResourceModel('sales/order_item_collection');
15
+ $select = $collection->getSelect();
16
+ $select
17
+ ->joinLeft(
18
+ array('o' => $collection->getTable('sales/order')),
19
+ 'main_table.order_id = o.entity_id',
20
+ array('o.increment_id', 'o.original_increment_id')
21
+ )
22
+ ->joinLeft(
23
+ array('cmo' => $collection->getTable('sales/creditmemo')),
24
+ 'main_table.order_id = cmo.order_id',
25
+ array()
26
+ )
27
+ // this is far more pure SQL than should be here but I don't see a way to
28
+ // get the proper groupings of where clauses without doing this
29
+ ->where(
30
+ // get only items within the correct store scope and filter out any
31
+ // configurable used simple products
32
+ 'main_table.store_id IN (?) AND NOT (main_table.product_type="simple" AND main_table.parent_item_id IS NOT NULL AND main_table.row_total=0)',
33
+ $storeIds
34
+ )
35
+ ->where(
36
+ "(o.original_increment_id IS NOT NULL AND o.created_at >= :lastRunTime AND o.created_at < :startTime) OR " .
37
+ "(cmo.created_at IS NOT NULL AND cmo.created_at >= :lastRunTime AND cmo.created_at < :startTime) OR " .
38
+ "(o.state = 'canceled' AND o.updated_at >= :lastRunTime AND o.updated_at < :startTime AND o.relation_child_id IS NULL)"
39
+ )
40
+ // The left joins can leave duplicate item rows
41
+ // But the selected items will be identical, so we don't need them.
42
+ ->distinct();
43
+
44
+ $collection->addBindParam(':lastRunTime', $lastRunTime)
45
+ ->addBindParam(':startTime', $startTime);
46
+
47
+ return $collection;
48
+ }
49
+
50
+ /**
51
+ * @see parent::_getFeedFields
52
+ */
53
+ protected function _getFeedFields()
54
+ {
55
+ return explode(',', Mage::helper('eems_affiliate/config')->getDynamicOrderFeedFields());
56
+ }
57
+
58
+ /**
59
+ * Get the file name format from config. Doesn't pass store context as the
60
+ * file name format should only ever exist at the global level.
61
+ * @see parent::_getFileNameFormat
62
+ * @codeCoverageIgnore
63
+ */
64
+ protected function _getFileNameFormat()
65
+ {
66
+ return Mage::helper('eems_affiliate/config')->getDynamicOrderFeedFileFormat();
67
+ }
68
+ }
app/code/community/EbayEnterprise/Affiliate/Model/Feed/Order/Itemized.php CHANGED
@@ -1,81 +1,81 @@
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_Model_Feed_Order_Itemized extends EbayEnterprise_Affiliate_Model_Feed_Order_Abstract
19
- {
20
- /**
21
- * @see parent::_getItems
22
- */
23
- protected function _getItems()
24
- {
25
- $lastRunTime = date(static::SELECT_TIME_FORMAT, Mage::helper('eems_affiliate/config')->getOrderLastRunTime() ?: 0);
26
- $startTime = date(static::SELECT_TIME_FORMAT, $this->_startTime);
27
- $storeIds = $this->_getStoreIdsToInclude();
28
-
29
- $collection = Mage::getResourceModel('sales/order_item_collection');
30
- $select = $collection->getSelect();
31
- $select
32
- ->joinLeft(
33
- array('o' => $collection->getTable('sales/order')),
34
- 'main_table.order_id = o.entity_id',
35
- array('o.increment_id', 'o.original_increment_id')
36
- )
37
- ->joinLeft(
38
- array('cmo' => $collection->getTable('sales/creditmemo')),
39
- 'main_table.order_id = cmo.order_id',
40
- array()
41
- )
42
- // this is far more pure SQL than should be here but I don't see a way to
43
- // get the proper groupings of where clauses without doing this
44
- ->where(
45
- // get only items within the correct store scope and filter out any
46
- // configurable used simple products
47
- 'main_table.store_id IN (?) AND NOT (main_table.product_type="simple" AND main_table.parent_item_id IS NOT NULL AND main_table.row_total=0)',
48
- $storeIds
49
- )
50
- ->where(
51
- "(o.original_increment_id IS NOT NULL AND o.created_at >= :lastRunTime AND o.created_at < :startTime) OR " .
52
- "(cmo.created_at IS NOT NULL AND cmo.created_at >= :lastRunTime AND cmo.created_at < :startTime) OR " .
53
- "(o.state = 'canceled' AND o.updated_at >= :lastRunTime AND o.updated_at < :startTime AND o.relation_child_id IS NULL)"
54
- )
55
- // The left joins can leave duplicate item rows
56
- // But the selected items will be identical, so we don't need them.
57
- ->distinct();
58
-
59
- $collection->addBindParam(':lastRunTime', $lastRunTime)
60
- ->addBindParam(':startTime', $startTime);
61
-
62
- return $collection;
63
- }
64
- /**
65
- * @see parent::_getFeedFields
66
- */
67
- protected function _getFeedFields()
68
- {
69
- return explode(',', Mage::helper('eems_affiliate/config')->getItemizedOrderFeedFields());
70
- }
71
- /**
72
- * Get the file name format from config. Doesn't pass store context as the
73
- * file name format should only ever exist at the global level.
74
- * @see parent::_getFileNameFormat
75
- * @codeCoverageIgnore
76
- */
77
- protected function _getFileNameFormat()
78
- {
79
- return Mage::helper('eems_affiliate/config')->getItemizedOrderFeedFileFormat();
80
- }
81
- }
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_Model_Feed_Order_Itemized extends EbayEnterprise_Affiliate_Model_Feed_Order_Abstract
19
+ {
20
+ /**
21
+ * @see parent::_getItems
22
+ */
23
+ protected function _getItems()
24
+ {
25
+ $lastRunTime = date(static::SELECT_TIME_FORMAT, Mage::helper('eems_affiliate/config')->getOrderLastRunTime() ?: 0);
26
+ $startTime = date(static::SELECT_TIME_FORMAT, $this->_startTime);
27
+ $storeIds = $this->_getStoreIdsToInclude();
28
+
29
+ $collection = Mage::getResourceModel('sales/order_item_collection');
30
+ $select = $collection->getSelect();
31
+ $select
32
+ ->joinLeft(
33
+ array('o' => $collection->getTable('sales/order')),
34
+ 'main_table.order_id = o.entity_id',
35
+ array('o.increment_id', 'o.original_increment_id')
36
+ )
37
+ ->joinLeft(
38
+ array('cmo' => $collection->getTable('sales/creditmemo')),
39
+ 'main_table.order_id = cmo.order_id',
40
+ array()
41
+ )
42
+ // this is far more pure SQL than should be here but I don't see a way to
43
+ // get the proper groupings of where clauses without doing this
44
+ ->where(
45
+ // get only items within the correct store scope and filter out any
46
+ // configurable used simple products
47
+ 'main_table.store_id IN (?) AND NOT (main_table.product_type="simple" AND main_table.parent_item_id IS NOT NULL AND main_table.row_total=0)',
48
+ $storeIds
49
+ )
50
+ ->where(
51
+ "(o.original_increment_id IS NOT NULL AND o.created_at >= :lastRunTime AND o.created_at < :startTime) OR " .
52
+ "(cmo.created_at IS NOT NULL AND cmo.created_at >= :lastRunTime AND cmo.created_at < :startTime) OR " .
53
+ "(o.state = 'canceled' AND o.updated_at >= :lastRunTime AND o.updated_at < :startTime AND o.relation_child_id IS NULL)"
54
+ )
55
+ // The left joins can leave duplicate item rows
56
+ // But the selected items will be identical, so we don't need them.
57
+ ->distinct();
58
+
59
+ $collection->addBindParam(':lastRunTime', $lastRunTime)
60
+ ->addBindParam(':startTime', $startTime);
61
+
62
+ return $collection;
63
+ }
64
+ /**
65
+ * @see parent::_getFeedFields
66
+ */
67
+ protected function _getFeedFields()
68
+ {
69
+ return explode(',', Mage::helper('eems_affiliate/config')->getItemizedOrderFeedFields());
70
+ }
71
+ /**
72
+ * Get the file name format from config. Doesn't pass store context as the
73
+ * file name format should only ever exist at the global level.
74
+ * @see parent::_getFileNameFormat
75
+ * @codeCoverageIgnore
76
+ */
77
+ protected function _getFileNameFormat()
78
+ {
79
+ return Mage::helper('eems_affiliate/config')->getItemizedOrderFeedFileFormat();
80
+ }
81
+ }
app/code/community/EbayEnterprise/Affiliate/Model/Feed/Product.php CHANGED
@@ -1,98 +1,110 @@
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
-
19
- class EbayEnterprise_Affiliate_Model_Feed_Product extends EbayEnterprise_Affiliate_Model_Feed_Abstract
20
- {
21
- const DELIMITER = "\t";
22
- /**
23
- * @see parent::_getItems
24
- */
25
- protected function _getItems()
26
- {
27
- return Mage::getResourceModel('catalog/product_collection')
28
- ->setStore($this->getStore())
29
- ->addAttributeToSelect(array('*'))
30
- ->addStoreFilter($this->getStore())
31
- ->addFieldToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
32
- }
33
- /**
34
- * Get an array of callback mappings for the feed. Should result in an array
35
- * with keys for the field in the CSV and a value of an array used to
36
- * represent a mapping callback.
37
- * @see parent::_invokeCallback
38
- */
39
- protected function _getFeedFields()
40
- {
41
- $store = $this->getStore();
42
- $callbackMap = Mage::helper('eems_affiliate/config')->getCallbackMappings($store);
43
- return array_filter(array_map(
44
- function ($key) use ($callbackMap) {
45
- return isset($callbackMap[$key])? $callbackMap[$key]['column_name'] : null;
46
- },
47
- array_keys(Mage::helper('eems_affiliate/config')->getProductFeedFields($store))
48
- ));
49
- }
50
- /**
51
- * @see parent::_applyMapping
52
- * @param mixed $item Likely a Varien_Object but could really be anything.
53
- * @return array
54
- */
55
- protected function _applyMapping($item)
56
- {
57
- $fields = array();
58
- $helper = Mage::helper('eems_affiliate/config');
59
- $store = $this->getStore();
60
- $mappings = $helper->getCallbackMappings($store);
61
- $columns = $helper->getProductFeedFields($store);
62
- foreach ($this->_getFeedFields() as $feedField) {
63
- // If the mapping doesn't exist, supplying an empty array will eventually
64
- // result in an exception for being an invalid config mapping.
65
- // @see self::_validateCallbackConfig
66
- $callback = isset($mappings[$feedField]) ? $mappings[$feedField] : array();
67
- if ($columns[$feedField]) {
68
- $callback['params']['key'] = $columns[$feedField];
69
- }
70
- // exclude any mappings that have a type of "disabled"
71
- if (!isset($callback['type']) || $callback['type'] !== 'disabled') {
72
- $fields[] = $this->_invokeCallback($callback, $item);
73
- }
74
- }
75
- return $fields;
76
- }
77
- /**
78
- * @see parent::_getFileName
79
- */
80
- protected function _getFileName()
81
- {
82
- $config = Mage::helper('eems_affiliate/config');
83
- $store = $this->getStore();
84
- return sprintf(
85
- $config->getProductFeedFilenameFormat($store),
86
- $config->getProgramId($this->getStore($store))
87
- );
88
- }
89
- /**
90
- * @see EbayEnterprise_Affiliate_Model_Feed_Abstract::_getDelimiter
91
- * @return string
92
- * @codeCoverageIgnore
93
- */
94
- protected function _getDelimiter()
95
- {
96
- return static::DELIMITER;
97
- }
98
- }
 
 
 
 
 
 
 
 
 
 
 
 
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
+
19
+ class EbayEnterprise_Affiliate_Model_Feed_Product extends EbayEnterprise_Affiliate_Model_Feed_Abstract
20
+ {
21
+ const DELIMITER = "\t";
22
+ const FIELD_PRODUCT_URL = 'product_url';
23
+ /**
24
+ * @see parent::_getItems
25
+ */
26
+ protected function _getItems()
27
+ {
28
+ $store = $this->getStore();
29
+ $requiredMap = Mage::helper('eems_affiliate/config')->getRequiredProductFeedFields($store);
30
+
31
+ $productCollection = Mage::getResourceModel('catalog/product_collection')
32
+ ->setStore($this->getStore())
33
+ ->addAttributeToSelect(array('*'))
34
+ ->addStoreFilter($this->getStore())
35
+ ->addFieldToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
36
+
37
+ foreach ($requiredMap as $field) {
38
+ if ($field != self::FIELD_PRODUCT_URL) {
39
+ $productCollection->addFieldToFilter($field, array('notnull' => true));
40
+ }
41
+ }
42
+
43
+ return $productCollection;
44
+ }
45
+ /**
46
+ * Get an array of callback mappings for the feed. Should result in an array
47
+ * with keys for the field in the CSV and a value of an array used to
48
+ * represent a mapping callback.
49
+ * @see parent::_invokeCallback
50
+ */
51
+ protected function _getFeedFields()
52
+ {
53
+ $store = $this->getStore();
54
+ $callbackMap = Mage::helper('eems_affiliate/config')->getCallbackMappings($store);
55
+ return array_filter(array_map(
56
+ function ($key) use ($callbackMap) {
57
+ return isset($callbackMap[$key])? $callbackMap[$key]['column_name'] : null;
58
+ },
59
+ array_keys(Mage::helper('eems_affiliate/config')->getProductFeedFields($store))
60
+ ));
61
+ }
62
+ /**
63
+ * @see parent::_applyMapping
64
+ * @param mixed $item Likely a Varien_Object but could really be anything.
65
+ * @return array
66
+ */
67
+ protected function _applyMapping($item)
68
+ {
69
+ $fields = array();
70
+ $helper = Mage::helper('eems_affiliate/config');
71
+ $store = $this->getStore();
72
+ $mappings = $helper->getCallbackMappings($store);
73
+ $columns = $helper->getProductFeedFields($store);
74
+ foreach ($this->_getFeedFields() as $feedField) {
75
+ // If the mapping doesn't exist, supplying an empty array will eventually
76
+ // result in an exception for being an invalid config mapping.
77
+ // @see self::_validateCallbackConfig
78
+ $callback = isset($mappings[$feedField]) ? $mappings[$feedField] : array();
79
+ if ($columns[$feedField]) {
80
+ $callback['params']['key'] = $columns[$feedField];
81
+ }
82
+ // exclude any mappings that have a type of "disabled"
83
+ if (!isset($callback['type']) || $callback['type'] !== 'disabled') {
84
+ $fields[] = $this->_invokeCallback($callback, $item);
85
+ }
86
+ }
87
+ return $fields;
88
+ }
89
+ /**
90
+ * @see parent::_getFileName
91
+ */
92
+ protected function _getFileName()
93
+ {
94
+ $config = Mage::helper('eems_affiliate/config');
95
+ $store = $this->getStore();
96
+ return sprintf(
97
+ $config->getProductFeedFilenameFormat($store),
98
+ $config->getProgramId($this->getStore($store))
99
+ );
100
+ }
101
+ /**
102
+ * @see EbayEnterprise_Affiliate_Model_Feed_Abstract::_getDelimiter
103
+ * @return string
104
+ * @codeCoverageIgnore
105
+ */
106
+ protected function _getDelimiter()
107
+ {
108
+ return static::DELIMITER;
109
+ }
110
+ }
app/code/community/EbayEnterprise/Affiliate/Model/Observer.php CHANGED
@@ -1,76 +1,76 @@
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
-
19
- class EbayEnterprise_Affiliate_Model_Observer
20
- {
21
- const PRODUCT_LOG_MESSAGE = 'Generating Product feed: program id %s, default store view: %s';
22
- /**
23
- * This observer method is the entry point to generating product feed when
24
- * the CRONJOB 'eems_affiliate_generate_product_feed' run.
25
- * @return void
26
- */
27
- public function createProductFeed()
28
- {
29
- if (!Mage::getStoreConfig('marketing_solutions/eems_affiliate/product_feed_enabled')) {
30
- Mage::log(Mage::helper('eems_affiliate')->__('Product feed disabled'), Zend_Log::NOTICE);
31
- return;
32
- }
33
-
34
- $helper = Mage::helper('eems_affiliate');
35
- foreach ($helper->getAllProgramIds() as $programId) {
36
- $store = $helper->getStoreForProgramId($programId);
37
- Mage::log(
38
- sprintf(static::PRODUCT_LOG_MESSAGE, $programId, $store->getName()),
39
- Zend_Log::INFO
40
- );
41
-
42
- Mage::getModel('eems_affiliate/feed_product', array(
43
- 'store' => $store
44
- ))->generateFeed();
45
- }
46
- }
47
- /**
48
- * Generate the order corrected feed.
49
- * @return self
50
- */
51
- public function createCorrectedOrdersFeed()
52
- {
53
- if (!Mage::getStoreConfig('marketing_solutions/eems_affiliate/order_feed_enabled')) {
54
- Mage::log(Mage::helper('eems_affiliate')->__('Corrected order feed disabled'), Zend_Log::NOTICE);
55
- return;
56
- }
57
-
58
- $startTime = time();
59
-
60
- $feedAlias = 'feed_order_'.Mage::helper('eems_affiliate/config')->getOrderType();
61
-
62
- Mage::log(sprintf('[%s] Generating %s feed', __CLASS__, $feedAlias), Zend_Log::INFO);
63
-
64
- $helper = Mage::helper('eems_affiliate');
65
- foreach ($helper->getAllProgramIds() as $programId) {
66
- Mage::getModel(
67
- "eems_affiliate/{$feedAlias}",
68
- array('store' => $helper->getStoreForProgramId($programId), 'start_time' => $startTime)
69
- )->generateFeed();
70
- }
71
-
72
- Mage::helper('eems_affiliate/config')->updateOrderLastRunTime($startTime);
73
-
74
- return $this;
75
- }
76
- }
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
+
19
+ class EbayEnterprise_Affiliate_Model_Observer
20
+ {
21
+ const PRODUCT_LOG_MESSAGE = 'Generating Product feed: program id %s, default store view: %s';
22
+ /**
23
+ * This observer method is the entry point to generating product feed when
24
+ * the CRONJOB 'eems_affiliate_generate_product_feed' run.
25
+ * @return void
26
+ */
27
+ public function createProductFeed()
28
+ {
29
+ if (!Mage::getStoreConfig('marketing_solutions/eems_affiliate/product_feed_enabled')) {
30
+ Mage::log(Mage::helper('eems_affiliate')->__('Product feed disabled'), Zend_Log::NOTICE);
31
+ return;
32
+ }
33
+
34
+ $helper = Mage::helper('eems_affiliate');
35
+ foreach ($helper->getAllProgramIds() as $programId) {
36
+ $store = $helper->getStoreForProgramId($programId);
37
+ Mage::log(
38
+ sprintf(static::PRODUCT_LOG_MESSAGE, $programId, $store->getName()),
39
+ Zend_Log::INFO
40
+ );
41
+
42
+ Mage::getModel('eems_affiliate/feed_product', array(
43
+ 'store' => $store
44
+ ))->generateFeed();
45
+ }
46
+ }
47
+ /**
48
+ * Generate the order corrected feed.
49
+ * @return self
50
+ */
51
+ public function createCorrectedOrdersFeed()
52
+ {
53
+ if (!Mage::getStoreConfig('marketing_solutions/eems_affiliate/order_feed_enabled')) {
54
+ Mage::log(Mage::helper('eems_affiliate')->__('Corrected order feed disabled'), Zend_Log::NOTICE);
55
+ return;
56
+ }
57
+
58
+ $startTime = time();
59
+
60
+ $feedAlias = 'feed_order_'.Mage::helper('eems_affiliate/config')->getOrderType();
61
+
62
+ Mage::log(sprintf('[%s] Generating %s feed', __CLASS__, $feedAlias), Zend_Log::INFO);
63
+
64
+ $helper = Mage::helper('eems_affiliate');
65
+ foreach ($helper->getAllProgramIds() as $programId) {
66
+ Mage::getModel(
67
+ "eems_affiliate/{$feedAlias}",
68
+ array('store' => $helper->getStoreForProgramId($programId), 'start_time' => $startTime)
69
+ )->generateFeed();
70
+ }
71
+
72
+ Mage::helper('eems_affiliate/config')->updateOrderLastRunTime($startTime);
73
+
74
+ return $this;
75
+ }
76
+ }
app/code/community/EbayEnterprise/Affiliate/Model/Product/Attribute/Source/CommissioningCategory.php CHANGED
@@ -1,29 +1,29 @@
1
- <?php
2
-
3
- class EbayEnterprise_Affiliate_Model_Product_Attribute_Source_CommissioningCategory extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
4
- {
5
- public function getAllOptions()
6
- {
7
- $rootCategoryId = Mage::app()->getStore()->getRootCategoryId();
8
- $rootCategories = Mage::getModel('catalog/category')->getCollection()->addAttributeToSelect('name')->addFieldToFilter('parent_id', $rootCategoryId);
9
-
10
- $categoryOptions = array(array('value' => '', 'label' => ''));
11
-
12
- $this->_addChildren($categoryOptions, $rootCategories->getFirstItem()->getChildrenCategories(), 0);
13
-
14
- return $categoryOptions;
15
- }
16
-
17
- protected function _addChildren(&$options, $categories, $level)
18
- {
19
- if (!$categories->count())
20
- return;
21
-
22
- foreach($categories as $category) {
23
- $options[] = array('value' => $category->getId(), 'label' => str_repeat('-', $level) . $category->getName());
24
-
25
- $subcategories = $category->getChildrenCategories();
26
- $this->_addChildren($options, $subcategories, $level+1);
27
- }
28
- }
29
- }
1
+ <?php
2
+
3
+ class EbayEnterprise_Affiliate_Model_Product_Attribute_Source_CommissioningCategory extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
4
+ {
5
+ public function getAllOptions()
6
+ {
7
+ $rootCategoryId = Mage::app()->getStore()->getRootCategoryId();
8
+ $rootCategories = Mage::getModel('catalog/category')->getCollection()->addAttributeToSelect('name')->addFieldToFilter('parent_id', $rootCategoryId);
9
+
10
+ $categoryOptions = array(array('value' => '', 'label' => ''));
11
+
12
+ $this->_addChildren($categoryOptions, $rootCategories->getFirstItem()->getChildrenCategories(), 0);
13
+
14
+ return $categoryOptions;
15
+ }
16
+
17
+ protected function _addChildren(&$options, $categories, $level)
18
+ {
19
+ if (!$categories->count())
20
+ return;
21
+
22
+ foreach($categories as $category) {
23
+ $options[] = array('value' => $category->getId(), 'label' => str_repeat('-', $level) . $category->getName());
24
+
25
+ $subcategories = $category->getChildrenCategories();
26
+ $this->_addChildren($options, $subcategories, $level+1);
27
+ }
28
+ }
29
+ }
app/code/community/EbayEnterprise/Affiliate/Model/System/Config/Source/Attributes.php CHANGED
@@ -1,75 +1,75 @@
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
-
19
- class EbayEnterprise_Affiliate_Model_System_Config_Source_Attributes
20
- {
21
- const PRODUCT_URL_VALUE = 'product_url';
22
- const PRODUCT_URL_LABEL = 'Product Url';
23
- /**
24
- * Get product attributes
25
- * @return array
26
- */
27
- public function toOptionArray()
28
- {
29
- $helper = Mage::helper('catalog');
30
- $collection = Mage::getSingleton('eav/config')
31
- ->getEntityType(Mage_Catalog_Model_Product::ENTITY)
32
- ->getAttributeCollection();
33
- $attributes = array(array('value' => '', 'label' => ''));
34
- foreach ($collection as $attribute) {
35
- $attributes[] = array(
36
- 'value' => $attribute->getAttributeCode(),
37
- 'label' => $helper->__($attribute->getFrontendLabel() ?
38
- $attribute->getFrontendLabel() :
39
- $this->_convertToTitleCase($attribute->getAttributeCode()))
40
- );
41
- }
42
- $attributes[] = array(
43
- 'value' => static::PRODUCT_URL_VALUE,
44
- 'label' => $helper->__(static::PRODUCT_URL_LABEL)
45
- );
46
- // sort the attribute options by label
47
- usort($attributes, array($this, '_compareLabels'));
48
- return $attributes;
49
- }
50
- /**
51
- * Convert the attribute code to title case. Replace '_'s with spaces
52
- * and capitalize each word.
53
- * @param string $attributeCode
54
- * @return string
55
- */
56
- protected function _convertToTitleCase($attributeCode)
57
- {
58
- return ucwords(str_replace('_', ' ', $attributeCode));
59
- }
60
- /**
61
- * Comparison method for sorting options by "label" key.
62
- * @param array $a
63
- * @param array $b
64
- * @return int
65
- */
66
- protected function _compareLabels($a, $b)
67
- {
68
- $aLabel = strtolower($a['label']);
69
- $bLabel = strtolower($b['label']);
70
- if ($aLabel === $bLabel) {
71
- return 0;
72
- }
73
- return $aLabel < $bLabel ? -1 : 1;
74
- }
75
- }
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
+
19
+ class EbayEnterprise_Affiliate_Model_System_Config_Source_Attributes
20
+ {
21
+ const PRODUCT_URL_VALUE = 'product_url';
22
+ const PRODUCT_URL_LABEL = 'Product Url';
23
+ /**
24
+ * Get product attributes
25
+ * @return array
26
+ */
27
+ public function toOptionArray()
28
+ {
29
+ $helper = Mage::helper('catalog');
30
+ $collection = Mage::getSingleton('eav/config')
31
+ ->getEntityType(Mage_Catalog_Model_Product::ENTITY)
32
+ ->getAttributeCollection();
33
+ $attributes = array(array('value' => '', 'label' => ''));
34
+ foreach ($collection as $attribute) {
35
+ $attributes[] = array(
36
+ 'value' => $attribute->getAttributeCode(),
37
+ 'label' => $helper->__($attribute->getFrontendLabel() ?
38
+ $attribute->getFrontendLabel() :
39
+ $this->_convertToTitleCase($attribute->getAttributeCode()))
40
+ );
41
+ }
42
+ $attributes[] = array(
43
+ 'value' => static::PRODUCT_URL_VALUE,
44
+ 'label' => $helper->__(static::PRODUCT_URL_LABEL)
45
+ );
46
+ // sort the attribute options by label
47
+ usort($attributes, array($this, '_compareLabels'));
48
+ return $attributes;
49
+ }
50
+ /**
51
+ * Convert the attribute code to title case. Replace '_'s with spaces
52
+ * and capitalize each word.
53
+ * @param string $attributeCode
54
+ * @return string
55
+ */
56
+ protected function _convertToTitleCase($attributeCode)
57
+ {
58
+ return ucwords(str_replace('_', ' ', $attributeCode));
59
+ }
60
+ /**
61
+ * Comparison method for sorting options by "label" key.
62
+ * @param array $a
63
+ * @param array $b
64
+ * @return int
65
+ */
66
+ protected function _compareLabels($a, $b)
67
+ {
68
+ $aLabel = strtolower($a['label']);
69
+ $bLabel = strtolower($b['label']);
70
+ if ($aLabel === $bLabel) {
71
+ return 0;
72
+ }
73
+ return $aLabel < $bLabel ? -1 : 1;
74
+ }
75
+ }
app/code/community/EbayEnterprise/Affiliate/Model/System/Config/Source/Categories.php CHANGED
@@ -1,37 +1,37 @@
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
-
19
- class EbayEnterprise_Affiliate_Model_System_Config_Source_Categories
20
- {
21
- const CATEGORY_VALUE = 'category';
22
- const CATEGORY_LABEL = 'Product Categories';
23
- /**
24
- * Get category attributes
25
- * @return array
26
- */
27
- public function toOptionArray()
28
- {
29
- return array(
30
- array('value' => '', 'label' => ''),
31
- array(
32
- 'value' => static::CATEGORY_VALUE,
33
- 'label' => Mage::helper('catalog')->__(static::CATEGORY_LABEL)
34
- )
35
- );
36
- }
37
- }
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
+
19
+ class EbayEnterprise_Affiliate_Model_System_Config_Source_Categories
20
+ {
21
+ const CATEGORY_VALUE = 'category';
22
+ const CATEGORY_LABEL = 'Product Categories';
23
+ /**
24
+ * Get category attributes
25
+ * @return array
26
+ */
27
+ public function toOptionArray()
28
+ {
29
+ return array(
30
+ array('value' => '', 'label' => ''),
31
+ array(
32
+ 'value' => static::CATEGORY_VALUE,
33
+ 'label' => Mage::helper('catalog')->__(static::CATEGORY_LABEL)
34
+ )
35
+ );
36
+ }
37
+ }
app/code/community/EbayEnterprise/Affiliate/Model/System/Config/Source/Ordertypes.php CHANGED
@@ -1,25 +1,25 @@
1
- <?php
2
-
3
- class EbayEnterprise_Affiliate_Model_System_Config_Source_Ordertypes
4
- {
5
- public function toOptionArray()
6
- {
7
- $helper = Mage::helper('eems_affiliate');
8
- $config = Mage::helper('eems_affiliate/config');
9
-
10
- return array(
11
- array(
12
- 'value' => $config::ORDER_TYPE_BASIC,
13
- 'label' => $helper->__('Basic'),
14
- ),
15
- array(
16
- 'value' => $config::ORDER_TYPE_ITEMIZED,
17
- 'label' => $helper->__('Itemized'),
18
- ),
19
- array(
20
- 'value' => $config::ORDER_TYPE_DYNAMIC,
21
- 'label' => $helper->__('Dynamic'),
22
- ),
23
- );
24
- }
25
  }
1
+ <?php
2
+
3
+ class EbayEnterprise_Affiliate_Model_System_Config_Source_Ordertypes
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ $helper = Mage::helper('eems_affiliate');
8
+ $config = Mage::helper('eems_affiliate/config');
9
+
10
+ return array(
11
+ array(
12
+ 'value' => $config::ORDER_TYPE_BASIC,
13
+ 'label' => $helper->__('Basic'),
14
+ ),
15
+ array(
16
+ 'value' => $config::ORDER_TYPE_ITEMIZED,
17
+ 'label' => $helper->__('Itemized'),
18
+ ),
19
+ array(
20
+ 'value' => $config::ORDER_TYPE_DYNAMIC,
21
+ 'label' => $helper->__('Dynamic'),
22
+ ),
23
+ );
24
+ }
25
  }
app/code/community/EbayEnterprise/Affiliate/Model/System/Config/Source/Stockquantity.php CHANGED
@@ -1,37 +1,37 @@
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
-
19
- class EbayEnterprise_Affiliate_Model_System_Config_Source_Stockquantity
20
- {
21
- const STOCK_QTY_VALUE = 'qty';
22
- const STOCK_QTY_LABEL = 'Quantity';
23
- /**
24
- * Get quantity in stock list
25
- * @return array
26
- */
27
- public function toOptionArray()
28
- {
29
- return array(
30
- array('value' => '', 'label' => ''),
31
- array(
32
- 'value' => static::STOCK_QTY_VALUE,
33
- 'label' => Mage::helper('catalog')->__(static::STOCK_QTY_LABEL)
34
- )
35
- );
36
- }
37
- }
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
+
19
+ class EbayEnterprise_Affiliate_Model_System_Config_Source_Stockquantity
20
+ {
21
+ const STOCK_QTY_VALUE = 'qty';
22
+ const STOCK_QTY_LABEL = 'Quantity';
23
+ /**
24
+ * Get quantity in stock list
25
+ * @return array
26
+ */
27
+ public function toOptionArray()
28
+ {
29
+ return array(
30
+ array('value' => '', 'label' => ''),
31
+ array(
32
+ 'value' => static::STOCK_QTY_VALUE,
33
+ 'label' => Mage::helper('catalog')->__(static::STOCK_QTY_LABEL)
34
+ )
35
+ );
36
+ }
37
+ }
app/code/community/EbayEnterprise/Affiliate/Model/System/Config/Source/Stockyesno.php CHANGED
@@ -1,37 +1,37 @@
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
-
19
- class EbayEnterprise_Affiliate_Model_System_Config_Source_Stockyesno
20
- {
21
- const IN_STOCK_VALUE = 'in_stock';
22
- const IN_STOCK_LABEL = 'Inventory Stock Availability';
23
- /**
24
- * Get in stock list
25
- * @return array
26
- */
27
- public function toOptionArray()
28
- {
29
- return array(
30
- array('value' => '', 'label' => ''),
31
- array(
32
- 'value' => static::IN_STOCK_VALUE,
33
- 'label' => Mage::helper('catalog')->__(static::IN_STOCK_LABEL)
34
- )
35
- );
36
- }
37
- }
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
+
19
+ class EbayEnterprise_Affiliate_Model_System_Config_Source_Stockyesno
20
+ {
21
+ const IN_STOCK_VALUE = 'in_stock';
22
+ const IN_STOCK_LABEL = 'Inventory Stock Availability';
23
+ /**
24
+ * Get in stock list
25
+ * @return array
26
+ */
27
+ public function toOptionArray()
28
+ {
29
+ return array(
30
+ array('value' => '', 'label' => ''),
31
+ array(
32
+ 'value' => static::IN_STOCK_VALUE,
33
+ 'label' => Mage::helper('catalog')->__(static::IN_STOCK_LABEL)
34
+ )
35
+ );
36
+ }
37
+ }
app/code/community/EbayEnterprise/Affiliate/Model/System/Config/Source/Transactiontype.php CHANGED
@@ -1,30 +1,30 @@
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
-
19
- class EbayEnterprise_Affiliate_Model_System_Config_Source_Transactiontype
20
- {
21
- /**
22
- * Get available Transaction Type options
23
- * @return array
24
- */
25
- public function toOptionArray()
26
- {
27
- $helper = Mage::helper('eems_affiliate');
28
- return array('1' => $helper->__('Sale'), '2' => $helper->__('Lead'));
29
- }
30
- }
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
+
19
+ class EbayEnterprise_Affiliate_Model_System_Config_Source_Transactiontype
20
+ {
21
+ /**
22
+ * Get available Transaction Type options
23
+ * @return array
24
+ */
25
+ public function toOptionArray()
26
+ {
27
+ $helper = Mage::helper('eems_affiliate');
28
+ return array('1' => $helper->__('Sale'), '2' => $helper->__('Lead'));
29
+ }
30
+ }
app/code/community/EbayEnterprise/Affiliate/Model/System/Config/Source/Visibilityyesno.php CHANGED
@@ -1,37 +1,37 @@
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
-
19
- class EbayEnterprise_Affiliate_Model_System_Config_Source_Visibilityyesno
20
- {
21
- const VISIBILITY_VALUE = 'visibility';
22
- const VISIBILITY_LABEL = 'Visibility';
23
- /**
24
- * Get product visibility list
25
- * @return array
26
- */
27
- public function toOptionArray()
28
- {
29
- return array(
30
- array('value' => '', 'label' => ''),
31
- array(
32
- 'value' => static::VISIBILITY_VALUE,
33
- 'label' => Mage::helper('catalog')->__(static::VISIBILITY_LABEL)
34
- )
35
- );
36
- }
37
- }
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
+
19
+ class EbayEnterprise_Affiliate_Model_System_Config_Source_Visibilityyesno
20
+ {
21
+ const VISIBILITY_VALUE = 'visibility';
22
+ const VISIBILITY_LABEL = 'Visibility';
23
+ /**
24
+ * Get product visibility list
25
+ * @return array
26
+ */
27
+ public function toOptionArray()
28
+ {
29
+ return array(
30
+ array('value' => '', 'label' => ''),
31
+ array(
32
+ 'value' => static::VISIBILITY_VALUE,
33
+ 'label' => Mage::helper('catalog')->__(static::VISIBILITY_LABEL)
34
+ )
35
+ );
36
+ }
37
+ }
app/code/community/EbayEnterprise/Affiliate/Test/Block/BeaconTest.php CHANGED
@@ -1,254 +1,254 @@
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_Test_Block_BeaconTest extends EcomDev_PHPUnit_Test_Case
19
- {
20
- /**
21
- * Get a mock of the config helper to return expected system configurations.
22
- * @param string $programId
23
- * @param string $transactionType
24
- * @param string $itemizeOrders
25
- * @return Mock_EbayEnterprise_Affiliate_Helper_Config
26
- */
27
- protected function _getConfigHelper($programId, $transactionType, $itemizeOrders)
28
- {
29
- $helper = $this->getHelperMock('eems_affiliate/config', array(
30
- 'getProgramId', 'getTransactionType', 'isItemizedOrders', 'isDynamicOrders',
31
- ));
32
- $helper->expects($this->any())
33
- ->method('getProgramId')
34
- ->will($this->returnValue($programId));
35
- $helper->expects($this->any())
36
- ->method('getTransactionType')
37
- ->will($this->returnValue($transactionType));
38
- $helper->expects($this->any())
39
- ->method('isItemizedOrders')
40
- ->will($this->returnValue($itemizeOrders));
41
- $helper->expects($this->any())
42
- ->method('isDynamicOrders')
43
- ->will($this->returnValue($itemizeOrders));
44
- return $helper;
45
- }
46
- /**
47
- * Test building the basic beacon url. Should only include order level
48
- * information about the order in the url params.
49
- */
50
- public function testGetBeaconUrlBasic()
51
- {
52
- $orderId = '000012';
53
- $subtotal = '10.99';
54
- $discount = '-5.00';
55
- $couponCode = 'COUPON';
56
- $programId = 'PROGRAM ID';
57
- $transactionType = 'TRANS TYPE';
58
- $itemizeOrders = false;
59
- $params = array(
60
- 'PID' => $programId,
61
- 'OID' => $orderId,
62
- 'PROMOCODE' => $couponCode,
63
- 'AMOUNT' => '5.99',
64
- 'TYPE' => $transactionType
65
- );
66
- $beaconUrl = 'https://example.com/track';
67
- $order = Mage::getModel('sales/order', array(
68
- 'increment_id' => $orderId,
69
- 'subtotal' => $subtotal,
70
- 'coupon_code' => $couponCode,
71
- 'discount_amount' => $discount,
72
- ));
73
- // mock out the config helper to setup expected system configurations
74
- $this->replaceByMock(
75
- 'helper',
76
- 'eems_affiliate/config',
77
- $this->_getConfigHelper($programId, $transactionType, $itemizeOrders)
78
- );
79
- $helper = $this->getHelperMock('eems_affiliate/data', array('buildBeaconUrl'));
80
- $helper->expects($this->once())
81
- ->method('buildBeaconUrl')
82
- ->with($this->identicalTo($params))
83
- ->will($this->returnValue($beaconUrl));
84
- $this->replaceByMock('helper', 'eems_affiliate', $helper);
85
-
86
- $block = $this->getBlockMock('eems_affiliate/beacon', array('_getOrder'));
87
- $block->expects($this->any())
88
- ->method('_getOrder')
89
- ->will($this->returnValue($order));
90
-
91
- $this->assertSame($beaconUrl, $block->getBeaconUrl());
92
- }
93
- /**
94
- * Test building the itemized beacon url. Should include item level details
95
- * in the url params for each item in the order.
96
- */
97
- public function testGetBeaconUrlItemized()
98
- {
99
- $programId = 'PROGRAM ID';
100
- // should use itemized beacon when itemize orders is true
101
- $itemizeOrders = true;
102
- $orderId = '000012';
103
- $couponCode = 'COUPON';
104
- $itemSku = 'sku-12345';
105
- $altSku = 'sku-54321';
106
- $itemQty = 2;
107
- $altQty = 3;
108
- $itemAmt = '12.34';
109
- $altAmt = '10.67';
110
- $discountAmt = '5.00';
111
- $bundleSku = 'bundle-sku-made-up-of-child-skus';
112
- $bundleQty = 1;
113
- // This is the expected final output from the method - gets returned from
114
- // the eems_affiliate/data helper when called with the right params.
115
- $beaconUrl = 'https://example.com/track?PARAM=Value';
116
- // These are the "correct" params the helper method should be called with.
117
- // Order of the array is significant - both to the test and the
118
- // actual implementation.
119
- $beaconParams = array(
120
- 'PID' => $programId,
121
- 'OID' => $orderId,
122
- 'PROMOCODE' => $couponCode,
123
- 'INT' => 'ITEMIZED',
124
- 'ITEM1' => $itemSku,
125
- 'QTY1' => $itemQty * 2,
126
- 'TOTALAMOUNT1' => number_format(($itemAmt - $discountAmt) * 2, 2),
127
- 'ITEM2' => $altSku,
128
- 'QTY2' => $altQty,
129
- 'TOTALAMOUNT2' => $altAmt,
130
- 'ITEM3' => $bundleSku,
131
- 'QTY3' => $bundleQty,
132
- 'TOTALAMOUNT3' => '0.00',
133
- );
134
-
135
- $item = Mage::getModel('sales/order_item', array(
136
- 'sku' => $itemSku, 'qty_ordered' => $itemQty, 'row_total' => $itemAmt,
137
- 'parent_item_id' => null, 'discount_amount' => $discountAmt,
138
- 'product_type' => 'simple',
139
- ));
140
- $itemDupe = Mage::getModel('sales/order_item', array(
141
- 'sku' => $itemSku, 'qty_ordered' => $itemQty, 'row_total' => $itemAmt,
142
- 'parent_item_id' => null, 'discount_amount' => $discountAmt,
143
- 'product_type' => 'simple',
144
- ));
145
- $parentItem = Mage::getModel('sales/order_item', array(
146
- 'sku' => $altSku, 'qty_ordered' => $altQty, 'row_total' => $altAmt,
147
- 'parent_item_id' => null, 'discount_amount' => 0.00,
148
- 'product_type' => 'configurable',
149
- ));
150
- $altItem = Mage::getModel('sales/order_item', array(
151
- 'sku' => $altSku, 'qty_ordered' => $altQty, 'row_total' => 0.00,
152
- 'parent_item_id' => '2', 'discount_amount' => 0.00,
153
- 'product_type' => 'simple',
154
- ));
155
- $bundleItem = Mage::getModel('sales/order_item', array(
156
- 'sku' => $bundleSku, 'qty_ordered' => $bundleQty, 'row_total' => '500.00',
157
- 'parent_item_id' => null, 'discount_amount' => 0.00,
158
- 'product_type' => 'bundle',
159
- ));
160
- $order = Mage::getModel('sales/order', array(
161
- 'increment_id' => $orderId, 'coupon_code' => $couponCode,
162
- ));
163
- $order->addItem($item);
164
- $order->addItem($itemDupe);
165
- $order->addItem($parentItem);
166
- $order->addItem($altItem);
167
- $order->addItem($bundleItem);
168
-
169
- // mock out the config helper to setup expected system configurations
170
- $this->replaceByMock(
171
- 'helper',
172
- 'eems_affiliate/config',
173
- $this->_getConfigHelper($programId, null, $itemizeOrders)
174
- );
175
-
176
- $helper = $this->getHelperMock('eems_affiliate/data', array('buildBeaconUrl'));
177
- $helper->expects($this->once())
178
- ->method('buildBeaconUrl')
179
- ->with($this->identicalTo($beaconParams))
180
- ->will($this->returnValue($beaconUrl));
181
- $this->replaceByMock('helper', 'eems_affiliate', $helper);
182
-
183
- $block = $this->getBlockMock('eems_affiliate/beacon', array('_getOrder'));
184
- $block->expects($this->any())
185
- ->method('_getOrder')
186
- ->will($this->returnValue($order));
187
-
188
- $this->assertSame($beaconUrl, $block->getBeaconUrl());
189
- }
190
- /**
191
- * Test that EbayEnterprise_Affiliate_Block_Beacon::_getOrder will be invoked
192
- * by this test and expect it to return Mage_Sales_Model_Order object
193
- */
194
- public function testGetOrder()
195
- {
196
- $orderId = '00000084848';
197
- $session = $this->getModelMockBuilder('checkout/session')
198
- ->disableOriginalConstructor()
199
- ->setMethods(null)
200
- ->getMock();
201
- $session->setLastOrderId($orderId);
202
- $this->replaceByMock('singleton', 'checkout/session', $session);
203
-
204
- $order = $this->getModelMock('sales/order', array('load'));
205
- $order->expects($this->once())
206
- ->method('load')
207
- ->with($this->identicalTo($orderId))
208
- ->will($this->returnSelf());
209
- $this->replaceByMock('model', 'sales/order', $order);
210
-
211
- $beacon = $this->getBlockMock('eems_affiliate/beacon', array());
212
- EcomDev_Utils_Reflection::setRestrictedPropertyValue($beacon, '_order', null);
213
-
214
- $this->assertSame($order, EcomDev_Utils_Reflection::invokeRestrictedMethod(
215
- $beacon,
216
- '_getOrder',
217
- array()
218
- ));
219
- }
220
- /**
221
- * Test that EbayEnterprise_Affiliate_Block_Beacon::showBeacon will return true
222
- * only if tracking is enabled and we have a valid order
223
- * AND either conditional pixel logic is OFF or it is ON and we have
224
- * a valid cookie.
225
- *
226
- * @dataProvider dataProvider
227
- */
228
- public function testShowBeacon($isEnabled, $isOrder, $isPixelLogicEnabled, $isValidCookie, $expectedResult)
229
- {
230
- $configHelper = $this->getHelperMock('eems_affiliate/config', array('isEnabled', 'isConditionalPixelEnabled'));
231
- $configHelper->expects($this->any())
232
- ->method('isEnabled')
233
- ->will($this->returnValue($isEnabled));
234
-
235
- $configHelper->expects($this->any())
236
- ->method('isConditionalPixelEnabled')
237
- ->will($this->returnValue($isPixelLogicEnabled));
238
- $this->replaceByMock('helper', 'eems_affiliate/config', $configHelper);
239
-
240
- $dataHelper = $this->getHelperMock('eems_affiliate', array('isValidCookie'));
241
- $dataHelper->expects(($this->any()))
242
- ->method('isValidCookie')
243
- ->will($this->returnValue($isValidCookie));
244
- $this->replaceByMock('helper', 'eems_affiliate', $dataHelper);
245
-
246
- $order = (bool)$isOrder ? Mage::getModel('sales/order') : null;
247
- $beacon = $this->getBlockMock('eems_affiliate/beacon', array('_getOrder'));
248
- $beacon->expects($this->any())
249
- ->method('_getOrder')
250
- ->will($this->returnValue($order));
251
-
252
- $this->assertEquals((bool)$expectedResult, $beacon->showBeacon());
253
- }
254
- }
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_Test_Block_BeaconTest extends EcomDev_PHPUnit_Test_Case
19
+ {
20
+ /**
21
+ * Get a mock of the config helper to return expected system configurations.
22
+ * @param string $programId
23
+ * @param string $transactionType
24
+ * @param string $itemizeOrders
25
+ * @return Mock_EbayEnterprise_Affiliate_Helper_Config
26
+ */
27
+ protected function _getConfigHelper($programId, $transactionType, $itemizeOrders)
28
+ {
29
+ $helper = $this->getHelperMock('eems_affiliate/config', array(
30
+ 'getProgramId', 'getTransactionType', 'isItemizedOrders', 'isDynamicOrders',
31
+ ));
32
+ $helper->expects($this->any())
33
+ ->method('getProgramId')
34
+ ->will($this->returnValue($programId));
35
+ $helper->expects($this->any())
36
+ ->method('getTransactionType')
37
+ ->will($this->returnValue($transactionType));
38
+ $helper->expects($this->any())
39
+ ->method('isItemizedOrders')
40
+ ->will($this->returnValue($itemizeOrders));
41
+ $helper->expects($this->any())
42
+ ->method('isDynamicOrders')
43
+ ->will($this->returnValue($itemizeOrders));
44
+ return $helper;
45
+ }
46
+ /**
47
+ * Test building the basic beacon url. Should only include order level
48
+ * information about the order in the url params.
49
+ */
50
+ public function testGetBeaconUrlBasic()
51
+ {
52
+ $orderId = '000012';
53
+ $subtotal = '10.99';
54
+ $discount = '-5.00';
55
+ $couponCode = 'COUPON';
56
+ $programId = 'PROGRAM ID';
57
+ $transactionType = 'TRANS TYPE';
58
+ $itemizeOrders = false;
59
+ $params = array(
60
+ 'PID' => $programId,
61
+ 'OID' => $orderId,
62
+ 'PROMOCODE' => $couponCode,
63
+ 'AMOUNT' => '5.99',
64
+ 'TYPE' => $transactionType
65
+ );
66
+ $beaconUrl = 'https://example.com/track';
67
+ $order = Mage::getModel('sales/order', array(
68
+ 'increment_id' => $orderId,
69
+ 'subtotal' => $subtotal,
70
+ 'coupon_code' => $couponCode,
71
+ 'discount_amount' => $discount,
72
+ ));
73
+ // mock out the config helper to setup expected system configurations
74
+ $this->replaceByMock(
75
+ 'helper',
76
+ 'eems_affiliate/config',
77
+ $this->_getConfigHelper($programId, $transactionType, $itemizeOrders)
78
+ );
79
+ $helper = $this->getHelperMock('eems_affiliate/data', array('buildBeaconUrl'));
80
+ $helper->expects($this->once())
81
+ ->method('buildBeaconUrl')
82
+ ->with($this->identicalTo($params))
83
+ ->will($this->returnValue($beaconUrl));
84
+ $this->replaceByMock('helper', 'eems_affiliate', $helper);
85
+
86
+ $block = $this->getBlockMock('eems_affiliate/beacon', array('_getOrder'));
87
+ $block->expects($this->any())
88
+ ->method('_getOrder')
89
+ ->will($this->returnValue($order));
90
+
91
+ $this->assertSame($beaconUrl, $block->getBeaconUrl());
92
+ }
93
+ /**
94
+ * Test building the itemized beacon url. Should include item level details
95
+ * in the url params for each item in the order.
96
+ */
97
+ public function testGetBeaconUrlItemized()
98
+ {
99
+ $programId = 'PROGRAM ID';
100
+ // should use itemized beacon when itemize orders is true
101
+ $itemizeOrders = true;
102
+ $orderId = '000012';
103
+ $couponCode = 'COUPON';
104
+ $itemSku = 'sku-12345';
105
+ $altSku = 'sku-54321';
106
+ $itemQty = 2;
107
+ $altQty = 3;
108
+ $itemAmt = '12.34';
109
+ $altAmt = '10.67';
110
+ $discountAmt = '5.00';
111
+ $bundleSku = 'bundle-sku-made-up-of-child-skus';
112
+ $bundleQty = 1;
113
+ // This is the expected final output from the method - gets returned from
114
+ // the eems_affiliate/data helper when called with the right params.
115
+ $beaconUrl = 'https://example.com/track?PARAM=Value';
116
+ // These are the "correct" params the helper method should be called with.
117
+ // Order of the array is significant - both to the test and the
118
+ // actual implementation.
119
+ $beaconParams = array(
120
+ 'PID' => $programId,
121
+ 'OID' => $orderId,
122
+ 'PROMOCODE' => $couponCode,
123
+ 'INT' => 'ITEMIZED',
124
+ 'ITEM1' => $itemSku,
125
+ 'QTY1' => $itemQty * 2,
126
+ 'TOTALAMOUNT1' => number_format(($itemAmt - $discountAmt) * 2, 2),
127
+ 'ITEM2' => $altSku,
128
+ 'QTY2' => $altQty,
129
+ 'TOTALAMOUNT2' => $altAmt,
130
+ 'ITEM3' => $bundleSku,
131
+ 'QTY3' => $bundleQty,
132
+ 'TOTALAMOUNT3' => '0.00',
133
+ );
134
+
135
+ $item = Mage::getModel('sales/order_item', array(
136
+ 'sku' => $itemSku, 'qty_ordered' => $itemQty, 'row_total' => $itemAmt,
137
+ 'parent_item_id' => null, 'discount_amount' => $discountAmt,
138
+ 'product_type' => 'simple',
139
+ ));
140
+ $itemDupe = Mage::getModel('sales/order_item', array(
141
+ 'sku' => $itemSku, 'qty_ordered' => $itemQty, 'row_total' => $itemAmt,
142
+ 'parent_item_id' => null, 'discount_amount' => $discountAmt,
143
+ 'product_type' => 'simple',
144
+ ));
145
+ $parentItem = Mage::getModel('sales/order_item', array(
146
+ 'sku' => $altSku, 'qty_ordered' => $altQty, 'row_total' => $altAmt,
147
+ 'parent_item_id' => null, 'discount_amount' => 0.00,
148
+ 'product_type' => 'configurable',
149
+ ));
150
+ $altItem = Mage::getModel('sales/order_item', array(
151
+ 'sku' => $altSku, 'qty_ordered' => $altQty, 'row_total' => 0.00,
152
+ 'parent_item_id' => '2', 'discount_amount' => 0.00,
153
+ 'product_type' => 'simple',
154
+ ));
155
+ $bundleItem = Mage::getModel('sales/order_item', array(
156
+ 'sku' => $bundleSku, 'qty_ordered' => $bundleQty, 'row_total' => '500.00',
157
+ 'parent_item_id' => null, 'discount_amount' => 0.00,
158
+ 'product_type' => 'bundle',
159
+ ));
160
+ $order = Mage::getModel('sales/order', array(
161
+ 'increment_id' => $orderId, 'coupon_code' => $couponCode,
162
+ ));
163
+ $order->addItem($item);
164
+ $order->addItem($itemDupe);
165
+ $order->addItem($parentItem);
166
+ $order->addItem($altItem);
167
+ $order->addItem($bundleItem);
168
+
169
+ // mock out the config helper to setup expected system configurations
170
+ $this->replaceByMock(
171
+ 'helper',
172
+ 'eems_affiliate/config',
173
+ $this->_getConfigHelper($programId, null, $itemizeOrders)
174
+ );
175
+
176
+ $helper = $this->getHelperMock('eems_affiliate/data', array('buildBeaconUrl'));
177
+ $helper->expects($this->once())
178
+ ->method('buildBeaconUrl')
179
+ ->with($this->identicalTo($beaconParams))
180
+ ->will($this->returnValue($beaconUrl));
181
+ $this->replaceByMock('helper', 'eems_affiliate', $helper);
182
+
183
+ $block = $this->getBlockMock('eems_affiliate/beacon', array('_getOrder'));
184
+ $block->expects($this->any())
185
+ ->method('_getOrder')
186
+ ->will($this->returnValue($order));
187
+
188
+ $this->assertSame($beaconUrl, $block->getBeaconUrl());
189
+ }
190
+ /**
191
+ * Test that EbayEnterprise_Affiliate_Block_Beacon::_getOrder will be invoked
192
+ * by this test and expect it to return Mage_Sales_Model_Order object
193
+ */
194
+ public function testGetOrder()
195
+ {
196
+ $orderId = '00000084848';
197
+ $session = $this->getModelMockBuilder('checkout/session')
198
+ ->disableOriginalConstructor()
199
+ ->setMethods(null)
200
+ ->getMock();
201
+ $session->setLastOrderId($orderId);
202
+ $this->replaceByMock('singleton', 'checkout/session', $session);
203
+
204
+ $order = $this->getModelMock('sales/order', array('load'));
205
+ $order->expects($this->once())
206
+ ->method('load')
207
+ ->with($this->identicalTo($orderId))
208
+ ->will($this->returnSelf());
209
+ $this->replaceByMock('model', 'sales/order', $order);
210
+
211
+ $beacon = $this->getBlockMock('eems_affiliate/beacon', array());
212
+ EcomDev_Utils_Reflection::setRestrictedPropertyValue($beacon, '_order', null);
213
+
214
+ $this->assertSame($order, EcomDev_Utils_Reflection::invokeRestrictedMethod(
215
+ $beacon,
216
+ '_getOrder',
217
+ array()
218
+ ));
219
+ }
220
+ /**
221
+ * Test that EbayEnterprise_Affiliate_Block_Beacon::showBeacon will return true
222
+ * only if tracking is enabled and we have a valid order
223
+ * AND either conditional pixel logic is OFF or it is ON and we have
224
+ * a valid cookie.
225
+ *
226
+ * @dataProvider dataProvider
227
+ */
228
+ public function testShowBeacon($isEnabled, $isOrder, $isPixelLogicEnabled, $isValidCookie, $expectedResult)
229
+ {
230
+ $configHelper = $this->getHelperMock('eems_affiliate/config', array('isEnabled', 'isConditionalPixelEnabled'));
231
+ $configHelper->expects($this->any())
232
+ ->method('isEnabled')
233
+ ->will($this->returnValue($isEnabled));
234
+
235
+ $configHelper->expects($this->any())
236
+ ->method('isConditionalPixelEnabled')
237
+ ->will($this->returnValue($isPixelLogicEnabled));
238
+ $this->replaceByMock('helper', 'eems_affiliate/config', $configHelper);
239
+
240
+ $dataHelper = $this->getHelperMock('eems_affiliate', array('isValidCookie'));
241
+ $dataHelper->expects(($this->any()))
242
+ ->method('isValidCookie')
243
+ ->will($this->returnValue($isValidCookie));
244
+ $this->replaceByMock('helper', 'eems_affiliate', $dataHelper);
245
+
246
+ $order = (bool)$isOrder ? Mage::getModel('sales/order') : null;
247
+ $beacon = $this->getBlockMock('eems_affiliate/beacon', array('_getOrder'));
248
+ $beacon->expects($this->any())
249
+ ->method('_getOrder')
250
+ ->will($this->returnValue($order));
251
+
252
+ $this->assertEquals((bool)$expectedResult, $beacon->showBeacon());
253
+ }
254
+ }
app/code/community/EbayEnterprise/Affiliate/Test/Block/providers/testShowBeacon.yaml CHANGED
@@ -1,99 +1,99 @@
1
- -
2
- - 1 # tracking enabled
3
- - 1 # order is instanceof Mage_Sales_Model_Order
4
- - 1 # conditional logic enabled
5
- - 1 # valid cookie
6
- - 1 # show beacon
7
- -
8
- - 1
9
- - 1
10
- - 1
11
- - 0
12
- - 0
13
- -
14
- - 1
15
- - 1
16
- - 0
17
- - 0
18
- - 1
19
- -
20
- - 1
21
- - 1
22
- - 0
23
- - 1
24
- - 1
25
- #
26
- -
27
- - 1
28
- - 0
29
- - 0
30
- - 0
31
- - 0
32
- -
33
- - 1
34
- - 0
35
- - 0
36
- - 1
37
- - 0
38
- -
39
- - 1
40
- - 0
41
- - 1
42
- - 0
43
- - 0
44
- -
45
- - 1
46
- - 0
47
- - 1
48
- - 1
49
- - 0
50
- #
51
- -
52
- - 0
53
- - 0
54
- - 0
55
- - 0
56
- - 0
57
- -
58
- - 0
59
- - 0
60
- - 0
61
- - 1
62
- - 0
63
- -
64
- - 0
65
- - 0
66
- - 1
67
- - 0
68
- - 0
69
- -
70
- - 0
71
- - 0
72
- - 1
73
- - 1
74
- - 0
75
- #
76
- -
77
- - 0
78
- - 1
79
- - 0
80
- - 0
81
- - 0
82
- -
83
- - 0
84
- - 1
85
- - 0
86
- - 1
87
- - 0
88
- -
89
- - 0
90
- - 1
91
- - 1
92
- - 0
93
- - 0
94
- -
95
- - 0
96
- - 1
97
- - 1
98
- - 1
99
- - 0
1
+ -
2
+ - 1 # tracking enabled
3
+ - 1 # order is instanceof Mage_Sales_Model_Order
4
+ - 1 # conditional logic enabled
5
+ - 1 # valid cookie
6
+ - 1 # show beacon
7
+ -
8
+ - 1
9
+ - 1
10
+ - 1
11
+ - 0
12
+ - 0
13
+ -
14
+ - 1
15
+ - 1
16
+ - 0
17
+ - 0
18
+ - 1
19
+ -
20
+ - 1
21
+ - 1
22
+ - 0
23
+ - 1
24
+ - 1
25
+ #
26
+ -
27
+ - 1
28
+ - 0
29
+ - 0
30
+ - 0
31
+ - 0
32
+ -
33
+ - 1
34
+ - 0
35
+ - 0
36
+ - 1
37
+ - 0
38
+ -
39
+ - 1
40
+ - 0
41
+ - 1
42
+ - 0
43
+ - 0
44
+ -
45
+ - 1
46
+ - 0
47
+ - 1
48
+ - 1
49
+ - 0
50
+ #
51
+ -
52
+ - 0
53
+ - 0
54
+ - 0
55
+ - 0
56
+ - 0
57
+ -
58
+ - 0
59
+ - 0
60
+ - 0
61
+ - 1
62
+ - 0
63
+ -
64
+ - 0
65
+ - 0
66
+ - 1
67
+ - 0
68
+ - 0
69
+ -
70
+ - 0
71
+ - 0
72
+ - 1
73
+ - 1
74
+ - 0
75
+ #
76
+ -
77
+ - 0
78
+ - 1
79
+ - 0
80
+ - 0
81
+ - 0
82
+ -
83
+ - 0
84
+ - 1
85
+ - 0
86
+ - 1
87
+ - 0
88
+ -
89
+ - 0
90
+ - 1
91
+ - 1
92
+ - 0
93
+ - 0
94
+ -
95
+ - 0
96
+ - 1
97
+ - 1
98
+ - 1
99
+ - 0
app/code/community/EbayEnterprise/Affiliate/Test/Helper/DataTest.php CHANGED
@@ -1,54 +1,54 @@
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_Test_Helper_DataTest extends EcomDev_PHPUnit_Test_Case
19
- {
20
- /**
21
- * Test that EbayEnterprise_Affiliate_Helper_Data::buildBeaconUrl yields the
22
- * expected, escaped url with query string when passed an array of params to append.
23
- */
24
- public function testBuildBeaconUrl()
25
- {
26
- $beaconUrl = 'https://example.com/track';
27
- $params = array('KEY1' => 'K1', 'KEY2' => 'K2');
28
- $result = $beaconUrl . '?' . http_build_query($params);
29
-
30
- $cfgHelper = $this->getHelperMock('eems_affiliate/config', array('getBeaconBaseUrl'));
31
- $cfgHelper->expects($this->once())
32
- ->method('getBeaconBaseUrl')
33
- ->will($this->returnValue($beaconUrl));
34
- $this->replaceByMock('helper', 'eems_affiliate/config', $cfgHelper);
35
-
36
- $this->assertSame($result, Mage::helper('eems_affiliate/data')->buildBeaconUrl($params));
37
- }
38
-
39
- /**
40
- * @dataProvider dataProvider
41
- */
42
- public function testIsValidCookie($cookie, $value, $expectedResult)
43
- {
44
- $dataHelper = $this->getHelperMock('eems_affiliate', array('getSourceCookieName'));
45
- $dataHelper->expects(($this->any()))
46
- ->method('getSourceCookieName')
47
- ->will($this->returnValue('ebay_enterprise_affiliate_source'));
48
- $this->replaceByMock('helper', 'eems_affiliate', $dataHelper);
49
-
50
- $_COOKIE[$cookie] = $value;
51
-
52
- $this->assertEquals((bool)$expectedResult, $dataHelper->isValidCookie());
53
- }
54
- }
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_Test_Helper_DataTest extends EcomDev_PHPUnit_Test_Case
19
+ {
20
+ /**
21
+ * Test that EbayEnterprise_Affiliate_Helper_Data::buildBeaconUrl yields the
22
+ * expected, escaped url with query string when passed an array of params to append.
23
+ */
24
+ public function testBuildBeaconUrl()
25
+ {
26
+ $beaconUrl = 'https://example.com/track';
27
+ $params = array('KEY1' => 'K1', 'KEY2' => 'K2');
28
+ $result = $beaconUrl . '?' . http_build_query($params);
29
+
30
+ $cfgHelper = $this->getHelperMock('eems_affiliate/config', array('getBeaconBaseUrl'));
31
+ $cfgHelper->expects($this->once())
32
+ ->method('getBeaconBaseUrl')
33
+ ->will($this->returnValue($beaconUrl));
34
+ $this->replaceByMock('helper', 'eems_affiliate/config', $cfgHelper);
35
+
36
+ $this->assertSame($result, Mage::helper('eems_affiliate/data')->buildBeaconUrl($params));
37
+ }
38
+
39
+ /**
40
+ * @dataProvider dataProvider
41
+ */
42
+ public function testIsValidCookie($cookie, $value, $expectedResult)
43
+ {
44
+ $dataHelper = $this->getHelperMock('eems_affiliate', array('getSourceCookieName'));
45
+ $dataHelper->expects(($this->any()))
46
+ ->method('getSourceCookieName')
47
+ ->will($this->returnValue('ebay_enterprise_affiliate_source'));
48
+ $this->replaceByMock('helper', 'eems_affiliate', $dataHelper);
49
+
50
+ $_COOKIE[$cookie] = $value;
51
+
52
+ $this->assertEquals((bool)$expectedResult, $dataHelper->isValidCookie());
53
+ }
54
+ }
app/code/community/EbayEnterprise/Affiliate/Test/Helper/Map/ProductTest.php CHANGED
@@ -1,174 +1,174 @@
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_Test_Helper_Map_ProductTest extends EcomDev_PHPUnit_Test_Case
19
- {
20
- /**
21
- * Test that EbayEnterprise_Affiliate_Helper_Map_Product::getCategory will
22
- * return a string of root category separated with the symbol '>' with inner
23
- * category to the the inner most category.
24
- */
25
- public function testGetCategory()
26
- {
27
-
28
- $categoryIds = array('1','2','3');
29
- $path = implode('/', $categoryIds);
30
- $categories = array('cat one', 'cat two', 'cat three');
31
- $collection = Mage::getResourceModel('catalog/category_collection');
32
-
33
- $categoryObjects = array();
34
- foreach ($categories as $index => $name) {
35
- $category = Mage::getModel('catalog/category', array(
36
- 'name' => $name, 'entity_id' => $index + 9999, 'path' => $path
37
- ));
38
- $categoryObjects[] = $category;
39
- $collection->addItem($category);
40
- }
41
-
42
- $productCategoryColl = Mage::getResourceModel('catalog/category_collection');
43
- ;
44
- $productCategoryColl->addItem($categoryObjects[2]);
45
- $product = $this->getModelMock('catalog/product', array('getCategoryCollection'));
46
- $product->expects($this->once())
47
- ->method('getCategoryCollection')
48
- ->will($this->returnValue($productCategoryColl));
49
-
50
- $params = array('item' => $product);
51
-
52
- $result = implode(' > ', $categories);
53
-
54
- $mapProduct = $this->getHelperMock('eems_affiliate/map_product', array('_getCategoriesByIds'));
55
- $mapProduct->expects($this->once())
56
- ->method('_getCategoriesByIds')
57
- ->with($this->identicalTo($categoryIds))
58
- ->will($this->returnValue($collection));
59
-
60
- $this->assertSame($result, $mapProduct->getCategory($params));
61
- }
62
- /**
63
- * Test that EbayEnterprise_Affiliate_Helper_Map_Product::getImageUrl will
64
- * return an absolute URL to an image view.
65
- */
66
- public function testGetImageUrl()
67
- {
68
- $key = 'image';
69
- $image = '/k/o/some-product-image.jpg';
70
- $mediaUrl = 'http://www.example.com/' .
71
- EbayEnterprise_Affiliate_Helper_Map_Product::MEDIA_PATH . $image;
72
-
73
- $product = $this->getModelMockBuilder('catalog/product')
74
- ->disableOriginalConstructor()
75
- ->setMethods(array('getDataUsingMethod'))
76
- ->getMock();
77
- $product->expects($this->once())
78
- ->method('getDataUsingMethod')
79
- ->with($this->identicalTo($key))
80
- ->will($this->returnValue($image));
81
-
82
- $params = array('item' => $product, 'key' => $key);
83
-
84
- $helperProduct = $this->getHelperMock('eems_affiliate/map_product', array(
85
- '_getAbsoluteImagePath'
86
- ));
87
-
88
- $helperProduct->expects($this->once())
89
- ->method('_getAbsoluteImagePath')
90
- ->with($this->identicalTo($image))
91
- ->will($this->returnValue($mediaUrl));
92
-
93
- $this->assertSame($mediaUrl, $helperProduct->getImageUrl($params));
94
- }
95
- /**
96
- * Test that EbayEnterprise_Affiliate_Helper_Map_Product::getInStockQty will
97
- * return an integer value representing the manage stock qty of a product.
98
- */
99
- public function testGetInStockQty()
100
- {
101
- $qty = 999;
102
- $product = Mage::getModel('catalog/product');
103
- $params = array('item' => $product);
104
-
105
- $stockItem = $this->getModelMockBuilder('cataloginventory/stock_item')
106
- ->disableOriginalConstructor()
107
- ->setMethods(array('loadByProduct', 'getQty'))
108
- ->getMock();
109
- $stockItem->expects($this->once())
110
- ->method('loadByProduct')
111
- ->with($this->identicalTo($product))
112
- ->will($this->returnSelf());
113
- $stockItem->expects($this->once())
114
- ->method('getQty')
115
- ->will($this->returnValue($qty));
116
- $this->replaceByMock('model', 'cataloginventory/stock_item', $stockItem);
117
-
118
- $this->assertSame($qty, Mage::helper('eems_affiliate/map_product')->getInStockQty($params));
119
- }
120
- /**
121
- * Test that EbayEnterprise_Affiliate_Helper_Map_Product::_getCategoriesByIds
122
- * will be invoked by this test passing an array of category entity ids
123
- * and will return a Mage_Catalog_Model_Resource_Category_Collection
124
- */
125
- public function testGetCategoriesByIds()
126
- {
127
- $entityIds = array(1,2,3);
128
- $collection = $this->getResourceModelMockBuilder('catalog/category_collection')
129
- ->disableOriginalConstructor()
130
- ->setMethods(array('addAttributeToSelect', 'addAttributeToFilter', 'load'))
131
- ->getMock();
132
- $collection->expects($this->once())
133
- ->method('addAttributeToSelect')
134
- ->with($this->identicalTo(array('name', 'entity_id')))
135
- ->will($this->returnSelf());
136
- $collection->expects($this->once())
137
- ->method('addAttributeToFilter')
138
- ->with($this->identicalTo(array(array('attribute' => 'entity_id', 'in' => $entityIds))))
139
- ->will($this->returnSelf());
140
- $collection->expects($this->once())
141
- ->method('load')
142
- ->will($this->returnSelf());
143
- $this->replaceByMock('resource_model', 'catalog/category_collection', $collection);
144
-
145
- $mapProduct = $this->getHelperMock('eems_affiliate/map_product', array());
146
-
147
- $this->assertSame($collection, EcomDev_Utils_Reflection::invokeRestrictedMethod(
148
- $mapProduct,
149
- '_getCategoriesByIds',
150
- array($entityIds)
151
- ));
152
- }
153
- /**
154
- * Test that EbayEnterprise_Affiliate_Helper_Map_Product::getInStockYesNo will
155
- * be called by this test passing an array with key item map to a
156
- * Mage_Catalog_Model_Product object and expects it to return the string value 'yes'.
157
- */
158
- public function testGetInStockYesNo()
159
- {
160
- $result = 'yes';
161
- $isInStock = '1';
162
- $params = array('item' => Mage::getModel('catalog/product'));
163
-
164
- $stockItem = $this->getModelMock('cataloginventory/stock_item', array('loadByProduct'));
165
- $stockItem->expects($this->once())
166
- ->method('loadByProduct')
167
- ->with($this->identicalTo($params['item']))
168
- ->will($this->returnSelf());
169
- $stockItem->setIsInstock($isInStock);
170
- $this->replaceByMock('model', 'cataloginventory/stock_item', $stockItem);
171
-
172
- $this->assertSame($result, Mage::helper('eems_affiliate/map_product')->getInStockYesNo($params));
173
- }
174
- }
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_Test_Helper_Map_ProductTest extends EcomDev_PHPUnit_Test_Case
19
+ {
20
+ /**
21
+ * Test that EbayEnterprise_Affiliate_Helper_Map_Product::getCategory will
22
+ * return a string of root category separated with the symbol '>' with inner
23
+ * category to the the inner most category.
24
+ */
25
+ public function testGetCategory()
26
+ {
27
+
28
+ $categoryIds = array('1','2','3');
29
+ $path = implode('/', $categoryIds);
30
+ $categories = array('cat one', 'cat two', 'cat three');
31
+ $collection = Mage::getResourceModel('catalog/category_collection');
32
+
33
+ $categoryObjects = array();
34
+ foreach ($categories as $index => $name) {
35
+ $category = Mage::getModel('catalog/category', array(
36
+ 'name' => $name, 'entity_id' => $index + 9999, 'path' => $path
37
+ ));
38
+ $categoryObjects[] = $category;
39
+ $collection->addItem($category);
40
+ }
41
+
42
+ $productCategoryColl = Mage::getResourceModel('catalog/category_collection');
43
+ ;
44
+ $productCategoryColl->addItem($categoryObjects[2]);
45
+ $product = $this->getModelMock('catalog/product', array('getCategoryCollection'));
46
+ $product->expects($this->once())
47
+ ->method('getCategoryCollection')
48
+ ->will($this->returnValue($productCategoryColl));
49
+
50
+ $params = array('item' => $product);
51
+
52
+ $result = implode(' > ', $categories);
53
+
54
+ $mapProduct = $this->getHelperMock('eems_affiliate/map_product', array('_getCategoriesByIds'));
55
+ $mapProduct->expects($this->once())
56
+ ->method('_getCategoriesByIds')
57
+ ->with($this->identicalTo($categoryIds))
58
+ ->will($this->returnValue($collection));
59
+
60
+ $this->assertSame($result, $mapProduct->getCategory($params));
61
+ }
62
+ /**
63
+ * Test that EbayEnterprise_Affiliate_Helper_Map_Product::getImageUrl will
64
+ * return an absolute URL to an image view.
65
+ */
66
+ public function testGetImageUrl()
67
+ {
68
+ $key = 'image';
69
+ $image = '/k/o/some-product-image.jpg';
70
+ $mediaUrl = 'http://www.example.com/' .
71
+ EbayEnterprise_Affiliate_Helper_Map_Product::MEDIA_PATH . $image;
72
+
73
+ $product = $this->getModelMockBuilder('catalog/product')
74
+ ->disableOriginalConstructor()
75
+ ->setMethods(array('getDataUsingMethod'))
76
+ ->getMock();
77
+ $product->expects($this->once())
78
+ ->method('getDataUsingMethod')
79
+ ->with($this->identicalTo($key))
80
+ ->will($this->returnValue($image));
81
+
82
+ $params = array('item' => $product, 'key' => $key);
83
+
84
+ $helperProduct = $this->getHelperMock('eems_affiliate/map_product', array(
85
+ '_getAbsoluteImagePath'
86
+ ));
87
+
88
+ $helperProduct->expects($this->once())
89
+ ->method('_getAbsoluteImagePath')
90
+ ->with($this->identicalTo($image))
91
+ ->will($this->returnValue($mediaUrl));
92
+
93
+ $this->assertSame($mediaUrl, $helperProduct->getImageUrl($params));
94
+ }
95
+ /**
96
+ * Test that EbayEnterprise_Affiliate_Helper_Map_Product::getInStockQty will
97
+ * return an integer value representing the manage stock qty of a product.
98
+ */
99
+ public function testGetInStockQty()
100
+ {
101
+ $qty = 999;
102
+ $product = Mage::getModel('catalog/product');
103
+ $params = array('item' => $product);
104
+
105
+ $stockItem = $this->getModelMockBuilder('cataloginventory/stock_item')
106
+ ->disableOriginalConstructor()
107
+ ->setMethods(array('loadByProduct', 'getQty'))
108
+ ->getMock();
109
+ $stockItem->expects($this->once())
110
+ ->method('loadByProduct')
111
+ ->with($this->identicalTo($product))
112
+ ->will($this->returnSelf());
113
+ $stockItem->expects($this->once())
114
+ ->method('getQty')
115
+ ->will($this->returnValue($qty));
116
+ $this->replaceByMock('model', 'cataloginventory/stock_item', $stockItem);
117
+
118
+ $this->assertSame($qty, Mage::helper('eems_affiliate/map_product')->getInStockQty($params));
119
+ }
120
+ /**
121
+ * Test that EbayEnterprise_Affiliate_Helper_Map_Product::_getCategoriesByIds
122
+ * will be invoked by this test passing an array of category entity ids
123
+ * and will return a Mage_Catalog_Model_Resource_Category_Collection
124
+ */
125
+ public function testGetCategoriesByIds()
126
+ {
127
+ $entityIds = array(1,2,3);
128
+ $collection = $this->getResourceModelMockBuilder('catalog/category_collection')
129
+ ->disableOriginalConstructor()
130
+ ->setMethods(array('addAttributeToSelect', 'addAttributeToFilter', 'load'))
131
+ ->getMock();
132
+ $collection->expects($this->once())
133
+ ->method('addAttributeToSelect')
134
+ ->with($this->identicalTo(array('name', 'entity_id')))
135
+ ->will($this->returnSelf());
136
+ $collection->expects($this->once())
137
+ ->method('addAttributeToFilter')
138
+ ->with($this->identicalTo(array(array('attribute' => 'entity_id', 'in' => $entityIds))))
139
+ ->will($this->returnSelf());
140
+ $collection->expects($this->once())
141
+ ->method('load')
142
+ ->will($this->returnSelf());
143
+ $this->replaceByMock('resource_model', 'catalog/category_collection', $collection);
144
+
145
+ $mapProduct = $this->getHelperMock('eems_affiliate/map_product', array());
146
+
147
+ $this->assertSame($collection, EcomDev_Utils_Reflection::invokeRestrictedMethod(
148
+ $mapProduct,
149
+ '_getCategoriesByIds',
150
+ array($entityIds)
151
+ ));
152
+ }
153
+ /**
154
+ * Test that EbayEnterprise_Affiliate_Helper_Map_Product::getInStockYesNo will
155
+ * be called by this test passing an array with key item map to a
156
+ * Mage_Catalog_Model_Product object and expects it to return the string value 'yes'.
157
+ */
158
+ public function testGetInStockYesNo()
159
+ {
160
+ $result = 'yes';
161
+ $isInStock = '1';
162
+ $params = array('item' => Mage::getModel('catalog/product'));
163
+
164
+ $stockItem = $this->getModelMock('cataloginventory/stock_item', array('loadByProduct'));
165
+ $stockItem->expects($this->once())
166
+ ->method('loadByProduct')
167
+ ->with($this->identicalTo($params['item']))
168
+ ->will($this->returnSelf());
169
+ $stockItem->setIsInstock($isInStock);
170
+ $this->replaceByMock('model', 'cataloginventory/stock_item', $stockItem);
171
+
172
+ $this->assertSame($result, Mage::helper('eems_affiliate/map_product')->getInStockYesNo($params));
173
+ }
174
+ }
app/code/community/EbayEnterprise/Affiliate/Test/Helper/providers/testIsValidCookie.yaml CHANGED
@@ -1,12 +1,12 @@
1
- -
2
- - ebay_enterprise_affiliate_source
3
- - eean
4
- - 1
5
- -
6
- - ebay_enterprise_affiliate_source
7
- - invalid_value
8
- - 0
9
- -
10
- - invalid_cookie_name
11
- - eean
12
- - 0
1
+ -
2
+ - ebay_enterprise_affiliate_source
3
+ - eean
4
+ - 1
5
+ -
6
+ - ebay_enterprise_affiliate_source
7
+ - invalid_value
8
+ - 0
9
+ -
10
+ - invalid_cookie_name
11
+ - eean
12
+ - 0
app/code/community/EbayEnterprise/Affiliate/Test/Model/Feed/AbstractTest.php CHANGED
@@ -1,293 +1,293 @@
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
-
19
- class EbayEnterprise_Affiliate_Test_Model_Feed_AbstractTest extends EcomDev_PHPUnit_Test_Case
20
- {
21
- /**
22
- * Test generating a feed file
23
- */
24
- public function testGenerateFeed()
25
- {
26
- $feedData = array(array('one', 'two', 'three'));
27
- $feed = $this->getModelMock(
28
- 'eems_affiliate/feed_abstract',
29
- array('_buildFeedData', '_generateFile'),
30
- true
31
- );
32
- $feed->expects($this->once())
33
- ->method('_buildFeedData')
34
- ->will($this->returnValue($feedData));
35
- $feed->expects($this->once())
36
- ->method('_generateFile')
37
- ->with($this->identicalTo($feedData))
38
- ->will($this->returnSelf());
39
- $this->assertSame($feed, $feed->generateFeed());
40
- }
41
- /**
42
- * Test generating array of data to place into feed
43
- */
44
- public function testBuildFeedData()
45
- {
46
- $itemOneMappedData = array('item', 'one', 'data');
47
- $itemTwoMappedData = array('item', 'two', 'data');
48
- $feedData = array($itemOneMappedData, $itemTwoMappedData);
49
-
50
- $itemCollection = new Varien_Data_Collection();
51
- $itemOne = Mage::getModel('sales/order');
52
- $itemTwo = Mage::getModel('sales/order');
53
- $itemCollection->addItem($itemOne)->addItem($itemTwo);
54
-
55
- $feed = $this->getModelMock(
56
- 'eems_affiliate/feed_abstract',
57
- array('_getItems', '_applyMapping'),
58
- true
59
- );
60
- // get items will vary per feed type - itemized order, basic order or product
61
- $feed->expects($this->once())
62
- ->method('_getItems')
63
- ->will($this->returnValue($itemCollection));
64
- // should get called once for each item, returning the array of item data for the feed
65
- $feed->expects($this->exactly(2))
66
- ->method('_applyMapping')
67
- ->will($this->returnValueMap(array(
68
- array($itemOne, $itemOneMappedData),
69
- array($itemTwo, $itemTwoMappedData),
70
- )));
71
-
72
- $this->assertSame(
73
- $feedData,
74
- EcomDev_Utils_Reflection::invokeRestrictedMethod($feed, '_buildFeedData')
75
- );
76
- }
77
- /**
78
- * Test applying the configured mapping to the item to get back an array of
79
- * data for each field in the feed.
80
- */
81
- public function testApplyMapping()
82
- {
83
- $orderAmt = 23.23;
84
- $store = Mage::app()->getStore();
85
- $fields = array('fieldA', 'fieldB');
86
- // callback mapping to use
87
- $mappings = array(
88
- 'fieldA' => array(
89
- 'class' => 'eems_affiliate/map_order', 'type' => 'helper',
90
- 'method' => 'getOrderAmount', 'params' => array('key' => 'value'),
91
- 'column_name' => 'OID'
92
- ),
93
- 'fieldB' => array('type' => 'disabled'),
94
- );
95
- $itemData = array($orderAmt);
96
- // The type of this object will vary depending on feed type but will likely
97
- // be a descendent of Varien_Object. It shouldn't matter much to the test
98
- // as it should just get passed through to the callbacks.
99
- $item = new Varien_Object();
100
-
101
- // All callbacks setup to use this helper
102
- $feedHelper = $this->getHelperMock(
103
- 'eems_affiliate/map_order',
104
- array('getOrderAmount')
105
- );
106
- $feedHelper->expects($this->once())
107
- ->method('getOrderAmount')
108
- ->with($this->identicalTo(array('key' => 'value', 'item' => $item, 'store' => $store)))
109
- ->will($this->returnValue($orderAmt));
110
- $this->replaceByMock('helper', 'eems_affiliate/map_order', $feedHelper);
111
-
112
- $config = $this->getHelperMock('eems_affiliate/config', array('getCallbackMappings'));
113
- $config->expects($this->any())
114
- ->method('getCallbackMappings')
115
- ->will($this->returnValue($mappings));
116
- $this->replaceByMock('helper', 'eems_affiliate/config', $config);
117
-
118
- $feed = $this->getModelMock(
119
- 'eems_affiliate/feed_abstract',
120
- array('_getFeedFields'),
121
- true,
122
- array(array('store' => $store))
123
- );
124
- // The _getFeedFields method will be defined for each type of feed and should
125
- // return array of mapped fields to include.
126
- $feed->expects($this->any())
127
- ->method('_getFeedFields')
128
- ->will($this->returnValue($fields));
129
-
130
- $this->assertSame(
131
- $itemData,
132
- EcomDev_Utils_Reflection::invokeRestrictedMethod($feed, '_applyMapping', array($item))
133
- );
134
- }
135
- /**
136
- * Test that when a configured method does not exist on the specified class,
137
- * an exception is thrown.
138
- */
139
- public function testInvokeCallbackFailures()
140
- {
141
- $callbackConfig = array('class' => 'eems_affiliate', 'type' => 'helper', 'method' => 'getSomething');
142
- $feed = $this->getModelMock(
143
- 'eems_affiliate/feed_abstract',
144
- array('_getCallbackInstance'),
145
- true
146
- );
147
- // Sub an object that will certainly not have the configured method on it.
148
- $feed->expects($this->once())
149
- ->method('_getCallbackInstance')
150
- ->with($this->identicalTo($callbackConfig))
151
- ->will($this->returnValue(new StdClass));
152
-
153
- $this->setExpectedException('EbayEnterprise_Affiliate_Exception_Configuration');
154
- EcomDev_Utils_Reflection::invokeRestrictedMethod(
155
- $feed,
156
- '_invokeCallback',
157
- array($callbackConfig, new Varien_Object())
158
- );
159
- }
160
- /**
161
- * Provide a sample callback configuration and whether the callback is
162
- * expected to be deemed valid.
163
- * @return array
164
- */
165
- public function provideCallbacksToValidate()
166
- {
167
- return array(
168
- array(
169
- array(),
170
- false
171
- ),
172
- array(
173
- array('type' => 'disabled'),
174
- true
175
- ),
176
- array(
177
- array('type' => 'disabled', 'class' => 'eems_affiliate'),
178
- true
179
- ),
180
- array(
181
- array('type' => 'model'),
182
- false
183
- ),
184
- array(
185
- array('type' => 'singleton', 'class' => 'eems_affiliate/feed_abstract'),
186
- false
187
- ),
188
- array(
189
- array('type' => 'helper', 'class' => 'eems_affiliate/map', 'method' => 'getOrderId'),
190
- false
191
- ),
192
- array(
193
- array('type' => 'helper', 'class' => 'eems_affiliate/map', 'method' => 'getOrderId', 'column_name' => 'OID'),
194
- true
195
- ),
196
- );
197
- }
198
- /**
199
- * Test checking for a callback configuration to be valid. When the is valid
200
- * param indicates the configuration is invalid, an exception should be
201
- * thrown. Otherwise, the method should simply reurun self.
202
- * @param array $config Array of config data to validate
203
- * @param boolean $isValid Is the config data valid
204
- * @dataProvider provideCallbacksToValidate
205
- */
206
- public function testValidateCallbackConfig($config, $isValid)
207
- {
208
- $feed = $this->getModelMock(
209
- 'eems_affiliate/feed_abstract',
210
- array(),
211
- true
212
- );
213
-
214
- if (!$isValid) {
215
- $this->setExpectedException('EbayEnterprise_Affiliate_Exception_Configuration');
216
- }
217
-
218
- $result = EcomDev_Utils_Reflection::invokeRestrictedMethod(
219
- $feed,
220
- '_validateCallbackConfig',
221
- array($config)
222
- );
223
- if ($isValid) {
224
- $this->assertSame($result, $feed);
225
- }
226
- }
227
- /**
228
- * Test getting column headers based on the configured mappings for the feed.
229
- */
230
- public function testGetHeaders()
231
- {
232
- $fields = array('program_id', 'order_id');
233
- $mapping = array(
234
- 'program_id' => array('class' => 'some/class', 'method' => 'getProgramId', 'column_name' => 'PID'),
235
- 'order_id' => array('class' => 'some/class', 'method' => 'getOrderId', 'column_name' => 'OID'),
236
- );
237
-
238
- $config = $this->getHelperMock('eems_affiliate/config', array('getCallbackMappings'));
239
- $config->expects($this->any())
240
- ->method('getCallbackMappings')
241
- ->will($this->returnValue($mapping));
242
- $this->replaceByMock('helper', 'eems_affiliate/config', $config);
243
-
244
- $feed = $this->getModelMock(
245
- 'eems_affiliate/feed_abstract',
246
- array('_getFeedFields'),
247
- true
248
- );
249
- $feed->expects($this->once())
250
- ->method('_getFeedFields')
251
- ->will($this->returnValue($fields));
252
-
253
- $this->assertSame(
254
- // keys don't matter, so make sure to compare just values to values
255
- array('PID', 'OID'),
256
- array_values(EcomDev_Utils_Reflection::invokeRestrictedMethod($feed, '_getHeaders'))
257
- );
258
- }
259
- /**
260
- * Test generating the full path to the file. Should consist of Magento's
261
- * base dir, the configured export feed path, and the name of the file.
262
- */
263
- public function testGenerateFilePath()
264
- {
265
- $format = 'file_name.csv';
266
- $configuredPath = 'var/feed/export';
267
- $configHelper = $this->getHelperMock(
268
- 'eems_affiliate/config',
269
- array('getExportFilePath', 'getProgramId')
270
- );
271
- $configHelper->expects($this->any())
272
- ->method('getExportFilePath')
273
- ->will($this->returnValue($configuredPath));
274
- $configHelper->expects($this->any())
275
- ->method('getProgramId')
276
- ->will($this->returnValue('PROGRAM_ID'));
277
- $this->replaceByMock('helper', 'eems_affiliate/config', $configHelper);
278
-
279
- $feed = $this->getModelMock(
280
- 'eems_affiliate/feed_abstract',
281
- array('_getFileName'),
282
- true
283
- );
284
- $feed->expects($this->any())
285
- ->method('_getFileName')
286
- ->will($this->returnValue($format));
287
-
288
- $this->assertSame(
289
- Mage::getBaseDir() . DS . 'var/feed/export' . DS . $format,
290
- EcomDev_Utils_Reflection::invokeRestrictedMethod($feed, '_generateFilePath')
291
- );
292
- }
293
- }
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
+
19
+ class EbayEnterprise_Affiliate_Test_Model_Feed_AbstractTest extends EcomDev_PHPUnit_Test_Case
20
+ {
21
+ /**
22
+ * Test generating a feed file
23
+ */
24
+ public function testGenerateFeed()
25
+ {
26
+ $feedData = array(array('one', 'two', 'three'));
27
+ $feed = $this->getModelMock(
28
+ 'eems_affiliate/feed_abstract',
29
+ array('_buildFeedData', '_generateFile'),
30
+ true
31
+ );
32
+ $feed->expects($this->once())
33
+ ->method('_buildFeedData')
34
+ ->will($this->returnValue($feedData));
35
+ $feed->expects($this->once())
36
+ ->method('_generateFile')
37
+ ->with($this->identicalTo($feedData))
38
+ ->will($this->returnSelf());
39
+ $this->assertSame($feed, $feed->generateFeed());
40
+ }
41
+ /**
42
+ * Test generating array of data to place into feed
43
+ */
44
+ public function testBuildFeedData()
45
+ {
46
+ $itemOneMappedData = array('item', 'one', 'data');
47
+ $itemTwoMappedData = array('item', 'two', 'data');
48
+ $feedData = array($itemOneMappedData, $itemTwoMappedData);
49
+
50
+ $itemCollection = new Varien_Data_Collection();
51
+ $itemOne = Mage::getModel('sales/order');
52
+ $itemTwo = Mage::getModel('sales/order');
53
+ $itemCollection->addItem($itemOne)->addItem($itemTwo);
54
+
55
+ $feed = $this->getModelMock(
56
+ 'eems_affiliate/feed_abstract',
57
+ array('_getItems', '_applyMapping'),
58
+ true
59
+ );
60
+ // get items will vary per feed type - itemized order, basic order or product
61
+ $feed->expects($this->once())
62
+ ->method('_getItems')
63
+ ->will($this->returnValue($itemCollection));
64
+ // should get called once for each item, returning the array of item data for the feed
65
+ $feed->expects($this->exactly(2))
66
+ ->method('_applyMapping')
67
+ ->will($this->returnValueMap(array(
68
+ array($itemOne, $itemOneMappedData),
69
+ array($itemTwo, $itemTwoMappedData),
70
+ )));
71
+
72
+ $this->assertSame(
73
+ $feedData,
74
+ EcomDev_Utils_Reflection::invokeRestrictedMethod($feed, '_buildFeedData')
75
+ );
76
+ }
77
+ /**
78
+ * Test applying the configured mapping to the item to get back an array of
79
+ * data for each field in the feed.
80
+ */
81
+ public function testApplyMapping()
82
+ {
83
+ $orderAmt = 23.23;
84
+ $store = Mage::app()->getStore();
85
+ $fields = array('fieldA', 'fieldB');
86
+ // callback mapping to use
87
+ $mappings = array(
88
+ 'fieldA' => array(
89
+ 'class' => 'eems_affiliate/map_order', 'type' => 'helper',
90
+ 'method' => 'getOrderAmount', 'params' => array('key' => 'value'),
91
+ 'column_name' => 'OID'
92
+ ),
93
+ 'fieldB' => array('type' => 'disabled'),
94
+ );
95
+ $itemData = array($orderAmt);
96
+ // The type of this object will vary depending on feed type but will likely
97
+ // be a descendent of Varien_Object. It shouldn't matter much to the test
98
+ // as it should just get passed through to the callbacks.
99
+ $item = new Varien_Object();
100
+
101
+ // All callbacks setup to use this helper
102
+ $feedHelper = $this->getHelperMock(
103
+ 'eems_affiliate/map_order',
104
+ array('getOrderAmount')
105
+ );
106
+ $feedHelper->expects($this->once())
107
+ ->method('getOrderAmount')
108
+ ->with($this->identicalTo(array('key' => 'value', 'item' => $item, 'store' => $store)))
109
+ ->will($this->returnValue($orderAmt));
110
+ $this->replaceByMock('helper', 'eems_affiliate/map_order', $feedHelper);
111
+
112
+ $config = $this->getHelperMock('eems_affiliate/config', array('getCallbackMappings'));
113
+ $config->expects($this->any())
114
+ ->method('getCallbackMappings')
115
+ ->will($this->returnValue($mappings));
116
+ $this->replaceByMock('helper', 'eems_affiliate/config', $config);
117
+
118
+ $feed = $this->getModelMock(
119
+ 'eems_affiliate/feed_abstract',
120
+ array('_getFeedFields'),
121
+ true,
122
+ array(array('store' => $store))
123
+ );
124
+ // The _getFeedFields method will be defined for each type of feed and should
125
+ // return array of mapped fields to include.
126
+ $feed->expects($this->any())
127
+ ->method('_getFeedFields')
128
+ ->will($this->returnValue($fields));
129
+
130
+ $this->assertSame(
131
+ $itemData,
132
+ EcomDev_Utils_Reflection::invokeRestrictedMethod($feed, '_applyMapping', array($item))
133
+ );
134
+ }
135
+ /**
136
+ * Test that when a configured method does not exist on the specified class,
137
+ * an exception is thrown.
138
+ */
139
+ public function testInvokeCallbackFailures()
140
+ {
141
+ $callbackConfig = array('class' => 'eems_affiliate', 'type' => 'helper', 'method' => 'getSomething');
142
+ $feed = $this->getModelMock(
143
+ 'eems_affiliate/feed_abstract',
144
+ array('_getCallbackInstance'),
145
+ true
146
+ );
147
+ // Sub an object that will certainly not have the configured method on it.
148
+ $feed->expects($this->once())
149
+ ->method('_getCallbackInstance')
150
+ ->with($this->identicalTo($callbackConfig))
151
+ ->will($this->returnValue(new StdClass));
152
+
153
+ $this->setExpectedException('EbayEnterprise_Affiliate_Exception_Configuration');
154
+ EcomDev_Utils_Reflection::invokeRestrictedMethod(
155
+ $feed,
156
+ '_invokeCallback',
157
+ array($callbackConfig, new Varien_Object())
158
+ );
159
+ }
160
+ /**
161
+ * Provide a sample callback configuration and whether the callback is
162
+ * expected to be deemed valid.
163
+ * @return array
164
+ */
165
+ public function provideCallbacksToValidate()
166
+ {
167
+ return array(
168
+ array(
169
+ array(),
170
+ false
171
+ ),
172
+ array(
173
+ array('type' => 'disabled'),
174
+ true
175
+ ),
176
+ array(
177
+ array('type' => 'disabled', 'class' => 'eems_affiliate'),
178
+ true
179
+ ),
180
+ array(
181
+ array('type' => 'model'),
182
+ false
183
+ ),
184
+ array(
185
+ array('type' => 'singleton', 'class' => 'eems_affiliate/feed_abstract'),
186
+ false
187
+ ),
188
+ array(
189
+ array('type' => 'helper', 'class' => 'eems_affiliate/map', 'method' => 'getOrderId'),
190
+ false
191
+ ),
192
+ array(
193
+ array('type' => 'helper', 'class' => 'eems_affiliate/map', 'method' => 'getOrderId', 'column_name' => 'OID'),
194
+ true
195
+ ),
196
+ );
197
+ }
198
+ /**
199
+ * Test checking for a callback configuration to be valid. When the is valid
200
+ * param indicates the configuration is invalid, an exception should be
201
+ * thrown. Otherwise, the method should simply reurun self.
202
+ * @param array $config Array of config data to validate
203
+ * @param boolean $isValid Is the config data valid
204
+ * @dataProvider provideCallbacksToValidate
205
+ */
206
+ public function testValidateCallbackConfig($config, $isValid)
207
+ {
208
+ $feed = $this->getModelMock(
209
+ 'eems_affiliate/feed_abstract',
210
+ array(),
211
+ true
212
+ );
213
+
214
+ if (!$isValid) {
215
+ $this->setExpectedException('EbayEnterprise_Affiliate_Exception_Configuration');
216
+ }
217
+
218
+ $result = EcomDev_Utils_Reflection::invokeRestrictedMethod(
219
+ $feed,
220
+ '_validateCallbackConfig',
221
+ array($config)
222
+ );
223
+ if ($isValid) {
224
+ $this->assertSame($result, $feed);
225
+ }
226
+ }
227
+ /**
228
+ * Test getting column headers based on the configured mappings for the feed.
229
+ */
230
+ public function testGetHeaders()
231
+ {
232
+ $fields = array('program_id', 'order_id');
233
+ $mapping = array(
234
+ 'program_id' => array('class' => 'some/class', 'method' => 'getProgramId', 'column_name' => 'PID'),
235
+ 'order_id' => array('class' => 'some/class', 'method' => 'getOrderId', 'column_name' => 'OID'),
236
+ );
237
+
238
+ $config = $this->getHelperMock('eems_affiliate/config', array('getCallbackMappings'));
239
+ $config->expects($this->any())
240
+ ->method('getCallbackMappings')
241
+ ->will($this->returnValue($mapping));
242
+ $this->replaceByMock('helper', 'eems_affiliate/config', $config);
243
+
244
+ $feed = $this->getModelMock(
245
+ 'eems_affiliate/feed_abstract',
246
+ array('_getFeedFields'),
247
+ true
248
+ );
249
+ $feed->expects($this->once())
250
+ ->method('_getFeedFields')
251
+ ->will($this->returnValue($fields));
252
+
253
+ $this->assertSame(
254
+ // keys don't matter, so make sure to compare just values to values
255
+ array('PID', 'OID'),
256
+ array_values(EcomDev_Utils_Reflection::invokeRestrictedMethod($feed, '_getHeaders'))
257
+ );
258
+ }
259
+ /**
260
+ * Test generating the full path to the file. Should consist of Magento's
261
+ * base dir, the configured export feed path, and the name of the file.
262
+ */
263
+ public function testGenerateFilePath()
264
+ {
265
+ $format = 'file_name.csv';
266
+ $configuredPath = 'var/feed/export';
267
+ $configHelper = $this->getHelperMock(
268
+ 'eems_affiliate/config',
269
+ array('getExportFilePath', 'getProgramId')
270
+ );
271
+ $configHelper->expects($this->any())
272
+ ->method('getExportFilePath')
273
+ ->will($this->returnValue($configuredPath));
274
+ $configHelper->expects($this->any())
275
+ ->method('getProgramId')
276
+ ->will($this->returnValue('PROGRAM_ID'));
277
+ $this->replaceByMock('helper', 'eems_affiliate/config', $configHelper);
278
+
279
+ $feed = $this->getModelMock(
280
+ 'eems_affiliate/feed_abstract',
281
+ array('_getFileName'),
282
+ true
283
+ );
284
+ $feed->expects($this->any())
285
+ ->method('_getFileName')
286
+ ->will($this->returnValue($format));
287
+
288
+ $this->assertSame(
289
+ Mage::getBaseDir() . DS . 'var/feed/export' . DS . $format,
290
+ EcomDev_Utils_Reflection::invokeRestrictedMethod($feed, '_generateFilePath')
291
+ );
292
+ }
293
+ }
app/code/community/EbayEnterprise/Affiliate/Test/Model/Feed/Order/AbstractTest.php CHANGED
@@ -1,60 +1,60 @@
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
-
19
- class EbayEnterprise_Affiliate_Test_Model_Feed_Order_AbstractTest extends EcomDev_PHPUnit_Test_Case
20
- {
21
- /**
22
- * Test generating the file name using the
23
- */
24
- public function testGetFileName()
25
- {
26
- $format = '%s_corrected_orders_%s.csv';
27
- $programId = 'PROGRAM_ID';
28
- $time = 1397829577;
29
- $formattedTime = date('YmdHis', $time);
30
- $fileName = "{$programId}_corrected_orders_{$formattedTime}.csv";
31
-
32
- // get the default store to be used as context for config getting
33
- $store = Mage::app()->getStore();
34
- // get the order feed instance with the expected store and start time injected
35
- $feed = $this->getModelMock(
36
- 'eems_affiliate/feed_order_itemized',
37
- array('_getFileNameFormat'),
38
- true,
39
- array(array('store' => $store, 'start_time' => $time))
40
- );
41
- $feed->expects($this->any())
42
- ->method('_getFileNameFormat')
43
- ->will($this->returnValue($format));
44
-
45
- $config = $this->getHelperMock('eems_affiliate/config', array('getProgramId'));
46
- // Will have different program ids per feed so store context definitely
47
- // matters when getting this value.
48
- $config->expects($this->any())
49
- ->method('getProgramId')
50
- ->with($this->identicalTo($store))
51
- ->will($this->returnValue($programId));
52
- $this->replaceByMock('helper', 'eems_affiliate/config', $config);
53
-
54
- $generated = EcomDev_Utils_Reflection::invokeRestrictedMethod($feed, '_getFileName');
55
- $this->assertSame(
56
- $fileName,
57
- $generated
58
- );
59
- }
60
- }
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
+
19
+ class EbayEnterprise_Affiliate_Test_Model_Feed_Order_AbstractTest extends EcomDev_PHPUnit_Test_Case
20
+ {
21
+ /**
22
+ * Test generating the file name using the
23
+ */
24
+ public function testGetFileName()
25
+ {
26
+ $format = '%s_corrected_orders_%s.csv';
27
+ $programId = 'PROGRAM_ID';
28
+ $time = 1397829577;
29
+ $formattedTime = date('YmdHis', $time);
30
+ $fileName = "{$programId}_corrected_orders_{$formattedTime}.csv";
31
+
32
+ // get the default store to be used as context for config getting
33
+ $store = Mage::app()->getStore();
34
+ // get the order feed instance with the expected store and start time injected
35
+ $feed = $this->getModelMock(
36
+ 'eems_affiliate/feed_order_itemized',
37
+ array('_getFileNameFormat'),
38
+ true,
39
+ array(array('store' => $store, 'start_time' => $time))
40
+ );
41
+ $feed->expects($this->any())
42
+ ->method('_getFileNameFormat')
43
+ ->will($this->returnValue($format));
44
+
45
+ $config = $this->getHelperMock('eems_affiliate/config', array('getProgramId'));
46
+ // Will have different program ids per feed so store context definitely
47
+ // matters when getting this value.
48
+ $config->expects($this->any())
49
+ ->method('getProgramId')
50
+ ->with($this->identicalTo($store))
51
+ ->will($this->returnValue($programId));
52
+ $this->replaceByMock('helper', 'eems_affiliate/config', $config);
53
+
54
+ $generated = EcomDev_Utils_Reflection::invokeRestrictedMethod($feed, '_getFileName');
55
+ $this->assertSame(
56
+ $fileName,
57
+ $generated
58
+ );
59
+ }
60
+ }
app/code/community/EbayEnterprise/Affiliate/Test/Model/Feed/Order/BasicTest.php CHANGED
@@ -1,40 +1,40 @@
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
-
19
- class EbayEnterprise_Affiliate_Test_Model_Feed_Order_BasicTest extends EcomDev_PHPUnit_Test_Case
20
- {
21
- /**
22
- * Test getting the fields to include in the feed. Should be pulling the
23
- * comma-separated list of fields from config.xml and splitting it to produce
24
- * an array of fields.
25
- * @return array
26
- */
27
- public function testFeedFields()
28
- {
29
- $config = $this->getHelperMock('eems_affiliate/config', array('getBasicOrderFeedFields'));
30
- $config->expects($this->any())
31
- ->method('getBasicOrderFeedFields')
32
- ->will($this->returnValue('one,two,three'));
33
- $this->replaceByMock('helper', 'eems_affiliate/config', $config);
34
- $feed = Mage::getModel('eems_affiliate/feed_order_basic');
35
- $this->assertSame(
36
- array('one', 'two', 'three'),
37
- EcomDev_Utils_Reflection::invokeRestrictedMethod($feed, '_getFeedFields')
38
- );
39
- }
40
- }
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
+
19
+ class EbayEnterprise_Affiliate_Test_Model_Feed_Order_BasicTest extends EcomDev_PHPUnit_Test_Case
20
+ {
21
+ /**
22
+ * Test getting the fields to include in the feed. Should be pulling the
23
+ * comma-separated list of fields from config.xml and splitting it to produce
24
+ * an array of fields.
25
+ * @return array
26
+ */
27
+ public function testFeedFields()
28
+ {
29
+ $config = $this->getHelperMock('eems_affiliate/config', array('getBasicOrderFeedFields'));
30
+ $config->expects($this->any())
31
+ ->method('getBasicOrderFeedFields')
32
+ ->will($this->returnValue('one,two,three'));
33
+ $this->replaceByMock('helper', 'eems_affiliate/config', $config);
34
+ $feed = Mage::getModel('eems_affiliate/feed_order_basic');
35
+ $this->assertSame(
36
+ array('one', 'two', 'three'),
37
+ EcomDev_Utils_Reflection::invokeRestrictedMethod($feed, '_getFeedFields')
38
+ );
39
+ }
40
+ }
app/code/community/EbayEnterprise/Affiliate/Test/Model/Feed/Order/ItemizedTest.php CHANGED
@@ -1,40 +1,40 @@
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
-
19
- class EbayEnterprise_Affiliate_Test_Model_Feed_Order_ItemizedTest extends EcomDev_PHPUnit_Test_Case
20
- {
21
- /**
22
- * Test getting the fields to include in the feed. Should be pulling the
23
- * comma-separated list of fields from config.xml and splitting it to produce
24
- * an array of fields.
25
- * @return array
26
- */
27
- public function testFeedFields()
28
- {
29
- $config = $this->getHelperMock('eems_affiliate/config', array('getItemizedOrderFeedFields'));
30
- $config->expects($this->any())
31
- ->method('getItemizedOrderFeedFields')
32
- ->will($this->returnValue('one,two,three'));
33
- $this->replaceByMock('helper', 'eems_affiliate/config', $config);
34
- $feed = Mage::getModel('eems_affiliate/feed_order_itemized');
35
- $this->assertSame(
36
- array('one', 'two', 'three'),
37
- EcomDev_Utils_Reflection::invokeRestrictedMethod($feed, '_getFeedFields')
38
- );
39
- }
40
- }
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
+
19
+ class EbayEnterprise_Affiliate_Test_Model_Feed_Order_ItemizedTest extends EcomDev_PHPUnit_Test_Case
20
+ {
21
+ /**
22
+ * Test getting the fields to include in the feed. Should be pulling the
23
+ * comma-separated list of fields from config.xml and splitting it to produce
24
+ * an array of fields.
25
+ * @return array
26
+ */
27
+ public function testFeedFields()
28
+ {
29
+ $config = $this->getHelperMock('eems_affiliate/config', array('getItemizedOrderFeedFields'));
30
+ $config->expects($this->any())
31
+ ->method('getItemizedOrderFeedFields')
32
+ ->will($this->returnValue('one,two,three'));
33
+ $this->replaceByMock('helper', 'eems_affiliate/config', $config);
34
+ $feed = Mage::getModel('eems_affiliate/feed_order_itemized');
35
+ $this->assertSame(
36
+ array('one', 'two', 'three'),
37
+ EcomDev_Utils_Reflection::invokeRestrictedMethod($feed, '_getFeedFields')
38
+ );
39
+ }
40
+ }
app/code/community/EbayEnterprise/Affiliate/Test/Model/Feed/ProductTest.php CHANGED
@@ -1,169 +1,169 @@
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
-
19
- class EbayEnterprise_Affiliate_Test_Model_Feed_ProductTest extends EcomDev_PHPUnit_Test_Case
20
- {
21
- /**
22
- * Test that EbayEnterprise_Affiliate_Model_Feed_Product::_getItems will return
23
- * a Mage_Catalog_Model_Resource_Product_Collection
24
- */
25
- public function testGetItems()
26
- {
27
- $store = Mage::getModel('core/store');
28
- $collection = $this->getResourceModelMockBuilder('catalog/product_collection')
29
- ->disableOriginalConstructor()
30
- ->setMethods(array('setStore', 'addAttributeToSelect', 'addStoreFilter', 'addFieldToFilter'))
31
- ->getMock();
32
- $collection->expects($this->once())
33
- ->method('setStore')
34
- ->with($this->identicalTo($store))
35
- ->will($this->returnSelf());
36
- $collection->expects($this->once())
37
- ->method('addAttributeToSelect')
38
- ->with($this->identicalTo(array('*')))
39
- ->will($this->returnSelf());
40
- $collection->expects($this->once())
41
- ->method('addStoreFilter')
42
- ->with($this->identicalTo($store))
43
- ->will($this->returnSelf());
44
- $collection->expects($this->once())
45
- ->method('addFieldToFilter')
46
- ->with($this->identicalTo('status'), $this->identicalTo(Mage_Catalog_Model_Product_Status::STATUS_ENABLED))
47
- ->will($this->returnSelf());
48
- $this->replaceByMock('resource_model', 'catalog/product_collection', $collection);
49
-
50
- $feedProduct = Mage::getModel('eems_affiliate/feed_product', array('store' => $store));
51
-
52
- $this->assertSame($collection, EcomDev_Utils_Reflection::invokeRestrictedMethod(
53
- $feedProduct,
54
- '_getItems',
55
- array()
56
- ));
57
- }
58
- /**
59
- * Test that EbayEnterprise_Affiliate_Model_Feed_Product::_getFeedFields will
60
- * retrieve a list of field from the configuration and explode it into an array
61
- * of fields
62
- */
63
- public function testGetFeedFields()
64
- {
65
- $maps = array(
66
- 'field_1' => array('column_name' => 'field_1'),
67
- 'field_2' => array('column_name' => 'field_2'),
68
- 'field_3' => array('column_name' => 'field_3')
69
- );
70
- $fields = array('field_1' => 'key 1', 'field_2' => 'key 2', 'field_3' => 'key 3');
71
- $configHelper = $this->getHelperMock('eems_affiliate/config', array(
72
- 'getProductFeedFields', 'getCallbackMappings'
73
- ));
74
- $result = array_keys($fields);
75
-
76
- $configHelper->expects($this->once())
77
- ->method('getProductFeedFields')
78
- ->will($this->returnValue($fields));
79
- $configHelper->expects($this->once())
80
- ->method('getCallbackMappings')
81
- ->will($this->returnValue($maps));
82
- $this->replaceByMock('helper', 'eems_affiliate/config', $configHelper);
83
-
84
- $feedProduct = Mage::getModel('eems_affiliate/feed_product');
85
-
86
- $this->assertSame($result, EcomDev_Utils_Reflection::invokeRestrictedMethod(
87
- $feedProduct,
88
- '_getFeedFields',
89
- array()
90
- ));
91
- }
92
- /**
93
- * Test that EbayEnterprise_Affiliate_Model_Feed_Product::_getFileName will return
94
- * a string representing a feed file name
95
- */
96
- public function testFileName()
97
- {
98
- $filenameFormat = '%s_Some_Feed.csv';
99
- $programId = 'P12';
100
- $result = sprintf($filenameFormat, $programId);
101
-
102
- $store = Mage::getModel('core/store');
103
- $configHelper = $this->getHelperMock('eems_affiliate/config', array(
104
- 'getProductFeedFilenameFormat', 'getProgramId'
105
- ));
106
- $configHelper->expects($this->once())
107
- ->method('getProductFeedFilenameFormat')
108
- ->will($this->returnValue($filenameFormat));
109
- $configHelper->expects($this->once())
110
- ->method('getProgramId')
111
- ->with($this->identicalTo($store))
112
- ->will($this->returnValue($programId));
113
- $this->replaceByMock('helper', 'eems_affiliate/config', $configHelper);
114
-
115
- $feedProduct = Mage::getModel('eems_affiliate/feed_product', array('store' => $store));
116
-
117
- $this->assertSame($result, EcomDev_Utils_Reflection::invokeRestrictedMethod(
118
- $feedProduct,
119
- '_getFileName',
120
- array()
121
- ));
122
- }
123
- /**
124
- * Test that EbayEnterprise_Affiliate_Model_Feed_Product::_applyMapping will
125
- * be invoked with a Mage_Catalog_Model_Product object passed as its parameter
126
- * and it will generate an array of callback result from configuration
127
- */
128
- public function testApplyMapping()
129
- {
130
- $result = 'some value';
131
- $fields = array('field_1' => 'code_1');
132
- $mappings = array(
133
- 'field_1' => array(
134
- 'params' => array(),
135
- 'column_name' => 'field_1',
136
- 'type' => 'helper'
137
- ),
138
- );
139
- $callback = $mappings['field_1'];
140
- $callback['params']['key'] = $fields['field_1'];
141
-
142
- $item = Mage::getModel('catalog/product');
143
-
144
- $callbackResult = array($result);
145
-
146
- $configHelper = $this->getHelperMock('eems_affiliate/config', array(
147
- 'getCallbackMappings', 'getProductFeedFields'
148
- ));
149
- $configHelper->expects($this->any())
150
- ->method('getCallbackMappings')
151
- ->will($this->returnValue($mappings));
152
- $configHelper->expects($this->any())
153
- ->method('getProductFeedFields')
154
- ->will($this->returnValue($fields));
155
- $this->replaceByMock('helper', 'eems_affiliate/config', $configHelper);
156
-
157
- $feedProduct = $this->getModelMock('eems_affiliate/feed_product', array('_invokeCallBack'));
158
- $feedProduct->expects($this->once())
159
- ->method('_invokeCallBack')
160
- ->with($this->identicalTo($callback), $this->identicalTo($item))
161
- ->will($this->returnValue($result));
162
-
163
- $this->assertSame($callbackResult, EcomDev_Utils_Reflection::invokeRestrictedMethod(
164
- $feedProduct,
165
- '_applyMapping',
166
- array($item)
167
- ));
168
- }
169
- }
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
+
19
+ class EbayEnterprise_Affiliate_Test_Model_Feed_ProductTest extends EcomDev_PHPUnit_Test_Case
20
+ {
21
+ /**
22
+ * Test that EbayEnterprise_Affiliate_Model_Feed_Product::_getItems will return
23
+ * a Mage_Catalog_Model_Resource_Product_Collection
24
+ */
25
+ public function testGetItems()
26
+ {
27
+ $store = Mage::getModel('core/store');
28
+ $collection = $this->getResourceModelMockBuilder('catalog/product_collection')
29
+ ->disableOriginalConstructor()
30
+ ->setMethods(array('setStore', 'addAttributeToSelect', 'addStoreFilter', 'addFieldToFilter'))
31
+ ->getMock();
32
+ $collection->expects($this->once())
33
+ ->method('setStore')
34
+ ->with($this->identicalTo($store))
35
+ ->will($this->returnSelf());
36
+ $collection->expects($this->once())
37
+ ->method('addAttributeToSelect')
38
+ ->with($this->identicalTo(array('*')))
39
+ ->will($this->returnSelf());
40
+ $collection->expects($this->once())
41
+ ->method('addStoreFilter')
42
+ ->with($this->identicalTo($store))
43
+ ->will($this->returnSelf());
44
+ $collection->expects($this->once())
45
+ ->method('addFieldToFilter')
46
+ ->with($this->identicalTo('status'), $this->identicalTo(Mage_Catalog_Model_Product_Status::STATUS_ENABLED))
47
+ ->will($this->returnSelf());
48
+ $this->replaceByMock('resource_model', 'catalog/product_collection', $collection);
49
+
50
+ $feedProduct = Mage::getModel('eems_affiliate/feed_product', array('store' => $store));
51
+
52
+ $this->assertSame($collection, EcomDev_Utils_Reflection::invokeRestrictedMethod(
53
+ $feedProduct,
54
+ '_getItems',
55
+ array()
56
+ ));
57
+ }
58
+ /**
59
+ * Test that EbayEnterprise_Affiliate_Model_Feed_Product::_getFeedFields will
60
+ * retrieve a list of field from the configuration and explode it into an array
61
+ * of fields
62
+ */
63
+ public function testGetFeedFields()
64
+ {
65
+ $maps = array(
66
+ 'field_1' => array('column_name' => 'field_1'),
67
+ 'field_2' => array('column_name' => 'field_2'),
68
+ 'field_3' => array('column_name' => 'field_3')
69
+ );
70
+ $fields = array('field_1' => 'key 1', 'field_2' => 'key 2', 'field_3' => 'key 3');
71
+ $configHelper = $this->getHelperMock('eems_affiliate/config', array(
72
+ 'getProductFeedFields', 'getCallbackMappings'
73
+ ));
74
+ $result = array_keys($fields);
75
+
76
+ $configHelper->expects($this->once())
77
+ ->method('getProductFeedFields')
78
+ ->will($this->returnValue($fields));
79
+ $configHelper->expects($this->once())
80
+ ->method('getCallbackMappings')
81
+ ->will($this->returnValue($maps));
82
+ $this->replaceByMock('helper', 'eems_affiliate/config', $configHelper);
83
+
84
+ $feedProduct = Mage::getModel('eems_affiliate/feed_product');
85
+
86
+ $this->assertSame($result, EcomDev_Utils_Reflection::invokeRestrictedMethod(
87
+ $feedProduct,
88
+ '_getFeedFields',
89
+ array()
90
+ ));
91
+ }
92
+ /**
93
+ * Test that EbayEnterprise_Affiliate_Model_Feed_Product::_getFileName will return
94
+ * a string representing a feed file name
95
+ */
96
+ public function testFileName()
97
+ {
98
+ $filenameFormat = '%s_Some_Feed.csv';
99
+ $programId = 'P12';
100
+ $result = sprintf($filenameFormat, $programId);
101
+
102
+ $store = Mage::getModel('core/store');
103
+ $configHelper = $this->getHelperMock('eems_affiliate/config', array(
104
+ 'getProductFeedFilenameFormat', 'getProgramId'
105
+ ));
106
+ $configHelper->expects($this->once())
107
+ ->method('getProductFeedFilenameFormat')
108
+ ->will($this->returnValue($filenameFormat));
109
+ $configHelper->expects($this->once())
110
+ ->method('getProgramId')
111
+ ->with($this->identicalTo($store))
112
+ ->will($this->returnValue($programId));
113
+ $this->replaceByMock('helper', 'eems_affiliate/config', $configHelper);
114
+
115
+ $feedProduct = Mage::getModel('eems_affiliate/feed_product', array('store' => $store));
116
+
117
+ $this->assertSame($result, EcomDev_Utils_Reflection::invokeRestrictedMethod(
118
+ $feedProduct,
119
+ '_getFileName',
120
+ array()
121
+ ));
122
+ }
123
+ /**
124
+ * Test that EbayEnterprise_Affiliate_Model_Feed_Product::_applyMapping will
125
+ * be invoked with a Mage_Catalog_Model_Product object passed as its parameter
126
+ * and it will generate an array of callback result from configuration
127
+ */
128
+ public function testApplyMapping()
129
+ {
130
+ $result = 'some value';
131
+ $fields = array('field_1' => 'code_1');
132
+ $mappings = array(
133
+ 'field_1' => array(
134
+ 'params' => array(),
135
+ 'column_name' => 'field_1',
136
+ 'type' => 'helper'
137
+ ),
138
+ );
139
+ $callback = $mappings['field_1'];
140
+ $callback['params']['key'] = $fields['field_1'];
141
+
142
+ $item = Mage::getModel('catalog/product');
143
+
144
+ $callbackResult = array($result);
145
+
146
+ $configHelper = $this->getHelperMock('eems_affiliate/config', array(
147
+ 'getCallbackMappings', 'getProductFeedFields'
148
+ ));
149
+ $configHelper->expects($this->any())
150
+ ->method('getCallbackMappings')
151
+ ->will($this->returnValue($mappings));
152
+ $configHelper->expects($this->any())
153
+ ->method('getProductFeedFields')
154
+ ->will($this->returnValue($fields));
155
+ $this->replaceByMock('helper', 'eems_affiliate/config', $configHelper);
156
+
157
+ $feedProduct = $this->getModelMock('eems_affiliate/feed_product', array('_invokeCallBack'));
158
+ $feedProduct->expects($this->once())
159
+ ->method('_invokeCallBack')
160
+ ->with($this->identicalTo($callback), $this->identicalTo($item))
161
+ ->will($this->returnValue($result));
162
+
163
+ $this->assertSame($callbackResult, EcomDev_Utils_Reflection::invokeRestrictedMethod(
164
+ $feedProduct,
165
+ '_applyMapping',
166
+ array($item)
167
+ ));
168
+ }
169
+ }
app/code/community/EbayEnterprise/Affiliate/Test/Model/ObserverTest.php CHANGED
@@ -1,62 +1,62 @@
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_Test_Model_ObserverTest extends EcomDev_PHPUnit_Test_Case
19
- {
20
- /**
21
- * Test that EbayEnterprise_Affiliate_Model_Observer::createProductFeed
22
- * will be invoked and expected the method
23
- * EbayEnterprise_Affiliate_Model_Observer::getWebsitesDefaultStoreviews
24
- * to be called and returned a known array of program keys map to default
25
- * website store views, then expects the method
26
- * EbayEnterprise_Affiliate_Model_Product::generateFeed to be invoked per
27
- * default program id and store views
28
- */
29
- public function testCreateProductFeed()
30
- {
31
- $websitesDefaultStoreViews = array(
32
- 'P1' => Mage::getModel('core/store', array('name' => 'store view 1')),
33
- 'P2' => Mage::getModel('core/store', array('name' => 'store view 2'))
34
- );
35
- $programIds = array_keys($websitesDefaultStoreViews);
36
-
37
- $helper = $this->getHelperMock('eems_affiliate/data', array(
38
- 'getAllProgramIds', 'getStoreForProgramId'
39
- ));
40
- $helper->expects($this->once())
41
- ->method('getAllProgramIds')
42
- ->will($this->returnValue($programIds));
43
- $helper->expects($this->exactly(2))
44
- ->method('getStoreForProgramId')
45
- ->will($this->returnValueMap(array(
46
- array($programIds[0], $websitesDefaultStoreViews[$programIds[0]]),
47
- array($programIds[1], $websitesDefaultStoreViews[$programIds[1]])
48
- )));
49
- $this->replaceByMock('helper', 'eems_affiliate', $helper);
50
-
51
- $productFeed = $this->getModelMockBuilder('eems_affiliate/feed_product')
52
- ->disableOriginalConstructor()
53
- ->setMethods(array('generateFeed'))
54
- ->getMock();
55
- $productFeed->expects($this->exactly(2))
56
- ->method('generateFeed')
57
- ->will($this->returnSelf());
58
- $this->replaceByMock('model', 'eems_affiliate/feed_product', $productFeed);
59
-
60
- Mage::getModel('eems_affiliate/observer')->createProductFeed();
61
- }
62
- }
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_Test_Model_ObserverTest extends EcomDev_PHPUnit_Test_Case
19
+ {
20
+ /**
21
+ * Test that EbayEnterprise_Affiliate_Model_Observer::createProductFeed
22
+ * will be invoked and expected the method
23
+ * EbayEnterprise_Affiliate_Model_Observer::getWebsitesDefaultStoreviews
24
+ * to be called and returned a known array of program keys map to default
25
+ * website store views, then expects the method
26
+ * EbayEnterprise_Affiliate_Model_Product::generateFeed to be invoked per
27
+ * default program id and store views
28
+ */
29
+ public function testCreateProductFeed()
30
+ {
31
+ $websitesDefaultStoreViews = array(
32
+ 'P1' => Mage::getModel('core/store', array('name' => 'store view 1')),
33
+ 'P2' => Mage::getModel('core/store', array('name' => 'store view 2'))
34
+ );
35
+ $programIds = array_keys($websitesDefaultStoreViews);
36
+
37
+ $helper = $this->getHelperMock('eems_affiliate/data', array(
38
+ 'getAllProgramIds', 'getStoreForProgramId'
39
+ ));
40
+ $helper->expects($this->once())
41
+ ->method('getAllProgramIds')
42
+ ->will($this->returnValue($programIds));
43
+ $helper->expects($this->exactly(2))
44
+ ->method('getStoreForProgramId')
45
+ ->will($this->returnValueMap(array(
46
+ array($programIds[0], $websitesDefaultStoreViews[$programIds[0]]),
47
+ array($programIds[1], $websitesDefaultStoreViews[$programIds[1]])
48
+ )));
49
+ $this->replaceByMock('helper', 'eems_affiliate', $helper);
50
+
51
+ $productFeed = $this->getModelMockBuilder('eems_affiliate/feed_product')
52
+ ->disableOriginalConstructor()
53
+ ->setMethods(array('generateFeed'))
54
+ ->getMock();
55
+ $productFeed->expects($this->exactly(2))
56
+ ->method('generateFeed')
57
+ ->will($this->returnSelf());
58
+ $this->replaceByMock('model', 'eems_affiliate/feed_product', $productFeed);
59
+
60
+ Mage::getModel('eems_affiliate/observer')->createProductFeed();
61
+ }
62
+ }
app/code/community/EbayEnterprise/Affiliate/controllers/Adminhtml/EemsAffiliateController.php CHANGED
@@ -1,85 +1,85 @@
1
- <?php
2
-
3
- class EbayEnterprise_Affiliate_Adminhtml_EemsAffiliateController extends Mage_Adminhtml_Controller_Action
4
- {
5
- const AFFILIATE_ID = 'commissioning_category';
6
- const DEFAULT_SCONFIG_FILENAME = 'cache.cfg';
7
- const PACKAGE_CHANNEL = 'community';
8
- const PACKAGE_NAME = 'eBay_Enterprise_Affiliate_Extension';
9
-
10
- protected $_config;
11
- protected $_sconfig;
12
-
13
- public function uninstallAction()
14
- {
15
- // Remove commissioning category
16
- $setup = new Mage_Eav_Model_Entity_Setup('eems_affiliate_setup');
17
- $setup->startSetup();
18
-
19
- $objCatalogEavSetup = Mage::getResourceModel('catalog/eav_mysql4_setup', 'core_setup');
20
-
21
- Mage::log(array('uninstallAction', get_class($objCatalogEavSetup)));
22
- $attributeExists = (bool) $objCatalogEavSetup->getAttributeId(Mage_Catalog_Model_Product::ENTITY, self::AFFILIATE_ID);
23
- if ($attributeExists) {
24
- $setup->removeAttribute(Mage_Catalog_Model_Product::ENTITY, self::AFFILIATE_ID);
25
- }
26
-
27
- $setup->endSetup();
28
-
29
- // Uninstall extension
30
- Mage_Connect_Command::registerCommands(); // Must run or next line will fail
31
- $installer = Mage_Connect_Command::getInstance('uninstall');
32
- $installer->setFrontendObject(Mage_Connect_Frontend::getInstance('CLI'));
33
- $installer->setSconfig($this->getSingleConfig());
34
-
35
- $installer->doUninstall('uninstall', array(), array(self::PACKAGE_CHANNEL, self::PACKAGE_NAME));
36
-
37
- // Clear cache
38
- Mage::app()->cleanCache();
39
-
40
- // Send message to admin
41
- Mage::getSingleton('core/session')->addSuccess('Package ' . self::PACKAGE_CHANNEL . '/' . self::PACKAGE_NAME . ' successfully deleted');
42
- }
43
-
44
- /**
45
- * Retrieve object of config and set it to Mage_Connect_Command
46
- *
47
- * @return Mage_Connect_Config
48
- */
49
- public function getConfig()
50
- {
51
- if (!$this->_config) {
52
- $this->_config = new Mage_Connect_Config();
53
- $ftp=$this->_config->__get('remote_config');
54
- if(!empty($ftp)){
55
- $packager = new Mage_Connect_Packager();
56
- list($cache, $config, $ftpObj) = $packager->getRemoteConf($ftp);
57
- $this->_config=$config;
58
- $this->_sconfig=$cache;
59
- }
60
- $this->_config->magento_root = Mage::getBaseDir('base');
61
- Mage_Connect_Command::setConfigObject($this->_config);
62
- }
63
- return $this->_config;
64
- }
65
-
66
- /**
67
- * Retrieve object of single config and set it to Mage_Connect_Command
68
- *
69
- * @param bool $reload
70
- * @return Mage_Connect_Singleconfig
71
- */
72
- public function getSingleConfig($reload = false)
73
- {
74
- if(!$this->_sconfig || $reload) {
75
- $this->_sconfig = new Mage_Connect_Singleconfig(
76
- $this->getConfig()->magento_root . DIRECTORY_SEPARATOR
77
- . $this->getConfig()->downloader_path . DIRECTORY_SEPARATOR
78
- . self::DEFAULT_SCONFIG_FILENAME
79
- );
80
- }
81
- Mage_Connect_Command::setSconfig($this->_sconfig);
82
- return $this->_sconfig;
83
-
84
- }
85
- }
1
+ <?php
2
+
3
+ class EbayEnterprise_Affiliate_Adminhtml_EemsAffiliateController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+ const AFFILIATE_ID = 'commissioning_category';
6
+ const DEFAULT_SCONFIG_FILENAME = 'cache.cfg';
7
+ const PACKAGE_CHANNEL = 'community';
8
+ const PACKAGE_NAME = 'eBay_Enterprise_Affiliate_Extension';
9
+
10
+ protected $_config;
11
+ protected $_sconfig;
12
+
13
+ public function uninstallAction()
14
+ {
15
+ // Remove commissioning category
16
+ $setup = new Mage_Eav_Model_Entity_Setup('eems_affiliate_setup');
17
+ $setup->startSetup();
18
+
19
+ $objCatalogEavSetup = Mage::getResourceModel('catalog/eav_mysql4_setup', 'core_setup');
20
+
21
+ Mage::log(array('uninstallAction', get_class($objCatalogEavSetup)));
22
+ $attributeExists = (bool) $objCatalogEavSetup->getAttributeId(Mage_Catalog_Model_Product::ENTITY, self::AFFILIATE_ID);
23
+ if ($attributeExists) {
24
+ $setup->removeAttribute(Mage_Catalog_Model_Product::ENTITY, self::AFFILIATE_ID);
25
+ }
26
+
27
+ $setup->endSetup();
28
+
29
+ // Uninstall extension
30
+ Mage_Connect_Command::registerCommands(); // Must run or next line will fail
31
+ $installer = Mage_Connect_Command::getInstance('uninstall');
32
+ $installer->setFrontendObject(Mage_Connect_Frontend::getInstance('CLI'));
33
+ $installer->setSconfig($this->getSingleConfig());
34
+
35
+ $installer->doUninstall('uninstall', array(), array(self::PACKAGE_CHANNEL, self::PACKAGE_NAME));
36
+
37
+ // Clear cache
38
+ Mage::app()->cleanCache();
39
+
40
+ // Send message to admin
41
+ Mage::getSingleton('core/session')->addSuccess('Package ' . self::PACKAGE_CHANNEL . '/' . self::PACKAGE_NAME . ' successfully deleted');
42
+ }
43
+
44
+ /**
45
+ * Retrieve object of config and set it to Mage_Connect_Command
46
+ *
47
+ * @return Mage_Connect_Config
48
+ */
49
+ public function getConfig()
50
+ {
51
+ if (!$this->_config) {
52
+ $this->_config = new Mage_Connect_Config();
53
+ $ftp=$this->_config->__get('remote_config');
54
+ if(!empty($ftp)){
55
+ $packager = new Mage_Connect_Packager();
56
+ list($cache, $config, $ftpObj) = $packager->getRemoteConf($ftp);
57
+ $this->_config=$config;
58
+ $this->_sconfig=$cache;
59
+ }
60
+ $this->_config->magento_root = Mage::getBaseDir('base');
61
+ Mage_Connect_Command::setConfigObject($this->_config);
62
+ }
63
+ return $this->_config;
64
+ }
65
+
66
+ /**
67
+ * Retrieve object of single config and set it to Mage_Connect_Command
68
+ *
69
+ * @param bool $reload
70
+ * @return Mage_Connect_Singleconfig
71
+ */
72
+ public function getSingleConfig($reload = false)
73
+ {
74
+ if(!$this->_sconfig || $reload) {
75
+ $this->_sconfig = new Mage_Connect_Singleconfig(
76
+ $this->getConfig()->magento_root . DIRECTORY_SEPARATOR
77
+ . $this->getConfig()->downloader_path . DIRECTORY_SEPARATOR
78
+ . self::DEFAULT_SCONFIG_FILENAME
79
+ );
80
+ }
81
+ Mage_Connect_Command::setSconfig($this->_sconfig);
82
+ return $this->_sconfig;
83
+
84
+ }
85
+ }
app/code/community/EbayEnterprise/Affiliate/etc/adminhtml.xml CHANGED
@@ -1,37 +1,37 @@
1
- <?xml version="1.0" encoding="utf-8"?>
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
- <config>
17
- <acl>
18
- <resources>
19
- <admin>
20
- <children>
21
- <system>
22
- <children>
23
- <config>
24
- <children>
25
- <marketing_solutions translate="title">
26
- <title>Marketing Solutions</title>
27
- <sort_order>20</sort_order>
28
- </marketing_solutions>
29
- </children>
30
- </config>
31
- </children>
32
- </system>
33
- </children>
34
- </admin>
35
- </resources>
36
- </acl>
37
- </config>
1
+ <?xml version="1.0" encoding="utf-8"?>
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
+ <config>
17
+ <acl>
18
+ <resources>
19
+ <admin>
20
+ <children>
21
+ <system>
22
+ <children>
23
+ <config>
24
+ <children>
25
+ <marketing_solutions translate="title">
26
+ <title>Marketing Solutions</title>
27
+ <sort_order>20</sort_order>
28
+ </marketing_solutions>
29
+ </children>
30
+ </config>
31
+ </children>
32
+ </system>
33
+ </children>
34
+ </admin>
35
+ </resources>
36
+ </acl>
37
+ </config>
app/code/community/EbayEnterprise/Affiliate/etc/config.xml CHANGED
@@ -1,1041 +1,1041 @@
1
- <?xml version="1.0" encoding="utf-8"?>
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
- <config>
17
- <modules>
18
- <EbayEnterprise_Affiliate>
19
- <version>1.2.1.0</version>
20
- </EbayEnterprise_Affiliate>
21
- </modules>
22
- <global>
23
- <models>
24
- <eems_affiliate>
25
- <class>EbayEnterprise_Affiliate_Model</class>
26
- </eems_affiliate>
27
- </models>
28
- <helpers>
29
- <eems_affiliate>
30
- <class>EbayEnterprise_Affiliate_Helper</class>
31
- </eems_affiliate>
32
- </helpers>
33
- <blocks>
34
- <eems_affiliate>
35
- <class>EbayEnterprise_Affiliate_Block</class>
36
- </eems_affiliate>
37
- </blocks>
38
- <resources>
39
- <eems_affiliate_setup>
40
- <setup>
41
- <module>EbayEnterprise_Affiliate</module>
42
- <class>Mage_Core_Model_Resource_Setup</class>
43
- </setup>
44
- </eems_affiliate_setup>
45
- </resources>
46
- </global>
47
- <crontab>
48
- <jobs>
49
- <eems_affiliate_generate_product_feed>
50
- <schedule>
51
- <cron_expr>0 3 * * *</cron_expr>
52
- </schedule>
53
- <run>
54
- <model>eems_affiliate/observer::createProductFeed</model>
55
- </run>
56
- </eems_affiliate_generate_product_feed>
57
- <eems_affiliate_generate_corrected_order_feed>
58
- <schedule>
59
- <cron_expr>0 3 * * *</cron_expr>
60
- </schedule>
61
- <run>
62
- <model>eems_affiliate/observer::createCorrectedOrdersFeed</model>
63
- </run>
64
- </eems_affiliate_generate_corrected_order_feed>
65
- </jobs>
66
- </crontab>
67
- <default>
68
- <marketing_solutions>
69
- <eems_affiliate>
70
- <active>0</active>
71
- <js_files>eems_affiliate/cookie.js</js_files>
72
- <!-- use comma to add more js files-->
73
- <beacon_url>https://t.pepperjamnetwork.com/track</beacon_url>
74
- <export_path>var/export/eems_affiliate/</export_path>
75
- <order_type>itemized</order_type>
76
- <program_id/>
77
- <transaction_type>1</transaction_type>
78
- <conditional_pixel_enabled>0</conditional_pixel_enabled>
79
- <source_key_name>eean</source_key_name>
80
- <product_feed_enabled>1</product_feed_enabled>
81
- <order_feed_enabled>1</order_feed_enabled>
82
- <feeds>
83
- <callback_mappings>
84
- <program_id>
85
- <class>eems_affiliate/map</class>
86
- <method>getProgramId</method>
87
- <type>helper</type>
88
- <column_name>PID</column_name>
89
- </program_id>
90
- <order_id>
91
- <class>eems_affiliate/map_order</class>
92
- <method>getOrderId</method>
93
- <type>helper</type>
94
- <column_name>OID</column_name>
95
- <params>
96
- <format>%.50s</format>
97
- </params>
98
- </order_id>
99
- <item_order_id>
100
- <class>eems_affiliate/map_order</class>
101
- <method>getItemOrderId</method>
102
- <type>helper</type>
103
- <column_name>OID</column_name>
104
- <params>
105
- <format>%.50s</format>
106
- </params>
107
- </item_order_id>
108
- <item_id>
109
- <class>eems_affiliate/map_order</class>
110
- <method>getItemId</method>
111
- <type>helper</type>
112
- <column_name>ITEMID</column_name>
113
- <params>
114
- <format>%.50s</format>
115
- <key>sku</key>
116
- </params>
117
- </item_id>
118
- <item_price>
119
- <class>eems_affiliate/map_order</class>
120
- <method>getItemPrice</method>
121
- <type>helper</type>
122
- <column_name>AMOUNT</column_name>
123
- <params>
124
- <format>%.2f</format>
125
- </params>
126
- </item_price>
127
- <item_quantity>
128
- <class>eems_affiliate/map_order</class>
129
- <method>getItemQuantity</method>
130
- <type>helper</type>
131
- <column_name>QUANTITY</column_name>
132
- </item_quantity>
133
- <dynamic_program_id>
134
- <class>eems_affiliate/map</class>
135
- <method>getProgramId</method>
136
- <type>helper</type>
137
- <column_name>PROGRAM_ID</column_name>
138
- </dynamic_program_id>
139
- <dynamic_item_order_id>
140
- <class>eems_affiliate/map_order</class>
141
- <method>getItemOrderId</method>
142
- <type>helper</type>
143
- <column_name>ORDER_ID</column_name>
144
- <params>
145
- <format>%.50s</format>
146
- </params>
147
- </dynamic_item_order_id>
148
- <dynamic_item_id>
149
- <class>eems_affiliate/map_order</class>
150
- <method>getItemId</method>
151
- <type>helper</type>
152
- <column_name>ITEM_ID</column_name>
153
- <params>
154
- <format>%.50s</format>
155
- <key>sku</key>
156
- </params>
157
- </dynamic_item_id>
158
- <dynamic_item_price>
159
- <class>eems_affiliate/map_order</class>
160
- <method>getItemPrice</method>
161
- <type>helper</type>
162
- <column_name>ITEM_PRICE</column_name>
163
- <params>
164
- <format>%.2f</format>
165
- </params>
166
- </dynamic_item_price>
167
- <category>
168
- <class>eems_affiliate/map_order</class>
169
- <method>getCategory</method>
170
- <type>helper</type>
171
- <column_name>CATEGORY</column_name>
172
- </category>
173
- <new_to_file>
174
- <class>eems_affiliate/map_order</class>
175
- <method>getNewToFile</method>
176
- <type>helper</type>
177
- <column_name>NEW_TO_FILE</column_name>
178
- </new_to_file>
179
- <order_amount>
180
- <class>eems_affiliate/map_order</class>
181
- <method>getOrderAmount</method>
182
- <type>helper</type>
183
- <column_name>AMOUNT</column_name>
184
- <params>
185
- <format>%.2f</format>
186
- </params>
187
- </order_amount>
188
- <reason>
189
- <class>eems_affiliate/map</class>
190
- <method>passStatic</method>
191
- <type>helper</type>
192
- <column_name>REASON</column_name>
193
- <params>
194
- <value>8</value>
195
- </params>
196
- </reason>
197
- <transaction_type>
198
- <class>eems_affiliate/map_order</class>
199
- <method>getTransactionType</method>
200
- <type>helper</type>
201
- <column_name>TYPE</column_name>
202
- </transaction_type>
203
- <age_range>
204
- <class>eems_affiliate/map</class>
205
- <method>getDataValue</method>
206
- <type>helper</type>
207
- <column_name>age_range</column_name>
208
- <params>
209
- <format>%.32s</format>
210
- </params>
211
- </age_range>
212
- <artist>
213
- <class>eems_affiliate/map</class>
214
- <method>getDataValue</method>
215
- <type>helper</type>
216
- <column_name>artist</column_name>
217
- <params>
218
- <format>%.128s</format>
219
- </params>
220
- </artist>
221
- <aspect_ratio>
222
- <class>eems_affiliate/map</class>
223
- <method>getDataValue</method>
224
- <type>helper</type>
225
- <column_name>aspect_ratio</column_name>
226
- <params>
227
- <format>%.16s</format>
228
- </params>
229
- </aspect_ratio>
230
- <author>
231
- <class>eems_affiliate/map</class>
232
- <method>getDataValue</method>
233
- <type>helper</type>
234
- <column_name>author</column_name>
235
- <params>
236
- <format>%.128s</format>
237
- </params>
238
- </author>
239
- <battery_life>
240
- <class>eems_affiliate/map</class>
241
- <method>getDataValue</method>
242
- <type>helper</type>
243
- <column_name>battery_life</column_name>
244
- <params>
245
- <format>%.32s</format>
246
- </params>
247
- </battery_life>
248
- <binding>
249
- <class>eems_affiliate/map</class>
250
- <method>getDataValue</method>
251
- <type>helper</type>
252
- <column_name>binding</column_name>
253
- <params>
254
- <format>%.32s</format>
255
- </params>
256
- </binding>
257
- <buy_url>
258
- <class>eems_affiliate/map</class>
259
- <method>getDataValue</method>
260
- <type>helper</type>
261
- <column_name>buy_url</column_name>
262
- <params>
263
- <key>product_url</key>
264
- <format>%.2000s</format>
265
- </params>
266
- </buy_url>
267
- <category_network>
268
- <class>eems_affiliate/map_product</class>
269
- <method>getCategory</method>
270
- <type>helper</type>
271
- <column_name>category_network</column_name>
272
- <params>
273
- <format>%.256s</format>
274
- </params>
275
- </category_network>
276
- <category_program>
277
- <class>eems_affiliate/map_product</class>
278
- <method>getCategory</method>
279
- <type>helper</type>
280
- <column_name>category_program</column_name>
281
- <params>
282
- <format>%.256s</format>
283
- </params>
284
- </category_program>
285
- <color>
286
- <class>eems_affiliate/map</class>
287
- <method>getDataValue</method>
288
- <type>helper</type>
289
- <column_name>color</column_name>
290
- <params>
291
- <format>%.32s</format>
292
- </params>
293
- </color>
294
- <color_output>
295
- <class>eems_affiliate/map</class>
296
- <method>getValueYesNo</method>
297
- <type>helper</type>
298
- <column_name>color_output</column_name>
299
- <params>
300
- <format>%s</format>
301
- </params>
302
- </color_output>
303
- <condition>
304
- <class>eems_affiliate/map</class>
305
- <method>getDataValue</method>
306
- <type>helper</type>
307
- <column_name>condition</column_name>
308
- <params>
309
- <format>%.64s</format>
310
- </params>
311
- </condition>
312
- <description_long>
313
- <class>eems_affiliate/map</class>
314
- <method>getDataValue</method>
315
- <type>helper</type>
316
- <column_name>description_long</column_name>
317
- <params>
318
- <format>%.2000s</format>
319
- </params>
320
- </description_long>
321
- <description_short>
322
- <class>eems_affiliate/map</class>
323
- <method>getDataValue</method>
324
- <type>helper</type>
325
- <column_name>description_short</column_name>
326
- <params>
327
- <format>%.512s</format>
328
- </params>
329
- </description_short>
330
- <director>
331
- <class>eems_affiliate/map</class>
332
- <method>getDataValue</method>
333
- <type>helper</type>
334
- <column_name>director</column_name>
335
- <params>
336
- <format>%.128s</format>
337
- </params>
338
- </director>
339
- <discontinued>
340
- <class>eems_affiliate/map</class>
341
- <method>getValueYesNo</method>
342
- <type>helper</type>
343
- <column_name>discontinued</column_name>
344
- <params>
345
- <format>%s</format>
346
- </params>
347
- </discontinued>
348
- <display_type>
349
- <class>eems_affiliate/map</class>
350
- <method>getDataValue</method>
351
- <type>helper</type>
352
- <column_name>display_type</column_name>
353
- <params>
354
- <format>%.32s</format>
355
- </params>
356
- </display_type>
357
- <edition>
358
- <class>eems_affiliate/map</class>
359
- <method>getDataValue</method>
360
- <type>helper</type>
361
- <column_name>edition</column_name>
362
- <params>
363
- <format>%.32s</format>
364
- </params>
365
- </edition>
366
- <expiration_date>
367
- <class>eems_affiliate/map</class>
368
- <method>getDateValue</method>
369
- <type>helper</type>
370
- <column_name>expiration_date</column_name>
371
- <params>
372
- <format>Y-m-d</format>
373
- </params>
374
- </expiration_date>
375
- <features>
376
- <class>eems_affiliate/map</class>
377
- <method>getDataValue</method>
378
- <type>helper</type>
379
- <column_name>features</column_name>
380
- <params>
381
- <format>%.128s</format>
382
- </params>
383
- </features>
384
- <focus_type>
385
- <class>eems_affiliate/map</class>
386
- <method>getDataValue</method>
387
- <type>helper</type>
388
- <column_name>focus_type</column_name>
389
- <params>
390
- <format>%.128s</format>
391
- </params>
392
- </focus_type>
393
- <format>
394
- <class>eems_affiliate/map</class>
395
- <method>getDataValue</method>
396
- <type>helper</type>
397
- <column_name>format</column_name>
398
- <params>
399
- <format>%.64s</format>
400
- </params>
401
- </format>
402
- <functions>
403
- <class>eems_affiliate/map</class>
404
- <method>getDataValue</method>
405
- <type>helper</type>
406
- <column_name>functions</column_name>
407
- <params>
408
- <format>%.64s</format>
409
- </params>
410
- </functions>
411
- <genre>
412
- <class>eems_affiliate/map</class>
413
- <method>getDataValue</method>
414
- <type>helper</type>
415
- <column_name>genre</column_name>
416
- <params>
417
- <format>%.64s</format>
418
- </params>
419
- </genre>
420
- <heel_height>
421
- <class>eems_affiliate/map</class>
422
- <method>getDataValue</method>
423
- <type>helper</type>
424
- <column_name>heel_height</column_name>
425
- <params>
426
- <format>%.32s</format>
427
- </params>
428
- </heel_height>
429
- <height>
430
- <class>eems_affiliate/map</class>
431
- <method>getDataValue</method>
432
- <type>helper</type>
433
- <column_name>height</column_name>
434
- <params>
435
- <format>%.32s</format>
436
- </params>
437
- </height>
438
- <image_thumb_url>
439
- <class>eems_affiliate/map_product</class>
440
- <method>getImageUrl</method>
441
- <type>helper</type>
442
- <column_name>image_thumb_url</column_name>
443
- <params>
444
- <format>%.2000s</format>
445
- </params>
446
- </image_thumb_url>
447
- <image_url>
448
- <class>eems_affiliate/map_product</class>
449
- <method>getImageUrl</method>
450
- <type>helper</type>
451
- <column_name>image_url</column_name>
452
- <params>
453
- <format>%.2000s</format>
454
- </params>
455
- </image_url>
456
- <installation>
457
- <class>eems_affiliate/map</class>
458
- <method>getDataValue</method>
459
- <type>helper</type>
460
- <column_name>installation</column_name>
461
- <params>
462
- <format>%.64s</format>
463
- </params>
464
- </installation>
465
- <in_stock>
466
- <class>eems_affiliate/map_product</class>
467
- <method>getInStockYesNo</method>
468
- <type>helper</type>
469
- <column_name>in_stock</column_name>
470
- <params>
471
- <format>%s</format>
472
- </params>
473
- </in_stock>
474
- <isbn>
475
- <class>eems_affiliate/map</class>
476
- <method>getDataValue</method>
477
- <type>helper</type>
478
- <column_name>isbn</column_name>
479
- <params>
480
- <format>%.64s</format>
481
- </params>
482
- </isbn>
483
- <keywords>
484
- <class>eems_affiliate/map</class>
485
- <method>getDataValue</method>
486
- <type>helper</type>
487
- <column_name>keywords</column_name>
488
- <params>
489
- <format>%.256s</format>
490
- </params>
491
- </keywords>
492
- <length>
493
- <class>eems_affiliate/map</class>
494
- <method>getDataValue</method>
495
- <type>helper</type>
496
- <column_name>length</column_name>
497
- <params>
498
- <format>%.32s</format>
499
- </params>
500
- </length>
501
- <load_type>
502
- <class>eems_affiliate/map</class>
503
- <method>getDataValue</method>
504
- <type>helper</type>
505
- <column_name>load_type</column_name>
506
- <params>
507
- <format>%.32s</format>
508
- </params>
509
- </load_type>
510
- <location>
511
- <class>eems_affiliate/map</class>
512
- <method>getDataValue</method>
513
- <type>helper</type>
514
- <column_name>location</column_name>
515
- <params>
516
- <format>%.64s</format>
517
- </params>
518
- </location>
519
- <made_in>
520
- <class>eems_affiliate/map</class>
521
- <method>getDataValue</method>
522
- <type>helper</type>
523
- <column_name>made_in</column_name>
524
- <params>
525
- <format>%.64s</format>
526
- </params>
527
- </made_in>
528
- <manufacturer>
529
- <class>eems_affiliate/map</class>
530
- <method>getDataValue</method>
531
- <type>helper</type>
532
- <column_name>manufacturer</column_name>
533
- <params>
534
- <format>%.128s</format>
535
- </params>
536
- </manufacturer>
537
- <material>
538
- <class>eems_affiliate/map</class>
539
- <method>getDataValue</method>
540
- <type>helper</type>
541
- <column_name>material</column_name>
542
- <params>
543
- <format>%.128s</format>
544
- </params>
545
- </material>
546
- <megapixels>
547
- <class>eems_affiliate/map</class>
548
- <method>getDataValue</method>
549
- <type>helper</type>
550
- <column_name>megapixels</column_name>
551
- <params>
552
- <format>%01.2f</format>
553
- </params>
554
- </megapixels>
555
- <memory_capacity>
556
- <class>eems_affiliate/map</class>
557
- <method>getDataValue</method>
558
- <type>helper</type>
559
- <column_name>memory_capacity</column_name>
560
- <params>
561
- <format>%.64s</format>
562
- </params>
563
- </memory_capacity>
564
- <memory_card_slot>
565
- <class>eems_affiliate/map</class>
566
- <method>getDataValue</method>
567
- <type>helper</type>
568
- <column_name>memory_card_slot</column_name>
569
- <params>
570
- <format>%.32s</format>
571
- </params>
572
- </memory_card_slot>
573
- <memory_type>
574
- <class>eems_affiliate/map</class>
575
- <method>getDataValue</method>
576
- <type>helper</type>
577
- <column_name>memory_type</column_name>
578
- <params>
579
- <format>%.64s</format>
580
- </params>
581
- </memory_type>
582
- <model_number>
583
- <class>eems_affiliate/map</class>
584
- <method>getDataValue</method>
585
- <type>helper</type>
586
- <column_name>model_number</column_name>
587
- <params>
588
- <format>%.128s</format>
589
- </params>
590
- </model_number>
591
- <mpn>
592
- <class>eems_affiliate/map</class>
593
- <method>getDataValue</method>
594
- <type>helper</type>
595
- <column_name>mpn</column_name>
596
- <params>
597
- <format>%.128s</format>
598
- </params>
599
- </mpn>
600
- <name>
601
- <class>eems_affiliate/map</class>
602
- <method>getDataValue</method>
603
- <type>helper</type>
604
- <column_name>name</column_name>
605
- <params>
606
- <format>%.128s</format>
607
- </params>
608
- </name>
609
- <occasion>
610
- <class>eems_affiliate/map</class>
611
- <method>getDataValue</method>
612
- <type>helper</type>
613
- <column_name>occasion</column_name>
614
- <params>
615
- <format>%.128s</format>
616
- </params>
617
- </occasion>
618
- <operating_system>
619
- <class>eems_affiliate/map</class>
620
- <method>getDataValue</method>
621
- <type>helper</type>
622
- <column_name>operating_system</column_name>
623
- <params>
624
- <format>%.128s</format>
625
- </params>
626
- </operating_system>
627
- <optical_drive>
628
- <class>eems_affiliate/map</class>
629
- <method>getDataValue</method>
630
- <type>helper</type>
631
- <column_name>optical_drive</column_name>
632
- <params>
633
- <format>%.64s</format>
634
- </params>
635
- </optical_drive>
636
- <pages>
637
- <class>eems_affiliate/map</class>
638
- <method>getDataValue</method>
639
- <type>helper</type>
640
- <column_name>pages</column_name>
641
- <params>
642
- <format>%.11d</format>
643
- </params>
644
- </pages>
645
- <payment_accepted>
646
- <class>eems_affiliate/map</class>
647
- <method>getDataValue</method>
648
- <type>helper</type>
649
- <column_name>payment_accepted</column_name>
650
- <params>
651
- <format>%.128s</format>
652
- </params>
653
- </payment_accepted>
654
- <payment_notes>
655
- <class>eems_affiliate/map</class>
656
- <method>getDataValue</method>
657
- <type>helper</type>
658
- <column_name>payment_notes</column_name>
659
- <params>
660
- <format>%.256s</format>
661
- </params>
662
- </payment_notes>
663
- <platform>
664
- <class>eems_affiliate/map</class>
665
- <method>getDataValue</method>
666
- <type>helper</type>
667
- <column_name>platform</column_name>
668
- <params>
669
- <format>%.64s</format>
670
- </params>
671
- </platform>
672
- <price>
673
- <class>eems_affiliate/map</class>
674
- <method>getDataValue</method>
675
- <type>helper</type>
676
- <column_name>price</column_name>
677
- <params>
678
- <format>%01.2f</format>
679
- </params>
680
- </price>
681
- <price_retail>
682
- <class>eems_affiliate/map</class>
683
- <method>getDataValue</method>
684
- <type>helper</type>
685
- <column_name>price_retail</column_name>
686
- <params>
687
- <format>%01.2f</format>
688
- </params>
689
- </price_retail>
690
- <price_sale>
691
- <class>eems_affiliate/map</class>
692
- <method>getDataValue</method>
693
- <type>helper</type>
694
- <column_name>price_sale</column_name>
695
- <params>
696
- <format>%01.2f</format>
697
- </params>
698
- </price_sale>
699
- <price_shipping>
700
- <class>eems_affiliate/map</class>
701
- <method>getDataValue</method>
702
- <type>helper</type>
703
- <column_name>price_shipping</column_name>
704
- <params>
705
- <format>%01.2f</format>
706
- </params>
707
- </price_shipping>
708
- <processor>
709
- <class>eems_affiliate/map</class>
710
- <method>getDataValue</method>
711
- <type>helper</type>
712
- <column_name>processor</column_name>
713
- <params>
714
- <format>%.64s</format>
715
- </params>
716
- </processor>
717
- <publisher>
718
- <class>eems_affiliate/map</class>
719
- <method>getDataValue</method>
720
- <type>helper</type>
721
- <column_name>publisher</column_name>
722
- <params>
723
- <format>%.128s</format>
724
- </params>
725
- </publisher>
726
- <quantity_in_stock>
727
- <class>eems_affiliate/map_product</class>
728
- <method>getInStockQty</method>
729
- <type>helper</type>
730
- <column_name>quantity_in_stock</column_name>
731
- <params>
732
- <format>%.11d</format>
733
- </params>
734
- </quantity_in_stock>
735
- <rating>
736
- <class>eems_affiliate/map</class>
737
- <method>getDataValue</method>
738
- <type>helper</type>
739
- <column_name>rating</column_name>
740
- <params>
741
- <format>%.32s</format>
742
- </params>
743
- </rating>
744
- <recommended_usage>
745
- <class>eems_affiliate/map</class>
746
- <method>getDataValue</method>
747
- <type>helper</type>
748
- <column_name>recommended_usage</column_name>
749
- <params>
750
- <format>%.128s</format>
751
- </params>
752
- </recommended_usage>
753
- <resolution>
754
- <class>eems_affiliate/map</class>
755
- <method>getDataValue</method>
756
- <type>helper</type>
757
- <column_name>resolution</column_name>
758
- <params>
759
- <format>%.64s</format>
760
- </params>
761
- </resolution>
762
- <screen_size>
763
- <class>eems_affiliate/map</class>
764
- <method>getDataValue</method>
765
- <type>helper</type>
766
- <column_name>screen_size</column_name>
767
- <params>
768
- <format>%.32s</format>
769
- </params>
770
- </screen_size>
771
- <shipping_method>
772
- <class>eems_affiliate/map</class>
773
- <method>getDataValue</method>
774
- <type>helper</type>
775
- <column_name>shipping_method</column_name>
776
- <params>
777
- <format>%.64s</format>
778
- </params>
779
- </shipping_method>
780
- <shoe_size>
781
- <class>eems_affiliate/map</class>
782
- <method>getDataValue</method>
783
- <type>helper</type>
784
- <column_name>shoe_size</column_name>
785
- <params>
786
- <format>%.32s</format>
787
- </params>
788
- </shoe_size>
789
- <shoe_width>
790
- <class>eems_affiliate/map</class>
791
- <method>getDataValue</method>
792
- <type>helper</type>
793
- <column_name>shoe_width</column_name>
794
- <params>
795
- <format>%.32s</format>
796
- </params>
797
- </shoe_width>
798
- <size>
799
- <class>eems_affiliate/map</class>
800
- <method>getDataValue</method>
801
- <type>helper</type>
802
- <column_name>size</column_name>
803
- <params>
804
- <format>%.32s</format>
805
- </params>
806
- </size>
807
- <sku>
808
- <class>eems_affiliate/map</class>
809
- <method>getDataValue</method>
810
- <type>helper</type>
811
- <column_name>sku</column_name>
812
- <params>
813
- <format>%.128s</format>
814
- </params>
815
- </sku>
816
- <staring>
817
- <class>eems_affiliate/map</class>
818
- <method>getDataValue</method>
819
- <type>helper</type>
820
- <column_name>staring</column_name>
821
- <params>
822
- <format>%.128s</format>
823
- </params>
824
- </staring>
825
- <style>
826
- <class>eems_affiliate/map</class>
827
- <method>getDataValue</method>
828
- <type>helper</type>
829
- <column_name>style</column_name>
830
- <params>
831
- <format>%.64s</format>
832
- </params>
833
- </style>
834
- <tech_spec_url>
835
- <class>eems_affiliate/map</class>
836
- <method>getDataValue</method>
837
- <type>helper</type>
838
- <column_name>tech_spec_url</column_name>
839
- <params>
840
- <format>%.2000s</format>
841
- </params>
842
- </tech_spec_url>
843
- <tracks>
844
- <class>eems_affiliate/map</class>
845
- <method>getDataValue</method>
846
- <type>helper</type>
847
- <column_name>tracks</column_name>
848
- <params>
849
- <format>%.11d</format>
850
- </params>
851
- </tracks>
852
- <upc>
853
- <class>eems_affiliate/map</class>
854
- <method>getDataValue</method>
855
- <type>helper</type>
856
- <column_name>upc</column_name>
857
- <params>
858
- <format>%.128s</format>
859
- </params>
860
- </upc>
861
- <weight>
862
- <class>eems_affiliate/map</class>
863
- <method>getDataValue</method>
864
- <type>helper</type>
865
- <column_name>weight</column_name>
866
- <params>
867
- <format>%.32s</format>
868
- </params>
869
- </weight>
870
- <width>
871
- <class>eems_affiliate/map</class>
872
- <method>getDataValue</method>
873
- <type>helper</type>
874
- <column_name>width</column_name>
875
- <params>
876
- <format>%.32s</format>
877
- </params>
878
- </width>
879
- <wireless_interface>
880
- <class>eems_affiliate/map</class>
881
- <method>getDataValue</method>
882
- <type>helper</type>
883
- <column_name>wireless_interface</column_name>
884
- <params>
885
- <format>%.32s</format>
886
- </params>
887
- </wireless_interface>
888
- <year>
889
- <class>eems_affiliate/map</class>
890
- <method>getYearValue</method>
891
- <type>helper</type>
892
- <column_name>year</column_name>
893
- <params>
894
- <format>%.dd</format>
895
- </params>
896
- </year>
897
- <zoom>
898
- <class>eems_affiliate/map</class>
899
- <method>getDataValue</method>
900
- <type>helper</type>
901
- <column_name>zoom</column_name>
902
- <params>
903
- <format>%.32s</format>
904
- </params>
905
- </zoom>
906
- </callback_mappings>
907
- <order_dynamic>
908
- <fields>dynamic_program_id,dynamic_item_order_id,dynamic_item_id,dynamic_item_price,item_quantity,category,new_to_file</fields>
909
- <file_name_format>%s_transactions_corrected_%s.csv</file_name_format>
910
- </order_dynamic>
911
- <order_itemized>
912
- <fields>program_id,item_order_id,item_id,item_price,item_quantity,reason</fields>
913
- <file_name_format>%s_transactions_corrected_%s.csv</file_name_format>
914
- </order_itemized>
915
- <order_basic>
916
- <fields>program_id,order_amount,order_id,reason,transaction_type</fields>
917
- <file_name_format>%s_transactions_corrected_%s.csv</file_name_format>
918
- </order_basic>
919
- <product>
920
- <file_name_format>%s_product_feed.csv</file_name_format>
921
- </product>
922
- </feeds>
923
- </eems_affiliate>
924
- <eems_affiliate_product_attribute_map>
925
- <!--
926
- The purpose of this mapping is enabled the coexistence of both
927
- pre-configured product attributes mapping and configured attributes
928
- mapping for the affiliate product feed. This means that when this
929
- module is installed and no other attribute is configured for the
930
- product feed the required pre-mapped attributes will be sufficient
931
- enough to generate a valid product feed.
932
- -->
933
- <age_range/>
934
- <artist/>
935
- <aspect_ratio/>
936
- <author/>
937
- <battery_life/>
938
- <binding/>
939
- <buy_url>product_url</buy_url>
940
- <category_network/>
941
- <category_program>category</category_program>
942
- <color/>
943
- <color_output/>
944
- <condition/>
945
- <description_long>description</description_long>
946
- <description_short>short_description</description_short>
947
- <director/>
948
- <discontinued/>
949
- <display_type/>
950
- <edition/>
951
- <expiration_date/>
952
- <features/>
953
- <focus_type/>
954
- <format/>
955
- <functions/>
956
- <genre/>
957
- <heel_height/>
958
- <height/>
959
- <image_thumb_url>thumbnail</image_thumb_url>
960
- <image_url>image</image_url>
961
- <installation/>
962
- <in_stock/>
963
- <isbn/>
964
- <keywords>meta_keyword</keywords>
965
- <length/>
966
- <load_type/>
967
- <location/>
968
- <made_in/>
969
- <manufacturer>manufacturer</manufacturer>
970
- <material/>
971
- <megapixels/>
972
- <memory_capacity/>
973
- <memory_card_slot/>
974
- <memory_type/>
975
- <model_number/>
976
- <mpn/>
977
- <name>name</name>
978
- <occasion/>
979
- <operating_system/>
980
- <optical_drive/>
981
- <pages/>
982
- <payment_accepted/>
983
- <payment_notes/>
984
- <platform/>
985
- <price>price</price>
986
- <price_retail>msrp</price_retail>
987
- <price_sale>special_price</price_sale>
988
- <price_shipping/>
989
- <processor/>
990
- <publisher/>
991
- <quantity_in_stock>qty</quantity_in_stock>
992
- <rating/>
993
- <recommended_usage/>
994
- <resolution/>
995
- <screen_size/>
996
- <shipping_method/>
997
- <shoe_size/>
998
- <shoe_width/>
999
- <size/>
1000
- <sku>sku</sku>
1001
- <staring/>
1002
- <style/>
1003
- <tech_spec_url/>
1004
- <tracks/>
1005
- <upc/>
1006
- <weight/>
1007
- <width/>
1008
- <wireless_interface/>
1009
- <year/>
1010
- <zoom/>
1011
- </eems_affiliate_product_attribute_map>
1012
- </marketing_solutions>
1013
- </default>
1014
- <frontend>
1015
- <layout>
1016
- <updates>
1017
- <eems_affiliate>
1018
- <file>eems_affiliate.xml</file>
1019
- </eems_affiliate>
1020
- </updates>
1021
- </layout>
1022
- </frontend>
1023
- <phpunit>
1024
- <suite>
1025
- <modules>
1026
- <EbayEnterprise_Affiliate/>
1027
- </modules>
1028
- </suite>
1029
- </phpunit>
1030
- <admin>
1031
- <routers>
1032
- <adminhtml>
1033
- <args>
1034
- <modules>
1035
- <eems_affiliate before="Mage_Adminhtml">EbayEnterprise_Affiliate_Adminhtml</eems_affiliate>
1036
- </modules>
1037
- </args>
1038
- </adminhtml>
1039
- </routers>
1040
- </admin>
1041
- </config>
1
+ <?xml version="1.0" encoding="utf-8"?>
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
+ <config>
17
+ <modules>
18
+ <EbayEnterprise_Affiliate>
19
+ <version>1.2.1.1</version>
20
+ </EbayEnterprise_Affiliate>
21
+ </modules>
22
+ <global>
23
+ <models>
24
+ <eems_affiliate>
25
+ <class>EbayEnterprise_Affiliate_Model</class>
26
+ </eems_affiliate>
27
+ </models>
28
+ <helpers>
29
+ <eems_affiliate>
30
+ <class>EbayEnterprise_Affiliate_Helper</class>
31
+ </eems_affiliate>
32
+ </helpers>
33
+ <blocks>
34
+ <eems_affiliate>
35
+ <class>EbayEnterprise_Affiliate_Block</class>
36
+ </eems_affiliate>
37
+ </blocks>
38
+ <resources>
39
+ <eems_affiliate_setup>
40
+ <setup>
41
+ <module>EbayEnterprise_Affiliate</module>
42
+ <class>Mage_Core_Model_Resource_Setup</class>
43
+ </setup>
44
+ </eems_affiliate_setup>
45
+ </resources>
46
+ </global>
47
+ <crontab>
48
+ <jobs>
49
+ <eems_affiliate_generate_product_feed>
50
+ <schedule>
51
+ <cron_expr>0 3 * * *</cron_expr>
52
+ </schedule>
53
+ <run>
54
+ <model>eems_affiliate/observer::createProductFeed</model>
55
+ </run>
56
+ </eems_affiliate_generate_product_feed>
57
+ <eems_affiliate_generate_corrected_order_feed>
58
+ <schedule>
59
+ <cron_expr>0 3 * * *</cron_expr>
60
+ </schedule>
61
+ <run>
62
+ <model>eems_affiliate/observer::createCorrectedOrdersFeed</model>
63
+ </run>
64
+ </eems_affiliate_generate_corrected_order_feed>
65
+ </jobs>
66
+ </crontab>
67
+ <default>
68
+ <marketing_solutions>
69
+ <eems_affiliate>
70
+ <active>0</active>
71
+ <js_files>eems_affiliate/cookie.js</js_files>
72
+ <!-- use comma to add more js files-->
73
+ <beacon_url>https://t.pepperjamnetwork.com/track</beacon_url>
74
+ <export_path>var/export/eems_affiliate/</export_path>
75
+ <order_type>itemized</order_type>
76
+ <program_id/>
77
+ <transaction_type>1</transaction_type>
78
+ <conditional_pixel_enabled>0</conditional_pixel_enabled>
79
+ <source_key_name>eean</source_key_name>
80
+ <product_feed_enabled>1</product_feed_enabled>
81
+ <order_feed_enabled>1</order_feed_enabled>
82
+ <feeds>
83
+ <callback_mappings>
84
+ <program_id>
85
+ <class>eems_affiliate/map</class>
86
+ <method>getProgramId</method>
87
+ <type>helper</type>
88
+ <column_name>PID</column_name>
89
+ </program_id>
90
+ <order_id>
91
+ <class>eems_affiliate/map_order</class>
92
+ <method>getOrderId</method>
93
+ <type>helper</type>
94
+ <column_name>OID</column_name>
95
+ <params>
96
+ <format>%.50s</format>
97
+ </params>
98
+ </order_id>
99
+ <item_order_id>
100
+ <class>eems_affiliate/map_order</class>
101
+ <method>getItemOrderId</method>
102
+ <type>helper</type>
103
+ <column_name>OID</column_name>
104
+ <params>
105
+ <format>%.50s</format>
106
+ </params>
107
+ </item_order_id>
108
+ <item_id>
109
+ <class>eems_affiliate/map_order</class>
110
+ <method>getItemId</method>
111
+ <type>helper</type>
112
+ <column_name>ITEMID</column_name>
113
+ <params>
114
+ <format>%.50s</format>
115
+ <key>sku</key>
116
+ </params>
117
+ </item_id>
118
+ <item_price>
119
+ <class>eems_affiliate/map_order</class>
120
+ <method>getItemPrice</method>
121
+ <type>helper</type>
122
+ <column_name>AMOUNT</column_name>
123
+ <params>
124
+ <format>%.2f</format>
125
+ </params>
126
+ </item_price>
127
+ <item_quantity>
128
+ <class>eems_affiliate/map_order</class>
129
+ <method>getItemQuantity</method>
130
+ <type>helper</type>
131
+ <column_name>QUANTITY</column_name>
132
+ </item_quantity>
133
+ <dynamic_program_id>
134
+ <class>eems_affiliate/map</class>
135
+ <method>getProgramId</method>
136
+ <type>helper</type>
137
+ <column_name>PROGRAM_ID</column_name>
138
+ </dynamic_program_id>
139
+ <dynamic_item_order_id>
140
+ <class>eems_affiliate/map_order</class>
141
+ <method>getItemOrderId</method>
142
+ <type>helper</type>
143
+ <column_name>ORDER_ID</column_name>
144
+ <params>
145
+ <format>%.50s</format>
146
+ </params>
147
+ </dynamic_item_order_id>
148
+ <dynamic_item_id>
149
+ <class>eems_affiliate/map_order</class>
150
+ <method>getItemId</method>
151
+ <type>helper</type>
152
+ <column_name>ITEM_ID</column_name>
153
+ <params>
154
+ <format>%.50s</format>
155
+ <key>sku</key>
156
+ </params>
157
+ </dynamic_item_id>
158
+ <dynamic_item_price>
159
+ <class>eems_affiliate/map_order</class>
160
+ <method>getItemPrice</method>
161
+ <type>helper</type>
162
+ <column_name>ITEM_PRICE</column_name>
163
+ <params>
164
+ <format>%.2f</format>
165
+ </params>
166
+ </dynamic_item_price>
167
+ <category>
168
+ <class>eems_affiliate/map_order</class>
169
+ <method>getCategory</method>
170
+ <type>helper</type>
171
+ <column_name>CATEGORY</column_name>
172
+ </category>
173
+ <new_to_file>
174
+ <class>eems_affiliate/map_order</class>
175
+ <method>getNewToFile</method>
176
+ <type>helper</type>
177
+ <column_name>NEW_TO_FILE</column_name>
178
+ </new_to_file>
179
+ <order_amount>
180
+ <class>eems_affiliate/map_order</class>
181
+ <method>getOrderAmount</method>
182
+ <type>helper</type>
183
+ <column_name>AMOUNT</column_name>
184
+ <params>
185
+ <format>%.2f</format>
186
+ </params>
187
+ </order_amount>
188
+ <reason>
189
+ <class>eems_affiliate/map</class>
190
+ <method>passStatic</method>
191
+ <type>helper</type>
192
+ <column_name>REASON</column_name>
193
+ <params>
194
+ <value>8</value>
195
+ </params>
196
+ </reason>
197
+ <transaction_type>
198
+ <class>eems_affiliate/map_order</class>
199
+ <method>getTransactionType</method>
200
+ <type>helper</type>
201
+ <column_name>TYPE</column_name>
202
+ </transaction_type>
203
+ <age_range>
204
+ <class>eems_affiliate/map</class>
205
+ <method>getDataValue</method>
206
+ <type>helper</type>
207
+ <column_name>age_range</column_name>
208
+ <params>
209
+ <format>%.32s</format>
210
+ </params>
211
+ </age_range>
212
+ <artist>
213
+ <class>eems_affiliate/map</class>
214
+ <method>getDataValue</method>
215
+ <type>helper</type>
216
+ <column_name>artist</column_name>
217
+ <params>
218
+ <format>%.128s</format>
219
+ </params>
220
+ </artist>
221
+ <aspect_ratio>
222
+ <class>eems_affiliate/map</class>
223
+ <method>getDataValue</method>
224
+ <type>helper</type>
225
+ <column_name>aspect_ratio</column_name>
226
+ <params>
227
+ <format>%.16s</format>
228
+ </params>
229
+ </aspect_ratio>
230
+ <author>
231
+ <class>eems_affiliate/map</class>
232
+ <method>getDataValue</method>
233
+ <type>helper</type>
234
+ <column_name>author</column_name>
235
+ <params>
236
+ <format>%.128s</format>
237
+ </params>
238
+ </author>
239
+ <battery_life>
240
+ <class>eems_affiliate/map</class>
241
+ <method>getDataValue</method>
242
+ <type>helper</type>
243
+ <column_name>battery_life</column_name>
244
+ <params>
245
+ <format>%.32s</format>
246
+ </params>
247
+ </battery_life>
248
+ <binding>
249
+ <class>eems_affiliate/map</class>
250
+ <method>getDataValue</method>
251
+ <type>helper</type>
252
+ <column_name>binding</column_name>
253
+ <params>
254
+ <format>%.32s</format>
255
+ </params>
256
+ </binding>
257
+ <buy_url>
258
+ <class>eems_affiliate/map</class>
259
+ <method>getDataValue</method>
260
+ <type>helper</type>
261
+ <column_name>buy_url</column_name>
262
+ <params>
263
+ <key>product_url</key>
264
+ <format>%.2000s</format>
265
+ </params>
266
+ </buy_url>
267
+ <category_network>
268
+ <class>eems_affiliate/map_product</class>
269
+ <method>getCategory</method>
270
+ <type>helper</type>
271
+ <column_name>category_network</column_name>
272
+ <params>
273
+ <format>%.256s</format>
274
+ </params>
275
+ </category_network>
276
+ <category_program>
277
+ <class>eems_affiliate/map_product</class>
278
+ <method>getCategory</method>
279
+ <type>helper</type>
280
+ <column_name>category_program</column_name>
281
+ <params>
282
+ <format>%.256s</format>
283
+ </params>
284
+ </category_program>
285
+ <color>
286
+ <class>eems_affiliate/map</class>
287
+ <method>getDataValue</method>
288
+ <type>helper</type>
289
+ <column_name>color</column_name>
290
+ <params>
291
+ <format>%.32s</format>
292
+ </params>
293
+ </color>
294
+ <color_output>
295
+ <class>eems_affiliate/map</class>
296
+ <method>getValueYesNo</method>
297
+ <type>helper</type>
298
+ <column_name>color_output</column_name>
299
+ <params>
300
+ <format>%s</format>
301
+ </params>
302
+ </color_output>
303
+ <condition>
304
+ <class>eems_affiliate/map</class>
305
+ <method>getDataValue</method>
306
+ <type>helper</type>
307
+ <column_name>condition</column_name>
308
+ <params>
309
+ <format>%.64s</format>
310
+ </params>
311
+ </condition>
312
+ <description_long>
313
+ <class>eems_affiliate/map</class>
314
+ <method>getDataValue</method>
315
+ <type>helper</type>
316
+ <column_name>description_long</column_name>
317
+ <params>
318
+ <format>%.2000s</format>
319
+ </params>
320
+ </description_long>
321
+ <description_short>
322
+ <class>eems_affiliate/map</class>
323
+ <method>getDataValue</method>
324
+ <type>helper</type>
325
+ <column_name>description_short</column_name>
326
+ <params>
327
+ <format>%.512s</format>
328
+ </params>
329
+ </description_short>
330
+ <director>
331
+ <class>eems_affiliate/map</class>
332
+ <method>getDataValue</method>
333
+ <type>helper</type>
334
+ <column_name>director</column_name>
335
+ <params>
336
+ <format>%.128s</format>
337
+ </params>
338
+ </director>
339
+ <discontinued>
340
+ <class>eems_affiliate/map</class>
341
+ <method>getValueYesNo</method>
342
+ <type>helper</type>
343
+ <column_name>discontinued</column_name>
344
+ <params>
345
+ <format>%s</format>
346
+ </params>
347
+ </discontinued>
348
+ <display_type>
349
+ <class>eems_affiliate/map</class>
350
+ <method>getDataValue</method>
351
+ <type>helper</type>
352
+ <column_name>display_type</column_name>
353
+ <params>
354
+ <format>%.32s</format>
355
+ </params>
356
+ </display_type>
357
+ <edition>
358
+ <class>eems_affiliate/map</class>
359
+ <method>getDataValue</method>
360
+ <type>helper</type>
361
+ <column_name>edition</column_name>
362
+ <params>
363
+ <format>%.32s</format>
364
+ </params>
365
+ </edition>
366
+ <expiration_date>
367
+ <class>eems_affiliate/map</class>
368
+ <method>getDateValue</method>
369
+ <type>helper</type>
370
+ <column_name>expiration_date</column_name>
371
+ <params>
372
+ <format>Y-m-d</format>
373
+ </params>
374
+ </expiration_date>
375
+ <features>
376
+ <class>eems_affiliate/map</class>
377
+ <method>getDataValue</method>
378
+ <type>helper</type>
379
+ <column_name>features</column_name>
380
+ <params>
381
+ <format>%.128s</format>
382
+ </params>
383
+ </features>
384
+ <focus_type>
385
+ <class>eems_affiliate/map</class>
386
+ <method>getDataValue</method>
387
+ <type>helper</type>
388
+ <column_name>focus_type</column_name>
389
+ <params>
390
+ <format>%.128s</format>
391
+ </params>
392
+ </focus_type>
393
+ <format>
394
+ <class>eems_affiliate/map</class>
395
+ <method>getDataValue</method>
396
+ <type>helper</type>
397
+ <column_name>format</column_name>
398
+ <params>
399
+ <format>%.64s</format>
400
+ </params>
401
+ </format>
402
+ <functions>
403
+ <class>eems_affiliate/map</class>
404
+ <method>getDataValue</method>
405
+ <type>helper</type>
406
+ <column_name>functions</column_name>
407
+ <params>
408
+ <format>%.64s</format>
409
+ </params>
410
+ </functions>
411
+ <genre>
412
+ <class>eems_affiliate/map</class>
413
+ <method>getDataValue</method>
414
+ <type>helper</type>
415
+ <column_name>genre</column_name>
416
+ <params>
417
+ <format>%.64s</format>
418
+ </params>
419
+ </genre>
420
+ <heel_height>
421
+ <class>eems_affiliate/map</class>
422
+ <method>getDataValue</method>
423
+ <type>helper</type>
424
+ <column_name>heel_height</column_name>
425
+ <params>
426
+ <format>%.32s</format>
427
+ </params>
428
+ </heel_height>
429
+ <height>
430
+ <class>eems_affiliate/map</class>
431
+ <method>getDataValue</method>
432
+ <type>helper</type>
433
+ <column_name>height</column_name>
434
+ <params>
435
+ <format>%.32s</format>
436
+ </params>
437
+ </height>
438
+ <image_thumb_url>
439
+ <class>eems_affiliate/map_product</class>
440
+ <method>getImageUrl</method>
441
+ <type>helper</type>
442
+ <column_name>image_thumb_url</column_name>
443
+ <params>
444
+ <format>%.2000s</format>
445
+ </params>
446
+ </image_thumb_url>
447
+ <image_url>
448
+ <class>eems_affiliate/map_product</class>
449
+ <method>getImageUrl</method>
450
+ <type>helper</type>
451
+ <column_name>image_url</column_name>
452
+ <params>
453
+ <format>%.2000s</format>
454
+ </params>
455
+ </image_url>
456
+ <installation>
457
+ <class>eems_affiliate/map</class>
458
+ <method>getDataValue</method>
459
+ <type>helper</type>
460
+ <column_name>installation</column_name>
461
+ <params>
462
+ <format>%.64s</format>
463
+ </params>
464
+ </installation>
465
+ <in_stock>
466
+ <class>eems_affiliate/map_product</class>
467
+ <method>getInStockYesNo</method>
468
+ <type>helper</type>
469
+ <column_name>in_stock</column_name>
470
+ <params>
471
+ <format>%s</format>
472
+ </params>
473
+ </in_stock>
474
+ <isbn>
475
+ <class>eems_affiliate/map</class>
476
+ <method>getDataValue</method>
477
+ <type>helper</type>
478
+ <column_name>isbn</column_name>
479
+ <params>
480
+ <format>%.64s</format>
481
+ </params>
482
+ </isbn>
483
+ <keywords>
484
+ <class>eems_affiliate/map</class>
485
+ <method>getDataValue</method>
486
+ <type>helper</type>
487
+ <column_name>keywords</column_name>
488
+ <params>
489
+ <format>%.256s</format>
490
+ </params>
491
+ </keywords>
492
+ <length>
493
+ <class>eems_affiliate/map</class>
494
+ <method>getDataValue</method>
495
+ <type>helper</type>
496
+ <column_name>length</column_name>
497
+ <params>
498
+ <format>%.32s</format>
499
+ </params>
500
+ </length>
501
+ <load_type>
502
+ <class>eems_affiliate/map</class>
503
+ <method>getDataValue</method>
504
+ <type>helper</type>
505
+ <column_name>load_type</column_name>
506
+ <params>
507
+ <format>%.32s</format>
508
+ </params>
509
+ </load_type>
510
+ <location>
511
+ <class>eems_affiliate/map</class>
512
+ <method>getDataValue</method>
513
+ <type>helper</type>
514
+ <column_name>location</column_name>
515
+ <params>
516
+ <format>%.64s</format>
517
+ </params>
518
+ </location>
519
+ <made_in>
520
+ <class>eems_affiliate/map</class>
521
+ <method>getDataValue</method>
522
+ <type>helper</type>
523
+ <column_name>made_in</column_name>
524
+ <params>
525
+ <format>%.64s</format>
526
+ </params>
527
+ </made_in>
528
+ <manufacturer>
529
+ <class>eems_affiliate/map</class>
530
+ <method>getDataValue</method>
531
+ <type>helper</type>
532
+ <column_name>manufacturer</column_name>
533
+ <params>
534
+ <format>%.128s</format>
535
+ </params>
536
+ </manufacturer>
537
+ <material>
538
+ <class>eems_affiliate/map</class>
539
+ <method>getDataValue</method>
540
+ <type>helper</type>
541
+ <column_name>material</column_name>
542
+ <params>
543
+ <format>%.128s</format>
544
+ </params>
545
+ </material>
546
+ <megapixels>
547
+ <class>eems_affiliate/map</class>
548
+ <method>getDataValue</method>
549
+ <type>helper</type>
550
+ <column_name>megapixels</column_name>
551
+ <params>
552
+ <format>%01.2f</format>
553
+ </params>
554
+ </megapixels>
555
+ <memory_capacity>
556
+ <class>eems_affiliate/map</class>
557
+ <method>getDataValue</method>
558
+ <type>helper</type>
559
+ <column_name>memory_capacity</column_name>
560
+ <params>
561
+ <format>%.64s</format>
562
+ </params>
563
+ </memory_capacity>
564
+ <memory_card_slot>
565
+ <class>eems_affiliate/map</class>
566
+ <method>getDataValue</method>
567
+ <type>helper</type>
568
+ <column_name>memory_card_slot</column_name>
569
+ <params>
570
+ <format>%.32s</format>
571
+ </params>
572
+ </memory_card_slot>
573
+ <memory_type>
574
+ <class>eems_affiliate/map</class>
575
+ <method>getDataValue</method>
576
+ <type>helper</type>
577
+ <column_name>memory_type</column_name>
578
+ <params>
579
+ <format>%.64s</format>
580
+ </params>
581
+ </memory_type>
582
+ <model_number>
583
+ <class>eems_affiliate/map</class>
584
+ <method>getDataValue</method>
585
+ <type>helper</type>
586
+ <column_name>model_number</column_name>
587
+ <params>
588
+ <format>%.128s</format>
589
+ </params>
590
+ </model_number>
591
+ <mpn>
592
+ <class>eems_affiliate/map</class>
593
+ <method>getDataValue</method>
594
+ <type>helper</type>
595
+ <column_name>mpn</column_name>
596
+ <params>
597
+ <format>%.128s</format>
598
+ </params>
599
+ </mpn>
600
+ <name>
601
+ <class>eems_affiliate/map</class>
602
+ <method>getDataValue</method>
603
+ <type>helper</type>
604
+ <column_name>name</column_name>
605
+ <params>
606
+ <format>%.128s</format>
607
+ </params>
608
+ </name>
609
+ <occasion>
610
+ <class>eems_affiliate/map</class>
611
+ <method>getDataValue</method>
612
+ <type>helper</type>
613
+ <column_name>occasion</column_name>
614
+ <params>
615
+ <format>%.128s</format>
616
+ </params>
617
+ </occasion>
618
+ <operating_system>
619
+ <class>eems_affiliate/map</class>
620
+ <method>getDataValue</method>
621
+ <type>helper</type>
622
+ <column_name>operating_system</column_name>
623
+ <params>
624
+ <format>%.128s</format>
625
+ </params>
626
+ </operating_system>
627
+ <optical_drive>
628
+ <class>eems_affiliate/map</class>
629
+ <method>getDataValue</method>
630
+ <type>helper</type>
631
+ <column_name>optical_drive</column_name>
632
+ <params>
633
+ <format>%.64s</format>
634
+ </params>
635
+ </optical_drive>
636
+ <pages>
637
+ <class>eems_affiliate/map</class>
638
+ <method>getDataValue</method>
639
+ <type>helper</type>
640
+ <column_name>pages</column_name>
641
+ <params>
642
+ <format>%.11d</format>
643
+ </params>
644
+ </pages>
645
+ <payment_accepted>
646
+ <class>eems_affiliate/map</class>
647
+ <method>getDataValue</method>
648
+ <type>helper</type>
649
+ <column_name>payment_accepted</column_name>
650
+ <params>
651
+ <format>%.128s</format>
652
+ </params>
653
+ </payment_accepted>
654
+ <payment_notes>
655
+ <class>eems_affiliate/map</class>
656
+ <method>getDataValue</method>
657
+ <type>helper</type>
658
+ <column_name>payment_notes</column_name>
659
+ <params>
660
+ <format>%.256s</format>
661
+ </params>
662
+ </payment_notes>
663
+ <platform>
664
+ <class>eems_affiliate/map</class>
665
+ <method>getDataValue</method>
666
+ <type>helper</type>
667
+ <column_name>platform</column_name>
668
+ <params>
669
+ <format>%.64s</format>
670
+ </params>
671
+ </platform>
672
+ <price>
673
+ <class>eems_affiliate/map</class>
674
+ <method>getDataValue</method>
675
+ <type>helper</type>
676
+ <column_name>price</column_name>
677
+ <params>
678
+ <format>%01.2f</format>
679
+ </params>
680
+ </price>
681
+ <price_retail>
682
+ <class>eems_affiliate/map</class>
683
+ <method>getDataValue</method>
684
+ <type>helper</type>
685
+ <column_name>price_retail</column_name>
686
+ <params>
687
+ <format>%01.2f</format>
688
+ </params>
689
+ </price_retail>
690
+ <price_sale>
691
+ <class>eems_affiliate/map</class>
692
+ <method>getDataValue</method>
693
+ <type>helper</type>
694
+ <column_name>price_sale</column_name>
695
+ <params>
696
+ <format>%01.2f</format>
697
+ </params>
698
+ </price_sale>
699
+ <price_shipping>
700
+ <class>eems_affiliate/map</class>
701
+ <method>getDataValue</method>
702
+ <type>helper</type>
703
+ <column_name>price_shipping</column_name>
704
+ <params>
705
+ <format>%01.2f</format>
706
+ </params>
707
+ </price_shipping>
708
+ <processor>
709
+ <class>eems_affiliate/map</class>
710
+ <method>getDataValue</method>
711
+ <type>helper</type>
712
+ <column_name>processor</column_name>
713
+ <params>
714
+ <format>%.64s</format>
715
+ </params>
716
+ </processor>
717
+ <publisher>
718
+ <class>eems_affiliate/map</class>
719
+ <method>getDataValue</method>
720
+ <type>helper</type>
721
+ <column_name>publisher</column_name>
722
+ <params>
723
+ <format>%.128s</format>
724
+ </params>
725
+ </publisher>
726
+ <quantity_in_stock>
727
+ <class>eems_affiliate/map_product</class>
728
+ <method>getInStockQty</method>
729
+ <type>helper</type>
730
+ <column_name>quantity_in_stock</column_name>
731
+ <params>
732
+ <format>%.11d</format>
733
+ </params>
734
+ </quantity_in_stock>
735
+ <rating>
736
+ <class>eems_affiliate/map</class>
737
+ <method>getDataValue</method>
738
+ <type>helper</type>
739
+ <column_name>rating</column_name>
740
+ <params>
741
+ <format>%.32s</format>
742
+ </params>
743
+ </rating>
744
+ <recommended_usage>
745
+ <class>eems_affiliate/map</class>
746
+ <method>getDataValue</method>
747
+ <type>helper</type>
748
+ <column_name>recommended_usage</column_name>
749
+ <params>
750
+ <format>%.128s</format>
751
+ </params>
752
+ </recommended_usage>
753
+ <resolution>
754
+ <class>eems_affiliate/map</class>
755
+ <method>getDataValue</method>
756
+ <type>helper</type>
757
+ <column_name>resolution</column_name>
758
+ <params>
759
+ <format>%.64s</format>
760
+ </params>
761
+ </resolution>
762
+ <screen_size>
763
+ <class>eems_affiliate/map</class>
764
+ <method>getDataValue</method>
765
+ <type>helper</type>
766
+ <column_name>screen_size</column_name>
767
+ <params>
768
+ <format>%.32s</format>
769
+ </params>
770
+ </screen_size>
771
+ <shipping_method>
772
+ <class>eems_affiliate/map</class>
773
+ <method>getDataValue</method>
774
+ <type>helper</type>
775
+ <column_name>shipping_method</column_name>
776
+ <params>
777
+ <format>%.64s</format>
778
+ </params>
779
+ </shipping_method>
780
+ <shoe_size>
781
+ <class>eems_affiliate/map</class>
782
+ <method>getDataValue</method>
783
+ <type>helper</type>
784
+ <column_name>shoe_size</column_name>
785
+ <params>
786
+ <format>%.32s</format>
787
+ </params>
788
+ </shoe_size>
789
+ <shoe_width>
790
+ <class>eems_affiliate/map</class>
791
+ <method>getDataValue</method>
792
+ <type>helper</type>
793
+ <column_name>shoe_width</column_name>
794
+ <params>
795
+ <format>%.32s</format>
796
+ </params>
797
+ </shoe_width>
798
+ <size>
799
+ <class>eems_affiliate/map</class>
800
+ <method>getDataValue</method>
801
+ <type>helper</type>
802
+ <column_name>size</column_name>
803
+ <params>
804
+ <format>%.32s</format>
805
+ </params>
806
+ </size>
807
+ <sku>
808
+ <class>eems_affiliate/map</class>
809
+ <method>getDataValue</method>
810
+ <type>helper</type>
811
+ <column_name>sku</column_name>
812
+ <params>
813
+ <format>%.128s</format>
814
+ </params>
815
+ </sku>
816
+ <staring>
817
+ <class>eems_affiliate/map</class>
818
+ <method>getDataValue</method>
819
+ <type>helper</type>
820
+ <column_name>staring</column_name>
821
+ <params>
822
+ <format>%.128s</format>
823
+ </params>
824
+ </staring>
825
+ <style>
826
+ <class>eems_affiliate/map</class>
827
+ <method>getDataValue</method>
828
+ <type>helper</type>
829
+ <column_name>style</column_name>
830
+ <params>
831
+ <format>%.64s</format>
832
+ </params>
833
+ </style>
834
+ <tech_spec_url>
835
+ <class>eems_affiliate/map</class>
836
+ <method>getDataValue</method>
837
+ <type>helper</type>
838
+ <column_name>tech_spec_url</column_name>
839
+ <params>
840
+ <format>%.2000s</format>
841
+ </params>
842
+ </tech_spec_url>
843
+ <tracks>
844
+ <class>eems_affiliate/map</class>
845
+ <method>getDataValue</method>
846
+ <type>helper</type>
847
+ <column_name>tracks</column_name>
848
+ <params>
849
+ <format>%.11d</format>
850
+ </params>
851
+ </tracks>
852
+ <upc>
853
+ <class>eems_affiliate/map</class>
854
+ <method>getDataValue</method>
855
+ <type>helper</type>
856
+ <column_name>upc</column_name>
857
+ <params>
858
+ <format>%.128s</format>
859
+ </params>
860
+ </upc>
861
+ <weight>
862
+ <class>eems_affiliate/map</class>
863
+ <method>getDataValue</method>
864
+ <type>helper</type>
865
+ <column_name>weight</column_name>
866
+ <params>
867
+ <format>%.32s</format>
868
+ </params>
869
+ </weight>
870
+ <width>
871
+ <class>eems_affiliate/map</class>
872
+ <method>getDataValue</method>
873
+ <type>helper</type>
874
+ <column_name>width</column_name>
875
+ <params>
876
+ <format>%.32s</format>
877
+ </params>
878
+ </width>
879
+ <wireless_interface>
880
+ <class>eems_affiliate/map</class>
881
+ <method>getDataValue</method>
882
+ <type>helper</type>
883
+ <column_name>wireless_interface</column_name>
884
+ <params>
885
+ <format>%.32s</format>
886
+ </params>
887
+ </wireless_interface>
888
+ <year>
889
+ <class>eems_affiliate/map</class>
890
+ <method>getYearValue</method>
891
+ <type>helper</type>
892
+ <column_name>year</column_name>
893
+ <params>
894
+ <format>%.dd</format>
895
+ </params>
896
+ </year>
897
+ <zoom>
898
+ <class>eems_affiliate/map</class>
899
+ <method>getDataValue</method>
900
+ <type>helper</type>
901
+ <column_name>zoom</column_name>
902
+ <params>
903
+ <format>%.32s</format>
904
+ </params>
905
+ </zoom>
906
+ </callback_mappings>
907
+ <order_dynamic>
908
+ <fields>dynamic_program_id,dynamic_item_order_id,dynamic_item_id,dynamic_item_price,item_quantity,category,new_to_file</fields>
909
+ <file_name_format>%s_transactions_corrected_%s.csv</file_name_format>
910
+ </order_dynamic>
911
+ <order_itemized>
912
+ <fields>program_id,item_order_id,item_id,item_price,item_quantity,reason</fields>
913
+ <file_name_format>%s_transactions_corrected_%s.csv</file_name_format>
914
+ </order_itemized>
915
+ <order_basic>
916
+ <fields>program_id,order_amount,order_id,reason,transaction_type</fields>
917
+ <file_name_format>%s_transactions_corrected_%s.csv</file_name_format>
918
+ </order_basic>
919
+ <product>
920
+ <file_name_format>%s_product_feed.csv</file_name_format>
921
+ </product>
922
+ </feeds>
923
+ </eems_affiliate>
924
+ <eems_affiliate_product_attribute_map>
925
+ <!--
926
+ The purpose of this mapping is enabled the coexistence of both
927
+ pre-configured product attributes mapping and configured attributes
928
+ mapping for the affiliate product feed. This means that when this
929
+ module is installed and no other attribute is configured for the
930
+ product feed the required pre-mapped attributes will be sufficient
931
+ enough to generate a valid product feed.
932
+ -->
933
+ <age_range/>
934
+ <artist/>
935
+ <aspect_ratio/>
936
+ <author/>
937
+ <battery_life/>
938
+ <binding/>
939
+ <buy_url>product_url</buy_url>
940
+ <category_network/>
941
+ <category_program>category</category_program>
942
+ <color/>
943
+ <color_output/>
944
+ <condition/>
945
+ <description_long>description</description_long>
946
+ <description_short>short_description</description_short>
947
+ <director/>
948
+ <discontinued/>
949
+ <display_type/>
950
+ <edition/>
951
+ <expiration_date/>
952
+ <features/>
953
+ <focus_type/>
954
+ <format/>
955
+ <functions/>
956
+ <genre/>
957
+ <heel_height/>
958
+ <height/>
959
+ <image_thumb_url>thumbnail</image_thumb_url>
960
+ <image_url>image</image_url>
961
+ <installation/>
962
+ <in_stock/>
963
+ <isbn/>
964
+ <keywords>meta_keyword</keywords>
965
+ <length/>
966
+ <load_type/>
967
+ <location/>
968
+ <made_in/>
969
+ <manufacturer>manufacturer</manufacturer>
970
+ <material/>
971
+ <megapixels/>
972
+ <memory_capacity/>
973
+ <memory_card_slot/>
974
+ <memory_type/>
975
+ <model_number/>
976
+ <mpn/>
977
+ <name>name</name>
978
+ <occasion/>
979
+ <operating_system/>
980
+ <optical_drive/>
981
+ <pages/>
982
+ <payment_accepted/>
983
+ <payment_notes/>
984
+ <platform/>
985
+ <price>price</price>
986
+ <price_retail>msrp</price_retail>
987
+ <price_sale>special_price</price_sale>
988
+ <price_shipping/>
989
+ <processor/>
990
+ <publisher/>
991
+ <quantity_in_stock>qty</quantity_in_stock>
992
+ <rating/>
993
+ <recommended_usage/>
994
+ <resolution/>
995
+ <screen_size/>
996
+ <shipping_method/>
997
+ <shoe_size/>
998
+ <shoe_width/>
999
+ <size/>
1000
+ <sku>sku</sku>
1001
+ <staring/>
1002
+ <style/>
1003
+ <tech_spec_url/>
1004
+ <tracks/>
1005
+ <upc/>
1006
+ <weight/>
1007
+ <width/>
1008
+ <wireless_interface/>
1009
+ <year/>
1010
+ <zoom/>
1011
+ </eems_affiliate_product_attribute_map>
1012
+ </marketing_solutions>
1013
+ </default>
1014
+ <frontend>
1015
+ <layout>
1016
+ <updates>
1017
+ <eems_affiliate>
1018
+ <file>eems_affiliate.xml</file>
1019
+ </eems_affiliate>
1020
+ </updates>
1021
+ </layout>
1022
+ </frontend>
1023
+ <phpunit>
1024
+ <suite>
1025
+ <modules>
1026
+ <EbayEnterprise_Affiliate/>
1027
+ </modules>
1028
+ </suite>
1029
+ </phpunit>
1030
+ <admin>
1031
+ <routers>
1032
+ <adminhtml>
1033
+ <args>
1034
+ <modules>
1035
+ <eems_affiliate before="Mage_Adminhtml">EbayEnterprise_Affiliate_Adminhtml</eems_affiliate>
1036
+ </modules>
1037
+ </args>
1038
+ </adminhtml>
1039
+ </routers>
1040
+ </admin>
1041
+ </config>
app/code/community/EbayEnterprise/Affiliate/sql/eems_affiliate_setup/install-1.0.0.1.php CHANGED
@@ -1,24 +1,24 @@
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
- /** @var $installer Mage_Core_Model_Resource_Setup */
19
- $installer = $this;
20
-
21
- // Set the last run time of the corrected orders feed to the time when the
22
- // extension is installed. This should help to reduce the number of untracked
23
- // orders included in the initial run of the feed.
24
- $installer->setConfigData('marketing_solutions/eems_affiliate/feed/last_run_time', time());
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
+ /** @var $installer Mage_Core_Model_Resource_Setup */
19
+ $installer = $this;
20
+
21
+ // Set the last run time of the corrected orders feed to the time when the
22
+ // extension is installed. This should help to reduce the number of untracked
23
+ // orders included in the initial run of the feed.
24
+ $installer->setConfigData('marketing_solutions/eems_affiliate/feed/last_run_time', time());
app/code/community/EbayEnterprise/Affiliate/sql/eems_affiliate_setup/mysql4-install-1.0.0.1.php CHANGED
@@ -1,24 +1,24 @@
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
- /** @var $installer Mage_Core_Model_Resource_Setup */
19
- $installer = $this;
20
-
21
- // Set the last run time of the corrected orders feed to the time when the
22
- // extension is installed. This should help to reduce the number of untracked
23
- // orders included in the initial run of the feed.
24
- $installer->setConfigData('marketing_solutions/eems_affiliate/feed/last_run_time', time());
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
+ /** @var $installer Mage_Core_Model_Resource_Setup */
19
+ $installer = $this;
20
+
21
+ // Set the last run time of the corrected orders feed to the time when the
22
+ // extension is installed. This should help to reduce the number of untracked
23
+ // orders included in the initial run of the feed.
24
+ $installer->setConfigData('marketing_solutions/eems_affiliate/feed/last_run_time', time());
app/code/community/EbayEnterprise/Affiliate/sql/eems_affiliate_setup/mysql4-upgrade-1.0.0.1-1.2.0.0.php CHANGED
@@ -1,36 +1,36 @@
1
- <?php
2
-
3
- $installer = $this;
4
-
5
- $installer->startSetup();
6
-
7
- // Below based on http://stackoverflow.com/questions/9599262/magento-add-new-attribute-to-all-products
8
- // Incremented version to get this to run for existing users.
9
- $attrCode = 'commissioning_category';
10
-
11
- $objCatalogEavSetup = Mage::getResourceModel('catalog/eav_mysql4_setup', 'core_setup');
12
- $attrIdTest = $objCatalogEavSetup->getAttributeId(Mage_Catalog_Model_Product::ENTITY, $attrCode);
13
-
14
- if ($attrIdTest === false) {
15
- $objCatalogEavSetup->addAttribute(Mage_Catalog_Model_Product::ENTITY, $attrCode, array(
16
- 'group' => 'General',
17
- 'type' => 'int',
18
- 'backend' => '',
19
- 'frontend' => '',
20
- 'label' => 'Commissioning Category',
21
- 'note' => 'Category that will be used for affiliate sales. If not set, one of the categories assigned to this product will be chosen.',
22
- 'input' => 'select',
23
- 'class' => '',
24
- 'source' => 'eems_affiliate/product_attribute_source_commissioningCategory',
25
- 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
26
- 'visible' => true,
27
- 'required' => false,
28
- 'user_defined' => false,
29
- 'default' => null,
30
- 'visible_on_front' => false,
31
- 'unique' => false,
32
- 'is_configurable' => false,
33
- 'used_for_promo_rules' => false,
34
- 'apply_to' => 'simple,configurable,bundle,grouped',
35
- ));
36
- }
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ // Below based on http://stackoverflow.com/questions/9599262/magento-add-new-attribute-to-all-products
8
+ // Incremented version to get this to run for existing users.
9
+ $attrCode = 'commissioning_category';
10
+
11
+ $objCatalogEavSetup = Mage::getResourceModel('catalog/eav_mysql4_setup', 'core_setup');
12
+ $attrIdTest = $objCatalogEavSetup->getAttributeId(Mage_Catalog_Model_Product::ENTITY, $attrCode);
13
+
14
+ if ($attrIdTest === false) {
15
+ $objCatalogEavSetup->addAttribute(Mage_Catalog_Model_Product::ENTITY, $attrCode, array(
16
+ 'group' => 'General',
17
+ 'type' => 'int',
18
+ 'backend' => '',
19
+ 'frontend' => '',
20
+ 'label' => 'Commissioning Category',
21
+ 'note' => 'Category that will be used for affiliate sales. If not set, one of the categories assigned to this product will be chosen.',
22
+ 'input' => 'select',
23
+ 'class' => '',
24
+ 'source' => 'eems_affiliate/product_attribute_source_commissioningCategory',
25
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
26
+ 'visible' => true,
27
+ 'required' => false,
28
+ 'user_defined' => false,
29
+ 'default' => null,
30
+ 'visible_on_front' => false,
31
+ 'unique' => false,
32
+ 'is_configurable' => false,
33
+ 'used_for_promo_rules' => false,
34
+ 'apply_to' => 'simple,configurable,bundle,grouped',
35
+ ));
36
+ }
app/design/frontend/base/default/layout/eems_affiliate.xml CHANGED
@@ -1,35 +1,35 @@
1
- <?xml version="1.0" encoding="utf-8"?>
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
- <layout version="0.1.0">
17
- <default>
18
- <reference name="head">
19
- <block type="eems_affiliate/tracking" name="eems_affiliate.tracking" template="eems_affiliate/tracking.phtml"/>
20
- </reference>
21
- </default>
22
- <checkout_affiliate_success translate="label">
23
- <reference name="before_body_end">
24
- <block type="eems_affiliate/beacon" name="eems_affiliate.beacon" template="eems_affiliate/beacon.phtml"/>
25
- </reference>
26
- </checkout_affiliate_success>
27
- <checkout_multishipping_success translate="label">
28
- <label>Multishipping Checkout Success</label>
29
- <update handle="checkout_affiliate_success"/>
30
- </checkout_multishipping_success>
31
- <checkout_onepage_success translate="label">
32
- <label>Onepage Checkout Success</label>
33
- <update handle="checkout_affiliate_success"/>
34
- </checkout_onepage_success>
35
- </layout>
1
+ <?xml version="1.0" encoding="utf-8"?>
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
+ <layout version="0.1.0">
17
+ <default>
18
+ <reference name="head">
19
+ <block type="eems_affiliate/tracking" name="eems_affiliate.tracking" template="eems_affiliate/tracking.phtml"/>
20
+ </reference>
21
+ </default>
22
+ <checkout_affiliate_success translate="label">
23
+ <reference name="before_body_end">
24
+ <block type="eems_affiliate/beacon" name="eems_affiliate.beacon" template="eems_affiliate/beacon.phtml"/>
25
+ </reference>
26
+ </checkout_affiliate_success>
27
+ <checkout_multishipping_success translate="label">
28
+ <label>Multishipping Checkout Success</label>
29
+ <update handle="checkout_affiliate_success"/>
30
+ </checkout_multishipping_success>
31
+ <checkout_onepage_success translate="label">
32
+ <label>Onepage Checkout Success</label>
33
+ <update handle="checkout_affiliate_success"/>
34
+ </checkout_onepage_success>
35
+ </layout>
app/design/frontend/base/default/template/eems_affiliate/beacon.phtml ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
19
+ <?php if ($this->showBeacon()) :
20
+ ?>
21
+ <?php $beaconUrl = $this->getBeaconUrl(); ?>
22
+ <script>
23
+ (function (d,i) {
24
+ i=d.createElement('iframe');
25
+ i.width=i.height=1;
26
+ i.frameBorder=0;
27
+ i.src="<?php echo $beaconUrl; ?>";
28
+ d.body.appendChild(i);
29
+ }(document));
30
+ </script>
31
+ <noscript>
32
+ <iframe width="1" height="1" frameBorder="0" src="<?php echo $beaconUrl; ?>"></iframe>
33
+ </noscript>
34
+ <?php
35
+ endif;
app/design/frontend/base/default/template/eems_affiliate/tracking.phtml ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright (c) 2013-2014 eBay Enterprise, Inc.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.md.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * @copyright Copyright (c) 2013-2014 eBay Enterprise, Inc. (http://www.ebayenterprise.com/)
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ */
15
+ ?>
16
+
17
+ <?php if ($this->injectJavaScript()) :
18
+ ?>
19
+ <?php $keyName = $this->getQueryStringKeyName(); ?>
20
+ <?php $cookieName = $this->getCookieName(); ?>
21
+ <script type="text/javascript">
22
+ //<![CDATA[
23
+ (function (window, document, duration_in_days, key_name, cookie_name) {
24
+ var milliseconds_in_days = 1000 * 60 * 60 * 24;
25
+ var query = location.search.substring(1);
26
+ var source = findAffiliateField(query, key_name);
27
+ var cookie = getCookie(cookie_name);
28
+
29
+ if (source) {
30
+ // set or update the cookie with the value from the current query string
31
+ setCookie(cookie_name, source, duration_in_days);
32
+ }
33
+
34
+ /**
35
+ * @param cname name of the cookie
36
+ * @param cvalue value assigned to cookie
37
+ * @param exdays duration of the cookie in days
38
+ */
39
+ function setCookie(cname, cvalue, exdays)
40
+ {
41
+ var d = new Date();
42
+ d.setTime(d.getTime() + (exdays * milliseconds_in_days));
43
+ var expires = "expires="+d.toUTCString();
44
+ document.cookie = cname + "=" + cvalue + "; " + expires + "; path=/";
45
+ }
46
+
47
+ /**
48
+ * @param cname name of the cookie
49
+ * @returns object | null object with the field and value or null if not found
50
+ */
51
+ function getCookie(cname)
52
+ {
53
+ var cookies = document.cookie.split(';');
54
+ for (var i = 0; i < cookies.length; i++) {
55
+ var keyPair = cookies[i].split('=');
56
+ if (keyPair.length < 2)
57
+ continue;
58
+ var field = keyPair[0].trim();
59
+ var value = keyPair[1].trim();
60
+
61
+ if (field === cname) {
62
+ return {field: value};
63
+ }
64
+ }
65
+
66
+ return null;
67
+ }
68
+
69
+ /**
70
+ * @param query query string minus the '?'
71
+ * @param field query string field to search for
72
+ * @returns string | null value of the query string field or null if the field isn't there
73
+ */
74
+ function findAffiliateField(query, field)
75
+ {
76
+ if (!query) {
77
+ return null;
78
+ }
79
+
80
+ var fields = query.split("&");
81
+ for (var i = 0; i < fields.length; i++) {
82
+ var keyPair = fields[i].split("=");
83
+ if (
84
+ keyPair.length == 2 &&
85
+ keyPair[0] === field
86
+ ) {
87
+ return keyPair[1];
88
+ }
89
+ }
90
+
91
+ return null;
92
+ }
93
+ }(window, document, 365, "<?php echo $keyName ?>", "<?php echo $cookieName ?>"));
94
+ //]]>
95
+ </script>
96
+ <?php
97
+ endif;
app/etc/modules/EbayEnterprise_Affiliate.xml CHANGED
@@ -1,23 +1,23 @@
1
- <?xml version="1.0" encoding="utf-8"?>
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
- <config>
17
- <modules>
18
- <EbayEnterprise_Affiliate>
19
- <active>true</active>
20
- <codePool>community</codePool>
21
- </EbayEnterprise_Affiliate>
22
- </modules>
23
- </config>
1
+ <?xml version="1.0" encoding="utf-8"?>
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
+ <config>
17
+ <modules>
18
+ <EbayEnterprise_Affiliate>
19
+ <active>true</active>
20
+ <codePool>community</codePool>
21
+ </EbayEnterprise_Affiliate>
22
+ </modules>
23
+ </config>
package.xml CHANGED
@@ -1,19 +1,19 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>eBay_Enterprise_Affiliate_Extension</name>
4
- <version>1.2.1.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://assets.pepperjam.com/legal/magento-connect-extension-eula.pdf">EULA</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>Please use the uninstall button in the EEAN extension configuration settings. Using this uninstall method may cause issues after the extension is removed.</summary>
10
- <description>Please use the uninstall button in the EEAN extension configuration settings. Using this uninstall method may cause issues after the extension is removed.</description>
11
- <notes>1.2.1.0 Release Notes&#xD;
12
- Added uninstall button to prevent errors when using magento connect.</notes>
13
  <authors><author><name>Philip Preston</name><user>phpreston</user><email>phpreston@pepperjam.com</email></author></authors>
14
- <date>2016-05-11</date>
15
- <time>20:10:24</time>
16
- <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"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><file name="Button.php" hash="dd87ef3bb3e4defeca503a2d1561e643"/></dir></dir></dir></dir><file name="Beacon.php" hash="08a376ac6747bd459b1462670a2774fd"/><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="controllers"><dir name="Adminhtml"><file name="EemsAffiliateController.php" hash="47f3da6bae4814a397e05c01b3638f64"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="fccf9b602bb22175bfb81148cb216644"/><file name="config.xml" hash="ceba9f7bac5999a51b5ddd3948c63ee4"/><file name="system.xml" hash="d5b780f3a44df676a272217a84e9746a"/></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="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="eems_affiliate"><dir name="system"><dir name="config"><file name="button.phtml" hash="3dc15ce1d9a1e974d52cc33adf961156"/></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="eems_affiliate.xml" hash="7d0b7b9a18086a9a61099a753d82f4fc"/></dir></dir></dir></dir></target></contents>
17
  <compatible/>
18
- <dependencies><required><php><min>5.2.0</min><max>5.99.99</max></php></required></dependencies>
19
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>eBay_Enterprise_Affiliate_Extension</name>
4
+ <version>1.2.1.1</version>
5
  <stability>stable</stability>
6
  <license uri="http://assets.pepperjam.com/legal/magento-connect-extension-eula.pdf">EULA</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>Please use the uninstall button in the EEAN extension configuration settings. Using this uninstall method may cause issues after the extension is removed.</summary>
10
+ <description>Please use the uninstall button in the EEAN extension configuration settings. Using this uninstall method may cause issues after the extension is removed.</description>
11
+ <notes>Changelog for 1.2.1.1&#xD;
12
+ Products without all required data will no longer be included in the product feed</notes>
13
  <authors><author><name>Philip Preston</name><user>phpreston</user><email>phpreston@pepperjam.com</email></author></authors>
14
+ <date>2016-07-27</date>
15
+ <time>21:35:18</time>
16
+ <contents><target name="mageetc"><dir name="modules"><file name="EbayEnterprise_Affiliate.xml" hash="2e042a1fa299f755a00bc041363eae18"/></dir></target><target name="magecommunity"><dir name="EbayEnterprise"><dir name="Affiliate"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><file name="Button.php" hash="ebf82ff2a79012e78066c2be78862836"/></dir></dir></dir></dir><file name="Beacon.php" hash="7d0d859b1f13787371d082192849c445"/><file name="Tracking.php" hash="e9d6eaf93beb55e8fe94330ea8dd32f5"/></dir><dir name="Exception"><file name="Configuration.php" hash="8d36de47ddbbbc2748b26d0bb572b23d"/></dir><dir name="Helper"><file name="Config.php" hash="c72c510ba39e03420c19140048e316ad"/><file name="Data.php" hash="24b2911d4442a51ada7a417961b25ad2"/><dir name="Map"><file name="Order.php" hash="7fcb6b4523e716b51b24f9ff0f739b36"/><file name="Product.php" hash="777c9aa86b7c90dc5e1e2ca32b1050e4"/></dir><file name="Map.php" hash="0bec79c51fe3be0556289e083a12418c"/></dir><dir name="Model"><dir name="Feed"><file name="Abstract.php" hash="735f23ef1963c066fa654cbedcf206d5"/><dir name="Order"><file name="Abstract.php" hash="c8d99f43441777379360e3ef8372e620"/><file name="Basic.php" hash="e790d9af4e74c9ab0ab880e4a41e0221"/><file name="Dynamic.php" hash="d80d91fcdc4e01d677a3a5c0adf2be22"/><file name="Itemized.php" hash="d6ea137e59a3bf13a6622eae2a418039"/></dir><file name="Product.php" hash="d3e45a705ddf5e0535449ac152b4a205"/></dir><file name="Observer.php" hash="f1b5d52b0345d8dbfda4de31e73c17ec"/><dir name="Product"><dir name="Attribute"><dir name="Source"><file name="CommissioningCategory.php" hash="c7fd762c53a3050920baca192adddb8e"/></dir></dir></dir><dir name="System"><dir name="Config"><dir name="Source"><file name="Attributes.php" hash="ed651780a471391e30d08811e10e7fe9"/><file name="Categories.php" hash="370906fa2ceb4c9b9ca581f89f135242"/><file name="Ordertypes.php" hash="a807a0964b5b9a6abc55af6791d4bc46"/><file name="Stockquantity.php" hash="b10584a5c6138baab0411c767920e82e"/><file name="Stockyesno.php" hash="43d33662c41f0f87f6870e1599f243c7"/><file name="Transactiontype.php" hash="1a49a75e2c92a68783d1509863de27f5"/><file name="Visibilityyesno.php" hash="1acf5b88eb0ef6d96302ab77325a89b7"/></dir></dir></dir></dir><dir name="Test"><dir name="Block"><file name="BeaconTest.php" hash="8cc4e0f43aace8033087ee81162931a4"/><dir name="providers"><file name="testShowBeacon.yaml" hash="3a605cb51a86987f318ce4186d80e04f"/></dir></dir><dir name="Helper"><file name="DataTest.php" hash="9bbbae7ffecb6034b6e3b855f0da3679"/><dir name="Map"><file name="ProductTest.php" hash="08e98dbbb660d0b766245c429e0ed076"/></dir><dir name="providers"><file name="testIsValidCookie.yaml" hash="2fcd588d55fe4c265c3205a7d4e808af"/></dir></dir><dir name="Model"><dir name="Feed"><file name="AbstractTest.php" hash="2c8da139165c9c66d66cf2301eeae7f2"/><dir name="Order"><file name="AbstractTest.php" hash="96d781fcb1f74ebae90f836f9f0580c3"/><file name="BasicTest.php" hash="577de16b9d4757eb3b9a03a5af7e2330"/><file name="ItemizedTest.php" hash="945d883350e9e22805f1f64e732ad28c"/></dir><file name="ProductTest.php" hash="02dd62b39a9e95229b0aa84ff6859587"/></dir><file name="ObserverTest.php" hash="010b83986ebb5298f680b70c2ff3cedc"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="EemsAffiliateController.php" hash="cedc56e322f5f06d278d602b1db4c72d"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="381ec621ea61e0880c7b137d097f879f"/><file name="config.xml" hash="96c2454c8d336c634fd62a1702652679"/><file name="system.xml" hash="d5b780f3a44df676a272217a84e9746a"/></dir><dir name="sql"><dir name="eems_affiliate_setup"><file name="install-1.0.0.1.php" hash="f98e9282dcb282d9c29731c513344770"/><file name="mysql4-install-1.0.0.1.php" hash="f98e9282dcb282d9c29731c513344770"/><file name="mysql4-upgrade-1.0.0.1-1.2.0.0.php" hash="ba4c4aaada71919d773753975b6dfa1d"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="eems_affiliate"><dir name="system"><dir name="config"><file name="button.phtml" hash="3dc15ce1d9a1e974d52cc33adf961156"/></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="eems_affiliate.xml" hash="e96799839e29ae63b38963fc84377c85"/></dir><dir name="template"><dir name="eems_affiliate"><file name="beacon.phtml" hash="aa060dc4dbe6c7fcdee2893fed634c59"/><file name="tracking.phtml" hash="3479f24c4666c59fc29b46ea0a06abad"/></dir></dir></dir></dir></dir></target></contents>
17
  <compatible/>
18
+ <dependencies><required><php><min>5.3.0</min><max>5.6.99</max></php></required></dependencies>
19
  </package>