Webcreta_OutofStockSubscription - Version 0.1.0

Version Notes

Minor bug fixed

Download this release

Release Info

Developer WebCreta
Extension Webcreta_OutofStockSubscription
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

Files changed (21) hide show
  1. app/code/local/Webcreta/OutofStockSubscription/Block/Adminhtml/Subcriber.php +13 -0
  2. app/code/local/Webcreta/OutofStockSubscription/Block/Adminhtml/Subcriber/Grid.php +103 -0
  3. app/code/local/Webcreta/OutofStockSubscription/Helper/Data.php +13 -0
  4. app/code/local/Webcreta/OutofStockSubscription/Model/Info.php +44 -0
  5. app/code/local/Webcreta/OutofStockSubscription/Model/Mysql4/Info.php +76 -0
  6. app/code/local/Webcreta/OutofStockSubscription/Model/Mysql4/Subscriber.php +9 -0
  7. app/code/local/Webcreta/OutofStockSubscription/Model/Mysql4/Subscriber/Collection.php +30 -0
  8. app/code/local/Webcreta/OutofStockSubscription/Model/Observer.php +111 -0
  9. app/code/local/Webcreta/OutofStockSubscription/Model/Subscriber.php +12 -0
  10. app/code/local/Webcreta/OutofStockSubscription/controllers/Adminhtml/SubscriberController.php +61 -0
  11. app/code/local/Webcreta/OutofStockSubscription/controllers/IndexController.php +36 -0
  12. app/code/local/Webcreta/OutofStockSubscription/etc/config.xml +155 -0
  13. app/code/local/Webcreta/OutofStockSubscription/etc/system.xml +44 -0
  14. app/code/local/Webcreta/OutofStockSubscription/sql/outofstocksubscription_setup/mysql4-install-0.1.0.php +28 -0
  15. app/design/adminhtml/default/default/template/outofstocksubscription/widget/grid.phtml +244 -0
  16. app/design/frontend/base/default/layout/outofstocksubscription.xml +10 -0
  17. app/design/frontend/base/default/template/outofstocksubscription/catalog/product/view.phtml +226 -0
  18. app/etc/modules/Webcreta_OutofStockSubscription.xml +13 -0
  19. app/locale/en_US/template/email/outofstock_subscription.html +30 -0
  20. doc/OutofStockSubscription.pdf +0 -0
  21. package.xml +34 -0
