Question

how to Setup alert emails for wish list availability in magento. Assuming the product is in out of stock when customer wanted to purchase it and he added to wish list.so When product is available customer get notified.

Was it helpful?

Solution

Magento already offers a functionality to notify customers when a product gets back in stock.
In my opinion the moral thing to do is not to notify the customer if a product from the wishlist is back in stock. Just let him subscribe to the "back in stock" alert if he wants to.
But if you insist you can observe the event wishlist_add_product and, if the product that is added to the wishlist is out of stock, just subscribe automatically the customer to the stock alert.
Something like this:

public function checkWishlistItem($observer) {
    $product = $observer->getEvent()->getProduct();
    if (!$product->getIsSalable()) {// if out of stock
        //subscribe to stock alert
        $model = Mage::getModel('productalert/stock')
                ->setCustomerId(Mage::getSingleton('customer/session')->getId())
                ->setProductId($product->getId())
                ->setWebsiteId(Mage::app()->getStore()->getWebsiteId());
        $model->save();
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top