2

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
1

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

4
  • i want to send email when stock goes below a fix quantity
    – inrsaurabh
    Oct 6 '17 at 9:43
  • can you check why my custom div not shown on view page. I copied same core file
    – inrsaurabh
    Oct 6 '17 at 9:44
  • Hi @SaurabhRanjan ,there is already option in magento.Go to System > Configuration > Catalog > Inventory > Product Stock Options section section and check product stock option "Notify for Quantity Below".
    – akgola
    Oct 6 '17 at 9:57
  • i want to send mail even when a product quantity is below a fixed number
    – inrsaurabh
    Oct 11 '17 at 19:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.