Uipl_Stockalert - Version 1.0.0.3

Version Notes

After installation of this module you should enable cron job at cpanel for magento.

Download this release

Release Info

Developer Ujjal
Extension Uipl_Stockalert
Version 1.0.0.3
Comparing to
See all releases


Code changes from version 1.0.0.2 to 1.0.0.3

app/code/community/Uipl/Stockalert/Model/Cron.php CHANGED
@@ -1,59 +1,60 @@
1
- <?php
2
- class Uipl_Stockalert_Model_Cron{
3
- public function SendAlert(){
4
-
5
- $configValue = Mage::getStoreConfig('general/stockalert/active');
6
- if($configValue!=1){
7
- Mage::log("Stock alert is disabled from admin general system configuration");
8
- return false;
9
- }
10
-
11
- $collection = Mage::getModel('catalog/product')
12
- ->getCollection()->addFieldToFilter('visibility', Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)
13
- ->addAttributeToSelect('*')->addAttributeToFilter('status', array('eq'=>'1'));
14
-
15
- $expro='<table width="100%" cellpadding="10" cellspacing="10">
16
- <tr><td>Product Id</td><td>Product Name</td><td>SKU</td><td>Product Url</td></tr>
17
- ';
18
- foreach($collection as $_product){
19
- $_product = Mage::getModel('catalog/product')->load($_product->getId());
20
-
21
-
22
- $num= Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty();
23
- $qtyStock=Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getMinQty();
24
- $qtyStock=$qtyStock-$orderqty;
25
- if($num<=$qtyStock){
26
-
27
- $expro .='<tr><td>'.$_product->getId().'</td><td>'.$_product->getName().'</td><td>'.$_product->getSku().'</td><td>'.$_product->getProductUrl().'</td></tr>';
28
-
29
- }
30
-
31
- }
32
-
33
- $expro .='</table>';
34
-
35
- $email_to=Mage::getStoreConfig('trans_email/ident_sales/email');
36
- $email_to .=",".Mage::getStoreConfig('general/stockalert/otheremails');
37
- $email_template_variables = array(
38
- 'alertGrid' => $expro,
39
-
40
-
41
- );
42
-
43
-
44
- $sender_name = Mage::getStoreConfig('trans_email/ident_general/name'); ;
45
-
46
- $sender_email = Mage::getStoreConfig('trans_email/ident_general/email');
47
-
48
- $emailTemplate->setSenderName($sender_name);
49
- $emailTemplate->setSenderEmail( $sender_email);
50
-
51
- $processedTemplate = $emailTemplate->getProcessedTemplate($email_template_variables);
52
-
53
- $emailTemplate->send($email_to,'Product Low Stock Notification', $email_template_variables);
54
-
55
-
56
-
57
-
58
- }
 
59
  }
1
+ <?php
2
+ class Uipl_Stockalert_Model_Cron{
3
+ public function SendAlert(){
4
+
5
+ $configValue = Mage::getStoreConfig('general/stockalert/active');
6
+ if($configValue!=1){
7
+ Mage::log("Stock alert is disabled from admin general system configuration");
8
+ return false;
9
+ }
10
+ $emailTemplate = Mage::getModel('core/email_template')
11
+ ->loadDefault('outofstock_email_template');
12
+ $collection = Mage::getModel('catalog/product')
13
+ ->getCollection()->addFieldToFilter('visibility', Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)
14
+ ->addAttributeToSelect('*')->addAttributeToFilter('status', array('eq'=>'1'));
15
+
16
+ $expro='<table width="100%" cellpadding="10" cellspacing="10">
17
+ <tr><td>Product Id</td><td>Product Name</td><td>SKU</td><td>Product Url</td></tr>
18
+ ';
19
+ foreach($collection as $_product){
20
+ $_product = Mage::getModel('catalog/product')->load($_product->getId());
21
+
22
+
23
+ $num= Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty();
24
+ $qtyStock=Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getMinQty();
25
+ $qtyStock=$qtyStock-$orderqty;
26
+ if($num<=$qtyStock){
27
+
28
+ $expro .='<tr><td>'.$_product->getId().'</td><td>'.$_product->getName().'</td><td>'.$_product->getSku().'</td><td>'.$_product->getProductUrl().'</td></tr>';
29
+
30
+ }
31
+
32
+ }
33
+
34
+ $expro .='</table>';
35
+
36
+ $email_to=Mage::getStoreConfig('trans_email/ident_sales/email');
37
+ $email_to .=",".Mage::getStoreConfig('general/stockalert/otheremails');
38
+ $email_template_variables = array(
39
+ 'alertGrid' => $expro,
40
+
41
+
42
+ );
43
+
44
+
45
+ $sender_name = Mage::getStoreConfig('trans_email/ident_general/name'); ;
46
+
47
+ $sender_email = Mage::getStoreConfig('trans_email/ident_general/email');
48
+
49
+ $emailTemplate->setSenderName($sender_name);
50
+ $emailTemplate->setSenderEmail( $sender_email);
51
+
52
+ $processedTemplate = $emailTemplate->getProcessedTemplate($email_template_variables);
53
+
54
+ $emailTemplate->send($email_to,'Product Low Stock Notification', $email_template_variables);
55
+
56
+
57
+
58
+
59
+ }
60
  }
