Dropfin_Autocomplete - Version 1.0.0

Version Notes

Dropfin Autocomplete Extension

Download this release

Release Info

Developer Dropfin
Extension Dropfin_Autocomplete
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/Dropfin/Autosearch/Helper/Data.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Dropfin
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Academic Free License (AFL 3.0)
9
+ * that is bundled with this package in the file LICENSE_AFL.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/afl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magento.com so we can send you a copy immediately.
15
+ *
16
+ * DISCLAIMER
17
+ *
18
+ * Do not edit or add to this file if you wish to upgrade
19
+ * this extension to newer versions in the future.
20
+ *
21
+ * @category Dropfin
22
+ * @package Autosearch
23
+ * @copyright Copyright (c) Dropfin (http://www.dropfin.com)
24
+ */
25
+
26
+ class Dropfin_Autosearch_Helper_Data extends Mage_Core_Helper_Abstract {
27
+
28
+ const XML_PATH_ENABLED = 'dropfin_autosearch/configurations/enabled';
29
+ const XML_PATH_SEARCHBOX_TEXT = 'dropfin_autosearch/configurations/search_box_text';
30
+ const XML_PATH_SEARCH_MIN_COUNT = 'dropfin_autosearch/configurations/search_min_count';
31
+ const XML_PATH_SEARCH_ITEM_COUNT = 'dropfin_autosearch/configurations/search_item_count';
32
+ const XML_PATH_SUGGESTION_WORD = 'dropfin_autosearch/configurations/suggestion_word';
33
+ const XML_PATH_SUGGESTION_WORD_COUNT = 'dropfin_autosearch/configurations/suggestion_word_count';
34
+ const XML_PATH_SUGGESTION_SEARCH_BOX_SETTINGS = 'dropfin_autosearch/configurations/search_box_settings';
35
+
36
+ public function getResultUrl() {
37
+ return Mage::helper('catalogsearch')->getResultUrl();
38
+ }
39
+
40
+ public function getQueryParamName() {
41
+ return Mage::helper('catalogsearch')->getQueryParamName();
42
+ }
43
+
44
+ public function getMaxQueryLength() {
45
+ return Mage::helper('catalogsearch')->getMaxQueryLength();
46
+ }
47
+
48
+ public function getEscapedQueryText() {
49
+ return Mage::helper('catalogsearch')->getEscapedQueryText();
50
+ }
51
+
52
+ public function getSuggestUrl() {
53
+ return $this->_getUrl('autosearch', array(
54
+ '_secure' => Mage::app()->getFrontController()->getRequest()->isSecure()
55
+ ));
56
+ }
57
+
58
+ public function getSearchBoxDefaultText() {
59
+ return Mage::getStoreConfig(self::XML_PATH_SEARCHBOX_TEXT);
60
+ }
61
+
62
+ public function searchQueryLength() {
63
+ $config = Mage::getStoreConfig(self::XML_PATH_SEARCH_MIN_COUNT);
64
+ $wc = 2;
65
+ if ((int) $config != 0) {
66
+ $wc = (int) $config;
67
+ }
68
+ return $wc;
69
+ }
70
+
71
+ public function getSearchItemCount() {
72
+ $config = Mage::getStoreConfig(self::XML_PATH_SEARCH_ITEM_COUNT);
73
+ $ic = 5;
74
+ if ((int) $config != 0) {
75
+ $ic = (int) $config;
76
+ }
77
+ return $ic;
78
+ }
79
+
80
+ public function getSuggestionWord() {
81
+ return Mage::getStoreConfig(self::XML_PATH_SUGGESTION_WORD);
82
+ }
83
+
84
+ public function getSuggestionWordCount() {
85
+ $config = Mage::getStoreConfig(self::XML_PATH_SUGGESTION_WORD_COUNT);
86
+ $swc = 5;
87
+ if ((int) $config != 0) {
88
+ $swc = (int) $config;
89
+ }
90
+ return $swc;
91
+ }
92
+
93
+ public function getSearchBoxSettings() {
94
+ return Mage::getStoreConfig(self::XML_PATH_SUGGESTION_SEARCH_BOX_SETTINGS);
95
+ }
96
+ }
app/code/community/Dropfin/Autosearch/Model/Settings.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Dropfin
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Academic Free License (AFL 3.0)
9
+ * that is bundled with this package in the file LICENSE_AFL.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/afl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magento.com so we can send you a copy immediately.
15
+ *
16
+ * DISCLAIMER
17
+ *
18
+ * Do not edit or add to this file if you wish to upgrade
19
+ * this extension to newer versions in the future.
20
+ *
21
+ * @category Dropfin
22
+ * @package Autosearch
23
+ * @copyright Copyright (c) Dropfin (http://www.dropfin.com)
24
+ */
25
+
26
+ class Dropfin_Autosearch_Model_Settings
27
+ {
28
+
29
+ /**
30
+ * Options getter
31
+ *
32
+ * @return array
33
+ */
34
+ public function toOptionArray()
35
+ {
36
+ return array(
37
+ array('value' => 1, 'label' => Mage::helper('adminhtml')->__('Product Name')),
38
+ array('value' => 2, 'label' => Mage::helper('adminhtml')->__('Thumb Image')),
39
+ array('value' => 3, 'label' => Mage::helper('adminhtml')->__('Short Description')),
40
+ array('value' => 4, 'label' => Mage::helper('adminhtml')->__('Price'))
41
+ );
42
+ }
43
+
44
+ /**
45
+ * Get options in "key-value" format
46
+ *
47
+ * @return array
48
+ */
49
+ public function toArray()
50
+ {
51
+ return array(
52
+ 1 => Mage::helper('adminhtml')->__('Product Name'),
53
+ 2 => Mage::helper('adminhtml')->__('Thumb Image'),
54
+ 3 => Mage::helper('adminhtml')->__('Short Description'),
55
+ 4 => Mage::helper('adminhtml')->__('Price'),
56
+ );
57
+ }
58
+
59
+ }
app/code/community/Dropfin/Autosearch/controllers/IndexController.php ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Dropfin
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Academic Free License (AFL 3.0)
9
+ * that is bundled with this package in the file LICENSE_AFL.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/afl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magento.com so we can send you a copy immediately.
15
+ *
16
+ * DISCLAIMER
17
+ *
18
+ * Do not edit or add to this file if you wish to upgrade
19
+ * this extension to newer versions in the future.
20
+ *
21
+ * @category Dropfin
22
+ * @package Autosearch
23
+ * @copyright Copyright (c) Dropfin (http://www.dropfin.com)
24
+ */
25
+
26
+ class Dropfin_Autosearch_IndexController extends Mage_Core_Controller_Front_Action {
27
+
28
+ public function IndexAction() {
29
+
30
+ $ic = Mage::helper('dropfin_autosearch')->getSearchItemCount();
31
+ $limit = 5;
32
+ if ((int) $ic != 0) {
33
+ $limit = (int) $ic;
34
+ }
35
+
36
+ $query = Mage::helper('catalogsearch')->getQuery();
37
+ $query->setStoreId(Mage::app()->getStore()->getId());
38
+ if ($query->getRedirect()) {
39
+ $query->save();
40
+ } else {
41
+ $query->prepare();
42
+ }
43
+ Mage::helper('catalogsearch')->checkNotes();
44
+
45
+ $catalogSearchModel = $query->getResultCollection();
46
+ $catalogSearchModel->addAttributeToFilter('visibility', array('neq' => 1));
47
+ $catalogSearchModel->addAttributeToSelect('short_description');
48
+ $catalogSearchModel->addAttributeToSelect('name');
49
+ $catalogSearchModel->addAttributeToSelect('thumbnail');
50
+ $catalogSearchModel->addAttributeToSelect('small_image');
51
+ $catalogSearchModel->addAttributeToSelect('url_key');
52
+
53
+ $resultText = '<div class="auto-suggest-content">';
54
+ if (count($catalogSearchModel) > 0) {
55
+ $resultText .= '<div class="suggest-word-content">';
56
+ $resultText .= '<ul class="suggest-products">';
57
+ $suggestionWord = (int) Mage::helper('dropfin_autosearch')->getSuggestionWord();
58
+ if ($suggestionWord == 1) {
59
+
60
+ $suggests = Mage::helper('catalogsearch')->getSuggestCollection();
61
+ if (count($suggests) > 0) {
62
+
63
+ $slimit = 5;
64
+ $swc = Mage::helper('dropfin_autosearch')->getSuggestionWordCount();
65
+ if ((int) $swc != 0) {
66
+ $slimit = (int) $swc;
67
+ }
68
+
69
+ $sc = 0;
70
+ $resultText .= '<li class="list-title">' . Mage::helper('core')->__('Popular suggestions: ') . '</li>';
71
+ foreach ($suggests as $_suggest) {
72
+ if ($sc < $slimit) {
73
+ $resultText .= "<li class=\"item\" onclick=\"document.getElementById('search').value='{$_suggest->getQueryText()}';document.getElementById('search_mini_form').submit()\">{$_suggest->getQueryText()} <span class=\"amount\">{$_suggest->getNumResults()}</span></li>";
74
+ $sc++;
75
+ } else {
76
+ break;
77
+ }
78
+ }
79
+ }
80
+ }
81
+
82
+ $model = Mage::getModel('catalog/product');
83
+ $searchBox = Mage::helper('dropfin_autosearch')->getSearchBoxSettings();
84
+ $searchBoxSettings = array();
85
+ if ($searchBox != '') {
86
+ $searchBoxSettings = explode(",", $searchBox);
87
+ }
88
+
89
+ $resultText .= '<li class="list-title">' . Mage::helper('core')->__('Products: ') . '</li>';
90
+ $i = 0;
91
+ foreach ($catalogSearchModel as $product) {
92
+
93
+ $i++;
94
+ if ($limit < $i) {
95
+ break;
96
+ }
97
+
98
+ $_product = $model->load($product->getId());
99
+ $productName = $_product->getName();
100
+
101
+ $resultText .= '<li class="item">';
102
+ $resultText .= '<a href="' . $product->getProductUrl() . '">';
103
+
104
+ if (in_array(2, $searchBoxSettings)) {
105
+ $resultText .= '<span class="item-thumbnail">';
106
+ $resultText .= '<img src="' . Mage::helper('catalog/image')->init($_product, 'image')->constrainOnly(TRUE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize(70, 70) . '" alt="' . $productName . '" />';
107
+ $resultText .= '</span>';
108
+ }
109
+
110
+ $resultText .= '<span class="productinfo">';
111
+ if (in_array(1, $searchBoxSettings)) {
112
+ $resultText .= '<span class="title">' . $productName . '</span>';
113
+ }
114
+
115
+ if (in_array(3, $searchBoxSettings)) {
116
+ $short_description = $_product->getShortDescription();
117
+ if(strlen($short_description) > 65){
118
+ $resultText .= '<span class="description">' . substr($short_description, 0, 65) . '...</span>';
119
+ } else{
120
+ $resultText .= '<span class="description">' . $short_description . '</span>';
121
+ }
122
+
123
+ }
124
+
125
+ if (in_array(4, $searchBoxSettings)) {
126
+ $resultText .= '<span class="item-price">' . Mage::helper('core')->currency($product->getFinalPrice()) . '</span>';
127
+ }
128
+ $resultText .= '</span>';
129
+
130
+ $resultText .= '</a>';
131
+ $resultText .= '</li>';
132
+ }
133
+
134
+ if ($limit < count($catalogSearchModel)) {
135
+ $resultText .= '<li class="all-product"><a href="javascript:value(0)" onclick="document.getElementById(\'search_mini_form\').submit()">' . Mage::helper('core')->__('View all products') . '</a></li>';
136
+ }
137
+ $resultText .= '</ul>';
138
+ $resultText .= '</div>';
139
+ } else {
140
+ $resultText .= '<h4>' . Mage::helper('core')->__('No product match') . '</h4>';
141
+ }
142
+ $resultText .= '</div>';
143
+ echo $resultText;
144
+ die;
145
+ }
146
+
147
+ }
app/code/community/Dropfin/Autosearch/etc/adminhtml.xml ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * Dropfin
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Academic Free License (AFL 3.0)
9
+ * that is bundled with this package in the file LICENSE_AFL.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/afl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magento.com so we can send you a copy immediately.
15
+ *
16
+ * DISCLAIMER
17
+ *
18
+ * Do not edit or add to this file if you wish to upgrade
19
+ * this extension to newer versions in the future.
20
+ *
21
+ * @category Dropfin
22
+ * @package Autosearch
23
+ * @copyright Copyright (c) Dropfin (http://www.dropfin.com)
24
+ */
25
+ -->
26
+ <config>
27
+ <menu>
28
+ <system>
29
+ <children>
30
+ <dropfin>
31
+ <title>Dropfin Extensions</title>
32
+ <sort_order>10</sort_order>
33
+ <children>
34
+ <dropfin_autosearch>
35
+ <title>Search Autocomplete</title>
36
+ <action>adminhtml/system_config/edit/section/dropfin_autosearch</action>
37
+ <sort_order>1</sort_order>
38
+ </dropfin_autosearch>
39
+ </children>
40
+ </dropfin>
41
+ </children>
42
+ </system>
43
+ </menu>
44
+ <acl>
45
+ <resources>
46
+ <all>
47
+ <title>Allow Everything</title>
48
+ </all>
49
+ <admin>
50
+ <children>
51
+ <system>
52
+ <children>
53
+ <config>
54
+ <children>
55
+ <dropfin_autosearch>
56
+ <title>Dropfin Autosearch</title>
57
+ </dropfin_autosearch>
58
+ </children>
59
+ </config>
60
+ </children>
61
+ </system>
62
+ </children>
63
+ </admin>
64
+ </resources>
65
+ </acl>
66
+ </config>
app/code/community/Dropfin/Autosearch/etc/config.xml ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * Dropfin
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Academic Free License (AFL 3.0)
9
+ * that is bundled with this package in the file LICENSE_AFL.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/afl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magento.com so we can send you a copy immediately.
15
+ *
16
+ * DISCLAIMER
17
+ *
18
+ * Do not edit or add to this file if you wish to upgrade
19
+ * this extension to newer versions in the future.
20
+ *
21
+ * @category Dropfin
22
+ * @package Autosearch
23
+ * @copyright Copyright (c) Dropfin (http://www.dropfin.com)
24
+ */
25
+ -->
26
+ <config>
27
+ <modules>
28
+ <Dropfin_Autosearch>
29
+ <version>1.0.0</version>
30
+ </Dropfin_Autosearch>
31
+ </modules>
32
+ <default>
33
+ <dropfin_autosearch>
34
+ <configurations module="autosearch">
35
+ <enabled>1</enabled>
36
+ <search_box_text>Search</search_box_text>
37
+ <search_min_count>3</search_min_count>
38
+ <search_box_settings>1</search_box_settings>
39
+ <search_item_count>3</search_item_count>
40
+ <suggestion_word>0</suggestion_word>
41
+ <suggestion_word_count>3</suggestion_word_count>
42
+ </configurations>
43
+ </dropfin_autosearch>
44
+ </default>
45
+ <frontend>
46
+ <routers>
47
+ <dropfin_autosearch>
48
+ <use>standard</use>
49
+ <args>
50
+ <module>Dropfin_Autosearch</module>
51
+ <frontName>autosearch</frontName>
52
+ </args>
53
+ </dropfin_autosearch>
54
+ </routers>
55
+ <layout>
56
+ <updates>
57
+ <dropfin_autosearch>
58
+ <file>dropfin/autosearch.xml</file>
59
+ </dropfin_autosearch>
60
+ </updates>
61
+ </layout>
62
+ </frontend>
63
+ <global>
64
+ <models>
65
+ <autosearch>
66
+ <class>Dropfin_Autosearch_Model</class>
67
+ </autosearch>
68
+ </models>
69
+ <helpers>
70
+ <dropfin_autosearch>
71
+ <class>Dropfin_Autosearch_Helper</class>
72
+ </dropfin_autosearch>
73
+ </helpers>
74
+ </global>
75
+ </config>
app/code/community/Dropfin/Autosearch/etc/system.xml ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * Dropfin
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Academic Free License (AFL 3.0)
9
+ * that is bundled with this package in the file LICENSE_AFL.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/afl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magento.com so we can send you a copy immediately.
15
+ *
16
+ * DISCLAIMER
17
+ *
18
+ * Do not edit or add to this file if you wish to upgrade
19
+ * this extension to newer versions in the future.
20
+ *
21
+ * @category Dropfin
22
+ * @package Autosearch
23
+ * @copyright Copyright (c) Dropfin (http://www.dropfin.com)
24
+ */
25
+ -->
26
+ <config>
27
+ <tabs>
28
+ <dropfin translate="label">
29
+ <label>Dropfin</label>
30
+ <sort_order>150</sort_order>
31
+ </dropfin>
32
+ </tabs>
33
+ <sections>
34
+ <dropfin_autosearch module="dropfin_autosearch">
35
+ <label>Search Autocomplete</label>
36
+ <tab>dropfin</tab>
37
+ <frontend_type>text</frontend_type>
38
+ <sort_order>10</sort_order>
39
+ <show_in_default>1</show_in_default>
40
+ <show_in_website>1</show_in_website>
41
+ <show_in_store>1</show_in_store>
42
+ <groups>
43
+
44
+ <configurations translate="label" module="dropfin_autosearch">
45
+ <label>Search Autocomplete Configuration</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
+ <enabled translate="label">
53
+ <label>Enable</label>
54
+ <frontend_type>select</frontend_type>
55
+ <source_model>adminhtml/system_config_source_yesno</source_model>
56
+ <sort_order>1</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
+ </enabled>
61
+
62
+ <search_box_text translate="label">
63
+ <label>Search Box Default Text </label>
64
+ <frontend_type>text</frontend_type>
65
+ <sort_order>2</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
+ <comment>Default text message on search box</comment>
70
+ <depends>
71
+ <enabled>1</enabled>
72
+ </depends>
73
+ <validate>required-entry</validate>
74
+ </search_box_text>
75
+
76
+ <search_min_count translate="label">
77
+ <label>Minimum Number of Characters to Search</label>
78
+ <frontend_type>text</frontend_type>
79
+ <sort_order>3</sort_order>
80
+ <show_in_default>1</show_in_default>
81
+ <show_in_website>1</show_in_website>
82
+ <show_in_store>1</show_in_store>
83
+ <depends>
84
+ <enabled>1</enabled>
85
+ </depends>
86
+ <validate>required-entry</validate>
87
+ </search_min_count>
88
+
89
+ <search_box_settings translate="label">
90
+ <label>Option to Show in Search Result</label>
91
+ <frontend_type>multiselect</frontend_type>
92
+ <source_model>autosearch/settings</source_model>
93
+ <sort_order>4</sort_order>
94
+ <show_in_default>1</show_in_default>
95
+ <show_in_website>1</show_in_website>
96
+ <show_in_store>1</show_in_store>
97
+ <comment>
98
+ Display selected options in search result. Product Name should be mandatory
99
+ </comment>
100
+ <depends>
101
+ <enabled>1</enabled>
102
+ </depends>
103
+ <validate>required-entry</validate>
104
+ </search_box_settings>
105
+
106
+ <search_item_count translate="label tooltip comment">
107
+ <label>Maximum Number of Items to Show</label>
108
+ <frontend_type>text</frontend_type>
109
+ <sort_order>5</sort_order>
110
+ <show_in_default>1</show_in_default>
111
+ <show_in_website>1</show_in_website>
112
+ <show_in_store>1</show_in_store>
113
+ <comment>No of item list on the filter</comment>
114
+ <depends>
115
+ <enabled>1</enabled>
116
+ </depends>
117
+ <validate>required-entry</validate>
118
+ </search_item_count>
119
+
120
+ <suggestion_word translate="label">
121
+ <label>Show Suggestion Keyword</label>
122
+ <frontend_type>select</frontend_type>
123
+ <source_model>adminhtml/system_config_source_yesno</source_model>
124
+ <active>true</active>
125
+ <sort_order>6</sort_order>
126
+ <show_in_default>1</show_in_default>
127
+ <show_in_website>1</show_in_website>
128
+ <show_in_store>1</show_in_store>
129
+ <depends>
130
+ <enabled>1</enabled>
131
+ </depends>
132
+ <validate>required-entry</validate>
133
+ </suggestion_word>
134
+
135
+ <suggestion_word_count translate="label tooltip comment">
136
+ <label>Suggestion Keyword Count</label>
137
+ <frontend_type>text</frontend_type>
138
+ <sort_order>7</sort_order>
139
+ <show_in_default>1</show_in_default>
140
+ <show_in_website>1</show_in_website>
141
+ <show_in_store>1</show_in_store>
142
+ <comment>No of suggestion keyword item list on the filter</comment>
143
+ <depends>
144
+ <enabled>1</enabled>
145
+ <suggestion_word>1</suggestion_word>
146
+ </depends>
147
+ <validate>required-entry</validate>
148
+ </suggestion_word_count>
149
+ </fields>
150
+ </configurations>
151
+
152
+ </groups>
153
+ </dropfin_autosearch>
154
+ </sections>
155
+ </config>
app/design/frontend/base/default/layout/dropfin/autosearch.xml ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <!--
4
+ /**
5
+ * Dropfin
6
+ *
7
+ * NOTICE OF LICENSE
8
+ *
9
+ * This source file is subject to the Academic Free License (AFL 3.0)
10
+ * that is bundled with this package in the file LICENSE_AFL.txt.
11
+ * It is also available through the world-wide-web at this URL:
12
+ * http://opensource.org/licenses/afl-3.0.php
13
+ * If you did not receive a copy of the license and are unable to
14
+ * obtain it through the world-wide-web, please send an email
15
+ * to license@magento.com so we can send you a copy immediately.
16
+ *
17
+ * DISCLAIMER
18
+ *
19
+ * Do not edit or add to this file if you wish to upgrade
20
+ * this extension to newer versions in the future.
21
+ *
22
+ * @category Dropfin
23
+ * @package Autosearch
24
+ * @copyright Copyright (c) Dropfin (http://www.dropfin.com)
25
+ */
26
+ -->
27
+
28
+ <layout version="1.0">
29
+
30
+ <default>
31
+
32
+ <reference name="head">
33
+ <action method="addItem" ifconfig="dropfin_autosearch/configurations/enabled"><type>skin_js</type><name>dropfin/autosearch/js/autocomplete.js</name></action>
34
+ <action method="addItem" ifconfig="dropfin_autosearch/configurations/enabled"><type>skin_css</type><name>dropfin/autosearch/css/style.css</name></action>
35
+ </reference>
36
+
37
+ <reference name="top.search">
38
+ <action method="setTemplate" ifconfig="dropfin_autosearch/configurations/enabled">
39
+ <template>dropfin/autosearch/autosearch.phtml</template>
40
+ </action>
41
+ </reference>
42
+
43
+ </default>
44
+
45
+ </layout>
46
+
app/design/frontend/base/default/template/dropfin/autosearch/autosearch.phtml ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Dropfin
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Academic Free License (AFL 3.0)
9
+ * that is bundled with this package in the file LICENSE_AFL.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/afl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magento.com so we can send you a copy immediately.
15
+ *
16
+ * DISCLAIMER
17
+ *
18
+ * Do not edit or add to this file if you wish to upgrade
19
+ * this extension to newer versions in the future.
20
+ *
21
+ * @category Dropfin
22
+ * @package Autosearch
23
+ * @copyright Copyright (c) Dropfin (http://www.dropfin.com)
24
+ */
25
+
26
+ $autosearch = $this->helper('dropfin_autosearch');
27
+
28
+ $magento_version = Mage::getVersion();
29
+ $magento_version = explode('.', $magento_version);
30
+ ?>
31
+ <form id="search_mini_form" action="<?php echo $autosearch->getResultUrl() ?>" method="get">
32
+ <?php
33
+ if($magento_version[1] == '9'){
34
+ $className = 'input-box';
35
+ }
36
+ else{
37
+ $className = 'form-search';
38
+ }
39
+ ?>
40
+ <div class="<?php echo $className;?>">
41
+ <label for="search"><?php echo $this->__('Search:') ?></label>
42
+ <input id="search" type="text" name="<?php echo $autosearch->getQueryParamName() ?>" value="<?php echo $autosearch->getEscapedQueryText() ?>" class="input-text required-entry" maxlength="<?php echo $autosearch->getMaxQueryLength();?>" placeholder="<?php echo $autosearch->getSearchBoxDefaultText() ?>" />
43
+ <button type="submit" title="<?php echo $this->__('Search') ?>" class="button search-button"><span><span><?php echo $this->__('Search') ?></span></span></button>
44
+ <div id="auto_search_loader" style="display: none;">
45
+ <img alt="" src="<?php echo $this->getSkinUrl('dropfin/autosearch/images/ajax-loader.gif');?>">
46
+ </div>
47
+ <div id="search_autocomplete" class="search-autocomplete"></div>
48
+ </div>
49
+ <script type="text/javascript">
50
+ //<![CDATA[
51
+ var searchForms = new autoSearchForm('search_mini_form', 'search', '<?php echo $autosearch->getSearchBoxDefaultText() ?>');
52
+ searchForms.initAutocomplete('<?php echo $autosearch->getSuggestUrl() ?>', 'search_autocomplete', '<?php echo $autosearch->searchQueryLength() ?>');
53
+ //]]>
54
+ </script>
55
+ </form>
app/etc/modules/Dropfin_Autosearch.xml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Dropfin
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Academic Free License (AFL 3.0)
9
+ * that is bundled with this package in the file LICENSE_AFL.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/afl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magento.com so we can send you a copy immediately.
15
+ *
16
+ * DISCLAIMER
17
+ *
18
+ * Do not edit or add to this file if you wish to upgrade
19
+ * this extension to newer versions in the future.
20
+ *
21
+ * @category Dropfin
22
+ * @package Autosearch
23
+ * @copyright Copyright (c) Dropfin (http://www.dropfin.com)
24
+ */
25
+ -->
26
+ <config>
27
+ <modules>
28
+ <Dropfin_Autosearch>
29
+ <active>true</active>
30
+ <codePool>community</codePool>
31
+ </Dropfin_Autosearch>
32
+ </modules>
33
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Dropfin_Autocomplete</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v.3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Dropfin Autocomplete Extension</summary>
10
+ <description>Dropfin Autocomplete Extension</description>
11
+ <notes>Dropfin Autocomplete Extension</notes>
12
+ <authors><author><name>Dropfin</name><user>Dropfin</user><email>t.balamani88@gmail.com</email></author></authors>
13
+ <date>2016-01-25</date>
14
+ <time>16:21:39</time>
15
+ <contents><target name="magecommunity"><dir name="Dropfin"><dir name="Autosearch"><dir name="Helper"><file name="Data.php" hash="4996f6a62009f2b0888f01695569efe9"/></dir><dir name="Model"><file name="Settings.php" hash="30458a0aa2f0f4d9386b08bf3d0e8572"/></dir><dir name="controllers"><file name="IndexController.php" hash="1320ecc9d8c4542e14e63ab050c6f5cc"/></dir><dir name="etc"><file name="adminhtml.xml" hash="4196211955aa93b4bde0b2c48161abbd"/><file name="config.xml" hash="96a499e5d0fddfeeb96d6775bae518c1"/><file name="system.xml" hash="3b7e7b810a23eb99d0f8079bc2b05095"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="dropfin"><file name="autosearch.xml" hash="6106085b934d39ac03037cbbabe33fac"/></dir></dir><dir name="template"><dir name="dropfin"><dir name="autosearch"><file name="autosearch.phtml" hash="cce00456e18c069dc5fdbc6196203c26"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Dropfin_Autosearch.xml" hash="45d2c3f81a2c02b38da1ad220d7d47b7"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="dropfin"><dir name="autosearch"><dir><dir name="css"><file name="style.css" hash="376350d778267afb0ee72a734e0a38c5"/></dir><dir name="images"><file name="ajax-loader.gif" hash="dd6b7b0bf5c3af22499abc0a9ee1e1b2"/></dir><dir name="js"><file name="autocomplete.js" hash="c5a2b7da3fe25024ec960dcf010421eb"/></dir></dir></dir></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>
skin/frontend/base/default/dropfin/autosearch/css/style.css ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #auto_search_loader {
2
+ position: absolute;
3
+ }
4
+
5
+ #search_mini_form .search-autocomplete {
6
+ left: 0 !important;
7
+ overflow: visible !important;
8
+ position: relative !important;
9
+ z-index: 200;
10
+ }
11
+
12
+ #search_mini_form .form-search #auto_search_loader {
13
+ left: 237px;
14
+ top: 3px;
15
+ }
16
+
17
+ #search_mini_form .form-search .search-autocomplete {
18
+ top: 26px !important;
19
+ width: 94% !important;
20
+ }
21
+
22
+ #search_mini_form .input-box #auto_search_loader {
23
+ left: 90%;
24
+ top: 25%;
25
+ }
26
+
27
+ #search_mini_form .input-box .search-autocomplete {
28
+ top: 15px !important;
29
+ width: 100% !important;
30
+ }
31
+
32
+ #search_mini_form .search-autocomplete ul, #search_mini_form .search-autocomplete h4 {
33
+ -webkit-border-radius: 2px;
34
+ -moz-border-radius: 2px;
35
+ -ms-border-radius: 2px;
36
+ -o-border-radius: 2px;
37
+ border-radius: 2px;
38
+ background-color: #FFFFFF;
39
+ border: 1px solid #3399cc;
40
+ left: 0;
41
+ padding-left: 0;
42
+ position: absolute;
43
+ top: 0;
44
+ width: 100%;
45
+ }
46
+
47
+ #search_mini_form .search-autocomplete h4 {
48
+ padding: 10px 0px;
49
+ text-align: center;
50
+ }
51
+
52
+ #search_mini_form .search-autocomplete li.all-product {
53
+ display: block;
54
+ margin: auto;
55
+ padding: 0;
56
+ height: 36px;
57
+ border: none;
58
+ background: #069;
59
+ color: #fff;
60
+ text-align: center;
61
+ text-decoration: none !important;
62
+ font-weight: bold;
63
+ font-size: 14px;
64
+ line-height: 36px;
65
+ cursor: pointer;
66
+ }
67
+
68
+ #search_mini_form .search-autocomplete li.all-product a {
69
+ color: #fff;
70
+ text-decoration: none;
71
+ }
72
+
73
+ #search_mini_form .search-autocomplete li.all-product a:hover {
74
+ text-decoration: underline;
75
+ }
76
+
77
+ #search_mini_form .search-autocomplete .list-title {
78
+ display: block;
79
+ padding: 5px 10px;
80
+ color: #636363;
81
+ text-transform: uppercase;
82
+ font-size: 14px;
83
+ line-height: 14px;
84
+ border-top: 1px solid #eeeeee;
85
+ border-bottom: 1px solid #eeeeee;
86
+ background: #f7f7f7;
87
+ cursor: auto;
88
+ }
89
+
90
+ #search_mini_form .search-autocomplete .item:hover {
91
+ background-color: #f7f7f7;
92
+ }
93
+
94
+ #search_mini_form .search-autocomplete ul li {
95
+ border-bottom: 1px solid #f4f4f4;
96
+ color: #3399cc;
97
+ cursor: pointer;
98
+ font-size: 12px;
99
+ padding: 4px 6px;
100
+ text-align: left;
101
+ overflow: hidden;
102
+ }
103
+
104
+ #search_mini_form .search-autocomplete .item a {
105
+ clear: both;
106
+ display: block;
107
+ padding: 2px;
108
+ outline: none;
109
+ opacity: 1;
110
+ text-decoration: none;
111
+ -moz-outline-style: none;
112
+ overflow: hidden;
113
+ }
114
+
115
+ #search_mini_form .search-autocomplete .item-thumbnail {
116
+ display: inline-block;
117
+ float: left;
118
+ margin: 5px 5px 5px 0px;
119
+ text-align: center;
120
+ width: 70px;
121
+ }
122
+
123
+ #search_mini_form .search-autocomplete .item-thumbnail img {
124
+ max-width: 70px;
125
+ max-height: 70px;
126
+ }
127
+
128
+ #search_mini_form .search-autocomplete .productinfo {
129
+ display: block;
130
+ overflow: hidden;
131
+ }
132
+
133
+ #search_mini_form .search-autocomplete .productinfo .title {
134
+ display: block;
135
+ color: #0288d1;
136
+ font-weight: bold;
137
+ font-size: 100%;
138
+ margin-top: 3px;
139
+ }
140
+
141
+ #search_mini_form .search-autocomplete .productinfo .description {
142
+ display: block;
143
+ margin-top: 5px;
144
+ color: #747474;
145
+ }
146
+
147
+ #search_mini_form .search-autocomplete .productinfo .item-price {
148
+ display: block;
149
+ margin-top: 6px;
150
+ font-weight: bold;
151
+ font-size: 100%;
152
+ }
skin/frontend/base/default/dropfin/autosearch/images/ajax-loader.gif ADDED
Binary file
skin/frontend/base/default/dropfin/autosearch/js/autocomplete.js ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Dropfin
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Academic Free License (AFL 3.0)
7
+ * that is bundled with this package in the file LICENSE_AFL.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/afl-3.0.php
10
+ * If you did not receive a copy of the license and are unable to
11
+ * obtain it through the world-wide-web, please send an email
12
+ * to license@magento.com so we can send you a copy immediately.
13
+ *
14
+ * DISCLAIMER
15
+ *
16
+ * Do not edit or add to this file if you wish to upgrade
17
+ * this extension to newer versions in the future.
18
+ *
19
+ * @category Dropfin
20
+ * @package Autosearch
21
+ * @copyright Copyright (c) Dropfin (http://www.dropfin.com)
22
+ */
23
+
24
+ if (Varien && typeof(Varien) === "object" && "searchForm" in Varien) {
25
+ Varien.searchForm.prototype.initAutocomplete = function(){}
26
+ }
27
+
28
+ var autoSearchForm = Class.create();
29
+ autoSearchForm.prototype = {
30
+ initialize : function(form, field, emptyText) {
31
+ this.form = $(form);
32
+ this.field = $(field);
33
+ this.emptyText = emptyText;
34
+ this.url = null;
35
+ this.destinationElement = null;
36
+ this.length = 0;
37
+
38
+ Event.observe(this.form, 'submit', this.submit.bind(this));
39
+ Event.observe(this.field, 'focus', this.focus.bind(this));
40
+ Event.observe(this.field, 'blur', this.blur.bind(this));
41
+ this.blur();
42
+ },
43
+
44
+ submit : function(event) {
45
+ if (this.field.value == this.emptyText || this.field.value == '') {
46
+ Event.stop(event);
47
+ return false;
48
+ }
49
+ return true;
50
+ },
51
+
52
+ focus : function(event) {
53
+ if (this.field.value == this.emptyText) {
54
+ this.field.value = '';
55
+ }
56
+
57
+ },
58
+
59
+ blur : function(event) {
60
+ if (this.field.value == '') {
61
+ this.field.value = this.emptyText;
62
+ }
63
+ },
64
+
65
+ initAutocomplete : function(url, destinationElement, wcount) {
66
+ new Ajax.Autocompleter(
67
+ this.field,
68
+ destinationElement,
69
+ url,
70
+ {
71
+ paramName: this.field.name,
72
+ method: 'get',
73
+ minChars: wcount,
74
+ updateElement: this._selectAutocompleteItem.bind(this),
75
+ indicator: 'auto_search_loader',
76
+ onShow : function(element, update) {
77
+ if(!update.style.position || update.style.position=='absolute') {
78
+ update.style.position = 'absolute';
79
+ Position.clone(element, update, {
80
+ setHeight: false,
81
+ offsetTop: element.offsetHeight
82
+ });
83
+ }
84
+ Effect.Appear(update,{duration:0});
85
+ }
86
+ }
87
+ );
88
+ },
89
+
90
+ _selectAutocompleteItem : function(element) {
91
+ if (element.title) {
92
+ this.field.value = element.title;
93
+ }
94
+ this.form.submit();
95
+ }
96
+ }