Magento 1.8: Adding a Guest Login for Product Stock Alert

magento-1.8product

I am entirely new to Magento Development and I am attempting to add guest email signup ability to the Magento ProductAlert system. I have begun creating a module to extend the Mage_ProductAlert_AddController class and add functionality to the the stockAction function.

I have been looking at the Newsletter SubscriberController.php controller for inspiration on how to approach this issue while providing Zend_Validate, etc.

I have also created an email column within my product_alert_stock table.

I am now at a loss as to how to approach the rest of building out my module.

Best Answer

I've done this before, in short, you need to edit the following:

  1. Add an email column to the product_alert_stock table (you've already done this);
  2. Drop the FK_PRODUCT_ALERT_STOCK_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID key on that same table;
  3. Extend the _prepareCollection method of Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Alerts_Stock to load the guest entries in the grid in the backend (found under the 'Product Alerts' tab at a product), by default this method only loads customers;
  4. Extend the send method of Mage_ProductAlert_Model_Email to send emails to guests, not only customers;
  5. Extend the _processStock method of Mage_ProductAlert_Model_Observer, to process the customers and guests that registered for a stock alert.

That's all you need to do. I'm not throwing all the code at you, maybe you can figure it out for yourself now, if not, maybe I can add all the necessary code later if you'd like that.

Related Topic