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' => 'options',
57
+ 'options' => array(
58
+ 1 => 'Enabled',
59
+ 2 => 'Disabled',
60
+ ),
61
+ ));
62
+
63
+ $this->addColumn('action',
64
+ array(
65
+ 'header' => Mage::helper('faq')->__('Action'),
66
+ 'width' => '100',
67
+ 'type' => 'action',
68
+ 'getter' => 'getId',
69
+ 'actions' => array(
70
+ array(
71
+ 'caption' => Mage::helper('faq')->__('Edit'),
72
+ 'url' => array('base'=> '*/*/edit'),
73
+ 'field' => 'id'
74
+ )
75
+ ),
76
+ 'filter' => false,
77
+ 'sortable' => false,
78
+ 'index' => 'stores',
79
+ 'is_system' => true,
80
+ ));
81
+
82
+ $this->addExportType('*/*/exportCsv', Mage::helper('faq')->__('CSV'));
83
+ $this->addExportType('*/*/exportXml', Mage::helper('faq')->__('XML'));
84
+
85
+ return parent::_prepareColumns();
86
+ }
87
+
88
+ protected function _prepareMassaction()
89
+ {
90
+ $this->setMassactionIdField('category_id');
91
+ $this->getMassactionBlock()->setFormFieldName('category');
92
+
93
+ $this->getMassactionBlock()->addItem('delete', array(
94
+ 'label' => Mage::helper('faq')->__('Delete'),
95
+ 'url' => $this->getUrl('*/*/massDelete'),
96
+ 'confirm' => Mage::helper('faq')->__('Are you sure?')
97
+ ));
98
+
99
+ $statuses = Mage::getSingleton('faq/status')->getOptionArray();
100
+
101
+ array_unshift($statuses, array('label'=>'', 'value'=>''));
102
+ $this->getMassactionBlock()->addItem('status', array(
103
+ 'label'=> Mage::helper('faq')->__('Change status'),
104
+ 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
105
+ 'additional' => array(
106
+ 'visibility' => array(
107
+ 'name' => 'status',
108
+ 'type' => 'select',
109
+ 'class' => 'required-entry',
110
+ 'label' => Mage::helper('faq')->__('Status'),
111
+ 'values' => $statuses
112
+ )
113
+ )
114
+ ));
115
+ return $this;
116
+ }
117
+
118
+ public function getRowUrl($row)
119
+ {
120
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
121
+ }
122
+
123
+ }
app/code/local/Magestore/Featuredproduct/controllers/Faq/Block/Adminhtml/Faq.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Magestore_Faq_Block_Adminhtml_Faq extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ public function __construct()
5
+ {
6
+ $this->_controller = 'adminhtml_faq';
7
+ $this->_blockGroup = 'faq';
8
+ $this->_headerText = Mage::helper('faq')->__('FAQ Manager');
9
+ $this->_addButtonLabel = Mage::helper('faq')->__('Add FAQ');
10
+ parent::__construct();
11
+ }
12
+ }
app/code/local/Magestore/Featuredproduct/controllers/Faq/Block/Adminhtml/Faq/Edit.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Faq_Block_Adminhtml_Faq_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_faq';
12
+
13
+ $this->_updateButton('save', 'label', Mage::helper('faq')->__('Save FAQ'));
14
+ $this->_updateButton('delete', 'label', Mage::helper('faq')->__('Delete FAQ'));
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
+ function toggleEditor() {
24
+ if (tinyMCE.getInstanceById('faq_description') == null) {
25
+ tinyMCE.execCommand('mceAddControl', false, 'faq_description');
26
+ } else {
27
+ tinyMCE.execCommand('mceRemoveControl', false, 'faq_description');
28
+ }
29
+ }
30
+ function saveAndContinueEdit(){
31
+ editForm.submit($('edit_form').action+'back/edit/');
32
+ }
33
+
34
+ ";
35
+ }
36
+
37
+ public function getHeaderText()
38
+ {
39
+ if( Mage::registry('faq_data') && Mage::registry('faq_data')->getId() ) {
40
+ return Mage::helper('faq')->__("Edit Item '%s'", $this->htmlEscape(Mage::registry('faq_data')->getTitle()));
41
+ } else {
42
+ return Mage::helper('faq')->__('Add Item');
43
+ }
44
+ }
45
+ }
app/code/local/Magestore/Featuredproduct/controllers/Faq/Block/Adminhtml/Faq/Edit/Form.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Faq_Block_Adminhtml_Faq_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/Faq/Edit/Tab/Form.php ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Faq_Block_Adminhtml_Faq_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+
6
+ public function getFaq()
7
+ {
8
+ return Mage::registry('faq_data');
9
+ }
10
+
11
+ protected function _prepareForm()
12
+ {
13
+ $form = new Varien_Data_Form();
14
+ $this->setForm($form);
15
+ $fieldset = $form->addFieldset('faq_form', array('legend'=>Mage::helper('faq')->__('Item information')));
16
+
17
+ $store_id = $this->getRequest()->getParam('store');
18
+
19
+
20
+ $disabled = false;
21
+
22
+
23
+ $fieldset->addField('status', 'select', array(
24
+ 'label' => Mage::helper('faq')->__('Status'),
25
+ 'name' => 'status',
26
+ 'values' => array(
27
+ array(
28
+ 'value' => 1,
29
+ 'label' => Mage::helper('faq')->__('Enabled'),
30
+ ),
31
+
32
+ array(
33
+ 'value' => 2,
34
+ 'label' => Mage::helper('faq')->__('Disabled'),
35
+ ),
36
+ ),
37
+ 'disabled' => $disabled,
38
+ ));
39
+
40
+ $fieldset->addField('title', 'text', array(
41
+ 'label' => Mage::helper('faq')->__('Title'),
42
+ 'class' => 'required-entry',
43
+ 'required' => true,
44
+ 'name' => 'title',
45
+ 'disabled' => $disabled,
46
+
47
+ ));
48
+
49
+ $fieldset->addField('category_id', 'select', array(
50
+ 'label' => Mage::helper('faq')->__('Category'),
51
+ 'class' => 'required-entry',
52
+ 'required' => true,
53
+ 'name' => 'category_id',
54
+ 'values' => Mage::helper('faq')->getCategoryOptions2($store_id),
55
+ 'disabled' => $disabled,
56
+ ));
57
+
58
+
59
+
60
+
61
+ $fieldset->addField('most_frequently', 'select', array(
62
+ 'label' => Mage::helper('faq')->__('Is Most Frequently'),
63
+ 'name' => 'most_frequently',
64
+ 'values' => array(
65
+ array(
66
+ 'value' => 0,
67
+ 'label' => Mage::helper('faq')->__('False'),
68
+ ),
69
+
70
+ array(
71
+ 'value' => 1,
72
+ 'label' => Mage::helper('faq')->__('True'),
73
+ ),
74
+ ),
75
+ 'disabled' => $disabled,
76
+ ));
77
+
78
+ $fieldset->addField('url_key', 'text', array(
79
+ 'label' => Mage::helper('faq')->__('Url Key'),
80
+
81
+ 'required' => false,
82
+ 'name' => 'url_key',
83
+ 'disabled' => $store_id?true:false,
84
+
85
+ ));
86
+
87
+ $fieldset->addField('ordering', 'text', array(
88
+ 'label' => Mage::helper('faq')->__('Ordering'),
89
+ 'required' => false,
90
+ 'name' => 'ordering',
91
+ 'disabled' => $disabled,
92
+ ));
93
+
94
+
95
+
96
+ $fieldset->addField('description', 'editor', array(
97
+ 'name' => 'description',
98
+ 'label' => Mage::helper('faq')->__('Description'),
99
+ 'title' => Mage::helper('faq')->__('Description'),
100
+ 'style' => 'width:500px; height:300px;',
101
+ 'wysiwyg' => false,
102
+ 'required' => false,
103
+ 'disabled' => $disabled,
104
+ ));
105
+
106
+
107
+
108
+ if ( Mage::getSingleton('adminhtml/session')->getFaqData() )
109
+ {
110
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getFaqData());
111
+ Mage::getSingleton('adminhtml/session')->setFaqData(null);
112
+ } elseif ( Mage::registry('faq_data') ) {
113
+ $form->setValues(Mage::registry('faq_data')->getData());
114
+ }
115
+ return parent::_prepareForm();
116
+ }
117
+ }
app/code/local/Magestore/Featuredproduct/controllers/Faq/Block/Adminhtml/Faq/Edit/Tabs.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Faq_Block_Adminhtml_Faq_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId('faq_tabs');
10
+ $this->setDestElementId('edit_form');
11
+ $this->setTitle(Mage::helper('faq')->__('FAQ Information'));
12
+ }
13
+
14
+ protected function _beforeToHtml()
15
+ {
16
+ $this->addTab('form_section', array(
17
+ 'label' => Mage::helper('faq')->__('FAQ Information'),
18
+ 'title' => Mage::helper('faq')->__('FAQ Information'),
19
+ 'content' => $this->getLayout()->createBlock('faq/adminhtml_faq_edit_tab_form')->toHtml(),
20
+ ));
21
+
22
+ return parent::_beforeToHtml();
23
+ }
24
+ }
app/code/local/Magestore/Featuredproduct/controllers/Faq/Block/Adminhtml/Faq/Grid.php ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Faq_Block_Adminhtml_Faq_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('faqGrid');
9
+ $this->setDefaultSort('faq_id');
10
+ $this->setDefaultDir('ASC');
11
+ $this->setSaveParametersInSession(true);
12
+ }
13
+
14
+ protected function _prepareCollection()
15
+ {
16
+ $collection = Mage::getModel('faq/faq')->getCollection();
17
+ $this->setCollection($collection);
18
+ return parent::_prepareCollection();
19
+ }
20
+
21
+ protected function _prepareColumns()
22
+ {
23
+ $this->addColumn('faq_id', array(
24
+ 'header' => Mage::helper('faq')->__('ID'),
25
+ 'align' =>'right',
26
+ 'width' => '50px',
27
+ 'index' => 'faq_id',
28
+ ));
29
+
30
+
31
+
32
+ $this->addColumn('title', array(
33
+ 'header' => Mage::helper('faq')->__('Title'),
34
+ 'align' =>'left',
35
+ 'index' => 'title',
36
+ 'width' => '250',
37
+ ));
38
+
39
+ $this->addColumn('ordering', array(
40
+ 'header' => Mage::helper('faq')->__('Ordering'),
41
+ 'align' =>'left',
42
+ 'width' => '80',
43
+ 'index' => 'ordering',
44
+ ));
45
+
46
+ $this->addColumn('category_id', array(
47
+ 'header' => Mage::helper('faq')->__('Category'),
48
+ 'align' => 'left',
49
+ 'width' => '150',
50
+ 'index' => 'category_id',
51
+ 'type' =>'options',
52
+ 'options' => Mage::helper('faq')->getCategoryOptions1(),
53
+ ));
54
+
55
+
56
+ $this->addColumn('url_key', array(
57
+ 'header' => Mage::helper('faq')->__('Url Key'),
58
+ 'width' => '250px',
59
+ 'index' => 'url_key',
60
+ ));
61
+
62
+ $this->addColumn('status', array(
63
+ 'header' => Mage::helper('faq')->__('Status'),
64
+ 'align' => 'left',
65
+ 'width' => '80px',
66
+ 'index' => 'status',
67
+ 'type' => 'options',
68
+ 'options' => array(
69
+ 1 => 'Enabled',
70
+ 2 => 'Disabled',
71
+ ),
72
+ ));
73
+
74
+ $this->addColumn('action',
75
+ array(
76
+ 'header' => Mage::helper('faq')->__('Action'),
77
+ 'width' => '100',
78
+ 'type' => 'action',
79
+ 'getter' => 'getId',
80
+ 'actions' => array(
81
+ array(
82
+ 'caption' => Mage::helper('faq')->__('Edit'),
83
+ 'url' => array('base'=> '*/*/edit'),
84
+ 'field' => 'id'
85
+ )
86
+ ),
87
+ 'filter' => false,
88
+ 'sortable' => false,
89
+ 'index' => 'stores',
90
+ 'is_system' => true,
91
+ ));
92
+
93
+ $this->addExportType('*/*/exportCsv', Mage::helper('faq')->__('CSV'));
94
+ $this->addExportType('*/*/exportXml', Mage::helper('faq')->__('XML'));
95
+
96
+ return parent::_prepareColumns();
97
+ }
98
+
99
+ protected function _prepareMassaction()
100
+ {
101
+ $this->setMassactionIdField('faq_id');
102
+ $this->getMassactionBlock()->setFormFieldName('faq');
103
+
104
+ $this->getMassactionBlock()->addItem('delete', array(
105
+ 'label' => Mage::helper('faq')->__('Delete'),
106
+ 'url' => $this->getUrl('*/*/massDelete'),
107
+ 'confirm' => Mage::helper('faq')->__('Are you sure?')
108
+ ));
109
+
110
+ $statuses = Mage::getSingleton('faq/status')->getOptionArray();
111
+
112
+ array_unshift($statuses, array('label'=>'', 'value'=>''));
113
+ $this->getMassactionBlock()->addItem('status', array(
114
+ 'label'=> Mage::helper('faq')->__('Change status'),
115
+ 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
116
+ 'additional' => array(
117
+ 'visibility' => array(
118
+ 'name' => 'status',
119
+ 'type' => 'select',
120
+ 'class' => 'required-entry',
121
+ 'label' => Mage::helper('faq')->__('Status'),
122
+ 'values' => $statuses
123
+ )
124
+ )
125
+ ));
126
+ return $this;
127
+ }
128
+
129
+ public function getRowUrl($row)
130
+ {
131
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
132
+ }
133
+
134
+ }
app/code/local/Magestore/Featuredproduct/controllers/Faq/Block/Category.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Magestore_Faq_Block_Category extends Mage_Core_Block_Template
3
+ {
4
+ public function _prepareLayout()
5
+ {
6
+ return parent::_prepareLayout();
7
+ }
8
+
9
+ public function getFaq()
10
+ {
11
+ if (!$this->hasData('faq')) {
12
+ $this->setData('faq', Mage::registry('faq'));
13
+ }
14
+ return $this->getData('faq');
15
+
16
+ }
17
+
18
+ public function getCategories()
19
+ {
20
+ $store_id = Mage::helper("faq")->getStoreId();
21
+ $collection = Mage::getModel("faq/category")
22
+ ->setStoreId($store_id)
23
+ ->getCollection();
24
+
25
+ return $collection;
26
+ }
27
+ }
app/code/local/Magestore/Featuredproduct/controllers/Faq/Block/Overview.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Magestore_Faq_Block_Overview extends Mage_Core_Block_Template
3
+ {
4
+ public function _prepareLayout()
5
+ {
6
+ $breadcrumbs = $this->getLayout()->getBlock('breadcrumbs');
7
+ $breadcrumbs->addCrumb('home', array('label'=>Mage::helper('cms')->__('Home'), 'title'=>Mage::helper('cms')->__('Home Page'), 'link'=>Mage::getBaseUrl()));
8
+ $breadcrumbs->addCrumb('faq', array('label'=>'FAQ', 'title'=>'FAQ', 'link'=>Mage::getUrl("faq")));
9
+
10
+ return parent::_prepareLayout();
11
+ }
12
+
13
+ public function getMostFrequently()
14
+ {
15
+ $most_frequently = Mage::getModel("faq/faq")
16
+ ->setStoreId($this->getStoreId())
17
+ ->getMostFrequently();
18
+
19
+ return $most_frequently;
20
+ }
21
+
22
+ public function getAllCategory()
23
+ {
24
+
25
+ $categories = Mage::getModel("faq/category")
26
+ ->setStoreId($this->getStoreId())
27
+ ->getCollection()
28
+ // ->addFieldToFilter("status",1)
29
+ // ->setOrder("ordering","ASC")
30
+ // ->setOrder("name", "ASC")
31
+ ;
32
+
33
+ return $categories;
34
+ }
35
+
36
+ public function getStoreId()
37
+ {
38
+ if(!$this->hasData('store_id'))
39
+ {
40
+ $store_id = Mage::app()->getStore()->getId();
41
+ $this->setData('store_id',$store_id);
42
+ }
43
+ return $this->getData('store_id');
44
+ }
45
+ }
app/code/local/Magestore/Featuredproduct/controllers/Faq/Block/Search.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Magestore_Faq_Block_Search extends Mage_Core_Block_Template
3
+ {
4
+ public function _prepareLayout()
5
+ {
6
+ $breadcrumbs = $this->getLayout()->getBlock('breadcrumbs');
7
+ $breadcrumbs->addCrumb('home', array('label'=>Mage::helper('cms')->__('Home'), 'title'=>Mage::helper('cms')->__('Home Page'), 'link'=>Mage::getBaseUrl()));
8
+ $breadcrumbs->addCrumb('faq', array('label'=>'FAQ', 'title'=>'FAQ', 'link'=>Mage::getUrl("faq")));
9
+ $breadcrumbs->addCrumb('search', array('label'=>Mage::helper('faq')->__('Search'), 'title'=>Mage::helper('faq')->__('Search'), 'link'=>Mage::getUrl("faq/search/result")));
10
+ return parent::_prepareLayout();
11
+ }
12
+
13
+ public function getStoreId()
14
+ {
15
+ if(!$this->hasData('store_id'))
16
+ {
17
+ $store_id = Mage::app()->getStore()->getId();
18
+ $this->setData('store_id',$store_id);
19
+ }
20
+ return $this->getData('store_id');
21
+ }
22
+ }
app/code/local/Magestore/Featuredproduct/controllers/Faq/Block/View.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Magestore_Faq_Block_View extends Mage_Core_Block_Template
3
+ {
4
+ public function _prepareLayout()
5
+ {
6
+ $category_id = Mage::registry("category_id");
7
+ $faq_id = Mage::registry("faq_id");
8
+
9
+ $category = Mage::getModel("faq/category")
10
+ ->setStoreId($this->getStoreId())
11
+ ->load($category_id);
12
+ //echo("category_id=".$category_id);
13
+
14
+
15
+ $base_url = Mage::getBaseUrl();
16
+ $category_view_url = $base_url . $category->getUrlKey();
17
+
18
+ $breadcrumbs = $this->getLayout()->getBlock('breadcrumbs');
19
+ $breadcrumbs->addCrumb('home', array('label'=>Mage::helper('cms')->__('Home'), 'title'=>Mage::helper('cms')->__('Home Page'), 'link'=>Mage::getBaseUrl()));
20
+ $breadcrumbs->addCrumb('faq', array('label'=>'FAQ', 'title'=>'FAQ', 'link'=>Mage::getUrl("faq")));
21
+ $breadcrumbs->addCrumb('category', array('label'=>$category->getName(), 'title'=>$category->getName(), 'link'=>$category_view_url));
22
+
23
+ $headBlock = $this->getLayout()->getBlock('head');
24
+
25
+ $page_title = $category->getName();
26
+
27
+ if($faq_id)
28
+ {
29
+
30
+ $faq = Mage::getModel('faq/faq')
31
+ ->setStoreId($this->getRequest()->getParam('store'))
32
+ ->load($faq_id);
33
+
34
+ $breadcrumbs->addCrumb('view_question', array('label'=>$faq->getTitle(), 'title'=>$faq->getTitle(), 'link'=>null));
35
+
36
+ $page_title .= " - ".$faq->getTitle();
37
+ }
38
+
39
+ $this->page_title = $page_title;
40
+ $headBlock->setTitle($page_title);
41
+
42
+
43
+
44
+
45
+ return parent::_prepareLayout();
46
+ }
47
+
48
+ public function getPageTitle()
49
+ {
50
+ return $this->page_title;
51
+ }
52
+
53
+ public function getStoreId()
54
+ {
55
+ if(!$this->hasData('store_id'))
56
+ {
57
+ $store_id = Mage::app()->getStore()->getId();
58
+ $this->setData('store_id',$store_id);
59
+ }
60
+ return $this->getData('store_id');
61
+ }
62
+
63
+ public function getFaq()
64
+ {
65
+ $faq_id = Mage::registry("faq_id");
66
+
67
+ $faq = Mage::getModel('faq/faq')
68
+ ->setStoreId($this->getStoreId())
69
+ ->load($faq_id);
70
+ if($faq->getStatus())
71
+ {
72
+ return $faq;
73
+ }
74
+ return null;
75
+ }
76
+ }
app/code/local/Magestore/Featuredproduct/controllers/Faq/Helper/Data.php ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Faq_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+ public static function getCategoryOptions1()
6
+ {
7
+ $options = array();
8
+ $collection = Mage::getModel('faq/category')->getCollection();
9
+ foreach($collection as $category)
10
+ {
11
+ $options[$category->getCategoryId()] = $category->getName();
12
+ }
13
+ return $options;
14
+ }
15
+
16
+ public static function getCategoryOptions2($store_id = null)
17
+ {
18
+ $options = array();
19
+ $collection = Mage::getModel('faq/category')
20
+ ->setStoreId($store_id)
21
+ ->getCollection();
22
+
23
+ foreach($collection as $category)
24
+ {
25
+ $option = array();
26
+ $option['label'] = $category->getName();
27
+ $option['value'] = $category->getCategoryId();
28
+ $options[] = $option;
29
+ }
30
+
31
+ return $options;
32
+ }
33
+
34
+ public function getOptionApplied()
35
+ {
36
+ return array(
37
+ array('value'=>1,'label'=>$this->__('Yes')),
38
+ array('value'=>0,'label'=>$this->__('No')),
39
+
40
+ );
41
+ }
42
+
43
+ public function getTablePrefix()
44
+ {
45
+ $tableName = Mage::getResourceModel('faq/faq')->getTable('faq');
46
+ $prefix = substr($tableName,0,strlen($tableName)-3);
47
+ return $prefix;
48
+ }
49
+
50
+ public function normalizeUrlKey($urlKey)
51
+ {
52
+ for($i=0;$i<5;$i++)
53
+ {
54
+ $urlKey = str_replace(" "," ",$urlKey);
55
+ }
56
+ $urlKey = trim($urlKey);
57
+ $urlKey = str_replace(" ","-",$urlKey);
58
+ $urlKey = str_replace(",","",$urlKey);
59
+ $urlKey = str_replace("?","",$urlKey);
60
+ $urlKey = str_replace(":","-",$urlKey);
61
+ $urlKey = str_replace("!","-",$urlKey);
62
+
63
+ $urlKey = str_replace("'","-",$urlKey);
64
+ $urlKey = strtolower($urlKey);
65
+
66
+ return $urlKey;
67
+ }
68
+
69
+ public function getFaqUrl()
70
+ {
71
+ $url = $this->_getUrl("faq", array());
72
+
73
+ return $url;
74
+ }
75
+
76
+ public function getStoreId()
77
+ {
78
+ $store_id = Mage::app()->getStore()->getId();
79
+
80
+ return $store_id;
81
+ }
82
+
83
+
84
+ public function cloneFaqStoreData($faqStore)
85
+ {
86
+
87
+ $stores = Mage::app()->getStores();
88
+ if(count($stores) == 1)
89
+ {
90
+ foreach($stores as $store)
91
+ {
92
+ $id = $faqStore->getFaqId();
93
+ $store_id = $store->getStoreId();
94
+ $faqStore_new = Mage::getModel("faq/faqstore")->loadByFaqIdStore($id,$store_id);
95
+ $faqStore_new->setTitle($faqStore->getTitle());
96
+ $faqStore_new->setCategoryId($faqStore->getCategoryId());
97
+ $faqStore_new->setDescription($faqStore->getDescription());
98
+ $faqStore_new->setStatus($faqStore->getStatus());
99
+ $faqStore_new->setOrdering($faqStore->getOrdering());
100
+ $faqStore_new->setUrlKey($faqStore->getUrlKey());
101
+ $faqStore_new->setData("most_frequently",$faqStore->getData("most_frequently"));
102
+
103
+ //print_r($faqStore_new->getData());die();
104
+
105
+ $faqStore_new->save();
106
+
107
+ if($faqStore_new->getStatus() == 1)
108
+ {
109
+ $faqStore_new->updateUrlKey();
110
+ }
111
+ else
112
+ {
113
+ $faqStore_new->deleteUrlKey();
114
+ }
115
+ }
116
+ }
117
+ else
118
+ {
119
+ $faqStore->save();
120
+ if($faqStore->getStoreId())
121
+ {
122
+ if($faqStore->getStatus() == 1)
123
+ {
124
+ $faqStore->updateUrlKey();
125
+ }
126
+ else
127
+ {
128
+ $faqStore->deleteUrlKey();
129
+ }
130
+ }
131
+ }
132
+ }
133
+
134
+ public function cloneCategoryStoreData($categoryStore)
135
+ {
136
+
137
+ $stores = Mage::app()->getStores();
138
+ if(count($stores) == 1)
139
+ {
140
+ foreach($stores as $store)
141
+ {
142
+ $id = $categoryStore->getCategoryId();
143
+ $store_id = $store->getStoreId();
144
+ $categoryStore_new = Mage::getModel("faq/categorystore")->loadByCatIdStore($id,$store_id);
145
+ $categoryStore_new->setName($categoryStore->getName());
146
+
147
+ $categoryStore_new->setDescription($categoryStore->getDescription());
148
+ $categoryStore_new->setStatus($categoryStore->getStatus());
149
+ $categoryStore_new->setOrdering($categoryStore->getOrdering());
150
+ $categoryStore_new->setUrlKey($categoryStore->getUrlKey());
151
+
152
+ $categoryStore_new->save();
153
+
154
+ if($categoryStore_new->getStatus() == 1)
155
+ {
156
+ $categoryStore_new->updateUrlKey();
157
+ }
158
+ else
159
+ {
160
+ $categoryStore_new->deleteUrlKey();
161
+ }
162
+ }
163
+ }
164
+ else
165
+ {
166
+ $categoryStore->save();
167
+ if($categoryStore->getStoreId())
168
+ {
169
+ if($categoryStore->getStatus() == 1)
170
+ {
171
+ $categoryStore->updateUrlKey();
172
+ }
173
+ else
174
+ {
175
+ $categoryStore->deleteUrlKey();
176
+ }
177
+ }
178
+ }
179
+ }
180
+
181
+
182
+ }
app/code/local/Magestore/Featuredproduct/controllers/Faq/Model/Category.php ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Faq_Model_Category extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('faq/category');
9
+ }
10
+
11
+ public function load($id, $field=null)
12
+ {
13
+ $store_id = $this->getStoreId();
14
+
15
+ if(!$store_id)
16
+ {
17
+ return parent::load($id, $field=null);
18
+ }
19
+
20
+ $cat = Mage::getModel('faq/categorystore')->loadByCatIdStore($id,$store_id);
21
+ $this->setData($cat->getData());
22
+ $this->setId($id);
23
+
24
+ return $this;
25
+ }
26
+
27
+ public function save()
28
+ {
29
+ if(!$this->getStoreId())
30
+ return parent::save();
31
+
32
+ $cate_store = Mage::getModel('faq/categorystore')
33
+ ->loadByCatIdStore($this->getCategoryId(),$this->getStoreId());
34
+ $id = $cate_store->getId();
35
+ $cate_store->setData($this->getData())
36
+ ->setId($id)
37
+ ->save();
38
+ return $this;
39
+ }
40
+
41
+ public function getCollection()
42
+ {
43
+ $store_id = $this->getStoreId();
44
+
45
+ if(!$store_id)
46
+ return parent::getCollection();
47
+
48
+ $collection = Mage::getResourceModel('faq/categorystore_collection')
49
+ ->addFieldToFilter('store_id',$store_id)
50
+ ->addFieldToFilter("status",1)
51
+ ->setOrder("ordering","ASC")
52
+ ->setOrder("name","ASC")
53
+ ;
54
+
55
+ return $collection;
56
+ }
57
+
58
+ public function updateUrlKey()
59
+ {
60
+ $id = $this->getId();
61
+ $store_id = $this->getStoreId();
62
+ if(!$store_id)
63
+ {
64
+ $store_id = 0;
65
+ }
66
+ $url_key = $this->getData('url_key');
67
+ $url_key .= ".html";
68
+ $urlrewrite = Mage::getModel("faq/urlrewrite")->load("faq_category/".$store_id ."/".$id,"id_path");
69
+
70
+
71
+ $product_id = Mage::getResourceModel("faq/faq")->getFirstProductId();
72
+ $urlrewrite->setData("faq_category/".$store_id ."/".$id,"id_path");
73
+ $urlrewrite->setData("request_path",$this->getData('url_key'));
74
+ $urlrewrite->setData("store_id",$store_id);
75
+ $urlrewrite->setData("target_path",'faq/index/view/category_id/'. $id );
76
+ $urlrewrite->setData("product_id",$product_id);
77
+
78
+ try{
79
+
80
+ $urlrewrite->save();
81
+ } catch (Exception $e){
82
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
83
+ }
84
+
85
+ }
86
+
87
+ public function deleteUrlKey()
88
+ {
89
+ $id = $this->getId();
90
+ $store_id = $this->getStoreId();
91
+ if(!$store_id)
92
+ {
93
+ $store_id = 0;
94
+ }
95
+ $url_key = $this->getData('url_key');
96
+ $urlrewrite = Mage::getModel("faq/urlrewrite")->load("faq_category/".$store_id."/".$id,"id_path");
97
+
98
+ try{
99
+
100
+ $urlrewrite->delete();
101
+ } catch (Exception $e){
102
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
103
+ }
104
+ }
105
+
106
+ public function deleteAllUrlKey()
107
+ {
108
+ try
109
+ {
110
+ $id = $this->getId();
111
+ $stores = Mage::app()->getStores();
112
+ foreach($stores as $store)
113
+ {
114
+ $urlrewrite = Mage::getModel("faq/urlrewrite")->load("faq_category/".$store->getStoreId()."/".$id,"id_path");
115
+ $urlrewrite->delete();
116
+ }
117
+ }
118
+ catch (Exception $e){
119
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
120
+ }
121
+
122
+ }
123
+
124
+
125
+
126
+ }
app/code/local/Magestore/Featuredproduct/controllers/Faq/Model/Categorystore.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Faq_Model_Categorystore extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('faq/categorystore');
9
+ }
10
+
11
+ public function loadByStore($catid,$store_id)
12
+ {
13
+ $collection = $this->getCollection()
14
+ ->addFieldToFilter('category_id',$catid)
15
+ ->addFieldToFilter('store_id',$store_id)
16
+ ->addFieldToFilter('is_applied',array('neq'=>0))
17
+ ;
18
+ return $collection->getFirstItem();
19
+ }
20
+
21
+ public function loadByCatIdStore($catid,$store_id)
22
+ {
23
+ $collection = $this->getCollection()
24
+ ->addFieldToFilter('category_id',$catid)
25
+ ->addFieldToFilter('store_id',$store_id)
26
+ ;
27
+ return $collection->getFirstItem();
28
+ }
29
+
30
+
31
+ public function updateUrlKey()
32
+ {
33
+ $id = $this->getCategoryId();
34
+ $url_key = $this->getData('url_key');
35
+ $url_key .= ".html";
36
+ $store_id = $this->getStoreId();
37
+ if(!$store_id)
38
+ {
39
+ $store_id = 0;
40
+ }
41
+
42
+
43
+ $urlrewrite = Mage::getModel("faq/urlrewrite")->load("faq_category/".$store_id."/".$id,"id_path");
44
+
45
+
46
+
47
+
48
+ $product_id = Mage::getResourceModel("faq/faq")->getFirstProductId();
49
+ $urlrewrite->setData("id_path","faq_category/".$store_id."/".$id);
50
+ $urlrewrite->setData("request_path",$this->getData('url_key'));
51
+ $urlrewrite->setData("store_id",$store_id);
52
+ $urlrewrite->setData("target_path",'faq/index/view/category_id/'. $id );
53
+ $urlrewrite->setData("product_id",$product_id);
54
+
55
+ try{
56
+
57
+ $urlrewrite->save();
58
+ } catch (Exception $e){
59
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
60
+ }
61
+
62
+ }
63
+
64
+ public function deleteUrlKey()
65
+ {
66
+ $id = $this->getCategoryId();
67
+ $url_key = $this->getData('url_key');
68
+ $store_id = $this->getStoreId();
69
+ $urlrewrite = Mage::getModel("faq/urlrewrite")->load("faq_category/".$store_id."/".$id,"id_path");
70
+
71
+ try{
72
+ if($urlrewrite->getId())
73
+ {
74
+ $urlrewrite->delete();
75
+ }
76
+ } catch (Exception $e){
77
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
78
+ }
79
+ }
80
+ }
app/code/local/Magestore/Featuredproduct/controllers/Faq/Model/Faq.php ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Faq_Model_Faq extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('faq/faq');
9
+ }
10
+
11
+ public function load($id, $field=null)
12
+ {
13
+ $store_id = $this->getStoreId();
14
+
15
+ if(!$store_id)
16
+ {
17
+ return parent::load($id, $field=null);
18
+ }
19
+
20
+ $faq = Mage::getModel('faq/faqstore')->loadByFaqIdStore($id,$store_id);
21
+
22
+ if($faq->getIsApplied() == '0') //is applied
23
+ {
24
+ $this->setData($faq->getData());
25
+ } elseif($faq->getIsApplied() == '1' // use default value
26
+ && !Mage::getSingleton('admin/session')->isLoggedIn() // not on admin page
27
+ ){
28
+ parent::load($id, $field=null);
29
+ } else {
30
+ $this->setData($faq->getData());
31
+ }
32
+ $this->setId($id);
33
+ return $this;
34
+ }
35
+
36
+ public function save()
37
+ {
38
+ if(!$this->getStoreId())
39
+ return parent::save();
40
+
41
+ $cate_store = Mage::getModel('faq/faqstore')
42
+ ->loadByFaqIdStore($this->getFaqId(),$this->getStoreId());
43
+ $id = $cate_store->getId();
44
+ $cate_store->setData($this->getData())
45
+ ->setId($id)
46
+ ->save();
47
+ return $this;
48
+ }
49
+
50
+
51
+ public function updateUrlKey()
52
+ {
53
+ $id = $this->getId();
54
+ $store_id = $this->getStoreId();
55
+ if(!$store_id)
56
+ {
57
+ $store_id = 0;
58
+ }
59
+
60
+ $url_key = $this->getData('url_key');
61
+ $url_key .= ".html";
62
+ $urlrewrite = Mage::getModel("faq/urlrewrite")->load("faq/".$store_id."/".$id,"id_path");
63
+ $product_id = Mage::getResourceModel("faq/faq")->getFirstProductId();
64
+ $urlrewrite->setData("id_path","faq/".$store_id."/".$id);
65
+ $urlrewrite->setData("request_path",$this->getData('url_key'));
66
+ $urlrewrite->setData("target_path",'faq/index/view/id/'. $id );
67
+ $urlrewrite->setData("product_id",$product_id);
68
+ $urlrewrite->setData("store_id",$store_id);
69
+
70
+ try{
71
+ $urlrewrite->save();
72
+ } catch (Exception $e){
73
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
74
+ }
75
+
76
+ }
77
+
78
+ public function deleteUrlKey()
79
+ {
80
+ $id = $this->getId();
81
+ $store_id = $this->getStoreId();
82
+ if(!$store_id)
83
+ {
84
+ $store_id = 0;
85
+ }
86
+ $url_key = $this->getData('url_key');
87
+ $urlrewrite = Mage::getModel("faq/urlrewrite")->load("faq/".$store_id."/".$id,"id_path");
88
+
89
+ try{
90
+ $urlrewrite->delete();
91
+ } catch (Exception $e){
92
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
93
+ }
94
+ }
95
+
96
+
97
+ public function deleteAllUrlKey()
98
+ {
99
+ try
100
+ {
101
+ $id = $this->getId();
102
+ $stores = Mage::app()->getStores();
103
+ foreach($stores as $store)
104
+ {
105
+ $urlrewrite = Mage::getModel("faq/urlrewrite")->load("faq/".$store->getStoreId()."/".$id,"id_path");
106
+ $urlrewrite->delete();
107
+ }
108
+ }
109
+ catch (Exception $e){
110
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
111
+ }
112
+
113
+ }
114
+
115
+ public function getMostFrequently()
116
+ {
117
+ $store_id = $this->getStoreId();
118
+
119
+ $limit = Mage::getStoreConfig('faq/general/most_frequently_number');
120
+
121
+ if(!$store_id)
122
+ {
123
+ $collection = $this->getCollection()
124
+ ->addFieldToFilter('most_frequently',1)
125
+ ->setOrder('main_table.ordering','ASC')
126
+ ->setOrder('main_table.title','ASC')
127
+ ->setOrder('update_time','DESC')
128
+ ->setCurPage(1)
129
+ ->setPageSize($limit);
130
+ //->setLimit($limit);
131
+ } else {
132
+ $collection = Mage::getSingleton('faq/faqstore')
133
+ ->setStoreId($store_id)
134
+ ->getMostFrequently($limit);
135
+ }
136
+
137
+
138
+
139
+ return $collection;
140
+ }
141
+
142
+ public function getQuestions($category_id,$limit=0)
143
+ {
144
+ $store_id = $this->getStoreId();
145
+
146
+ if(!$store_id)
147
+ {
148
+ $collection = Mage::getResourceModel('faq/faq_collection')
149
+ ->join('category', 'category.category_id=main_table.category_id',array('category_id'=>'category_id'))
150
+ ->addFieldToFilter("main_table.status",1)
151
+ ->addFieldToFilter("category.status",1)
152
+ ->addFieldToFilter('main_table.category_id',$category_id)
153
+ ->setOrder('main_table.ordering','ASC')
154
+ ->setOrder('main_table.title','ASC')
155
+ ->setOrder('main_table.update_time','DESC')
156
+ ->setCurPage(1);
157
+ if($limit)
158
+ {
159
+ $collection->setPageSize($limit);
160
+ }
161
+ } else {
162
+ $collection = Mage::getSingleton('faq/faqstore')
163
+ ->setStoreId($store_id)
164
+ ->getQuestions($category_id,$limit);
165
+ }
166
+ return $collection;
167
+ }
168
+
169
+ public function getSearchResult($keyword)
170
+ {
171
+ $store_id = $this->getStoreId();
172
+
173
+ if(!$store_id)
174
+ {
175
+ $collection = Mage::getResourceModel('faq/faq_collection')
176
+ ->join('category', 'category.category_id=main_table.category_id',array('category_id'=>'category_id'))
177
+ ->addFieldToFilter("main_table.status",1)
178
+ ->addFieldToFilter("category.status",1)
179
+ ->setOrder('main_table.ordering','ASC')
180
+ ->setOrder('main_table.title','ASC')
181
+ ->setOrder('main_table.update_time','DESC');
182
+ $collection->getSelect()->where("main_table.title like '%".$keyword."%' or main_table.description like '%".$keyword."%'");
183
+ } else {
184
+ $collection = Mage::getModel('faq/faqstore')
185
+ ->setStoreId($store_id)
186
+ ->getSearchResult($keyword);
187
+ }
188
+ return $collection;
189
+ }
190
+ }
app/code/local/Magestore/Featuredproduct/controllers/Faq/Model/Faqstore.php ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Faq_Model_Faqstore extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('faq/faqstore');
9
+ }
10
+
11
+ public function loadByStore($faqid,$store_id)
12
+ {
13
+ $collection = $this->getCollection()
14
+ ->addFieldToFilter('faq_id',$faqid)
15
+ ->addFieldToFilter('store_id',$store_id)
16
+ ->addFieldToFilter('status',1)
17
+ ;
18
+ return $collection->getFirstItem();
19
+ }
20
+
21
+ public function loadByFaqIdStore($faqid,$store_id)
22
+ {
23
+ $collection = $this->getCollection()
24
+ ->addFieldToFilter('faq_id',$faqid)
25
+ ->addFieldToFilter('store_id',$store_id)
26
+ ;
27
+ return $collection->getFirstItem();
28
+ }
29
+
30
+ public function getJoinedCollection($status=1)
31
+ {
32
+ $store_id = $this->getStoreId();
33
+ $category_table = Mage::getResourceModel('faq/faq')
34
+ ->getTable('categorystore');
35
+
36
+
37
+ $collection = $this->getCollection();
38
+ $collection->getSelect()
39
+
40
+ ->join(array("category_table"=>$category_table),'category_table.category_id=main_table.category_id',
41
+ array('category_id'=>'category_id',
42
+ 'cat_is_applied'=>'is_applied',
43
+ 'cat_store_id'=>'store_id',
44
+ 'cat_status'=>'status',
45
+ )
46
+ );
47
+ $collection
48
+ ->addFieldToFilter('main_table.status',$status)
49
+ ->addFieldToFilter('category_table.status',$status)
50
+ ->addFieldToFilter('main_table.status',1)
51
+ ->addFieldToFilter('category_table.status',1)
52
+ ->addFieldToFilter('main_table.store_id',$store_id)
53
+ ->addFieldToFilter('category_table.store_id',$store_id)
54
+ ->setOrder('main_table.ordering','ASC')
55
+ ->setOrder('main_table.title','ASC')
56
+ ->setOrder('main_table.update_time','DESC')
57
+ ;
58
+
59
+ //$collection->printlogquery(true);die();
60
+
61
+ return $collection;
62
+ }
63
+
64
+ public function getMostFrequently($limit)
65
+ {
66
+ $collection = $this->getJoinedCollection()
67
+ ->addFieldToFilter('main_table.most_frequently',1)
68
+ ->setCurPage(1)
69
+ ->setPageSize($limit)
70
+ ;
71
+ return $this->_prepareLoadData($collection);
72
+ }
73
+
74
+ public function getQuestions($category_id,$limit = null)
75
+ {
76
+ $collection = $this->getJoinedCollection()
77
+ ->addFieldToFilter('main_table.category_id',$category_id)
78
+ ->setCurPage(1)
79
+ ;
80
+ if($limit)
81
+ {
82
+ $collection->setPageSize($limit);
83
+ }
84
+ return $this->_prepareLoadData($collection);
85
+ }
86
+
87
+ public function getSearchResult($keyword)
88
+ {
89
+ $collection = $this->getJoinedCollection()
90
+ ;
91
+
92
+ $collection->getSelect()->where("main_table.title like '%".$keyword."%' or main_table.description like '%".$keyword."%'");
93
+ //$collection->printlogquery(true);die();
94
+ return $collection;
95
+ }
96
+
97
+ protected function _prepareLoadData($collection)
98
+ {
99
+
100
+ return $collection;
101
+ }
102
+
103
+ public function updateUrlKey()
104
+ {
105
+
106
+ $id = $this->getFaqId();
107
+ $store_id = $this->getStoreId();
108
+ if(!$store_id)
109
+ {
110
+ $store_id = 0;
111
+ }
112
+
113
+ $url_key = $this->getData('url_key');
114
+ $url_key .= ".html";
115
+ $urlrewrite = Mage::getModel("faq/urlrewrite")->load("faq/".$store_id."/".$id,"id_path");
116
+ $product_id = Mage::getResourceModel("faq/faq")->getFirstProductId();
117
+ $urlrewrite->setData("id_path","faq/".$store_id."/".$id);
118
+ $urlrewrite->setData("store_id",$store_id);
119
+ $urlrewrite->setData("request_path",$this->getData('url_key'));
120
+ $urlrewrite->setData("target_path",'faq/index/view/id/'. $id );
121
+ $urlrewrite->setData("product_id",$product_id);
122
+
123
+
124
+
125
+ try{
126
+ $urlrewrite->save();
127
+ } catch (Exception $e){
128
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
129
+ }
130
+
131
+ }
132
+
133
+ public function deleteUrlKey()
134
+ {
135
+ $id = $this->getFaqId();
136
+ if(!$store_id)
137
+ {
138
+ $store_id = 0;
139
+ }
140
+ $url_key = $this->getData('url_key');
141
+ $urlrewrite = Mage::getModel("faq/urlrewrite")->load("faq/".$store_id."/".$id,"id_path");
142
+
143
+ try{
144
+ $urlrewrite->delete();
145
+ } catch (Exception $e){
146
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
147
+ }
148
+ }
149
+
150
+ }
app/code/local/Magestore/Featuredproduct/controllers/Faq/Model/Mysql4/Category.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Faq_Model_Mysql4_Category extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Note that the faq_id refers to the key field in your database table.
8
+ $this->_init('faq/category', 'category_id');
9
+ }
10
+ }
app/code/local/Magestore/Featuredproduct/controllers/Faq/Model/Mysql4/Category/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Faq_Model_Mysql4_Category_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('faq/category');
9
+ }
10
+ }
app/code/local/Magestore/Featuredproduct/controllers/Faq/Model/Mysql4/Categorystore.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Faq_Model_Mysql4_Categorystore extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Note that the faq_id refers to the key field in your database table.
8
+ $this->_init('faq/categorystore', 'category_store_id');
9
+ }
10
+ }
app/code/local/Magestore/Featuredproduct/controllers/Faq/Model/Mysql4/Categorystore/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Faq_Model_Mysql4_Categorystore_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('faq/categorystore');
9
+ }
10
+ }
app/code/local/Magestore/Featuredproduct/controllers/Faq/Model/Mysql4/Faq.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Faq_Model_Mysql4_Faq extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Note that the faq_id refers to the key field in your database table.
8
+ $this->_init('faq/faq', 'faq_id');
9
+ }
10
+
11
+ public function getFirstProductId()
12
+ {
13
+ $prefix = Mage::helper('faq')->getTablePrefix();
14
+
15
+ $select = $this->_getReadAdapter()->select()
16
+ ->from(array('eao'=> $prefix .'catalog_product_entity'),'entity_id');
17
+
18
+ $product_id = $this->_getReadAdapter()->fetchOne($select);
19
+
20
+
21
+ return $product_id;
22
+ }
23
+ }
app/code/local/Magestore/Featuredproduct/controllers/Faq/Model/Mysql4/Faq/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Faq_Model_Mysql4_Faq_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('faq/faq');
9
+ }
10
+ }
app/code/local/Magestore/Featuredproduct/controllers/Faq/Model/Mysql4/Faqstore.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Faq_Model_Mysql4_Faqstore extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('faq/faqstore', 'faq_store_id');
8
+ }
9
+
10
+ }
app/code/local/Magestore/Featuredproduct/controllers/Faq/Model/Mysql4/Faqstore/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Faq_Model_Mysql4_Faqstore_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('faq/faqstore');
9
+ }
10
+ }
app/code/local/Magestore/Featuredproduct/controllers/Faq/Model/Mysql4/Urlrewrite.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Faq_Model_Mysql4_Urlrewrite extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Note that the manufacturer_id refers to the key field in your database table.
8
+ $this->_init('faq/urlrewrite', 'url_rewrite_id');
9
+ }
10
+
11
+
12
+
13
+
14
+
15
+ }
app/code/local/Magestore/Featuredproduct/controllers/Faq/Model/Status.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Faq_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('faq')->__('Enabled'),
12
+ self::STATUS_DISABLED => Mage::helper('faq')->__('Disabled')
13
+ );
14
+ }
15
+ }
app/code/local/Magestore/Featuredproduct/controllers/Faq/Model/Urlrewrite.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Faq_Model_Urlrewrite extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('faq/urlrewrite');
9
+
10
+
11
+ }
12
+ }
app/code/local/Magestore/Featuredproduct/controllers/Faq/controllers/Adminhtml/CategoryController.php ADDED
@@ -0,0 +1,250 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Faq_Adminhtml_CategoryController extends Mage_Adminhtml_Controller_action
4
+ {
5
+
6
+ protected function _initAction() {
7
+ $this->loadLayout()
8
+ ->_setActiveMenu('faq/category')
9
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Categories Manager'), Mage::helper('adminhtml')->__('Category 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
+ $store_id = $this->getRequest()->getParam('store');
22
+ $stores = Mage::app()->getStores();
23
+ if(count($stores) == 1)
24
+ {
25
+ foreach($stores as $store)
26
+ {
27
+ $store_id = $store->getStoreId();
28
+ }
29
+ }
30
+
31
+
32
+ $model = Mage::getModel('faq/category')
33
+ ->setStoreId($store_id)
34
+ ->load($id);
35
+
36
+ //if ($model->getId() || $id == 0) {
37
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
38
+ if (!empty($data)) {
39
+ $model->setData($data);
40
+ }
41
+
42
+ Mage::register('faqcategory_data', $model);
43
+
44
+ $this->loadLayout();
45
+ $this->_setActiveMenu('faq/category');
46
+
47
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Category Manager'), Mage::helper('adminhtml')->__('Category Manager'));
48
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Category News'), Mage::helper('adminhtml')->__('Category News'));
49
+
50
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
51
+
52
+ $this->_addContent($this->getLayout()->createBlock('faq/adminhtml_category_edit'))
53
+ ->_addLeft($this->getLayout()->createBlock('faq/adminhtml_category_edit_tabs'));
54
+
55
+ $this->renderLayout();
56
+ //} else {
57
+ // Mage::getSingleton('adminhtml/session')->addError(Mage::helper('faq')->__('Item does not exist'));
58
+ // $this->_redirect('*/*/');
59
+ //}
60
+ }
61
+
62
+ public function newAction() {
63
+ $this->editAction();
64
+ }
65
+
66
+ public function saveAction() {
67
+
68
+ $store_id = $this->getRequest()->getParam('store');
69
+ $id = $this->getRequest()->getParam('id');
70
+
71
+ if ($data = $this->getRequest()->getPost()) {
72
+
73
+ if(isset($data['url_key']) && $data['url_key'])
74
+ {
75
+ $data['url_key'] = Mage::helper('faq')->normalizeUrlKey($data['url_key']);
76
+ }
77
+ elseif(isset($data['name']))
78
+ {
79
+ $data['url_key'] = Mage::helper('faq')->normalizeUrlKey($data['name']);
80
+ }
81
+
82
+ //$model = Mage::getModel('faq/category');
83
+ //$model->setData($data)
84
+ //->setStoreId($store_id)
85
+ //->setId($this->getRequest()->getParam('id'));
86
+
87
+ try {
88
+
89
+ if(!$store_id)
90
+ {
91
+ $model = Mage::getModel('faq/category');
92
+ $model->setData($data)
93
+ ->setId($this->getRequest()->getParam('id'));
94
+ $model->save();
95
+ //$model->updateUrlKey();
96
+
97
+ $id = $model->getCategoryId();
98
+ }
99
+
100
+ $categoryStore = Mage::getModel("faq/categorystore")->loadByCatIdStore($id,$store_id);
101
+ if($store_id && $categoryStore->getUrlKey() )
102
+ {
103
+ $data['url_key'] = $categoryStore->getUrlKey();
104
+ }
105
+ $categoryStore->addData($data);
106
+ $categoryStore->setCategoryId($id);
107
+
108
+ if(!$this->getRequest()->getParam('id'))
109
+ {
110
+ $stores = Mage::app()->getStores();
111
+ foreach($stores as $store)
112
+ {
113
+ $categoryStore->setId(null);
114
+ $categoryStore->setStoreId($store->getStoreId())
115
+ ->save();
116
+ $categoryStore->updateUrlKey();
117
+ }
118
+
119
+ }
120
+ else
121
+ {
122
+ $categoryStore->setStoreId($store_id);
123
+ $categoryStore->save();
124
+ }
125
+
126
+
127
+ $categoryStore->setStoreId($store_id);
128
+
129
+ Mage::helper('faq')->cloneCategoryStoreData($categoryStore);
130
+
131
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('faq')->__('Item was successfully saved'));
132
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
133
+
134
+ if ($this->getRequest()->getParam('back')) {
135
+ $this->_redirect('*/*/edit', array('id' => $id,'store'=>$store_id));
136
+ return;
137
+ }
138
+ $this->_redirect('*/*/');
139
+ return;
140
+ } catch (Exception $e) {
141
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
142
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
143
+ $this->_redirect('*/*/edit', array('id' => $id,'store'=>$store_id));
144
+ return;
145
+ }
146
+ }
147
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('faq')->__('Unable to find item to save'));
148
+ $this->_redirect('*/*/');
149
+ }
150
+
151
+ public function deleteAction() {
152
+ if( $this->getRequest()->getParam('id') > 0 ) {
153
+ try {
154
+ $model = Mage::getModel('faq/category');
155
+
156
+ $model->load($this->getRequest()->getParam('id'));
157
+ $model->deleteAllUrlKey();
158
+ $model->delete();
159
+
160
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
161
+ $this->_redirect('*/*/');
162
+ } catch (Exception $e) {
163
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
164
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
165
+ }
166
+ }
167
+ $this->_redirect('*/*/');
168
+ }
169
+
170
+ public function massDeleteAction() {
171
+ $faqIds = $this->getRequest()->getParam('category');
172
+ if(!is_array($faqIds)) {
173
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
174
+ } else {
175
+ try {
176
+ foreach ($faqIds as $faqId) {
177
+ $category = Mage::getModel('faq/category')->load($faqId);
178
+ $category->deleteAllUrlKey();
179
+ $category->delete();
180
+ }
181
+ Mage::getSingleton('adminhtml/session')->addSuccess(
182
+ Mage::helper('adminhtml')->__(
183
+ 'Total of %d record(s) were successfully deleted', count($faqIds)
184
+ )
185
+ );
186
+ } catch (Exception $e) {
187
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
188
+ }
189
+ }
190
+ $this->_redirect('*/*/index');
191
+ }
192
+
193
+ public function massStatusAction()
194
+ {
195
+ $faqIds = $this->getRequest()->getParam('category');
196
+ if(!is_array($faqIds)) {
197
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
198
+ } else {
199
+ try {
200
+ foreach ($faqIds as $faqId) {
201
+ $faq = Mage::getSingleton('faq/category')
202
+ ->load($faqId)
203
+ ->setStatus($this->getRequest()->getParam('status'))
204
+ ->setIsMassupdate(true)
205
+ ->save();
206
+ }
207
+ $this->_getSession()->addSuccess(
208
+ $this->__('Total of %d record(s) were successfully updated', count($faqIds))
209
+ );
210
+ } catch (Exception $e) {
211
+ $this->_getSession()->addError($e->getMessage());
212
+ }
213
+ }
214
+ $this->_redirect('*/*/index');
215
+ }
216
+
217
+ public function exportCsvAction()
218
+ {
219
+ $fileName = 'faqcategory.csv';
220
+ $content = $this->getLayout()->createBlock('faq/adminhtml_category_grid')
221
+ ->getCsv();
222
+
223
+ $this->_sendUploadResponse($fileName, $content);
224
+ }
225
+
226
+ public function exportXmlAction()
227
+ {
228
+ $fileName = 'faqcategory.xml';
229
+ $content = $this->getLayout()->createBlock('faq/adminhtml_category_grid')
230
+ ->getXml();
231
+
232
+ $this->_sendUploadResponse($fileName, $content);
233
+ }
234
+
235
+ protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
236
+ {
237
+ $response = $this->getResponse();
238
+ $response->setHeader('HTTP/1.1 200 OK','');
239
+ $response->setHeader('Pragma', 'public', true);
240
+ $response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
241
+ $response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
242
+ $response->setHeader('Last-Modified', date('r'));
243
+ $response->setHeader('Accept-Ranges', 'bytes');
244
+ $response->setHeader('Content-Length', strlen($content));
245
+ $response->setHeader('Content-type', $contentType);
246
+ $response->setBody($content);
247
+ $response->sendResponse();
248
+ die;
249
+ }
250
+ }
app/code/local/Magestore/Featuredproduct/controllers/Faq/controllers/Adminhtml/FaqController.php ADDED
@@ -0,0 +1,260 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magestore_Faq_Adminhtml_FaqController extends Mage_Adminhtml_Controller_action
4
+ {
5
+
6
+ protected function _initAction() {
7
+ $this->loadLayout()
8
+ ->_setActiveMenu('faq/faq')
9
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('FAQ Manager'), Mage::helper('adminhtml')->__('FAQ Manager'));
10
+
11
+ return $this;
12
+ }
13
+
14
+ public function indexAction() {
15
+ $this->_initAction()
16
+ ->renderLayout();
17
+ }
18
+
19
+ public function editAction() {
20
+
21
+ $store_id = $this->getRequest()->getParam('store');
22
+ $stores = Mage::app()->getStores();
23
+ if(count($stores) == 1)
24
+ {
25
+ foreach($stores as $store)
26
+ {
27
+ $store_id = $store->getStoreId();
28
+ }
29
+ }
30
+
31
+
32
+
33
+ $id = $this->getRequest()->getParam('id');
34
+ $model = Mage::getModel('faq/faq')
35
+ ->setStoreId($store_id)
36
+ ->load($id);
37
+
38
+ if ($model->getId() || $id == 0) {
39
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
40
+ if (!empty($data)) {
41
+ $model->setData($data);
42
+ }
43
+
44
+ Mage::register('faq_data', $model);
45
+
46
+ $this->loadLayout();
47
+ $this->_setActiveMenu('faq/faq');
48
+
49
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('FAQ Manager'), Mage::helper('adminhtml')->__('FAQ Manager'));
50
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('FAQ News'), Mage::helper('adminhtml')->__('FAQ News'));
51
+
52
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
53
+
54
+ $this->_addContent($this->getLayout()->createBlock('faq/adminhtml_faq_edit'))
55
+ ->_addLeft($this->getLayout()->createBlock('faq/adminhtml_faq_edit_tabs'));
56
+
57
+ $this->renderLayout();
58
+ } else {
59
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('faq')->__('Item does not exist'));
60
+ $this->_redirect('*/*/');
61
+ }
62
+ }
63
+
64
+ public function newAction() {
65
+ $this->editAction();
66
+ }
67
+
68
+ public function saveAction() {
69
+ $store_id = $this->getRequest()->getParam('store');
70
+ $id = $this->getRequest()->getParam('id');
71
+
72
+ if ($data = $this->getRequest()->getPost()) {
73
+
74
+ if(isset($data['url_key']) && $data['url_key'])
75
+ {
76
+ $data['url_key'] = Mage::helper('faq')->normalizeUrlKey($data['url_key']);
77
+ }
78
+ elseif(isset($data['title']))
79
+ {
80
+ $data['url_key'] = Mage::helper('faq')->normalizeUrlKey($data['title']);
81
+ }
82
+
83
+
84
+ $model = Mage::getModel('faq/faq');
85
+ $model->setData($data)
86
+ ->setStoreId($store_id)
87
+ ->setId($this->getRequest()->getParam('id'));
88
+
89
+ try {
90
+
91
+ if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) {
92
+ $model->setCreatedTime(now())
93
+ ->setUpdateTime(now());
94
+ } else {
95
+ $model->setUpdateTime(now());
96
+ }
97
+
98
+ if(!$store_id)
99
+ {
100
+ $model->save();
101
+ $id = $model->getId();
102
+ }
103
+
104
+ $faqStore = Mage::getModel("faq/faqstore")->loadByFaqIdStore($id,$store_id);
105
+
106
+ if($store_id && $faqStore->getUrlKey() )
107
+ {
108
+ $data['url_key'] = $faqStore->getUrlKey();
109
+ }
110
+ $faqStore->addData($data);
111
+ $faqStore->setFaqId($id);
112
+
113
+ if(!$this->getRequest()->getParam('id'))
114
+ {
115
+ //$model->updateUrlKey();
116
+ $stores = Mage::app()->getStores();
117
+ foreach($stores as $store)
118
+ {
119
+ $faqStore->setId(null);
120
+ $faqStore->setStoreId($store->getStoreId())
121
+ ->save();
122
+ //print_r($faqStore->getData()); die();
123
+ $faqStore->updateUrlKey();
124
+ }
125
+
126
+ //$faqStore->setId(null);
127
+ //$faqStore->setStoreId(0)
128
+ // ->save();
129
+ //$categoryStore->updateUrlKey();
130
+ }
131
+
132
+
133
+ $faqStore->setStoreId($store_id);
134
+
135
+ Mage::helper('faq')->cloneFaqStoreData($faqStore);
136
+
137
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('faq')->__('Item was successfully saved'));
138
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
139
+
140
+ if ($this->getRequest()->getParam('back')) {
141
+ $this->_redirect('*/*/edit', array('id' => $id,'store'=>$store_id));
142
+ return;
143
+ }
144
+ $this->_redirect('*/*/');
145
+ return;
146
+ } catch (Exception $e) {
147
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
148
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
149
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id'),'store'=>$store_id));
150
+ return;
151
+ }
152
+ }
153
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('faq')->__('Unable to find item to save'));
154
+ $this->_redirect('*/*/');
155
+ }
156
+
157
+
158
+
159
+
160
+
161
+ public function deleteAction() {
162
+ if( $this->getRequest()->getParam('id') > 0 ) {
163
+ try {
164
+ $model = Mage::getModel('faq/faq');
165
+
166
+ $model->load($this->getRequest()->getParam('id'));
167
+ $model->deleteAllUrlKey();
168
+ $model->delete();
169
+
170
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
171
+ $this->_redirect('*/*/');
172
+ } catch (Exception $e) {
173
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
174
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
175
+ }
176
+ }
177
+ $this->_redirect('*/*/');
178
+ }
179
+
180
+ public function massDeleteAction() {
181
+ $faqIds = $this->getRequest()->getParam('faq');
182
+ if(!is_array($faqIds)) {
183
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
184
+ } else {
185
+ try {
186
+ foreach ($faqIds as $faqId) {
187
+ $faq = Mage::getModel('faq/faq')->load($faqId);
188
+ $faq->deleteAllUrlKey();
189
+ $faq->delete();
190
+ }
191
+ Mage::getSingleton('adminhtml/session')->addSuccess(
192
+ Mage::helper('adminhtml')->__(
193
+ 'Total of %d record(s) were successfully deleted', count($faqIds)
194
+ )
195
+ );
196
+ } catch (Exception $e) {
197
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
198
+ }
199
+ }
200
+ $this->_redirect('*/*/index');
201
+ }
202
+
203
+ public function massStatusAction()
204
+ {
205
+ $faqIds = $this->getRequest()->getParam('faq');
206
+ if(!is_array($faqIds)) {
207
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
208
+ } else {
209
+ try {
210
+ foreach ($faqIds as $faqId) {
211
+ $faq = Mage::getSingleton('faq/faq')
212
+ ->load($faqId)
213
+ ->setStatus($this->getRequest()->getParam('status'))
214
+ ->setIsMassupdate(true)
215
+ ->save();
216
+ }
217
+ $this->_getSession()->addSuccess(
218
+ $this->__('Total of %d record(s) were successfully updated', count($faqIds))
219
+ );
220
+ } catch (Exception $e) {
221
+ $this->_getSession()->addError($e->getMessage());
222
+ }
223
+ }
224
+ $this->_redirect('*/*/index');
225
+ }
226
+
227
+ public function exportCsvAction()
228
+ {
229
+ $fileName = 'faq.csv';
230
+ $content = $this->getLayout()->createBlock('faq/adminhtml_faq_grid')
231
+ ->getCsv();
232
+
233
+ $this->_sendUploadResponse($fileName, $content);
234
+ }
235
+
236
+ public function exportXmlAction()
237
+ {
238
+ $fileName = 'faq.xml';
239
+ $content = $this->getLayout()->createBlock('faq/adminhtml_faq_grid')
240
+ ->getXml();
241
+
242
+ $this->_sendUploadResponse($fileName, $content);
243
+ }
244
+
245
+ protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
246
+ {
247
+ $response = $this->getResponse();
248
+ $response->setHeader('HTTP/1.1 200 OK','');
249
+ $response->setHeader('Pragma', 'public', true);
250
+ $response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
251
+ $response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
252
+ $response->setHeader('Last-Modified', date('r'));
253
+ $response->setHeader('Accept-Ranges', 'bytes');
254
+ $response->setHeader('Content-Length', strlen($content));
255
+ $response->setHeader('Content-type', $contentType);
256
+ $response->setBody($content);
257
+ $response->sendResponse();
258
+ die;
259
+ }
260
+ }
app/code/local/Magestore/Featuredproduct/controllers/Faq/controllers/IndexController.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Magestore_Faq_IndexController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ public function viewAction()
5
+ {
6
+ $store_id = Mage::app()->getStore()->getId();
7
+ $id = $this->getRequest()->getParam("id",0);
8
+ $category_id = $this->getRequest()->getParam("category_id",0);
9
+ $question = Mage::getModel("faq/faq")
10
+ ->setStoreId($store_id)
11
+ ->load($id);
12
+
13
+
14
+ if($question->getId() || $category_id)
15
+ {
16
+ if(!$category_id)
17
+ {
18
+ $category_id = $question->getCategoryId();
19
+ }
20
+ $questions = Mage::getModel("faq/faq")
21
+ ->setStoreId($store_id)
22
+ ->getQuestions($category_id);
23
+ Mage::register("questions", $questions);
24
+ Mage::register("faq_id",$question->getId());
25
+ Mage::register("category_id",$category_id);
26
+
27
+
28
+ }
29
+ else
30
+ {
31
+ Mage::register("questions", null);
32
+ }
33
+
34
+
35
+ $this->loadLayout();
36
+ $this->renderLayout();
37
+ }
38
+ public function indexAction()
39
+ {
40
+ $this->loadLayout();
41
+ $this->renderLayout();
42
+ }
43
+ }
app/code/local/Magestore/Featuredproduct/controllers/Faq/controllers/SearchController.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Magestore_Faq_SearchController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ public function resultAction()
5
+ {
6
+ $store_id = Mage::app()->getStore()->getId();
7
+ $keywords = $this->getRequest()->getParam("keyword","");
8
+ $questions = Mage::getModel("faq/faq")
9
+ ->setStoreId($store_id)
10
+ ->getSearchResult($keywords);
11
+ Mage::register("questions",$questions);
12
+ Mage::register("keywords",$keywords);
13
+
14
+ $this->loadLayout();
15
+ $this->renderLayout();
16
+ }
17
+ }
app/code/local/Magestore/Featuredproduct/controllers/Faq/etc/adminhtml.xml ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <menu>
4
+ <faq module="faq">
5
+ <title>FAQ</title>
6
+ <sort_order>71</sort_order>
7
+ <children>
8
+ <faq module="faq">
9
+ <title>Manage FAQ</title>
10
+ <sort_order>0</sort_order>
11
+ <action>faq/adminhtml_faq</action>
12
+ </faq>
13
+
14
+ <category module="faq">
15
+ <title>Manage Category</title>
16
+ <sort_order>0</sort_order>
17
+ <action>faq/adminhtml_category</action>
18
+ </category>
19
+ </children>
20
+ </faq>
21
+ </menu>
22
+ <acl>
23
+ <resources>
24
+ <all>
25
+ <title>Allow Everything</title>
26
+ </all>
27
+ <admin>
28
+ <children>
29
+ <system>
30
+ <children>
31
+ <config>
32
+ <children>
33
+ <faq translate="title">
34
+ <title>FAQ</title>
35
+ <sort_order>50</sort_order>
36
+ </faq>
37
+
38
+ </children>
39
+ </config>
40
+ </children>
41
+ </system>
42
+ <Magestore_Faq>
43
+ <title>Faq Module</title>
44
+ <sort_order>10</sort_order>
45
+ </Magestore_Faq>
46
+ </children>
47
+ </admin>
48
+ </resources>
49
+ </acl>
50
+ </config>
app/code/local/Magestore/Featuredproduct/controllers/Faq/etc/config.xml ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <default>
4
+ <faq>
5
+ <general>
6
+ <most_frequently_number>6</most_frequently_number>
7
+ <overview_number>3</overview_number>
8
+ </general>
9
+ </faq>
10
+ </default>
11
+ <modules>
12
+ <Magestore_Faq>
13
+ <version>0.1.3</version>
14
+ </Magestore_Faq>
15
+ </modules>
16
+ <frontend>
17
+ <routers>
18
+ <faq>
19
+ <use>standard</use>
20
+ <args>
21
+ <module>Magestore_Faq</module>
22
+ <frontName>faq</frontName>
23
+ </args>
24
+ </faq>
25
+ </routers>
26
+ <layout>
27
+ <updates>
28
+ <faq>
29
+ <file>faq.xml</file>
30
+ </faq>
31
+ </updates>
32
+ </layout>
33
+ <translate>
34
+ <modules>
35
+ <Magestore_Faq>
36
+ <files>
37
+ <default>Magestore_Faq.csv</default>
38
+ </files>
39
+ </Magestore_Faq>
40
+ </modules>
41
+ </translate>
42
+ </frontend>
43
+
44
+ <adminhtml>
45
+ <layout>
46
+ <updates>
47
+ <faq>
48
+ <file>faq.xml</file>
49
+ </faq>
50
+ </updates>
51
+ </layout>
52
+ </adminhtml>
53
+ <global>
54
+ <models>
55
+ <faq>
56
+ <class>Magestore_Faq_Model</class>
57
+ <resourceModel>faq_mysql4</resourceModel>
58
+ </faq>
59
+ <faq_mysql4>
60
+ <class>Magestore_Faq_Model_Mysql4</class>
61
+ <entities>
62
+ <faq>
63
+ <table>faq</table>
64
+ </faq>
65
+
66
+ <category>
67
+ <table>faq_category</table>
68
+ </category>
69
+
70
+ <faqstore>
71
+ <table>faq_store</table>
72
+ </faqstore>
73
+
74
+ <categorystore>
75
+ <table>faq_category_store</table>
76
+ </categorystore>
77
+
78
+ <urlrewrite>
79
+ <table>core_url_rewrite</table>
80
+ </urlrewrite>
81
+ </entities>
82
+ </faq_mysql4>
83
+ </models>
84
+ <resources>
85
+ <faq_setup>
86
+ <setup>
87
+ <module>Magestore_Faq</module>
88
+ </setup>
89
+ <connection>
90
+ <use>core_setup</use>
91
+ </connection>
92
+ </faq_setup>
93
+ <faq_write>
94
+ <connection>
95
+ <use>core_write</use>
96
+ </connection>
97
+ </faq_write>
98
+ <faq_read>
99
+ <connection>
100
+ <use>core_read</use>
101
+ </connection>
102
+ </faq_read>
103
+ </resources>
104
+ <blocks>
105
+ <faq>
106
+ <class>Magestore_Faq_Block</class>
107
+ </faq>
108
+ </blocks>
109
+ <helpers>
110
+ <faq>
111
+ <class>Magestore_Faq_Helper</class>
112
+ </faq>
113
+ </helpers>
114
+ </global>
115
+ </config>
app/code/local/Magestore/Featuredproduct/controllers/Faq/etc/system.xml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
  <label>FAQ Configuration</label>
