eBay_Enterprise_Affiliate_Extension - Version 1.0.1

Version Notes

Use discounted amounts for order totals.

Download this release

Release Info

Developer Michael A. Smith
Extension eBay_Enterprise_Affiliate_Extension
Version 1.0.1
Comparing to
See all releases


Code changes from version 1.0.0 to 1.0.1

app/code/community/EbayEnterprise/Affiliate/Block/Beacon.php CHANGED
@@ -92,7 +92,7 @@ class EbayEnterprise_Affiliate_Block_Beacon extends Mage_Core_Block_Template
92
  protected function _buildBasicParams(Mage_Sales_Model_Order $order)
93
  {
94
  return array_merge($this->_buildCommonParams($order), array(
95
- static::KEY_AMOUNT => round($order->getSubtotal(), 2),
96
  static::KEY_TYPE => Mage::helper('eems_affiliate/config')->getTransactionType()
97
  ));
98
  }
@@ -105,21 +105,31 @@ class EbayEnterprise_Affiliate_Block_Beacon extends Mage_Core_Block_Template
105
  {
106
  $params = array(static::KEY_INT => Mage::helper('eems_affiliate/config')->getInt());
107
  $increment = 1; // incrementer for the unique item keys
108
- foreach ($order->getAllVisibleItems() as $item) {
 
 
109
  $position = $this->_getDupePosition($params, $item);
110
- $quantity = (int) $item->getQtyOrdered();
111
- $total = round($item->getRowTotal(), 2);
 
 
 
 
 
 
 
112
  if ($position) {
113
  // we detected that the current item already exist in the params array
114
  // and have the key increment position let's simply adjust
115
  // the qty and total amount
116
  $params[static::KEY_QTY . $position] += $quantity;
117
- $params[static::KEY_TOTALAMOUNT . $position] += $total;
 
118
  } else {
119
  $params = array_merge($params, array(
120
  static::KEY_ITEM . $increment => $item->getSku(),
121
  static::KEY_QTY . $increment => $quantity,
122
- static::KEY_TOTALAMOUNT . $increment => $total
123
  ));
124
  $increment++; // only get incremented when a unique key have been appended
125
  }
92
  protected function _buildBasicParams(Mage_Sales_Model_Order $order)
93
  {
94
  return array_merge($this->_buildCommonParams($order), array(
95
+ static::KEY_AMOUNT => number_format($order->getSubtotal() + $order->getDiscountAmount() + $order->getShippingDiscountAmount(), 2, '.', ''),
96
  static::KEY_TYPE => Mage::helper('eems_affiliate/config')->getTransactionType()
97
  ));
98
  }
105
  {
106
  $params = array(static::KEY_INT => Mage::helper('eems_affiliate/config')->getInt());
107
  $increment = 1; // incrementer for the unique item keys
108
+ foreach ($order->getAllItems() as $item) {
109
+ // need to ignore the bundle parent as it will contain collected total
110
+ // for children but not discounts
111
  $position = $this->_getDupePosition($params, $item);
112
+ // ignore the parent configurable quantity - quantity of config products
113
+ // will come from the simple used product with the same SKU
114
+ $quantity = $item->getProductType() === Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE ?
115
+ 0 : (int) $item->getQtyOrdered();
116
+ // consider parent bundle products to be 0.00 total - total of the bundle
117
+ // is the sum of all child products which are also included in the beacon
118
+ // so including both totals would effectively double the price of the bundle
119
+ $total = $item->getProductType() === Mage_Catalog_Model_Product_Type::TYPE_BUNDLE ?
120
+ 0.00 : $item->getRowTotal() - $item->getDiscountAmount();
121
  if ($position) {
122
  // we detected that the current item already exist in the params array
123
  // and have the key increment position let's simply adjust
124
  // the qty and total amount
125
  $params[static::KEY_QTY . $position] += $quantity;
126
+ $amtKey = static::KEY_TOTALAMOUNT . $position;
127
+ $params[$amtKey] = number_format($params[$amtKey] + $total, 2, '.', '');
128
  } else {
129
  $params = array_merge($params, array(
130
  static::KEY_ITEM . $increment => $item->getSku(),
131
  static::KEY_QTY . $increment => $quantity,
132
+ static::KEY_TOTALAMOUNT . $increment => number_format($total, 2, '.', ''),
133
  ));
134
  $increment++; // only get incremented when a unique key have been appended
135
  }
app/code/community/EbayEnterprise/Affiliate/Helper/Map/Order.php CHANGED
@@ -32,6 +32,25 @@ class EbayEnterprise_Affiliate_Helper_Map_Order
32
  // field limit doesn't allow this to go above 99
33
  return (int) ($item->getQtyOrdered() - $item->getQtyRefunded() - $item->getQtyCanceled());
34
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  /**
36
  * Get the corrected total for the row - price * corrected qty. Expects the
37
  * "item" to be a Mage_Sales_Model_Order_Item, "format" to be a valid
@@ -49,7 +68,7 @@ class EbayEnterprise_Affiliate_Helper_Map_Order
49
  }
50
  return sprintf(
51
  $params['format'],
52
- $params['item']->getBasePrice() * $this->getItemQuantity($params)
53
  );
54
  }
55
  /**
@@ -69,7 +88,13 @@ class EbayEnterprise_Affiliate_Helper_Map_Order
69
  $order = $params['item'];
70
  return sprintf(
71
  $params['format'],
72
- $order->getBaseSubtotal() - $order->getBaseSubtotalRefunded() - $order->getBaseSubtotalCanceled()
 
 
 
 
 
 
73
  );
74
  }
75
  /**
32
  // field limit doesn't allow this to go above 99
33
  return (int) ($item->getQtyOrdered() - $item->getQtyRefunded() - $item->getQtyCanceled());
34
  }
35
+ /**
36
+ * Calculate a row total including discounts.
37
+ * @param array $params
38
+ * @return float
39
+ */
40
+ private function _calculateDiscountedRowTotal($params)
41
+ {
42
+ $item = $params['item'];
43
+ // tread bundle items as 0.00 total as their total will be represented by
44
+ // the total of their children products
45
+ if ($item->getProductType() === Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {
46
+ return 0.00;
47
+ }
48
+ // don't allow negative amounts - could happen if a discounted item was cancelled
49
+ return max(
50
+ 0,
51
+ $item->getBasePrice() * $this->getItemQuantity($params) - ($item->getBaseDiscountAmount() - $item->getbaseDiscountRefunded())
52
+ );
53
+ }
54
  /**
55
  * Get the corrected total for the row - price * corrected qty. Expects the
56
  * "item" to be a Mage_Sales_Model_Order_Item, "format" to be a valid
68
  }
69
  return sprintf(
70
  $params['format'],
71
+ $this->_calculateDiscountedRowTotal($params)
72
  );
73
  }
74
  /**
88
  $order = $params['item'];
89
  return sprintf(
90
  $params['format'],
91
+ // prevent sub-zero amounts for canceled orders with discounts
92
+ max(
93
+ 0,
94
+ ($order->getBaseSubtotal() + $order->getBaseDiscountAmount()) -
95
+ ($order->getBaseSubtotalRefunded() + $order->getBaseDiscountRefunded()) -
96
+ ($order->getBaseSubtotalCanceled() + $order->getBaseDiscountCanceled())
97
+ )
98
  );
99
  }
100
  /**
app/code/community/EbayEnterprise/Affiliate/Model/Feed/Order/Itemized.php CHANGED
@@ -28,7 +28,9 @@ class EbayEnterprise_Affiliate_Model_Feed_Order_Itemized
28
  // this is far more pure SQL than should be here but I don't see a way to
29
  // get the proper groupings of where clauses without doing this
30
  ->where(
31
- 'main_table.store_id IN (?) AND main_table.parent_item_id IS NULL', $storeIds
 
 
32
  )
33
  ->where(
34
  "(o.original_increment_id IS NOT NULL AND o.created_at >= :lastRunTime AND o.created_at < :startTime) OR " .
28
  // this is far more pure SQL than should be here but I don't see a way to
29
  // get the proper groupings of where clauses without doing this
30
  ->where(
31
+ // get only items within the correct store scope and filter out any
32
+ // configurable used simple products
33
+ '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)', $storeIds
34
  )
35
  ->where(
36
  "(o.original_increment_id IS NOT NULL AND o.created_at >= :lastRunTime AND o.created_at < :startTime) OR " .
package.xml CHANGED
@@ -1,50 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>eBay_Enterprise_Affiliate_Extension</name>
4
- <version>1.0.0</version>
5
  <stability>stable</stability>
6
- <license uri="http://www.ebayenterprise.com/files/pdf/Magento_Connect_Extensions_EULA_050714.pdf">eBay Enterprise Magento Extensions End User License Agreement</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>Connect with 200+ affiliate publishers, generate reports, expand customer outreach, and drive sales.</summary>
10
- <description>&lt;p&gt;Launching an affiliate marketing program has never been easier. With the eBay Enterprise Affiliate Extension, you can start driving traffic and revenue right now. The extension empowers merchants with:&lt;p /&gt;&#xD;
11
- &lt;ol&gt;&#xD;
12
- &lt;li&gt;Automated integration and on-boarding&lt;/li&gt;&#xD;
13
- &lt;li&gt;Easy-to-use tracking integration&lt;/li&gt;&#xD;
14
- &lt;li&gt;Ability to track and record affiliate sales and conversions&lt;/li&gt;&#xD;
15
- &lt;li&gt;Flexible configuration&lt;/li&gt;&#xD;
16
- &lt;li&gt;Product feed export automated nightly in eBay Enterprise Affiliate format&lt;/li&gt;&#xD;
17
- &lt;li&gt;Correction feed automated nightly in eBay Enterprise Affiliate format&lt;/li&gt;&#xD;
18
- &lt;/ol&gt;&#xD;
19
- &lt;p /&gt;With the eBay Enterprise Affiliate Extension tracking in place, you&#x2019;ll gain instant access to the program&#x2019;s user-friendly interface&#x2014;along with the tracking technology, informative analytics, and innovative applications you need to expand your online presence.&lt;/p&gt;&#xD;
20
- &lt;p&gt;What makes eBay&#x2019;s affiliate program different from all the others? Good question. Here are some of our program&#x2019;s exclusive features:&lt;/p&gt;&#xD;
21
- &lt;h2&gt;Do it all in one place&lt;/h2&gt;&#xD;
22
- &lt;p&gt;With eBay Enterprise Affiliate, you can access and recruit over 200,000 active network publishers across 20+ promotional categories and 30+ verticals. Plus, you can manage your publisher&#x2019;s terms, commissions, corrections, and bonuses&#x2014;without reloading the page.&lt;/p&gt;&#xD;
23
- &lt;h2&gt;Banners for your benefit&lt;/h2&gt;&#xD;
24
- &lt;p&gt;You can easily upload banners and text links to drive traffic to new product lines. Plus, you can promote offers like free shipping, coupons, and percentage-off discounts.&lt;/p&gt;&#xD;
25
- &lt;h2&gt;Stay in touch, easily&lt;/h2&gt;&#xD;
26
- &lt;p&gt;Communication is key, so we&#x2019;ve made reaching out to affiliates as simple as possible. Our affiliate program comes complete with a newsletter subscription and a built-in email feature. You&#x2019;ll enjoy easy, effective communication with your top publishers.&lt;/p&gt;&#xD;
27
- &lt;h2&gt;Track your progress&lt;/h2&gt;&#xD;
28
- &lt;p&gt;eBay Enterprise Affiliate really works&#x2014;and you can track it yourself. Monitor robust reports, including transaction summaries, commission totals, and link performances. Then use the data to optimize your program.&lt;/p&gt;&#xD;
29
- &lt;h2&gt;Stay socially connected&lt;/h2&gt;&#xD;
30
- &lt;p&gt;Leverage your most loyal customers and brand advocates while driving commerce. Our program&#x2019;s private-label peer platform makes it easy to share products and special promotions via Facebook, Twitter, and email.&lt;/p&gt;&#xD;
31
- &lt;h2&gt;Enjoy unparalleled support&lt;/h2&gt;&#xD;
32
- &lt;p&gt;If you have questions, problems, or difficulties with your account, simply click the customer support tab to submit a ticket. The request will be sent straight to qualified eBay Enterprise Affiliate customer service representatives, and they&#x2019;ll respond immediately.&lt;/p&gt;&#xD;
33
- &lt;h2&gt;How to get started:&lt;/h2&gt;&#xD;
34
- &lt;ol&gt;&#xD;
35
- &lt;li&gt;Install extension from the Magento Connect store&lt;/li&gt;&#xD;
36
- &lt;li&gt;Under System Configuration, you&#x2019;ll find eBay Enterprise Marketing Solutions on the left hand navigation pane. Click to begin Affiliate installation.&lt;/li&gt;&#xD;
37
- &lt;li&gt;Select &#x201C;Yes&#x201D; to enable Affiliate tracking.&lt;/li&gt;&#xD;
38
- &lt;li&gt;Insert your unique Program ID (PID) into the extension. If you do not yet have a PID, click on the &#x201C;Register Now&#x201D; link to register for an account.&lt;/li&gt;&#xD;
39
- &lt;li&gt;Select &#x201C;Yes&#x201D; for itemized orders, unless otherwise instructed.&lt;/li&gt;&#xD;
40
- &lt;li&gt;Set export path to a directory accessible via FTP.&lt;/li&gt;&#xD;
41
- &lt;li&gt;Place test transaction to confirm installation.&lt;/li&gt;&#xD;
42
- &lt;/ol&gt;</description>
43
- <notes>First Release</notes>
44
- <authors><author><name>Michael A. Smith</name><user>kojiro</user><email>msmith3@ebay.com</email></author><author><name>Scott van Brug</name><user>scottvanbrug</user><email>svanbrug@ebay.com</email></author><author><name>Michael West</name><user>MikeWest</user><email>micwest@ebay.com</email></author><author><name>Michael Phang</name><user>mphang6432</user><email>mphang@ebay.com</email></author><author><name>Adam Hobson</name><user>adhobson</user><email>adhobson@ebay.com</email></author><author><name>Reginald Gabriel</name><user>rgabriel</user><email>rgabriel@ebay.com</email></author></authors>
45
- <date>2014-05-09</date>
46
- <time>19:30:37</time>
47
- <contents><target name="mageetc"><dir name="modules"><file name="EbayEnterprise_Affiliate.xml" hash="c3a7b9a2113ad859d20cea7e452a3982"/></dir></target><target name="magecommunity"><dir name="EbayEnterprise"><dir name="Affiliate"><dir name="Block"><file name="Beacon.php" hash="e14207b9ce4aceec578d6be1b929e1fe"/></dir><dir name="Exception"><file name="Configuration.php" hash="65542b125d2ead6007353db0ee1c6885"/></dir><dir name="Helper"><file name="Config.php" hash="ac3fc4ad23d9eb7c643b9fa03470df92"/><file name="Data.php" hash="49e35c3ef95dcc1abc0082569a559c70"/><dir name="Map"><file name="Order.php" hash="edd9946b73e0fbe21b6715748334d0de"/><file name="Product.php" hash="97444501356a60bcc423cba6c457337c"/></dir><file name="Map.php" hash="d266381ad5dff9c4d774afc3a6bb14d9"/></dir><dir name="Model"><dir name="Feed"><file name="Abstract.php" hash="ed4bcacbc43af20d68f9aa66d055de2c"/><dir name="Order"><file name="Abstract.php" hash="842e746eb3d049d2112b130dc3e465da"/><file name="Basic.php" hash="4cdd308dd1209052934be1c1cf5bb8ed"/><file name="Itemized.php" hash="f6c510a28381cfdb9760fdddb7581b0f"/></dir><file name="Product.php" hash="9828991bccc6ec34a6c4632dd47ea70c"/></dir><file name="Observer.php" hash="3e7022180266d5e6c54b9945d1f3a7a3"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Attributes.php" hash="4bf9ee9194e49a5a5790f9e319afd4fa"/><file name="Categories.php" hash="4d7ce8590af1007d0478166268953628"/><file name="Stockquantity.php" hash="e0ae4a9f912c54e0e031d1787c01a082"/><file name="Stockyesno.php" hash="951ce3efa1d8c665a57b888b8aaced52"/><file name="Transactiontype.php" hash="c5e692ee61ae43b4ba4906dba8882286"/><file name="Visibilityyesno.php" hash="fd36e0f36e740ade056d3bab6798cdab"/></dir></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="d0477ee491b0d801bec3776a9d973b53"/><file name="config.xml" hash="7285f83ecd87c5964c993812d8ad05a0"/><file name="system.xml" hash="81cddbe43ec09285b07bde7e5a215130"/></dir><dir name="sql"><dir name="eems_affiliate_setup"><file name="install-1.0.0.1.php" hash="2c49a4637831affbce446f997e07efe7"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="eems_affiliate"><file name="beacon.phtml" hash="73aabddbd2bf4cb81927e69290abc59f"/></dir></dir><dir name="layout"><file name="eems_affiliate.xml" hash="db291e14f3ddf8e9364357b477627d67"/></dir></dir></dir></dir></target></contents>
48
  <compatible/>
49
  <dependencies><required><php><min>5.3.0</min><max>5.3.99</max></php></required></dependencies>
50
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>eBay_Enterprise_Affiliate_Extension</name>
4
+ <version>1.0.1</version>
5
  <stability>stable</stability>
6
+ <license>EULA</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>eBay Enterprise Affiliate Extension.</summary>
10
+ <description>eBay Enterprise Affiliate Extension.</description>
11
+ <notes>Use discounted amounts for order totals.</notes>
12
+ <authors><author><name>Michael A. Smith</name><user>msmith3</user><email>msmith3@ebay.com</email></author><author><name>Michael Phang</name><user>mphang</user><email>mphang@ebay.com</email></author><author><name>Scott van Brug</name><user>svanbrug</user><email>svanbrug@ebay.com</email></author><author><name>Mike West</name><user>micwest</user><email>micwest@ebay.com</email></author><author><name>Reginald Gabriel</name><user>rgabriel</user><email>rgabriel@ebay.com</email></author></authors>
13
+ <date>2014-05-20</date>
14
+ <time>20:16:10</time>
15
+ <contents><target name="magecommunity"><dir name="EbayEnterprise"><dir name="Affiliate"><dir name="Block"><file name="Beacon.php" hash="71e559204118de2d2cd865ed3066901e"/></dir><dir name="Exception"><file name="Configuration.php" hash="65542b125d2ead6007353db0ee1c6885"/></dir><dir name="Helper"><file name="Config.php" hash="ac3fc4ad23d9eb7c643b9fa03470df92"/><file name="Data.php" hash="49e35c3ef95dcc1abc0082569a559c70"/><dir name="Map"><file name="Order.php" hash="e22c43240fe1b9a4acce75c356c07ce2"/><file name="Product.php" hash="97444501356a60bcc423cba6c457337c"/></dir><file name="Map.php" hash="d266381ad5dff9c4d774afc3a6bb14d9"/></dir><dir name="Model"><dir name="Feed"><file name="Abstract.php" hash="ed4bcacbc43af20d68f9aa66d055de2c"/><dir name="Order"><file name="Abstract.php" hash="842e746eb3d049d2112b130dc3e465da"/><file name="Basic.php" hash="4cdd308dd1209052934be1c1cf5bb8ed"/><file name="Itemized.php" hash="a546060ab5fbbafc1091d64578e25e99"/></dir><file name="Product.php" hash="9828991bccc6ec34a6c4632dd47ea70c"/></dir><file name="Observer.php" hash="3e7022180266d5e6c54b9945d1f3a7a3"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Attributes.php" hash="4bf9ee9194e49a5a5790f9e319afd4fa"/><file name="Categories.php" hash="4d7ce8590af1007d0478166268953628"/><file name="Stockquantity.php" hash="e0ae4a9f912c54e0e031d1787c01a082"/><file name="Stockyesno.php" hash="951ce3efa1d8c665a57b888b8aaced52"/><file name="Transactiontype.php" hash="c5e692ee61ae43b4ba4906dba8882286"/><file name="Visibilityyesno.php" hash="fd36e0f36e740ade056d3bab6798cdab"/></dir></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="d0477ee491b0d801bec3776a9d973b53"/><file name="config.xml" hash="7285f83ecd87c5964c993812d8ad05a0"/><file name="system.xml" hash="81cddbe43ec09285b07bde7e5a215130"/></dir><dir name="sql"><dir name="eems_affiliate_setup"><file name="install-1.0.0.1.php" hash="2c49a4637831affbce446f997e07efe7"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="eems_affiliate.xml" hash="db291e14f3ddf8e9364357b477627d67"/></dir><dir name="template"><dir name="eems_affiliate"><file name="beacon.phtml" hash="73aabddbd2bf4cb81927e69290abc59f"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="EbayEnterprise_Affiliate.xml" hash="c3a7b9a2113ad859d20cea7e452a3982"/></dir></target></contents>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  <compatible/>
17
  <dependencies><required><php><min>5.3.0</min><max>5.3.99</max></php></required></dependencies>
18
  </package>