Hatimeria_AskForProduct - Version 1.0.0

Version Notes

Ready to listen your opinion

Download this release

Release Info

Developer Magento Core Team
Extension Hatimeria_AskForProduct
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/local/Hatimeria/Askforproduct/Helper/Data.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Hatimeria_Askforproduct_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ public function getAddUrl($item)
5
+ {
6
+ if ($item instanceof Mage_Catalog_Model_Product) {
7
+ return $this->_getUrl('askforproduct', array('product'=>$item->getId()));
8
+ }
9
+ return false;
10
+ }
11
+
12
+ public function getUserName()
13
+ {
14
+ if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
15
+ return '';
16
+ }
17
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
18
+ return trim($customer->getName());
19
+ }
20
+
21
+ public function getUserEmail()
22
+ {
23
+ if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
24
+ return '';
25
+ }
26
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
27
+ return $customer->getEmail();
28
+ }
29
+ }
app/code/local/Hatimeria/Askforproduct/Model/Resource/Eav/Mysql4/Setup.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Hatimeria_Askforproduct_Model_Resource_Eav_Mysql4_Setup extends Mage_Eav_Model_Entity_Setup
3
+ {
4
+ public function getDefaultEntities()
5
+ {
6
+ return array(
7
+ 'catalog_product' => array(
8
+ 'entity_model' => 'catalog/product',
9
+ 'attribute_model' => 'catalog/resource_eav_attribute',
10
+ 'table' => 'catalog/product',
11
+ 'additional_attribute_table' => 'catalog/eav_attribute',
12
+ 'entity_attribute_collection' => 'catalog/product_attribute_collection',
13
+ 'attributes' => array(
14
+ 'hatimeria_askforproduct' => array(
15
+ 'group' => 'General',
16
+ 'label' => 'Zapytaj o produkt',
17
+ 'type' => 'int',
18
+ 'input' => 'boolean',
19
+ 'default' => 1,
20
+ 'class' => '',
21
+ 'backend' => '',
22
+ 'frontend' => '',
23
+ 'source' => '',
24
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
25
+ 'visible' => true,
26
+ 'required' => false,
27
+ 'user_defined' => false,
28
+ 'searchable' => false,
29
+ 'filterable' => false,
30
+ 'comparable' => false,
31
+ 'visible_on_front' => false,
32
+ 'visible_in_advanced_search' => false,
33
+ 'unique' => false
34
+ ),
35
+ )
36
+ ),
37
+ );
38
+ }
39
+ }
app/code/local/Hatimeria/Askforproduct/README.txt ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Wpisy do templatek pozwalaj�ce na dzia�anie modu�u:
2
+
3
+ [widok produktu]
4
+ <?php if(Mage::getStoreConfigFlag('askforproduct/askforproduct/enable_product_view')):?>
5
+ <a href="<?php echo $this->helper('askforproduct')->getAddUrl($_product) ?>"><?php echo Mage::getStoreConfig('askforproduct/askforproduct/askforproduct_question') ?></a>
6
+ <?php endif; ?>
7
+
8
+
9
+ [lista produkt�w]
10
+ <?php if(Mage::getStoreConfigFlag('askforproduct/askforproduct/enable_product_list')):?>
11
+ <a href="<?php echo $this->helper('askforproduct')->getAddUrl($_product) ?>"><?php echo Mage::getStoreConfig('askforproduct/askforproduct/askforproduct_question') ?></a>
12
+ <?php endif; ?>
13
+
14
+ Dodatkowo dla poprawnego dzia�ania modu�u nale�y pami�ta� o zgraniu templatki maila do odpowiedniego locale
15
+ locale/pl_PL/template/email/askforproduct_form.phtml
app/code/local/Hatimeria/Askforproduct/controllers/IndexController.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Hatimeria_Askforproduct_IndexController extends Mage_Core_Controller_Front_Action
3
+ {
4
+
5
+ const XML_PATH_EMAIL_RECIPIENT = 'askforproduct/email/recipient_email';
6
+ const XML_PATH_EMAIL_SENDER = 'askforproduct/email/sender_email_identity';
7
+ const XML_PATH_EMAIL_TEMPLATE = 'askforproduct/email/email_template';
8
+ const XML_PATH_ENABLED_VIEW = 'askforproduct/askforproduct/enable_product_view';
9
+ const XML_PATH_ENABLED_LIST = 'askforproduct/askforproduct/enable_product_list';
10
+
11
+
12
+ public function preDispatch()
13
+ {
14
+ parent::preDispatch();
15
+
16
+ if( !Mage::getStoreConfigFlag(self::XML_PATH_ENABLED_VIEW) && !Mage::getStoreConfigFlag(self::XML_PATH_ENABLED_VIEW)) {
17
+ $this->norouteAction();
18
+ }
19
+ }
20
+
21
+ public function indexAction()
22
+ {
23
+ $this->loadLayout();
24
+ $this->getLayout()->getBlock('askforproductForm')
25
+ ->setFormAction( Mage::getUrl('*/*/post') );
26
+
27
+ $this->_initLayoutMessages('customer/session');
28
+ $this->_initLayoutMessages('catalog/session');
29
+ $this->renderLayout();
30
+ }
31
+
32
+ public function postAction()
33
+ {
34
+ $post = $this->getRequest()->getPost();
35
+ if ( $post ) {
36
+ $translate = Mage::getSingleton('core/translate');
37
+ /* @var $translate Mage_Core_Model_Translate */
38
+ $translate->setTranslateInline(false);
39
+ try {
40
+ $postObject = new Varien_Object();
41
+ $postObject->setData($post);
42
+
43
+ $error = false;
44
+
45
+ if (!Zend_Validate::is(trim($post['name']) , 'NotEmpty')) {
46
+ $error = true;
47
+ }
48
+
49
+ if (!Zend_Validate::is(trim($post['comment']) , 'NotEmpty')) {
50
+ $error = true;
51
+ }
52
+
53
+ if (!Zend_Validate::is(trim($post['email']), 'EmailAddress')) {
54
+ $error = true;
55
+ }
56
+
57
+ if ($error) {
58
+ throw new Exception();
59
+ }
60
+ $mailTemplate = Mage::getModel('core/email_template');
61
+ /* @var $mailTemplate Mage_Core_Model_Email_Template */
62
+ $mailTemplate->setDesignConfig(array('area' => 'frontend'))
63
+ ->setReplyTo($post['email'])
64
+ ->sendTransactional(
65
+ Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE),
66
+ Mage::getStoreConfig(self::XML_PATH_EMAIL_SENDER),
67
+ Mage::getStoreConfig(self::XML_PATH_EMAIL_RECIPIENT),
68
+ null,
69
+ array('data' => $postObject)
70
+ );
71
+
72
+ if (!$mailTemplate->getSentSuccess()) {
73
+ throw new Exception();
74
+ }
75
+
76
+ $translate->setTranslateInline(true);
77
+
78
+ Mage::getSingleton('catalog/session')->addSuccess(Mage::helper('contacts')->__('Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us.'));
79
+ $this->_redirect('catalog/product/view/id',array('id' => $post['product']));
80
+
81
+ return;
82
+ } catch (Exception $e) {
83
+ $translate->setTranslateInline(true);
84
+
85
+ Mage::getSingleton('customer/session')->addError(Mage::helper('contacts')->__('Unable to submit your request. Please, try again later'));
86
+ $this->_redirect('*/*/',array('product' => $post['product']));
87
+ return;
88
+ }
89
+
90
+ } else {
91
+ $this->_redirect('*/*/');
92
+ }
93
+ }
94
+
95
+
96
+ }
app/code/local/Hatimeria/Askforproduct/etc/adminhtml.xml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <admin>
6
+ <children>
7
+ <system>
8
+ <children>
9
+ <config>
10
+ <children>
11
+ <askforproduct translate="title" module="askforproduct">
12
+ <title>Ask for product</title>
13
+ <sort_order>110</sort_order>
14
+ </askforproduct>
15
+ </children>
16
+ </config>
17
+ </children>
18
+ </system>
19
+ </children>
20
+ </admin>
21
+ </resources>
22
+ </acl>
23
+ </config>
app/code/local/Hatimeria/Askforproduct/etc/config.xml ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Hatimeria_Askforproduct>
5
+ <version>1.0.0</version>
6
+ </Hatimeria_Askforproduct>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <askforproduct>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>Hatimeria_Askforproduct</module>
14
+ <frontName>askforproduct</frontName>
15
+ </args>
16
+ </askforproduct>
17
+ </routers>
18
+ <layout>
19
+ <updates>
20
+ <askforproduct>
21
+ <file>askforproduct.xml</file>
22
+ </askforproduct>
23
+ </updates>
24
+ </layout>
25
+ </frontend>
26
+ <global>
27
+ <helpers>
28
+ <askforproduct>
29
+ <class>Hatimeria_Askforproduct_Helper</class>
30
+ </askforproduct>
31
+ </helpers>
32
+ <models>
33
+ <askforproduct>
34
+ <class>Hatimeria_Askforproduct_Model</class>
35
+ </askforproduct>
36
+ </models>
37
+ <blocks>
38
+ <askforproduct>
39
+ <class>Hatimeria_Askforproduct_Block</class>
40
+ </askforproduct>
41
+ </blocks>
42
+ <resources>
43
+ <askforproduct_setup>
44
+ <setup>
45
+ <module>Hatimeria_Askforproduct</module>
46
+ <class>Hatimeria_Askforproduct_Model_Resource_Eav_Mysql4_Setup</class>
47
+ </setup>
48
+ <connection>
49
+ <use>core_setup</use>
50
+ </connection>
51
+ </askforproduct_setup>
52
+ <askforproduct_write>
53
+ <connection>
54
+ <use>core_write</use>
55
+ </connection>
56
+ </askforproduct_write>
57
+ <askforproduct_read>
58
+ <connection>
59
+ <use>core_read</use>
60
+ </connection>
61
+ </askforproduct_read>
62
+ </resources>
63
+ <template>
64
+ <email>
65
+ <askforproduct_email_email_template translate="label" module="askforproduct">
66
+ <label>Ask For Product Form</label>
67
+ <file>askforproduct_form.html</file>
68
+ <type>text</type>
69
+ </askforproduct_email_email_template>
70
+ </email>
71
+ </template>
72
+ </global>
73
+ <default>
74
+ <askforproduct>
75
+ <askforproduct>
76
+ <askforproduct_question>Zapytaj o produkt</askforproduct_question>
77
+ <enable_product_view>1</enable_product_view>
78
+ <enable_product_view>0</enable_product_view>
79
+ </askforproduct>
80
+ <email>
81
+ <recipient_email>biuro@przyklad.pl</recipient_email>
82
+ </email>
83
+ </askforproduct>
84
+ </default>
85
+ </config>
app/code/local/Hatimeria/Askforproduct/etc/system.xml ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <askforproduct translate="label" module="askforproduct">
5
+ <label>Zapytaj o produkt</label>
6
+ <sort_order>301</sort_order>
7
+ </askforproduct>
8
+ </tabs>
9
+ <sections>
10
+ <askforproduct translate="label" module="askforproduct">
11
+ <label>Konfiguracja - zapytaj o produkt</label>
12
+ <tab>askforproduct</tab>
13
+ <sort_order>130</sort_order>
14
+ <show_in_default>1</show_in_default>
15
+ <show_in_website>1</show_in_website>
16
+ <show_in_store>1</show_in_store>
17
+ <groups>
18
+ <askforproduct translate="label">
19
+ <label>Opcje - zapytaj o produkt</label>
20
+ <frontend_type>text</frontend_type>
21
+ <sort_order>49</sort_order>
22
+ <show_in_default>1</show_in_default>
23
+ <show_in_website>1</show_in_website>
24
+ <show_in_store>1</show_in_store>
25
+ <fields>
26
+ <enable_product_view translate="label">
27
+ <label>Czy włączony w karcie produktu: </label>
28
+ <comment>Czy przycisk 'zapytaj' będzie pojawiał się w karcie produktu. (uwaga - pojawi się jedynie kiedy ustawimy w produkcie że jest to produkt o który można pytać)</comment>
29
+ <frontend_type>select</frontend_type>
30
+ <sort_order>80</sort_order>
31
+ <show_in_default>1</show_in_default>
32
+ <show_in_website>1</show_in_website>
33
+ <show_in_store>1</show_in_store>
34
+ <source_model>adminhtml/system_config_source_yesno</source_model>
35
+ </enable_product_view>
36
+ <enable_product_list translate="label">
37
+ <label>Czy włączony na liście produktów: </label>
38
+ <comment>Czy przycisk 'zapytaj' będzie pojawiał się na liście produktów. (uwaga - pojawi się jedynie kiedy ustawimy w produkcie że jest to produkt o który można pytać)</comment>
39
+ <frontend_type>select</frontend_type>
40
+ <sort_order>80</sort_order>
41
+ <show_in_default>1</show_in_default>
42
+ <show_in_website>1</show_in_website>
43
+ <show_in_store>1</show_in_store>
44
+ <source_model>adminhtml/system_config_source_yesno</source_model>
45
+ </enable_product_list>
46
+ <askforproduct_question translate="label">
47
+ <label>Treść na przycisku: </label>
48
+ <comment>Ta treść wyświetli się na przycisku który przekierowuje do formularza z zapytaniem</comment>
49
+ <frontend_type>text</frontend_type>
50
+ <sort_order>20</sort_order>
51
+ <show_in_default>1</show_in_default>
52
+ <show_in_website>1</show_in_website>
53
+ <show_in_store>1</show_in_store>
54
+ </askforproduct_question>
55
+ <!--<enable translate="label">
56
+ <label>Enable</label>
57
+ <comment>Ta opcja zmienia sposób otwierania formularza zapytania o produkt. (uwaga - pojawi się jedynie kiedy ustawimy w produkcie że jest to produkt o który można pytać)</comment>
58
+ <frontend_type>select</frontend_type>
59
+ <source_model>adminhtml/system_config_source_yesno</source_model>
60
+ <sort_order>90</sort_order>
61
+ <show_in_default>1</show_in_default>
62
+ <show_in_website>1</show_in_website>
63
+ <show_in_store>1</show_in_store>
64
+ </enable>-->
65
+ </fields>
66
+ </askforproduct>
67
+ <email translate="label">
68
+ <label>Email Options</label>
69
+ <frontend_type>text</frontend_type>
70
+ <sort_order>50</sort_order>
71
+ <show_in_default>1</show_in_default>
72
+ <show_in_website>1</show_in_website>
73
+ <show_in_store>1</show_in_store>
74
+ <fields>
75
+ <recipient_email translate="label">
76
+ <label>Send Emails To</label>
77
+ <frontend_type>text</frontend_type>
78
+ <sort_order>10</sort_order>
79
+ <show_in_default>1</show_in_default>
80
+ <show_in_website>1</show_in_website>
81
+ <show_in_store>1</show_in_store>
82
+ </recipient_email>
83
+ <sender_email_identity translate="label">
84
+ <label>Email Sender</label>
85
+ <frontend_type>select</frontend_type>
86
+ <source_model>adminhtml/system_config_source_email_identity</source_model>
87
+ <sort_order>20</sort_order>
88
+ <show_in_default>1</show_in_default>
89
+ <show_in_website>1</show_in_website>
90
+ <show_in_store>1</show_in_store>
91
+ </sender_email_identity>
92
+ <email_template translate="label">
93
+ <label>Email Template</label>
94
+ <frontend_type>select</frontend_type>
95
+ <source_model>adminhtml/system_config_source_email_template</source_model>
96
+ <sort_order>30</sort_order>
97
+ <show_in_default>1</show_in_default>
98
+ <show_in_website>1</show_in_website>
99
+ <show_in_store>1</show_in_store>
100
+ </email_template>
101
+ </fields>
102
+ </email>
103
+ </groups>
104
+ </askforproduct>
105
+ </sections>
106
+ </config>
app/code/local/Hatimeria/Askforproduct/sql/askforproduct_setup/mysql4-install-1.0.0.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ $installer->installEntities();
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+ INSERT INTO {$this->getTable('core_email_template')} (`template_code`, `template_text`, `template_type`, `template_subject`, `template_sender_name`, `template_sender_email`, `added_at`, `modified_at`) VALUES
9
+ ('Askforproduct Form (Plain)', 'Name: {{var data.name}}\r\nE-mail: {{var data.email}}\r\nTelephone: {{var data.telephone}}\r\nComment: {{var data.comment}}', 1, 'Question about: {{var data.productname}} - {{var data.productsku}}', NULL, NULL, NOW(), NOW());
10
+ ");
11
+ $installer->endSetup();
app/design/frontend/default/default/layout/askforproduct.xml ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <!-- potrzebne do zapytania bez ajaxa -->
4
+ <askforproduct_index_index>
5
+ <reference name="head">
6
+ <action method="addCss"><script>css/askforproduct.css</script></action>
7
+ </reference>
8
+ <reference name="root">
9
+ <action method="setTemplate"><template>page/2columns-left.phtml</template></action>
10
+ <action method="setHeaderTitle" translate="title" module="askforproduct"><title>Zapytanie o produkt</title></action>
11
+ </reference>
12
+ <reference name="content">
13
+ <block type="core/template" name="askforproductForm" template="askforproduct/form.phtml"/>
14
+ </reference>
15
+ </askforproduct_index_index>
16
+ <catalog_product_view>
17
+ <reference name="head">
18
+ <action method="addCss"><script>css/askforproduct.css</script></action>
19
+ </reference>
20
+ <reference name="product.info">
21
+ <block type="core/template" name="askview" template="askforproduct/ask_view.phtml"/>
22
+ </reference>
23
+
24
+ </catalog_product_view>
25
+
26
+
27
+ <!-- to jest srednio potrzebne do ajaxa -->
28
+ <!--<askforproduct_index_index>
29
+ <reference name="root">
30
+ <action method="setTemplate"><template>page/2columns-right.phtml</template></action>
31
+ <action method="setHeaderTitle" translate="title" module="askforproduct"><title>Zapytanie o produkt</title></action>
32
+ </reference>
33
+ <reference name="content">
34
+ <block type="core/template" name="askforproductForm" template="askforproduct/form.phtml"/>
35
+ <block type="core/template" name="askforproductForm" template="askforproductForm/formajax.phtml"></block>
36
+ </reference>
37
+ <reference name="product.info">
38
+ <block type="core/template" name="askview" template="askforproduct/ask_view.phtml"/>
39
+ </reference>
40
+ </askforproduct_index_index>-->
41
+ <!-- koniec niepotrzebnego -->
42
+ <!--<catalog_product_view>
43
+ <reference name="head">
44
+ <action method="addJs"><script>hatimeria/askforproduct.js</script></action>
45
+ <action method="addCss"><script>css/askforproduct.css</script></action>
46
+ </reference>
47
+ <reference name="product.info">
48
+ <block type="core/template" name="askview" template="askforproduct/ask_view.phtml"/>
49
+ </reference>
50
+ <reference name="before_body_end">
51
+ <block type="askforproduct/js" name="askforproduct" as="askforproduct" />
52
+ </reference>
53
+ </catalog_product_view>
54
+
55
+ <askforproduct_index_index translate="label">
56
+ <reference name="root">
57
+ <action method="setTemplate"><template>page/empty.phtml</template></action>
58
+ <action method="setHeaderTitle" translate="title" module="contacts"><title>Contact Us</title></action>
59
+ </reference>
60
+ <reference name="head">
61
+ <action method="addJs"><script>hatimeria/askforproduct.js</script></action>
62
+ <action method="addCss"><script>css/askforproduct.css</script></action>
63
+ </reference>
64
+ <reference name="content">
65
+ <block type="askforproduct/form" name="askforproductForm" template="askforproduct/formajax.phtml"></block>
66
+ </reference>
67
+ <reference name="before_body_end">
68
+ <block type="askforproduct/js" name="askforproduct" as="askforproduct" />
69
+ </reference>
70
+ </askforproduct_index_index>-->
71
+ </layout>
app/design/frontend/default/default/template/askforproduct/ask_view.phtml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+
2
+ <?php
3
+ $_product = $this->getProduct();
4
+ if(Mage::getStoreConfigFlag('askforproduct/askforproduct/enable_product_view')):?>
5
+ <p id="ask">
6
+ <a href="<?php echo $this->helper('askforproduct')->getAddUrl($_product) ?>"><?php echo Mage::getStoreConfig('askforproduct/askforproduct/askforproduct_question') ?></a>
7
+ </p>
8
+ <?php endif; ?>
app/design/frontend/default/default/template/askforproduct/form.phtml ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $productId = (int) $this->getRequest()->getParam('product');
2
+ if (!$productId) {
3
+ $this->_redirect('*/');
4
+ return;
5
+ }
6
+ $product = Mage::getModel('catalog/product')->load($productId);
7
+ $product->getProductUrl();
8
+ $product->getSku();
9
+
10
+ ?>
11
+
12
+ <div id="messages_product_view"><?php echo $this->getMessagesBlock()->getGroupedHtml() ?></div>
13
+ <div class="page-head">
14
+ <h3><?php echo Mage::helper('askforproduct')->__('Question about:')." ".$product->getName();?></h3>
15
+ </div>
16
+
17
+ <form action="<?php echo $this->getFormAction(); ?>" id="askforproductForm" method="post">
18
+ <input type="hidden" name="reference_url" id="reference_url" value="<?php echo $product->getProductUrl() ?>" />
19
+ <input type="text" name="hideit" id="hideit" value="" style="display:none !important;" />
20
+ <fieldset class="group-select">
21
+ <h4 class="legend"><?php echo Mage::helper('askforproduct')->__('Ask Question') ?></h4>
22
+ <ul>
23
+ <li>
24
+ <div class="input-box">
25
+ <label for="name"><?php echo Mage::helper('askforproduct')->__('Name') ?> <span class="required">*</span></label><br />
26
+ <input name="name" id="name" title="<?php echo $this->__('Name') ?>" value="<?php echo $this->htmlEscape($this->helper('askforproduct')->getUserName()) ?>" class="required-entry input-text" type="text" />
27
+ </div>
28
+
29
+ <div class="input-box">
30
+ <label for="email"><?php echo Mage::helper('askforproduct')->__('Email') ?> <span class="required">*</span></label><br />
31
+ <input name="email" id="email" title="<?php echo $this->__('Email') ?>" value="<?php echo $this->htmlEscape($this->helper('askforproduct')->getUserEmail()) ?>" class="required-entry input-text validate-email" type="text" />
32
+ </div>
33
+
34
+ <div class="clear"></div>
35
+
36
+ <div class="input-box">
37
+ <label for="telephone"><?php echo Mage::helper('askforproduct')->__('Telephone') ?></label><br />
38
+ <input name="telephone" id="telephone" title="<?php echo $this->__('Telephone') ?>" value="" class="input-text" type="text" />
39
+ </div>
40
+
41
+ <div class="clear"></div>
42
+
43
+ <div class="input-box">
44
+ <label for="comment"><?php echo Mage::helper('askforproduct')->__('Ask your question') ?> <span class="required">*</span></label><br />
45
+ <textarea name="comment" id="comment" title="<?php echo $this->__('Question') ?>" class="required-entry input-text" style="height:150px;width:525px;" cols="50" rows="5"></textarea>
46
+ </div>
47
+ </li>
48
+ </ul>
49
+ </fieldset>
50
+ <div class="button-set">
51
+ <p class="required"><?php echo Mage::helper('askforproduct')->__('* Required Fields') ?></p>
52
+ <button class="form-button" type="submit"><span><?php echo Mage::helper('askforproduct')->__('Submit') ?></span></button>
53
+ </div>
54
+ <input type="hidden" name="product" value="<?php echo $productId ?>">
55
+ <input type="hidden" name="productname" value="<?php echo $product->getName() ?>">
56
+ <input type="hidden" name="productsku" value="<?php echo $product->getSku() ?>">
57
+ </form>
58
+ <script type="text/javascript">
59
+ var contactForm = new VarienForm('askforproductForm', true);
60
+ </script>
app/design/frontend/default/default/template/askforproduct/formajax.phtml ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script>
2
+ /*$$("iframe").each(function(el) {
3
+ var url = $(el).readAttribute('action');
4
+ var slices = url.substring(url.search(/\/product\/[0-9]+\//)).split('/');
5
+ productId = slices[2];
6
+ console.log(url);
7
+ });
8
+ $$("#frameless_ask").each(function(el) {
9
+ var url = $(el).readAttribute('class').split(' ');
10
+ productId = url[1];
11
+ console.log(productId);
12
+ });*/
13
+ </script>
14
+ <?php $productId = (int) $this->getRequest()->getParam('product');
15
+ $product = Mage::getModel('catalog/product')->load($productId);
16
+ $product->getProductUrl();
17
+ $product->getSku();
18
+
19
+ ?>
20
+
21
+ <div id="messages_product_view"><?php echo $this->getMessagesBlock()->getGroupedHtml() ?></div>
22
+ <div class="page-head">
23
+ <?php echo $productId; ?>
24
+ <h3><?php echo Mage::helper('askforproduct')->__('Question about:')." ".$product->getName();?></h3>
25
+ </div>
26
+
27
+ <form action="<?php echo $this->getFormAction(); ?>" id="askforproductForm" method="post">
28
+ <input type="hidden" name="reference_url" id="reference_url" value="<?php echo $product->getProductUrl() ?>" />
29
+ <input type="text" name="hideit" id="hideit" value="" style="display:none !important;" />
30
+ <fieldset class="group-select">
31
+ <h4 class="legend"><?php echo Mage::helper('askforproduct')->__('Ask Question') ?></h4>
32
+ <ul>
33
+ <li>
34
+ <div class="input-box">
35
+ <label for="name"><?php echo Mage::helper('askforproduct')->__('Name') ?> <span class="required">*</span></label><br />
36
+ <input name="name" id="name" title="<?php echo $this->__('Name') ?>" value="<?php echo $this->htmlEscape($this->helper('askforproduct')->getUserName()) ?>" class="required-entry input-text" type="text" />
37
+ </div>
38
+
39
+ <div class="input-box">
40
+ <label for="email"><?php echo Mage::helper('askforproduct')->__('Email') ?> <span class="required">*</span></label><br />
41
+ <input name="email" id="email" title="<?php echo $this->__('Email') ?>" value="<?php echo $this->htmlEscape($this->helper('askforproduct')->getUserEmail()) ?>" class="required-entry input-text validate-email" type="text" />
42
+ </div>
43
+
44
+ <div class="clear"></div>
45
+
46
+ <div class="input-box">
47
+ <label for="telephone"><?php echo Mage::helper('askforproduct')->__('Telephone') ?></label><br />
48
+ <input name="telephone" id="telephone" title="<?php echo $this->__('Telephone') ?>" value="" class="input-text" type="text" />
49
+ </div>
50
+
51
+ <div class="clear"></div>
52
+
53
+ <div class="input-box">
54
+ <label for="comment"><?php echo Mage::helper('askforproduct')->__('Ask your question') ?> <span class="required">*</span></label><br />
55
+ <textarea name="comment" id="comment" title="<?php echo $this->__('Question') ?>" class="required-entry input-text" style="height:150px;width:525px;" cols="50" rows="5"></textarea>
56
+ </div>
57
+ </li>
58
+ </ul>
59
+ </fieldset>
60
+ <div class="button-set">
61
+ <p class="required"><?php echo Mage::helper('askforproduct')->__('* Required Fields') ?></p>
62
+ <button class="form-button" type="submit"><span><?php echo Mage::helper('askforproduct')->__('Submit') ?></span></button>
63
+ </div>
64
+ <input type="hidden" name="product" value="<?php echo $productId ?>">
65
+ <input type="hidden" name="productname" value="<?php echo $product->getName() ?>">
66
+ <input type="hidden" name="productsku" value="<?php echo $product->getSku() ?>">
67
+ </form>
68
+ <script type="text/javascript">
69
+ var contactForm = new VarienForm('askforproductForm', true);
70
+ </script>
app/design/frontend/default/klimamarket/template/askforproduct/form.phtml ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $productId = (int) $this->getRequest()->getParam('product');
2
+ if (!$productId) {
3
+ $this->_redirect('*/');
4
+ return;
5
+ }
6
+ $product = Mage::getModel('catalog/product')->load($productId);
7
+ $product->getProductUrl();
8
+ $product->getSku();
9
+
10
+ ?>
11
+
12
+ <div id="messages_product_view"><?php echo $this->getMessagesBlock()->getGroupedHtml() ?></div>
13
+ <h1><?php echo Mage::helper('askforproduct')->__('Question about:')." ".$product->getName();?></h1>
14
+ <form action="<?php echo $this->getFormAction(); ?>" id="askforproductForm" method="post">
15
+ <input type="hidden" name="reference_url" id="reference_url" value="<?php echo $product->getProductUrl() ?>" />
16
+ <input type="text" name="hideit" id="hideit" value="" style="display:none !important;" />
17
+ <fieldset class="group-select">
18
+ <ul>
19
+ <li>
20
+ <label for="name"><?php echo Mage::helper('askforproduct')->__('Name') ?> <span class="required">*</span></label>
21
+ <input name="name" id="name" title="<?php echo $this->__('Name') ?>" value="<?php echo $this->htmlEscape($this->helper('askforproduct')->getUserName()) ?>" class="required-entry input-text" type="text" />
22
+ </li>
23
+ <li>
24
+ <label for="email"><?php echo Mage::helper('askforproduct')->__('Email') ?> <span class="required">*</span></label>
25
+ <input name="email" id="email" title="<?php echo $this->__('Email') ?>" value="<?php echo $this->htmlEscape($this->helper('askforproduct')->getUserEmail()) ?>" class="required-entry input-text validate-email" type="text" />
26
+ <li>
27
+ <label for="telephone"><?php echo Mage::helper('askforproduct')->__('Telephone') ?></label>
28
+ <input name="telephone" id="telephone" title="<?php echo $this->__('Telephone') ?>" value="" class="input-text" type="text" />
29
+ </li>
30
+ <li>
31
+ <label for="comment"><?php echo Mage::helper('askforproduct')->__('Ask your question') ?> <span class="required">*</span></label>
32
+ <textarea name="comment" id="comment" title="<?php echo $this->__('Question') ?>" class="required-entry input-text" cols="50" rows="5"></textarea>
33
+ </li>
34
+ </ul>
35
+ </fieldset>
36
+ <div class="button-set">
37
+ <p class="required"><?php echo Mage::helper('askforproduct')->__('* Required Fields') ?></p>
38
+ <button class="button" type="submit"><span><?php echo Mage::helper('askforproduct')->__('Submit') ?></span></button>
39
+ </div>
40
+ <input type="hidden" name="product" value="<?php echo $productId ?>">
41
+ <input type="hidden" name="productname" value="<?php echo $product->getName() ?>">
42
+ <input type="hidden" name="productsku" value="<?php echo $product->getSku() ?>">
43
+ </form>
44
+ <script type="text/javascript">
45
+ var contactForm = new VarienForm('askforproductForm', true);
46
+ </script>
app/design/frontend/default/klimamarket/template/catalog/product/view.phtml ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $_helper = $this->helper('catalog/output');
3
+ $_product = $this->getProduct();
4
+ $msg = $this->getMessagesBlock()->getGroupedHtml();
5
+ ?>
6
+ <?php if($msg): ?>
7
+ <div id="messages_product_view"><?php echo $msg ?></div>
8
+ <?php endif; ?>
9
+
10
+ <div class="product-view hproduct">
11
+ <h1><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></h1>
12
+ <div class="product-essential">
13
+ <form action="<?php echo $this->getAddToCartUrl($_product) ?>" method="post" id="product_addtocart_form"<?php if($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
14
+ <div class="product-shop hreview-aggregate">
15
+ <?php if ($this->canEmailToFriend()): ?>
16
+ <p class="email-friend"><a href="<?php echo $this->helper('catalog/product')->getEmailToFriendUrl($_product) ?>"><?php echo $this->__('Email to a Friend') ?></a></p>
17
+ <?php endif; ?>
18
+
19
+ <!-- obsługa przycisku -->
20
+ <?php if($this->getChild('askview')): ?>
21
+ <?php $this->getChild('askview')->setProduct($_product); ?>
22
+ <?php echo $this->getChildHtml('askview') ?>
23
+ <?php endif; ?>
24
+
25
+ <?php echo $this->getChildHtml('alert_urls') ?>
26
+ <?php echo $this->getChildHtml('product_type_data') ?>
27
+ <?php echo $this->getTierPriceHtml() ?>
28
+
29
+ <?php if (!$this->hasOptions()):?>
30
+ <div class="add-to-box">
31
+ <?php if($_product->isSaleable()): ?>
32
+ <?php echo $this->getChildHtml('addtocart') ?>
33
+ <?php if( $this->helper('wishlist')->isAllow() || $_compareUrl=$this->helper('catalog/product_compare')->getAddUrl($_product)): ?>
34
+ <?php //echo $this->getChildHtml('addto') ?>
35
+ <?php endif; ?>
36
+ <?php endif; ?>
37
+ </div>
38
+ <?php endif; ?>
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+ <?php echo $this->getChildHtml('additional') ?>
47
+ <?php echo $this->getChildHtml('description') ?>
48
+
49
+ <?php echo $this->getChildHtml('other');?>
50
+
51
+ <?php if ($_product->isSaleable() && $this->hasOptions()):?>
52
+ <?php echo $this->getChildChildHtml('container1', '', true, true) ?>
53
+ <?php endif;?>
54
+
55
+ </div>
56
+
57
+ <div class="product-img-box">
58
+ <?php echo $this->getChildHtml('media') ?>
59
+ </div>
60
+
61
+ <div class="clearer"></div>
62
+ <?php if ($_product->isSaleable() && $this->hasOptions()):?>
63
+ <?php echo $this->getChildChildHtml('container2', '', true, true) ?>
64
+ <?php endif;?>
65
+ </form>
66
+ <?php if($this->getJsonConfig() != '[]'): ?>
67
+ <script type="text/javascript">
68
+ //<![CDATA[
69
+ var optionsPrice = new Product.OptionsPrice(<?php echo $this->getJsonConfig() ?>);
70
+ //]]>
71
+ </script>
72
+ <?php endif; ?>
73
+ </div>
74
+ <div class="product-collateral">
75
+ <?php echo $this->getChildHtml('upsell_products') ?>
76
+ </div>
77
+ <div class="no-display">
78
+ <input type="hidden" name="product" value="<?php echo $_product->getId() ?>" />
79
+ <input type="hidden" name="related_product" id="related-products-field" value="" />
80
+ </div>
81
+ </div>
82
+ <!--<script>
83
+ $$("form#product_addtocart_form").each(function(el) {
84
+ var url = $(el).readAttribute('action');
85
+ var slices = url.substring(url.search(/\/product\/[0-9]+\//)).split('/');
86
+ productId = slices[2];
87
+ console.log(productId);
88
+ });
89
+
90
+ </script>-->
app/etc/modules/Hatimeria_Askforproduct.xml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Hatimeria_Askforproduct>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ <depends>
8
+ <Mage_Checkout />
9
+ </depends>
10
+ </Hatimeria_Askforproduct>
11
+ </modules>
12
+ </config>
app/locale/en_US/template/email/askforproduct_form.html ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--@subject Ask for product@-->
2
+ <!--@vars
3
+ {"var data.name":"Sender",
4
+ "var data.email":"Sender email",
5
+ "var data.telephone":"Sender telephone",
6
+ "var data.comment":"Comment",
7
+ "var data.productname":"Product Name",
8
+ "var data.productsku":"Product SKU",
9
+ "var data.reference_url":"Product URL"}
10
+ @-->
11
+
12
+ Name {{var data.name}}
13
+ E-mail: {{var data.email}}
14
+ Telephone: {{var data.telephone}}
15
+
16
+ Product: {{var data.productname}}, sku:{{var data.productsku}}
17
+ Product URL: {{var data.reference_url}}
18
+
19
+ Comment: {{var data.comment}}
package.xml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Hatimeria_AskForProduct</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.opensource.org/licenses/OSL-3.0">OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Ask for product button on product page view/product list which redirect to Ask for product form.</summary>
10
+ <description>On the admin section in product card you can find a ask for product feature. You can enable/disable possibility to ask for product (in manage products page administator can select product(s) and set update attributes when you can find Ask for product attribute to enable/disable)
11
+
12
+ The module check if ask for product attribute is enabled and add to the product page/products list possibility to inquiry about the product. When customer click this inquiry module redirect to ask for product form.
13
+
14
+ Module settings can be found on the sytem/configuration page int the Ask or product tab.
15
+ There you can find:
16
+ - possibility to on/off module
17
+ - display on the product
18
+ - display on the list of products
19
+ - set sender email
20
+ - set sender
21
+ - set e-mail template</description>
22
+ <notes>Ready to listen your opinion</notes>
23
+ <authors><author><name>Hatimeria</name><user>auto-converted</user><email>magento@hatimeria.pl</email></author></authors>
24
+ <date>2011-11-02</date>
25
+ <time>09:50:05</time>
26
+ <contents><target name="magelocale"><dir name="en_US"><dir name="template"><dir name="email"><file name="askforproduct_form.html" hash="7661f014f71f6bdf6003246d88b966d9"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="askforproduct.xml" hash="3c0cbce3d17f6cae768dad39ace8f70f"/></dir><dir name="template"><dir name="askforproduct"><file name="ask_view.phtml" hash="878beaeeafee87f0379e57856aa2a9e7"/><file name="form.phtml" hash="6de7cba77599170c9c65711b437dee6e"/><file name="formajax.phtml" hash="2963f5d2af1b98ce372ab58d537023c1"/></dir></dir></dir><dir name="klimamarket"><dir name="template"><dir name="askforproduct"><file name="form.phtml" hash="5f5a7de06ee0b40c6c3bf914147a4c77"/></dir><dir name="catalog"><dir name="product"><file name="view.phtml" hash="edc81cf69903abdd63b7e7e882cfa689"/></dir></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="default"><dir name="klimamarket"><dir name="css"><dir name="img"><file name="ask.png" hash="43f8f27bf92bb2f821763d4ce3d53c9a"/></dir><file name="askforproduct.css" hash="2dc1d2e56517898f7c3c9303259817e5"/></dir></dir></dir></dir></target><target name="magelocal"><dir name="Hatimeria"><dir name="Askforproduct"><dir name="controllers"><file name="IndexController.php" hash="c422cb3a88762556eb3f248abec9ee70"/></dir><dir name="etc"><file name="adminhtml.xml" hash="95c694e2f4982ee17c6bb6d5ff835097"/><file name="config.xml" hash="45e35fbcdff5139320cf4986b7fbd426"/><file name="system.xml" hash="e89d05513bb6b1f2e2e3a87dceb82ac4"/></dir><dir name="Helper"><file name="Data.php" hash="f77ea4323461248b1793caa8c4afcd2d"/></dir><dir name="Model"><dir name="Resource"><dir name="Eav"><dir name="Mysql4"><file name="Setup.php" hash="fb7d194e99cc4ecce06b07de4d710eb0"/></dir></dir></dir></dir><dir name="sql"><dir name="askforproduct_setup"><file name="mysql4-install-1.0.0.php" hash="2d9028a117ebfa6cd56f912795aae4dc"/></dir></dir><file name="README.txt" hash="9a746e02fca555b307d0dab1e51e7b5e"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Hatimeria_Askforproduct.xml" hash="9db9456adbdb0992c890439e3f08f199"/></dir></target></contents>
27
+ <compatible/>
28
+ <dependencies/>
29
+ </package>
skin/frontend/default/klimamarket/css/askforproduct.css ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #askforproductForm button.button {
2
+ padding: 0 45px 0 0;
3
+ }
4
+
5
+ #ask a {
6
+ width:200px;
7
+ height:35px;
8
+ background:url(img/ask.png);
9
+ text-indent:-999px;
10
+ overflow:hidden;
11
+ display:block;
12
+ border:0;
13
+ margin:0px auto;
14
+ position: relative;
15
+ top: -25px;
16
+ float: right;
17
+ }
18
+
19
+ #askforproductForm label {
20
+ width: 100px;
21
+ padding-right: 20px;
22
+ }
23
+
24
+ #askforproductForm input {
25
+ width: 350px;
26
+ margin-right: 200px;
27
+ float: right;
28
+ }
29
+
30
+ #askforproductForm textarea {
31
+ width: 350px;
32
+ margin-right: 200px;
33
+ float: right;
34
+ }
35
+ #askforproductForm .button-set {
36
+ float: right;
37
+ margin-right: 200px;
38
+ margin-top: 10px;
39
+ }
40
+ #askforproductForm button {
41
+ padding-left: 41px;
42
+ }
43
+ #askforproductForm li {
44
+ height: 25px;
45
+ }
46
+ #askforproductForm .group-select{
47
+ margin-top: 15px;
48
+ }
49
+
50
+ .askforproduct-index-index {
51
+ padding: 0;
52
+ overflow: hidden;
53
+ }
54
+ .askforproduct-index-index .input-box input {
55
+ margin-top: -17px;
56
+ }
57
+ form#askforproductForm .input-box {
58
+ margin-bottom: 10px;
59
+ }
60
+ .askforproduct-index-index .input-box textarea {
61
+ margin-top: 5px;
62
+ }
63
+ form#askforproductForm li {
64
+ margin-bottom: 15px;
65
+ }
66
+ #askforproductForm .validation-advice {
67
+ float:right;
68
+ margin-right: 270px;
69
+ width: 275px;
70
+ }
71
+ #askforproductForm .required {
72
+ color: #FF0000;
73
+ }
skin/frontend/default/klimamarket/css/img/ask.png ADDED
Binary file