cancel
Showing results for 
Search instead for 
Did you mean: 

Add product attributes to "product back in stock alert" email

Add product attributes to "product back in stock alert" email

I'm trying to edit the alert email that a customer receives when an item is back in stock. I need to add the product attributes name to the body of the email message.

 

The file "template/email/productalert/stock.phtml" is the file that sends the email. It already loops through each product

with: 

<?php foreach ($products as $product): ?>

<a href="<?php echo $product->getProductUrl() ?> ... This creates the link

To display the products attributes I tried the code below, Any ideas what I might be doing wrong?

<p><?php echo $product->getSubtitle() ?></p>  ... I need to display the attributes
5 REPLIES 5

Re: Add product attributes to "product back in stock alert" email

 

Try this:

<?php foreach ($products as $product):

$attr = $product->getResource()->getAttribute('size');
echo $attr->getId();

 

Re: Add product attributes to "product back in stock alert" email

Thanks for the response. This returns the size attributes ID, or in my situation it is the number 135 . Is there an option to return the attributes value (size 8 1/2)?

Re: Add product attributes to "product back in stock alert" email

Yes, try this snippet:

 

<?php foreach ($products as $product):

    echo $product->getAttributeText('size'); 

Re: Add product attributes to "product back in stock alert" email

Hi Neklo,

You will get value of attribute:-

 

<?php foreach ($products as $product):

    echo $product->getData('size') 

 

Re: Add product attributes to "product back in stock alert" email

It seems everything i try doesn't work.

 

I've tried:

echo $product->getData('size');
echo $product->getData('135 ');   // 135 is the ID for size

Both return empty values

$attr = $product->getResource()->getAttribute('size');
echo $attr->getId();

This returns the ID of 135

Is the data even available at this stage? Or is another call needed?