Ifuturz_Productcomment - Version 0.1.0

Version Notes

First Product Comment Extension

Download this release

Release Info

Developer Iverve
Extension Ifuturz_Productcomment
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

Files changed (22) hide show
  1. app/code/local/Ifuturz/Productcomment/Block/Adminhtml/Productcomment.php +14 -0
  2. app/code/local/Ifuturz/Productcomment/Block/Adminhtml/Productcomment/Edit.php +49 -0
  3. app/code/local/Ifuturz/Productcomment/Block/Adminhtml/Productcomment/Edit/Form.php +19 -0
  4. app/code/local/Ifuturz/Productcomment/Block/Adminhtml/Productcomment/Edit/Tab/Form.php +27 -0
  5. app/code/local/Ifuturz/Productcomment/Block/Adminhtml/Productcomment/Edit/Tabs.php +23 -0
  6. app/code/local/Ifuturz/Productcomment/Block/Adminhtml/Productcomment/Grid.php +71 -0
  7. app/code/local/Ifuturz/Productcomment/Block/Productcomment.php +17 -0
  8. app/code/local/Ifuturz/Productcomment/Helper/Data.php +4 -0
  9. app/code/local/Ifuturz/Productcomment/Model/Mysql4/Productcomment.php +10 -0
  10. app/code/local/Ifuturz/Productcomment/Model/Mysql4/Productcomment/Collection.php +50 -0
  11. app/code/local/Ifuturz/Productcomment/Model/Productcomment.php +10 -0
  12. app/code/local/Ifuturz/Productcomment/controllers/AccountController.php +48 -0
  13. app/code/local/Ifuturz/Productcomment/controllers/Adminhtml/ProductcommentController.php +154 -0
  14. app/code/local/Ifuturz/Productcomment/controllers/IndexController.php +27 -0
  15. app/code/local/Ifuturz/Productcomment/etc/config.xml +116 -0
  16. app/code/local/Ifuturz/Productcomment/sql/productcomment_setup/mysql4-install-0.1.0.php +21 -0
  17. app/design/adminhtml/default/default/layout/productcomment.xml +8 -0
  18. app/design/adminhtml/default/default/template/productcomment/form.phtml +1 -0
  19. app/design/frontend/default/default/layout/productcomment.xml +9 -0
  20. app/design/frontend/default/default/template/productcomment/productcomment.phtml +56 -0
  21. app/etc/modules/Ifuturz_Productcomment.xml +9 -0
  22. package.xml +21 -0
