Multistore-Newsletter-Subscription-per-store - Version 1.0.0

Version Notes

Allow users to subscribe for multiple store with same email Id.

Download this release

Release Info

Developer Magegeeks
Extension Multistore-Newsletter-Subscription-per-store
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/local/Magegeeks/Perstorenewsletter/Model/Mysql4/Subscriber.php ADDED
@@ -0,0 +1,85 @@
1
+ <?php
2
+ /**
3
+ * Magegeeks
4
+ *
5
+ * Magegeeks's Mage_Newsletter customizations
6
+ *
7
+ * PHP Version 5
8
+ *
9
+ * @category Magegeeks
10
+ * @package Magegeeks_Perstorenewsletter
11
+ * @author Magegeeks <magegeeks@gmail.com>
12
+ * @copyright Copyright (c) 2017 Magegeeks (http://www.magegeeks.in)
13
+ */
14
+ class Magegeeks_Perstorenewsletter_Model_Mysql4_Subscriber extends Mage_Newsletter_Model_Mysql4_Subscriber
15
+ {
16
+
17
+ /**
18
+ * Load subscriber from DB by email
19
+ *
20
+ * @param string $subscriberEmail
21
+ * @return array
22
+ */
23
+ public function loadByEmail($subscriberEmail)
24
+ {
25
+
26
+ /** @var $customerSession Mage_Customer_Model_Session */
27
+ $customerSession = Mage::getSingleton('customer/session');
28
+ $ownerId = Mage::getModel('customer/customer')
29
+ ->setWebsiteId(Mage::app()->getStore()->getWebsiteId())
30
+ ->loadByEmail($subscriberEmail)
31
+ ->getId();
32
+ $storeId = $customerSession->isLoggedIn() && $ownerId == $customerSession->getId()
33
+ ? $customerSession->getCustomer()->getStoreId()
34
+ : Mage::app()->getStore()->getId();
35
+ $select = $this->_read->select()
36
+ ->from($this->getMainTable())
37
+ ->where('subscriber_email=:subscriber_email')
38
+ ->where('store_id=:store_id'); // Add store ID for newsletters
39
+ $result = $this->_read->fetchRow($select, array(
40
+ 'subscriber_email' => $subscriberEmail,
41
+ 'store_id' => $storeId
42
+ ));
43
+
44
+ if (!$result) {
45
+ return array();
46
+ }
47
+ return $result;
48
+ }
49
+
50
+ /**
51
+ * Load subscriber by customer
52
+ *
53
+ * @param Mage_Customer_Model_Customer $customer
54
+ * @return array
55
+ */
56
+ public function loadByCustomer(Mage_Customer_Model_Customer $customer)
57
+ {
58
+ $select = $this->_read->select()
59
+ ->from($this->getMainTable())
60
+ ->where('customer_id=:customer_id')
61
+ ->where('store_id=:store_id');
62
+ $result = $this->_read->fetchRow($select, array(
63
+ 'customer_id' => $customer->getId(),
64
+ 'store_id' => $customer->getStoreId()
65
+ ));
66
+
67
+ if ($result) {
68
+ return $result;
69
+ }
70
+
71
+ $select = $this->_read->select()
72
+ ->from($this->getMainTable())
73
+ ->where('subscriber_email=:subscriber_email')
74
+ ->where('store_id=:store_id');
75
+ $result = $this->_read->fetchRow($select, array(
76
+ 'subscriber_email' => $customer->getEmail(),
77
+ 'store_id' => $customer->getStoreId()
78
+ ));
79
+
80
+ if ($result) {
81
+ return $result;
82
+ }
83
+ return array();
84
+ }
85
+ }
app/code/local/Magegeeks/Perstorenewsletter/etc/config.xml ADDED
@@ -0,0 +1,17 @@
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Magegeeks_Perstorenewsletter>
5
+ <version>1.0</version>
6
+ </Magegeeks_Perstorenewsletter>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <newsletter_mysql4>
11
+ <rewrite>
12
+ <subscriber>Magegeeks_Perstorenewsletter_Model_Mysql4_Subscriber</subscriber>
13
+ </rewrite>
14
+ </newsletter_mysql4>
15
+ </models>
16
+ </global>
17
+ </config>
app/etc/modules/Magegeeks_Perstorenewsletter.xml ADDED
@@ -0,0 +1,26 @@
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magegeeks
5
+ *
6
+ * Magegeeks's Mage_Newsletter customizations
7
+ *
8
+ * PHP Version 5
9
+ *
10
+ * @category Magegeeks
11
+ * @package Magegeeks_Perstorenewsletter
12
+ * @author Magegeeks <magegeeks@gmail.com>
13
+ * @copyright Copyright (c) 2017 Magegeeks (http://www.magegeeks.in)
14
+ */
15
+ -->
16
+ <config>
17
+ <modules>
18
+ <Magegeeks_Perstorenewsletter>
19
+ <active>true</active>
20
+ <codePool>local</codePool>
21
+ <depends>
22
+ <Mage_Newsletter />
23
+ </depends>
24
+ </Magegeeks_Perstorenewsletter>
25
+ </modules>
26
+ </config>
package.xml ADDED
@@ -0,0 +1,22 @@
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Multistore-Newsletter-Subscription-per-store</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license>OSL v1.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Allow users to subscribe for multiple store with same email Id.</summary>
10
+ <description>If you use Magento multi-store feature, you possibly know that visitors of the store cannot sign up for newsletters of all multi-stores. Store visitor will be able to sign up only for one store.&#xD;
11
+ &#xD;
12
+ Lets imagine that you have two multi-stores: one for Gifts and other for Chocolate. If some of your visitor will open Gifts store and sign up for Gifts newsletter, Magento will record it. However if the same visitor will come to Chocolate store the other day and submit his email in newsletter box, in this case Magento will remove his email from Gifts newsletter and add him to Chocolate newsletter. By default it is not possible to sign up for News of both stores.&#xD;
13
+ &#xD;
14
+ This extension will help you to overcome this limitation and allow your visitors to sign up for multi-store newsletters.</description>
15
+ <notes>Allow users to subscribe for multiple store with same email Id.</notes>
16
+ <authors><author><name>magegeeks</name><user>magegeeks</user><email>magegeeks@gmail.com</email></author></authors>
17
+ <date>2017-03-07</date>
18
+ <time>11:23:55</time>
19
+ <contents><target name="mageetc"><dir><dir name="modules"><file name="Magegeeks_Perstorenewsletter.xml" hash="b962e25eb1cd5fdb1bc7228e3ec8fd68"/></dir></dir></target><target name="magelocal"><dir name="Magegeeks"><dir name="Perstorenewsletter"><dir name="Model"><dir name="Mysql4"><file name="Subscriber.php" hash="e7eec77069a623771a050b2a57f655c1"/></dir></dir><dir name="etc"><file name="config.xml" hash="63c110d215f69e91f38c62f523885e36"/></dir></dir></dir></target></contents>
20
+ <compatible/>
21
+ <dependencies><required><php><min>5.3.0</min><max>7.0.5</max></php></required></dependencies>
22
+ </package>