Version Notes
After installation of this module you need to enable stock alert enabled from system configuration and cron job at cpanel for magento.
Download this release
Release Info
Developer | Ujjal |
Extension | Uipl_Stockalert |
Version | 1.0.0.5 |
Comparing to | |
See all releases |
Code changes from version 1.0.0.4 to 1.0.0.5
app/code/community/Uipl/Stockalert/Helper/Data.php
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Uipl_Stockalert_Helper_Data extends Mage_Core_Helper_Abstract
|
3 |
+
{
|
4 |
+
}
|
5 |
+
|
app/code/community/Uipl/Stockalert/Model/Observer.php
CHANGED
@@ -1,78 +1,77 @@
|
|
1 |
-
<?php
|
2 |
-
class Uipl_Stockalert_Model_Observer {
|
3 |
-
|
4 |
-
public function getalert($observer) {
|
5 |
-
|
6 |
-
$configValue = Mage::getStoreConfig('general/stockalert/active');
|
7 |
-
if($configValue!=1){
|
8 |
-
Mage::log("Stock alert is disabled from admin general system configuration");
|
9 |
-
return false;
|
10 |
-
}
|
11 |
-
|
12 |
-
$order = $observer->getEvent()->getOrder();
|
13 |
-
|
14 |
-
$orders = Mage::getModel("sales/order")->load($order->getId());
|
15 |
-
|
16 |
-
|
17 |
-
$ordered_items = $orders->getAllItems();
|
18 |
-
|
19 |
-
foreach($ordered_items as $item){
|
20 |
-
|
21 |
-
$product_id =$item->getProductId();
|
22 |
-
//product id
|
23 |
-
|
24 |
-
$orderqty= $item->getQtyOrdered();
|
25 |
-
$_product = Mage::getModel('catalog/product')->load($product_id);
|
26 |
-
//$qtyStock= $_product->getMinQty();
|
27 |
-
|
28 |
-
$num= Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty();
|
29 |
-
$qtyStock=Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getMinQty();
|
30 |
-
$qtyStock=$qtyStock-$orderqty;
|
31 |
-
if($num<=$qtyStock){
|
32 |
-
$email_to=Mage::getStoreConfig('trans_email/ident_sales/email');
|
33 |
-
$email_to .=",".Mage::getStoreConfig('general/stockalert/otheremails');
|
34 |
-
$emailTemplate = Mage::getModel('core/email_template')
|
35 |
-
->loadDefault('outofstock_email_template');
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
$expro='<table width="100%" cellpadding="10" cellspacing="10">
|
40 |
-
<tr><td>Product Id</td><td>Product Name</td><td>SKU</td><td>Product Url</td></tr>
|
41 |
-
';
|
42 |
-
|
43 |
-
$expro .='<tr><td>'.$_product->getId().'</td><td>'.$_product->getName().'</td><td>'.$_product->getSku().'</td><td>'.$_product->getProductUrl().'</td></tr>';
|
44 |
-
|
45 |
-
|
46 |
-
$expro .='</table>';
|
47 |
-
|
48 |
-
$email_template_variables = array(
|
49 |
-
'alertGrid' => $expro,
|
50 |
-
|
51 |
-
|
52 |
-
);
|
53 |
-
|
54 |
-
|
55 |
-
$sender_name = Mage::getStoreConfig('trans_email/ident_general/name'); ;
|
56 |
-
|
57 |
-
$sender_email = Mage::getStoreConfig('trans_email/ident_general/email');
|
58 |
-
|
59 |
-
$emailTemplate->setSenderName($sender_name);
|
60 |
-
$emailTemplate->setSenderEmail( $sender_email);
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
}
|
78 |
?>
|
1 |
+
<?php
|
2 |
+
class Uipl_Stockalert_Model_Observer {
|
3 |
+
|
4 |
+
public function getalert($observer) {
|
5 |
+
|
6 |
+
$configValue = Mage::getStoreConfig('general/stockalert/active');
|
7 |
+
if($configValue!=1){
|
8 |
+
Mage::log("Stock alert is disabled from admin general system configuration");
|
9 |
+
return false;
|
10 |
+
}
|
11 |
+
|
12 |
+
$order = $observer->getEvent()->getOrder();
|
13 |
+
|
14 |
+
$orders = Mage::getModel("sales/order")->load($order->getId());
|
15 |
+
|
16 |
+
|
17 |
+
$ordered_items = $orders->getAllItems();
|
18 |
+
|
19 |
+
foreach($ordered_items as $item){
|
20 |
+
|
21 |
+
$product_id =$item->getProductId();
|
22 |
+
//product id
|
23 |
+
|
24 |
+
$orderqty= $item->getQtyOrdered();
|
25 |
+
$_product = Mage::getModel('catalog/product')->load($product_id);
|
26 |
+
//$qtyStock= $_product->getMinQty();
|
27 |
+
|
28 |
+
$num= Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty();
|
29 |
+
$qtyStock=Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getMinQty();
|
30 |
+
$qtyStock=$qtyStock-$orderqty;
|
31 |
+
if($num<=$qtyStock){
|
32 |
+
$email_to=Mage::getStoreConfig('trans_email/ident_sales/email');
|
33 |
+
$email_to .=",".Mage::getStoreConfig('general/stockalert/otheremails');
|
34 |
+
$emailTemplate = Mage::getModel('core/email_template')
|
35 |
+
->loadDefault('outofstock_email_template');
|
36 |
+
|
37 |
+
|
38 |
+
|
39 |
+
$expro='<table width="100%" cellpadding="10" cellspacing="10">
|
40 |
+
<tr><td>Product Id</td><td>Product Name</td><td>SKU</td><td>Product Url</td></tr>
|
41 |
+
';
|
42 |
+
|
43 |
+
$expro .='<tr><td>'.$_product->getId().'</td><td>'.$_product->getName().'</td><td>'.$_product->getSku().'</td><td>'.$_product->getProductUrl().'</td></tr>';
|
44 |
+
|
45 |
+
|
46 |
+
$expro .='</table>';
|
47 |
+
|
48 |
+
$email_template_variables = array(
|
49 |
+
'alertGrid' => $expro,
|
50 |
+
|
51 |
+
|
52 |
+
);
|
53 |
+
|
54 |
+
|
55 |
+
$sender_name = Mage::getStoreConfig('trans_email/ident_general/name'); ;
|
56 |
+
|
57 |
+
$sender_email = Mage::getStoreConfig('trans_email/ident_general/email');
|
58 |
+
|
59 |
+
$emailTemplate->setSenderName($sender_name);
|
60 |
+
$emailTemplate->setSenderEmail( $sender_email);
|
61 |
+
|
62 |
+
$processedTemplate = $emailTemplate->getProcessedTemplate($email_template_variables);
|
63 |
+
|
64 |
+
$emailTemplate->send($email_to,'Product Low Stock Notification', $email_template_variables);
|
65 |
+
|
66 |
+
|
67 |
+
}
|
68 |
+
|
69 |
+
|
70 |
+
//Mage::log('pid='. $product_id." sale qty =".$orderqty." stock qty=".$qtyStock." another qty=".$num.$processedTemplate);
|
71 |
+
|
72 |
+
}
|
73 |
+
|
74 |
+
}
|
75 |
+
|
76 |
+
}
|
|
|
77 |
?>
|
app/code/community/Uipl/Stockalert/etc/config.xml
CHANGED
@@ -6,6 +6,12 @@
|
|
6 |
</Uipl_Stockalert>
|
7 |
</modules>
|
8 |
<global>
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
<models>
|
10 |
<stockalert>
|
11 |
<class>Uipl_Stockalert_Model</class>
|
6 |
</Uipl_Stockalert>
|
7 |
</modules>
|
8 |
<global>
|
9 |
+
<helpers>
|
10 |
+
<stockalert>
|
11 |
+
<class>Uipl_Stockalert_Helper</class>
|
12 |
+
</stockalert>
|
13 |
+
</helpers>
|
14 |
+
|
15 |
<models>
|
16 |
<stockalert>
|
17 |
<class>Uipl_Stockalert_Model</class>
|
package.xml
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Uipl_Stockalert</name>
|
4 |
-
<version>1.0.0.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
-
<summary>
|
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
|
12 |
-
<authors><author><name>
|
13 |
-
<date>2015-11-
|
14 |
-
<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="
|
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.5</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>
|
8 |
<extends/>
|
9 |
+
<summary>Send notification to admin using cron job and on order place when stock is low.</summary>
|
10 |
+
<description>This module will generate out of stock alert notification for admin when product goes below minimum stock.After installation of this module you should enable cron job at cpanel for magento.</description>
|
11 |
+
<notes>After installation of this module you need to enable stock alert enabled from system configuration and 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-29</date>
|
14 |
+
<time>06:12:57</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Uipl"><dir name="Stockalert"><dir name="Helper"><file name="Data.php" hash="97ae3bc9b0493e0db9e9b02cfdd10e73"/></dir><dir name="Model"><file name="Cron.php" hash="b16ba267777e27a0ca976ff26c7d05e6"/><file name="Observer.php" hash="802b44d82fee08de4aea0f30d0f173b1"/></dir><dir name="etc"><file name="adminhtml.xml" hash="d39956779ec5c37a2cff0bf04c70729d"/><file name="config.xml" hash="5050951f447011df0a39d141745f4c5a"/><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>
|