Monday, July 3, 2017

Magento 1.9 Newsletter Unsubscribe Link Not Working

Yes.... still we are working on Magento 1.9 as Magento 2.0 is bit difficult to work with and there were some bugs in it. So recently we created magento store with Magento 1.9 where we faced an issue of adding unsubscribe link in subscription success email and other newsletter.

Subscriber object is shared with all the newsletter email templates. So to add unsubscribe link you just have to add following code.

<a href="{{var subscriber.getUnsubscriptionLink() }}"> Unsubscribe </a>

 But somehow this was not working. So after checking system log we found following error.

getUnsubscribeUrl function not found for Mage_Newsletter_Helper_Data class.

Now this was a strange issue as this is the basic functionality of Magento 1.9 and it is not working. So I checked the Mage_Newsletter_Helper_Data class in app/code/core/Mage/Newsletter/Helper folder and there was no such function but the function name was different.

Following is the function found in data.php

public function getUnsubscribeLink($subscriber)
    {
        return Mage::getModel('core/url')
            ->setStore($subscriber->getStoreId())
            ->getUrl('newsletter/subscriber/unsubscribe', array(
                'id'     => $subscriber->getId(),
                'code'   => $subscriber->getCode(),
                '_nosid' => true
            ));
    }

And in app/code/core/Mage/Newsletter/Model/Subscriber.php file following is the function.

public function getUnsubscriptionLink() {
        return Mage::helper('newsletter')->getUnsubscribeUrl($this);
    }

Which was used in template. So that was the issue. So to solve this issue replace above function with following function in app/code/core/Mage/Newsletter/Model/Subscriber.php file.

public function getUnsubscriptionLink() {
        return Mage::helper('newsletter')->getUnsubscribeLink($this);
    }

And now it should work. Hope this helps you.

Friday, June 2, 2017

Magento Amazon SES - Transactional Emails Not Working with SMTP Pro

Recently in one of our project, we were using Amazon SES service with SMTP pro extension in Magento 1.9. After verification of domain and sender email address, when we to test in SMTP pro, it was working fine. But when we try to send transactional emails such as new order, invoice etc. It was not working. So on debugging we found following exception.

Email address is not verified. The following identities failed the check in region US-EAST-1: hdave10@gmail.com

Now that was bit strange as that raised a question that do we have to verify all the receiver email as well and that was practically not possible as in Magento we can have any number of customers. 

So I checked docs of Amazon SES and after reading for a while I got the issue. 

The issue was we have configured three regions in Amazon SES. But we were still in sandbox mode for two regions and mail was sending from the region where we were still running in sandbox mode. 

To solve this issue log in to your Amazon SES console and select region from top left corner.


Once you select region, Go to SES Sending Limits Increase case.

and submit for limit increase. It will take a while to process your request. Once your limit is increased, you will come out of sandbox mode. You have to do this process for all the regions.

Hope this helps you.

Wednesday, May 31, 2017

Amazon EC2 Create Swap Space

Hello,

Recently in one of my project we have laravel application deployed on amazon ec2 instance. When running composer update command, we were facing issue of swap space as it was not defined. So in this blog I will explain how you can create swap space in your amazon ec2 instance. Please note these steps are specifically for ubuntu instance. If you are running other version of liunx, please check commands first and then use it.

1) Create swap file

sudo fallocate -l 1G /swapfile

2) Verify it

ls -lh /swapfile

It should show following output.

-rw-r--r-- 1 root root 1.0G Apr 25 11:14 /swapfile

3) Enable it and make it accessible by only root user.

sudo chmod 600 /swapfile

sudo mkswap /swapfile

sudo swapon /swapfile

That's it now you have swap space configured in your instance.