I want to create a stock alert where user can subscribe
product_alert_stock
table in the database store details when user click on subscribe link.
Currently it sends on two conditions : On stock change
and Price change
.
I want to send email if stock goes below a fixed quantity.
For this i created an custom attribute
namely send_mail_qty
It must send an email to the customer when a product is below a fixed quantity
i created a custom module
and using event “
in config.xml
<events>
<cataloginventory_stock_item_save_after> <!-- identifier of the event we want to catch -->
<observers>
<cataloginventory_stock_item_save_after_handler> <!-- identifier of the event handler -->
<type>model</type> <!-- class method call type; valid are model, object and singleton -->
<class>customalert/observer</class> <!-- observers class alias -->
<method>stockChange</method> <!-- observer's method to be called -->
<args></args> <!-- additional arguments passed to observer -->
</cataloginventory_stock_item_save_after_handler>
</observers>
</cataloginventory_stock_item_save_after>
</events>
In observer.php
public function stockChange(Varien_Event_Observer $observer)
{
$arg_attribute = 'send_mail_qty';
$attribute_model = Mage::getModel('eav/entity_attribute');
$attribute_options_model= Mage::getModel('eav/entity_attribute_source_table') ;
$attribute_code = $attribute_model->getIdByCode('catalog_product', $arg_attribute);
$attribute = $attribute_model->load($attribute_code);
$attribute_table = $attribute_options_model->setAttribute($attribute);
$options = $attribute_options_model->getAllOptions();
Mage::log( 'start');
Mage::log( $options );
// Mage::log( print_r($val) );
Mage::log( 'end');
}
}
But it gives me
2017-10-13T06:26:42+00:00 DEBUG (7): start
2017-10-13T06:26:42+00:00 DEBUG (7): Array
(
[0] => Array
(
[label] =>
[value] =>
)
)
2017-10-13T06:26:42+00:00 DEBUG (7): end
Best Answer
Magento Default provide product alert module so configure phtml file as per your requirement.You don't need to create custom module for it.
Read Magento Doc http://docs.magento.com/m1/ce/user_guide/catalog/inventory-product-alert.html