1
  <frontend_type>text</frontend_type>
2
  <sort_order>1</sort_order>
3
  <show_in_default>1</show_in_default>
4
  <show_in_website>1</show_in_website>
5
  <show_in_store>0</show_in_store>
6
  <fields>
7
  <label>Number of Most Frequently Questions</label>
8
  <frontend_type>text</frontend_type>
9
  <sort_order>2</sort_order>
10
  <show_in_default>1</show_in_default>
11
  <show_in_website>1</show_in_website>
12
  <show_in_store>1</show_in_store>
13
  </most_frequently_number>
14
  <label>Number of Overview Questions</label>
15
  <frontend_type>text</frontend_type>
16
  <sort_order>3</sort_order>
17
  <show_in_default>1</show_in_default>
18
  <show_in_website>1</show_in_website>
19
  <show_in_store>1</show_in_store>
20
  </overview_number>
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <magestore translate="label">
5
+ <label>Magestore Extension</label>
6
+ <sort_order>400</sort_order>
7
+ </magestore>
8
+ </tabs>
9
+ <sections>
10
+ <faq translate="label" module="faq">
11
+ <class>separator-top</class>
12
+ <label>FAQ</label>
13
+ <tab>magestore</tab>
14
+ <frontend_type>text</frontend_type>
15
+ <sort_order>300</sort_order>
16
+ <show_in_default>1</show_in_default>
17
+ <show_in_website>1</show_in_website>
18
+ <show_in_store>1</show_in_store>
19
+ <groups>
20
  <label>FAQ Configuration</label>
