FeaturedProduct - Version 0.1.0

Version Notes

Featured Product for magento1.4

Download this release

Release Info

Developer Magento Core Team
Extension FeaturedProduct
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

Files changed (70) hide show
  1. app/code/local/Magestore/Featuredproduct/Block/Adminhtml/Featuredproduct.php +14 -0
  2. app/code/local/Magestore/Featuredproduct/Block/Adminhtml/Featuredproduct/Copy of Grid.php +116 -0
  3. app/code/local/Magestore/Featuredproduct/Block/Adminhtml/Featuredproduct/Edit.php +220 -0
  4. app/code/local/Magestore/Featuredproduct/Block/Adminhtml/Featuredproduct/Edit/Form.php +19 -0
  5. app/code/local/Magestore/Featuredproduct/Block/Adminhtml/Featuredproduct/Edit/Tab/Form.php +58 -0
  6. app/code/local/Magestore/Featuredproduct/Block/Adminhtml/Featuredproduct/Edit/Tabs.php +24 -0
  7. app/code/local/Magestore/Featuredproduct/Block/Adminhtml/Featuredproduct/Grid.php +233 -0
  8. app/code/local/Magestore/Featuredproduct/Block/Featuredproduct.php +26 -0
  9. app/code/local/Magestore/Featuredproduct/Helper/Data.php +6 -0
  10. app/code/local/Magestore/Featuredproduct/Model/Featuredproduct.php +10 -0
  11. app/code/local/Magestore/Featuredproduct/Model/Mysql4/Featuredproduct.php +10 -0
  12. app/code/local/Magestore/Featuredproduct/Model/Mysql4/Featuredproduct/Collection.php +10 -0
  13. app/code/local/Magestore/Featuredproduct/Model/Status.php +15 -0
  14. app/code/local/Magestore/Featuredproduct/Model/Typeshow.php +14 -0
  15. app/code/local/Magestore/Featuredproduct/controllers/Adminhtml/FeaturedproductController.php +238 -0
  16. app/code/local/Magestore/Featuredproduct/controllers/Faq/Block/Adminhtml/Category.php +12 -0
  17. app/code/local/Magestore/Featuredproduct/controllers/Faq/Block/Adminhtml/Category/Edit.php +38 -0
  18. app/code/local/Magestore/Featuredproduct/controllers/Faq/Block/Adminhtml/Category/Edit/Form.php +19 -0
  19. app/code/local/Magestore/Featuredproduct/controllers/Faq/Block/Adminhtml/Category/Edit/Tab/Form.php +87 -0
  20. app/code/local/Magestore/Featuredproduct/controllers/Faq/Block/Adminhtml/Category/Edit/Tabs.php +24 -0
  21. app/code/local/Magestore/Featuredproduct/controllers/Faq/Block/Adminhtml/Category/Grid.php +123 -0
  22. app/code/local/Magestore/Featuredproduct/controllers/Faq/Block/Adminhtml/Faq.php +12 -0
  23. app/code/local/Magestore/Featuredproduct/controllers/Faq/Block/Adminhtml/Faq/Edit.php +45 -0
  24. app/code/local/Magestore/Featuredproduct/controllers/Faq/Block/Adminhtml/Faq/Edit/Form.php +19 -0
  25. app/code/local/Magestore/Featuredproduct/controllers/Faq/Block/Adminhtml/Faq/Edit/Tab/Form.php +117 -0
  26. app/code/local/Magestore/Featuredproduct/controllers/Faq/Block/Adminhtml/Faq/Edit/Tabs.php +24 -0
  27. app/code/local/Magestore/Featuredproduct/controllers/Faq/Block/Adminhtml/Faq/Grid.php +134 -0
  28. app/code/local/Magestore/Featuredproduct/controllers/Faq/Block/Category.php +27 -0
  29. app/code/local/Magestore/Featuredproduct/controllers/Faq/Block/Overview.php +45 -0
  30. app/code/local/Magestore/Featuredproduct/controllers/Faq/Block/Search.php +22 -0
  31. app/code/local/Magestore/Featuredproduct/controllers/Faq/Block/View.php +76 -0
  32. app/code/local/Magestore/Featuredproduct/controllers/Faq/Helper/Data.php +182 -0
  33. app/code/local/Magestore/Featuredproduct/controllers/Faq/Model/Category.php +126 -0
  34. app/code/local/Magestore/Featuredproduct/controllers/Faq/Model/Categorystore.php +80 -0
  35. app/code/local/Magestore/Featuredproduct/controllers/Faq/Model/Faq.php +190 -0
  36. app/code/local/Magestore/Featuredproduct/controllers/Faq/Model/Faqstore.php +150 -0
  37. app/code/local/Magestore/Featuredproduct/controllers/Faq/Model/Mysql4/Category.php +10 -0
  38. app/code/local/Magestore/Featuredproduct/controllers/Faq/Model/Mysql4/Category/Collection.php +10 -0
  39. app/code/local/Magestore/Featuredproduct/controllers/Faq/Model/Mysql4/Categorystore.php +10 -0
  40. app/code/local/Magestore/Featuredproduct/controllers/Faq/Model/Mysql4/Categorystore/Collection.php +10 -0
  41. app/code/local/Magestore/Featuredproduct/controllers/Faq/Model/Mysql4/Faq.php +23 -0
  42. app/code/local/Magestore/Featuredproduct/controllers/Faq/Model/Mysql4/Faq/Collection.php +10 -0
  43. app/code/local/Magestore/Featuredproduct/controllers/Faq/Model/Mysql4/Faqstore.php +10 -0
  44. app/code/local/Magestore/Featuredproduct/controllers/Faq/Model/Mysql4/Faqstore/Collection.php +10 -0
  45. app/code/local/Magestore/Featuredproduct/controllers/Faq/Model/Mysql4/Urlrewrite.php +15 -0
  46. app/code/local/Magestore/Featuredproduct/controllers/Faq/Model/Status.php +15 -0
  47. app/code/local/Magestore/Featuredproduct/controllers/Faq/Model/Urlrewrite.php +12 -0
  48. app/code/local/Magestore/Featuredproduct/controllers/Faq/controllers/Adminhtml/CategoryController.php +250 -0
  49. app/code/local/Magestore/Featuredproduct/controllers/Faq/controllers/Adminhtml/FaqController.php +260 -0
  50. app/code/local/Magestore/Featuredproduct/controllers/Faq/controllers/IndexController.php +43 -0
  51. app/code/local/Magestore/Featuredproduct/controllers/Faq/controllers/SearchController.php +17 -0
  52. app/code/local/Magestore/Featuredproduct/controllers/Faq/etc/adminhtml.xml +50 -0
  53. app/code/local/Magestore/Featuredproduct/controllers/Faq/etc/config.xml +115 -0
  54. app/code/local/Magestore/Featuredproduct/controllers/Faq/etc/system.xml +23 -0
  55. app/code/local/Magestore/Featuredproduct/controllers/Faq/sql/faq_setup/mysql4-install-0.1.1.php +80 -0
  56. app/code/local/Magestore/Featuredproduct/controllers/Faq/sql/faq_setup/mysql4-install-0.1.2.php +80 -0
  57. app/code/local/Magestore/Featuredproduct/controllers/Faq/sql/faq_setup/mysql4-install-0.1.3.php +80 -0
  58. app/code/local/Magestore/Featuredproduct/controllers/Faq/sql/faq_setup/mysql4-upgrade-0.1.0-0.1.1.php +54 -0
  59. app/code/local/Magestore/Featuredproduct/controllers/Faq/sql/faq_setup/mysql4-upgrade-0.1.1-0.1.2.php +54 -0
  60. app/code/local/Magestore/Featuredproduct/controllers/Faq/sql/faq_setup/mysql4-upgrade-0.1.2-0.1.3.php +54 -0
  61. app/code/local/Magestore/Featuredproduct/controllers/IndexController.php +47 -0
  62. app/code/local/Magestore/Featuredproduct/etc/adminhtml.xml +43 -0
  63. app/code/local/Magestore/Featuredproduct/etc/config.xml +104 -0
  64. app/code/local/Magestore/Featuredproduct/etc/system.xml +64 -0
  65. app/code/local/Magestore/Featuredproduct/sql/featuredproduct_setup/mysql4-install-0.1.0.php +67 -0
  66. app/design/frontend/default/default/layout/featuredproduct.xml +13 -0
  67. app/design/frontend/default/default/template/featuredproduct/featuredproduct.phtml +178 -0
  68. app/etc/modules/Magestore_Featuredproduct.xml +9 -0
  69. package.xml +18 -0
  70. skin/frontend/default/default/css/magestore/featuredproduct.css +72 -0
