recapture - Version 1.0.2

Version Notes

More cool updates!

Download this release

Release Info

Developer David Webber
Extension recapture
Version 1.0.2
Comparing to
See all releases


Code changes from version 1.0.1 to 1.0.2

app/code/local/Recapture/Connector/Helper/Data.php CHANGED
@@ -14,4 +14,40 @@ class Recapture_Connector_Helper_Data extends Mage_Core_Helper_Abstract {
14
 
15
  }
16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  }
14
 
15
  }
16
 
17
+ public function translateCartHash($hash = ''){
18
+
19
+ if (empty($hash)) return false;
20
+
21
+ $result = Mage::helper('recapture/transport')->dispatch('cart/retrieve', array(
22
+ 'hash' => $hash
23
+ ));
24
+
25
+ $body = @json_decode($result->getBody());
26
+
27
+ if ($body->status == 'success'){
28
+
29
+ return $body->data->cart_id;
30
+
31
+ } else return false;
32
+
33
+ }
34
+
35
+ public function associateCartToMe($cartId = null){
36
+
37
+ if (empty($cartId)) return false;
38
+
39
+ $session = Mage::getSingleton('checkout/session');
40
+
41
+ $session->clear();
42
+ $session->setQuoteId($cartId);
43
+
44
+ $quote = $session->getQuote();
45
+
46
+ //if this cart somehow was already converted, we're not going to be able to load it. as such, we can't associate it.
47
+ if ($quote->getId() != $cartId) return false;
48
+
49
+ return true;
50
+
51
+ }
52
+
53
  }
app/code/local/Recapture/Connector/controllers/Adminhtml/AuthenticateController.php CHANGED
@@ -6,7 +6,7 @@ class Recapture_Connector_Adminhtml_AuthenticateController extends Mage_Adminhtm
6
 
7
  $query = http_build_query(array(
8
  'return' => Mage::helper('adminhtml')->getUrl('recapture_admin/authenticate/return'),
9
- 'recapture' => Mage::getUrl('recapture/cart/index')
10
  ));
11
 
12
  $authenticateUrl = 'http://recapture.io/account/auth?' . $query;
6
 
7
  $query = http_build_query(array(
8
  'return' => Mage::helper('adminhtml')->getUrl('recapture_admin/authenticate/return'),
9
+ 'recapture' => Mage::getUrl('recapture/cart/index', array('hash' => 'CART_HASH'))
10
  ));
11
 
12
  $authenticateUrl = 'http://recapture.io/account/auth?' . $query;