app/code/community/Uipl/Stockalert/etc/config.xml CHANGED
@@ -1,50 +1,50 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <modules>
4
- <Uipl_Stockalert>
5
- <version>0.0.1</version>
6
- </Uipl_Stockalert>
7
- </modules>
8
- <global>
9
- <models>
10
- <stockalert>
11
- <class>Uipl_Stockalert_Model</class>
12
- <resourceModel>stockalert_mysql4</resourceModel>
13
- </stockalert>
14
- </models>
15
- <events>
16
- <sales_order_place_before>
17
- <observers>
18
- <uipl_stockalert_model_observer>
19
- <type>singleton</type>
20
- <class>Uipl_Stockalert_Model_Observer</class>
21
- <method>getalert</method>
22
- </uipl_stockalert_model_observer>
23
- </observers>
24
- </sales_order_place_before>
25
- </events>
26
-
27
- <template>
28
- <email>
29
- <outofstock_email_template module="stockalert">
30
- <label>Out of stock email module</label>
31
- <file>admin_stock_alert.html</file>
32
- <type>html</type>
33
- </outofstock_email_template>
34
- </email>
35
- </template>
36
- </global>
37
-
38
-
39
- <crontab>
40
- <jobs>
41
- <stockalert_sendalert>
42
- <schedule><cron_expr>* * * * *</cron_expr></schedule>
43
- <run><model>stockalert/cron::SendAlert</model></run>
44
- </stockalert_sendalert>
45
- </jobs>
46
- </crontab>
47
-
48
-
49
-
50
  </config>
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Uipl_Stockalert>
5
+ <version>0.0.1</version>
6
+ </Uipl_Stockalert>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <stockalert>
11
+ <class>Uipl_Stockalert_Model</class>
12
+ <resourceModel>stockalert_mysql4</resourceModel>
13
+ </stockalert>
14
+ </models>
15
+ <events>
16
+ <sales_order_place_before>
17
+ <observers>
18
+ <uipl_stockalert_model_observer>
19
+ <type>singleton</type>
20
+ <class>Uipl_Stockalert_Model_Observer</class>
21
+ <method>getalert</method>
22
+ </uipl_stockalert_model_observer>
23
+ </observers>
24
+ </sales_order_place_before>
25
+ </events>
26
+
27
+ <template>
28
+ <email>
29
+ <outofstock_email_template module="stockalert">
30
+ <label>Out of stock email module</label>
31
+ <file>admin_stock_alert.html</file>
32
+ <type>html</type>
33
+ </outofstock_email_template>
34
+ </email>
35
+ </template>
36
+ </global>
37
+
38
+
39
+ <crontab>
40
+ <jobs>
41
+ <stockalert_sendalert>
42
+ <schedule><cron_expr>*/1 * * * *</cron_expr></schedule>
43
+ <run><model>stockalert/cron::SendAlert</model></run>
44
+ </stockalert_sendalert>
45
+ </jobs>
46
+ </crontab>
47
+
48
+
49
+
50
  </config>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Uipl_Stockalert</name>
4
- <version>1.0.0.2</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
@@ -10,9 +10,9 @@
10
  <description>This module will generate out of stock alert notification for admin when product goes below minimum stock.</description>
11
  <notes>After installation of this module you should enable cron job at cpanel for magento.</notes>
12
  <authors><author><name>Ujjal Dutta</name><user>ujjaldutta</user><email>ujjal.dutta.pro@gmail.com</email></author></authors>
13
- <date>2015-10-29</date>
14
- <time>14:52:08</time>
15
- <contents><target name="magecommunity"><dir name="Uipl"><dir name="Stockalert"><dir name="Model"><file name="Cron.php" hash="6ad38b494f7573d7c986a006a382ee23"/><file name="Observer.php" hash="ba703cec79a8580bc49cb1c17594b76b"/></dir><dir name="etc"><file name="adminhtml.xml" hash="d39956779ec5c37a2cff0bf04c70729d"/><file name="config.xml" hash="51c340059949d28e9cfe791b18e0cb16"/><file name="system.xml" hash="ef575d85bf311bf2f11727ba7a651d61"/></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><dir name="template"><dir name="email"><file name="admin_stock_alert.html" hash="14fc57366851be80b061cf29356794eb"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Uipl_Stockalert.xml" hash="c441dfaa4fcc00683f7541f730345c0c"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Uipl_Stockalert</name>
4
+ <version>1.0.0.3</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
10
  <description>This module will generate out of stock alert notification for admin when product goes below minimum stock.</description>
11
  <notes>After installation of this module you should enable cron job at cpanel for magento.</notes>
12
  <authors><author><name>Ujjal Dutta</name><user>ujjaldutta</user><email>ujjal.dutta.pro@gmail.com</email></author></authors>
13
+ <date>2015-11-14</date>
14
+ <time>19:22:49</time>
15
+ <contents><target name="magecommunity"><dir name="Uipl"><dir name="Stockalert"><dir name="Model"><file name="Cron.php" hash="b16ba267777e27a0ca976ff26c7d05e6"/><file name="Observer.php" hash="ba703cec79a8580bc49cb1c17594b76b"/></dir><dir name="etc"><file name="adminhtml.xml" hash="d39956779ec5c37a2cff0bf04c70729d"/><file name="config.xml" hash="6d01388b74dd7d071e4cb3e941169e7a"/><file name="system.xml" hash="ef575d85bf311bf2f11727ba7a651d61"/></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><dir name="template"><dir name="email"><file name="admin_stock_alert.html" hash="14fc57366851be80b061cf29356794eb"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Uipl_Stockalert.xml" hash="c441dfaa4fcc00683f7541f730345c0c"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>