app/code/local/Webcreta/OutofStockSubscription/Block/Adminhtml/Subcriber.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Webcreta_OutofStockSubscription_Block_Adminhtml_Subcriber extends Mage_Adminhtml_Block_Widget_Grid_Container
4
+ {
5
+ public function __construct()
6
+ {
7
+ $this->_blockGroup = 'outofstocksubscription';
8
+ $this->_controller = 'adminhtml_subcriber';
9
+ $this->_headerText = Mage::helper('outofstocksubscription')->__('Out of Stock Subscribers');
10
+ parent::__construct();
11
+ $this->_removeButton('add');
12
+ }
13
+ }
app/code/local/Webcreta/OutofStockSubscription/Block/Adminhtml/Subcriber/Grid.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Webcreta_OutofStockSubscription_Block_Adminhtml_Subcriber_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('subcribersGrid');
9
+ $this->setUseAjax(true);
10
+ $this->setDefaultSort('id');
11
+ $this->setDefaultDir('DESC');
12
+ $this->setSaveParametersInSession(true);
13
+
14
+ $this->setTemplate('outofstocksubscription/widget/grid.phtml');
15
+ }
16
+
17
+ protected function _prepareCollection()
18
+ {
19
+ /*$collection = Mage::getModel('catalog/product')->getCollection()
20
+ ->addAttributeToSelect('name')
21
+ ->addAttributeToSelect('supplier')
22
+ ->addAttributeToSelect('supplier_sku')
23
+ ->joinField('email',
24
+ 'outofstocksubscription_info',
25
+ 'email',
26
+ 'product_id=entity_id')
27
+ //->join(array('table_alias'=>'outofstocksubscription_info'), 'e.entity_id = table_alias.product_id', array('table_alias.email'));
28
+ ;
29
+ */
30
+ $collection = Mage::getResourceModel('outofstocksubscription/subscriber_collection');
31
+ //echo $collection->getSelect();
32
+ $this->setCollection($collection);
33
+ //$this->getCollection()->getSelect()->joinRight(array('table_alias'=>'outofstocksubscription_info'), 'e.entity_id = table_alias.product_id', array('table_alias.email'));
34
+
35
+ parent::_prepareCollection();
36
+ //echo $this->getCollection()->getSelect();
37
+ return $this;
38
+ }
39
+
40
+ protected function _prepareColumns()
41
+ {
42
+ $this->addColumn('email', array(
43
+ 'header' => Mage::helper('outofstocksubscription')->__('Email'),
44
+ 'width' => '100px',
45
+ 'index' => 'email',
46
+ ));
47
+
48
+ $this->addColumn('product_id', array(
49
+ 'header' => Mage::helper('outofstocksubscription')->__('Product ID'),
50
+ 'width' => '50px',
51
+ 'index' => 'product_id',
52
+ 'type' => 'number'
53
+ ));
54
+
55
+ $this->addColumn('sku', array(
56
+ 'header' => Mage::helper('outofstocksubscription')->__('SKU'),
57
+ 'width' => '100px',
58
+ 'index' => 'sku',
59
+ ));
60
+
61
+ $this->addColumn('product_name', array(
62
+ 'header' => Mage::helper('outofstocksubscription')->__('Product Name'),
63
+ 'width' => '100px',
64
+ 'index' => 'product_id',
65
+ ));
66
+
67
+ $this->addColumn('date', array(
68
+ 'header' => Mage::helper('outofstocksubscription')->__('Subscribed On'),
69
+ 'index' => 'date',
70
+ 'type' => 'datetime',
71
+ 'width' => '100px',
72
+ ));
73
+
74
+ $this->addColumn('action', array(
75
+ 'header' => Mage::helper('outofstocksubscription')->__('Action'),
76
+ 'width' => '50px',
77
+ 'index' => 'id',
78
+ 'filter' => false,
79
+ 'sortable' => false,
80
+ ));
81
+
82
+ /*$this->addColumn('action',
83
+ array(
84
+ 'header' => Mage::helper('outofstocksubscription')->__('Action'),
85
+ 'width' => '50px',
86
+ 'type' => 'action',
87
+ 'getter' => 'getId',
88
+ 'actions' => array(
89
+ array(
90
+ 'caption' => Mage::helper('outofstocksubscription')->__('Delete'),
91
+ 'url' => array(
92
+ 'base'=>'outofstocksubscription/adminhtml_subscriber/delete'
93
+ ),
94
+ 'field' => 'id'
95
+ )
96
+ ),
97
+ 'filter' => false,
98
+ 'sortable' => false,
99
+ ));*/
100
+
101
+ return parent::_prepareColumns();
102
+ }
103
+ }
app/code/local/Webcreta/OutofStockSubscription/Helper/Data.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Webcreta
4
+ * @package Webcreta_OutofStockSubscription
5
+ */
6
+
7
+ /**
8
+ * Out of Stock Subscription data helper
9
+ */
10
+ class Webcreta_OutofStockSubscription_Helper_Data extends Mage_Core_Helper_Abstract
11
+ {
12
+
13
+ }
app/code/local/Webcreta/OutofStockSubscription/Model/Info.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Webcreta_OutofStockSubscription_Model_Info extends Mage_Core_Model_Abstract
4
+ {
5
+ protected function _construct()
6
+ {
7
+
8
+ }
9
+
10
+ public function saveSubscrition($productId, $email)
11
+ {
12
+ Mage::getResourceSingleton('outofstocksubscription/info')->saveSubscrition($productId, $email);
13
+ }
14
+
15
+ public function deleteSubscrition($id)
16
+ {
17
+ Mage::getResourceSingleton('outofstocksubscription/info')->deleteSubscrition($id);
18
+ }
19
+
20
+ public function getProducts()
21
+ {
22
+ return Mage::getResourceSingleton('outofstocksubscription/info')->getProducts();
23
+ }
24
+
25
+ public function saveProductAttributesInfo($productId, $supplier, $supplierSku)
26
+ {
27
+ Mage::getResourceSingleton('outofstocksubscription/info')->saveProductAttributesInfo($productId, $supplier, $supplierSku);
28
+ }
29
+
30
+ public function getSupplierAttributeId()
31
+ {
32
+ return Mage::getResourceSingleton('outofstocksubscription/info')->getSupplierAttributeId();
33
+ }
34
+
35
+ public function getSupplierValues($supplierAttributeId)
36
+ {
37
+ return Mage::getResourceSingleton('outofstocksubscription/info')->getSupplierValues($supplierAttributeId);
38
+ }
39
+
40
+ public function getCollection()
41
+ {
42
+ return Mage::getResourceSingleton('outofstocksubscription/info')->getCollection();
43
+ }
44
+ }
app/code/local/Webcreta/OutofStockSubscription/Model/Mysql4/Info.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Webcreta_OutofStockSubscription_Model_Mysql4_Info extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ protected function _construct()
6
+ {
7
+ $this->_init('core/store', 'store_id');
8
+ }
9
+
10
+ public function saveSubscrition($productId, $email)
11
+ {
12
+ $write = $this->_getWriteAdapter();
13
+ $read = $this->_getReadAdapter();
14
+
15
+ $select = $read->select()
16
+ ->from($this->getTable('outofstocksubscription/info'))
17
+ ->where("product_id = ".$productId." AND email = '".$email."'");
18
+ $result = $read->fetchRow($select);
19
+
20
+ if (!isset($result['id'])) {
21
+ $write->insert($this->getTable('outofstocksubscription/info'), array('product_id'=>$productId, 'email'=>$email, 'date'=>date('Y-m-d H:i:s')));
22
+ }
23
+ }
24
+
25
+ public function deleteSubscrition($id)
26
+ {
27
+ if ($id)
28
+ {
29
+ $write = $this->_getWriteAdapter();
30
+ $write->delete($this->getTable('outofstocksubscription/info'), 'id='.$id);
31
+ }
32
+ }
33
+
34
+ public function getProducts()
35
+ {
36
+ $read = $this->_getReadAdapter();
37
+
38
+ $select = "SELECT DISTINCT(product_id) FROM ".$this->getTable('outofstocksubscription/info');
39
+
40
+ return $read->fetchAll($select);
41
+ }
42
+
43
+ public function getSubscriptions($productId)
44
+ {
45
+ $read = $this->_getReadAdapter();
46
+
47
+ $select = $read->select()
48
+ ->from($this->getTable('outofstocksubscription/info'))
49
+ ->where("product_id = ".$productId);
50
+
51
+ return $read->fetchAll($select);
52
+ }
53
+
54
+ public function deleteSubscription($id)
55
+ {
56
+ $write = $this->_getWriteAdapter();
57
+ $write->delete($this->getTable('outofstocksubscription/info'), 'id='.$id);
58
+ }
59
+
60
+ public function getAttributeId()
61
+ {
62
+ $read = $this->_getReadAdapter();
63
+
64
+ $select = $read->select()
65
+ ->from('eav_entity_type', 'entity_type_id')
66
+ ->where("entity_type_code = 'catalog_product'");
67
+ $entityTypeId = $read->fetchOne($select);
68
+ if (!$entityTypeId) {
69
+ $entityTypeId = 4;
70
+ }
71
+ $select = $read->select()
72
+ ->from('eav_attribute', 'attribute_id')
73
+ ->where("entity_type_id = ".$entityTypeId." AND attribute_code = 'name'");
74
+ return $read->fetchOne($select);
75
+ }
76
+ }
app/code/local/Webcreta/OutofStockSubscription/Model/Mysql4/Subscriber.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Webcreta_OutofStockSubscription_Model_Mysql4_Subscriber extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ protected function _construct()
6
+ {
7
+ $this->_init('outofstocksubscription/info', 'id');
8
+ }
9
+ }
app/code/local/Webcreta/OutofStockSubscription/Model/Mysql4/Subscriber/Collection.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category Webcreta
5
+ * @package Webcreta_OutofStockSubscription
6
+ */
7
+ class Webcreta_OutofStockSubscription_Model_Mysql4_Subscriber_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
8
+ {
9
+ /**
10
+ * Initialize collection
11
+ *
12
+ */
13
+ protected function _construct()
14
+ {
15
+ $this->_init('outofstocksubscription/subscriber');
16
+ }
17
+
18
+ protected function _initSelect()
19
+ {
20
+ parent::_initSelect();
21
+ //$attributeId = Mage::getResourceSingleton('outofstocksubscription/info')->getAttributeId();
22
+ $this->getSelect()->join(array("cpe" => 'catalog_product_entity'), 'main_table.product_id=cpe.entity_id', array('sku'=>'cpe.sku'));
23
+ //$this->getSelect()->join(array("cpev" => 'catalog_product_entity_varchar'), 'cpe.entity_id=cpev.entity_id', array('value'=>'cpev.value'));
24
+ //$this->getSelect()->where("cpev.attribute_id=".$attributeId);
25
+
26
+ //$this->getSelect()->group("con.ticket_id");
27
+ //$this->getSelect()->order("con.comment_date DESC");
28
+ //exit($this->getSelect());
29
+ }
30
+ }
app/code/local/Webcreta/OutofStockSubscription/Model/Observer.php ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category Webcreta
5
+ * @package Webcreta_OutofStockSubscription
6
+ */
7
+ class Webcreta_OutofStockSubscription_Model_Observer
8
+ {
9
+ const OUTOFSTOCKSUBSCRIPTION_MAIL_TEMPLATE = 'outofstock_subscription';
10
+
11
+ public function sendEmailToOutofStockSubscription($observer)
12
+ {
13
+ $product = $observer->getEvent()->getProduct();
14
+
15
+ if ($product) {
16
+ if ($product->getStockItem()) {
17
+ $stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product->getId());
18
+
19
+ //$isInStock = $product->getStockItem()->getIsInStock();
20
+ $isInStock = $stockItem->getIsInStock();
21
+
22
+ if ($isInStock>=1) {
23
+ $subscriptions = Mage::getResourceModel('outofstocksubscription/info')->getSubscriptions($product->getId());
24
+ if (count($subscriptions) > 0) {
25
+
26
+ //$prodUrl = $product->getProductUrl();
27
+ $prodUrl = Mage::getBaseUrl();
28
+ $prodUrl = str_replace("/index.php", "", $prodUrl);
29
+ $prodUrl = $prodUrl.$product->getData('url_path');
30
+
31
+ $storeId = Mage::app()->getStore()->getId();
32
+
33
+ // get email template
34
+ $emailTemplate = Mage::getStoreConfig('outofstocksubscription/mail/template', $storeId);
35
+ if (!is_numeric($emailTemplate)) {
36
+ $emailTemplate = self::OUTOFSTOCKSUBSCRIPTION_MAIL_TEMPLATE;
37
+ }
38
+
39
+ $translate = Mage::getSingleton('core/translate');
40
+
41
+ foreach ($subscriptions as $subscription) {
42
+
43
+ $translate->setTranslateInline(false);
44
+ Mage::getModel('core/email_template')
45
+ ->setDesignConfig(array('area'=>'frontend', 'store'=>$storeId))
46
+ ->sendTransactional(
47
+ $emailTemplate,
48
+ 'support',
49
+ $subscription['email'],
50
+ '',
51
+ array(
52
+ 'product' => $product->getName(),
53
+ 'product_url' => $prodUrl,
54
+ ));
55
+ $translate->setTranslateInline(true);
56
+
57
+ Mage::getResourceModel('outofstocksubscription/info')->deleteSubscription($subscription['id']);
58
+ }
59
+ }
60
+ }
61
+ }
62
+ }
63
+ //return $this;
64
+ }
65
+
66
+ public function cancelOrderItem($observer)
67
+ {
68
+ $item = $observer->getEvent()->getItem();
69
+
70
+ $productId = $item->getProductId();
71
+ if ($productId) {
72
+ $subscriptions = Mage::getResourceModel('outofstocksubscription/info')->getSubscriptions($productId);
73
+ if (count($subscriptions) > 0) {
74
+
75
+ $product = Mage::getModel('catalog/product')->load($productId);
76
+ $prodUrl = Mage::getBaseUrl();
77
+ $prodUrl = str_replace("/index.php", "", $prodUrl);
78
+ $prodUrl = $prodUrl.$product->getData('url_path');
79
+
80
+ $storeId = Mage::app()->getStore()->getId();
81
+
82
+ // get email template
83
+ $emailTemplate = Mage::getStoreConfig('outofstocksubscription/mail/template', $storeId);
84
+ if (!is_numeric($emailTemplate)) {
85
+ $emailTemplate = self::OUTOFSTOCKSUBSCRIPTION_MAIL_TEMPLATE;
86
+ }
87
+
88
+ $translate = Mage::getSingleton('core/translate');
89
+
90
+ foreach ($subscriptions as $subscription) {
91
+
92
+ $translate->setTranslateInline(false);
93
+ Mage::getModel('core/email_template')
94
+ ->setDesignConfig(array('area'=>'frontend', 'store'=>$storeId))
95
+ ->sendTransactional(
96
+ $emailTemplate,
97
+ 'support',
98
+ $subscription['email'],
99
+ '',
100
+ array(
101
+ 'product' => $product->getName(),
102
+ 'product_url' => $prodUrl,
103
+ ));
104
+ $translate->setTranslateInline(true);
105
+
106
+ Mage::getResourceModel('outofstocksubscription/info')->deleteSubscription($subscription['id']);
107
+ }
108
+ }
109
+ }
110
+ }
111
+ }
app/code/local/Webcreta/OutofStockSubscription/Model/Subscriber.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Webcreta_OutofStockSubscription_Model_Subscriber extends Mage_Core_Model_Abstract
4
+ {
5
+ /**
6
+ * Init model
7
+ */
8
+ protected function _construct()
9
+ {
10
+ $this->_init('outofstocksubscription/info');
11
+ }
12
+ }
app/code/local/Webcreta/OutofStockSubscription/controllers/Adminhtml/SubscriberController.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Out of Stock Subscriber controller
5
+ *
6
+ * @category Webcreta
7
+ * @package Webcreta_OutofStockSubscription
8
+ */
9
+ class Webcreta_OutofStockSubscription_Adminhtml_SubscriberController extends Mage_Adminhtml_Controller_Action
10
+ {
11
+ public function _initAction()
12
+ {
13
+ $this->loadLayout()
14
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Out of Stock Subscribers'), Mage::helper('adminhtml')->__('Out of Stock Subscribers'));
15
+ return $this;
16
+ }
17
+
18
+ public function indexAction()
19
+ {
20
+ if ($this->getRequest()->getQuery('ajax')) {
21
+ $this->_forward('grid');
22
+ return;
23
+ }
24
+ $this->loadLayout();
25
+
26
+ /**
27
+ * Set active menu item
28
+ */
29
+ $this->_setActiveMenu('outofstocksubscription');
30
+
31
+ $this->_addContent(
32
+ $this->getLayout()->createBlock('outofstocksubscription/adminhtml_subcriber')
33
+ );
34
+
35
+ /**
36
+ * Add breadcrumb item
37
+ */
38
+ $this->_addBreadcrumb(Mage::helper('outofstocksubscription')->__('Out of Stock Subscribers'), Mage::helper('outofstocksubscription')->__('Out of Stock Subscribers'));
39
+
40
+ $this->renderLayout();
41
+ }
42
+
43
+ public function gridAction()
44
+ {
45
+ $this->loadLayout();
46
+ $this->getResponse()->setBody($this->getLayout()->createBlock('outofstocksubscription/adminhtml_subcriber_grid')->toHtml());
47
+ }
48
+
49
+ public function deleteAction()
50
+ {
51
+ $id = (int) $this->getRequest()->getParam('id');
52
+ Mage::getSingleton('outofstocksubscription/info')->deleteSubscrition($id);
53
+ $this->_getSession()->addSuccess($this->__('The subscription has been deleted.'));
54
+ $this->_redirect('*/*/');
55
+ }
56
+
57
+ protected function _isAllowed()
58
+ {
59
+ return Mage::getSingleton('admin/session')->isAllowed('outofstocksubscription');
60
+ }
61
+ }
app/code/local/Webcreta/OutofStockSubscription/controllers/IndexController.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Out of Stock Subscription index controller
5
+ *
6
+ * @category Webcreta
7
+ * @package Webcreta_OutofStockSubscription
8
+ */
9
+ class Webcreta_OutofStockSubscription_IndexController extends Mage_Core_Controller_Front_Action
10
+ {
11
+ public function indexAction()
12
+ {
13
+ $productId = $this->getRequest()->getPost('product');
14
+ $email = $this->getRequest()->getPost('subscription_email');
15
+ if ($email && $productId) {
16
+
17
+ Mage::getModel('outofstocksubscription/info')->saveSubscrition($productId, $email);
18
+
19
+ $this->_getSession()->addSuccess($this->__('Subscription added successfully.'));
20
+
21
+ $product = Mage::getModel('catalog/product')->load($productId);
22
+ //$product->getProductUrl();
23
+ $url = $product->getData('url_path');
24
+ //$this->_redirect('catalog/product/view', array('id'=>$productId));
25
+ $this->_redirect($url);
26
+ }
27
+ else {
28
+ $this->_redirect('');
29
+ }
30
+ }
31
+
32
+ protected function _getSession()
33
+ {
34
+ return Mage::getSingleton('checkout/session');
35
+ }
36
+ }
app/code/local/Webcreta/OutofStockSubscription/etc/config.xml ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Webcreta_OutofStockSubscription>
5
+ <version>0.1.0</version>
6
+ </Webcreta_OutofStockSubscription>
7
+ </modules>
8
+
9
+ <global>
10
+ <blocks>
11
+ <outofstocksubscription>
12
+ <class>Webcreta_OutofStockSubscription_Block</class>
13
+ </outofstocksubscription>
14
+ </blocks>
15
+ <helpers>
16
+ <outofstocksubscription>
17
+ <class>Webcreta_OutofStockSubscription_Helper</class>
18
+ </outofstocksubscription>
19
+ </helpers>
20
+ <models>
21
+ <outofstocksubscription>
22
+ <class>Webcreta_OutofStockSubscription_Model</class>
23
+ <resourceModel>outofstocksubscription_mysql4</resourceModel>
24
+ </outofstocksubscription>
25
+ <outofstocksubscription_mysql4>
26
+ <class>Webcreta_OutofStockSubscription_Model_Mysql4</class>
27
+ <entities>
28
+ <info>
29
+ <table>outofstocksubscription_info</table>
30
+ </info>
31
+ </entities>
32
+ </outofstocksubscription_mysql4>
33
+ </models>
34
+ <resources>
35
+ <outofstocksubscription_setup>
36
+ <setup>
37
+ <module>Webcreta_OutofStockSubscription</module>
38
+ </setup>
39
+ <connection>
40
+ <use>core_setup</use>
41
+ </connection>
42
+ </outofstocksubscription_setup>
43
+ <outofstocksubscription_write>
44
+ <connection>
45
+ <use>core_write</use>
46
+ </connection>
47
+ </outofstocksubscription_write>
48
+ <outofstocksubscription_read>
49
+ <connection>
50
+ <use>core_read</use>
51
+ </connection>
52
+ </outofstocksubscription_read>
53
+ </resources>
54
+ <events>
55
+ <catalog_product_save_after>
56
+ <observers>
57
+ <outofstocksubscription_inventory>
58
+ <class>outofstocksubscription/observer</class>
59
+ <method>sendEmailToOutofStockSubscription</method>
60
+ </outofstocksubscription_inventory>
61
+ </observers>
62
+ </catalog_product_save_after>
63
+ <sales_order_item_cancel>
64
+ <observers>
65
+ <outofstocksubscription_order_cancel>
66
+ <class>outofstocksubscription/observer</class>
67
+ <method>cancelOrderItem</method>
68
+ </outofstocksubscription_order_cancel>
69
+ </observers>
70
+ </sales_order_item_cancel>
71
+ </events>
72
+ <template>
73
+ <email>
74
+ <outofstock_subscription translate="label" module="outofstocksubscription">
75
+ <label>Out of Stock Subscription</label>
76
+ <file>outofstock_subscription.html</file>
77
+ <type>html</type>
78
+ </outofstock_subscription>
79
+ </email>
80
+ </template>
81
+ </global>
82
+
83
+ <frontend>
84
+ <routers>
85
+ <outofstocksubscription>
86
+ <use>standard</use>
87
+ <args>
88
+ <module>Webcreta_OutofStockSubscription</module>
89
+ <frontName>outofstocksubscription</frontName>
90
+ </args>
91
+ </outofstocksubscription>
92
+ </routers>
93
+ <layout>
94
+ <updates>
95
+ <outofstocksubscription>
96
+ <file>outofstocksubscription.xml</file>
97
+ </outofstocksubscription>
98
+ </updates>
99
+ </layout>
100
+ </frontend>
101
+
102
+ <admin>
103
+ <routers>
104
+ <outofstocksubscription>
105
+ <use>admin</use>
106
+ <args>
107
+ <module>Webcreta_OutofStockSubscription</module>
108
+ <frontName>outofstocksubscription</frontName>
109
+ </args>
110
+ </outofstocksubscription>
111
+ </routers>
112
+ </admin>
113
+
114
+ <default>
115
+ <outofstocksubscription>
116
+ <mail>
117
+ <active>1</active>
118
+ </mail>
119
+ </outofstocksubscription>
120
+ </default>
121
+
122
+ <adminhtml>
123
+ <menu>
124
+ <outofstocksubscription translate="title" module="outofstocksubscription">
125
+ <title>Subscribers</title>
126
+ <sort_order>130</sort_order>
127
+ <action>outofstocksubscription/adminhtml_subscriber</action>
128
+ </outofstocksubscription>
129
+ </menu>
130
+ <acl>
131
+ <resources>
132
+ <admin translate="title" module="adminhtml">
133
+ <children>
134
+ <outofstocksubscription>
135
+ <title>Subscribers</title>
136
+ </outofstocksubscription>
137
+ <system>
138
+ <children>
139
+ <config>
140
+ <children>
141
+ <outofstocksubscription translate="title">
142
+ <title>Out of Stock Subscription</title>
143
+ <sort_order>200</sort_order>
144
+ </outofstocksubscription>
145
+ </children>
146
+ </config>
147
+ </children>
148
+ </system>
149
+ </children>
150
+ </admin>
151
+ </resources>
152
+ </acl>
153
+ </adminhtml>
154
+
155
+ </config>
app/code/local/Webcreta/OutofStockSubscription/etc/system.xml ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <outofstocksubscription translate="label" module="outofstocksubscription">
5
+ <label>Out of Stock Subscription</label>
6
+ <tab>catalog</tab>
7
+ <frontend_type>text</frontend_type>
8
+ <sort_order>200</sort_order>
9
+ <show_in_default>1</show_in_default>
10
+ <show_in_website>1</show_in_website>
11
+ <show_in_store>1</show_in_store>
12
+ <groups>
13
+ <mail translate="label">
14
+ <label>Out of Stock Subscription</label>
15
+ <frontend_type>text</frontend_type>
16
+ <sort_order>5</sort_order>
17
+ <show_in_default>1</show_in_default>
18
+ <show_in_website>1</show_in_website>
19
+ <show_in_store>1</show_in_store>
20
+ <fields>
21
+ <active translate="label">
22
+ <label>Enabled</label>
23
+ <frontend_type>select</frontend_type>
24
+ <source_model>adminhtml/system_config_source_yesno</source_model>
25
+ <sort_order>1</sort_order>
26
+ <show_in_default>1</show_in_default>
27
+ <show_in_website>1</show_in_website>
28
+ <show_in_store>1</show_in_store>
29
+ </active>
30
+ <template translate="label">
31
+ <label>Email Template</label>
32
+ <frontend_type>select</frontend_type>
33
+ <source_model>adminhtml/system_config_source_email_template</source_model>
34
+ <sort_order>2</sort_order>
35
+ <show_in_default>1</show_in_default>
36
+ <show_in_website>1</show_in_website>
37
+ <show_in_store>1</show_in_store>
38
+ </template>
39
+ </fields>
40
+ </mail>
41
+ </groups>
42
+ </outofstocksubscription>
43
+ </sections>
44
+ </config>
app/code/local/Webcreta/OutofStockSubscription/sql/outofstocksubscription_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Webcreta
4
+ * @package Webcreta_OutofStockSubscription
5
+ */
6
+
7
+ $installer = $this;
8
+ /* @var $installer Mage_Core_Model_Resource_Setup */
9
+
10
+ $installer->startSetup();
11
+
12
+ $installer->run("
13
+
14
+ -- DROP TABLE IF EXISTS `{$this->getTable('outofstocksubscription_info')}`;
15
+ CREATE TABLE `{$this->getTable('outofstocksubscription_info')}` (
16
+ `id` INTEGER unsigned NOT NULL auto_increment,
17
+ `product_id` INTEGER unsigned NOT NULL,
18
+ `email` TEXT NOT NULL default '',
19
+ `is_active` ENUM('0','1') NOT NULL DEFAULT '0',
20
+ `date` DATETIME default '0000-00-00 00:00:00',
21
+ PRIMARY KEY (`id`),
22
+ KEY `FK_OUTOFSTOCKSUBSCRIPTION_PRODUCT_ID` (`product_id`),
23
+ CONSTRAINT `FK_OUTOFSTOCKSUBSCRIPTION_PRODUCT_ID` FOREIGN KEY (`product_id`) REFERENCES `{$this->getTable('catalog_product_entity')}` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE
24
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
25
+
26
+ ");
27
+
28
+ $installer->endSetup();
app/design/adminhtml/default/default/template/outofstocksubscription/widget/grid.phtml ADDED
@@ -0,0 +1,244 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package default_default
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ /**
29
+ * Template for Mage_Adminhtml_Block_Widget_Grid
30
+ *
31
+ * getId()
32
+ * getCollection()
33
+ * getColumns()
34
+ * getPagerVisibility()
35
+ * getVarNamePage()
36
+ */
37
+ $numColumns = sizeof($this->getColumns());
38
+ ?>
39
+ <?php if($this->getCollection()): ?>
40
+ <?php if($this->canDisplayContainer()): ?>
41
+ <?php if($this->getGridHeader()): ?>
42
+ <div class="content-header">
43
+ <table cellspacing="0">
44
+ <tr>
45
+ <td style="width:50%;"><h2><?php echo $this->getGridHeader(); ?></h2></td>
46
+ </tr>
47
+ </table>
48
+ </div>
49
+ <?php endif ?>
50
+
51
+ <div id="<?php echo $this->getId() ?>">
52
+ <?php else: ?>
53
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
54
+ <?php endif; ?>
55
+ <?php if($this->getPagerVisibility() || $this->getExportTypes() || $this->getFilterVisibility()): ?>
56
+ <table cellspacing="0" class="actions">
57
+ <tr>
58
+ <?php if($this->getPagerVisibility()): ?>
59
+ <td class="pager">
60
+ <?php echo $this->__('Page') ?>
61
+
62
+ <?php $_curPage = $this->getCollection()->getCurPage() ?>
63
+ <?php $_lastPage = $this->getCollection()->getLastPageNumber() ?>
64
+ <?php if($_curPage>1): ?>
65
+ <a href="#" title="<?php echo $this->__('Previous page') ?>" onclick="<?php echo $this->getJsObjectName() ?>.setPage('<?php echo ($_curPage-1) ?>');return false;"><img src="<?php echo $this->getSkinUrl('images/pager_arrow_left.gif') ?>" alt="Go to Previous page" class="arrow"/></a>
66
+ <?php else: ?>
67
+ <img src="<?php echo $this->getSkinUrl('images/pager_arrow_left_off.gif') ?>" alt="Go to Previous page" class="arrow"/>
68
+ <?php endif; ?>
69
+
70
+ <input type="text" name="<?php echo $this->getVarNamePage() ?>" value="<?php echo $_curPage ?>" class="input-text page" onkeypress="<?php echo $this->getJsObjectName() ?>.inputPage(event, '<?php echo $_lastPage ?>')"/>
71
+
72
+ <?php if($_curPage < $_lastPage): ?>
73
+ <a href="#" title="<?php echo $this->__('Next page') ?>" onclick="<?php echo $this->getJsObjectName() ?>.setPage('<?php echo ($_curPage+1) ?>');return false;"><img src="<?php echo $this->getSkinUrl('images/pager_arrow_right.gif') ?>" alt="Go to Next page" class="arrow"/></a>
74
+ <?php else: ?>
75
+ <img src="<?php echo $this->getSkinUrl('images/pager_arrow_right_off.gif') ?>" alt="Go to Previous page" class="arrow"/>
76
+ <?php endif; ?>
77
+
78
+ <?php echo $this->__('of %s pages', $this->getCollection()->getLastPageNumber()) ?>
79
+ <span class="separator">|</span>
80
+ <?php echo $this->__('View') ?>
81
+ <select name="<?php echo $this->getVarNameLimit() ?>" onchange="<?php echo $this->getJsObjectName() ?>.loadByElement(this)">
82
+ <option value="20"<?php if($this->getCollection()->getPageSize()==20): ?> selected="selected"<?php endif; ?>>20</option>
83
+ <option value="30"<?php if($this->getCollection()->getPageSize()==30): ?> selected="selected"<?php endif; ?>>30</option>
84
+ <option value="50"<?php if($this->getCollection()->getPageSize()==50): ?> selected="selected"<?php endif; ?>>50</option>
85
+ <option value="100"<?php if($this->getCollection()->getPageSize()==100): ?> selected="selected"<?php endif; ?>>100</option>
86
+ <option value="200"<?php if($this->getCollection()->getPageSize()==200): ?> selected="selected"<?php endif; ?>>200</option>
87
+ </select>
88
+ <?php echo $this->__('per page') ?><span class="separator">|</span>
89
+ <?php echo $this->__('Total %d records found', $this->getCollection()->getSize()) ?>
90
+ <span id="<?php echo $this->getHtmlId() ?>-total-count" class="no-display"><?php echo $this->getCollection()->getSize() ?></span>
91
+ <?php if($this->getRssLists()): ?>
92
+ <?php foreach ($this->getRssLists() as $_rss): ?>
93
+ <span class="separator">|</span><a href="<?php echo $_rss->getUrl() ?>" class="link-feed"><?php echo $_rss->getLabel() ?></a>
94
+ <?php endforeach ?>
95
+ <?php endif; ?>
96
+ </td>
97
+ <?php endif ?>
98
+ <?php if($this->getExportTypes()): ?>
99
+ <td class="export a-right">
100
+ <img src="<?php echo $this->getSkinUrl('images/icon_export.gif') ?>" alt="" class="v-middle"/>&nbsp; <?php echo $this->__('Export to:') ?>
101
+ <select name="<?php echo $this->getId() ?>_export" id="<?php echo $this->getId() ?>_export" style="width:8em;">
102
+ <?php foreach ($this->getExportTypes() as $_type): ?>
103
+ <option value="<?php echo $_type->getUrl() ?>"><?php echo $_type->getLabel() ?></option>
104
+ <?php endforeach; ?>
105
+ </select>
106
+ <?php echo $this->getExportButtonHtml() ?>
107
+ </td>
108
+ <?php endif; ?>
109
+ <td class="filter-actions a-right">
110
+ <?php echo $this->getMainButtonsHtml() ?>
111
+ </td>
112
+ </tr>
113
+ </table>
114
+ <?php endif; ?>
115
+ <?php if($this->getMassactionBlock()->isAvailable()): ?>
116
+ <?php echo $this->getMassactionBlockHtml() ?>
117
+ <?php endif ?>
118
+ <div class="grid">
119
+ <div class="hor-scroll">
120
+ <table cellspacing="0" class="data" id="<?php echo $this->getId() ?>_table">
121
+ <?php foreach ($this->getColumns() as $_column): ?>
122
+ <col <?php echo $_column->getHtmlProperty() ?> />
123
+ <?php if ($_column->getEditable() && !$_column->getEditOnly()) : ?>
124
+ <col <?php echo $_column->getHtmlProperty() ?> />
125
+ <?php endif ?>
126
+ <?php endforeach; ?>
127
+ <?php if ($this->getHeadersVisibility() || $this->getFilterVisibility()): ?>
128
+ <thead>
129
+ <?php if ($this->getHeadersVisibility()): ?>
130
+ <tr class="headings">
131
+ <?php foreach ($this->getColumns() as $_column): ?>
132
+ <th<?php echo $_column->getHeaderHtmlProperty() ?>><span class="nobr"><?php echo $_column->getHeaderHtml() ?></span></th>
133
+ <?php endforeach; ?>
134
+ </tr>
135
+ <?php endif; ?>
136
+ <?php if ($this->getFilterVisibility()): ?>
137
+ <tr class="filter">
138
+ <?php $i=0;foreach ($this->getColumns() as $_column): ?>
139
+ <th<?php echo $_column->getHeaderHtmlProperty() ?>><?php echo $_column->getFilterHtml() ?></th>
140
+ <?php endforeach; ?>
141
+ </tr>
142
+ <?php endif ?>
143
+ </thead>
144
+ <?php endif; ?>
145
+ <?php if ($this->getCountTotals()): ?>
146
+ <tfoot>
147
+ <tr class="totals">
148
+ <?php foreach ($this->getColumns() as $_column): ?>
149
+ <th class="<?php echo $_column->getCssProperty() ?>"><?php echo ($_column->hasTotalsLabel()) ? $_column->getTotalsLabel() : $_column->getRowField($_column->getGrid()->getTotals()) ?>&nbsp;</th>
150
+ <?php endforeach; ?>
151
+ </tr>
152
+ </tfoot>
153
+ <?php endif; ?>
154
+
155
+ <tbody>
156
+ <?php if (($this->getCollection()->getSize()>0) && (!$this->getIsCollapsed())): ?>
157
+ <?php foreach ($this->getCollection() as $_index=>$_item): ?>
158
+ <tr title="<?php //echo $this->getRowUrl($_item) ?>"<?php if ($_class = $this->getRowClass($_item)):?> class="<?php echo $_class; ?>"<?php endif;?> >
159
+ <?php $i=0;foreach ($this->getColumns() as $_column): ?>
160
+
161
+ <?php if ($this->shouldRenderCell($_item, $_column)):?>
162
+ <?php $_rowspan = $this->getRowspan($_item, $_column);?>
163
+ <td <?php echo ($_rowspan ? 'rowspan="' . $_rowspan . '" ' : '') ?>class="<?php echo $_column->getCssProperty() ?> <?php echo ++$i==$numColumns?'last':'' ?>">
164
+ <?php if ($i==4): ?>
165
+ <?php $_productId = $_column->getRowField($_item) ?>
166
+ <?php $_product = Mage::getModel('catalog/product')->load($_productId) ?>
167
+ <?php echo $_product->getName() ?>
168
+ <?php elseif ($i!=6): ?>
169
+ <?php echo (($_html = $_column->getRowField($_item)) != '' ? $_html : '&nbsp;') ?>
170
+ <?php else: ?>
171
+ <?php $_id = (($_html = $_column->getRowField($_item)) != '' ? $_html : '&nbsp;') ?>
172
+ <a href="<?php echo $this->getUrl('outofstocksubscription/adminhtml_subscriber/delete', array('id'=>$_id)); ?>" onclick="return deleteSubscription();"><?php echo $this->__('Delete') ?></a>
173
+ <?php endif; ?>
174
+ </td>
175
+ <?php if ($this->shouldRenderEmptyCell($_item, $_column)):?>
176
+ <td colspan="<?php echo $this->getEmptyCellColspan($_item)?>" class="last"><?php echo $this->getEmptyCellLabel()?></td>
177
+ <?php endif;?>
178
+ <?php endif;?>
179
+
180
+ <?php endforeach; ?>
181
+ </tr>
182
+ <?php if ($_multipleRows = $this->getMultipleRows($_item)):?>
183
+ <?php foreach ($_multipleRows as $_i):?>
184
+ <tr>
185
+ <?php $i=0;foreach ($this->getMultipleRowColumns($_i) as $_column): ?>
186
+ <td class="<?php echo $_column->getCssProperty() ?> <?php echo ++$i==$numColumns-1?'last':'' ?>">
187
+ <?php echo (($_html = $_column->getRowField($_i)) != '' ? $_html : '&nbsp;') ?>
188
+ </td>
189
+ <?php endforeach; ?>
190
+ </tr>
191
+ <?php endforeach;?>
192
+ <?php endif;?>
193
+
194
+ <?php if ($this->shouldRenderSubTotal($_item)): ?>
195
+ <tr class="subtotals">
196
+ <?php $i = 0; foreach ($this->getSubTotalColumns() as $_column): ?>
197
+ <td class="<?php echo $_column->getCssProperty() ?> <?php echo ++$i == $numColumns ? 'last' : '' ?>">
198
+ <?php echo ($_column->hasSubtotalsLabel() ? $_column->getSubtotalsLabel() :
199
+ $_column->getRowField($this->getSubTotalItem($_item))
200
+ );
201
+ ?>
202
+ </td>
203
+ <?php endforeach; ?>
204
+ </tr>
205
+ <?php endif; ?>
206
+ <?php endforeach; ?>
207
+ <?php elseif ($this->getEmptyText()): ?>
208
+ <tr>
209
+ <td class="empty-text <?php echo $this->getEmptyTextClass() ?>" colspan="100"><?php echo $this->getEmptyText() ?></td>
210
+ </tr>
211
+ <?php endif; ?>
212
+ </tbody>
213
+
214
+ </table>
215
+ </div>
216
+ </div>
217
+ <?php if($this->canDisplayContainer()): ?>
218
+ </div>
219
+ <script type="text/javascript">
220
+ //<![CDATA[
221
+ <?php echo $this->getJsObjectName() ?> = new varienGrid('<?php echo $this->getId() ?>', '<?php echo $this->getGridUrl() ?>', '<?php echo $this->getVarNamePage() ?>', '<?php echo $this->getVarNameSort() ?>', '<?php echo $this->getVarNameDir() ?>', '<?php echo $this->getVarNameFilter() ?>');
222
+ <?php echo $this->getJsObjectName() ?>.useAjax = '<?php echo $this->getUseAjax() ?>';
223
+ <?php if($this->getRowClickCallback()): ?>
224
+ <?php echo $this->getJsObjectName() ?>.rowClickCallback = <?php echo $this->getRowClickCallback() ?>;
225
+ <?php endif; ?>
226
+ <?php if($this->getCheckboxCheckCallback()): ?>
227
+ <?php echo $this->getJsObjectName() ?>.checkboxCheckCallback = <?php echo $this->getCheckboxCheckCallback() ?>;
228
+ <?php endif; ?>
229
+ <?php if($this->getRowInitCallback()): ?>
230
+ <?php echo $this->getJsObjectName() ?>.initRowCallback = <?php echo $this->getRowInitCallback() ?>;
231
+ <?php echo $this->getJsObjectName() ?>.initGridRows();
232
+ <?php endif; ?>
233
+ <?php if($this->getMassactionBlock()->isAvailable()): ?>
234
+ <?php echo $this->getMassactionBlock()->getJavaScript() ?>
235
+ <?php endif ?>
236
+ //]]>
237
+ function deleteSubscription()
238
+ {
239
+ var msg = '<?php echo $this->__('Are you sure you want to delete?') ?>';
240
+ return confirm(msg);
241
+ }
242
+ </script>
243
+ <?php endif; ?>
244
+ <?php endif ?>
app/design/frontend/base/default/layout/outofstocksubscription.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <catalog_product_view>
4
+ <reference name="product.info">
5
+ <action method="setTemplate">
6
+ <template>outofstocksubscription/catalog/product/view.phtml</template>
7
+ </action>
8
+ </reference>
9
+ </catalog_product_view>
10
+ </layout>
app/design/frontend/base/default/template/outofstocksubscription/catalog/product/view.phtml ADDED
@@ -0,0 +1,226 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category design
22
+ * @package rwd_default
23
+ * @copyright Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Product view template
29
+ *
30
+ * @see Mage_Catalog_Block_Product_View
31
+ * @see Mage_Review_Block_Product_View
32
+ */
33
+ ?>
34
+ <?php $_helper = $this->helper('catalog/output'); ?>
35
+ <?php $_product = $this->getProduct(); ?>
36
+ <script type="text/javascript">
37
+ var optionsPrice = new Product.OptionsPrice(<?php echo $this->getJsonConfig() ?>);
38
+ </script>
39
+ <div id="messages_product_view"><?php echo $this->getMessagesBlock()->toHtml() ?></div>
40
+ <div class="product-view">
41
+ <div class="product-essential">
42
+ <?php $_storeId = Mage::app()->getStore()->getId(); ?>
43
+ <?php $_isActive = Mage::getStoreConfig('outofstocksubscription/mail/active', $_storeId); ?>
44
+ <?php if(!$_product->isSaleable() && $_isActive): ?>
45
+ <?php $_url = $this->getUrl('outofstocksubscription') ?>
46
+ <?php else: ?>
47
+ <?php $_url = $this->getAddToCartUrl($_product); ?>
48
+ <?php endif; ?>
49
+ <form action="<?php echo $_url ?>" method="post" id="product_addtocart_form"<?php if($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
50
+ <?php echo $this->getBlockHtml('formkey') ?>
51
+ <div class="no-display">
52
+ <input type="hidden" name="product" value="<?php echo $_product->getId() ?>" />
53
+ <input type="hidden" name="related_product" id="related-products-field" value="" />
54
+ </div>
55
+
56
+ <div class="product-img-box">
57
+ <div class="product-name">
58
+ <h1><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></h1>
59
+ </div>
60
+ <?php echo $this->getChildHtml('media') ?>
61
+ </div>
62
+
63
+ <div class="product-shop">
64
+ <div class="product-name">
65
+ <span class="h1"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></span>
66
+ </div>
67
+
68
+ <div class="price-info">
69
+ <?php echo $this->getPriceHtml($_product); ?>
70
+ <?php echo $this->getChildHtml('bundle_prices') ?>
71
+ <?php echo $this->getTierPriceHtml() ?>
72
+ </div>
73
+
74
+ <div class="extra-info">
75
+ <?php echo $this->getReviewsSummaryHtml($_product, 'default', false)?>
76
+ <?php echo $this->getChildHtml('product_type_availability'); ?>
77
+ </div>
78
+
79
+ <?php echo $this->getChildHtml('alert_urls') ?>
80
+ <?php if(!$_product->isSaleable() && $_isActive): ?>
81
+ <div class="product-options">
82
+ <table width="100%">
83
+ <tr>
84
+ <td colspan="2" style="padding-bottom:5px;">
85
+ <strong><?php echo $this->__('Product Out of Stock Subscription') ?></strong>
86
+ </td>
87
+ </tr>
88
+ <tr>
89
+ <td style="padding-bottom:5px;"><?php echo $this->__('Email') ?></td>
90
+ <td>
91
+ <input type="text" id="subscription_email" name="subscription_email" value="" style="width:200px;" class="input-text required-entry validate-email" />
92
+ </td>
93
+ </tr>
94
+ <tr>
95
+ <td>&nbsp;</td>
96
+ <td style="font-size:10px;">
97
+ (<?php echo $this->__("Notify me when this product is back in stock") ?>)
98
+ </td>
99
+ </tr>
100
+ <tr>
101
+ <td style="">&nbsp;</td>
102
+ <td>
103
+ <button onclick="productAddToCartForm.submit();" class="button btn-cart" type="button"><span><span><?php echo $this->__('Subscribe') ?></span></span></button>
104
+ </td>
105
+ </tr>
106
+ </table>
107
+ </div>
108
+ <?php endif; ?>
109
+ <?php if ($_product->getShortDescription()):?>
110
+ <div class="short-description">
111
+ <div class="std"><?php echo $_helper->productAttribute($_product, nl2br($_product->getShortDescription()), 'short_description') ?></div>
112
+ </div>
113
+ <?php endif;?>
114
+
115
+
116
+
117
+
118
+ <?php echo $this->getChildHtml('other');?>
119
+
120
+ <?php if ($_product->isSaleable() && $this->hasOptions()):?>
121
+ <?php echo $this->getChildChildHtml('container1', '', true, true) ?>
122
+ <?php endif;?>
123
+
124
+ </div>
125
+
126
+ <div class="add-to-cart-wrapper">
127
+ <?php echo $this->getChildHtml('product_type_data') ?>
128
+ <?php echo $this->getChildHtml('extrahint') ?>
129
+
130
+ <?php if (!$this->hasOptions()):?>
131
+ <div class="add-to-box">
132
+ <?php if($_product->isSaleable()): ?>
133
+ <?php echo $this->getChildHtml('addtocart') ?>
134
+ <?php if( $this->helper('wishlist')->isAllow() || $_compareUrl=$this->helper('catalog/product_compare')->getAddUrl($_product)): ?>
135
+ <span class="or"><?php echo $this->__('OR') ?></span>
136
+ <?php endif; ?>
137
+ <?php endif; ?>
138
+ <?php echo $this->getChildHtml('addto') ?>
139
+ <?php echo $this->getChildHtml('sharing') ?>
140
+ </div>
141
+ <?php echo $this->getChildHtml('extra_buttons') ?>
142
+ <?php elseif (!$_product->isSaleable()): ?>
143
+ <div class="add-to-box">
144
+ <?php echo $this->getChildHtml('addto') ?>
145
+ <?php echo $this->getChildHtml('sharing') ?>
146
+ </div>
147
+ <?php endif; ?>
148
+ </div>
149
+
150
+ <?php echo $this->getChildHtml('related_products') ?>
151
+
152
+ <div class="clearer"></div>
153
+ <?php if ($_product->isSaleable() && $this->hasOptions()):?>
154
+ <?php echo $this->getChildChildHtml('container2', '', true, true) ?>
155
+ <?php endif;?>
156
+ </form>
157
+ <script type="text/javascript">
158
+ //<![CDATA[
159
+ var productAddToCartForm = new VarienForm('product_addtocart_form');
160
+ productAddToCartForm.submit = function(button, url) {
161
+ if (this.validator.validate()) {
162
+ var form = this.form;
163
+ var oldUrl = form.action;
164
+
165
+ if (url) {
166
+ form.action = url;
167
+ }
168
+ var e = null;
169
+ try {
170
+ this.form.submit();
171
+ } catch (e) {
172
+ }
173
+ this.form.action = oldUrl;
174
+ if (e) {
175
+ throw e;
176
+ }
177
+
178
+ if (button && button != 'undefined') {
179
+ button.disabled = true;
180
+ }
181
+ }
182
+ }.bind(productAddToCartForm);
183
+
184
+ productAddToCartForm.submitLight = function(button, url){
185
+ if(this.validator) {
186
+ var nv = Validation.methods;
187
+ delete Validation.methods['required-entry'];
188
+ delete Validation.methods['validate-one-required'];
189
+ delete Validation.methods['validate-one-required-by-name'];
190
+ // Remove custom datetime validators
191
+ for (var methodName in Validation.methods) {
192
+ if (methodName.match(/^validate-datetime-.*/i)) {
193
+ delete Validation.methods[methodName];
194
+ }
195
+ }
196
+
197
+ if (this.validator.validate()) {
198
+ if (url) {
199
+ this.form.action = url;
200
+ }
201
+ this.form.submit();
202
+ }
203
+ Object.extend(Validation.methods, nv);
204
+ }
205
+ }.bind(productAddToCartForm);
206
+ //]]>
207
+ </script>
208
+ </div>
209
+
210
+ <div class="product-collateral toggle-content tabs">
211
+ <?php if ($detailedInfoGroup = $this->getChildGroup('detailed_info', 'getChildHtml')):?>
212
+ <dl id="collateral-tabs" class="collateral-tabs">
213
+ <?php foreach ($detailedInfoGroup as $alias => $html):?>
214
+ <dt class="tab"><span><?php echo $this->escapeHtml($this->getChildData($alias, 'title')) ?></span></dt>
215
+ <dd class="tab-container">
216
+ <div class="tab-content"><?php echo $html ?></div>
217
+ </dd>
218
+ <?php endforeach;?>
219
+ </dl>
220
+ <?php endif; ?>
221
+ </div>
222
+
223
+ <?php echo $this->getChildHtml('upsell_products') ?>
224
+ <?php echo $this->getChildHtml('product_additional_data') ?>
225
+
226
+ </div>
app/etc/modules/Webcreta_OutofStockSubscription.xml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <config>
3
+ <modules>
4
+ <Webcreta_OutofStockSubscription>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ <depends>
8
+ <Mage_Catalog/>
9
+ <Mage_CatalogInventory/>
10
+ </depends>
11
+ </Webcreta_OutofStockSubscription>
12
+ </modules>
13
+ </config>
app/locale/en_US/template/email/outofstock_subscription.html ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--@subject Out of Stock Subscription Mail @-->
2
+
3
+ <style type="text/css">
4
+ body,td { color:#2f2f2f; font:11px/1.35em Verdana, Arial, Helvetica, sans-serif; }
5
+ </style>
6
+ <div style="font:11px/1.35em Verdana, Arial, Helvetica, sans-serif;">
7
+ <table cellspacing="0" cellpadding="0" border="0" width="98%" style="margin-top:10px; font:11px/1.35em Verdana, Arial, Helvetica, sans-serif; margin-bottom:10px;">
8
+ <tr>
9
+ <td valign="top">
10
+ <!-- [ header starts here] -->
11
+ <table cellspacing="0" cellpadding="0" border="0" width="650">
12
+ <tr>
13
+ <td valign="top">
14
+ <p><a href="{{store url=""}}" style="color:#1E7EC8;"><img src="{{skin url="images/logo_email.gif" _area='frontend'}}" alt="" border="0"/></a></p></td>
15
+ </tr>
16
+ </table>
17
+
18
+ <!-- [ middle starts here] -->
19
+ <p>Dear Customer,</p>
20
+ <p>
21
+ This is to inform you that the '{{var product}}' product is back in stock, so you can purchase this product now.
22
+ </p>
23
+ <p>
24
+ Click here to open <a href="{{var product_url}}">{{var product}}</a> product page.
25
+ </p>
26
+
27
+ </td>
28
+ </tr>
29
+ </table>
30
+ </div>
doc/OutofStockSubscription.pdf ADDED
Binary file
package.xml ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Webcreta_OutofStockSubscription</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>When a product is out of stock, the customer be able to request notification of availability &#xD;
10
+ entering an email address on the product detail page. The subscribers will be notified by email&#xD;
11
+ when the product will be back in stock.</summary>
12
+ <description>When a product is out of stock, the customer be able to request notification of availability by &#xD;
13
+ entering an email address on the product detail page. The &#xD;
14
+ subscribers will be notified by email &#xD;
15
+ when the product will be back in stock.&#xD;
16
+ For example, one of your products goes out of stock, in the product info page customer can see &#xD;
17
+ one new form that will allow to subscribe for newsletter. When the product quantity&#xD;
18
+ will be &#xD;
19
+ changed, the customer will receive an email that will inform him that product is ready for &#xD;
20
+ ordering.&#xD;
21
+ Also admin can see the list of subscribers at Magento backend, and could delete any subscriber &#xD;
22
+ from the list. Product wise filtering allows to see&#xD;
23
+ which product is most subscribed by your &#xD;
24
+ customers. You can change the product stock notification email template from backend. And &#xD;
25
+ also allow to enable/disable the product out of stock subscription form at frontend product &#xD;
26
+ page</description>
27
+ <notes>Minor bug fixed</notes>
28
+ <authors><author><name>WebCreta</name><user>WebCreta</user><email>webcreta@gmail.com</email></author></authors>
29
+ <date>2016-11-16</date>
30
+ <time>05:45:12</time>
31
+ <contents><target name="magelocal"><dir name="Webcreta"><dir name="OutofStockSubscription"><dir name="Block"><dir name="Adminhtml"><dir name="Subcriber"><file name="Grid.php" hash="ab9a38c48d1bc3b6e6d72cc80a74156b"/></dir><file name="Subcriber.php" hash="a00f1b454b9438993d59f2bea3d0931f"/></dir></dir><dir name="Helper"><file name="Data.php" hash="b3fa8070a43a247555852acc9c55c358"/></dir><dir name="Model"><file name="Info.php" hash="79ff79329804db8fcf3f49f49fa99c14"/><dir name="Mysql4"><file name="Info.php" hash="d2bd997f7877dbd6f392dc08aa17923c"/><dir name="Subscriber"><file name="Collection.php" hash="42bae24d76a143264bf8e90bba6502d0"/></dir><file name="Subscriber.php" hash="f936f70379f307a37f61f680f68b0a42"/></dir><file name="Observer.php" hash="1e93e5185a6c61c5e00fda583401acd1"/><file name="Subscriber.php" hash="6276c4c4d2fb2415ab2dd89425fc45ca"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="SubscriberController.php" hash="44564d558f5c58edcc5b8bd59720a5e6"/></dir><file name="IndexController.php" hash="de0345eb94d2a730beaae36a838e9338"/></dir><dir name="etc"><file name="config.xml" hash="7b6df7a36c4bb1c9bfe8684a59e9b9f3"/><file name="system.xml" hash="d5be0ebee7493694e31971a602f1cdd9"/></dir><dir name="sql"><dir name="outofstocksubscription_setup"><file name="mysql4-install-0.1.0.php" hash="ae6ee71a5d32a317c3e02ed66fb5e56c"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="outofstocksubscription.xml" hash="e2c047ad07a8a4ed7fbd853c014de265"/></dir><dir name="template"><dir name="outofstocksubscription"><dir name="catalog"><dir name="product"><file name="view.phtml" hash="cfc92b8355830a534d64f049fa3ae3b3"/></dir></dir></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="outofstocksubscription"><dir name="widget"><file name="grid.phtml" hash="ce924354c4c94be46de6789435e531b1"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Webcreta_OutofStockSubscription.xml" hash="957fffd2d58a543cc0460c4e6ecd33f7"/></dir></target><target name="magelocale"><dir name="en_US"><dir name="template"><dir name="email"><file name="outofstock_subscription.html" hash="d179b8ac5ba5ce7786916d1b53149f8a"/></dir></dir></dir></target><target name="mage"><dir name="doc"><file name="OutofStockSubscription.pdf" hash="b62b3bab6984c7a7eeeea38c926e632f"/></dir></target></contents>
32
+ <compatible/>
33
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
34
+ </package>