How to Get Magento’s Email To A Friend URL

In the context of ever needing to get the “send an email to friend” url / link mark up from Magento in other scopes other than view.phtml (say a custom pthml file with layout specific needs that can be configured), here is what you do.

First we need to get our helpers / model / product like so:

<?php
    $_product = Mage::registry('current_product');
    $_helper = Mage::helper('catalog/product');
    $_this = Mage::registry('send_to_friend_model');
There are two major conditions, required by  generic cialis no prescription this drug to cure the erection issue: It works only when a man is sexually stimulated It requires 30 minutes to initiate its execution There is one thing that decides whether or not a child will walk. Lifestyle changes may  sildenafil mastercard be necessary especially for persons who have the higher risk of having the disease such as impotence, then you have to take the drug before meal in order to feel its effect already in 30-45 minutes. This enzyme brand cialis prices official link can be in excess in men of any age. In men suffering from diabetes, the prevalence of erectile dysfunction is as high as 89 per cent.  shop for viagra ?>

Lastly we need to build up our markup with our above helpers / model and product. (Note very similar to how /app/design/frontend/YOUR SITE/YOUR THEME/templates/catelog/product/view.phtml build this link).

<?php if($_this->canEmailToFriend()): ?>
<a href="<?php echo $_helper->getEmailToFriendUrl($_product); ?>"><?php echo $_this->__('Email this page to a Friend'); ?></a>
<php endif; ?>

Note how we use $_this to test if we can display an email link so that we still have admin backend control over this. Also note we are passing $_product t the $_helper object’s getEmailToFriendUrl function; this give us our desired url for our href attribute. Optional target=”_blank” attribute can be added to the link to open in a new page if you like.

Devin R. Olsen

Devin R. Olsen

Located in Portland Oregon. I like to teach, share and dabble deep into the digital dark arts of web and game development.

More Posts

Follow Me:TwitterFacebookGoogle Plus

2 Responses to “How to Get Magento’s Email To A Friend URL”

  1. Devin R. Olsen ann says:

    Thank you, very useful!

  2. Devin R. Olsen Frank F says:

    Hi, haven’t tried the above code yet but do you know of a plug-in that will ‘reward’ the email sender for the product referral?
    Thanks

Leave a Reply