Dolphin_Productqa - Version 1.0.1

Version Notes

Stable Release

Download this release

Release Info

Developer Magento Core Team
Extension Dolphin_Productqa
Version 1.0.1
Comparing to
See all releases


Version 1.0.1

Files changed (30) hide show
  1. app/code/community/Dolphin/Productqa/Block/Adminhtml/Productqa.php +12 -0
  2. app/code/community/Dolphin/Productqa/Block/Adminhtml/Productqa/Edit.php +45 -0
  3. app/code/community/Dolphin/Productqa/Block/Adminhtml/Productqa/Edit/Form.php +19 -0
  4. app/code/community/Dolphin/Productqa/Block/Adminhtml/Productqa/Edit/Tab/Form.php +77 -0
  5. app/code/community/Dolphin/Productqa/Block/Adminhtml/Productqa/Edit/Tabs.php +24 -0
  6. app/code/community/Dolphin/Productqa/Block/Adminhtml/Productqa/Grid.php +151 -0
  7. app/code/community/Dolphin/Productqa/Block/Productqa.php +34 -0
  8. app/code/community/Dolphin/Productqa/Helper/Data.php +22 -0
  9. app/code/community/Dolphin/Productqa/Model/Mysql4/Productqa.php +10 -0
  10. app/code/community/Dolphin/Productqa/Model/Mysql4/Productqa/Collection.php +10 -0
  11. app/code/community/Dolphin/Productqa/Model/Productqa.php +10 -0
  12. app/code/community/Dolphin/Productqa/Model/Status.php +15 -0
  13. app/code/community/Dolphin/Productqa/controllers/Adminhtml/ProductqaController.php +205 -0
  14. app/code/community/Dolphin/Productqa/controllers/IndexController.php +101 -0
  15. app/code/community/Dolphin/Productqa/etc/config.xml +149 -0
  16. app/code/community/Dolphin/Productqa/etc/system.xml +93 -0
  17. app/code/community/Dolphin/Productqa/sql/productqa_setup/mysql4-install-1.0.1.php +27 -0
  18. app/design/adminhtml/default/default/layout/productqa.xml +8 -0
  19. app/design/frontend/default/default/layout/productqa.xml +44 -0
  20. app/design/frontend/default/default/template/productqa/productqa.phtml +47 -0
  21. app/design/frontend/default/default/template/productqa/productqa_link.phtml +2 -0
  22. app/design/frontend/default/default/template/productqa/productqaall.phtml +33 -0
  23. app/design/frontend/default/default/template/productqa/productqalist.phtml +32 -0
  24. app/etc/modules/Dolphin_Productqa.xml +9 -0
  25. app/locale/en_US/template/email/product_answer.html +10 -0
  26. app/locale/en_US/template/email/product_question.html +10 -0
  27. js/dolphin/productqa/productqa.js +21 -0
  28. package.xml +28 -0
  29. skin/frontend/default/default/dolphin/productqa/images/pop-close.png +0 -0
  30. skin/frontend/default/default/dolphin/productqa/productqa.css +3 -0
