cartdefender_actions - Version 2.2.0

Version Notes

Performance updates to data gathering.

Download this release

Release Info

Developer Radoslaw Gliniecki
Extension cartdefender_actions
Version 2.2.0
Comparing to
See all releases


Code changes from version 2.1.9 to 2.2.0

app/code/community/CartDefender/Actions/Model/EventBuilder.php CHANGED
@@ -27,7 +27,7 @@ class CartDefender_Actions_Model_EventBuilder
27
  $store = Mage::app()->getStore();
28
 
29
  $sessionData = $this->captureSessionData();
30
- $cart = $this->captureCartData();
31
  $fullOrders = $this->captureOrderData($observerData);
32
  $visitorData = $sessionData['visitor_data'];
33
  $event = array(
@@ -111,15 +111,30 @@ class CartDefender_Actions_Model_EventBuilder
111
  * obtained from the Magento cart.
112
  *
113
  * @return array various bits of data to be sent on each event,
114
- * obtained from the Magento cart.
115
  */
116
- private function captureCartData()
117
  {
118
- return session_id()
119
- ? $this->getCartFromQuote(
120
- Mage::getSingleton('checkout/session')->getQuote()
121
- )
122
- : array(CDData::MISSING_VALUE);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  }
124
 
125
  /**
@@ -197,36 +212,53 @@ class CartDefender_Actions_Model_EventBuilder
197
  private function captureOrderData($observerData)
198
  {
199
  $fullOrders = array(CDData::MISSING_VALUE);
200
- if (!session_id() || !isset($observerData['order_ids'])) {
201
  return $fullOrders;
202
  }
203
-
 
 
 
 
 
 
 
204
  $orderIds = $observerData['order_ids'];
205
  foreach ($orderIds as $orderId) {
206
- $oneFullOrder = array();
207
- $oneFullOrder['order_id'] = $orderId;
208
-
209
  $order = Mage::getModel('sales/order')->load($orderId);
210
- $orderData = $this->removePersonalData($order->getData());
211
- $oneFullOrder['order_data'] = $orderData;
212
-
213
- $quoteId = $orderData['quote_id'];
214
- $cartFromOrder = Mage::getModel('sales/quote')->load($quoteId);
215
- $oneFullOrder['cart'] = $this->getCartFromQuote($cartFromOrder);
216
-
217
- $items = $order->getAllVisibleItems();
218
- $orderItems = array();
219
- foreach ($items as $item) {
220
- $itemData = $item->getData();
221
- $orderItems[] = $itemData;
222
- }
223
- $oneFullOrder['order_items'] = $orderItems;
224
-
225
- $fullOrders[] = $oneFullOrder;
226
  }
227
  return $fullOrders;
228
  }
229
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
230
  /**
231
  * Removes sensitive data from the input array and returns it.
232
  *
27
  $store = Mage::app()->getStore();
28
 
29
  $sessionData = $this->captureSessionData();
30
+ $cart = $this->captureCartData($eventName, $observerData);
31
  $fullOrders = $this->captureOrderData($observerData);
32
  $visitorData = $sessionData['visitor_data'];
33
  $event = array(
111
  * obtained from the Magento cart.
112
  *
113
  * @return array various bits of data to be sent on each event,
114
+ * obtained from the Magento cart.
115
  */
116
+ private function captureCartData ($eventName, $observerData)
117
  {
118
+ if (session_id()) {
119
+ if ($eventName === 'checkout_cart_save_after') {
120
+ $cart = $observerData['cart'];
121
+ $quote = $cart->getQuote();
122
+ } elseif ($eventName === 'sales_quote_collect_totals_after') {
123
+ $quote = $observerData['quote'];
124
+ } elseif ($eventName === 'sales_quote_product_add_after') {
125
+ $items = $observerData['items'];
126
+ $firstItem = $items[0];
127
+ $quote = $firstItem->getQuote();
128
+ } else {
129
+ $quote = Mage::getSingleton('checkout/cart')->getQuote();
130
+ }
131
+ $cartFromQuote = $this->getCartFromQuote($quote);
132
+ return $cartFromQuote;
133
+ } else {
134
+ return array(
135
+ CDData::MISSING_VALUE
136
+ );
137
+ }
138
  }
139
 
140
  /**
212
  private function captureOrderData($observerData)
213
  {
214
  $fullOrders = array(CDData::MISSING_VALUE);
215
+ if (!session_id() || (!isset($observerData['order_ids']) && !isset($observerData['order'])) ) {
216
  return $fullOrders;
217
  }
218
+
219
+ if (!isset($observerData['order_ids'])) {
220
+ $order = $observerData['order'];
221
+ $fullOrders[] = $this->getFullOrder($order);
222
+
223
+ return $fullOrders;
224
+ }
225
+
226
  $orderIds = $observerData['order_ids'];
227
  foreach ($orderIds as $orderId) {
 
 
 
228
  $order = Mage::getModel('sales/order')->load($orderId);
229
+ $fullOrders[] = $this->getFullOrder($order);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
230
  }
231
  return $fullOrders;
232
  }
233
 
234
+ /**
235
+ * Return order data as an array including items and the related shopping cart.
236
+ * @param $order
237
+ * @return array various bits of data obtained from the Magento orders.
238
+ */
239
+ private function getFullOrder($order)
240
+ {
241
+ $oneFullOrder = array();
242
+ $oneFullOrder['order_id'] = $order->getId();
243
+
244
+ $orderData = $this->removePersonalData($order->getData());
245
+ $oneFullOrder['order_data'] = $orderData;
246
+
247
+ $quoteId = $orderData['quote_id'];
248
+ $cartFromOrder = Mage::getModel('sales/quote')->load($quoteId);
249
+ $oneFullOrder['cart'] = $this->getCartFromQuote($cartFromOrder);
250
+
251
+ $items = $order->getAllVisibleItems();
252
+ $orderItems = array();
253
+ foreach ($items as $item) {
254
+ $itemData = $item->getData();
255
+ $orderItems[] = $itemData;
256
+ }
257
+ $oneFullOrder['order_items'] = $orderItems;
258
+
259
+ return $oneFullOrder;
260
+ }
261
+
262
  /**
263
  * Removes sensitive data from the input array and returns it.
264
  *
app/code/community/CartDefender/Actions/etc/config.xml CHANGED
@@ -12,7 +12,7 @@
12
  <config>
13
  <modules>
14
  <CartDefender_Actions>
15
- <version>2.1.9</version>
16
  </CartDefender_Actions>
17
  </modules>
18
 
@@ -117,6 +117,15 @@
117
  </cartdefender_order_cancel_after>
118
  </observers>
119
  </order_cancel_after>
 
 
 
 
 
 
 
 
 
120
  <sales_order_place_after>
121
  <observers>
122
  <cartdefender_sales_order_place_after>
12
  <config>
13
  <modules>
14
  <CartDefender_Actions>
15
+ <version>2.2.0</version>
16
  </CartDefender_Actions>
17
  </modules>
18
 
117
  </cartdefender_order_cancel_after>
118
  </observers>
119
  </order_cancel_after>
120
+ <sales_quote_product_add_after>
121
+ <observers>
122
+ <cartdefender_sales_quote_product_add_after>
123
+ <type>singleton</type>
124
+ <class>CartDefender_Actions_Model_Observer</class>
125
+ <method>captureEvent</method>
126
+ </cartdefender_sales_quote_product_add_after>
127
+ </observers>
128
+ </sales_quote_product_add_after>
129
  <sales_order_place_after>
130
  <observers>
131
  <cartdefender_sales_order_place_after>
package.xml CHANGED
@@ -1,20 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>cartdefender_actions</name>
4
- <version>2.1.9</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Increase sales with this state-of-the-art product recommendations and targeted popups, including a FREE exit intent message. Engage your visitors in real time or later via email!</summary>
10
  <description>You can instantly use product recommendations, messages and offers which convert your visitors into customers. Start with FREE exit intent messages. Do it without A/B tests, because Cart Defender learns which messages convert the best and adjusts itself automatically.</description>
11
- <notes>Adding the CURL transport method as well as updating data gathering to improve compatibility with other plugins and various setups.&#xD;
12
- Minor fixes.&#xD;
13
- </notes>
14
  <authors><author><name>Radoslaw Gliniecki</name><user>Cart_Defender</user><email>radek@cartdefender.com</email></author><author><name>Jan Zankowski</name><user>janzankowski</user><email>jan@cartdefender.com</email></author><author><name>Przemyslaw Gliniecki</name><user>psgliniecki</user><email>psg@cartdefender.com</email></author></authors>
15
- <date>2017-05-04</date>
16
- <time>14:57:57</time>
17
- <contents><target name="magecommunity"><dir name="CartDefender"><dir name="Actions"><dir name="Block"><file name="Script.php" hash="247305c63594b6442e94122b226e3bb2"/></dir><dir name="Helper"><file name="Data.php" hash="f6da7288d3b111b4e9d82aeee64aebb6"/><file name="Logger.php" hash="aca3233298074d3cf8f436e668969bb9"/></dir><dir name="Model"><dir name="Api"><file name="V2.php" hash="64b8b03a84578a6f9a1fbf1321e109f2"/></dir><file name="Api.php" hash="a2d9ede9d01bb14ff31ebd792c9bbc51"/><file name="AsyncLocalSender.php" hash="2e22d4c07c7f983d98687d6faa6fe413"/><file name="CorrelationIdManager.php" hash="56f619241fdec54bcc4457937af893b8"/><file name="EventAsyncLocalSender.php" hash="4bcc43959212d0610e3e4b653d01c6cc"/><file name="EventBuilder.php" hash="a18aa9b59aa3a71f0de37dd232879a5c"/><file name="Observer.php" hash="44922ecc47fdf4a60fa86b929c5877c8"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Transport.php" hash="f63ca41ae1242de7bb18854d0f450b00"/></dir></dir></dir></dir><dir name="controllers"><file name="CartDefenderSenderController.php" hash="c3fb495d4ad88ac658867c77447d2b2b"/></dir><dir name="etc"><file name="api.xml" hash="3d9558fa5df621470460d4c9d62ba7f3"/><file name="config.xml" hash="7603e1fce070c2334ea618b142f3b880"/><file name="system.xml" hash="3bc66fa6869648811f2283f54abac2f5"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="CartDefender_Actions.xml" hash="f9e77235e41f79ac086160ef2e494837"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="actions"><file name="script.phtml" hash="4de68c84b01a9532595d2d13c494ef6c"/></dir></dir><dir name="layout"><file name="actions.xml" hash="e6a4b2f6d8132a833a1b5f8b9fce7166"/></dir></dir></dir></dir></target></contents>
18
  <compatible/>
19
  <dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.7.0.2</min><max>1.9.3.2</max></package><extension><name>openssl</name><min>0.9.6</min><max>1.1.0</max></extension></required></dependencies>
20
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>cartdefender_actions</name>
4
+ <version>2.2.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Increase sales with this state-of-the-art product recommendations and targeted popups, including a FREE exit intent message. Engage your visitors in real time or later via email!</summary>
10
  <description>You can instantly use product recommendations, messages and offers which convert your visitors into customers. Start with FREE exit intent messages. Do it without A/B tests, because Cart Defender learns which messages convert the best and adjusts itself automatically.</description>
11
+ <notes>Performance updates to data gathering.</notes>
 
 
12
  <authors><author><name>Radoslaw Gliniecki</name><user>Cart_Defender</user><email>radek@cartdefender.com</email></author><author><name>Jan Zankowski</name><user>janzankowski</user><email>jan@cartdefender.com</email></author><author><name>Przemyslaw Gliniecki</name><user>psgliniecki</user><email>psg@cartdefender.com</email></author></authors>
13
+ <date>2017-05-10</date>
14
+ <time>13:02:15</time>
15
+ <contents><target name="magecommunity"><dir name="CartDefender"><dir name="Actions"><dir name="Block"><file name="Script.php" hash="247305c63594b6442e94122b226e3bb2"/></dir><dir name="Helper"><file name="Data.php" hash="f6da7288d3b111b4e9d82aeee64aebb6"/><file name="Logger.php" hash="aca3233298074d3cf8f436e668969bb9"/></dir><dir name="Model"><dir name="Api"><file name="V2.php" hash="64b8b03a84578a6f9a1fbf1321e109f2"/></dir><file name="Api.php" hash="a2d9ede9d01bb14ff31ebd792c9bbc51"/><file name="AsyncLocalSender.php" hash="2e22d4c07c7f983d98687d6faa6fe413"/><file name="CorrelationIdManager.php" hash="56f619241fdec54bcc4457937af893b8"/><file name="EventAsyncLocalSender.php" hash="4bcc43959212d0610e3e4b653d01c6cc"/><file name="EventBuilder.php" hash="d75b16474b9cfceb5b94178ac0e7b0b8"/><file name="Observer.php" hash="44922ecc47fdf4a60fa86b929c5877c8"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Transport.php" hash="f63ca41ae1242de7bb18854d0f450b00"/></dir></dir></dir></dir><dir name="controllers"><file name="CartDefenderSenderController.php" hash="c3fb495d4ad88ac658867c77447d2b2b"/></dir><dir name="etc"><file name="api.xml" hash="3d9558fa5df621470460d4c9d62ba7f3"/><file name="config.xml" hash="4f90c41dddce88e16f169aa05067c41d"/><file name="system.xml" hash="3bc66fa6869648811f2283f54abac2f5"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="CartDefender_Actions.xml" hash="f9e77235e41f79ac086160ef2e494837"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="actions"><file name="script.phtml" hash="4de68c84b01a9532595d2d13c494ef6c"/></dir></dir><dir name="layout"><file name="actions.xml" hash="e6a4b2f6d8132a833a1b5f8b9fce7166"/></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.7.0.2</min><max>1.9.3.2</max></package><extension><name>openssl</name><min>0.9.6</min><max>1.1.0</max></extension></required></dependencies>
18
  </package>