diff --git a/CHANGELOG.md b/CHANGELOG.md index 6da3319..e9a7083 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +### 2.2.0 + +- Disable Magento newsletter emails if opt-in/out enabled - [[#15](https://github.com/sendsmaily/Sendsmaily-Sync-for-Magento/issues/15)] + ### 2.1.1 - Add section to Admin panel for easy access to Smaily RSS-feed diff --git a/app/code/community/Sendsmaily/Sync/Model/Subscriber.php b/app/code/community/Sendsmaily/Sync/Model/Subscriber.php new file mode 100644 index 0000000..c41419c --- /dev/null +++ b/app/code/community/Sendsmaily/Sync/Model/Subscriber.php @@ -0,0 +1,53 @@ +. + */ + +class Sendsmaily_Sync_Model_Subscriber extends Mage_Newsletter_Model_Subscriber +{ + /** + * Skip sending out confirmation success email if Smaily opt-in enabled. + * + * @return Sendsmaily_Sync_Model_Subscriber|Mage_Newsletter_Model_Subscriber + */ + public function sendConfirmationSuccessEmail() + { + // Do not send. + if (Mage::helper('sync')->newsletterOptInEnabled() === true) { + return $this; + } + // Send subscription email via Magento. + return parent::sendConfirmationSuccessEmail(); + } + + /** + * Skip sending out unsubsciption email if Smaily opt-in enabled. + * + * @return Sendsmaily_Sync_Model_Subscriber|Mage_Newsletter_Model_Subscriber + */ + public function sendUnsubscriptionEmail() + { + // Do not send. + if (Mage::helper('sync')->newsletterOptInEnabled() === true) { + return $this; + } + // Send unsubscription email via Magento. + return parent::sendUnsubscriptionEmail(); + } +} diff --git a/app/code/community/Sendsmaily/Sync/etc/config.xml b/app/code/community/Sendsmaily/Sync/etc/config.xml index 69c7505..c78243c 100644 --- a/app/code/community/Sendsmaily/Sync/etc/config.xml +++ b/app/code/community/Sendsmaily/Sync/etc/config.xml @@ -22,7 +22,7 @@ - 2.1.1 + 2.2.0 @@ -71,6 +71,11 @@ Sendsmaily_Sync_Model + + + Sendsmaily_Sync_Model_Subscriber + +