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')->getCustomer()->getId();
$customer_stock_alerts = Mage::getModel('productalert/stock')
         ->getCollection()
         ->addFieldToFilter('customer_id', $customer_id);
foreach ( $customer_stock_alerts as $alert )
{
 echo $alert->getProductId();
}
  • Product price alert list
$customer_id = Mage::getSingleton('customer/session')->getCustomer()->getId();
$customer_price_alerts = Mage::getModel('productalert/price')
         ->getCollection()
         ->addFieldToFilter('customer_id', $customer_id);
foreach ( $customer_price_alerts as $alert )
{
 echo $alert->getProductId();
}
Categories: Getting things

3 Comments

rixitRixit · April 4, 2013 at 6:10 am

But Here, you are not write where I put this code. For this I need to make the Module using the Module Creator or need to set this code in any File. please Help me.

Thanks

    Pau · April 11, 2013 at 5:29 am

    Hi rixitrixit,

    You should include your module into your block or model, that’s up to your needs!

idan abada · January 10, 2014 at 1:36 am

it didn’t work… I tried putting it in the file at the end of: Subscriber.php
but it shows nothing. I tried to put it as an html on a page in magento also did not work. I will be SO HAPPY if you can tell me to create a new file that I can put a code in and see all the product alerts to back in stock items!

thank you so much!!!!!

Leave a Reply

Your email address will not be published. Required fields are marked *

Press Ctrl+C to copy the following code.
"