eBay_Enterprise_Display_Extension - Version 1.0.2

Version Notes

DE1411 Fix missing package file

Download this release

Release Info

Developer Michael A. Smith
Extension eBay_Enterprise_Display_Extension
Version 1.0.2
Comparing to
See all releases


Code changes from version 1.0.1 to 1.0.2

app/code/community/EbayEnterprise/Display/Block/Beacon.php ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class EbayEnterprise_Display_Block_Beacon extends Mage_Core_Block_Template
3
+ {
4
+ protected $_order; // The order
5
+
6
+ /**
7
+ * Get the last order.
8
+ * @return Mage_Sales_Model_Order
9
+ */
10
+ protected function _getOrder()
11
+ {
12
+ if (!($this->_order instanceof Mage_Sales_Model_Order)) {
13
+ $orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
14
+ if ($orderId) {
15
+ $this->_order = Mage::getModel('sales/order')->load($orderId);
16
+ }
17
+ }
18
+ return $this->_order;
19
+ }
20
+ /**
21
+ * Get the current customer quote
22
+ * @return Mage_Sales_Model_Quote
23
+ */
24
+ protected function _getQuote()
25
+ {
26
+ if (!($this->_quote instanceof Mage_Sales_Model_Quote)) {
27
+ $this->_quote = Mage::getSingleton('checkout/session')->getQuote();
28
+ }
29
+ return $this->_quote;
30
+ }
31
+ /**
32
+ * Load a Quote object from an Order object
33
+ * @param Mage_Sales_Model_Order $order
34
+ * @return Mage_Sales_Model_Quote
35
+ */
36
+ protected function _getQuoteFromOrder($order)
37
+ {
38
+ if (!($this->_quote instanceof Mage_Sales_Model_Quote)) {
39
+ $this->_quote = Mage::getModel('sales/quote')->load($order->getQuoteId());
40
+ }
41
+ return $this->_quote;
42
+ }
43
+ /**
44
+ * Get the current request scheme
45
+ * @return string
46
+ */
47
+ protected function _getRequestScheme()
48
+ {
49
+ return Mage::app()->getRequest()->getScheme();
50
+ }
51
+ /**
52
+ * Determine which type of page the user is on
53
+ * default, home, product, checkout thanks
54
+ *
55
+ * @return string
56
+ */
57
+ public function getPageType()
58
+ {
59
+ if ($this->hasData('page_type')) {
60
+ return $this->getData('page_type');
61
+ } else {
62
+ return 'default';
63
+ }
64
+ }
65
+ /**
66
+ * Get Fetchback beacon params based on the page type
67
+ */
68
+ protected function _getParamsByPageType()
69
+ {
70
+ $pageType = $this->getPageType();
71
+ switch ($pageType) {
72
+ case 'product':
73
+ return $this->_getProductParams();
74
+ case 'cart':
75
+ return $this->_getCartParams();
76
+ case 'checkout_success':
77
+ return $this->_getCheckoutSuccessParams();
78
+ default:
79
+ return $this->_getDefaultParams();
80
+ }
81
+ }
82
+ /**
83
+ * Default params for beacon on all pages
84
+ */
85
+ protected function _getDefaultParams()
86
+ {
87
+ return array(
88
+ 'cat' => '',
89
+ 'sid' => $this->helper('eems_display/config')->getSiteId(Mage::app()->getStore()->getId()),
90
+ 'name' => 'landing',
91
+ );
92
+ }
93
+ /**
94
+ * Get the params for product page
95
+ * @return array
96
+ */
97
+ protected function _getProductParams()
98
+ {
99
+ $currentProductId = (int) $this->getRequest()->getParam('id');
100
+ $mageProduct = Mage::getModel('catalog/product')->load($currentProductId);
101
+ return array_merge($this->_getDefaultParams(), array(
102
+ 'name' => 'landing',
103
+ 'browse_products' => $mageProduct->getSku(),
104
+ ));
105
+ }
106
+ /**
107
+ * Get the params for cart page
108
+ * @return array
109
+ */
110
+ protected function _getCartParams()
111
+ {
112
+ $quote = $this->_getQuote();
113
+ $params = $this->_getDefaultParams();
114
+ if ($quote instanceof Mage_Sales_Model_Quote) {
115
+ $cartedProducts = array_reduce($quote->getAllVisibleItems(), array($this, '_pidListFromCollection'));
116
+ $params = array_merge($params, array(
117
+ 'abandon_products' => $cartedProducts,
118
+ ));
119
+ }
120
+ return $params;
121
+ }
122
+ /**
123
+ * Get the params for checkout thanks page
124
+ * @return array
125
+ */
126
+ protected function _getCheckoutSuccessParams()
127
+ {
128
+ $params = $this->_getDefaultParams();
129
+ $order = $this->_getOrder();
130
+ if ($order instanceof Mage_Sales_Model_Order) {
131
+ $quote = $this->_getQuoteFromOrder($order);
132
+ $orderTotal = $quote->getSubtotalWithDiscount();
133
+ $purchasedProducts = array_reduce($order->getAllVisibleItems(), array($this, '_pidListFromCollection'));
134
+ $params = array_merge($params, array(
135
+ 'name' => 'success',
136
+ 'purchase_products' => $purchasedProducts,
137
+ 'crv' => $orderTotal,
138
+ 'oid' => $order->getIncrementId(),
139
+ ));
140
+ }
141
+ return $params;
142
+ }
143
+ /**
144
+ * array_reduce callback to get comma separated list of product ids
145
+ * @param string $result
146
+ * @param Mage_Sales_Model_Quote_Item|Mage_Sales_Model_Order_Item $item
147
+ * @return string
148
+ */
149
+ protected function _pidListFromCollection($result, $item)
150
+ {
151
+ $productId = $item->getSku();
152
+ $result .= (empty($result) ? '' : ',') . $productId;
153
+ return $result;
154
+ }
155
+ /**
156
+ * Get the beacon url.
157
+ * @return String
158
+ */
159
+ public function getBeaconUrl()
160
+ {
161
+ $params = $this->_getParamsByPageType();
162
+ $url = $this->_getRequestScheme() . '://pixel.fetchback.com/serve/fb/pdj?' . http_build_query($params);
163
+ return $url;
164
+ }
165
+ /**
166
+ * Whether or not to display the beacon.
167
+ */
168
+ public function showBeacon()
169
+ {
170
+ return Mage::helper('eems_display/config')->getIsEnabled(Mage::app()->getStore()->getId());
171
+ }
172
+ }
package.xml CHANGED
@@ -1,20 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>eBay_Enterprise_Display_Extension</name>
4
- <version>1.0.1</version>
5
  <stability>stable</stability>