app/code/local/Ifuturz/Productcomment/Block/Adminhtml/Productcomment.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ifuturz_Productcomment_Block_Adminhtml_Productcomment extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ public function __construct()
5
+ {
6
+
7
+ $this->_controller = 'adminhtml_productcomment';
8
+ $this->_blockGroup = 'productcomment';
9
+ $this->_headerText = Mage::helper('productcomment')->__('Productcomment Management');
10
+ $this->_addButtonLabel = Mage::helper('productcomment')->__('Add Productcomment');
11
+ parent::__construct();
12
+ $this->_removeButton('add');
13
+ }
14
+ }
app/code/local/Ifuturz/Productcomment/Block/Adminhtml/Productcomment/Edit.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ifuturz_Productcomment_Block_Adminhtml_Productcomment_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 = 'productcomment';
11
+ $this->_controller = 'adminhtml_productcomment';
12
+
13
+ $this->_updateButton('save', 'label', Mage::helper('productcomment')->__('Save Productcomment'));
14
+ $this->_updateButton('delete', 'label', Mage::helper('productcomment')->__('Delete Productcomment'));
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('productcomment_content') == null) {
25
+ tinyMCE.execCommand('mceAddControl', false, 'productcomment_content');
26
+ } else {
27
+ tinyMCE.execCommand('mceRemoveControl', false, 'productcomment_content');
28
+ }
29
+ }
30
+
31
+ function saveAndContinueEdit(){
32
+ editForm.submit($('edit_form').action+'back/edit/');
33
+ }
34
+ ";
35
+ }
36
+
37
+ public function getHeaderText()
38
+ {
39
+ if( Mage::registry('productcomment_data') && Mage::registry('productcomment_data')->getId() )
40
+ {
41
+ //$name=Mage::getModel('register')->getCollection()->getCountryName(Mage::registry('register_data')->getCountry());
42
+ return Mage::helper('productcomment')->__("Edit Productcomment '%s'", $this->htmlEscape(Mage::registry('productcomment_data')->getProductcommentName()));
43
+ }
44
+ else
45
+ {
46
+ return Mage::helper('productcomment')->__('Add Productcomment');
47
+ }
48
+ }
49
+ }
app/code/local/Ifuturz/Productcomment/Block/Adminhtml/Productcomment/Edit/Form.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ifuturz_Productcomment_Block_Adminhtml_Productcomment_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/Ifuturz/Productcomment/Block/Adminhtml/Productcomment/Edit/Tab/Form.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ifuturz_Productcomment_Block_Adminhtml_Productcomment_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setTemplate('productcomment/form.phtml');
9
+ }
10
+
11
+ protected function _prepareForm()
12
+ {
13
+ $form = new Varien_Data_Form();
14
+ $this->setForm($form);
15
+ $fieldset = $form->addFieldset('productcomment_form', array('legend'=>Mage::helper('productcomment')->__('Productcomment information')));
16
+
17
+
18
+ if ( Mage::getSingleton('adminhtml/session')->getproductcommentData() )
19
+ {
20
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getproductcommentData());
21
+ Mage::getSingleton('adminhtml/session')->setproductcommentData(null);
22
+ } elseif ( Mage::registry('productcomment_data') ) {
23
+ $form->setValues(Mage::registry('productcomment_data')->getData());
24
+ }
25
+ return parent::_prepareForm();
26
+ }
27
+ }
app/code/local/Ifuturz/Productcomment/Block/Adminhtml/Productcomment/Edit/Tabs.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ifuturz_Productcomment_Block_Adminhtml_Productcomment_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
3
+ {
4
+
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('productcomment_tabs');
9
+ $this->setDestElementId('edit_form');
10
+ $this->setTitle(Mage::helper('productcomment')->__('Productcomment Information'));
11
+ }
12
+
13
+ protected function _beforeToHtml()
14
+ {
15
+ $this->addTab('form_section', array(
16
+ 'label' => Mage::helper('productcomment')->__('Productcomment Information'),
17
+ 'title' => Mage::helper('productcomment')->__('Productcomment Information'),
18
+ 'content' => $this->getLayout()->createBlock('productcomment/adminhtml_productcomment_edit_tab_form')->toHtml(),
19
+ ));
20
+
21
+ return parent::_beforeToHtml();
22
+ }
23
+ }
app/code/local/Ifuturz/Productcomment/Block/Adminhtml/Productcomment/Grid.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ifuturz_Productcomment_Block_Adminhtml_Productcomment_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('productcommentGrid');
9
+ $this->setDefaultSort('productcomment_id');
10
+ $this->setDefaultDir('ASC');
11
+ $this->setSaveParametersInSession(true);
12
+ }
13
+
14
+ protected function _prepareCollection()
15
+ {
16
+ $collection = Mage::getModel('productcomment/productcomment')->getCollection();
17
+ //echo "<pre>"; print_r($collection->getData());exit;
18
+ $this->setCollection($collection);
19
+ return parent::_prepareCollection();
20
+ }
21
+
22
+ protected function _prepareColumns()
23
+ {
24
+
25
+ $this->addColumn('productcomment_id', array(
26
+ 'header' => Mage::helper('productcomment')->__('ID'),
27
+ 'align' =>'left',
28
+ 'index' => 'productcomment_id',
29
+ 'width' => '100',
30
+ ));
31
+ $this->addColumn('product_id', array(
32
+ 'header' => Mage::helper('productcomment')->__('Product ID'),
33
+ 'index' => 'product_id',
34
+ 'width' => '100',
35
+ ));
36
+ $this->addColumn('customer_id', array(
37
+ 'header' => Mage::helper('productcomment')->__('Customer ID'),
38
+ 'index' => 'customer_id',
39
+ 'width' => '100',
40
+ ));
41
+ $this->addColumn('product_comment', array(
42
+ 'header' => Mage::helper('productcomment')->__('Product Comments'),
43
+ 'index' => 'product_comment',
44
+ ));
45
+ $this->addColumn('created_at', array(
46
+ 'header' => Mage::helper('productcomment')->__('Created At'),
47
+ 'type' => 'datetime',
48
+ 'gmtoffset' => true,
49
+ 'align' => 'center',
50
+ 'width' => '150',
51
+ 'index' => 'created_at',
52
+ ));
53
+
54
+
55
+ return parent::_prepareColumns();
56
+ }
57
+
58
+ protected function _prepareMassaction()
59
+ {
60
+ $this->setMassactionIdField('productcomment_id');
61
+ $this->getMassactionBlock()->setFormFieldName('productcomment');
62
+
63
+ $this->getMassactionBlock()->addItem('delete', array(
64
+ 'label' => Mage::helper('productcomment')->__('Delete'),
65
+ 'url' => $this->getUrl('*/*/massDelete'),
66
+ 'confirm' => Mage::helper('productcomment')->__('Are you sure?')
67
+ ));
68
+ return $this;
69
+ }
70
+
71
+ }
app/code/local/Ifuturz/Productcomment/Block/Productcomment.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ifuturz_Productcomment_Block_Productcomment extends Mage_Core_Block_Template
3
+ {
4
+ public function _prepareLayout()
5
+ {
6
+ return parent::_prepareLayout();
7
+ }
8
+
9
+ public function getProductcomment()
10
+ {
11
+ if(!$this->hasData('productcomment'))
12
+ {
13
+ $this->setData('productcomment',Mage::registry('productcomment'));
14
+ }
15
+ return $this->getData('productcomment');
16
+ }
17
+ }
app/code/local/Ifuturz/Productcomment/Helper/Data.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ class Ifuturz_Productcomment_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ }
app/code/local/Ifuturz/Productcomment/Model/Mysql4/Productcomment.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ifuturz_Productcomment_Model_Mysql4_Productcomment extends Mage_Core_Model_Mysql4_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ // Note that the register_id refers to the key field in your database table.
7
+ $this->_init('productcomment/productcomment', 'productcomment_id');
8
+ }
9
+
10
+ }
app/code/local/Ifuturz/Productcomment/Model/Mysql4/Productcomment/Collection.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ifuturz_Productcomment_Model_Mysql4_Productcomment_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->_init('productcomment/productcomment');
8
+ }
9
+ public function getproductcommentArray()
10
+ {
11
+ $options = array();
12
+ $this->addOrder('applicant_group_code', 'asc');
13
+ foreach ($this as $item) {
14
+ $options[] = array(
15
+ 'value' => $item->getProductcommentId(),
16
+ 'label' => $item->getApplicantGroupCode()
17
+ );
18
+ }
19
+
20
+ return $options;
21
+ }
22
+ public function setRealGroupsFilter()
23
+ {
24
+ return $this->addFieldToFilter('productcomment_id', array('gt' => 0));
25
+ }
26
+ public function toOptionArray()
27
+ {
28
+ return parent::_toOptionArray('productcomment_id', 'applicant_group_code');
29
+ }
30
+ public function toOptionHash()
31
+ {
32
+ return parent::_toOptionHash('productcomment_id', 'applicant_group_code');
33
+ }
34
+ //for applier tooltip module
35
+ public function getAppliergroups()
36
+ {
37
+ $options = array();
38
+ $this->addOrder('applicant_group_code', 'asc');
39
+ foreach ($this as $item) {
40
+ $options[] = array(
41
+ 'value' => $item->getProductcommentId(),
42
+ 'label' => $item->getApplicantGroupCode()
43
+ );
44
+ }
45
+ if (count($options)>0) {
46
+ array_unshift($options, array('title'=>null, 'value'=>'', 'label'=>Mage::helper('productcomment')->__('-- Please select --')));
47
+ }
48
+ return $options;
49
+ }
50
+ }
app/code/local/Ifuturz/Productcomment/Model/Productcomment.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ifuturz_Productcomment_Model_Productcomment extends Mage_Core_Model_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->_init('productcomment/productcomment');
8
+ }
9
+
10
+ }
app/code/local/Ifuturz/Productcomment/controllers/AccountController.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once("Mage/Customer/controllers/AccountController.php");
3
+ class Ifuturz_Productcomment_AccountController extends Mage_Customer_AccountController
4
+ {
5
+
6
+ protected function _loginPostRedirect()
7
+ {
8
+
9
+ $session = $this->_getSession();
10
+ //echo "<pre>"; print_r($session->getData());die;
11
+ //start code by urvisha
12
+ if ($session->getProductUrl()) {
13
+ $session->setBeforeAuthUrl($session->getProductUrl());
14
+ }
15
+ //end
16
+ else if(!$session->getBeforeAuthUrl() || $session->getBeforeAuthUrl() == Mage::getBaseUrl()) {
17
+
18
+ // Set default URL to redirect customer to
19
+ $session->setBeforeAuthUrl(Mage::helper('customer')->getAccountUrl());
20
+ // Redirect customer to the last page visited after logging in
21
+ if ($session->isLoggedIn()) {
22
+ if (!Mage::getStoreConfigFlag('customer/startup/redirect_dashboard')) {
23
+ $referer = $this->getRequest()->getParam(Mage_Customer_Helper_Data::REFERER_QUERY_PARAM_NAME);
24
+ if ($referer) {
25
+ $referer = Mage::helper('core')->urlDecode($referer);
26
+ if ($this->_isUrlInternal($referer)) {
27
+ $session->setBeforeAuthUrl($referer);
28
+ }
29
+ }
30
+ } else if ($session->getAfterAuthUrl()) {
31
+ $session->setBeforeAuthUrl($session->getAfterAuthUrl(true));
32
+ }
33
+ } else {
34
+ $session->setBeforeAuthUrl(Mage::helper('customer')->getLoginUrl());
35
+ }
36
+ } else if ($session->getBeforeAuthUrl() == Mage::helper('customer')->getLogoutUrl()) {
37
+ $session->setBeforeAuthUrl(Mage::helper('customer')->getDashboardUrl());
38
+ } else {
39
+ if (!$session->getAfterAuthUrl()) {
40
+ $session->setAfterAuthUrl($session->getBeforeAuthUrl());
41
+ }
42
+ if ($session->isLoggedIn()) {
43
+ $session->setBeforeAuthUrl($session->getAfterAuthUrl(true));
44
+ }
45
+ }
46
+ $this->_redirectUrl($session->getBeforeAuthUrl(true));
47
+ }
48
+ }
app/code/local/Ifuturz/Productcomment/controllers/Adminhtml/ProductcommentController.php ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ifuturz_Productcomment_Adminhtml_ProductcommentController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+ protected function _initAction()
6
+ {
7
+ $this->loadLayout()
8
+ ->_setActiveMenu('productcomment')
9
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Add productcomment Category Management'), Mage::helper('adminhtml')->__('Add productcomment category Management'));
10
+
11
+ return $this;
12
+ }
13
+
14
+ public function indexAction()
15
+ {
16
+ $this->_initAction()
17
+ ->renderLayout();
18
+ }
19
+
20
+ public function editAction() {
21
+ $id = $this->getRequest()->getParam('id');
22
+ $model = Mage::getModel('productcomment/productcomment')->load($id);
23
+
24
+ if ($model->getId() || $id == 0) {
25
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
26
+ if (!empty($data)) {
27
+ $model->setData($data);
28
+ }
29
+ Mage::register('productcomment_data', $model);
30
+
31
+ $this->loadLayout();
32
+ $this->_setActiveMenu('productcomment');
33
+
34
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Add productcommentegory Management'), Mage::helper('adminhtml')->__('Add productcomment category Management'));
35
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Rule News'), Mage::helper('adminhtml')->__('Rule News'));
36
+
37
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
38
+
39
+ $this->_addContent($this->getLayout()->createBlock('productcomment/adminhtml_productcomment_edit'))
40
+ ->_addLeft($this->getLayout()->createBlock('productcomment/adminhtml_productcomment_edit_tabs'));
41
+
42
+ $this->renderLayout();
43
+ } else {
44
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('productcomment')->__('productcomment does not exist'));
45
+ $this->_redirect('*/*/');
46
+ }
47
+ }
48
+
49
+
50
+ public function newAction()
51
+ {
52
+ $this->_forward('edit');
53
+ }
54
+
55
+ public function saveAction()
56
+ {
57
+ if ($data = $this->getRequest()->getPost())
58
+ {
59
+
60
+ $model = Mage::getModel('productcomment/productcomment');
61
+ $model->setData($data)
62
+ ->setId($this->getRequest()->getParam('id'));
63
+
64
+ try
65
+ {
66
+ $model->save();
67
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('productcomment')->__('User was successfully saved'));
68
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
69
+
70
+ if ($this->getRequest()->getParam('back'))
71
+ {
72
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
73
+ return;
74
+ }
75
+ $this->_redirect('*/*/');
76
+ return;
77
+ }
78
+ catch (Exception $e)
79
+ {
80
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
81
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
82
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
83
+ return;
84
+ }
85
+ }
86
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('productcomment')->__('Unable to find User to save'));
87
+ $this->_redirect('*/*/');
88
+ }
89
+
90
+ public function deleteAction() {
91
+ if( $this->getRequest()->getParam('id') > 0 ) {
92
+ try {
93
+ $model = Mage::getModel('productcomment/productcomment');
94
+
95
+ $model->setId($this->getRequest()->getParam('id'))
96
+ ->delete();
97
+
98
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('productcomment was successfully deleted'));
99
+ $this->_redirect('*/*/');
100
+ } catch (Exception $e) {
101
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
102
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
103
+ }
104
+ }
105
+ $this->_redirect('*/*/');
106
+ }
107
+
108
+ public function massDeleteAction() {
109
+ $productcommentIds = $this->getRequest()->getParam('productcomment');
110
+ if(!is_array($productcommentIds)) {
111
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('productcomment')->__('Please select Productcomment(s)'));
112
+ } else {
113
+ try {
114
+ foreach ($productcommentIds as $productcommentId) {
115
+ $productcomment = Mage::getModel('productcomment/productcomment')->load($productcommentId);
116
+ $productcomment->delete();
117
+ }
118
+ Mage::getSingleton('adminhtml/session')->addSuccess(
119
+ Mage::helper('adminhtml')->__(
120
+ 'Total of %d record(s) were successfully deleted', count($productcommentIds)
121
+ )
122
+ );
123
+ } catch (Exception $e) {
124
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
125
+ }
126
+ }
127
+ $this->_redirect('*/*/index');
128
+ }
129
+
130
+ public function massStatusAction()
131
+ {
132
+ $productcommentIds = $this->getRequest()->getParam('productcomment');
133
+ if(!is_array($productcommentIds)) {
134
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Please select Productcomment(s)'));
135
+ } else {
136
+ try {
137
+ foreach ($productcommentIds as $productcommentId) {
138
+ $productcomment = Mage::getSingleton('productcomment/productcomment')
139
+ ->load($productcommentId)
140
+ ->setStatus($this->getRequest()->getParam('status'))
141
+ ->setIsMassupdate(true)
142
+ ->save();
143
+ }
144
+ $this->_getSession()->addSuccess(
145
+ $this->__('Total of %d record(s) were successfully updated', count($productcommentIds))
146
+ );
147
+ } catch (Exception $e) {
148
+ $this->_getSession()->addError($e->getMessage());
149
+ }
150
+ }
151
+ $this->_redirect('*/*/index');
152
+ }
153
+
154
+ }
app/code/local/Ifuturz/Productcomment/controllers/IndexController.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ifuturz_Productcomment_IndexController extends Mage_Core_Controller_Front_Action
3
+ {
4
+
5
+ public function indexAction()
6
+ {
7
+ $this->loadLayout()->renderLayout();
8
+ }
9
+ public function addAction()
10
+ {
11
+
12
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
13
+ $customerid = $customer['entity_id'];
14
+ $data = $this->getRequest()->getPost();
15
+
16
+ $productid = $data['productid'];
17
+ $obj = Mage::getModel('catalog/product');
18
+ $product = $obj->load($productid);
19
+ $url = $product->getProductUrl();
20
+ $comment = $data['productcommentbox'];
21
+
22
+ $write = Mage::getSingleton('core/resource')->getConnection('core_write');
23
+ $sql1 = "INSERT INTO `productcomment` (`product_id`,`customer_id`,`created_at`,`product_comment`) VALUES ('$productid','$customerid',now(),'$comment ')";
24
+ $write->query($sql1);
25
+ $this->_redirectUrl($url);
26
+ }
27
+ }
app/code/local/Ifuturz/Productcomment/etc/config.xml ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+
3
+ <config>
4
+ <modules>
5
+ <Ifuturz_Productcomment>
6
+ <version>0.1.0</version>
7
+ </Ifuturz_Productcomment>
8
+ </modules>
9
+ <frontend>
10
+ <routers>
11
+ <productcomment>
12
+ <use>standard</use>
13
+ <args>
14
+ <module>Ifuturz_Productcomment</module>
15
+ <frontName>productcomment</frontName>
16
+ </args>
17
+ </productcomment>
18
+ <customer>
19
+ <args>
20
+ <modules>
21
+ <Ifuturz_Productcomment before="Mage_Customer">Ifuturz_Productcomment</Ifuturz_Productcomment>
22
+ </modules>
23
+ </args>
24
+ </customer>
25
+ </routers>
26
+ <layout>
27
+ <updates>
28
+ <productcomment>
29
+ <file>productcomment.xml</file>
30
+ </productcomment>
31
+ </updates>
32
+ </layout>
33
+ </frontend>
34
+
35
+ <admin>
36
+ <routers>
37
+ <productcomment>
38
+ <use>admin</use>
39
+ <args>
40
+ <module>Ifuturz_Productcomment</module>
41
+ <frontName>productcomment</frontName>
42
+ </args>
43
+ </productcomment>
44
+ </routers>
45
+
46
+ </admin>
47
+ <adminhtml>
48
+ <menu>
49
+ <customer>
50
+ <children>
51
+ <productcomment translate="title" module="productcomment">
52
+ <title>Products Comment</title>
53
+ <action>productcomment/adminhtml_productcomment</action>
54
+ <sort_order>110</sort_order>
55
+ </productcomment>
56
+ </children>
57
+ </customer>
58
+ </menu>
59
+ <layout>
60
+ <updates>
61
+ <productcomment>
62
+ <file>productcomment.xml</file>
63
+ </productcomment>
64
+ </updates>
65
+ </layout>
66
+
67
+ </adminhtml>
68
+ <global>
69
+ <models>
70
+ <productcomment>
71
+ <class>Ifuturz_Productcomment_Model</class>
72
+ <resourceModel>productcomment_mysql4</resourceModel>
73
+ </productcomment>
74
+ <productcomment_mysql4>
75
+ <class>Ifuturz_Productcomment_Model_Mysql4</class>
76
+ <entities>
77
+ <productcomment>
78
+ <table>productcomment</table>
79
+ </productcomment>
80
+ </entities>
81
+ </productcomment_mysql4>
82
+ </models>
83
+ <resources>
84
+ <productcomment_setup>
85
+ <setup>
86
+ <module>Ifuturz_Productcomment</module>
87
+ </setup>
88
+ <connection>
89
+ <use>core_setup</use>
90
+ </connection>
91
+ </productcomment_setup>
92
+ <productcomment_write>
93
+ <connection>
94
+ <use>core_write</use>
95
+ </connection>
96
+ </productcomment_write>
97
+ <productcomment_read>
98
+ <connection>
99
+ <use>core_read</use>
100
+ </connection>
101
+ </productcomment_read>
102
+ </resources>
103
+ <blocks>
104
+ <productcomment>
105
+ <class>Ifuturz_Productcomment_Block</class>
106
+ </productcomment>
107
+ </blocks>
108
+ <helpers>
109
+ <productcomment>
110
+ <class>Ifuturz_Productcomment_Helper</class>
111
+ </productcomment>
112
+ </helpers>
113
+
114
+ </global>
115
+
116
+ </config>
app/code/local/Ifuturz/Productcomment/sql/productcomment_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+
4
+ $installer->startSetup();
5
+
6
+
7
+ $installer->run("
8
+
9
+ -- DROP TABLE IF EXISTS {$this->getTable('productcomment')};
10
+ CREATE TABLE {$this->getTable('productcomment')} (
11
+ `productcomment_id` int(11) unsigned NOT NULL auto_increment,
12
+ `product_id` int(11) NULL,
13
+ `customer_id` int(11) NULL,
14
+ `created_at` datetime NULL,
15
+ `product_comment` text,
16
+ PRIMARY KEY (`productcomment_id`)
17
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
18
+
19
+ ");
20
+
21
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/productcomment.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <productcomment_adminhtml_productcomment_index>
4
+ <reference name="content">
5
+ <block type="productcomment/adminhtml_productcomment" name="productcomment"/>
6
+ </reference>
7
+ </productcomment_adminhtml_productcomment_index>
8
+ </layout>
app/design/adminhtml/default/default/template/productcomment/form.phtml ADDED
@@ -0,0 +1 @@
 
1
+ <?php echo $this->getFormHtml() ?>
app/design/frontend/default/default/layout/productcomment.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <catalog_product_view>
4
+ <reference name="content">
5
+ <block type="productcomment/productcomment" as="productcommentAs" template="productcomment/productcomment.phtml" />
6
+ <!--<action method="setTemplate"><template>productcomment/productcomment.phtml</template></action>-->
7
+ </reference>
8
+ </catalog_product_view>
9
+ </layout>
app/design/frontend/default/default/template/productcomment/productcomment.phtml ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <div class="product-collateral product-view">
3
+ <div>
4
+ <?php
5
+
6
+ $product_id = Mage::registry('current_product')->getId();
7
+ $obj = Mage::getModel('catalog/product');
8
+ $product = $obj->load($product_id);
9
+ $url = $product->getProductUrl();
10
+ ?>
11
+ <?php $loginurl = $url."?login=1"?>
12
+ <?php if (Mage::getSingleton("customer/session")->isLoggedIn()): ?>
13
+ <?php Mage::getSingleton('customer/session')->unsetData('product_url',$loginurl);?>
14
+ <a onclick="document.getElementById('product_comments').focus();" style="font-size:16px; font-weight:bold; cursor:pointer"><span> <u><?php echo Mage::helper('productcomment')->__('Add Your Comment')?></u></span> </a><br /><br />
15
+ <?php else:?>
16
+
17
+
18
+ <?php Mage::getSingleton('customer/session')->setData('product_url',$loginurl) ?>
19
+ <span style='font-size:16px; font-weight:bold;'><?php echo Mage::helper('productcomment')->__("Please <a href='".Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB)."customer/account/login/'><u>login</u></a> to submit your comment")?></span>
20
+
21
+ <?php endif;?>
22
+
23
+
24
+ <?php
25
+ $productcommentCollection = Mage::getModel('productcomment/productcomment')->getCollection()->addFieldToFilter('product_id',$product_id)->setOrder('created_at','desc');
26
+ ?>
27
+
28
+ <?php
29
+ foreach($productcommentCollection as $productcomment): ?>
30
+ <div style="border-bottom:1px solid";>
31
+ <?php
32
+ $date = $productcomment['created_at'];
33
+ echo date('F d, Y ', strtotime($date))."<br/>";
34
+ echo $productcomment['product_comment'];
35
+ ?>
36
+ </div><br />
37
+
38
+ <?php endforeach;?>
39
+
40
+ <?php
41
+ if (Mage::getSingleton("customer/session")->isLoggedIn()): ?>
42
+ <form id = "productcomment" action="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);?>index.php/productcomment/index/add" method="post" >
43
+ <textarea name="productcommentbox" class="required-entry" id="product_comments" cols="86" rows="4" <?php if($_GET['___SID']=='U?login=1')://if($_GET['login']==1):?>autofocus="autofocus"<?php endif;?>></textarea>
44
+ <input type="hidden" name = "productid" value="<?php echo $product_id ?>" />
45
+ <div style="margin-top:8px;">
46
+ <input type="submit" value="Add Comment" name = "productcomment" style="height:30px; font-size:14px; background: none repeat scroll 0 0 #F18200; font-family:bold; color:white;" >
47
+ </div>
48
+ </form>
49
+ <?php endif; ?>
50
+ </div>
51
+ </div>
52
+ <script type="text/javascript">
53
+ //< ![CDATA[
54
+ var myForm= new VarienForm('productcomment', true);
55
+ //]]>
56
+ </script><br />
app/etc/modules/Ifuturz_Productcomment.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <config>
3
+ <modules>
4
+ <Ifuturz_Productcomment>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Ifuturz_Productcomment>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Ifuturz_Productcomment</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Customer can give the comments to particular product from view page using this extension</summary>
10
+ <description>&#x2022; Add comment box on product view page on frontend. Customer can add more than one comment for one product.&#xD;
11
+ &#x2022; Admin can view list of comments which customer has added for particular product. Admin can have ability to delete the product comments from admin panel.&#xD;
12
+ &#x2022; Only logged in customer can add the comments on product view page.&#xD;
13
+ &#x2022; Not logged in customer also can view the list of product comments. All comments should be listed below the comment box with date and month.</description>
14
+ <notes>First Product Comment Extension</notes>
15
+ <authors><author><name>Iverve</name><user>iverve</user><email>extension.geek@ifuturz.com</email></author></authors>
16
+ <date>2014-01-09</date>
17
+ <time>06:10:34</time>
18
+ <contents><target name="magelocal"><dir name="Ifuturz"><dir name="Productcomment"><dir name="Block"><dir name="Adminhtml"><dir name="Productcomment"><dir name="Edit"><file name="Form.php" hash="42f0391b1164759c6b8d52d111b4793a"/><dir name="Tab"><file name="Form.php" hash="2d00f84b10a51b02ed45737e26aea0c6"/></dir><file name="Tabs.php" hash="5978b718131a70a71f8ac34e3ebb3c10"/></dir><file name="Edit.php" hash="a3c19776224d8927c36d2fea5019382d"/><file name="Grid.php" hash="56435d12ce7044364820d647425a2cfd"/></dir><file name="Productcomment.php" hash="656fd8b1f289851dcde3830ef0f31a73"/></dir><file name="Productcomment.php" hash="80cda9965bfe699bb0fcbaed0e38cc3f"/></dir><dir name="Helper"><file name="Data.php" hash="493bf8d95253b3027f0e4c968eb4c30b"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Productcomment"><file name="Collection.php" hash="f18ce14c0c0984b5038a3457e0634094"/></dir><file name="Productcomment.php" hash="b44713215d612eaf508953949460d388"/></dir><file name="Productcomment.php" hash="90e6b197cc9bfd42312d4186e075051e"/></dir><dir name="controllers"><file name="AccountController.php" hash="2ee135dd1b879f61926745c1c41bdac3"/><dir name="Adminhtml"><file name="ProductcommentController.php" hash="ce4a9f62b34c21040a2deba9861e2b1e"/></dir><file name="IndexController.php" hash="4c03b78767a6601e95af1579d4455568"/></dir><dir name="etc"><file name="config.xml" hash="8f055eb03c22256846e52f524186722b"/></dir><dir name="sql"><dir name="productcomment_setup"><file name="mysql4-install-0.1.0.php" hash="138f9f3b0c9e2ef9e8db2a1de0a579ee"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="productcomment.xml" hash="4fdaf1e29305d721da4a902f5d450a48"/></dir><dir name="template"><dir name="productcomment"><file name="form.phtml" hash="0f7681757082f0200e50e87a0cf5f19a"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="productcomment.xml" hash="124315732cbf1b960a0256c4d3262bd0"/></dir><dir name="template"><dir name="productcomment"><file name="productcomment.phtml" hash="0d9e41cc27e1bc1eb72c0731f212ce31"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Ifuturz_Productcomment.xml" hash="445555826c0f16a0bd2f3b59ff918bd7"/></dir></target></contents>
19
+ <compatible/>
20
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
21
+ </package>