app/code/local/Magestore/Featuredproduct/Block/Adminhtml/Featuredproduct.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Magestore_Featuredproduct_Block_Adminhtml_Featuredproduct extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ public function __construct()
5
+ {
6
+ $this->_controller = 'adminhtml_featuredproduct';//path to block
7
+ $this->_blockGroup = 'featuredproduct';//name module
8
+ $this->_headerText = Mage::helper('featuredproduct')->__('Featured Product Manager');
9
+ // $this->_addButtonLabel = Mage::helper('featuredproduct')->__('Add Item');
10
+ parent::__construct();
11
+ $this->_removeButton('add', 'label');
12
+ }
13
+
14
+ }
app/code/local/Magestore/Featuredproduct/Block/Adminhtml/Featuredproduct/Copy of Grid.php ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Featuredproduct_Block_Adminhtml_Featuredproduct_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('featuredproductGrid');
9
+ $this->setDefaultSort('featuredproduct_id');
10
+ $this->setDefaultDir('ASC');
11
+ $this->setSaveParametersInSession(true);
12
+ }
13
+
14
+ protected function _prepareCollection()
15
+ {
16
+ $collection = Mage::getModel('featuredproduct/featuredproduct')->getCollection();
17
+ $this->setCollection($collection);
18
+ return parent::_prepareCollection();
19
+ }
20
+
21
+ protected function _prepareColumns()
22
+ {
23
+ $this->addColumn('featuredproduct_id', array(
24
+ 'header' => Mage::helper('featuredproduct')->__('ID'),
25
+ 'align' =>'right',
26
+ 'width' => '50px',
27
+ 'index' => 'featuredproduct_id',
28
+ ));
29
+
30
+ $this->addColumn('title', array(
31
+ 'header' => Mage::helper('featuredproduct')->__('Title'),
32
+ 'align' =>'left',
33
+ 'index' => 'title',
34
+ ));
35
+
36
+ /*
37
+ $this->addColumn('content', array(
38
+ 'header' => Mage::helper('featuredproduct')->__('Item Content'),
39
+ 'width' => '150px',
40
+ 'index' => 'content',
41
+ ));
42
+ */
43
+
44
+ $this->addColumn('status', array(
45
+ 'header' => Mage::helper('featuredproduct')->__('Status'),
46
+ 'align' => 'left',
47
+ 'width' => '80px',
48
+ 'index' => 'status',
49
+ 'type' => 'options',
50
+ 'options' => array(
51
+ 1 => 'Enabled',
52
+ 2 => 'Disabled',
53
+ ),
54
+ ));
55
+
56
+ $this->addColumn('action',
57
+ array(
58
+ 'header' => Mage::helper('featuredproduct')->__('Action'),
59
+ 'width' => '100',
60
+ 'type' => 'action',
61
+ 'getter' => 'getId',
62
+ 'actions' => array(
63
+ array(
64
+ 'caption' => Mage::helper('featuredproduct')->__('Edit'),
65
+ 'url' => array('base'=> '*/*/edit'),
66
+ 'field' => 'id'
67
+ )
68
+ ),
69
+ 'filter' => false,
70
+ 'sortable' => false,
71
+ 'index' => 'stores',
72
+ 'is_system' => true,
73
+ ));
74
+
75
+ $this->addExportType('*/*/exportCsv', Mage::helper('featuredproduct')->__('CSV'));
76
+ $this->addExportType('*/*/exportXml', Mage::helper('featuredproduct')->__('XML'));
77
+
78
+ return parent::_prepareColumns();
79
+ }
80
+
81
+ protected function _prepareMassaction()
82
+ {
83
+ $this->setMassactionIdField('featuredproduct_id');
84
+ $this->getMassactionBlock()->setFormFieldName('featuredproduct');
85
+
86
+ $this->getMassactionBlock()->addItem('delete', array(
87
+ 'label' => Mage::helper('featuredproduct')->__('Delete'),
88
+ 'url' => $this->getUrl('*/*/massDelete'),
89
+ 'confirm' => Mage::helper('featuredproduct')->__('Are you sure?')
90
+ ));
91
+
92
+ $statuses = Mage::getSingleton('featuredproduct/status')->getOptionArray();
93
+
94
+ array_unshift($statuses, array('label'=>'', 'value'=>''));
95
+ $this->getMassactionBlock()->addItem('status', array(
96
+ 'label'=> Mage::helper('featuredproduct')->__('Change status'),
97
+ 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
98
+ 'additional' => array(
99
+ 'visibility' => array(
100
+ 'name' => 'status',
101
+ 'type' => 'select',
102
+ 'class' => 'required-entry',
103
+ 'label' => Mage::helper('featuredproduct')->__('Status'),
104
+ 'values' => $statuses
105
+ )
106
+ )
107
+ ));
108
+ return $this;
109
+ }
110
+
111
+ public function getRowUrl($row)
112
+ {
113
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
114
+ }
115
+
116
+ }
app/code/local/Magestore/Featuredproduct/Block/Adminhtml/Featuredproduct/Edit.php ADDED
@@ -0,0 +1,220 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Featuredproduct_Block_Adminhtml_Featuredproduct_Edit extends Mage_Adminhtml_Block_Widget
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setTemplate('catalog/product/edit.phtml');
10
+ $this->setId('product_edit');
11
+ }
12
+
13
+ /**
14
+ * Retrieve currently edited product object
15
+ *
16
+ * @return Mage_Catalog_Model_Product
17
+ */
18
+ public function getProduct()
19
+ {
20
+ return Mage::registry('current_product');
21
+ }
22
+
23
+ protected function _prepareLayout()
24
+ {
25
+ if (!$this->getRequest()->getParam('popup')) {
26
+ $this->setChild('back_button',
27
+ $this->getLayout()->createBlock('adminhtml/widget_button')
28
+ ->setData(array(
29
+ 'label' => Mage::helper('catalog')->__('Back'),
30
+ 'onclick' => 'setLocation(\''.$this->getUrl('*/*/', array('store'=>$this->getRequest()->getParam('store', 0))).'\')',
31
+ 'class' => 'back'
32
+ ))
33
+ );
34
+ } else {
35
+ $this->setChild('back_button',
36
+ $this->getLayout()->createBlock('adminhtml/widget_button')
37
+ ->setData(array(
38
+ 'label' => Mage::helper('catalog')->__('Close Window'),
39
+ 'onclick' => 'window.close()',
40
+ 'class' => 'cancel'
41
+ ))
42
+ );
43
+ }
44
+
45
+ if (!$this->getProduct()->isReadonly()) {
46
+ $this->setChild('reset_button',
47
+ $this->getLayout()->createBlock('adminhtml/widget_button')
48
+ ->setData(array(
49
+ 'label' => Mage::helper('catalog')->__('Reset'),
50
+ 'onclick' => 'setLocation(\''.$this->getUrl('*/*/*', array('_current'=>true)).'\')'
51
+ ))
52
+ );
53
+
54
+ $this->setChild('save_button',
55
+ $this->getLayout()->createBlock('adminhtml/widget_button')
56
+ ->setData(array(
57
+ 'label' => Mage::helper('catalog')->__('Save'),
58
+ 'onclick' => 'productForm.submit()',
59
+ 'class' => 'save'
60
+ ))
61
+ );
62
+ }
63
+
64
+ if (!$this->getRequest()->getParam('popup')) {
65
+ if (!$this->getProduct()->isReadonly()) {
66
+ $this->setChild('save_and_edit_button',
67
+ $this->getLayout()->createBlock('adminhtml/widget_button')
68
+ ->setData(array(
69
+ 'label' => Mage::helper('catalog')->__('Save and Continue Edit'),
70
+ 'onclick' => 'saveAndContinueEdit(\''.$this->getSaveAndContinueUrl().'\')',
71
+ 'class' => 'save'
72
+ ))
73
+ );
74
+ }
75
+ if ($this->getProduct()->isDeleteable()) {
76
+ $this->setChild('delete_button',
77
+ $this->getLayout()->createBlock('adminhtml/widget_button')
78
+ ->setData(array(
79
+ 'label' => Mage::helper('catalog')->__('Delete'),
80
+ 'onclick' => 'confirmSetLocation(\''.Mage::helper('catalog')->__('Are you sure?').'\', \''.$this->getDeleteUrl().'\')',
81
+ 'class' => 'delete'
82
+ ))
83
+ );
84
+ }
85
+
86
+ if ($this->getProduct()->isDuplicable()) {
87
+ $this->setChild('duplicate_button',
88
+ $this->getLayout()->createBlock('adminhtml/widget_button')
89
+ ->setData(array(
90
+ 'label' => Mage::helper('catalog')->__('Duplicate'),
91
+ 'onclick' => 'setLocation(\''.$this->getDuplicateUrl().'\')',
92
+ 'class' => 'add'
93
+ ))
94
+ );
95
+ }
96
+ }
97
+
98
+ return parent::_prepareLayout();
99
+ }
100
+
101
+ public function getBackButtonHtml()
102
+ {
103
+ return $this->getChildHtml('back_button');
104
+ }
105
+
106
+ public function getCancelButtonHtml()
107
+ {
108
+ return $this->getChildHtml('reset_button');
109
+ }
110
+
111
+ public function getSaveButtonHtml()
112
+ {
113
+ return $this->getChildHtml('save_button');
114
+ }
115
+
116
+ public function getSaveAndEditButtonHtml()
117
+ {
118
+ return $this->getChildHtml('save_and_edit_button');
119
+ }
120
+
121
+ public function getDeleteButtonHtml()
122
+ {
123
+ return $this->getChildHtml('delete_button');
124
+ }
125
+
126
+ public function getDuplicateButtonHtml()
127
+ {
128
+ return $this->getChildHtml('duplicate_button');
129
+ }
130
+
131
+ public function getValidationUrl()
132
+ {
133
+ return $this->getUrl('*/*/validate', array('_current'=>true));
134
+ }
135
+
136
+ public function getSaveUrl()
137
+ {
138
+ return $this->getUrl('*/*/save', array('_current'=>true, 'back'=>null));
139
+ }
140
+
141
+ public function getSaveAndContinueUrl()
142
+ {
143
+ return $this->getUrl('*/*/save', array(
144
+ '_current' => true,
145
+ 'back' => 'edit',
146
+ 'tab' => '{{tab_id}}',
147
+ 'active_tab' => null
148
+ ));
149
+ }
150
+
151
+ public function getProductId()
152
+ {
153
+ return $this->getProduct()->getId();
154
+ }
155
+
156
+ public function getProductSetId()
157
+ {
158
+ $setId = false;
159
+ if (!($setId = $this->getProduct()->getAttributeSetId()) && $this->getRequest()) {
160
+ $setId = $this->getRequest()->getParam('set', null);
161
+ }
162
+ return $setId;
163
+ }
164
+
165
+ public function getIsGrouped()
166
+ {
167
+ return $this->getProduct()->isGrouped();
168
+ }
169
+
170
+ public function getDeleteUrl()
171
+ {
172
+ return $this->getUrl('*/*/delete', array('_current'=>true));
173
+ }
174
+
175
+ public function getDuplicateUrl()
176
+ {
177
+ return $this->getUrl('*/*/duplicate', array('_current'=>true));
178
+ }
179
+
180
+ public function getHeader()
181
+ {
182
+ $header = '';
183
+ if ($this->getProduct()->getId()) {
184
+ $header = $this->htmlEscape($this->getProduct()->getName());
185
+ }
186
+ else {
187
+ $header = Mage::helper('catalog')->__('New Product');
188
+ }
189
+ if ($setName = $this->getAttributeSetName()) {
190
+ $header.= ' (' . $setName . ')';
191
+ }
192
+ return $header;
193
+ }
194
+
195
+ public function getAttributeSetName()
196
+ {
197
+ if ($setId = $this->getProduct()->getAttributeSetId()) {
198
+ $set = Mage::getModel('eav/entity_attribute_set')
199
+ ->load($setId);
200
+ return $set->getAttributeSetName();
201
+ }
202
+ return '';
203
+ }
204
+
205
+ public function getIsConfigured()
206
+ {
207
+ if ($this->getProduct()->isConfigurable()
208
+ && !($superAttributes = $this->getProduct()->getTypeInstance(true)->getUsedProductAttributeIds($this->getProduct()))) {
209
+ $superAttributes = false;
210
+ }
211
+
212
+ return !$this->getProduct()->isConfigurable() || $superAttributes !== false;
213
+ }
214
+
215
+ public function getSelectedTabId()
216
+ {
217
+ return addslashes(htmlspecialchars($this->getRequest()->getParam('tab')));
218
+ }
219
+
220
+ }
app/code/local/Magestore/Featuredproduct/Block/Adminhtml/Featuredproduct/Edit/Form.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Featuredproduct_Block_Adminhtml_Featuredproduct_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ $form = new Varien_Data_Form(array(
8
+ 'id' => 'edit_form',
9
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
10
+ 'method' => 'post',
11
+ 'enctype' => 'multipart/form-data'
12
+ )
13
+ );
14
+
15
+ $form->setUseContainer(true);
16
+ $this->setForm($form);
17
+ return parent::_prepareForm();
18
+ }
19
+ }
app/code/local/Magestore/Featuredproduct/Block/Adminhtml/Featuredproduct/Edit/Tab/Form.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Featuredproduct_Block_Adminhtml_Featuredproduct_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ $form = new Varien_Data_Form();
8
+ $this->setForm($form);
9
+ $fieldset = $form->addFieldset('featuredproduct_form', array('legend'=>Mage::helper('featuredproduct')->__('Item information')));
10
+
11
+ $fieldset->addField('title', 'text', array(
12
+ 'label' => Mage::helper('featuredproduct')->__('Title'),
13
+ 'class' => 'required-entry',
14
+ 'required' => true,
15
+ 'name' => 'title',
16
+ ));
17
+
18
+ $fieldset->addField('filename', 'file', array(
19
+ 'label' => Mage::helper('featuredproduct')->__('File'),
20
+ 'required' => false,
21
+ 'name' => 'filename',
22
+ ));
23
+
24
+ $fieldset->addField('status', 'select', array(
25
+ 'label' => Mage::helper('featuredproduct')->__('Status'),
26
+ 'name' => 'status',
27
+ 'values' => array(
28
+ array(
29
+ 'value' => 1,
30
+ 'label' => Mage::helper('featuredproduct')->__('Enabled'),
31
+ ),
32
+
33
+ array(
34
+ 'value' => 2,
35
+ 'label' => Mage::helper('featuredproduct')->__('Disabled'),
36
+ ),
37
+ ),
38
+ ));
39
+
40
+ $fieldset->addField('content', 'editor', array(
41
+ 'name' => 'content',
42
+ 'label' => Mage::helper('featuredproduct')->__('Content'),
43
+ 'title' => Mage::helper('featuredproduct')->__('Content'),
44
+ 'style' => 'width:700px; height:500px;',
45
+ 'wysiwyg' => false,
46
+ 'required' => true,
47
+ ));
48
+
49
+ if ( Mage::getSingleton('adminhtml/session')->getFeaturedproductData() )
50
+ {
51
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getFeaturedproductData());
52
+ Mage::getSingleton('adminhtml/session')->setFeaturedproductData(null);
53
+ } elseif ( Mage::registry('featuredproduct_data') ) {
54
+ $form->setValues(Mage::registry('featuredproduct_data')->getData());
55
+ }
56
+ return parent::_prepareForm();
57
+ }
58
+ }
app/code/local/Magestore/Featuredproduct/Block/Adminhtml/Featuredproduct/Edit/Tabs.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Featuredproduct_Block_Adminhtml_Featuredproduct_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId('featuredproduct_tabs');
10
+ $this->setDestElementId('edit_form');
11
+ $this->setTitle(Mage::helper('featuredproduct')->__('Item Information'));
12
+ }
13
+
14
+ protected function _beforeToHtml()
15
+ {
16
+ $this->addTab('form_section', array(
17
+ 'label' => Mage::helper('featuredproduct')->__('Item Information'),
18
+ 'title' => Mage::helper('featuredproduct')->__('Item Information'),
19
+ 'content' => $this->getLayout()->createBlock('featuredproduct/adminhtml_featuredproduct_edit_tab_form')->toHtml(),
20
+ ));
21
+
22
+ return parent::_beforeToHtml();
23
+ }
24
+ }
app/code/local/Magestore/Featuredproduct/Block/Adminhtml/Featuredproduct/Grid.php ADDED
@@ -0,0 +1,233 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Featuredproduct_Block_Adminhtml_Featuredproduct_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId('featuredproductGrid');
10
+ $this->setDefaultSort('entity_id');
11
+ $this->setDefaultDir('DESC');
12
+ $this->setSaveParametersInSession(true);
13
+ // $this->setUseAjax(true);
14
+ //$this->setVarNameFilter('product_filter');
15
+ }
16
+
17
+ protected function _getStore()
18
+ {
19
+ $storeId = (int) $this->getRequest()->getParam('store', 0);
20
+ return Mage::app()->getStore($storeId);
21
+ }
22
+
23
+ protected function _prepareCollection()
24
+ {
25
+ $store = $this->_getStore();
26
+ $collection = Mage::getModel('catalog/product')->getCollection()
27
+ ->addAttributeToSelect('sku')
28
+ ->addAttributeToSelect('name')
29
+ ->addAttributeToSelect('attribute_set_id')
30
+ ->addAttributeToSelect('type_id')
31
+ ->addAttributeToSelect('fb_product')
32
+ //->addAttributeToFilter('fb_product', array('eq'=>1))
33
+ ->joinField('qty',
34
+ 'cataloginventory/stock_item',
35
+ 'qty',
36
+ 'product_id=entity_id',
37
+ '{{table}}.stock_id=1',
38
+ 'left');
39
+ if ($store->getId()) {
40
+ //$collection->setStoreId($store->getId());
41
+ $adminStore = Mage_Core_Model_App::ADMIN_STORE_ID;
42
+ $collection->addStoreFilter($store);
43
+ $collection->joinAttribute('name', 'catalog_product/name', 'entity_id', null, 'inner', $adminStore);
44
+ $collection->joinAttribute('custom_name', 'catalog_product/name', 'entity_id', null, 'inner', $store->getId());
45
+ $collection->joinAttribute('status', 'catalog_product/status', 'entity_id', null, 'inner', $store->getId());
46
+ $collection->joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'inner', $store->getId());
47
+ $collection->joinAttribute('price', 'catalog_product/price', 'entity_id', null, 'left', $store->getId());
48
+ }
49
+ else {
50
+ $collection->addAttributeToSelect('price');
51
+ $collection->addAttributeToSelect('status');
52
+ $collection->addAttributeToSelect('visibility');
53
+ }
54
+
55
+ $this->setCollection($collection);
56
+ parent::_prepareCollection();
57
+ $this->getCollection()->addWebsiteNamesToResult();
58
+ return $this;
59
+
60
+ }
61
+ protected function _addColumnFilterToCollection($column)
62
+ {
63
+ if ($this->getCollection()) {
64
+ if ($column->getId() == 'websites') {
65
+ $this->getCollection()->joinField('websites',
66
+ 'catalog/product_website',
67
+ 'website_id',
68
+ 'product_id=entity_id',
69
+ null,
70
+ 'left');
71
+ }
72
+ }
73
+ return parent::_addColumnFilterToCollection($column);
74
+ }
75
+
76
+ protected function _prepareColumns()
77
+ {
78
+ /* $this->addColumn('fb_product', array(
79
+ 'header_css_class' => 'a-center',
80
+ 'type' => 'checkbox',
81
+ 'values' => $this->_getSelectedProducts(),
82
+ 'align' => 'center',
83
+ 'index' => 'fb_product'
84
+ )); */
85
+
86
+ $this->addColumn('entity_id',
87
+ array(
88
+ 'header'=> Mage::helper('featuredproduct')->__('ID'),
89
+ 'width' => '50px',
90
+ 'type' => 'number',
91
+ 'index' => 'entity_id',
92
+ ));
93
+ $this->addColumn('name',
94
+ array(
95
+ 'header'=> Mage::helper('featuredproduct')->__('Name'),
96
+ 'index' => 'name',
97
+ ));
98
+
99
+ $store = $this->_getStore();
100
+ if ($store->getId()) {
101
+ $this->addColumn('custom_name',
102
+ array(
103
+ 'header'=> Mage::helper('featuredproduct')->__('Name in %s', $store->getName()),
104
+ 'index' => 'custom_name',
105
+ ));
106
+ }
107
+
108
+
109
+ $sets = Mage::getResourceModel('eav/entity_attribute_set_collection')
110
+ ->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId())
111
+ ->load()
112
+ ->toOptionHash();
113
+
114
+ $this->addColumn('set_name',
115
+ array(
116
+ 'header'=> Mage::helper('featuredproduct')->__('Attrib. Set Name'),
117
+ 'width' => '100px',
118
+ 'index' => 'attribute_set_id',
119
+ 'type' => 'options',
120
+ 'options' => $sets,
121
+ ));
122
+
123
+
124
+ $store = $this->_getStore();
125
+ $this->addColumn('price',
126
+ array(
127
+ 'header'=> Mage::helper('featuredproduct')->__('Price'),
128
+ 'type' => 'price',
129
+ 'currency_code' => $store->getBaseCurrency()->getCode(),
130
+ 'index' => 'price',
131
+ ));
132
+
133
+ $this->addColumn('qty',
134
+ array(
135
+ 'header'=> Mage::helper('featuredproduct')->__('Qty'),
136
+ 'width' => '100px',
137
+ 'type' => 'number',
138
+ 'index' => 'qty',
139
+ ));
140
+
141
+
142
+
143
+ $this->addColumn('status',
144
+ array(
145
+ 'header'=> Mage::helper('featuredproduct')->__('Status'),
146
+ 'width' => '70px',
147
+ 'index' => 'status',
148
+ 'type' => 'options',
149
+ 'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(),
150
+ ));
151
+
152
+ $this->addColumn('fb_product',
153
+ array(
154
+ 'header'=> Mage::helper('featuredproduct')->__('Featured Product'),
155
+ 'width' => '70px',
156
+ 'index' => 'fb_product',
157
+ 'type' => 'options',
158
+ 'options' => array(
159
+ 1 => 'Yes',
160
+ 0 => 'No',
161
+ ),
162
+ ));
163
+
164
+ if (!Mage::app()->isSingleStoreMode()) {
165
+ $this->addColumn('websites',
166
+ array(
167
+ 'header'=> Mage::helper('featuredproduct')->__('Websites'),
168
+ 'width' => '100px',
169
+ 'sortable' => false,
170
+ 'index' => 'websites',
171
+ 'type' => 'options',
172
+ 'options' => Mage::getModel('core/website')->getCollection()->toOptionHash(),
173
+ ));
174
+ }
175
+
176
+
177
+
178
+ $this->addRssList('rss/catalog/notifystock', Mage::helper('featuredproduct')->__('Notify Low Stock RSS'));
179
+
180
+ return parent::_prepareColumns();
181
+ }
182
+
183
+ protected function _prepareMassaction()
184
+ {
185
+ $this->setMassactionIdField('entity_id');
186
+ $this->getMassactionBlock()->setFormFieldName('featuredproduct');
187
+
188
+ $this->getMassactionBlock()->addItem('delete', array(
189
+ 'label' => Mage::helper('featuredproduct')->__('Delete'),
190
+ 'url' => $this->getUrl('*/*/massDelete'),
191
+ 'confirm' => Mage::helper('featuredproduct')->__('Are you sure?')
192
+ ));
193
+
194
+ $statuses = Mage::getSingleton('catalog/product_status')->getOptionArray();
195
+
196
+ array_unshift($statuses, array('label'=>'', 'value'=>''));
197
+ $this->getMassactionBlock()->addItem('status', array(
198
+ 'label'=> Mage::helper('featuredproduct')->__('Change status'),
199
+ 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
200
+ 'additional' => array(
201
+ 'visibility' => array(
202
+ 'name' => 'status',
203
+ 'type' => 'select',
204
+ 'class' => 'required-entry',
205
+ 'label' => Mage::helper('featuredproduct')->__('Status'),
206
+ 'values' => $statuses
207
+ )
208
+ )
209
+ ));
210
+
211
+ $featuredproduct = array(
212
+ 1 => 'Yes',
213
+ 0 => 'No',
214
+ );
215
+
216
+ array_unshift($featuredproduct, array('label'=>'', 'value'=>''));
217
+ $this->getMassactionBlock()->addItem('fb_product', array(
218
+ 'label'=> Mage::helper('featuredproduct')->__('Change featured product'),
219
+ 'url' => $this->getUrl('*/*/massFeaturedproduct', array('_current'=>true)),
220
+ 'additional' => array(
221
+ 'visibility' => array(
222
+ 'name' => 'fb_product',
223
+ 'type' => 'select',
224
+ 'class' => 'required-entry',
225
+ 'label' => Mage::helper('featuredproduct')->__('Featured Product'),
226
+ 'values' => $featuredproduct
227
+ )
228
+ )
229
+ ));
230
+
231
+ return $this;
232
+ }
233
+ }
app/code/local/Magestore/Featuredproduct/Block/Featuredproduct.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Magestore_Featuredproduct_Block_Featuredproduct extends Mage_Catalog_Block_Product_Abstract
3
+ {
4
+ public function __construct()
5
+ {
6
+ parent::__construct();
7
+
8
+ $storeId = Mage::app()->getStore()->getId();
9
+ $number = Mage::getStoreConfig('featuredproduct/general/show_product_number');
10
+
11
+ $products = Mage::getModel('catalog/product')->getCollection()
12
+ ->addAttributeToSelect('*')
13
+ //->addAttributeToSelect(array('name', 'price', 'small_image')) //edit to suit tastes
14
+ ->setStoreId($storeId)
15
+ ->addStoreFilter($storeId)
16
+ ->addAttributeToFilter('fb_product', array('eq' => '1'))
17
+ ->setPageSize($number)
18
+ ->setCurPage(1)
19
+ ->load();
20
+
21
+ //Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products);
22
+ //Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($products);
23
+
24
+ $this->setProductCollection($products);
25
+ }
26
+ }
app/code/local/Magestore/Featuredproduct/Helper/Data.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Featuredproduct_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ }
app/code/local/Magestore/Featuredproduct/Model/Featuredproduct.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Featuredproduct_Model_Featuredproduct extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('featuredproduct/featuredproduct');
9
+ }
10
+ }
app/code/local/Magestore/Featuredproduct/Model/Mysql4/Featuredproduct.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Magestore_Featuredproduct_Model_Mysql4_Featuredproduct extends Mage_Core_Model_Mysql4_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ // Note that the featuredproduct_id refers to the key field in your database table.
7
+ $this->_init('featuredproduct/featuredproduct', 'entity_id');
8
+ }
9
+ }
10
+ //featuredproduct/featuredproduct
app/code/local/Magestore/Featuredproduct/Model/Mysql4/Featuredproduct/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Featuredproduct_Model_Mysql4_Featuredproduct_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('featuredproduct/featuredproduct');
9
+ }
10
+ }
app/code/local/Magestore/Featuredproduct/Model/Status.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Featuredproduct_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('featuredproduct')->__('Enabled'),
12
+ self::STATUS_DISABLED => Mage::helper('featuredproduct')->__('Disabled')
13
+ );
14
+ }
15
+ }
app/code/local/Magestore/Featuredproduct/Model/Typeshow.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Magestore_Featuredproduct_Model_Typeshow extends Varien_Object
3
+ {
4
+ public function toOptionArray()
5
+ {
6
+ return array(
7
+ array('value'=>'static', 'label'=>Mage::helper('featuredproduct')->__('Static')),
8
+ array('value'=>'slider', 'label'=>Mage::helper('featuredproduct')->__('Slider')),
9
+ array('value'=>'slider2', 'label'=>Mage::helper('featuredproduct')->__('Slider2')),
10
+ );
11
+ }
12
+
13
+ }
14
+ ?>
app/code/local/Magestore/Featuredproduct/controllers/Adminhtml/FeaturedproductController.php ADDED
@@ -0,0 +1,238 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Featuredproduct_Adminhtml_FeaturedproductController extends Mage_Adminhtml_Controller_action
4
+ {
5
+
6
+ protected function _initAction() {
7
+ $this->loadLayout()
8
+ ->_setActiveMenu('featuredproduct/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('featuredproduct/featuredproduct')->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('featuredproduct_data', $model);
30
+
31
+ $this->loadLayout();
32
+ $this->_setActiveMenu('featuredproduct/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('featuredproduct/adminhtml_featuredproduct_edit'))
40
+ ->_addLeft($this->getLayout()->createBlock('featuredproduct/adminhtml_featuredproduct_edit_tabs'));
41
+
42
+ $this->renderLayout();
43
+ } else {
44
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('featuredproduct')->__('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('featuredproduct/featuredproduct');
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('featuredproduct')->__('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('featuredproduct')->__('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('featuredproduct/featuredproduct');
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
+ $featuredproductIds = $this->getRequest()->getParam('featuredproduct');
137
+ if(!is_array($featuredproductIds)) {
138
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
139
+ } else {
140
+ try {
141
+ foreach ($featuredproductIds as $featuredproductId) {
142
+ $featuredproduct = Mage::getModel('featuredproduct/featuredproduct')->load($featuredproductId);
143
+ $featuredproduct->delete();
144
+ }
145
+ Mage::getSingleton('adminhtml/session')->addSuccess(
146
+ Mage::helper('adminhtml')->__(
147
+ 'Total of %d record(s) were successfully deleted', count($featuredproductIds)
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
+ $featuredproductIds = $this->getRequest()->getParam('featuredproduct');
160
+ if(!is_array($featuredproductIds)) {
161
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
162
+ } else {
163
+ try {
164
+ foreach ($featuredproductIds as $featuredproductId) {
165
+ $featuredproduct = Mage::getSingleton('catalog/product')
166
+ ->load($featuredproductId)
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($featuredproductIds))
173
+ );
174
+ } catch (Exception $e) {
175
+ $this->_getSession()->addError($e->getMessage());
176
+ }
177
+ }
178
+ $this->_redirect('*/*/index');
179
+ }
180
+
181
+ public function massFeaturedproductAction()
182
+ {
183
+ $productIds = $this->getRequest()->getParam('featuredproduct');
184
+ $storeId = (int)$this->getRequest()->getParam('store', 0);
185
+ $featuredproduct = (int)$this->getRequest()->getParam('fb_product');
186
+
187
+ try {
188
+ Mage::getSingleton('catalog/product_action')
189
+ ->updateAttributes($productIds, array('fb_product' => $featuredproduct), $storeId);
190
+
191
+ $this->_getSession()->addSuccess(
192
+ $this->__('Total of %d record(s) have been updated.', count($productIds))
193
+ );
194
+ }
195
+ catch (Mage_Core_Model_Exception $e) {
196
+ $this->_getSession()->addError($e->getMessage());
197
+ }
198
+ catch (Exception $e) {
199
+ $this->_getSession()->addException($e, $this->__('An error occurred while updating the product(s) status.'));
200
+ }
201
+
202
+ $this->_redirect('*/*/', array('store'=> $storeId));
203
+ }
204
+
205
+ /* public function exportCsvAction()
206
+ {
207
+ $fileName = 'featuredproduct.csv';
208
+ $content = $this->getLayout()->createBlock('featuredproduct/adminhtml_featuredproduct_grid')
209
+ ->getCsv();
210
+
211
+ $this->_sendUploadResponse($fileName, $content);
212
+ }
213
+
214
+ public function exportXmlAction()
215
+ {
216
+ $fileName = 'featuredproduct.xml';
217
+ $content = $this->getLayout()->createBlock('featuredproduct/adminhtml_featuredproduct_grid')
218
+ ->getXml();
219
+
220
+ $this->_sendUploadResponse($fileName, $content);
221
+ } */
222
+
223
+ protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
224
+ {
225
+ $response = $this->getResponse();
226
+ $response->setHeader('HTTP/1.1 200 OK','');
227
+ $response->setHeader('Pragma', 'public', true);
228
+ $response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
229
+ $response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
230
+ $response->setHeader('Last-Modified', date('r'));
231
+ $response->setHeader('Accept-Ranges', 'bytes');
232
+ $response->setHeader('Content-Length', strlen($content));
233
+ $response->setHeader('Content-type', $contentType);
234
+ $response->setBody($content);
235
+ $response->sendResponse();
236
+ die;
237
+ }
238
+ }
app/code/local/Magestore/Featuredproduct/controllers/Faq/Block/Adminhtml/Category.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Magestore_Faq_Block_Adminhtml_Category extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ public function __construct()
5
+ {
6
+ $this->_controller = 'adminhtml_category';
7
+ $this->_blockGroup = 'faq';
8
+ $this->_headerText = Mage::helper('faq')->__('Category Manager');
9
+ $this->_addButtonLabel = Mage::helper('faq')->__('Add category');
10
+ parent::__construct();
11
+ }
12
+ }
app/code/local/Magestore/Featuredproduct/controllers/Faq/Block/Adminhtml/Category/Edit.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Faq_Block_Adminhtml_Category_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+
9
+ $this->_objectId = 'id';
10
+ $this->_blockGroup = 'faq';
11
+ $this->_controller = 'adminhtml_category';
12
+
13
+ $this->_updateButton('save', 'label', Mage::helper('faq')->__('Save Category'));
14
+ $this->_updateButton('delete', 'label', Mage::helper('faq')->__('Delete Category'));
15
+
16
+ $this->_addButton('saveandcontinue', array(
17
+ 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
18
+ 'onclick' => 'saveAndContinueEdit()',
19
+ 'class' => 'save',
20
+ ), -100);
21
+
22
+ $this->_formScripts[] = "
23
+
24
+ function saveAndContinueEdit(){
25
+ editForm.submit($('edit_form').action+'back/edit/');
26
+ }
27
+ ";
28
+ }
29
+
30
+ public function getHeaderText()
31
+ {
32
+ if( Mage::registry('faqcategory_data') && Mage::registry('faqcategory_data')->getId() ) {
33
+ return Mage::helper('faq')->__("Edit Category '%s'", $this->htmlEscape(Mage::registry('faqcategory_data')->getName()));
34
+ } else {
35
+ return Mage::helper('faq')->__('Add Category');
36
+ }
37
+ }
38
+ }
app/code/local/Magestore/Featuredproduct/controllers/Faq/Block/Adminhtml/Category/Edit/Form.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Faq_Block_Adminhtml_Category_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ $form = new Varien_Data_Form(array(
8
+ 'id' => 'edit_form',
9
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'),'store'=>$this->getRequest()->getParam('store'))),
10
+ 'method' => 'post',
11
+ 'enctype' => 'multipart/form-data'
12
+ )
13
+ );
14
+
15
+ $form->setUseContainer(true);
16
+ $this->setForm($form);
17
+ return parent::_prepareForm();
18
+ }
19
+ }
app/code/local/Magestore/Featuredproduct/controllers/Faq/Block/Adminhtml/Category/Edit/Tab/Form.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Faq_Block_Adminhtml_Category_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+
6
+ public function getCategory()
7
+ {
8
+ return Mage::registry('faqcategory_data');
9
+ }
10
+
11
+ protected function _prepareForm()
12
+ {
13
+ $form = new Varien_Data_Form();
14
+ $this->setForm($form);
15
+ $fieldset = $form->addFieldset('category_form', array('legend'=>Mage::helper('faq')->__('Category information')));
16
+
17
+ $store_id = $this->getRequest()->getParam('store');
18
+
19
+ $fieldset->addField('status', 'select', array(
20
+ 'label' => Mage::helper('faq')->__('Status'),
21
+ 'name' => 'status',
22
+ 'values' => array(
23
+ array(
24
+ 'value' => 1,
25
+ 'label' => Mage::helper('faq')->__('Enabled'),
26
+ ),
27
+
28
+ array(
29
+ 'value' => 2,
30
+ 'label' => Mage::helper('faq')->__('Disabled'),
31
+ ),
32
+ ),
33
+ 'disabled' => false,
34
+ ));
35
+
36
+ $fieldset->addField('name', 'text', array(
37
+ 'label' => Mage::helper('faq')->__('Name'),
38
+ 'class' => 'required-entry',
39
+ 'required' => true,
40
+ 'name' => 'name',
41
+
42
+ 'disabled' => false,
43
+ ));
44
+
45
+
46
+ $fieldset->addField('url_key', 'text', array(
47
+ 'label' => Mage::helper('faq')->__('Url Key'),
48
+ 'required' => false,
49
+ 'name' => 'url_key',
50
+
51
+ 'disabled' => $store_id?true:false,
52
+ ));
53
+
54
+
55
+ $fieldset->addField('ordering', 'text', array(
56
+ 'label' => Mage::helper('faq')->__('Ordering'),
57
+ 'class' => 'required-entry',
58
+ 'required' => true,
59
+ 'name' => 'ordering',
60
+ 'disabled' => false,
61
+ ));
62
+
63
+
64
+
65
+ $fieldset->addField('description', 'editor', array(
66
+ 'name' => 'description',
67
+ 'label' => Mage::helper('faq')->__('Description'),
68
+ 'title' => Mage::helper('faq')->__('Description'),
69
+ 'style' => 'width:500px; height:100px;',
70
+ 'wysiwyg' => false,
71
+ 'required' => true,
72
+ 'disabled' => false,
73
+ ));
74
+
75
+
76
+ if ( Mage::getSingleton('adminhtml/session')->getFaqcategoryData() )
77
+ {
78
+ $data = Mage::getSingleton('adminhtml/session')->getFaqcategoryData();
79
+ $form->setValues($data);
80
+ Mage::getSingleton('adminhtml/session')->setFaqcategoryData(null);
81
+ } elseif ( Mage::registry('faqcategory_data') ) {
82
+ $data = Mage::registry('faqcategory_data')->getData() ;
83
+ $form->setValues($data);
84
+ }
85
+ return parent::_prepareForm();
86
+ }
87
+ }
app/code/local/Magestore/Featuredproduct/controllers/Faq/Block/Adminhtml/Category/Edit/Tabs.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Faq_Block_Adminhtml_Category_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId('category_tabs');
10
+ $this->setDestElementId('edit_form');
11
+ $this->setTitle(Mage::helper('faq')->__('Category Information'));
12
+ }
13
+
14
+ protected function _beforeToHtml()
15
+ {
16
+ $this->addTab('form_section', array(
17
+ 'label' => Mage::helper('faq')->__('Category Information'),
18
+ 'title' => Mage::helper('faq')->__('category Information'),
19
+ 'content' => $this->getLayout()->createBlock('faq/adminhtml_category_edit_tab_form')->toHtml(),
20
+ ));
21
+
22
+ return parent::_beforeToHtml();
23
+ }
24
+ }
app/code/local/Magestore/Featuredproduct/controllers/Faq/Block/Adminhtml/Category/Grid.php ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Faq_Block_Adminhtml_Category_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('categoryGrid');
9
+ $this->setDefaultSort('category_id');
10
+ $this->setDefaultDir('ASC');
11
+ $this->setSaveParametersInSession(true);
12
+ }
13
+
14
+ protected function _prepareCollection()
15
+ {
16
+ $collection = Mage::getModel('faq/category')->getCollection();
17
+ $this->setCollection($collection);
18
+ return parent::_prepareCollection();
19
+ }
20
+
21
+ protected function _prepareColumns()
22
+ {
23
+ $this->addColumn('category_id', array(
24
+ 'header' => Mage::helper('faq')->__('ID'),
25
+ 'align' =>'right',
26
+ 'width' => '50px',
27
+ 'index' => 'category_id',
28
+ ));
29
+
30
+ $this->addColumn('name', array(
31
+ 'header' => Mage::helper('faq')->__('Name'),
32
+ 'align' =>'left',
33
+ 'width' => '250px',
34
+ 'index' => 'name',
35
+ ));
36
+
37
+ $this->addColumn('url_key', array(
38
+ 'header' => Mage::helper('faq')->__('Url Key'),
39
+ 'align' =>'left',
40
+ 'width' => '250px',
41
+ 'index' => 'url_key',
42
+ ));
43
+
44
+
45
+ $this->addColumn('ordering', array(
46
+ 'header' => Mage::helper('faq')->__('Ordering'),
47
+ 'align' =>'right',
48
+ 'width' => '50px',
49
+ 'index' => 'ordering',
50
+ ));
51
+ $this->addColumn('status', array(
52
+ 'header' => Mage::helper('faq')->__('Status'),
53
+ 'align' => 'left',
54
+ 'width' => '80px',
55
+ 'index' => 'status',
56
+ 'type'