app/code/local/Recapture/Connector/controllers/CartController.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Recapture_Connector_CartController extends Mage_Core_Controller_Front_Action {
4
+
5
+ public function indexAction(){
6
+
7
+ $helper = Mage::helper('recapture');
8
+
9
+ $hash = $this->getRequest()->getParam('hash');
10
+
11
+ $cartId = $helper->translateCartHash($hash);
12
+
13
+ if (!$cartId){
14
+
15
+ Mage::getSingleton('core/session')->addError('There was an error retrieving your cart.');
16
+ $this->_redirect('/');
17
+
18
+ }
19
+
20
+ $result = $helper->associateCartToMe($cartId);
21
+
22
+ if (!$result){
23
+
24
+ Mage::getSingleton('core/session')->addError('There was an error retrieving your cart.');
25
+ $this->_redirect('/');
26
+
27
+ } else {
28
+
29
+ $cart = Mage::getModel('checkout/cart')->getQuote();
30
+
31
+ $this->_redirect('checkout/cart');
32
+
33
+ }
34
+
35
+ }
36
+
37
+ }
app/code/local/Recapture/Connector/controllers/ExportController.php DELETED
@@ -1,115 +0,0 @@
1
- <?php
2
-
3
- class Soshify_Connector_ExportController extends Mage_Core_Controller_Front_Action {
4
-
5
- public function indexAction(){
6
-
7
- $resource = Mage::getSingleton('core/resource');
8
- $readConnection = $resource->getConnection('core_read');
9
- $productResource = Mage::getModel('catalog/product')->getResource();
10
-
11
- $name = $productResource->getAttribute('name');
12
- $visibility = $productResource->getAttribute('visibility');
13
- $status = $productResource->getAttribute('status');
14
-
15
- $nameId = $name->getId();
16
- $visibilityId = $visibility->getId();
17
- $statusId = $status->getId();
18
-
19
- $select = $readConnection->select();
20
- $select = $select->from(array('e' => $resource->getTableName('catalog/product')), array('sku'))->where(new Zend_Db_Expr('sku IS NOT NULL'));
21
-
22
- //is active
23
- $select->joinLeft(array('table_status' => $status->getBackendTable()), "(table_status.entity_id = e.entity_id AND table_status.attribute_id = $statusId)", null)->where("table_status.value = '" . Mage_Catalog_Model_Product_Status::STATUS_ENABLED . "'");
24
-
25
- //name
26
- $select->joinLeft(array('table_name' => $name->getBackendTable()), "(table_name.entity_id = e.entity_id AND table_name.attribute_id = $nameId)", array('name' => 'value'));
27
-
28
- //visibility
29
- $select->joinLeft(array('table_visibility' => $visibility->getBackendTable()), "(table_visibility.entity_id = e.entity_id AND table_visibility.attribute_id = $visibilityId)", array('visibility' => 'value'))->where("table_visibility.value != '" . Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE . "'");
30
-
31
- $query = $select->query();
32
-
33
- $dir = Mage::getBaseDir('var') . '/soshify/';
34
- $file = 'soshify.csv';
35
-
36
- mkdir($dir, 0777, true);
37
-
38
- $fh = fopen($dir . '/' . $file, 'w');
39
- $csv = new Varien_File_Csv();
40
-
41
- while ($product = $query->fetch()){
42
-
43
- $csv->fputcsv($fh, $product);
44
-
45
- }
46
-
47
- fclose($fh);
48
-
49
- }
50
-
51
- public function exportAction(){
52
-
53
- $resource = Mage::getSingleton('core/resource');
54
- $readConnection = $resource->getConnection('core_read');
55
- $productResource = Mage::getModel('catalog/product')->getResource();
56
-
57
- $name = $productResource->getAttribute('name');
58
- $photos = $productResource->getAttribute('instagram_photos');
59
-
60
- $nameId = $name->getId();
61
- $photosId = $photos->getId();
62
-
63
- $select = $readConnection->select();
64
- $select = $select->from(array('e' => $resource->getTableName('catalog/product')), array('sku'))->where(new Zend_Db_Expr('sku IS NOT NULL'));
65
-
66
- //name
67
- $select->joinLeft(array('table_name' => $name->getBackendTable()), "(table_name.entity_id = e.entity_id AND table_name.attribute_id = $nameId)", array('name' => 'value'));
68
-
69
- //name
70
- $select->joinLeft(array('table_photos' => $photos->getBackendTable()), "(table_photos.entity_id = e.entity_id AND table_photos.attribute_id = $photosId)", array('photos' => 'value'));
71
-
72
- $query = $select->query();
73
-
74
- $ids = array();
75
-
76
- while ($product = $query->fetch()){
77
-
78
- $theseIds = explode(',', $product['photos']);
79
-
80
- if (count($theseIds)){
81
-
82
- foreach ($theseIds as $id){
83
-
84
- if (empty($id)) continue;
85
-
86
- if (!isset($ids[$id])) $ids[$id] = array();
87
-
88
- $ids[$id][] = $product['sku'];
89
-
90
- }
91
-
92
- }
93
-
94
- }
95
-
96
- $dir = Mage::getBaseDir('var') . '/soshify/';
97
- $file = 'soshify-photos.csv';
98
-
99
- $fh = fopen($dir . '/' . $file, 'w');
100
- $csv = new Varien_File_Csv();
101
-
102
- foreach ($ids as $id => $products){
103
-
104
- $csv->fputcsv($fh, array(
105
- 'code' => $id,
106
- 'products' => implode(',', $products)
107
- ));
108
-
109
- }
110
-
111
- fclose($fh);
112
-
113
- }
114
-
115
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Recapture/Connector/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Recapture_Connector>
5
- <version>1.0.1</version>
6
  </Recapture_Connector>
7
  </modules>
8
 
2
  <config>
3
  <modules>
4
  <Recapture_Connector>
5
+ <version>1.0.2</version>
6
  </Recapture_Connector>
7
  </modules>
8
 
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>recapture</name>
4
- <version>1.0.1</version>
5
  <stability>stable</stability>
6
  <license>OSL</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Free analytics dashboard for abandoned carts. Set up automated cart recovery email campaigns in minutes.</summary>
10
  <description>Free analytics dashboard for abandoned carts. Set up automated cart recovery email campaigns in minutes.</description>
11
- <notes>Fixed minor incompatibility issue</notes>
12
  <authors><author><name>David Webber</name><user>Adstream</user><email>david@adstreaminc.com</email></author></authors>
13
- <date>2015-07-22</date>
14
- <time>17:47:13</time>
15
- <contents><target name="magelocal"><dir name="Recapture"><dir name="Connector"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><file name="Authenticate.php" hash="b4def4c279d801f7e9c327d8ee87c414"/><file name="Key.php" hash="f95c74992894b0a823793ef605c103e1"/><file name="Status.php" hash="003133a47fb37e6f522314778eec9632"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="AuthenticateController.php" hash="1c5ad4701f9fc353c1f387212ea0c0c5"/></dir><file name="ExportController.php" hash="6da6668ecd201d5dbc627b831c3b37ba"/></dir><dir name="etc"><file name="config.xml" hash="b50452e33d6c09b6354cca829a4c5d7d"/><file name="system.xml" hash="12f5cd5932b919ba61f0cb366f252efc"/></dir><dir name="Helper"><file name="Data.php" hash="a20da6edda255919ade055203ac459ac"/><file name="Transport.php" hash="a13bf58b13e207f5260fe2bdbe86fb5e"/></dir><dir name="Model"><file name="Observer.php" hash="3dbcbfc25944aedb3cc6658c495bb70b"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Recapture_Connector.xml" hash="e8fea9dc4237af6b34219c7f52bd02d8"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>recapture</name>
4
+ <version>1.0.2</version>
5
  <stability>stable</stability>
6
  <license>OSL</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Free analytics dashboard for abandoned carts. Set up automated cart recovery email campaigns in minutes.</summary>
10
  <description>Free analytics dashboard for abandoned carts. Set up automated cart recovery email campaigns in minutes.</description>
11
+ <notes>More cool updates!</notes>
12
  <authors><author><name>David Webber</name><user>Adstream</user><email>david@adstreaminc.com</email></author></authors>
13
+ <date>2015-07-24</date>
14
+ <time>23:37:19</time>
15
+ <contents><target name="magelocal"><dir name="Recapture"><dir name="Connector"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><file name="Authenticate.php" hash="b4def4c279d801f7e9c327d8ee87c414"/><file name="Key.php" hash="f95c74992894b0a823793ef605c103e1"/><file name="Status.php" hash="003133a47fb37e6f522314778eec9632"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="AuthenticateController.php" hash="677c55f039ca051b44fec1bfbf63b969"/></dir><file name="CartController.php" hash="0ec0843034d768ad6d978e291183a980"/></dir><dir name="etc"><file name="config.xml" hash="50062202cfd4a8262cd001bfb7e4f6f0"/><file name="system.xml" hash="12f5cd5932b919ba61f0cb366f252efc"/></dir><dir name="Helper"><file name="Data.php" hash="a8256fffe350a4bd82ba13a9af8ddd54"/><file name="Transport.php" hash="a13bf58b13e207f5260fe2bdbe86fb5e"/></dir><dir name="Model"><file name="Observer.php" hash="3dbcbfc25944aedb3cc6658c495bb70b"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Recapture_Connector.xml" hash="e8fea9dc4237af6b34219c7f52bd02d8"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>