6
  <license>OSL</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>eBay Enterprise Display Extension.</summary>
10
  <description>eBay Enterprise Display Extension.</description>
11
- <notes>Merge pull request #12 from micwest/DE1388_fix_inconsistent_const_references&#xD;
12
- DE1388 Fix Inconsistent Const References&#xD;
13
- US11653 Rename Extension Package Name</notes>
14
  <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>
15
- <date>2014-05-23</date>
16
- <time>20:32:19</time>
17
- <contents><target name="magecommunity"><dir name="EbayEnterprise"><dir name="Display"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Feedurl.php" hash="82241e7e509b9c27dc734c8728e501f5"/></dir></dir></dir></dir></dir></dir><dir name="controllers"><file name="IndexController.php" hash="197cb073d339eb76e6dbcf2167107a93"/></dir><dir name="etc"><file name="adminhtml.xml" hash="e1208b50586829c2e6c6536dd062ef0c"/><file name="config.xml" hash="5c8237485eb9c7c77fea466e26f41bd9"/><file name="system.xml" hash="55731b868ba01e966120cd53235b4407"/></dir><dir name="Helper"><file name="Config.php" hash="f831ae412417e253a57f37d6d3423e50"/><file name="Data.php" hash="3a5312fe107714d34267c72ce2910f40"/></dir><dir name="Model"><file name="Email.php" hash="2252c80035c9515650cd49e2c52e3645"/><file name="Products.php" hash="63129b2a0bd7f790ffbd96473c7d2c31"/><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Backend"><file name="Feedurl.php" hash="aa1810a7c67e0b35e732ff5155f81a6b"/><file name="Siteidchecksum.php" hash="f72b7dc6d0294faafcfc51e8ec46a222"/></dir></dir></dir></dir><dir name="Error"><file name="Exception.php" hash="65df9f687c4746431f9316baca3b5495"/></dir></dir><dir name="sql"><dir name="eemsdisplay_setup"><file name="install-1.0.0.0.php" hash="a9c02c7e94cdad9965ffa62571276ba2"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="eems_display.xml" hash="7f823afa4c46cc316e198d5ff80eaa6b"/></dir><dir name="template"><dir name="eems_display"><file name="beacon.phtml" hash="4937e1a21b75f436b6a013fdcea59be9"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="EbayEnterprise_Display.xml" hash="ae74ae5088d96d6300c544a031d4c0c6"/></dir></target><target name="magelocale"><dir name="en_US"><dir name="template"><dir name="email"><file name="eemsdisplay_installed.html" hash="609fa6fc13a7a3f444bd0c256e207e7f"/></dir></dir></dir></target></contents>
18
  <compatible/>
