Version Notes
New functionality to track anonymous to registered customers with the same abandoned cart token in MessageFocus.
Download this release
Release Info
Developer | Anna Grieve |
Extension | Adestra_MFAbandonedCart |
Version | 1.0.4 |
Comparing to | |
See all releases |
Code changes from version 1.0.3 to 1.0.4
- app/code/local/Adestra/MFAbandonedCart/Model/Conversion.php +36 -1
- app/code/local/Adestra/MFAbandonedCart/Model/Resource/Setup.php +9 -0
- app/code/local/Adestra/MFAbandonedCart/Model/Resource/Token.php +54 -0
- app/code/local/Adestra/MFAbandonedCart/Model/Resource/Token/Collection.php +8 -0
- app/code/local/Adestra/MFAbandonedCart/Model/Token.php +36 -0
- app/code/local/Adestra/MFAbandonedCart/controllers/IndexController.php +19 -2
- app/code/local/Adestra/MFAbandonedCart/etc/config.xml +27 -3
- app/code/local/Adestra/MFAbandonedCart/sql/mfabandonedcart_setup/install-1.0.4.php +24 -0
- package.xml +7 -7
app/code/local/Adestra/MFAbandonedCart/Model/Conversion.php
CHANGED
@@ -24,11 +24,46 @@ class Adestra_MFAbandonedCart_Model_Conversion {
|
|
24 |
}
|
25 |
|
26 |
private function _updateBasics() {
|
|
|
27 |
$this->account_id = Mage::getStoreConfig('adestra/mfabandonedcart/accountid');
|
28 |
$this->capture_id = Mage::getStoreConfig('adestra/mfabandonedcart/captureid');
|
29 |
$this->client_domain = Mage::getStoreConfig('adestra/mfabandonedcart/clientdomain');
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
|
|
|
|
|
|
32 |
}
|
33 |
|
34 |
public function updateCart() {
|
24 |
}
|
25 |
|
26 |
private function _updateBasics() {
|
27 |
+
|
28 |
$this->account_id = Mage::getStoreConfig('adestra/mfabandonedcart/accountid');
|
29 |
$this->capture_id = Mage::getStoreConfig('adestra/mfabandonedcart/captureid');
|
30 |
$this->client_domain = Mage::getStoreConfig('adestra/mfabandonedcart/clientdomain');
|
31 |
+
|
32 |
+
$model = Mage::getModel('mfabandonedcart/token');
|
33 |
+
$sid = Mage::getSingleton("customer/session")->getEncryptedSessionId();
|
34 |
+
$quote_id = Mage::getSingleton('checkout/session')->getQuoteId();
|
35 |
+
$session_token = Mage::getSingleton('core/session')->getMFAbandonedCartTokenId();
|
36 |
+
|
37 |
+
if ($session_token) $model->load($session_token);
|
38 |
+
if(!$model->getTokenId()) $model->loadBySessionId($sid);
|
39 |
+
if(!$model->getTokenId() && $quote_id > 0) $model->loadByQuoteId($quote_id);
|
40 |
+
|
41 |
+
if(!$model->getTokenId()) {
|
42 |
+
if($quote_id > 0) {
|
43 |
+
$model->setTokenId($sid);
|
44 |
+
$model->setSessionId($sid);
|
45 |
+
$model->setQuoteId($quote_id);
|
46 |
+
$model->save();
|
47 |
+
}
|
48 |
+
}
|
49 |
+
else {
|
50 |
+
$model->setQuoteId($quote_id);
|
51 |
+
$model->setSessionId($sid);
|
52 |
+
$model->save();
|
53 |
+
}
|
54 |
+
|
55 |
+
$this->token = $model->getTokenId();
|
56 |
+
Mage::getSingleton('core/session')->setMFAbandonedCartTokenId($model->getTokenId());
|
57 |
+
//
|
58 |
+
//Mage::Log('************');
|
59 |
+
//Mage::Log(__FUNCTION__);
|
60 |
+
//Mage::Log('Mage sid: '.$sid);
|
61 |
+
//Mage::Log('MF token: '.Mage::getSingleton('core/session')->getMFAbandonedCartTokenId());
|
62 |
+
//Mage::Log('************');
|
63 |
|
64 |
+
|
65 |
+
// $this->token = $token;
|
66 |
+
// $this->token = Mage::getSingleton("customer/session")->getEncryptedSessionId();
|
67 |
}
|
68 |
|
69 |
public function updateCart() {
|
app/code/local/Adestra/MFAbandonedCart/Model/Resource/Setup.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Adestra_MFAbandonedCart_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup {
|
4 |
+
|
5 |
+
|
6 |
+
}
|
7 |
+
|
8 |
+
|
9 |
+
?>
|
app/code/local/Adestra/MFAbandonedCart/Model/Resource/Token.php
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Adestra_MFAbandonedCart_Model_Resource_Token extends Mage_Core_Model_Resource_Db_Abstract {
|
4 |
+
protected function _construct()
|
5 |
+
{
|
6 |
+
$this->_init('mfabandonedcart/token', 'token_id');
|
7 |
+
}
|
8 |
+
|
9 |
+
public function loadBySessionId($sid)
|
10 |
+
{
|
11 |
+
$adapter = $this->_getReadAdapter();
|
12 |
+
$select = $adapter->select()
|
13 |
+
->from($this->getMainTable())
|
14 |
+
->where('session_id = "'.$sid.'"');
|
15 |
+
return $adapter->fetchRow($select);
|
16 |
+
}
|
17 |
+
|
18 |
+
public function loadByQuoteId($qid)
|
19 |
+
{
|
20 |
+
$adapter = $this->_getReadAdapter();
|
21 |
+
$select = $adapter->select()
|
22 |
+
->from($this->getMainTable())
|
23 |
+
->where('quote_id = "'.$qid.'"');
|
24 |
+
return $adapter->fetchRow($select);
|
25 |
+
}
|
26 |
+
|
27 |
+
|
28 |
+
public function write($token_id,$data) {
|
29 |
+
|
30 |
+
$bindValues = array( 'token_id' => $token_id );
|
31 |
+
$select = $this->_getReadAdapter()->select()
|
32 |
+
->from($this->getMainTable())
|
33 |
+
->where('token_id = :token_id');
|
34 |
+
$exists = $this->_getReadAdapter()->fetchOne($select, $bindValues);
|
35 |
+
|
36 |
+
$bind = array(
|
37 |
+
// 'token_id' => $token_id,
|
38 |
+
'session_id' => $data['session_id'],
|
39 |
+
'updated_at' => $data['updated_at'],
|
40 |
+
'quote_id' => $data['quote_id']
|
41 |
+
);
|
42 |
+
|
43 |
+
if ($exists) {
|
44 |
+
$where = array(
|
45 |
+
'token_id=?' => $token_id
|
46 |
+
);
|
47 |
+
$this->_getWriteAdapter()->update($this->getMainTable(), $bind, $where);
|
48 |
+
} else {
|
49 |
+
$bind['token_id'] = $token_id;
|
50 |
+
$this->_getWriteAdapter()->insert($this->getMainTable(), $bind);
|
51 |
+
}
|
52 |
+
|
53 |
+
}
|
54 |
+
}
|
app/code/local/Adestra/MFAbandonedCart/Model/Resource/Token/Collection.php
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Adestra_MFAbandonedCart_Model_Resource_Token_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
3 |
+
{
|
4 |
+
protected function _construct()
|
5 |
+
{
|
6 |
+
$this->_init('mfabandonedcart/token');
|
7 |
+
}
|
8 |
+
}
|
app/code/local/Adestra/MFAbandonedCart/Model/Token.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Adestra_MFAbandonedCart_Model_Token extends Mage_Core_Model_Abstract {
|
4 |
+
protected function _construct()
|
5 |
+
{
|
6 |
+
$this->_init('mfabandonedcart/token');
|
7 |
+
}
|
8 |
+
|
9 |
+
public function loadBySessionId($sid) {
|
10 |
+
$this->setData($this->getResource()->loadBySessionId($sid));
|
11 |
+
return $this;
|
12 |
+
}
|
13 |
+
|
14 |
+
public function loadByQuoteId($qid) {
|
15 |
+
$this->setData($this->getResource()->loadByQuoteId($qid));
|
16 |
+
return $this;
|
17 |
+
}
|
18 |
+
|
19 |
+
// protected function _beforeSave() {
|
20 |
+
// $this->setUpdatedAt(date("Y-m-d H:i:s", time()));
|
21 |
+
// return parent::_beforeSave();
|
22 |
+
// }
|
23 |
+
|
24 |
+
public function save() {
|
25 |
+
$this->setUpdatedAt(date("Y-m-d H:i:s", time()));
|
26 |
+
if (!$this->getQuoteId()) $this->setQuoteId(0);
|
27 |
+
|
28 |
+
$data = array(
|
29 |
+
'session_id' => $this->getSessionId(),
|
30 |
+
'updated_at' => $this->getUpdatedAt(),
|
31 |
+
'quote_id' => $this->getQuoteId()
|
32 |
+
);
|
33 |
+
$this->getResource()->write($this->getTokenId(),$data);
|
34 |
+
}
|
35 |
+
|
36 |
+
}
|
app/code/local/Adestra/MFAbandonedCart/controllers/IndexController.php
CHANGED
@@ -4,8 +4,25 @@
|
|
4 |
public function indexAction(){
|
5 |
|
6 |
$cart_url = Mage::getUrl('checkout/cart');
|
7 |
-
if (isset($_GET['sid']))
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
}
|
11 |
|
4 |
public function indexAction(){
|
5 |
|
6 |
$cart_url = Mage::getUrl('checkout/cart');
|
7 |
+
if (isset($_GET['sid'])) {
|
8 |
+
$token_id = $_GET['sid'];
|
9 |
+
$token = Mage::getModel('mfabandonedcart/token')->load($token_id);
|
10 |
+
|
11 |
+
if($token->getTokenId()) {
|
12 |
+
$quote = Mage::getModel('sales/quote')->load($token->getQuoteId());
|
13 |
+
if($quote->getId()) {
|
14 |
+
Mage::getSingleton('checkout/session')->setQuoteId($quote->getId());
|
15 |
+
}
|
16 |
+
|
17 |
+
$sid = Mage::getSingleton("customer/session")->getEncryptedSessionId();
|
18 |
+
if ($token->getSessionId() != $sid) {
|
19 |
+
$token->setSessionId($sid);
|
20 |
+
$token->save();
|
21 |
+
}
|
22 |
+
//$cart_url .= '?SID='.$token->getTokenId();
|
23 |
+
}
|
24 |
+
header('Location: ' . $cart_url);
|
25 |
+
}
|
26 |
|
27 |
}
|
28 |
|
app/code/local/Adestra/MFAbandonedCart/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Adestra_MFAbandonedCart>
|
5 |
-
<version>1.0.
|
6 |
</Adestra_MFAbandonedCart>
|
7 |
</modules>
|
8 |
<global>
|
@@ -19,11 +19,35 @@
|
|
19 |
<models>
|
20 |
<mfabandonedcart>
|
21 |
<class>Adestra_MFAbandonedCart_Model</class>
|
|
|
22 |
</mfabandonedcart>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
</models>
|
24 |
<events>
|
25 |
-
<!--
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
</global>
|
28 |
<frontend>
|
29 |
<layout>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Adestra_MFAbandonedCart>
|
5 |
+
<version>1.0.4</version>
|
6 |
</Adestra_MFAbandonedCart>
|
7 |
</modules>
|
8 |
<global>
|
19 |
<models>
|
20 |
<mfabandonedcart>
|
21 |
<class>Adestra_MFAbandonedCart_Model</class>
|
22 |
+
<resourceModel>mfabandonedcart_resource</resourceModel>
|
23 |
</mfabandonedcart>
|
24 |
+
<mfabandonedcart_resource>
|
25 |
+
<class>Adestra_MFAbandonedCart_Model_Resource</class>
|
26 |
+
<entities>
|
27 |
+
<token>
|
28 |
+
<table>mfabandonedcart_tokens</table>
|
29 |
+
</token>
|
30 |
+
</entities>
|
31 |
+
</mfabandonedcart_resource>
|
32 |
</models>
|
33 |
<events>
|
34 |
+
<!-- <customer_login>
|
35 |
+
<observers>
|
36 |
+
<customer_login_observer>
|
37 |
+
<class>mfabandonedcart/observer</class>
|
38 |
+
<method>customerLogin</method>
|
39 |
+
</customer_login_observer>
|
40 |
+
</observers>
|
41 |
+
</customer_login>
|
42 |
+
--> </events>
|
43 |
+
<resources>
|
44 |
+
<mfabandonedcart_setup>
|
45 |
+
<setup>
|
46 |
+
<module>Adestra_MFAbandonedCart</module>
|
47 |
+
<class>Adestra_MFAbandonedCart_Model_Resource_Setup</class>
|
48 |
+
</setup>
|
49 |
+
</mfabandonedcart_setup>
|
50 |
+
</resources>
|
51 |
</global>
|
52 |
<frontend>
|
53 |
<layout>
|
app/code/local/Adestra/MFAbandonedCart/sql/mfabandonedcart_setup/install-1.0.4.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
$installer->startSetup();
|
5 |
+
$table = $installer->getConnection()->newTable($installer->getTable('mfabandonedcart/token'))
|
6 |
+
->addColumn('token_id', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
|
7 |
+
'nullable' => false,
|
8 |
+
'primary' => true,
|
9 |
+
), 'Token ID')
|
10 |
+
->addColumn('session_id', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
|
11 |
+
'nullable' => false,
|
12 |
+
), 'Session ID')
|
13 |
+
->addColumn('quote_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
14 |
+
'unsigned' => true,
|
15 |
+
'nullable' => false,
|
16 |
+
), 'Quote ID')
|
17 |
+
->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_DATETIME, null, array(
|
18 |
+
'nullable' => false,
|
19 |
+
), 'Update date')
|
20 |
+
->setComment('Adestra MessageFocus Abandoned Cart token table');
|
21 |
+
$installer->getConnection()->createTable($table);
|
22 |
+
$installer->endSetup();
|
23 |
+
|
24 |
+
?>
|
package.xml
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Adestra_MFAbandonedCart</name>
|
4 |
-
<version>1.0.
|
5 |
<stability>stable</stability>
|
6 |
<license>GNU General Public License (GPL)</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
-
<summary>Adestra
|
10 |
-
<description>
|
11 |
-
<notes>
|
12 |
<authors><author><name>Anna Grieve</name><user>Adestra</user><email>integrations@adestra.com</email></author></authors>
|
13 |
-
<date>
|
14 |
-
<time>
|
15 |
-
<contents><target name="magelocal"><dir name="Adestra"><dir name="MFAbandonedCart"><dir name="Block"><file name="Checkout.php" hash="70e50c4ac3ed85eddb01577a131e275c"/></dir><dir name="Helper"><file name="Data.php" hash="5e73c48ff39c3de8d9fafd9f451e2931"/></dir><dir name="Model"><file name="Conversion.php" hash="
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.5</min><max>1.7</max></package></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Adestra_MFAbandonedCart</name>
|
4 |
+
<version>1.0.4</version>
|
5 |
<stability>stable</stability>
|
6 |
<license>GNU General Public License (GPL)</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
+
<summary>Adestra MessageFocus Abandoned cart</summary>
|
10 |
+
<description>MessageFocus conversion capture integration module.</description>
|
11 |
+
<notes>New functionality to track anonymous to registered customers with the same abandoned cart token in MessageFocus.</notes>
|
12 |
<authors><author><name>Anna Grieve</name><user>Adestra</user><email>integrations@adestra.com</email></author></authors>
|
13 |
+
<date>2014-03-05</date>
|
14 |
+
<time>16:38:08</time>
|
15 |
+
<contents><target name="magelocal"><dir name="Adestra"><dir name="MFAbandonedCart"><dir name="Block"><file name="Checkout.php" hash="70e50c4ac3ed85eddb01577a131e275c"/></dir><dir name="Helper"><file name="Data.php" hash="5e73c48ff39c3de8d9fafd9f451e2931"/></dir><dir name="Model"><file name="Conversion.php" hash="81f4ef1210d27c62a63d23a23d9efe43"/><dir name="Resource"><file name="Setup.php" hash="dfb8d7784e2a6f4c18719eea80f41506"/><dir name="Token"><file name="Collection.php" hash="128f1714c7f8c962d03e4525ac9c5611"/></dir><file name="Token.php" hash="f3f1c401f86229eb9a6f28acd5f1f41b"/></dir><file name="Token.php" hash="5ccdc9b611759caec10f522eefb354ab"/></dir><dir name="controllers"><file name="IndexController.php" hash="ed9191dc3ed6ef95a2313e13756f9305"/></dir><dir name="etc"><file name="config.xml" hash="7ed6c4239697b0f1cd1469604af264b3"/><file name="system.xml" hash="9ea649f0de6f98188316f378250743a3"/></dir><dir name="sql"><dir name="mfabandonedcart_setup"><file name="install-1.0.4.php" hash="f56aebaf2ae75cca3970e5318a9a187e"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="mfabandonedcart.xml" hash="ffc1de303843a0e960fe101881c83ad8"/></dir><dir name="template"><dir name="mfabandonedcart"><dir name="checkout"><file name="purchase_action.phtml" hash="c79a929292c3ec02c0ab88b27869311c"/><file name="update_action.phtml" hash="9b2b200dc7501a9e181dc02343948b92"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Adestra_MFAbandonedCart.xml" hash="98a24bc0c93f67574a5acc486117e3cc"/></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.5</min><max>1.7</max></package></required></dependencies>
|
18 |
</package>
|