21
  <frontend_type>text</frontend_type>
22
  <sort_order>1</sort_order>
23
  <show_in_default>1</show_in_default>
24
  <show_in_website>1</show_in_website>
25
  <show_in_store>0</show_in_store>
26
  <fields>
27
  <label>Number of Most Frequently Questions</label>
28
  <frontend_type>text</frontend_type>
29
  <sort_order>2</sort_order>
30
  <show_in_default>1</show_in_default>
31
  <show_in_website>1</show_in_website>
32
  <show_in_store>1</show_in_store>
33
  </most_frequently_number>
34
  <label>Number of Overview Questions</label>
35
  <frontend_type>text</frontend_type>
36
  <sort_order>3</sort_order>
37
  <show_in_default>1</show_in_default>
38
  <show_in_website>1</show_in_website>
39
  <show_in_store>1</show_in_store>
40
  </overview_number>
41
+ </groups>
42
+ </faq>
43
+ </sections>
44
+ </config>
app/code/local/Magestore/Featuredproduct/controllers/Faq/sql/faq_setup/mysql4-install-0.1.1.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+
9
+ DROP TABLE IF EXISTS {$this->getTable('faq')};
10
+ CREATE TABLE {$this->getTable('faq')} (
11
+ `faq_id` int(11) unsigned NOT NULL auto_increment,
12
+ `title` varchar(255) NOT NULL default '',
13
+ `category_id` int(11) unsigned NOT NULL default '0',
14
+ `description` text NOT NULL default '',
15
+ `status` smallint(6) NOT NULL default '0',
16
+ `created_time` datetime NULL,
17
+ `update_time` datetime NULL,
18
+ `ordering` int(11) unsigned NOT NULL default '0',
19
+ `url_key` varchar(255) NOT NULL default '',
20
+ `most_frequently` smallint(6) NOT NULL default '0',
21
+ PRIMARY KEY (`faq_id`)
22
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
23
+
24
+ DROP TABLE IF EXISTS {$this->getTable('faq_category')};
25
+ CREATE TABLE {$this->getTable('faq_category')} (
26
+ `category_id` int(11) unsigned NOT NULL auto_increment,
27
+ `name` varchar(255) NOT NULL default '',
28
+ `url_key` varchar(255) NOT NULL default '',
29
+ `description` text NOT NULL default '',
30
+ `status` smallint(6) NOT NULL default '0',
31
+ `ordering` int(11) unsigned NOT NULL default '0',
32
+ PRIMARY KEY (`category_id`)
33
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
34
+
35
+ DROP TABLE IF EXISTS {$this->getTable('faq_store')};
36
+ CREATE TABLE {$this->getTable('faq_store')} (
37
+ `faq_store_id` int(11) unsigned NOT NULL auto_increment,
38
+ `faq_id` int(11) unsigned NOT NULL,
39
+ `store_id` smallint(5) unsigned NOT NULL,
40
+ `is_applied` tinyint(1) default '0',
41
+ `title` varchar(255) default'',
42
+ `category_id` int(11) unsigned NOT NULL default '0',
43
+ `description` text NOT NULL default '',
44
+ `status` smallint(6) NOT NULL default '0',
45
+ `created_time` datetime NULL,
46
+ `update_time` datetime NULL,
47
+ `ordering` int(11) unsigned NOT NULL default '0',
48
+ `url_key` varchar(255) NOT NULL default '',
49
+ `most_frequently` smallint(6) NOT NULL default '0',
50
+ INDEX(`faq_id`),
51
+ INDEX(`store_id`),
52
+ UNIQUE(`faq_id`, `store_id`),
53
+ FOREIGN KEY (`faq_id`) REFERENCES {$this->getTable('faq')} (`faq_id`) ON DELETE CASCADE ON UPDATE CASCADE,
54
+ FOREIGN KEY (`store_id`) REFERENCES {$this->getTable('core/store')} (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE,
55
+ PRIMARY KEY (`faq_store_id`)
56
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
57
+
58
+
59
+ DROP TABLE IF EXISTS {$this->getTable('faq_category_store')};
60
+ CREATE TABLE {$this->getTable('faq_category_store')} (
61
+ `category_store_id` int(11) unsigned NOT NULL auto_increment,
62
+ `category_id` int(11) unsigned NOT NULL,
63
+ `store_id` smallint(5) unsigned NOT NULL,
64
+ `is_applied` tinyint(1) default '0',
65
+ `name` varchar(255) NOT NULL default '',
66
+ `url_key` varchar(255) NOT NULL default '',
67
+ `description` text NOT NULL default '',
68
+ `status` smallint(6) NOT NULL default '0',
69
+ `ordering` int(11) unsigned NOT NULL default '0',
70
+ INDEX(`category_id`),
71
+ INDEX(`store_id`),
72
+ UNIQUE(`category_id`, `store_id`),
73
+ FOREIGN KEY (`category_id`) REFERENCES {$this->getTable('faq_category')} (`category_id`) ON DELETE CASCADE ON UPDATE CASCADE,
74
+ FOREIGN KEY (`store_id`) REFERENCES {$this->getTable('core/store')} (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE,
75
+ PRIMARY KEY (`category_store_id`)
76
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
77
+
78
+ ");
79
+
80
+ $installer->endSetup();
app/code/local/Magestore/Featuredproduct/controllers/Faq/sql/faq_setup/mysql4-install-0.1.2.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+
9
+ DROP TABLE IF EXISTS {$this->getTable('faq')};
10
+ CREATE TABLE {$this->getTable('faq')} (
11
+ `faq_id` int(11) unsigned NOT NULL auto_increment,
12
+ `title` varchar(255) NOT NULL default '',
13
+ `category_id` int(11) unsigned NOT NULL default '0',
14
+ `description` text NOT NULL default '',
15
+ `status` smallint(6) NOT NULL default '0',
16
+ `created_time` datetime NULL,
17
+ `update_time` datetime NULL,
18
+ `ordering` int(11) unsigned NOT NULL default '0',
19
+ `url_key` varchar(255) NOT NULL default '',
20
+ `most_frequently` smallint(6) NOT NULL default '0',
21
+ PRIMARY KEY (`faq_id`)
22
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
23
+
24
+ DROP TABLE IF EXISTS {$this->getTable('faq_category')};
25
+ CREATE TABLE {$this->getTable('faq_category')} (
26
+ `category_id` int(11) unsigned NOT NULL auto_increment,
27
+ `name` varchar(255) NOT NULL default '',
28
+ `url_key` varchar(255) NOT NULL default '',
29
+ `description` text NOT NULL default '',
30
+ `status` smallint(6) NOT NULL default '0',
31
+ `ordering` int(11) unsigned NOT NULL default '0',
32
+ PRIMARY KEY (`category_id`)
33
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
34
+
35
+ DROP TABLE IF EXISTS {$this->getTable('faq_store')};
36
+ CREATE TABLE {$this->getTable('faq_store')} (
37
+ `faq_store_id` int(11) unsigned NOT NULL auto_increment,
38
+ `faq_id` int(11) unsigned NOT NULL,
39
+ `store_id` smallint(5) unsigned NOT NULL,
40
+ `is_applied` tinyint(1) default '0',
41
+ `title` varchar(255) default'',
42
+ `category_id` int(11) unsigned NOT NULL default '0',
43
+ `description` text NOT NULL default '',
44
+ `status` smallint(6) NOT NULL default '0',
45
+ `created_time` datetime NULL,
46
+ `update_time` datetime NULL,
47
+ `ordering` int(11) unsigned NOT NULL default '0',
48
+ `url_key` varchar(255) NOT NULL default '',
49
+ `most_frequently` smallint(6) NOT NULL default '0',
50
+ INDEX(`faq_id`),
51
+ INDEX(`store_id`),
52
+ UNIQUE(`faq_id`, `store_id`),
53
+ FOREIGN KEY (`faq_id`) REFERENCES {$this->getTable('faq')} (`faq_id`) ON DELETE CASCADE ON UPDATE CASCADE,
54
+ FOREIGN KEY (`store_id`) REFERENCES {$this->getTable('core/store')} (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE,
55
+ PRIMARY KEY (`faq_store_id`)
56
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
57
+
58
+
59
+ DROP TABLE IF EXISTS {$this->getTable('faq_category_store')};
60
+ CREATE TABLE {$this->getTable('faq_category_store')} (
61
+ `category_store_id` int(11) unsigned NOT NULL auto_increment,
62
+ `category_id` int(11) unsigned NOT NULL,
63
+ `store_id` smallint(5) unsigned NOT NULL,
64
+ `is_applied` tinyint(1) default '0',
65
+ `name` varchar(255) NOT NULL default '',
66
+ `url_key` varchar(255) NOT NULL default '',
67
+ `description` text NOT NULL default '',
68
+ `status` smallint(6) NOT NULL default '0',
69
+ `ordering` int(11) unsigned NOT NULL default '0',
70
+ INDEX(`category_id`),
71
+ INDEX(`store_id`),
72
+ UNIQUE(`category_id`, `store_id`),
73
+ FOREIGN KEY (`category_id`) REFERENCES {$this->getTable('faq_category')} (`category_id`) ON DELETE CASCADE ON UPDATE CASCADE,
74
+ FOREIGN KEY (`store_id`) REFERENCES {$this->getTable('core/store')} (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE,
75
+ PRIMARY KEY (`category_store_id`)
76
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
77
+
78
+ ");
79
+
80
+ $installer->endSetup();
app/code/local/Magestore/Featuredproduct/controllers/Faq/sql/faq_setup/mysql4-install-0.1.3.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+
9
+ DROP TABLE IF EXISTS {$this->getTable('faq')};
10
+ CREATE TABLE {$this->getTable('faq')} (
11
+ `faq_id` int(11) unsigned NOT NULL auto_increment,
12
+ `title` varchar(255) NOT NULL default '',
13
+ `category_id` int(11) unsigned NOT NULL default '0',
14
+ `description` text NOT NULL default '',
15
+ `status` smallint(6) NOT NULL default '0',
16
+ `created_time` datetime NULL,
17
+ `update_time` datetime NULL,
18
+ `ordering` int(11) unsigned NOT NULL default '0',
19
+ `url_key` varchar(255) NOT NULL default '',
20
+ `most_frequently` smallint(6) NOT NULL default '0',
21
+ PRIMARY KEY (`faq_id`)
22
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
23
+
24
+ DROP TABLE IF EXISTS {$this->getTable('faq_category')};
25
+ CREATE TABLE {$this->getTable('faq_category')} (
26
+ `category_id` int(11) unsigned NOT NULL auto_increment,
27
+ `name` varchar(255) NOT NULL default '',
28
+ `url_key` varchar(255) NOT NULL default '',
29
+ `description` text NOT NULL default '',
30
+ `status` smallint(6) NOT NULL default '0',
31
+ `ordering` int(11) unsigned NOT NULL default '0',
32
+ PRIMARY KEY (`category_id`)
33
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
34
+
35
+ DROP TABLE IF EXISTS {$this->getTable('faq_store')};
36
+ CREATE TABLE {$this->getTable('faq_store')} (
37
+ `faq_store_id` int(11) unsigned NOT NULL auto_increment,
38
+ `faq_id` int(11) unsigned NOT NULL,
39
+ `store_id` smallint(5) unsigned NOT NULL,
40
+ `is_applied` tinyint(1) default '0',
41
+ `title` varchar(255) default'',
42
+ `category_id` int(11) unsigned NOT NULL default '0',
43
+ `description` text NOT NULL default '',
44
+ `status` smallint(6) NOT NULL default '0',
45
+ `created_time` datetime NULL,
46
+ `update_time` datetime NULL,
47
+ `ordering` int(11) unsigned NOT NULL default '0',
48
+ `url_key` varchar(255) NOT NULL default '',
49
+ `most_frequently` smallint(6) NOT NULL default '0',
50
+ INDEX(`faq_id`),
51
+ INDEX(`store_id`),
52
+ UNIQUE(`faq_id`, `store_id`),
53
+ FOREIGN KEY (`faq_id`) REFERENCES {$this->getTable('faq')} (`faq_id`) ON DELETE CASCADE ON UPDATE CASCADE,
54
+ FOREIGN KEY (`store_id`) REFERENCES {$this->getTable('core/store')} (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE,
55
+ PRIMARY KEY (`faq_store_id`)
56
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
57
+
58
+
59
+ DROP TABLE IF EXISTS {$this->getTable('faq_category_store')};
60
+ CREATE TABLE {$this->getTable('faq_category_store')} (
61
+ `category_store_id` int(11) unsigned NOT NULL auto_increment,
62
+ `category_id` int(11) unsigned NOT NULL,
63
+ `store_id` smallint(5) unsigned NOT NULL,
64
+ `is_applied` tinyint(1) default '0',
65
+ `name` varchar(255) NOT NULL default '',
66
+ `url_key` varchar(255) NOT NULL default '',
67
+ `description` text NOT NULL default '',
68
+ `status` smallint(6) NOT NULL default '0',
69
+ `ordering` int(11) unsigned NOT NULL default '0',
70
+ INDEX(`category_id`),
71
+ INDEX(`store_id`),
72
+ UNIQUE(`category_id`, `store_id`),
73
+ FOREIGN KEY (`category_id`) REFERENCES {$this->getTable('faq_category')} (`category_id`) ON DELETE CASCADE ON UPDATE CASCADE,
74
+ FOREIGN KEY (`store_id`) REFERENCES {$this->getTable('core/store')} (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE,
75
+ PRIMARY KEY (`category_store_id`)
76
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
77
+
78
+ ");
79
+
80
+ $installer->endSetup();
app/code/local/Magestore/Featuredproduct/controllers/Faq/sql/faq_setup/mysql4-upgrade-0.1.0-0.1.1.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+
9
+ DROP TABLE IF EXISTS {$this->getTable('faq_store')};
10
+ CREATE TABLE {$this->getTable('faq_store')} (
11
+ `faq_store_id` int(11) unsigned NOT NULL auto_increment,
12
+ `faq_id` int(11) unsigned NOT NULL,
13
+ `store_id` smallint(5) unsigned NOT NULL,
14
+ `is_applied` tinyint(1) default '0',
15
+ `title` varchar(255) default'',
16
+ `category_id` int(11) unsigned NOT NULL default '0',
17
+ `description` text NOT NULL default '',
18
+ `status` smallint(6) NOT NULL default '0',
19
+ `created_time` datetime NULL,
20
+ `update_time` datetime NULL,
21
+ `ordering` int(11) unsigned NOT NULL default '0',
22
+ `url_key` varchar(255) NOT NULL default '',
23
+ `most_frequently` smallint(6) NOT NULL default '0',
24
+ INDEX(`faq_id`),
25
+ INDEX(`store_id`),
26
+ UNIQUE(`faq_id`, `store_id`),
27
+ FOREIGN KEY (`faq_id`) REFERENCES {$this->getTable('faq')} (`faq_id`) ON DELETE CASCADE ON UPDATE CASCADE,
28
+ FOREIGN KEY (`store_id`) REFERENCES {$this->getTable('core/store')} (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE,
29
+ PRIMARY KEY (`faq_store_id`)
30
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
31
+
32
+
33
+ DROP TABLE IF EXISTS {$this->getTable('faq_category_store')};
34
+ CREATE TABLE {$this->getTable('faq_category_store')} (
35
+ `category_store_id` int(11) unsigned NOT NULL auto_increment,
36
+ `category_id` int(11) unsigned NOT NULL,
37
+ `store_id` smallint(5) unsigned NOT NULL,
38
+ `is_applied` tinyint(1) default '0',
39
+ `name` varchar(255) NOT NULL default '',
40
+ `url_key` varchar(255) NOT NULL default '',
41
+ `description` text NOT NULL default '',
42
+ `status` smallint(6) NOT NULL default '0',
43
+ `ordering` int(11) unsigned NOT NULL default '0',
44
+ INDEX(`category_id`),
45
+ INDEX(`store_id`),
46
+ UNIQUE(`category_id`, `store_id`),
47
+ FOREIGN KEY (`category_id`) REFERENCES {$this->getTable('faq_category')} (`category_id`) ON DELETE CASCADE ON UPDATE CASCADE,
48
+ FOREIGN KEY (`store_id`) REFERENCES {$this->getTable('core/store')} (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE,
49
+ PRIMARY KEY (`category_store_id`)
50
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
51
+
52
+ ");
53
+
54
+ $installer->endSetup();
app/code/local/Magestore/Featuredproduct/controllers/Faq/sql/faq_setup/mysql4-upgrade-0.1.1-0.1.2.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+
9
+ DROP TABLE IF EXISTS {$this->getTable('faq_store')};
10
+ CREATE TABLE {$this->getTable('faq_store')} (
11
+ `faq_store_id` int(11) unsigned NOT NULL auto_increment,
12
+ `faq_id` int(11) unsigned NOT NULL,
13
+ `store_id` smallint(5) unsigned NOT NULL,
14
+ `is_applied` tinyint(1) default '0',
15
+ `title` varchar(255) default'',
16
+ `category_id` int(11) unsigned NOT NULL default '0',
17
+ `description` text NOT NULL default '',
18
+ `status` smallint(6) NOT NULL default '0',
19
+ `created_time` datetime NULL,
20
+ `update_time` datetime NULL,
21
+ `ordering` int(11) unsigned NOT NULL default '0',
22
+ `url_key` varchar(255) NOT NULL default '',
23
+ `most_frequently` smallint(6) NOT NULL default '0',
24
+ INDEX(`faq_id`),
25
+ INDEX(`store_id`),
26
+ UNIQUE(`faq_id`, `store_id`),
27
+ FOREIGN KEY (`faq_id`) REFERENCES {$this->getTable('faq')} (`faq_id`) ON DELETE CASCADE ON UPDATE CASCADE,
28
+ FOREIGN KEY (`store_id`) REFERENCES {$this->getTable('core/store')} (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE,
29
+ PRIMARY KEY (`faq_store_id`)
30
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
31
+
32
+
33
+ DROP TABLE IF EXISTS {$this->getTable('faq_category_store')};
34
+ CREATE TABLE {$this->getTable('faq_category_store')} (
35
+ `category_store_id` int(11) unsigned NOT NULL auto_increment,
36
+ `category_id` int(11) unsigned NOT NULL,
37
+ `store_id` smallint(5) unsigned NOT NULL,
38
+ `is_applied` tinyint(1) default '0',
39
+ `name` varchar(255) NOT NULL default '',
40
+ `url_key` varchar(255) NOT NULL default '',
41
+ `description` text NOT NULL default '',
42
+ `status` smallint(6) NOT NULL default '0',
43
+ `ordering` int(11) unsigned NOT NULL default '0',
44
+ INDEX(`category_id`),
45
+ INDEX(`store_id`),
46
+ UNIQUE(`category_id`, `store_id`),
47
+ FOREIGN KEY (`category_id`) REFERENCES {$this->getTable('faq_category')} (`category_id`) ON DELETE CASCADE ON UPDATE CASCADE,
48
+ FOREIGN KEY (`store_id`) REFERENCES {$this->getTable('core/store')} (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE,
49
+ PRIMARY KEY (`category_store_id`)
50
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
51
+
52
+ ");
53
+
54
+ $installer->endSetup();
app/code/local/Magestore/Featuredproduct/controllers/Faq/sql/faq_setup/mysql4-upgrade-0.1.2-0.1.3.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+
9
+ DROP TABLE IF EXISTS {$this->getTable('faq_store')};
10
+ CREATE TABLE {$this->getTable('faq_store')} (
11
+ `faq_store_id` int(11) unsigned NOT NULL auto_increment,
12
+ `faq_id` int(11) unsigned NOT NULL,
13
+ `store_id` smallint(5) unsigned NOT NULL,
14
+ `is_applied` tinyint(1) default '0',
15
+ `title` varchar(255) default'',
16
+ `category_id` int(11) unsigned NOT NULL default '0',
17
+ `description` text NOT NULL default '',
18
+ `status` smallint(6) NOT NULL default '0',
19
+ `created_time` datetime NULL,
20
+ `update_time` datetime NULL,
21
+ `ordering` int(11) unsigned NOT NULL default '0',
22
+ `url_key` varchar(255) NOT NULL default '',
23
+ `most_frequently` smallint(6) NOT NULL default '0',
24
+ INDEX(`faq_id`),
25
+ INDEX(`store_id`),
26
+ UNIQUE(`faq_id`, `store_id`),
27
+ FOREIGN KEY (`faq_id`) REFERENCES {$this->getTable('faq')} (`faq_id`) ON DELETE CASCADE ON UPDATE CASCADE,
28
+ FOREIGN KEY (`store_id`) REFERENCES {$this->getTable('core/store')} (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE,
29
+ PRIMARY KEY (`faq_store_id`)
30
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
31
+
32
+
33
+ DROP TABLE IF EXISTS {$this->getTable('faq_category_store')};
34
+ CREATE TABLE {$this->getTable('faq_category_store')} (
35
+ `category_store_id` int(11) unsigned NOT NULL auto_increment,
36
+ `category_id` int(11) unsigned NOT NULL,
37
+ `store_id` smallint(5) unsigned NOT NULL,
38
+ `is_applied` tinyint(1) default '0',
39
+ `name` varchar(255) NOT NULL default '',
40
+ `url_key` varchar(255) NOT NULL default '',
41
+ `description` text NOT NULL default '',
42
+ `status` smallint(6) NOT NULL default '0',
43
+ `ordering` int(11) unsigned NOT NULL default '0',
44
+ INDEX(`category_id`),
45
+ INDEX(`store_id`),
46
+ UNIQUE(`category_id`, `store_id`),
47
+ FOREIGN KEY (`category_id`) REFERENCES {$this->getTable('faq_category')} (`category_id`) ON DELETE CASCADE ON UPDATE CASCADE,
48
+ FOREIGN KEY (`store_id`) REFERENCES {$this->getTable('core/store')} (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE,
49
+ PRIMARY KEY (`category_store_id`)
50
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
51
+
52
+ ");
53
+
54
+ $installer->endSetup();
app/code/local/Magestore/Featuredproduct/controllers/IndexController.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Magestore_Featuredproduct_IndexController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ public function indexAction()
5
+ {
6
+
7
+ /*
8
+ * Load an object by id
9
+ * Request looking like:
10
+ * http://site.com/featuredproduct?id=15
11
+ * or
12
+ * http://site.com/featuredproduct/id/15
13
+ */
14
+ /*
15
+ $featuredproduct_id = $this->getRequest()->getParam('id');
16
+
17
+ if($featuredproduct_id != null && $featuredproduct_id != '') {
18
+ $featuredproduct = Mage::getModel('featuredproduct/featuredproduct')->load($featuredproduct_id)->getData();
19
+ } else {
20
+ $featuredproduct = null;
21
+ }
22
+ */
23
+
24
+ /*
25
+ * If no param we load a the last created item
26
+ */
27
+ /*
28
+ if($featuredproduct == null) {
29
+ $resource = Mage::getSingleton('core/resource');
30
+ $read= $resource->getConnection('core_read');
31
+ $featuredproductTable = $resource->getTableName('featuredproduct');
32
+
33
+ $select = $read->select()
34
+ ->from($featuredproductTable,array('featuredproduct_id','title','content','status'))
35
+ ->where('status',1)
36
+ ->order('created_time DESC') ;
37
+
38
+ $featuredproduct = $read->fetchRow($select);
39
+ }
40
+ Mage::register('featuredproduct', $featuredproduct);
41
+ */
42
+
43
+
44
+ $this->loadLayout();
45
+ $this->renderLayout();
46
+ }
47
+ }
app/code/local/Magestore/Featuredproduct/etc/adminhtml.xml ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <menu>
4
+ <featuredproduct module="featuredproduct">
5
+ <title>Featured Product</title>
6
+ <sort_order>71</sort_order>
7
+ <children>
8
+ <managefeaturedproduct module="featuredproduct">
9
+ <title>Manage Featured Product</title>
10
+ <sort_order>0</sort_order>
11
+ <action>featuredproduct/adminhtml_featuredproduct</action>
12
+ </managefeaturedproduct>
13
+ </children>
14
+ </featuredproduct>
15
+ </menu>
16
+ <acl>
17
+ <resources>
18
+ <all>
19
+ <title>Allow Everything</title>
20
+ </all>
21
+ <admin>
22
+ <children>
23
+ <system>
24
+ <children>
25
+ <config>
26
+ <children>
27
+ <featuredproduct translate="title">
28
+ <title>Featured Product</title>
29
+ <sort_order>50</sort_order>
30
+ </featuredproduct>
31
+ </children>
32
+ </config>
33
+ </children>
34
+ </system>
35
+ <Magestore_Featuredproduct>
36
+ <title>Featuredproduct Module</title>
37
+ <sort_order>10</sort_order>
38
+ </Magestore_Featuredproduct>
39
+ </children>
40
+ </admin>
41
+ </resources>
42
+ </acl>
43
+ </config>
app/code/local/Magestore/Featuredproduct/etc/config.xml ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <default>
4
+ <featuredproduct>
5
+ <general>
6
+ <show_product_number>4</show_product_number>
7
+ <show_type>static</show_type>
8
+ <delay_time>3</delay_time>
9
+ </general>
10
+
11
+ </featuredproduct>
12
+ </default>
13
+ <modules>
14
+ <Magestore_Featuredproduct>
15
+ <version>0.1.0</version>
16
+ </Magestore_Featuredproduct>
17
+ </modules>
18
+ <frontend>
19
+ <routers>
20
+ <featuredproduct>
21
+ <use>standard</use>
22
+ <args>
23
+ <module>Magestore_Featuredproduct</module>
24
+ <frontName>featuredproduct</frontName>
25
+ </args>
26
+ </featuredproduct>
27
+ </routers>
28
+ <layout>
29
+ <updates>
30
+ <featuredproduct>
31
+ <file>featuredproduct.xml</file>
32
+ </featuredproduct>
33
+ </updates>
34
+ </layout>
35
+ </frontend>
36
+ <admin>
37
+ <routers>
38
+ <featuredproduct>
39
+ <use>admin</use>
40
+ <args>
41
+ <module>Magestore_Featuredproduct</module>
42
+ <frontName>featuredproduct</frontName>
43
+ </args>
44
+ </featuredproduct>
45
+ </routers>
46
+ </admin>
47
+ <adminhtml>
48
+
49
+ <layout>
50
+ <updates>
51
+ <featuredproduct>
52
+ <file>featuredproduct.xml</file>
53
+ </featuredproduct>
54
+ </updates>
55
+ </layout>
56
+ </adminhtml>
57
+ <global>
58
+ <models>
59
+ <featuredproduct>
60
+ <class>Magestore_Featuredproduct_Model</class>
61
+ <resourceModel>featuredproduct_mysql4</resourceModel>
62
+ </featuredproduct>
63
+ <featuredproduct_mysql4>
64
+ <class>Magestore_Featuredproduct_Model_Mysql4</class>
65
+ <entities>
66
+ <featuredproduct>
67
+ <table>catalog_product_entity</table>
68
+ </featuredproduct>
69
+ </entities>
70
+ </featuredproduct_mysql4>
71
+ </models>
72
+ <resources>
73
+ <featuredproduct_setup>
74
+ <setup>
75
+ <module>Magestore_Featuredproduct</module>
76
+ </setup>
77
+ <connection>
78
+ <use>core_setup</use>
79
+ </connection>
80
+ </featuredproduct_setup>
81
+ <featuredproduct_write>
82
+ <connection>
83
+ <use>core_write</use>
84
+ </connection>
85
+ </featuredproduct_write>
86
+ <featuredproduct_read>
87
+ <connection>
88
+ <use>core_read</use>
89
+ </connection>
90
+ </featuredproduct_read>
91
+ </resources>
92
+ <blocks>
93
+ <featuredproduct>
94
+ <class>Magestore_Featuredproduct_Block</class>
95
+ </featuredproduct>
96
+
97
+ </blocks>
98
+ <helpers>
99
+ <featuredproduct>
100
+ <class>Magestore_Featuredproduct_Helper</class>
101
+ </featuredproduct>
102
+ </helpers>
103
+ </global>
104
+ </config>
app/code/local/Magestore/Featuredproduct/etc/system.xml ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <magestore translate="label">
5
+ <label>Magestore Extension</label>
6
+ <sort_order>400</sort_order>
7
+ </magestore>
8
+ </tabs>
9
+
10
+ <sections>
11
+ <featuredproduct translate="label" module="featuredproduct">
12
+ <class>separator-top</class>
13
+ <label>Featured Product</label>
14
+ <tab>magestore</tab>
15
+ <frontend_type>text</frontend_type>
16
+ <sort_order>300</sort_order>
17
+ <show_in_default>1</show_in_default>
18
+ <show_in_website>1</show_in_website>
19
+ <show_in_store>1</show_in_store>
20
+ <groups>
21
+ <general translate="label">
22
+ <label>Featured Product Configuration</label>
23
+ <frontend_type>text</frontend_type>
24
+ <sort_order>1</sort_order>
25
+ <show_in_default>1</show_in_default>
26
+ <show_in_website>1</show_in_website>
27
+ <show_in_store>0</show_in_store>
28
+ <fields>
29
+ <show_product_number translate="label">
30
+ <label>Number of Product Show</label>
31
+ <frontend_type>text</frontend_type>
32
+ <sort_order>2</sort_order>
33
+ <show_in_default>1</show_in_default>
34
+ <show_in_website>1</show_in_website>
35
+ <show_in_store>1</show_in_store>
36
+ <comment>The number of products that show on home page or catelogy</comment>
37
+ </show_product_number>
38
+
39
+ <show_type translate="label">
40
+ <label>Show type</label>
41
+ <frontend_type>select</frontend_type>
42
+ <source_model>featuredproduct/typeshow</source_model>
43
+ <sort_order>3</sort_order>
44
+ <show_in_default>1</show_in_default>
45
+ <show_in_website>1</show_in_website>
46
+ <show_in_store>1</show_in_store>
47
+ <comment></comment>
48
+ </show_type>
49
+
50
+ <delay_time translate="label">
51
+ <label>Delay time</label>
52
+ <frontend_type>text</frontend_type>
53
+ <sort_order>4</sort_order>
54
+ <show_in_default>1</show_in_default>
55
+ <show_in_website>1</show_in_website>
56
+ <show_in_store>1</show_in_store>
57
+ <comment>The delay time of slidershow in second</comment>
58
+ </delay_time>
59
+ </fields>
60
+ </general>
61
+ </groups>
62
+ </featuredproduct>
63
+ </sections>
64
+ </config>
app/code/local/Magestore/Featuredproduct/sql/featuredproduct_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+
6
+ $installer->startSetup();
7
+
8
+
9
+ $entity_type = Mage::getSingleton("eav/entity_type")->loadByCode("catalog_product");
10
+ $entity_type_id = $entity_type->getId();
11
+ $collection = Mage::getModel("eav/entity_attribute")
12
+ ->getCollection()
13
+ ->addFieldToFilter("entity_type_id",$entity_type_id)
14
+ ->addFieldToFilter("attribute_code","fb_product");
15
+
16
+ if(!count($collection))
17
+ {
18
+
19
+ $attribute = $collection->getFirstItem();
20
+ $data = array();
21
+ $data['id'] = null;
22
+ $data['entity_type_id'] = $entity_type_id;
23
+ $data['attribute_code'] = "fb_product";
24
+ $data['backend_type'] = "int";
25
+ $data['frontend_input'] = "boolean";
26
+ $data['frontend_label'] = 'Featured Product';
27
+ $attribute->setData($data);
28
+ $attribute->save();
29
+
30
+ $resource = Mage::getSingleton('core/resource');
31
+ $read= $resource->getConnection('core_read');
32
+ $write = $resource->getConnection('core_write');
33
+
34
+ //get entity_type_id
35
+ $entity_type = Mage::getSingleton("eav/entity_type")->loadByCode("catalog_product");
36
+ $entity_type_id = $entity_type->getId();
37
+
38
+ //get attribute_set_id
39
+ $select = $read->select()
40
+ ->from($this->getTable("eav_attribute_set"),array('attribute_set_id'))
41
+ ->where("entity_type_id=?",$entity_type_id);
42
+ $attribute_sets = $read->fetchAll($select);
43
+
44
+ foreach($attribute_sets as $attribute_set) {
45
+ $attribute_set_id = $attribute_set['attribute_set_id'];
46
+ $select = $read->select()
47
+ ->from($this->getTable("eav_attribute"),array('attribute_id'))
48
+ ->where("entity_type_id=?",$entity_type_id)
49
+ ->where("attribute_code=?","fb_product");
50
+ $attribute = $read->fetchRow($select);
51
+ $attribute_id = $attribute['attribute_id'];
52
+
53
+ $select = $read->select()
54
+ ->from($this->getTable("eav_attribute_group"),array('attribute_group_id'))
55
+ ->where("attribute_set_id=?",$attribute_set_id)
56
+ ->where("attribute_group_name=?","General");
57
+ $attribute_group = $read->fetchRow($select);
58
+ $attribute_group_id = $attribute_group['attribute_group_id'];
59
+
60
+ $write->beginTransaction();
61
+ $write->insert($this->getTable("eav_entity_attribute"),array("entity_type_id"=>$entity_type_id,"attribute_set_id"=>$attribute_set_id,"attribute_group_id"=>$attribute_group_id,"attribute_id"=>$attribute_id,"sort_order"=>0));
62
+ $write->commit();
63
+ }
64
+ }
65
+
66
+
67
+ $installer->endSetup();
app/design/frontend/default/default/layout/featuredproduct.xml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ <reference name="head">
5
+ <action method="addCss"><stylesheet>css/magestore/featuredproduct.css</stylesheet></action>
6
+ </reference>
7
+ </default>
8
+ <featuredproduct_index_index>
9
+ <reference name="content">
10
+ <block type="featuredproduct/featuredproduct" name="featuredproduct" template="featuredproduct/featuredproduct.phtml" />
11
+ </reference>
12
+ </featuredproduct_index_index>
13
+ </layout>
app/design/frontend/default/default/template/featuredproduct/featuredproduct.phtml ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $mode = Mage::getStoreConfig('featuredproduct/general/show_type');
3
+ $delay_time = Mage::getStoreConfig('featuredproduct/general/delay_time') * 1000;
4
+ ?>
5
+ <?php if (($products = $this->getProductCollection())): ?>
6
+ <div id="fp" class="fp" <?php if($mode != 'static'){?>style ="height:200px;"<?php }?>>
7
+ <div id="slider" <?php if($mode == 'slider'){?>style ="margin-left:25px;"<?php }?>>
8
+ <a name="sliderbutton" onclick="prevSlider()"class="slider-button left" href="#" <?php if($mode == 'slider2'){?>style ="display:block;"<?php }?>>&#139;</a>
9
+ <div id="main-slider">
10
+ <div id="frame">
11
+ <?php $i = 0; foreach ($products->getItems() as $product): ?>
12
+ <div <?php if($mode != 'static'){?>style="width:410px; text-align:left; position:absolute; <?php if($i != 0){?>opacity:0; filter: alpha(opacity = 0); display:none;<?php }else{?> opacity:1; filter: alpha(opacity = 100); <?php } }?>" class="product-block" id="slider-<?php echo $i ?>" <?php if($mode == 'static'){?>onmouseover="showDes(<?php echo $i ?>, event)" onmouseout="hideDes()"<?php }?>>
13
+ <h4><?php echo $this->htmlEscape($product->getName()) ?></h4>
14
+ <a href="<?php echo $product->getProductUrl() ?>">
15
+ <img class="product-image" src="<?php echo $this->helper('catalog/image')->init($product, 'small_image')->resize(120, 120); ?>" <?php if($mode != 'static'){?>style ="float:left;"<?php }?>/>
16
+ </a>
17
+
18
+ <span class="product-info">
19
+ <span class="product-des" id="des-<?php echo $i ?>" <?php if($mode != 'static'){?>style="display:inline;"<?php }?>>
20
+ <?php echo substr($product->getShortDescription(), 0, 220); if(strlen($product->getShortDescription()) > 220) echo '...';?>
21
+ </span>
22
+ <?php echo $this->getPriceHtml($product, true) ?>
23
+ </span>
24
+ </div>
25
+ <?php $i++; endforeach;?>
26
+ </div>
27
+ </div>
28
+ <a name="sliderbutton" onclick="nextSlider()" class="slider-button right" href="#" <?php if($mode == 'slider2'){?>style ="display:block;"<?php }?>>&#155;</a>
29
+ </div>
30
+ <div id="popup-des"></div>
31
+ </div>
32
+ <?php endif; ?>
33
+
34
+ <script type="text/javascript">
35
+ var total = getBlocks().length;
36
+ var curIndex = 0;
37
+ var nextIndex;
38
+ var IE = document.all?true:false;
39
+
40
+ function nextSlider(){
41
+ var blocks = getBlocks();
42
+ for(var i = 0; i < blocks.length; i++){
43
+ if(blocks[i].style.opacity == 1 || (IE && blocks[i].filters.alpha.opacity == 100)){
44
+ //blocks[i].style.opacity = 0;
45
+ if(i < blocks.length -1 )
46
+ j = i + 1;
47
+ //blocks[i+1].style.opacity = 1;
48
+ else
49
+ j = 0;
50
+ //blocks[0].style.opacity = 1;
51
+ showSlider(i,j);
52
+ break;
53
+ }
54
+ }
55
+ }
56
+ function prevSlider(){
57
+ var blocks = getBlocks();
58
+ for(var i = 0; i < blocks.length; i++){
59
+ if(blocks[i].style.opacity == 1 || (IE && blocks[i].filters.alpha.opacity == 100)){
60
+ //blocks[i].style.opacity = 0;
61
+ if(i > 0)
62
+ //blocks[--i].style.opacity = 1;
63
+ j = i-1;
64
+ else
65
+ //blocks[blocks.length-1].style.opacity = 1;
66
+ j = blocks.length-1;
67
+ showSlider(i,j);
68
+ break;
69
+ }
70
+ }
71
+ }
72
+
73
+ function getBlocks(){
74
+ var tempBlocks = document.getElementById('frame').getElementsByTagName('div');
75
+ var blocks = new Array();
76
+ var j = 0;
77
+ for(var i = 0; i < tempBlocks.length; i++){
78
+ if(tempBlocks[i].parentNode == document.getElementById('frame')){
79
+ blocks[j] = tempBlocks[i];
80
+ j++;
81
+ }
82
+ }
83
+ return blocks;
84
+ }
85
+ <?php if($mode == 'slider'){ ?>
86
+ var frame = document.getElementById('frame');
87
+ var stopSlider;
88
+ frame.onmouseover = function(){
89
+ stopSlider = 1;
90
+ }
91
+ frame.onmouseout = function(){
92
+ stopSlider = 0;
93
+ }
94
+
95
+ setInterval(function (){
96
+ if(stopSlider)
97
+ return;
98
+ if(curIndex < total - 1)
99
+ nextIndex = curIndex + 1;
100
+ if(curIndex == total - 1)
101
+ nextIndex = 0;
102
+ showSlider(curIndex, nextIndex);
103
+
104
+ setTimeout(function(){
105
+ curIndex = nextIndex;
106
+ }, 3000);
107
+
108
+ }, <?php echo($delay_time); ?> )
109
+ <?php }?>
110
+ //nextSlider(curIndex, nextIndex);
111
+ function showSlider(curIndex,nextIndex){
112
+ var curSlider = document.getElementById('slider-' + curIndex);
113
+ var nextSlider = document.getElementById('slider-' + nextIndex);
114
+ var i = 1000, j = 100;
115
+
116
+ var curThread, nextThread;
117
+ var IE = document.all?true:false;
118
+ curThread = setInterval(function(){
119
+ if(i >= 0){
120
+ curSlider.style.opacity = i/1000;
121
+ if(IE)
122
+ curSlider.filters.alpha.opacity = i/10
123
+ i -= 100;
124
+ if(i == 0)
125
+ curSlider.style.display = 'none';
126
+ }
127
+ else{
128
+ if(j <= 1000){
129
+
130
+ nextSlider.style.display = 'block';
131
+ nextSlider.style.opacity = j/1000;
132
+ if(IE)
133
+ nextSlider.filters.alpha.opacity = j/10;
134
+ j += 100;
135
+
136
+ }
137
+ else{
138
+ clearInterval(curThread)
139
+ }
140
+ }
141
+
142
+ }, 100)
143
+
144
+ }
145
+
146
+ function showDes(index, e){
147
+ var popup = document.getElementById('popup-des');
148
+ var des = document.getElementById('des-'+index);
149
+ var content = des.innerHTML;
150
+ popup.innerHTML = content;
151
+ popup.style.display = 'block';
152
+
153
+ var IE = document.all?true:false;
154
+ if (!IE) document.captureEvents(Event.MOUSEMOVE)
155
+
156
+ if (IE) { // grab the x-y pos.s if browser is IE
157
+ tempX = event.clientX + document.body.scrollLeft;
158
+ tempY = event.clientY + document.body.scrollTop;
159
+ }
160
+ else { // grab the x-y pos.s if browser is NS
161
+ tempX = e.pageX;
162
+ tempY = e.pageY;
163
+ }
164
+ if (tempX < 0){tempX = 0;}
165
+ if (tempY < 0){tempY = 0;}
166
+ moveTo(popup, tempX, tempY);
167
+ }
168
+
169
+ function moveTo(popup, tempX, tempY){
170
+ popup.style.top = tempY+5+'px'
171
+ popup.style.left = tempX +5+'px'
172
+ }
173
+
174
+ function hideDes(){
175
+ var popup = document.getElementById('popup-des');
176
+ popup.style.display = 'none';
177
+ }
178
+ </script>
app/etc/modules/Magestore_Featuredproduct.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Magestore_Featuredproduct>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Magestore_Featuredproduct>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>FeaturedProduct</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.opensource.org/licenses/osl-3.0.php">http://www.opensource.org/licenses/osl-3.0.php</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Featured Product for Magento 1.4</summary>
10
+ <description>Provide a professional and easy way to show "featured product".</description>
11
+ <notes>Featured Product for magento1.4</notes>
12
+ <authors><author><name>Magestore</name><user>auto-converted</user><email>support@magestore.com</email></author></authors>
13
+ <date>2010-08-05</date>
14
+ <time>08:54:07</time>
15
+ <contents><target name="mageskin"><dir name="frontend"><dir name="default"><dir name="default"><dir name="css"><dir name="magestore"><file name="featuredproduct.css" hash="587926672eab0980a70f01778e2a583d"/></dir></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="featuredproduct.xml" hash="2eedc65567e8103c1a834e182f0dce51"/></dir><dir name="template"><dir name="featuredproduct"><file name="featuredproduct.phtml" hash="d9ccc267e92c016520ef5c21ca831b9a"/></dir></dir></dir></dir></dir></target><target name="magelocal"><dir name="Magestore"><dir name="Featuredproduct"><dir name="Block"><file name="Featuredproduct.php" hash="019ab0e14a8debf482a348a2b8cfcc70"/><dir name="Adminhtml"><file name="Featuredproduct.php" hash="656a8545b6e73d62079a2ebd54a249ad"/><dir name="Featuredproduct"><file name="Copy of Grid.php" hash="195eef54b83c193e1202d54f5193fe13"/><file name="Edit.php" hash="c9d54c11d84c437dbc8f06b5d05d6c69"/><file name="Grid.php" hash="94826e750b44e97a91f29f145547ca58"/><dir name="Edit"><file name="Form.php" hash="58adb32f608f05b2dba468c7b0527893"/><file name="Tabs.php" hash="237c088748c5b37f501ad8c19f703dde"/><dir name="Tab"><file name="Form.php" hash="753fa65374a2877c14b0159fafa9bbd1"/></dir></dir></dir></dir></dir><dir name="controllers"><file name="IndexController.php" hash="6b67cdc3363b75a162bb66f6fd64362c"/><dir name="Adminhtml"><file name="FeaturedproductController.php" hash="873067cddaf77c5b7f18aeed3adbe48d"/></dir><dir name="Faq"><dir name="Block"><file name="Category.php" hash="8c6244a358ae7f8365348199dfb86cee"/><file name="Overview.php" hash="d2591ed8019d33f3566e3aca67c57bfd"/><file name="Search.php" hash="7d6c0c7a91c82aadaa63b46a0340672b"/><file name="View.php" hash="ee4933c4dd86e9f404a3f295f0a2cadb"/><dir name="Adminhtml"><file name="Category.php" hash="eaf753008d0122d76ac533497fd568a0"/><file name="Faq.php" hash="75122aa6dd395d9aa425be63ba99b413"/><dir name="Category"><file name="Edit.php" hash="0d0a0591e880f7a71929f896b349dddc"/><file name="Grid.php" hash="c576ed9f6e91c34357054e9f15d572ea"/><dir name="Edit"><file name="Form.php" hash="e71c08fa0443c3d9692c6e0547c51e0a"/><file name="Tabs.php" hash="f9a548d48a3e9b326aaa333c06e93d34"/><dir name="Tab"><file name="Form.php" hash="8804db81e9111e34b899436d49daffa1"/></dir></dir></dir><dir name="Faq"><file name="Edit.php" hash="42539ec3166fe565c9968a8e58c03a3f"/><file name="Grid.php" hash="9e8ab73f94b96eaa4fb15c6461adc903"/><dir name="Edit"><file name="Form.php" hash="b82f1774057c6d6d47e40c25d0792dc4"/><file name="Tabs.php" hash="f6b47e466c6dee1b9f32b9b23559d0eb"/><dir name="Tab"><file name="Form.php" hash="25a981d81386f363b78ccea913f6019f"/></dir></dir></dir></dir></dir><dir name="controllers"><file name="IndexController.php" hash="dc957c2b847dda7ab5dc0850c132a8c1"/><file name="SearchController.php" hash="9060bf0f7abc547fcffda576690741cc"/><dir name="Adminhtml"><file name="CategoryController.php" hash="f193ad29ed97637dfc7935da5c5aace9"/><file name="FaqController.php" hash="3f03a9e716d9466eca7ac7b70f05595f"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="919e09ae7303d540355df15fffba9c91"/><file name="config.xml" hash="fa8389329470285027ec9546a1ab6108"/><file name="system.xml" hash="24c9beda52d9702944a328cf1e34e921"/></dir><dir name="Helper"><file name="Data.php" hash="402531f08ebc7911cd58869acbfaf35f"/></dir><dir name="Model"><file name="Category.php" hash="2d45192cf11fd5854da22ff79f7aa7d1"/><file name="Categorystore.php" hash="9d999cf7f79dcf474df5d8b39a9575a9"/><file name="Faq.php" hash="59b5b2b4f4ee01ed16486595bf9e5104"/><file name="Faqstore.php" hash="9682aa1febb30a500a1df0f1d24ad097"/><file name="Status.php" hash="640659f0a8830aea921553130633e398"/><file name="Urlrewrite.php" hash="437f2198b9ef9f57fb50c07caa2a25bc"/><dir name="Mysql4"><file name="Category.php" hash="3ba731452c12afbac0af768ffb2e2d11"/><file name="Categorystore.php" hash="6350e0400201a8e1ced06742e7a6a27e"/><file name="Faq.php" hash="dcbcbc895a7fc6064794b48b844f1625"/><file name="Faqstore.php" hash="464bd63a02e6c7275d08369164c2f8b7"/><file name="Urlrewrite.php" hash="37162978078256d42adbed7a0bfb92c8"/><dir name="Category"><file name="Collection.php" hash="15fec5a44ee4fd8b586a06540f77ec51"/></dir><dir name="Categorystore"><file name="Collection.php" hash="bb42232decbfdc871e708a1ddab35f72"/></dir><dir name="Faq"><file name="Collection.php" hash="4d9367d6b2a782fbe7a205dd10ae4c6a"/></dir><dir name="Faqstore"><file name="Collection.php" hash="1d708431f2553703e21278d2af9823db"/></dir></dir></dir><dir name="sql"><dir name="faq_setup"><file name="mysql4-install-0.1.1.php" hash="e170781759c33b5bf3283affff8d46cf"/><file name="mysql4-install-0.1.2.php" hash="e170781759c33b5bf3283affff8d46cf"/><file name="mysql4-install-0.1.3.php" hash="e170781759c33b5bf3283affff8d46cf"/><file name="mysql4-upgrade-0.1.0-0.1.1.php" hash="89cc56b07dabda6e15ed48c29b997a0b"/><file name="mysql4-upgrade-0.1.1-0.1.2.php" hash="89cc56b07dabda6e15ed48c29b997a0b"/><file name="mysql4-upgrade-0.1.2-0.1.3.php" hash="89cc56b07dabda6e15ed48c29b997a0b"/></dir></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="8e89d834028cc309805ab81c2eaefbd2"/><file name="config.xml" hash="67d24f123a741ca4db1d792272f10706"/><file name="system.xml" hash="c96219c03295d5ac654b6d114a44bcc8"/></dir><dir name="Helper"><file name="Data.php" hash="10a8107c3036344d5ffae91a9ee97256"/></dir><dir name="Model"><file name="Featuredproduct.php" hash="07aab102a969c8647db51c6961297229"/><file name="Status.php" hash="2bd6ead6e2cc84220fb34230efed8622"/><file name="Typeshow.php" hash="741bb38c511c6f4481d5e5ea4cc8be8b"/><dir name="Mysql4"><file name="Featuredproduct.php" hash="9a3726fef837d9bd45f49f54d4ef48ec"/><dir name="Featuredproduct"><file name="Collection.php" hash="91074b823af540e090f103042ed8a7ae"/></dir></dir></dir><dir name="sql"><dir name="featuredproduct_setup"><file name="mysql4-install-0.1.0.php" hash="33d394d7d31a5ae6f0f9a908fe116b7d"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Magestore_Featuredproduct.xml" hash="9672dcf79470d911f20db5f0b4d11607"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies/>
18
+ </package>
skin/frontend/default/default/css/magestore/featuredproduct.css ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #fp{
2
+ background:#FFFFFF;
3
+ display:block;
4
+ overflow:hidden;
5
+ }
6
+
7
+ #main-slider{
8
+ overflow:hidden;
9
+ }
10
+ .product-block{
11
+ display:block;
12
+ width:235px;
13
+ height:200px;
14
+ float:left;
15
+ margin-top:10px;
16
+ text-align:center;
17
+ }
18
+
19
+ .product-block h4{
20
+
21
+ }
22
+
23
+ #frame{
24
+ width:auto;
25
+ }
26
+ .product-des{
27
+ display:none;
28
+ }
29
+
30
+ .product-image{
31
+ width:120px;
32
+ height:120px;
33
+ margin-right:10px;
34
+ }
35
+ .product-info{
36
+ }
37
+ .product-price{
38
+ color:#C76200;
39
+ font-size:13px;
40
+ font-weight:bold;
41
+ display:block;
42
+ margin-top:10px;
43
+ }
44
+ #popup-des{
45
+ display:none;
46
+ background:none repeat scroll 0 0 #FFFFCC;
47
+ border:1px solid gray;
48
+ padding:5px;
49
+ position:absolute;
50
+ width:200px;
51
+ z-index:110;
52
+ }
53
+ .slider-button{
54
+ display:none;
55
+ float:left;
56
+ font-size:100px;
57
+ text-decoration:none;
58
+ color:#CCCCCC;
59
+ font-family:"Times New Roman", Times, serif;
60
+ }
61
+ .slider-button:hover{
62
+ color:#000000;
63
+ }
64
+
65
+
66
+ #slider .left{
67
+ left:5px;
68
+ margin-right:5px;
69
+ }
70
+ #slider .right{
71
+ right:5px;
72
+ }