0

I am a Magento newbie and I am not much of a PHP guy either.

I am setting up abandoned cart emails in our magento site and it uses Abandoned Carts Pro extension to generate these abandoned cart tables. I want to change the format of the mail that would be sent, and I can't seem to understand how the email variables work.

Right now, the template at app/locale/en_US/template/email/abandoned_cart.html looks like this:

<table cellspacing="0" cellpadding="0" border="0" width="650">
    <tr>
       <td valign="top">
          <p><strong>Hello {{var customer_name}},</strong></p>
          <p>Thank you for stopping by {{var website_name}} and considering us for your purchase. We noticed that during your visit to our store you placed the following item(s) in your shopping cart, but did not complete the transaction.</p>
          <p>Shopping Cart Contents: </p>
          <p>{{var products}}</p>

I want to add a tracking code to the product link that comes from {{url products}} and I don't know where this code is being generated or how to change it. I have tried changing the product code to look like this, to check if any of these variables work:

      <p>Shopping Cart Contents: </p>
      <p>{{var products}}</p>
      <p>{{var product_name}}</p>
      <p>{{var product_url}}</p>
      <p>{{var product_image}}</p>
      <p>{{var product_url}}?utm_source=abandoned_cart&utm_medium=email</p>

but the variables are not working like the reference suggests. All I end up getting are empty <p> tags with the analytics text.

How can I add the tracking code to product urls that would get generated?

  • template variables are set before sending the e-mail, check the controller or model or block of the module. – Pankaj Dec 19 '14 at 12:17
  • @Pankaj: Sorry for being ignorant, but could you tell me where should I be looking for them? – Bharadwaj Srigiriraju Dec 19 '14 at 12:47
1

Figured this out myself, and wanted to post the answer. Also answered here.

The code that generates the products is in the models of the third-party extension I've installed for sending the cart emails. I have too many extensions installed, and couldn't find this one easily.

I understood that all the extension related code is in app/code/local/<extension-name>/Cartalert. (the Cartalert directory would be named differently depending on the extension). I did this by greping through my repository searching for "Save and Send out" text, which is used in CMS for manually sending these emails.

grep -Ril "Save and Send out" <directory>

This was my reference. Also, if you're dealing with custom emails like me, this would help.

Next I went to the model where these alerts are being generated, which was in app/local/<extension-name>/Cartalert/Model/Cartalert.php

This was the relevant code I had to change.

for ($i=0, $n=sizeof($prod); $i<$n; $i+=2){
            $product = Mage::getModel('catalog/product')
                ->setStoreId($this->getStoreId())
                ->load($prod[$i]);
            if(in_array($product->getStatus(),$status)&&in_array($product->getVisibility(),$visibility)&&$product->isSaleable())
            {
                $url = $baseUrl . 'catalog/product/view/id/'.$prod[$i];
                $name = $prod[$i+1];

I had to append the parameters to the $url string, and it got the job done. Never thought grep would help me more than the docs... :D

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.