19
  <dependencies><required><php><min>5.3.0</min><max>5.3.99</max></php></required></dependencies>
20
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>eBay_Enterprise_Display_Extension</name>
4
+ <version>1.0.2</version>
5
  <stability>stable</stability>
6
  <license>OSL</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>eBay Enterprise Display Extension.</summary>
10
  <description>eBay Enterprise Display Extension.</description>
11
+ <notes>DE1411 Fix missing package file</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-27</date>
14
+ <time>20:49:46</time>
15
+ <contents><target name="magecommunity"><dir name="EbayEnterprise"><dir name="Display"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Feedurl.php" hash="82241e7e509b9c27dc734c8728e501f5"/></dir></dir></dir></dir></dir><file name="Beacon.php" hash="b272092167ffa1f7f08be5b3715b7968"/></dir><dir name="controllers"><file name="IndexController.php" hash="197cb073d339eb76e6dbcf2167107a93"/></dir><dir name="etc"><file name="adminhtml.xml" hash="e1208b50586829c2e6c6536dd062ef0c"/><file name="config.xml" hash="5c8237485eb9c7c77fea466e26f41bd9"/><file name="system.xml" hash="55731b868ba01e966120cd53235b4407"/></dir><dir name="Helper"><file name="Config.php" hash="f831ae412417e253a57f37d6d3423e50"/><file name="Data.php" hash="3a5312fe107714d34267c72ce2910f40"/></dir><dir name="Model"><file name="Email.php" hash="2252c80035c9515650cd49e2c52e3645"/><file name="Products.php" hash="63129b2a0bd7f790ffbd96473c7d2c31"/><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Backend"><file name="Feedurl.php" hash="aa1810a7c67e0b35e732ff5155f81a6b"/><file name="Siteidchecksum.php" hash="f72b7dc6d0294faafcfc51e8ec46a222"/></dir></dir></dir></dir><dir name="Error"><file name="Exception.php" hash="65df9f687c4746431f9316baca3b5495"/></dir></dir><dir name="sql"><dir name="eemsdisplay_setup"><file name="install-1.0.0.0.php" hash="a9c02c7e94cdad9965ffa62571276ba2"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="eems_display.xml" hash="7f823afa4c46cc316e198d5ff80eaa6b"/></dir><dir name="template"><dir name="eems_display"><file name="beacon.phtml" hash="4937e1a21b75f436b6a013fdcea59be9"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="EbayEnterprise_Display.xml" hash="ae74ae5088d96d6300c544a031d4c0c6"/></dir></target><target name="magelocale"><dir name="en_US"><dir name="template"><dir name="email"><file name="eemsdisplay_installed.html" hash="609fa6fc13a7a3f444bd0c256e207e7f"/></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.3.0</min><max>5.3.99</max></php></required></dependencies>
18
  </package>