How to notify when a product is added within Magento?

I’m wondering what would be the best way to notify an user when a new product is added which matches his/her interests?

I think of a cron running at least 2 times a days (or more, every hour for example)

I can also imagine to implement kind of an event system but that one may be tricky.

Do you have any feedback?

Thanks

4 thoughts on “How to notify when a product is added within Magento?”

  1. At the time of new product adding time do you want send a mail to customers then don’t go for RSS or cron just use the EVENT called “catalog_product_save_after” in your config.xml file and call one function in that function just write like this

    public function sendMailToNotifiedCustomerOk($observer){
    
           $product  = $observer->getProduct();  //get the current product
           echo "<pre>";    print_r($product); echo "</pre>";exit;
    
    }
    

    when you clicked on save button this function will execute and show you one flag value like

     [_isObjectNew:protected] => 1
    

    This values is 1 for only adding new products.

    if you are updating or editing products then this value is

     [_isObjectNew:protected] =>  
    

    so it is zero(0)

    you can write like this

    if($product->_isObjectNew)
    {
     //send email to your friends
    }
    

  2. You need to add a value to “Set Product as New from Date” attribute so that will appear in new product RSS feed. Doesn’t make sense to make new event system. This is easy way to implement such kind of things.

  3. You can create a script that runs simultaneously with the INSERT script that searches a table in your database called say “Notify” and searched loops through the table and finds everyone who signed up for say category “Toothpicks” and sends a mass email at the end to every user that is found

    So you would need to set up the variable to catch the users in ($users) and one for the category ($category = mysql_real_escape_string(‘$_POST[‘category’]); . Then set up a SELECT statement to pull from table “Kitchen_Goods” WHERE category = $category. Then set up the $rows variable so you can pull the username and email_address columns and set them to variables. then concat all the email results to have a comma in between, then echo that variable as the recipients field in your mail() function. That is a round about, incomplete way of doing it.

    Or you can just use RSS which is 100 times easier lol.

  4. You don’t state how you save customer interests, so I’ll relegate that one to magic until you say otherwise. A good way to do this is to hook an event to the catalog_product_save_after event in Magento. This function will fire whenever you save products. Create an observer that looks something like this:

    public function observeProductSave($event) {
        $product = $event['product'];
        $customers = $this->getMatchingCustomerInterests($product);
        foreach($customers as $customer) {
            //send email to that customer
        }
    }
    
    public function getMatchingCustomerInterests($product) {
        // here you'll need to use your mechanism for saving
        // customer interests to grab an array/collection of
        // customers to send the emails to.
    }
    

    Obviously this code is not 100% complete, but that’s the gist of it. You will probably want to add a facility to make sure that customers are not notified too many times about a product as well.

    Hope that helps!

    Thanks,
    Joe

Leave a Reply

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