1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27:
28: 29: 30: 31: 32: 33: 34:
35: class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Alerts_Price extends Mage_Adminhtml_Block_Widget_Grid
36: {
37: public function __construct()
38: {
39: parent::__construct();
40:
41: $this->setId('alertPrice');
42: $this->setDefaultSort('add_date');
43: $this->setDefaultSort('DESC');
44: $this->setUseAjax(true);
45: $this->setFilterVisibility(false);
46: $this->setEmptyText(Mage::helper('catalog')->__('There are no customers for this alert'));
47: }
48:
49: protected function _prepareCollection()
50: {
51: $productId = $this->getRequest()->getParam('id');
52: $websiteId = 0;
53: if ($store = $this->getRequest()->getParam('store')) {
54: $websiteId = Mage::app()->getStore($store)->getWebsiteId();
55: }
56: if (Mage::helper('catalog')->isModuleEnabled('Mage_ProductAlert')) {
57: $collection = Mage::getModel('productalert/price')
58: ->getCustomerCollection()
59: ->join($productId, $websiteId);
60: $this->setCollection($collection);
61: }
62: return parent::_prepareCollection();
63: }
64:
65: protected function _prepareColumns()
66: {
67: $this->addColumn('firstname', array(
68: 'header' => Mage::helper('catalog')->__('First Name'),
69: 'index' => 'firstname',
70: ));
71:
72: $this->addColumn('lastname', array(
73: 'header' => Mage::helper('catalog')->__('Last Name'),
74: 'index' => 'lastname',
75: ));
76:
77: $this->addColumn('email', array(
78: 'header' => Mage::helper('catalog')->__('Email'),
79: 'index' => 'email',
80: ));
81:
82: $this->addColumn('price', array(
83: 'header' => Mage::helper('catalog')->__('Price'),
84: 'index' => 'price',
85: 'type' => 'currency',
86: 'currency_code'
87: => Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE)
88: ));
89:
90: $this->addColumn('add_date', array(
91: 'header' => Mage::helper('catalog')->__('Date Subscribed'),
92: 'index' => 'add_date',
93: 'type' => 'date'
94: ));
95:
96: $this->addColumn('last_send_date', array(
97: 'header' => Mage::helper('catalog')->__('Last Notification'),
98: 'index' => 'last_send_date',
99: 'type' => 'date'
100: ));
101:
102: $this->addColumn('send_count', array(
103: 'header' => Mage::helper('catalog')->__('Send Count'),
104: 'index' => 'send_count',
105: ));
106:
107: return parent::_prepareColumns();
108: }
109:
110: public function getGridUrl()
111: {
112: $productId = $this->getRequest()->getParam('id');
113: $storeId = $this->getRequest()->getParam('store', 0);
114: if ($storeId) {
115: $storeId = Mage::app()->getStore($storeId)->getId();
116: }
117: return $this->getUrl('*/catalog_product/alertsPriceGrid', array(
118: 'id' => $productId,
119: 'store' => $storeId
120: ));
121: }
122: }
123: