Version Notes
First Release.
Download this release
Release Info
Developer | Bikash Kaushik |
Extension | ajax_out_of_stock_notification |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/community/Kaushik/Outofstock/Block/Adminhtml/Outofstock.php +13 -0
- app/code/community/Kaushik/Outofstock/Block/Adminhtml/Outofstock/Grid.php +156 -0
- app/code/community/Kaushik/Outofstock/Block/Adminhtml/Outofstock/Renderer/Customergroup.php +15 -0
- app/code/community/Kaushik/Outofstock/Block/Adminhtml/Outofstock/Renderer/Productname.php +9 -0
- app/code/community/Kaushik/Outofstock/Block/Adminhtml/Outofstock/Renderer/Productsku.php +9 -0
- app/code/community/Kaushik/Outofstock/Block/Outofstock.php +17 -0
- app/code/community/Kaushik/Outofstock/Helper/Data.php +6 -0
- app/code/community/Kaushik/Outofstock/Model/Adminhtml/Observer.php +39 -0
- app/code/community/Kaushik/Outofstock/Model/Mysql4/Outofstock.php +10 -0
- app/code/community/Kaushik/Outofstock/Model/Mysql4/Outofstock/Collection.php +10 -0
- app/code/community/Kaushik/Outofstock/Model/Outofstock.php +10 -0
- app/code/community/Kaushik/Outofstock/Model/Status.php +15 -0
- app/code/community/Kaushik/Outofstock/controllers/Adminhtml/OutofstockController.php +214 -0
- app/code/community/Kaushik/Outofstock/controllers/IndexController.php +75 -0
- app/code/community/Kaushik/Outofstock/etc/adminhtml.xml +23 -0
- app/code/community/Kaushik/Outofstock/etc/config.xml +155 -0
- app/code/community/Kaushik/Outofstock/etc/system.xml +59 -0
- app/code/community/Kaushik/Outofstock/sql/outofstock_setup/mysql4-install-1.0.0.php +20 -0
- app/design/adminhtml/default/default/layout/outofstock.xml +8 -0
- app/design/frontend/base/default/layout/kaushik_outofstock.xml +30 -0
- app/etc/modules/Kaushik_Outofstock.xml +9 -0
- package.xml +18 -0
app/code/community/Kaushik/Outofstock/Block/Adminhtml/Outofstock.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Kaushik_Outofstock_Block_Adminhtml_Outofstock extends Mage_Adminhtml_Block_Widget_Grid_Container
|
3 |
+
{
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
$this->_controller = 'adminhtml_outofstock';
|
7 |
+
$this->_blockGroup = 'outofstock';
|
8 |
+
$this->_headerText = Mage::helper('outofstock')->__('Out of Stock Manager');
|
9 |
+
$this->_addButtonLabel = Mage::helper('outofstock')->__('Add Item');
|
10 |
+
parent::__construct();
|
11 |
+
$this->_removeButton('add');
|
12 |
+
}
|
13 |
+
}
|
app/code/community/Kaushik/Outofstock/Block/Adminhtml/Outofstock/Grid.php
ADDED
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Kaushik_Outofstock_Block_Adminhtml_Outofstock_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
$this->setId('outofstockGrid');
|
9 |
+
$this->setDefaultSort('outofstock_id');
|
10 |
+
$this->setDefaultDir('ASC');
|
11 |
+
$this->setSaveParametersInSession(true);
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _prepareCollection()
|
15 |
+
{
|
16 |
+
$collection = Mage::getModel('outofstock/outofstock')->getCollection();
|
17 |
+
$this->setCollection($collection);
|
18 |
+
return parent::_prepareCollection();
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _prepareColumns()
|
22 |
+
{
|
23 |
+
$this->addColumn('outofstock_id', array(
|
24 |
+
'header' => Mage::helper('outofstock')->__('ID'),
|
25 |
+
'align' =>'left',
|
26 |
+
'width' => '50px',
|
27 |
+
'index' => 'outofstock_id',
|
28 |
+
));
|
29 |
+
|
30 |
+
$this->addColumn('email', array(
|
31 |
+
'header' => Mage::helper('outofstock')->__('Customer Email'),
|
32 |
+
'align' =>'left',
|
33 |
+
'width' => '250px',
|
34 |
+
'index' => 'email',
|
35 |
+
));
|
36 |
+
|
37 |
+
$this->addColumn('customer_type', array(
|
38 |
+
'header' => Mage::helper('outofstock')->__('Customer Group'),
|
39 |
+
'align' =>'left',
|
40 |
+
'width' => '150px',
|
41 |
+
'index' => 'customer_type',
|
42 |
+
'type' => 'options',
|
43 |
+
'renderer' => 'Kaushik_Outofstock_Block_Adminhtml_Outofstock_Renderer_Customergroup',
|
44 |
+
//'filter_condition_callback' => array($this, '_filterCategoriesCondition'),
|
45 |
+
));
|
46 |
+
|
47 |
+
/*$this->addColumn('product_id', array(
|
48 |
+
'header' => Mage::helper('outofstock')->__('Product ID'),
|
49 |
+
'align' =>'left',
|
50 |
+
'width' => '50px',
|
51 |
+
'index' => 'product_id',
|
52 |
+
));*/
|
53 |
+
|
54 |
+
$this->addColumn('sku', array(
|
55 |
+
'header' => Mage::helper('outofstock')->__('Product Sku'),
|
56 |
+
'align' =>'left',
|
57 |
+
'width' => '150px',
|
58 |
+
'index' => 'sku',
|
59 |
+
'renderer' => 'Kaushik_Outofstock_Block_Adminhtml_Outofstock_Renderer_Productsku',
|
60 |
+
));
|
61 |
+
|
62 |
+
$this->addColumn('product_name', array(
|
63 |
+
'header' => Mage::helper('outofstock')->__('Product Name'),
|
64 |
+
'align' =>'left',
|
65 |
+
'index' => 'product_name',
|
66 |
+
'renderer' => 'Kaushik_Outofstock_Block_Adminhtml_Outofstock_Renderer_Productname',
|
67 |
+
));
|
68 |
+
|
69 |
+
$this->addColumn('created_time', array(
|
70 |
+
'header' => Mage::helper('outofstock')->__('Subscription Date'),
|
71 |
+
'align' =>'left',
|
72 |
+
'width' => '200px',
|
73 |
+
'index' => 'created_time',
|
74 |
+
));
|
75 |
+
|
76 |
+
$this->addColumn('status', array(
|
77 |
+
'header' => Mage::helper('outofstock')->__('Status'),
|
78 |
+
'align' => 'left',
|
79 |
+
'width' => '80px',
|
80 |
+
'index' => 'status',
|
81 |
+
'type' => 'options',
|
82 |
+
'options' => array(
|
83 |
+
1 => 'Waiting',
|
84 |
+
2 => 'Notified',
|
85 |
+
),
|
86 |
+
));
|
87 |
+
|
88 |
+
$this->addColumn('action',
|
89 |
+
array(
|
90 |
+
'header' => Mage::helper('outofstock')->__('Action'),
|
91 |
+
'width' => '100',
|
92 |
+
'type' => 'action',
|
93 |
+
'getter' => 'getId',
|
94 |
+
'actions' => array(
|
95 |
+
array(
|
96 |
+
'caption' => Mage::helper('outofstock')->__('Delete'),
|
97 |
+
'url' => array('base'=> '*/*/delete'),
|
98 |
+
'field' => 'id'
|
99 |
+
)
|
100 |
+
),
|
101 |
+
'filter' => false,
|
102 |
+
'sortable' => false,
|
103 |
+
'index' => 'stores',
|
104 |
+
'is_system' => true,
|
105 |
+
));
|
106 |
+
|
107 |
+
$this->addExportType('*/*/exportCsv', Mage::helper('outofstock')->__('CSV'));
|
108 |
+
$this->addExportType('*/*/exportXml', Mage::helper('outofstock')->__('XML'));
|
109 |
+
|
110 |
+
return parent::_prepareColumns();
|
111 |
+
}
|
112 |
+
|
113 |
+
// protected function _filterCategoriesCondition($collection, $column)
|
114 |
+
// {
|
115 |
+
// if (!$value = $column->getFilter()->getValue()) {
|
116 |
+
// return;
|
117 |
+
// }
|
118 |
+
// $this->getCollection()->addFieldToFilter('customer_id', array('finset' => $value));
|
119 |
+
// }
|
120 |
+
|
121 |
+
protected function _prepareMassaction()
|
122 |
+
{
|
123 |
+
$this->setMassactionIdField('outofstock_id');
|
124 |
+
$this->getMassactionBlock()->setFormFieldName('outofstock');
|
125 |
+
|
126 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
127 |
+
'label' => Mage::helper('outofstock')->__('Delete'),
|
128 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
129 |
+
'confirm' => Mage::helper('outofstock')->__('Are you sure?')
|
130 |
+
));
|
131 |
+
|
132 |
+
$statuses = Mage::getSingleton('outofstock/status')->getOptionArray();
|
133 |
+
|
134 |
+
array_unshift($statuses, array('label'=>'', 'value'=>''));
|
135 |
+
$this->getMassactionBlock()->addItem('status', array(
|
136 |
+
'label'=> Mage::helper('outofstock')->__('Change status'),
|
137 |
+
'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
|
138 |
+
'additional' => array(
|
139 |
+
'visibility' => array(
|
140 |
+
'name' => 'status',
|
141 |
+
'type' => 'select',
|
142 |
+
'class' => 'required-entry',
|
143 |
+
'label' => Mage::helper('outofstock')->__('Status'),
|
144 |
+
'values' => $statuses
|
145 |
+
)
|
146 |
+
)
|
147 |
+
));
|
148 |
+
return $this;
|
149 |
+
}
|
150 |
+
|
151 |
+
public function getRowUrl($row)
|
152 |
+
{
|
153 |
+
return false;//$this->getUrl('*/*/edit', array('id' => $row->getId()));
|
154 |
+
}
|
155 |
+
|
156 |
+
}
|
app/code/community/Kaushik/Outofstock/Block/Adminhtml/Outofstock/Renderer/Customergroup.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Kaushik_Outofstock_Block_Adminhtml_Outofstock_Renderer_Customergroup extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
3 |
+
{
|
4 |
+
public function render(Varien_Object $row)
|
5 |
+
{
|
6 |
+
$customer = Mage::getModel('customer/customer')->getCollection();
|
7 |
+
$customer->addAttributeToFilter('email', $row->getData('email'));
|
8 |
+
$custData = $customer->getData()[0];
|
9 |
+
$groupname = Mage::getModel('customer/group')->load($custData['group_id'])->getCustomerGroupCode();
|
10 |
+
if($groupname == "") {
|
11 |
+
$groupname = "Guest";
|
12 |
+
}
|
13 |
+
return $groupname;
|
14 |
+
}
|
15 |
+
}
|
app/code/community/Kaushik/Outofstock/Block/Adminhtml/Outofstock/Renderer/Productname.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Kaushik_Outofstock_Block_Adminhtml_Outofstock_Renderer_Productname extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
3 |
+
{
|
4 |
+
public function render(Varien_Object $row)
|
5 |
+
{
|
6 |
+
$product = Mage::getModel('catalog/product')->load($row->getData('product_id'));
|
7 |
+
return $product->getName();
|
8 |
+
}
|
9 |
+
}
|
app/code/community/Kaushik/Outofstock/Block/Adminhtml/Outofstock/Renderer/Productsku.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Kaushik_Outofstock_Block_Adminhtml_Outofstock_Renderer_Productsku extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
3 |
+
{
|
4 |
+
public function render(Varien_Object $row)
|
5 |
+
{
|
6 |
+
$product = Mage::getModel('catalog/product')->load($row->getData('product_id'));
|
7 |
+
return $product->getSku();
|
8 |
+
}
|
9 |
+
}
|
app/code/community/Kaushik/Outofstock/Block/Outofstock.php
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Kaushik_Outofstock_Block_Outofstock extends Mage_Core_Block_Template
|
3 |
+
{
|
4 |
+
public function _prepareLayout()
|
5 |
+
{
|
6 |
+
return parent::_prepareLayout();
|
7 |
+
}
|
8 |
+
|
9 |
+
public function getOutofstock()
|
10 |
+
{
|
11 |
+
if (!$this->hasData('outofstock')) {
|
12 |
+
$this->setData('outofstock', Mage::registry('outofstock'));
|
13 |
+
}
|
14 |
+
return $this->getData('outofstock');
|
15 |
+
|
16 |
+
}
|
17 |
+
}
|
app/code/community/Kaushik/Outofstock/Helper/Data.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Kaushik_Outofstock_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
+
}
|
app/code/community/Kaushik/Outofstock/Model/Adminhtml/Observer.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Kaushik_Outofstock_Model_Adminhtml_Observer
|
3 |
+
{
|
4 |
+
public function onBlockHtmlBefore(Varien_Event_Observer $observer) {
|
5 |
+
$block = $observer->getBlock();
|
6 |
+
if (!isset($block)) return;
|
7 |
+
|
8 |
+
switch ($block->getType()) {
|
9 |
+
case 'adminhtml/catalog_product_grid':
|
10 |
+
$block->addColumn('total_subs', array(
|
11 |
+
'header' => Mage::helper('outofstock')->__('Stock Subscription'),
|
12 |
+
'index' => 'total_subs',
|
13 |
+
'filter' => false,
|
14 |
+
'width' => '50px'
|
15 |
+
));
|
16 |
+
break;
|
17 |
+
}
|
18 |
+
}
|
19 |
+
|
20 |
+
public function onEavLoadBefore(Varien_Event_Observer $observer) {
|
21 |
+
$collection = $observer->getCollection();
|
22 |
+
if (!isset($collection)) return;
|
23 |
+
|
24 |
+
if (is_a($collection, 'Mage_Catalog_Model_Resource_Product_Collection')) {
|
25 |
+
$collection->getSelect()->joinLeft( array('oos'=> 'outofstock'), 'oos.product_id = e.entity_id', array('total_subs'=>'count(oos.product_id)'))->group('e.entity_id');
|
26 |
+
//echo $collection->getSelect()->__toString();exit;
|
27 |
+
}
|
28 |
+
}
|
29 |
+
|
30 |
+
public function deleteSubscription(Varien_Event_Observer $observer) {
|
31 |
+
$productdelete = $observer->getEvent()->getProduct();
|
32 |
+
$productId = $productdelete->getEntityId();
|
33 |
+
|
34 |
+
$model = Mage::getModel('outofstock/outofstock')->getCollection();
|
35 |
+
$model->addFieldToFilter('product_id', $productId);
|
36 |
+
$model->walk('delete');
|
37 |
+
}
|
38 |
+
|
39 |
+
}
|
app/code/community/Kaushik/Outofstock/Model/Mysql4/Outofstock.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Kaushik_Outofstock_Model_Mysql4_Outofstock extends Mage_Core_Model_Mysql4_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
// Note that the outofstock_id refers to the key field in your database table.
|
8 |
+
$this->_init('outofstock/outofstock', 'outofstock_id');
|
9 |
+
}
|
10 |
+
}
|
app/code/community/Kaushik/Outofstock/Model/Mysql4/Outofstock/Collection.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Kaushik_Outofstock_Model_Mysql4_Outofstock_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('outofstock/outofstock');
|
9 |
+
}
|
10 |
+
}
|
app/code/community/Kaushik/Outofstock/Model/Outofstock.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Kaushik_Outofstock_Model_Outofstock extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('outofstock/outofstock');
|
9 |
+
}
|
10 |
+
}
|
app/code/community/Kaushik/Outofstock/Model/Status.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Kaushik_Outofstock_Model_Status extends Varien_Object
|
4 |
+
{
|
5 |
+
const STATUS_ENABLED = 1;
|
6 |
+
const STATUS_DISABLED = 2;
|
7 |
+
|
8 |
+
static public function getOptionArray()
|
9 |
+
{
|
10 |
+
return array(
|
11 |
+
self::STATUS_ENABLED => Mage::helper('outofstock')->__('Enabled'),
|
12 |
+
self::STATUS_DISABLED => Mage::helper('outofstock')->__('Disabled')
|
13 |
+
);
|
14 |
+
}
|
15 |
+
}
|
app/code/community/Kaushik/Outofstock/controllers/Adminhtml/OutofstockController.php
ADDED
@@ -0,0 +1,214 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Kaushik_Outofstock_Adminhtml_OutofstockController extends Mage_Adminhtml_Controller_action
|
4 |
+
{
|
5 |
+
|
6 |
+
protected function _initAction() {
|
7 |
+
$this->loadLayout()
|
8 |
+
->_setActiveMenu('outofstock/items')
|
9 |
+
->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
10 |
+
|
11 |
+
return $this;
|
12 |
+
}
|
13 |
+
|
14 |
+
public function indexAction() {
|
15 |
+
$this->_initAction()
|
16 |
+
->renderLayout();
|
17 |
+
}
|
18 |
+
|
19 |
+
public function editAction() {
|
20 |
+
$id = $this->getRequest()->getParam('id');
|
21 |
+
$model = Mage::getModel('outofstock/outofstock')->load($id);
|
22 |
+
|
23 |
+
if ($model->getId() || $id == 0) {
|
24 |
+
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
|
25 |
+
if (!empty($data)) {
|
26 |
+
$model->setData($data);
|
27 |
+
}
|
28 |
+
|
29 |
+
Mage::register('outofstock_data', $model);
|
30 |
+
|
31 |
+
$this->loadLayout();
|
32 |
+
$this->_setActiveMenu('outofstock/items');
|
33 |
+
|
34 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
35 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
|
36 |
+
|
37 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
38 |
+
|
39 |
+
$this->_addContent($this->getLayout()->createBlock('outofstock/adminhtml_outofstock_edit'))
|
40 |
+
->_addLeft($this->getLayout()->createBlock('outofstock/adminhtml_outofstock_edit_tabs'));
|
41 |
+
|
42 |
+
$this->renderLayout();
|
43 |
+
} else {
|
44 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('outofstock')->__('Item does not exist'));
|
45 |
+
$this->_redirect('*/*/');
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
public function newAction() {
|
50 |
+
$this->_forward('edit');
|
51 |
+
}
|
52 |
+
|
53 |
+
public function saveAction() {
|
54 |
+
if ($data = $this->getRequest()->getPost()) {
|
55 |
+
|
56 |
+
if(isset($_FILES['filename']['name']) && $_FILES['filename']['name'] != '') {
|
57 |
+
try {
|
58 |
+
/* Starting upload */
|
59 |
+
$uploader = new Varien_File_Uploader('filename');
|
60 |
+
|
61 |
+
// Any extention would work
|
62 |
+
$uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
|
63 |
+
$uploader->setAllowRenameFiles(false);
|
64 |
+
|
65 |
+
// Set the file upload mode
|
66 |
+
// false -> get the file directly in the specified folder
|
67 |
+
// true -> get the file in the product like folders
|
68 |
+
// (file.jpg will go in something like /media/f/i/file.jpg)
|
69 |
+
$uploader->setFilesDispersion(false);
|
70 |
+
|
71 |
+
// We set media as the upload dir
|
72 |
+
$path = Mage::getBaseDir('media') . DS ;
|
73 |
+
$uploader->save($path, $_FILES['filename']['name'] );
|
74 |
+
|
75 |
+
} catch (Exception $e) {
|
76 |
+
|
77 |
+
}
|
78 |
+
|
79 |
+
//this way the name is saved in DB
|
80 |
+
$data['filename'] = $_FILES['filename']['name'];
|
81 |
+
}
|
82 |
+
|
83 |
+
|
84 |
+
$model = Mage::getModel('outofstock/outofstock');
|
85 |
+
$model->setData($data)
|
86 |
+
->setId($this->getRequest()->getParam('id'));
|
87 |
+
|
88 |
+
try {
|
89 |
+
if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) {
|
90 |
+
$model->setCreatedTime(now())
|
91 |
+
->setUpdateTime(now());
|
92 |
+
} else {
|
93 |
+
$model->setUpdateTime(now());
|
94 |
+
}
|
95 |
+
|
96 |
+
$model->save();
|
97 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('outofstock')->__('Item was successfully saved'));
|
98 |
+
Mage::getSingleton('adminhtml/session')->setFormData(false);
|
99 |
+
|
100 |
+
if ($this->getRequest()->getParam('back')) {
|
101 |
+
$this->_redirect('*/*/edit', array('id' => $model->getId()));
|
102 |
+
return;
|
103 |
+
}
|
104 |
+
$this->_redirect('*/*/');
|
105 |
+
return;
|
106 |
+
} catch (Exception $e) {
|
107 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
108 |
+
Mage::getSingleton('adminhtml/session')->setFormData($data);
|
109 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
110 |
+
return;
|
111 |
+
}
|
112 |
+
}
|
113 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('outofstock')->__('Unable to find item to save'));
|
114 |
+
$this->_redirect('*/*/');
|
115 |
+
}
|
116 |
+
|
117 |
+
public function deleteAction() {
|
118 |
+
if( $this->getRequest()->getParam('id') > 0 ) {
|
119 |
+
try {
|
120 |
+
$model = Mage::getModel('outofstock/outofstock');
|
121 |
+
|
122 |
+
$model->setId($this->getRequest()->getParam('id'))
|
123 |
+
->delete();
|
124 |
+
|
125 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
|
126 |
+
$this->_redirect('*/*/');
|
127 |
+
} catch (Exception $e) {
|
128 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
129 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
130 |
+
}
|
131 |
+
}
|
132 |
+
$this->_redirect('*/*/');
|
133 |
+
}
|
134 |
+
|
135 |
+
public function massDeleteAction() {
|
136 |
+
$outofstockIds = $this->getRequest()->getParam('outofstock');
|
137 |
+
if(!is_array($outofstockIds)) {
|
138 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
|
139 |
+
} else {
|
140 |
+
try {
|
141 |
+
foreach ($outofstockIds as $outofstockId) {
|
142 |
+
$outofstock = Mage::getModel('outofstock/outofstock')->load($outofstockId);
|
143 |
+
$outofstock->delete();
|
144 |
+
}
|
145 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
146 |
+
Mage::helper('adminhtml')->__(
|
147 |
+
'Total of %d record(s) were successfully deleted', count($outofstockIds)
|
148 |
+
)
|
149 |
+
);
|
150 |
+
} catch (Exception $e) {
|
151 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
152 |
+
}
|
153 |
+
}
|
154 |
+
$this->_redirect('*/*/index');
|
155 |
+
}
|
156 |
+
|
157 |
+
public function massStatusAction()
|
158 |
+
{
|
159 |
+
$outofstockIds = $this->getRequest()->getParam('outofstock');
|
160 |
+
if(!is_array($outofstockIds)) {
|
161 |
+
Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
|
162 |
+
} else {
|
163 |
+
try {
|
164 |
+
foreach ($outofstockIds as $outofstockId) {
|
165 |
+
$outofstock = Mage::getSingleton('outofstock/outofstock')
|
166 |
+
->load($outofstockId)
|
167 |
+
->setStatus($this->getRequest()->getParam('status'))
|
168 |
+
->setIsMassupdate(true)
|
169 |
+
->save();
|
170 |
+
}
|
171 |
+
$this->_getSession()->addSuccess(
|
172 |
+
$this->__('Total of %d record(s) were successfully updated', count($outofstockIds))
|
173 |
+
);
|
174 |
+
} catch (Exception $e) {
|
175 |
+
$this->_getSession()->addError($e->getMessage());
|
176 |
+
}
|
177 |
+
}
|
178 |
+
$this->_redirect('*/*/index');
|
179 |
+
}
|
180 |
+
|
181 |
+
public function exportCsvAction()
|
182 |
+
{
|
183 |
+
$fileName = 'outofstock.csv';
|
184 |
+
$content = $this->getLayout()->createBlock('outofstock/adminhtml_outofstock_grid')
|
185 |
+
->getCsv();
|
186 |
+
|
187 |
+
$this->_sendUploadResponse($fileName, $content);
|
188 |
+
}
|
189 |
+
|
190 |
+
public function exportXmlAction()
|
191 |
+
{
|
192 |
+
$fileName = 'outofstock.xml';
|
193 |
+
$content = $this->getLayout()->createBlock('outofstock/adminhtml_outofstock_grid')
|
194 |
+
->getXml();
|
195 |
+
|
196 |
+
$this->_sendUploadResponse($fileName, $content);
|
197 |
+
}
|
198 |
+
|
199 |
+
protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
|
200 |
+
{
|
201 |
+
$response = $this->getResponse();
|
202 |
+
$response->setHeader('HTTP/1.1 200 OK','');
|
203 |
+
$response->setHeader('Pragma', 'public', true);
|
204 |
+
$response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
|
205 |
+
$response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
|
206 |
+
$response->setHeader('Last-Modified', date('r'));
|
207 |
+
$response->setHeader('Accept-Ranges', 'bytes');
|
208 |
+
$response->setHeader('Content-Length', strlen($content));
|
209 |
+
$response->setHeader('Content-type', $contentType);
|
210 |
+
$response->setBody($content);
|
211 |
+
$response->sendResponse();
|
212 |
+
die;
|
213 |
+
}
|
214 |
+
}
|
app/code/community/Kaushik/Outofstock/controllers/IndexController.php
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Kaushik_Outofstock_IndexController extends Mage_Core_Controller_Front_Action
|
3 |
+
{
|
4 |
+
// public function indexAction()
|
5 |
+
// {
|
6 |
+
// $this->loadLayout();
|
7 |
+
// $this->renderLayout();
|
8 |
+
// }
|
9 |
+
|
10 |
+
public function subscribeAction()
|
11 |
+
{
|
12 |
+
if($this->getRequest()->isPost()){
|
13 |
+
$data = $this->getRequest()->getPost();
|
14 |
+
$response = array();
|
15 |
+
$model = Mage::getModel('outofstock/outofstock')->getCollection();
|
16 |
+
$model->addFieldToFilter('product_id', array('eq' => $data['product_id']));
|
17 |
+
$model->addFieldToFilter('email', array('eq' => $data['email']));
|
18 |
+
|
19 |
+
foreach($model as $data){
|
20 |
+
$outofstockId = $data->getOutofstockId();
|
21 |
+
$createdTime = $data->getCreatedTime();
|
22 |
+
}
|
23 |
+
if($outofstockId) {
|
24 |
+
$response['msg'] = 'This email is already subscribed on '.$createdTime;
|
25 |
+
$response['status'] = 'warning';
|
26 |
+
} else {
|
27 |
+
$newmodel = Mage::getModel('outofstock/outofstock');
|
28 |
+
$data['created_time'] = now();
|
29 |
+
$newmodel->setData($data);
|
30 |
+
try {
|
31 |
+
$newmodel->save();
|
32 |
+
$response['msg'] = 'You will be notified when this item is available for purchase.';
|
33 |
+
$response['status'] = 'success';
|
34 |
+
} catch(Exception $e) {
|
35 |
+
$response['msg'] = $e->getMessage();
|
36 |
+
$response['status'] = 'failure';
|
37 |
+
}
|
38 |
+
}
|
39 |
+
echo json_encode($response);
|
40 |
+
}
|
41 |
+
}
|
42 |
+
|
43 |
+
public function unsubscribeAction() {
|
44 |
+
if($this->getRequest()->isPost()){
|
45 |
+
$data = $this->getRequest()->getPost();
|
46 |
+
$response = array();
|
47 |
+
$model = Mage::getModel('outofstock/outofstock')->getCollection();
|
48 |
+
$model->addFieldToFilter('email', $data['email']);
|
49 |
+
$model->addFieldToFilter('product_id', $data['product_id']);
|
50 |
+
//print_r($model->getData());
|
51 |
+
try {
|
52 |
+
$model->walk('delete');
|
53 |
+
$response['msg'] = 'Unsubscribed successfully.';
|
54 |
+
$response['status'] = 'success';
|
55 |
+
} catch(Exception $e) {
|
56 |
+
$response['msg'] = $e->getMessage();
|
57 |
+
$response['status'] = 'failure';
|
58 |
+
}
|
59 |
+
echo json_encode($response);
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
63 |
+
public function subscribedlistAction() {
|
64 |
+
|
65 |
+
if(Mage::getModel('customer/session')->isLoggedin()) {
|
66 |
+
$this->loadLayout();
|
67 |
+
$this->_initLayoutMessages('customer/session');
|
68 |
+
$this->_initLayoutMessages('catalog/session');
|
69 |
+
$this->getLayout()->getBlock('head')->setTitle($this->__('My Product Stock Subscriptions'));
|
70 |
+
$this->renderLayout();
|
71 |
+
} else {
|
72 |
+
Mage::app()->getResponse()->setRedirect(Mage::getUrl("customer/account/login/"));
|
73 |
+
}
|
74 |
+
}
|
75 |
+
}
|
app/code/community/Kaushik/Outofstock/etc/adminhtml.xml
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<acl>
|
4 |
+
<resources>
|
5 |
+
<admin>
|
6 |
+
<children>
|
7 |
+
<system>
|
8 |
+
<children>
|
9 |
+
<config>
|
10 |
+
<children>
|
11 |
+
<outofstock translate="title" module="outofstock">
|
12 |
+
<title>quickview</title>
|
13 |
+
<sort_order>0</sort_order>
|
14 |
+
</outofstock>
|
15 |
+
</children>
|
16 |
+
</config>
|
17 |
+
</children>
|
18 |
+
</system>
|
19 |
+
</children>
|
20 |
+
</admin>
|
21 |
+
</resources>
|
22 |
+
</acl>
|
23 |
+
</config>
|
app/code/community/Kaushik/Outofstock/etc/config.xml
ADDED
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Kaushik_Outofstock>
|
5 |
+
<version>1.0.0</version>
|
6 |
+
</Kaushik_Outofstock>
|
7 |
+
</modules>
|
8 |
+
<frontend>
|
9 |
+
<routers>
|
10 |
+
<outofstock>
|
11 |
+
<use>standard</use>
|
12 |
+
<args>
|
13 |
+
<module>Kaushik_Outofstock</module>
|
14 |
+
<frontName>outofstock</frontName>
|
15 |
+
</args>
|
16 |
+
</outofstock>
|
17 |
+
</routers>
|
18 |
+
<layout>
|
19 |
+
<updates>
|
20 |
+
<outofstock>
|
21 |
+
<file>kaushik_outofstock.xml</file>
|
22 |
+
</outofstock>
|
23 |
+
</updates>
|
24 |
+
</layout>
|
25 |
+
</frontend>
|
26 |
+
<admin>
|
27 |
+
<routers>
|
28 |
+
<outofstock>
|
29 |
+
<use>admin</use>
|
30 |
+
<args>
|
31 |
+
<module>Kaushik_Outofstock</module>
|
32 |
+
<frontName>outofstock</frontName>
|
33 |
+
</args>
|
34 |
+
</outofstock>
|
35 |
+
</routers>
|
36 |
+
</admin>
|
37 |
+
<adminhtml>
|
38 |
+
<events>
|
39 |
+
<adminhtml_block_html_before>
|
40 |
+
<observers>
|
41 |
+
<outofstock>
|
42 |
+
<class>outofstock/adminhtml_observer</class>
|
43 |
+
<method>onBlockHtmlBefore</method>
|
44 |
+
</outofstock>
|
45 |
+
</observers>
|
46 |
+
</adminhtml_block_html_before>
|
47 |
+
<eav_collection_abstract_load_before>
|
48 |
+
<observers>
|
49 |
+
<outofstock>
|
50 |
+
<class>outofstock/adminhtml_observer</class>
|
51 |
+
<method>onEavLoadBefore</method>
|
52 |
+
</outofstock>
|
53 |
+
</observers>
|
54 |
+
</eav_collection_abstract_load_before>
|
55 |
+
<catalog_product_delete_after>
|
56 |
+
<observers>
|
57 |
+
<outofstock_delete_subscription>
|
58 |
+
<class>outofstock/adminhtml_observer</class>
|
59 |
+
<method>deleteSubscription</method>
|
60 |
+
</outofstock_delete_subscription>
|
61 |
+
</observers>
|
62 |
+
</catalog_product_delete_after>
|
63 |
+
</events>
|
64 |
+
<menu>
|
65 |
+
<outofstock module="outofstock">
|
66 |
+
<title>OutOfStock Subscriptions</title>
|
67 |
+
<sort_order>71</sort_order>
|
68 |
+
<children>
|
69 |
+
<items module="outofstock">
|
70 |
+
<title>Manage Subscriptions</title>
|
71 |
+
<sort_order>0</sort_order>
|
72 |
+
<action>outofstock/adminhtml_outofstock</action>
|
73 |
+
</items>
|
74 |
+
</children>
|
75 |
+
</outofstock>
|
76 |
+
</menu>
|
77 |
+
<acl>
|
78 |
+
<resources>
|
79 |
+
<all>
|
80 |
+
<title>Allow Everything</title>
|
81 |
+
</all>
|
82 |
+
<admin>
|
83 |
+
<children>
|
84 |
+
<Kaushik_Outofstock>
|
85 |
+
<title>Outofstock Module</title>
|
86 |
+
<sort_order>10</sort_order>
|
87 |
+
</Kaushik_Outofstock>
|
88 |
+
</children>
|
89 |
+
</admin>
|
90 |
+
</resources>
|
91 |
+
</acl>
|
92 |
+
<layout>
|
93 |
+
<updates>
|
94 |
+
<outofstock>
|
95 |
+
<file>outofstock.xml</file>
|
96 |
+
</outofstock>
|
97 |
+
</updates>
|
98 |
+
</layout>
|
99 |
+
</adminhtml>
|
100 |
+
<global>
|
101 |
+
<models>
|
102 |
+
<outofstock>
|
103 |
+
<class>Kaushik_Outofstock_Model</class>
|
104 |
+
<resourceModel>outofstock_mysql4</resourceModel>
|
105 |
+
</outofstock>
|
106 |
+
<outofstock_mysql4>
|
107 |
+
<class>Kaushik_Outofstock_Model_Mysql4</class>
|
108 |
+
<entities>
|
109 |
+
<outofstock>
|
110 |
+
<table>outofstock</table>
|
111 |
+
</outofstock>
|
112 |
+
</entities>
|
113 |
+
</outofstock_mysql4>
|
114 |
+
</models>
|
115 |
+
<resources>
|
116 |
+
<outofstock_setup>
|
117 |
+
<setup>
|
118 |
+
<module>Kaushik_Outofstock</module>
|
119 |
+
</setup>
|
120 |
+
<connection>
|
121 |
+
<use>core_setup</use>
|
122 |
+
</connection>
|
123 |
+
</outofstock_setup>
|
124 |
+
<outofstock_write>
|
125 |
+
<connection>
|
126 |
+
<use>core_write</use>
|
127 |
+
</connection>
|
128 |
+
</outofstock_write>
|
129 |
+
<outofstock_read>
|
130 |
+
<connection>
|
131 |
+
<use>core_read</use>
|
132 |
+
</connection>
|
133 |
+
</outofstock_read>
|
134 |
+
</resources>
|
135 |
+
<blocks>
|
136 |
+
<outofstock>
|
137 |
+
<class>Kaushik_Outofstock_Block</class>
|
138 |
+
</outofstock>
|
139 |
+
</blocks>
|
140 |
+
<helpers>
|
141 |
+
<outofstock>
|
142 |
+
<class>Kaushik_Outofstock_Helper</class>
|
143 |
+
</outofstock>
|
144 |
+
</helpers>
|
145 |
+
<template>
|
146 |
+
<email>
|
147 |
+
<outofstock_email_template module="outofstock">
|
148 |
+
<label>Existing User Quote Template</label>
|
149 |
+
<file>outofstock/outofstock.html</file>
|
150 |
+
<type>html</type>
|
151 |
+
</outofstock_email_template>
|
152 |
+
</email>
|
153 |
+
</template>
|
154 |
+
</global>
|
155 |
+
</config>
|
app/code/community/Kaushik/Outofstock/etc/system.xml
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<config>
|
2 |
+
<tabs>
|
3 |
+
<kaushik translate="label" module="outofstock">
|
4 |
+
<label>Kaushik Extensions</label>
|
5 |
+
<sort_order>20</sort_order>
|
6 |
+
</kaushik>
|
7 |
+
</tabs>
|
8 |
+
<sections>
|
9 |
+
<outofstock translate="label" module="outofstock">
|
10 |
+
<label>Out of Stock Subscription</label>
|
11 |
+
<tab>kaushik</tab>
|
12 |
+
<frontend_type>text</frontend_type>
|
13 |
+
<sort_order>990</sort_order>
|
14 |
+
<show_in_default>1</show_in_default>
|
15 |
+
<show_in_website>1</show_in_website>
|
16 |
+
<show_in_store>1</show_in_store>
|
17 |
+
<groups>
|
18 |
+
<settings translate="label">
|
19 |
+
<label>Default Settings</label>
|
20 |
+
<frontend_type>text</frontend_type>
|
21 |
+
<sort_order>1</sort_order>
|
22 |
+
<show_in_default>1</show_in_default>
|
23 |
+
<show_in_website>1</show_in_website>
|
24 |
+
<show_in_store>1</show_in_store>
|
25 |
+
<fields>
|
26 |
+
<enable translate="label">
|
27 |
+
<label>Enable Module</label>
|
28 |
+
<frontend_type>select</frontend_type>
|
29 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
30 |
+
<sort_order>1</sort_order>
|
31 |
+
<show_in_default>1</show_in_default>
|
32 |
+
<show_in_website>1</show_in_website>
|
33 |
+
<show_in_store>1</show_in_store>
|
34 |
+
</enable>
|
35 |
+
</fields>
|
36 |
+
</settings>
|
37 |
+
<email_options translate="label">
|
38 |
+
<label>Email Settings</label>
|
39 |
+
<frontend_type>text</frontend_type>
|
40 |
+
<sort_order>5</sort_order>
|
41 |
+
<show_in_default>1</show_in_default>
|
42 |
+
<show_in_website>1</show_in_website>
|
43 |
+
<show_in_store>1</show_in_store>
|
44 |
+
<fields>
|
45 |
+
<enable translate="label">
|
46 |
+
<label>Email Sender</label>
|
47 |
+
<frontend_type>select</frontend_type>
|
48 |
+
<source_model>adminhtml/system_config_source_email_template</source_model>
|
49 |
+
<sort_order>1</sort_order>
|
50 |
+
<show_in_default>1</show_in_default>
|
51 |
+
<show_in_website>1</show_in_website>
|
52 |
+
<show_in_store>1</show_in_store>
|
53 |
+
</enable>
|
54 |
+
</fields>
|
55 |
+
</email_options>
|
56 |
+
</groups>
|
57 |
+
</outofstock>
|
58 |
+
</sections>
|
59 |
+
</config>
|
app/code/community/Kaushik/Outofstock/sql/outofstock_setup/mysql4-install-1.0.0.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
$installer->startSetup();
|
6 |
+
|
7 |
+
$installer->run("
|
8 |
+
|
9 |
+
-- DROP TABLE IF EXISTS {$this->getTable('outofstock')};
|
10 |
+
CREATE TABLE {$this->getTable('outofstock')} (
|
11 |
+
`outofstock_id` int(11) unsigned NOT NULL auto_increment,
|
12 |
+
`email` varchar(255) NOT NULL default '' COMMENT 'Customer email',
|
13 |
+
`product_id` MEDIUMINT NOT NULL default '',
|
14 |
+
`created_time` datetime NULL,
|
15 |
+
PRIMARY KEY (`outofstock_id`)
|
16 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
17 |
+
|
18 |
+
");
|
19 |
+
|
20 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/layout/outofstock.xml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<outofstock_adminhtml_outofstock_index>
|
4 |
+
<reference name="content">
|
5 |
+
<block type="outofstock/adminhtml_outofstock" name="outofstock" />
|
6 |
+
</reference>
|
7 |
+
</outofstock_adminhtml_outofstock_index>
|
8 |
+
</layout>
|
app/design/frontend/base/default/layout/kaushik_outofstock.xml
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<default>
|
4 |
+
</default>
|
5 |
+
<!-- <outofstock_index_index>
|
6 |
+
<reference name="content">
|
7 |
+
<block type="outofstock/outofstock" name="outofstock" template="outofstock/outofstock.phtml" />
|
8 |
+
</reference>
|
9 |
+
</outofstock_index_index> -->
|
10 |
+
<catalog_product_view>
|
11 |
+
<reference name="product.info.extrahint">
|
12 |
+
<block type="outofstock/outofstock" name="outofstock" template="outofstock/outofstock.phtml" />
|
13 |
+
</reference>
|
14 |
+
</catalog_product_view>
|
15 |
+
<customer_account>
|
16 |
+
<reference name="customer_account_navigation">
|
17 |
+
<action method="addLink" translate="label" module="outofstock">
|
18 |
+
<name>stocksubscription</name>
|
19 |
+
<path>outofstock/index/subscribedlist</path>
|
20 |
+
<label>My Product Stock Subscriptions</label>
|
21 |
+
</action>
|
22 |
+
</reference>
|
23 |
+
</customer_account>
|
24 |
+
<outofstock_index_subscribedlist>
|
25 |
+
<update handle="customer_account"/> <!-- include existing customer account layout -->
|
26 |
+
<reference name="content">
|
27 |
+
<block type="outofstock/outofstock" name="mystocksubscription" template="outofstock/mysubscription.phtml" />
|
28 |
+
</reference>
|
29 |
+
</outofstock_index_subscribedlist>
|
30 |
+
</layout>
|
app/etc/modules/Kaushik_Outofstock.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Kaushik_Outofstock>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</Kaushik_Outofstock>
|
8 |
+
</modules>
|
9 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>ajax_out_of_stock_notification</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="https://opensource.org/licenses/osl-3.0.php">Open Software License</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>This extension allows both customers and guest to sign up for alerts once out of stock products are available.</summary>
|
10 |
+
<description>This extension adds a Notify button into product detail page for out of stock products. By clicking on this button, registered members & guests can enter their email to receive notifications when products are in stock. When admin adds new inventory for a product and it becomes in stock, the system will send an email notification to customers who subscribed to that product. This extension helps store owners in inventory decision making about out of stock products based on subscriptions.</description>
|
11 |
+
<notes>First Release.</notes>
|
12 |
+
<authors><author><name>Bikash Kaushik</name><user>bikashkaushik</user><email>bikashkaushik10@gmail.com</email></author></authors>
|
13 |
+
<date>2017-01-05</date>
|
14 |
+
<time>06:17:25</time>
|
15 |
+
<contents><target name="mageetc"><dir name="modules"><file name="Kaushik_Outofstock.xml" hash="fd1e66f8a5bead211c2ea44092facfce"/></dir></target><target name="magecommunity"><dir name="Kaushik"><dir name="Outofstock"><dir name="Block"><dir name="Adminhtml"><dir name="Outofstock"><file name="Grid.php" hash="c005078b83898a6a530e9707e963660e"/><dir name="Renderer"><file name="Customergroup.php" hash="6f61885eb9edf31d11bf63c377ef163b"/><file name="Productname.php" hash="075b88440a10ad72feb9feaa1cb02b3a"/><file name="Productsku.php" hash="055505ace7ea75e3af4eabc27a09192d"/></dir></dir><file name="Outofstock.php" hash="7da318da3c745ce52a0b136fdd3b2d1f"/></dir><file name="Outofstock.php" hash="61d61ac94f1effb50fa605a3b3ffc015"/></dir><dir name="Helper"><file name="Data.php" hash="300e095c1c92671fdc9b33b900f6f282"/></dir><dir name="Model"><dir name="Adminhtml"><file name="Observer.php" hash="de5c63ffe094e4fc1941431b93bc366b"/></dir><dir name="Mysql4"><dir name="Outofstock"><file name="Collection.php" hash="c679943ae9ead796676f0b9cb5aeb708"/></dir><file name="Outofstock.php" hash="4d2a337d37c11b174d8652adf05c96f8"/></dir><file name="Outofstock.php" hash="585524ff6b1de528db940ec27591f60d"/><file name="Status.php" hash="6aca3bcdebce0753f5853f5fe4b009ca"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="OutofstockController.php" hash="b1f10282d4ceaf5bd30e960a591c831a"/></dir><file name="IndexController.php" hash="62673cf4afe4d4ce88018a5daa107dae"/></dir><dir name="etc"><file name="adminhtml.xml" hash="72760cb708ffcc195e12a75a40e94f16"/><file name="config.xml" hash="5c665f4b357dbd67e1e383cddc9863e5"/><file name="system.xml" hash="8e9b17fe5cedbbb222c345f0784454ec"/></dir><dir name="sql"><dir name="outofstock_setup"><file name="mysql4-install-1.0.0.php" hash="a0e891081ddb04fb8eefd4a083ff6ac7"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="outofstock.xml" hash="8f11e51d42ac271810d0a891ec8a0bce"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="kaushik_outofstock.xml" hash="8d2c38a2d84647ee0822f8c1e762ad70"/></dir></dir></dir></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.0.0</min><max>7.1.0</max></php></required></dependencies>
|
18 |
+
</package>
|