app/code/community/Dolphin/Productqa/Block/Adminhtml/Productqa.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dolphin_Productqa_Block_Adminhtml_Productqa extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ public function __construct()
5
+ {
6
+ $this->_controller = 'adminhtml_productqa';
7
+ $this->_blockGroup = 'productqa';
8
+ $this->_headerText = Mage::helper('productqa')->__('Item Manager');
9
+ $this->_addButtonLabel = Mage::helper('productqa')->__('Add Item');
10
+ parent::__construct();
11
+ }
12
+ }
app/code/community/Dolphin/Productqa/Block/Adminhtml/Productqa/Edit.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dolphin_Productqa_Block_Adminhtml_Productqa_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 = 'productqa';
11
+ $this->_controller = 'adminhtml_productqa';
12
+
13
+ $this->_updateButton('save', 'label', Mage::helper('productqa')->__('Save Item'));
14
+ $this->_updateButton('delete', 'label', Mage::helper('productqa')->__('Delete Item'));
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('productqa_content') == null) {
25
+ tinyMCE.execCommand('mceAddControl', false, 'productqa_content');
26
+ } else {
27
+ tinyMCE.execCommand('mceRemoveControl', false, 'productqa_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('productqa_data') && Mage::registry('productqa_data')->getId() ) {
40
+ return Mage::helper('productqa')->__("Edit Item '%s'", $this->htmlEscape(Mage::registry('productqa_data')->getTitle()));
41
+ } else {
42
+ return Mage::helper('productqa')->__('Add Item');
43
+ }
44
+ }
45
+ }
app/code/community/Dolphin/Productqa/Block/Adminhtml/Productqa/Edit/Form.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dolphin_Productqa_Block_Adminhtml_Productqa_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/community/Dolphin/Productqa/Block/Adminhtml/Productqa/Edit/Tab/Form.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dolphin_Productqa_Block_Adminhtml_Productqa_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('productqa_form', array('legend'=>Mage::helper('productqa')->__('Item information')));
10
+
11
+ $fieldset->addField('cutomer_email_status', 'hidden', array(
12
+ 'name' => 'cutomer_email_status',
13
+ ));
14
+
15
+ $fieldset->addField('product_sku', 'text', array(
16
+ 'label' => Mage::helper('productqa')->__('Product Sku'),
17
+ 'class' => 'required-entry',
18
+ 'required' => true,
19
+ 'name' => 'product_sku',
20
+ ));
21
+
22
+ $fieldset->addField('name', 'text', array(
23
+ 'label' => Mage::helper('productqa')->__('Customer Name'),
24
+ 'class' => 'required-entry',
25
+ 'required' => true,
26
+ 'name' => 'name',
27
+ ));
28
+
29
+ $fieldset->addField('email', 'text', array(
30
+ 'label' => Mage::helper('productqa')->__('Customer Email'),
31
+ 'class' => 'required-entry',
32
+ 'required' => true,
33
+ 'name' => 'email',
34
+ ));
35
+
36
+ $fieldset->addField('status', 'select', array(
37
+ 'label' => Mage::helper('productqa')->__('Status'),
38
+ 'name' => 'status',
39
+ 'values' => array(
40
+ array(
41
+ 'value' => 1,
42
+ 'label' => Mage::helper('productqa')->__('Enabled'),
43
+ ),
44
+ array(
45
+ 'value' => 2,
46
+ 'label' => Mage::helper('productqa')->__('Disabled'),
47
+ ),
48
+ ),
49
+ ));
50
+
51
+
52
+ $fieldset->addField('question', 'text', array(
53
+ 'label' => Mage::helper('productqa')->__('Question'),
54
+ 'class' => 'required-entry',
55
+ 'required' => true,
56
+ 'name' => 'question',
57
+ ));
58
+
59
+ $fieldset->addField('answer', 'editor', array(
60
+ 'name' => 'answer',
61
+ 'label' => Mage::helper('productqa')->__('Answer'),
62
+ 'title' => Mage::helper('productqa')->__('Answer'),
63
+ 'style' => 'width:700px; height:500px;',
64
+ 'wysiwyg' => false,
65
+ 'required' => true,
66
+ ));
67
+
68
+ if ( Mage::getSingleton('adminhtml/session')->getProductqaData() )
69
+ {
70
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getProductqaData());
71
+ Mage::getSingleton('adminhtml/session')->setProductqaData(null);
72
+ } elseif ( Mage::registry('productqa_data') ) {
73
+ $form->setValues(Mage::registry('productqa_data')->getData());
74
+ }
75
+ return parent::_prepareForm();
76
+ }
77
+ }
app/code/community/Dolphin/Productqa/Block/Adminhtml/Productqa/Edit/Tabs.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dolphin_Productqa_Block_Adminhtml_Productqa_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId('productqa_tabs');
10
+ $this->setDestElementId('edit_form');
11
+ $this->setTitle(Mage::helper('productqa')->__('Item Information'));
12
+ }
13
+
14
+ protected function _beforeToHtml()
15
+ {
16
+ $this->addTab('form_section', array(
17
+ 'label' => Mage::helper('productqa')->__('Item Information'),
18
+ 'title' => Mage::helper('productqa')->__('Item Information'),
19
+ 'content' => $this->getLayout()->createBlock('productqa/adminhtml_productqa_edit_tab_form')->toHtml(),
20
+ ));
21
+
22
+ return parent::_beforeToHtml();
23
+ }
24
+ }
app/code/community/Dolphin/Productqa/Block/Adminhtml/Productqa/Grid.php ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dolphin_Productqa_Block_Adminhtml_Productqa_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('productqaGrid');
9
+ $this->setDefaultSort('productqa_id');
10
+ $this->setDefaultDir('ASC');
11
+ $this->setSaveParametersInSession(true);
12
+ }
13
+
14
+ protected function _prepareCollection()
15
+ {
16
+ $collection = Mage::getModel('productqa/productqa')->getCollection();
17
+ $this->setCollection($collection);
18
+ return parent::_prepareCollection();
19
+ }
20
+
21
+ protected function _prepareColumns()
22
+ {
23
+ $this->addColumn('productqa_id', array(
24
+ 'header' => Mage::helper('productqa')->__('ID'),
25
+ 'align' =>'right',
26
+ 'width' => '50px',
27
+ 'index' => 'productqa_id',
28
+ ));
29
+
30
+ $this->addColumn('product_sku', array(
31
+ 'header' => Mage::helper('productqa')->__('Product Sku'),
32
+ 'align' =>'left',
33
+ 'index' => 'product_sku',
34
+ ));
35
+
36
+ $this->addColumn('name', array(
37
+ 'header' => Mage::helper('productqa')->__('Name'),
38
+ 'align' =>'left',
39
+ 'index' => 'name',
40
+ ));
41
+ $this->addColumn('email', array(
42
+ 'header' => Mage::helper('productqa')->__('Email'),
43
+ 'align' =>'left',
44
+ 'index' => 'email',
45
+ ));
46
+
47
+ $this->addColumn('question', array(
48
+ 'header' => Mage::helper('productqa')->__('Question'),
49
+ 'align' =>'left',
50
+ 'index' => 'question',
51
+ ));
52
+
53
+ $this->addColumn('answer', array(
54
+ 'header' => Mage::helper('productqa')->__('Answer'),
55
+ 'align' =>'left',
56
+ 'index' => 'answer',
57
+ ));
58
+
59
+ $this->addColumn('status', array(
60
+ 'header' => Mage::helper('productqa')->__('Status'),
61
+ 'align' => 'left',
62
+ 'width' => '80px',
63
+ 'index' => 'status',
64
+ 'type' => 'options',
65
+ 'options' => array(
66
+ 1 => 'Enabled',
67
+ 2 => 'Disabled',
68
+ ),
69
+ ));
70
+
71
+ /*
72
+ $this->addColumn('content', array(
73
+ 'header' => Mage::helper('productqa')->__('Item Content'),
74
+ 'width' => '150px',
75
+ 'index' => 'content',
76
+ ));
77
+ */
78
+
79
+ /* $this->addColumn('status', array(
80
+ 'header' => Mage::helper('productqa')->__('Status'),
81
+ 'align' => 'left',
82
+ 'width' => '80px',
83
+ 'index' => 'status',
84
+ 'type' => 'options',
85
+ 'options' => array(
86
+ 1 => 'Enabled',
87
+ 2 => 'Disabled',
88
+ ),
89
+ )); */
90
+
91
+ $this->addColumn('action',
92
+ array(
93
+ 'header' => Mage::helper('productqa')->__('Action'),
94
+ 'width' => '100',
95
+ 'type' => 'action',
96
+ 'getter' => 'getId',
97
+ 'actions' => array(
98
+ array(
99
+ 'caption' => Mage::helper('productqa')->__('Edit'),
100
+ 'url' => array('base'=> '*/*/edit'),
101
+ 'field' => 'id'
102
+ )
103
+ ),
104
+ 'filter' => false,
105
+ 'sortable' => false,
106
+ 'index' => 'stores',
107
+ 'is_system' => true,
108
+ ));
109
+
110
+ $this->addExportType('*/*/exportCsv', Mage::helper('productqa')->__('CSV'));
111
+ $this->addExportType('*/*/exportXml', Mage::helper('productqa')->__('XML'));
112
+
113
+ return parent::_prepareColumns();
114
+ }
115
+
116
+ protected function _prepareMassaction()
117
+ {
118
+ $this->setMassactionIdField('productqa_id');
119
+ $this->getMassactionBlock()->setFormFieldName('productqa');
120
+
121
+ $this->getMassactionBlock()->addItem('delete', array(
122
+ 'label' => Mage::helper('productqa')->__('Delete'),
123
+ 'url' => $this->getUrl('*/*/massDelete'),
124
+ 'confirm' => Mage::helper('productqa')->__('Are you sure?')
125
+ ));
126
+
127
+ $statuses = Mage::getSingleton('productqa/status')->getOptionArray();
128
+
129
+ array_unshift($statuses, array('label'=>'', 'value'=>''));
130
+ $this->getMassactionBlock()->addItem('status', array(
131
+ 'label'=> Mage::helper('productqa')->__('Change status'),
132
+ 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
133
+ 'additional' => array(
134
+ 'visibility' => array(
135
+ 'name' => 'status',
136
+ 'type' => 'select',
137
+ 'class' => 'required-entry',
138
+ 'label' => Mage::helper('productqa')->__('Status'),
139
+ 'values' => $statuses
140
+ )
141
+ )
142
+ ));
143
+ return $this;
144
+ }
145
+
146
+ public function getRowUrl($row)
147
+ {
148
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
149
+ }
150
+
151
+ }
app/code/community/Dolphin/Productqa/Block/Productqa.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dolphin_Productqa_Block_Productqa extends Mage_Core_Block_Template
3
+ {
4
+ public function __construct()
5
+ {
6
+ parent::__construct();
7
+ $productsku = $this->getRequest()->getParam('ps');
8
+ $collection = Mage::getModel('productqa/productqa')->getCollection()
9
+ ->addFieldToFilter('product_sku',$productsku)
10
+ ->addFieldToFilter('status',1)
11
+ ->setOrder('productqa_id', 'DESC');
12
+ $this->setCollection($collection);
13
+ }
14
+
15
+ protected function _prepareLayout()
16
+ {
17
+ parent::_prepareLayout();
18
+
19
+ $pager = $this->getLayout()->createBlock('page/html_pager', 'custom.pager');
20
+ $pager->setAvailableLimit(array(5=>5,10=>10,15=>15,20=>20,25=>25,'all'=>'all'));
21
+ $pager->setCollection($this->getCollection());
22
+ $this->setChild('pager', $pager);
23
+ $this->getCollection()->load();
24
+ return $this;
25
+ }
26
+
27
+ public function getPagerHtml()
28
+ {
29
+ return $this->getChildHtml('pager');
30
+ }
31
+
32
+
33
+
34
+ }
app/code/community/Dolphin/Productqa/Helper/Data.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dolphin_Productqa_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+ public function getUserName()
6
+ {
7
+ if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
8
+ return '';
9
+ }
10
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
11
+ return trim($customer->getName());
12
+ }
13
+
14
+ public function getUserEmail()
15
+ {
16
+ if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
17
+ return '';
18
+ }
19
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
20
+ return $customer->getEmail();
21
+ }
22
+ }
app/code/community/Dolphin/Productqa/Model/Mysql4/Productqa.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dolphin_Productqa_Model_Mysql4_Productqa extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Note that the productqa_id refers to the key field in your database table.
8
+ $this->_init('productqa/productqa', 'productqa_id');
9
+ }
10
+ }
app/code/community/Dolphin/Productqa/Model/Mysql4/Productqa/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dolphin_Productqa_Model_Mysql4_Productqa_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('productqa/productqa');
9
+ }
10
+ }
app/code/community/Dolphin/Productqa/Model/Productqa.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dolphin_Productqa_Model_Productqa extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('productqa/productqa');
9
+ }
10
+ }
app/code/community/Dolphin/Productqa/Model/Status.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dolphin_Productqa_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('productqa')->__('Enabled'),
12
+ self::STATUS_DISABLED => Mage::helper('productqa')->__('Disabled')
13
+ );
14
+ }
15
+ }
app/code/community/Dolphin/Productqa/controllers/Adminhtml/ProductqaController.php ADDED
@@ -0,0 +1,205 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dolphin_Productqa_Adminhtml_ProductqaController extends Mage_Adminhtml_Controller_action
4
+ {
5
+ const XML_PATH_EMAIL_RECIPIENT = 'catalog/email/recipient_email';
6
+ const XML_PATH_EMAIL_SENDER = 'catalog/email/sender_email_identity';
7
+ const XML_PATH_EMAIL2_TEMPLATE = 'catalog/email/email2_template';
8
+
9
+ protected function _initAction() {
10
+ $this->loadLayout()
11
+ ->_setActiveMenu('productqa/items')
12
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
13
+
14
+ return $this;
15
+ }
16
+
17
+ public function indexAction() {
18
+ $this->_initAction()
19
+ ->renderLayout();
20
+ }
21
+
22
+ public function editAction() {
23
+ $id = $this->getRequest()->getParam('id');
24
+ $model = Mage::getModel('productqa/productqa')->load($id);
25
+
26
+ if ($model->getId() || $id == 0) {
27
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
28
+ if (!empty($data)) {
29
+ $model->setData($data);
30
+ }
31
+
32
+ Mage::register('productqa_data', $model);
33
+
34
+ $this->loadLayout();
35
+ $this->_setActiveMenu('productqa/items');
36
+
37
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
38
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
39
+
40
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
41
+
42
+ $this->_addContent($this->getLayout()->createBlock('productqa/adminhtml_productqa_edit'))
43
+ ->_addLeft($this->getLayout()->createBlock('productqa/adminhtml_productqa_edit_tabs'));
44
+
45
+ $this->renderLayout();
46
+ } else {
47
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('productqa')->__('Item does not exist'));
48
+ $this->_redirect('*/*/');
49
+ }
50
+ }
51
+
52
+ public function newAction() {
53
+ $this->_forward('edit');
54
+ }
55
+
56
+ public function saveAction() {
57
+ if ($data = $this->getRequest()->getPost()) {
58
+
59
+ $postObject = new Varien_Object();
60
+ $postObject->setData($data);
61
+
62
+ $model = Mage::getModel('productqa/productqa');
63
+ $model->setData($data)
64
+ ->setId($this->getRequest()->getParam('id'));
65
+
66
+ try {
67
+ if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) {
68
+ $model->setCreatedTime(now())
69
+ ->setUpdateTime(now());
70
+ } else {
71
+ $model->setUpdateTime(now());
72
+ }
73
+
74
+ if($data['cutomer_email_status'] != 1){
75
+ $mailTemplate = Mage::getModel('core/email_template');
76
+ $mailTemplate->setDesignConfig(array('area' => 'frontend'))
77
+ ->setReplyTo(self::XML_PATH_EMAIL_RECIPIENT)
78
+ ->sendTransactional(
79
+ Mage::getStoreConfig(self::XML_PATH_EMAIL2_TEMPLATE),
80
+ Mage::getStoreConfig(self::XML_PATH_EMAIL_SENDER),
81
+ $data['email'],
82
+ null,
83
+ array('data' => $postObject)
84
+ );
85
+ $model->setData('cutomer_email_status',1);
86
+ }
87
+ $model->save();
88
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('productqa')->__('Item was successfully saved'));
89
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
90
+
91
+ if ($this->getRequest()->getParam('back')) {
92
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
93
+ return;
94
+ }
95
+ $this->_redirect('*/*/');
96
+ return;
97
+ } catch (Exception $e) {
98
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
99
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
100
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
101
+ return;
102
+ }
103
+ }
104
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('productqa')->__('Unable to find item to save'));
105
+ $this->_redirect('*/*/');
106
+ }
107
+
108
+ public function deleteAction() {
109
+ if( $this->getRequest()->getParam('id') > 0 ) {
110
+ try {
111
+ $model = Mage::getModel('productqa/productqa');
112
+
113
+ $model->setId($this->getRequest()->getParam('id'))
114
+ ->delete();
115
+
116
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
117
+ $this->_redirect('*/*/');
118
+ } catch (Exception $e) {
119
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
120
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
121
+ }
122
+ }
123
+ $this->_redirect('*/*/');
124
+ }
125
+
126
+ public function massDeleteAction() {
127
+ $productqaIds = $this->getRequest()->getParam('productqa');
128
+ if(!is_array($productqaIds)) {
129
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
130
+ } else {
131
+ try {
132
+ foreach ($productqaIds as $productqaId) {
133
+ $productqa = Mage::getModel('productqa/productqa')->load($productqaId);
134
+ $productqa->delete();
135
+ }
136
+ Mage::getSingleton('adminhtml/session')->addSuccess(
137
+ Mage::helper('adminhtml')->__(
138
+ 'Total of %d record(s) were successfully deleted', count($productqaIds)
139
+ )
140
+ );
141
+ } catch (Exception $e) {
142
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
143
+ }
144
+ }
145
+ $this->_redirect('*/*/index');
146
+ }
147
+
148
+ public function massStatusAction()
149
+ {
150
+ $productqaIds = $this->getRequest()->getParam('productqa');
151
+ if(!is_array($productqaIds)) {
152
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
153
+ } else {
154
+ try {
155
+ foreach ($productqaIds as $productqaId) {
156
+ $productqa = Mage::getSingleton('productqa/productqa')
157
+ ->load($productqaId)
158
+ ->setStatus($this->getRequest()->getParam('status'))
159
+ ->setIsMassupdate(true)
160
+ ->save();
161
+ }
162
+ $this->_getSession()->addSuccess(
163
+ $this->__('Total of %d record(s) were successfully updated', count($productqaIds))
164
+ );
165
+ } catch (Exception $e) {
166
+ $this->_getSession()->addError($e->getMessage());
167
+ }
168
+ }
169
+ $this->_redirect('*/*/index');
170
+ }
171
+
172
+ public function exportCsvAction()
173
+ {
174
+ $fileName = 'productqa.csv';
175
+ $content = $this->getLayout()->createBlock('productqa/adminhtml_productqa_grid')
176
+ ->getCsv();
177
+
178
+ $this->_sendUploadResponse($fileName, $content);
179
+ }
180
+
181
+ public function exportXmlAction()
182
+ {
183
+ $fileName = 'productqa.xml';
184
+ $content = $this->getLayout()->createBlock('productqa/adminhtml_productqa_grid')
185
+ ->getXml();
186
+
187
+ $this->_sendUploadResponse($fileName, $content);
188
+ }
189
+
190
+ protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
191
+ {
192
+ $response = $this->getResponse();
193
+ $response->setHeader('HTTP/1.1 200 OK','');
194
+ $response->setHeader('Pragma', 'public', true);
195
+ $response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
196
+ $response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
197
+ $response->setHeader('Last-Modified', date('r'));
198
+ $response->setHeader('Accept-Ranges', 'bytes');
199
+ $response->setHeader('Content-Length', strlen($content));
200
+ $response->setHeader('Content-type', $contentType);
201
+ $response->setBody($content);
202
+ $response->sendResponse();
203
+ die;
204
+ }
205
+ }
app/code/community/Dolphin/Productqa/controllers/IndexController.php ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dolphin_Productqa_IndexController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ const XML_PATH_EMAIL_RECIPIENT = 'catalog/email/recipient_email';
5
+ const XML_PATH_EMAIL_SENDER = 'catalog/email/sender_email_identity';
6
+ const XML_PATH_EMAIL_TEMPLATE = 'catalog/email/email_template';
7
+ const XML_PATH_ENABLED = 'catalog/productqa/enabled';
8
+
9
+ public function preDispatch()
10
+ {
11
+ parent::preDispatch();
12
+
13
+ if( !Mage::getStoreConfigFlag(self::XML_PATH_ENABLED) ) {
14
+ $this->norouteAction();
15
+ }
16
+ }
17
+
18
+ public function indexAction()
19
+ {
20
+ $this->loadLayout();
21
+ $this->renderLayout();
22
+ }
23
+ public function postAction()
24
+ {
25
+
26
+ $post = $this->getRequest()->getPost();
27
+ //print_r($post);
28
+ if ( $post ) {
29
+ $model = Mage::getSingleton('productqa/productqa')->setData($post);
30
+ }
31
+ try {
32
+ $postObject = new Varien_Object();
33
+ $postObject->setData($post);
34
+
35
+ $error = false;
36
+
37
+ if (!Zend_Validate::is(trim($post['name']) , 'NotEmpty')) {
38
+ $error = true;
39
+ }
40
+
41
+ //if (!Zend_Validate::is(trim($post['phone']) , 'NotEmpty')) {
42
+ // $error = true;
43
+ //}
44
+
45
+ if (!Zend_Validate::is(trim($post['email']), 'EmailAddress')) {
46
+ $error = true;
47
+ }
48
+
49
+ if ($error) {
50
+ throw new Exception();
51
+ }
52
+ try {
53
+ if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) {
54
+ $model->setCreatedTime(now())
55
+ ->setUpdateTime(now());
56
+ } else {
57
+ $model->setUpdateTime(now());
58
+ }
59
+ $model->save();
60
+
61
+ $mailTemplate = Mage::getModel('core/email_template');
62
+ /* @var $mailTemplate Mage_Core_Model_Email_Template */
63
+ $mailTemplate->setDesignConfig(array('area' => 'frontend'))
64
+ ->setReplyTo($post['email'])
65
+ ->sendTransactional(
66
+ Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE),
67
+ Mage::getStoreConfig(self::XML_PATH_EMAIL_SENDER),
68
+ Mage::getStoreConfig(self::XML_PATH_EMAIL_RECIPIENT),
69
+ null,
70
+ array('data' => $postObject)
71
+ );
72
+
73
+ if (!$mailTemplate->getSentSuccess()) {
74
+ throw new Exception();
75
+ }
76
+
77
+ //$translate->setTranslateInline(true);
78
+
79
+ Mage::getSingleton('core/session')->addSuccess(Mage::helper('productqa')->__('Your question submited Successfully'));
80
+ $this->_redirectUrl($post['product_url']);
81
+ return;
82
+ }catch (Exception $e) {
83
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
84
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
85
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
86
+ return;
87
+ }
88
+ } catch (Exception $e) {
89
+ $translate->setTranslateInline(true);
90
+
91
+ Mage::getSingleton('core/session')->addError(Mage::helper('productqa')->__('Unable to submit your request. Please, try again later').$e->getMessage());
92
+ $this->_redirectUrl($post['product_url']);
93
+ return;
94
+ }
95
+ }
96
+ public function viewAction()
97
+ {
98
+ $this->loadLayout();
99
+ $this->renderLayout();
100
+ }
101
+ }
app/code/community/Dolphin/Productqa/etc/config.xml ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Dolphin_Productqa>
5
+ <version>1.0.1</version>
6
+ </Dolphin_Productqa>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <productqa>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>Dolphin_Productqa</module>
14
+ <frontName>productqa</frontName>
15
+ </args>
16
+ </productqa>
17
+ </routers>
18
+ <layout>
19
+ <updates>
20
+ <productqa>
21
+ <file>productqa.xml</file>
22
+ </productqa>
23
+ </updates>
24
+ </layout>
25
+ </frontend>
26
+ <admin>
27
+ <routers>
28
+ <productqa>
29
+ <use>admin</use>
30
+ <args>
31
+ <module>Dolphin_Productqa</module>
32
+ <frontName>productqa</frontName>
33
+ </args>
34
+ </productqa>
35
+ </routers>
36
+ </admin>
37
+ <adminhtml>
38
+ <menu>
39
+ <productqa module="productqa">
40
+ <title>Productqa</title>
41
+ <sort_order>71</sort_order>
42
+ <children>
43
+ <items module="productqa">
44
+ <title>Manage Product Question</title>
45
+ <sort_order>0</sort_order>
46
+ <action>productqa/adminhtml_productqa</action>
47
+ </items>
48
+ </children>
49
+ </productqa>
50
+ </menu>
51
+ <acl>
52
+ <resources>
53
+ <all>
54
+ <title>Allow Everything</title>
55
+ </all>
56
+ <admin>
57
+ <children>
58
+ <Dolphin_Productqa>
59
+ <title>Productqa Module</title>
60
+ <sort_order>10</sort_order>
61
+ </Dolphin_Productqa>
62
+ </children>
63
+ </admin>
64
+ </resources>
65
+ </acl>
66
+ <layout>
67
+ <updates>
68
+ <productqa>
69
+ <file>productqa.xml</file>
70
+ </productqa>
71
+ </updates>
72
+ </layout>
73
+ </adminhtml>
74
+ <global>
75
+ <models>
76
+ <productqa>
77
+ <class>Dolphin_Productqa_Model</class>
78
+ <resourceModel>productqa_mysql4</resourceModel>
79
+ </productqa>
80
+ <productqa_mysql4>
81
+ <class>Dolphin_Productqa_Model_Mysql4</class>
82
+ <entities>
83
+ <productqa>
84
+ <table>productqa</table>
85
+ </productqa>
86
+ </entities>
87
+ </productqa_mysql4>
88
+ </models>
89
+ <resources>
90
+ <productqa_setup>
91
+ <setup>
92
+ <module>Dolphin_Productqa</module>
93
+ </setup>
94
+ <connection>
95
+ <use>core_setup</use>
96
+ </connection>
97
+ </productqa_setup>
98
+ <productqa_write>
99
+ <connection>
100
+ <use>core_write</use>
101
+ </connection>
102
+ </productqa_write>
103
+ <productqa_read>
104
+ <connection>
105
+ <use>core_read</use>
106
+ </connection>
107
+ </productqa_read>
108
+ </resources>
109
+ <template>
110
+ <email>
111
+ <catalog_email_email_template translate="label" module="productqa">
112
+ <label>Product Question Form</label>
113
+ <file>product_question.html</file>
114
+ <type>html</type>
115
+ </catalog_email_email_template>
116
+ <catalog_email_email2_template translate="label" module="productqa">
117
+ <label>Answer Notification</label>
118
+ <file>product_answer.html</file>
119
+ <type>html</type>
120
+ </catalog_email_email2_template>
121
+ </email>
122
+ </template>
123
+ <blocks>
124
+ <productqa>
125
+ <class>Dolphin_Productqa_Block</class>
126
+ </productqa>
127
+ </blocks>
128
+ <helpers>
129
+ <productqa>
130
+ <class>Dolphin_Productqa_Helper</class>
131
+ </productqa>
132
+ </helpers>
133
+ </global>
134
+ <default>
135
+ <catalog>
136
+ <productqa>
137
+ <enabled>0</enabled>
138
+ <product_number>3</product_number>
139
+ <link_text>Click to ask a question</link_text>
140
+ </productqa>
141
+ <email>
142
+ <recipient_email><![CDATA[hello@example.com]]></recipient_email>
143
+ <sender_email_identity>custom2</sender_email_identity>
144
+ <email_template>catalog_email_email_template</email_template>
145
+ <email_template>catalog_email_email2_template</email_template>
146
+ </email>
147
+ </catalog>
148
+ </default>
149
+ </config>
app/code/community/Dolphin/Productqa/etc/system.xml ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <catalog translate="label" module="productqa">
5
+ <groups>
6
+ <productqa translate="label">
7
+ <label>Enable Product Question</label>
8
+ <frontend_type>text</frontend_type>
9
+ <sort_order>0</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
+ <fields>
14
+ <enabled translate="label">
15
+ <label>Enabled</label>
16
+ <frontend_type>select</frontend_type>
17
+ <source_model>adminhtml/system_config_source_yesno</source_model>
18
+ <sort_order>1</sort_order>
19
+ <show_in_default>1</show_in_default>
20
+ <show_in_website>1</show_in_website>
21
+ <show_in_store>0</show_in_store>
22
+ <comment>Enable Product Question module</comment>
23
+ </enabled>
24
+ <product_number translate="label">
25
+ <label>Number of Question</label>
26
+ <frontend_type>text</frontend_type>
27
+ <sort_order>2</sort_order>
28
+ <show_in_default>1</show_in_default>
29
+ <show_in_website>1</show_in_website>
30
+ <show_in_store>0</show_in_store>
31
+ <comment>Display number of question on product page</comment>
32
+ </product_number>
33
+ <link_text translate="label">
34
+ <label>Text of link</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>0</show_in_store>
40
+ <comment>Text of link on product page</comment>
41
+ </link_text>
42
+ </fields>
43
+ </productqa>
44
+ <email translate="label">
45
+ <label>Product Question Email Options</label>
46
+ <frontend_type>text</frontend_type>
47
+ <sort_order>1</sort_order>
48
+ <show_in_default>1</show_in_default>
49
+ <show_in_website>1</show_in_website>
50
+ <show_in_store>1</show_in_store>
51
+ <fields>
52
+ <recipient_email translate="label">
53
+ <label>Send Emails To</label>
54
+ <frontend_type>text</frontend_type>
55
+ <validate>validate-email</validate>
56
+ <sort_order>10</sort_order>
57
+ <show_in_default>1</show_in_default>
58
+ <show_in_website>1</show_in_website>
59
+ <show_in_store>1</show_in_store>
60
+ </recipient_email>
61
+ <sender_email_identity translate="label">
62
+ <label>Email Sender</label>
63
+ <frontend_type>select</frontend_type>
64
+ <source_model>adminhtml/system_config_source_email_identity</source_model>
65
+ <sort_order>20</sort_order>
66
+ <show_in_default>1</show_in_default>
67
+ <show_in_website>1</show_in_website>
68
+ <show_in_store>1</show_in_store>
69
+ </sender_email_identity>
70
+ <email_template translate="label">
71
+ <label>Email Template</label>
72
+ <frontend_type>select</frontend_type>
73
+ <source_model>adminhtml/system_config_source_email_template</source_model>
74
+ <sort_order>30</sort_order>
75
+ <show_in_default>1</show_in_default>
76
+ <show_in_website>1</show_in_website>
77
+ <show_in_store>1</show_in_store>
78
+ </email_template>
79
+ <email2_template translate="label">
80
+ <label>Answer Notification Template</label>
81
+ <frontend_type>select</frontend_type>
82
+ <source_model>adminhtml/system_config_source_email_template</source_model>
83
+ <sort_order>31</sort_order>
84
+ <show_in_default>1</show_in_default>
85
+ <show_in_website>1</show_in_website>
86
+ <show_in_store>1</show_in_store>
87
+ </email2_template>
88
+ </fields>
89
+ </email>
90
+ </groups>
91
+ </catalog>
92
+ </sections>
93
+ </config>
app/code/community/Dolphin/Productqa/sql/productqa_setup/mysql4-install-1.0.1.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+
9
+ -- DROP TABLE IF EXISTS {$this->getTable('productqa')};
10
+ CREATE TABLE {$this->getTable('productqa')} (
11
+ `productqa_id` int(11) unsigned NOT NULL auto_increment,
12
+ `product_sku` varchar(255) NOT NULL DEFAULT '',
13
+ `name` varchar(255) NOT NULL,
14
+ `email` varchar(100) NOT NULL,
15
+ `title` varchar(255) NOT NULL DEFAULT '',
16
+ `question` text NOT NULL,
17
+ `answer` text NOT NULL,
18
+ `cutomer_email_status` smallint(6) NOT NULL DEFAULT '2',
19
+ `status` smallint(6) NOT NULL DEFAULT '2',
20
+ `created_time` datetime DEFAULT NULL,
21
+ `update_time` datetime DEFAULT NULL,
22
+ PRIMARY KEY (`productqa_id`)
23
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
24
+
25
+ ");
26
+
27
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/productqa.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <productqa_adminhtml_productqa_index>
4
+ <reference name="content">
5
+ <block type="productqa/adminhtml_productqa" name="productqa" />
6
+ </reference>
7
+ </productqa_adminhtml_productqa_index>
8
+ </layout>
app/design/frontend/default/default/layout/productqa.xml ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ <reference name="head">
5
+ <action method="addJs" ifconfig="catalog/productqa/enabled">
6
+ <script>dolphin/productqa/productqa.js</script>
7
+ </action>
8
+ <action method="addCss" ifconfig="catalog/productqa/enabled">
9
+ <stylesheet>dolphin/productqa/productqa.css</stylesheet>
10
+ </action>
11
+ </reference>
12
+ </default>
13
+
14
+ <catalog_product_view>
15
+ <reference name="content">
16
+ <block type="productqa/productqa" name="productqa_link" before="media">
17
+ <action method="setTemplate" ifconfig="catalog/productqa/enabled">
18
+ <template>productqa/productqa_link.phtml</template>
19
+ </action>
20
+ </block>
21
+ <block type="productqa/productqa" name="productqa" before="product.info.additional">
22
+ <action method="setTemplate" ifconfig="catalog/productqa/enabled">
23
+ <template>productqa/productqa.phtml</template>
24
+ </action>
25
+ </block>
26
+ <block type="productqa/productqa" name="productqa_list" after="product.info.additional">
27
+ <action method="setTemplate" ifconfig="catalog/productqa/enabled">
28
+ <template>productqa/productqalist.phtml</template>
29
+ </action>
30
+ </block>
31
+ </reference>
32
+ </catalog_product_view>
33
+ <productqa_index_view>
34
+ <reference name="head">
35
+ <action method="setTitle" translate="title" module="productqa"><title>Product Question</title></action>
36
+ </reference>
37
+ <reference name="root">
38
+ <action method="setTemplate"><template>page/1column.phtml</template></action>
39
+ </reference>
40
+ <reference name="content">
41
+ <block type="productqa/productqa" name="productqa_all" template="productqa/productqaall.phtml" />
42
+ </reference>
43
+ </productqa_index_view>
44
+ </layout>
app/design/frontend/default/default/template/productqa/productqa.phtml ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div id="popupoverlay">&nbsp;</div>
2
+ <div id="popupquestion">
3
+ <a class="popupclose" onclick="popquetionclose();" href="javascript:;"><img src="<?php echo $this->getskinUrl('dolphin/productqa/images/pop-close.png')?>"></a>
4
+ <?php $current_product = Mage::registry('current_product'); ?>
5
+ <h4><?php echo $this->__('Ask Question About '). $current_product->getSku();?></h4>
6
+ <?php $current_product = Mage::registry('current_product'); ?>
7
+ <form method="post" action="<?php echo $this->getUrl('productqa/index/post/') ?>" id="productqaform">
8
+ <input type="hidden" name="product_sku" value="<?php echo $current_product->getSku(); ?>" />
9
+ <input type="hidden" name="product_url" value="<?php echo $this->helper('core/url')->getCurrentUrl(); ?>" />
10
+ <ul class="form-list">
11
+ <li>
12
+ <div class="field">
13
+ <label for="name" class="required"><em>*</em><?php echo Mage::helper('productqa')->__('Name') ?></label>
14
+ <div class="input-box">
15
+ <input name="name" id="name" title="<?php echo Mage::helper('productqa')->__('Name') ?>" value="<?php echo $this->htmlEscape($this->helper('contacts')->getUserName()) ?>" class="input-text required-entry" type="text" />
16
+ </div>
17
+ </div>
18
+ </li>
19
+ <li>
20
+ <div class="field">
21
+ <label for="email" class="required"><em>*</em><?php echo Mage::helper('productqa')->__('Email') ?></label>
22
+ <div class="input-box">
23
+ <input name="email" id="email" title="<?php echo Mage::helper('productqa')->__('Email') ?>" value="<?php echo $this->htmlEscape($this->helper('productqa')->getUserEmail()) ?>" class="input-text required-entry validate-email" type="text" />
24
+ </div>
25
+ </div>
26
+ </li>
27
+ <li>
28
+ <div class="field">
29
+ <label for="name" class="required"><em>*</em><?php echo Mage::helper('productqa')->__('Question') ?></label>
30
+ <div class="input-box">
31
+ <input name="question" id="question" title="<?php echo Mage::helper('productqa')->__('Question') ?>" class="input-text required-entry" type="text" />
32
+ </div>
33
+ </div>
34
+ </li>
35
+ </ul>
36
+ <div class="buttons-set">
37
+ <p class="required"><?php echo Mage::helper('productqa')->__('* Required Fields') ?></p>
38
+ <button type="submit" title="<?php echo Mage::helper('productqa')->__('Submit') ?>" class="button"><span><span><?php echo Mage::helper('productqa')->__('Submit') ?></span></span></button>
39
+ </div>
40
+ </form>
41
+ <script type="text/javascript">
42
+ //<![CDATA[
43
+ var productqaform = new VarienForm('productqaform', true);
44
+ //]]>
45
+ </script>
46
+ </div>
47
+
app/design/frontend/default/default/template/productqa/productqa_link.phtml ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <?php $text = Mage::getStoreConfig('catalog/productqa/link_text'); ?>
2
+ <a onclick="popquetion();" href="javascript:;"><?php echo $text;?></a>
app/design/frontend/default/default/template/productqa/productqaall.phtml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $productsku = $this->getRequest()->getParam('ps');
3
+ $product = Mage::getModel('catalog/product')->loadByAttribute('sku',$productsku);
4
+ if($product){
5
+ $collection = $this->getCollection();
6
+ $cnt = count($collection);
7
+ $i=0;
8
+ if($cnt > 0){
9
+ ?>
10
+ <h4><?php echo $this->__('Question and answer about '). $product->getName();?></h4>
11
+ <?php
12
+ }else{
13
+ ?>
14
+ <h4><?php echo $this->__('No question answer for this product')?></h4>
15
+ <?php
16
+ }
17
+ echo $this->getPagerHtml();
18
+ foreach ($collection as $item) {
19
+ if($item->getanswer() != ""){
20
+ ?>
21
+ <h2><?php echo $item->getQuestion(); ?></h2>
22
+ <p><?php echo $item->getanswer(); ?></p>
23
+ <?php
24
+ }
25
+ } ?>
26
+ <?php
27
+ echo $this->getPagerHtml();
28
+ }else{
29
+ ?>
30
+ <h4><?php echo $this->__('Sorry This Sku is Not Exist '). $productsku;?></h4>
31
+ <?php
32
+ }
33
+ ?>
app/design/frontend/default/default/template/productqa/productqalist.phtml ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $current_product = Mage::registry('current_product'); ?>
2
+ <?php
3
+ $number = Mage::getStoreConfig('catalog/productqa/product_number');
4
+ $collection = Mage::getModel('productqa/productqa')->getCollection()
5
+ ->addFieldToFilter('product_sku',$current_product->getSku())
6
+ ->addFieldToFilter('status',1)
7
+ ->setOrder('productqa_id', 'DESC');
8
+ $cnt = count($collection);
9
+ $i=0;
10
+ if($cnt > 0){
11
+ ?>
12
+ <h4><?php echo $this->__('Question and answer about '). $current_product->getName();?></h4>
13
+ <?php
14
+ }
15
+ foreach ($collection as $item) {
16
+ if($item->getanswer() != ""){
17
+ $i++;
18
+ if($i > $number){
19
+ break;
20
+ }
21
+ ?>
22
+ <h2><?php echo $item->getQuestion(); ?></h2>
23
+ <p><?php echo $item->getanswer(); ?></p>
24
+ <?php
25
+ }
26
+ }
27
+ if($cnt > 2){
28
+ ?>
29
+ <a href="<?php echo $this->getUrl('productqa/index/view/')?>?ps=<?php echo $current_product->getSku() ?>">See More</a>
30
+ <?php
31
+ }
32
+ ?>
app/etc/modules/Dolphin_Productqa.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Dolphin_Productqa>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Dolphin_Productqa>
8
+ </modules>
9
+ </config>
app/locale/en_US/template/email/product_answer.html ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <!--@subject Contact Form@-->
2
+ <!--@vars
3
+ {"var data.name":"Sender Name",
4
+ "var data.email":"Sender Email",
5
+ "var data.question":"Question"}
6
+ @-->
7
+ hello {{var data.name}}<br/>
8
+ Thanks for Your Quetsion here is your answer for question.<br/>
9
+ <br/>
10
+ Answer: {{var data.answer}}
app/locale/en_US/template/email/product_question.html ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <!--@subject Contact Form@-->
2
+ <!--@vars
3
+ {"var data.name":"Sender Name",
4
+ "var data.email":"Sender Email",
5
+ "var data.question":"Question"}
6
+ @-->
7
+ Name: {{var data.name}}<br/>
8
+ E-mail: {{var data.email}}<br/>
9
+
10
+ Question: {{var data.question}}<br/>
js/dolphin/productqa/productqa.js ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function popquetion()
2
+ {
3
+
4
+ //document.getElementById("popupoverlay").style.z-index = '99999';
5
+ document.getElementById("popupoverlay").style.display = 'block';
6
+ //document.getElementById("popupquestion").style.z-index = '999999';
7
+ document.getElementById("popupquestion").style.display = 'block';
8
+ document.getElementById("popupquestion").style.left = '37%';
9
+ document.getElementById("popupquestion").style.top = '25%';
10
+
11
+ }
12
+ function popquetionclose()
13
+ {
14
+ document.getElementById("popupoverlay").style.height = '0';
15
+ document.getElementById("popupoverlay").style.width = '0';
16
+ //document.getElementById("popupoverlay").style.z-index = '0';
17
+ document.getElementById("popupoverlay").style.display = 'none';
18
+ document.getElementById("popupquestion").style.display = 'none';
19
+ }
20
+
21
+
package.xml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Dolphin_Productqa</name>
4
+ <version>1.0.1</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>This magento extension allow customers to ask question about products to admin directly.This extension will save countless hours spent on customer support answering same questions.All Question and Answers display on the product page.</summary>
10
+ <description>This magento extension allow customers to ask question about products to admin directly.This extension will save countless hours spent on customer support answering same questions.All Question and Answers display on the product page.&#xD;
11
+ &#xD;
12
+ The module works this way:&#xD;
13
+ &#xD;
14
+ 1. customers are asking a question about a product to admin directly.&#xD;
15
+ 2. Admin can enable/disable extension from admin panel.&#xD;
16
+ 3. Admin can change title of link for display on product page.&#xD;
17
+ 3. Admin can replied answer from admin panel.&#xD;
18
+ 4. the question and answers appears on the website for future propose for other peoples.)&#xD;
19
+ &#xD;
20
+ Admin can also Enable/Disable and Managed questions and answer from the admin.</description>
21
+ <notes>Stable Release</notes>
22
+ <authors><author><name>DolphinWeb</name><user>auto-converted</user><email>ankit@dolphinwebsolution.com</email></author></authors>
23
+ <date>2013-09-11</date>
24
+ <time>11:38:14</time>
25
+ <contents><target name="mageetc"><dir name="modules"><file name="Dolphin_Productqa.xml" hash="1f890680667cf7382b6dc1229b21a087"/></dir></target><target name="magecommunity"><dir name="Dolphin"><dir name="Productqa"><dir name="Block"><dir name="Adminhtml"><dir name="Productqa"><dir name="Edit"><dir name="Tab"><file name="Form.php" hash="cba56da87fb57aa44e99c74eb61db146"/></dir><file name="Form.php" hash="4f8bf03d5cea16fbf0b55718a3d8b905"/><file name="Tabs.php" hash="e839f279a7f55ccfc566b5ee601dd866"/></dir><file name="Edit.php" hash="88bc0925c09f5dd9ed5c693d1d799d1e"/><file name="Grid.php" hash="75167189b80b63572710ed8dd6557069"/></dir><file name="Productqa.php" hash="688de399b45fbf9a324b3b5afeb26e0b"/></dir><file name="Productqa.php" hash="31cdcbba36a031034d4b4c1d491240c5"/></dir><dir name="Helper"><file name="Data.php" hash="48e66a1deb68ec942e2cb4cd02abb181"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Productqa"><file name="Collection.php" hash="494320891d977da23c2e4f986e078273"/></dir><file name="Productqa.php" hash="8ba35453e89d9fb3a535c07311c77595"/></dir><file name="Productqa.php" hash="8f8fdb963ddf1d8c488c7bfc4f9ef275"/><file name="Status.php" hash="6443ad838b2ec1335d73540d6517f71d"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ProductqaController.php" hash="a4ff06dff6e4d2d6bf6649ebf08f2f4c"/></dir><file name="IndexController.php" hash="cc2f1a0c17bca5f0b59b766d91cb4c0f"/></dir><dir name="etc"><file name="config.xml" hash="fb7ca5122e9f7de10c87d78b22e13628"/><file name="system.xml" hash="2a12e9c887a8730d596f50bdc341a468"/></dir><dir name="sql"><dir name="productqa_setup"><file name="mysql4-install-1.0.1.php" hash="2b88feb350ee12f758a96bea28c3db6b"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="productqa.xml" hash="58ff87cc4866add3180a732b66560827"/></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="productqa"><file name="productqa.phtml" hash="ed7286ced491606eef68581d0158842b"/><file name="productqa_link.phtml" hash="1edcf694416c55f5397da59b79f69505"/><file name="productqaall.phtml" hash="c3743302780245e9f65e403487702823"/><file name="productqalist.phtml" hash="0e0b71a9ad0a77554a35a3eb25e3c973"/></dir></dir><dir name="layout"><file name="productqa.xml" hash="af6083fdb4a26c68c236fe8826b2770b"/></dir></dir></dir></dir></target><target name="mage"><dir name="js"><dir name="dolphin"><dir name="productqa"><file name="productqa.js" hash="3a1cc28e77b70a1c75b13691ed9cb7a5"/></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="default"><dir name="default"><dir name="dolphin"><dir name="productqa"><dir name="images"><file name="pop-close.png" hash="3612a71b283fbbf6b5f5ad5b463cb840"/></dir><file name="productqa.css" hash="73157c0f5eb1568844f3ff8f3603232a"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><dir name="template"><dir name="email"><file name="product_answer.html" hash="404290f0e3afcc70d0f9a6762f583c1d"/><file name="product_question.html" hash="7ce5f8597433861c99dabb1468964706"/></dir></dir></dir></target></contents>
26
+ <compatible/>
27
+ <dependencies/>
28
+ </package>
skin/frontend/default/default/dolphin/productqa/images/pop-close.png ADDED
Binary file
skin/frontend/default/default/dolphin/productqa/productqa.css ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ #popupoverlay{position:fixed; display:none; opacity:0.8;}
2
+ #popupquestion{display:none; position:fixed; background:#fff; padding:10px; border:7px solid #000000; z-index: 9999;}
3
+ .popupclose{position: absolute; right: -21px; top: -19px;}