Skip to content

Get customer product alert subscriptions list in Magento

December 5, 2011

Some things are easy, some things are not. This one is easy-peasy.

If you want to get the product list that a customer has been subscribed to (price or stock alert), you need to use the productalert model.

  • Product stock alert list

$customer_id = Mage::getSingleton('customer/session')-&gt;getCustomer()-&gt;getId();</p>
<p>$customer_stock_alerts = Mage::getModel('productalert/stock')<br />
         -&gt;getCollection()<br />
         -&gt;addFieldToFilter('customer_id', $customer_id);</p>
<p>foreach ( $customer_stock_alerts as $alert )<br />
{<br />
 echo $alert-&gt;getProductId();<br />
}

  • Product price alert list

$customer_id = Mage::getSingleton('customer/session')-&gt;getCustomer()-&gt;getId();</p>
<p>$customer_price_alerts = Mage::getModel('productalert/price')<br />
         -&gt;getCollection()<br />
         -&gt;addFieldToFilter('customer_id', $customer_id);</p>
<p>foreach ( $customer_price_alerts as $alert )<br />
{<br />
 echo $alert-&gt;getProductId();<br />
}

Advertisements

From → Getting things

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: