Magebuzz_Free_Text_Search - Version 0.1.2

Version Notes

Magento 0.1.2 supports all Magento versions

Download this release

Release Info

Developer Magebuzz
Extension Magebuzz_Free_Text_Search
Version 0.1.2
Comparing to
See all releases


Version 0.1.2

Files changed (28) hide show
  1. app/code/community/Magebuzz/Freetextsearch/Block/Freetextsearch.php +17 -0
  2. app/code/community/Magebuzz/Freetextsearch/Block/Result.php +28 -0
  3. app/code/community/Magebuzz/Freetextsearch/Helper/Data.php +200 -0
  4. app/code/community/Magebuzz/Freetextsearch/Helper/Quicksearch.php +158 -0
  5. app/code/community/Magebuzz/Freetextsearch/Model/Freetextsearch.php +10 -0
  6. app/code/community/Magebuzz/Freetextsearch/Model/Mysql4/Freetextsearch.php +10 -0
  7. app/code/community/Magebuzz/Freetextsearch/Model/Mysql4/Freetextsearch/Collection.php +10 -0
  8. app/code/community/Magebuzz/Freetextsearch/Model/Session.php +10 -0
  9. app/code/community/Magebuzz/Freetextsearch/Model/Status.php +15 -0
  10. app/code/community/Magebuzz/Freetextsearch/Model/Wysiwyg/Config.php +34 -0
  11. app/code/community/Magebuzz/Freetextsearch/controllers/IndexController.php +64 -0
  12. app/code/community/Magebuzz/Freetextsearch/controllers/SearchController.php +98 -0
  13. app/code/community/Magebuzz/Freetextsearch/etc/adminhtml.xml +26 -0
  14. app/code/community/Magebuzz/Freetextsearch/etc/config.xml +135 -0
  15. app/code/community/Magebuzz/Freetextsearch/etc/system.xml +165 -0
  16. app/design/frontend/base/default/layout/freetextsearch.xml +38 -0
  17. app/design/frontend/base/default/template/freetextsearch/form.phtml +47 -0
  18. app/design/frontend/base/default/template/freetextsearch/result.phtml +37 -0
  19. app/etc/modules/Magebuzz_Freetextsearch.xml +9 -0
  20. app/locale/en_US/Magebuzz_Freetextsearch.csv +19 -0
  21. js/magebuzz/quicksearch.js +77 -0
  22. package.xml +18 -0
  23. skin/frontend/base/default/css/magebuzz/freetextsearch.css +42 -0
  24. skin/frontend/base/default/css/magebuzz/images/close-icon.png +0 -0
  25. skin/frontend/base/default/css/magebuzz/images/list-icon.png +0 -0
  26. skin/frontend/base/default/css/magebuzz/images/search-loading.gif +0 -0
  27. skin/frontend/base/default/css/magebuzz/images/search_complete.png +0 -0
  28. skin/frontend/base/default/css/magebuzz/quicksearch.css +95 -0
app/code/community/Magebuzz/Freetextsearch/Block/Freetextsearch.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Magebuzz_Freetextsearch_Block_Freetextsearch extends Mage_Core_Block_Template
3
+ {
4
+ public function _prepareLayout()
5
+ {
6
+ return parent::_prepareLayout();
7
+ }
8
+
9
+ public function getFreetextsearch()
10
+ {
11
+ if (!$this->hasData('freetextsearch')) {
12
+ $this->setData('freetextsearch', Mage::registry('freetextsearch'));
13
+ }
14
+ return $this->getData('freetextsearch');
15
+
16
+ }
17
+ }
app/code/community/Magebuzz/Freetextsearch/Block/Result.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Magebuzz_Freetextsearch_Block_Result extends Mage_Core_Block_Template
3
+ {
4
+ public function _prepareLayout()
5
+ {
6
+ $keyword = Mage::registry("keyword");
7
+ $this->getLayout()->getBlock('head')->setTitle(Mage::helper('freetextsearch')->__('Search result for "%s"', $keyword));
8
+ return parent::_prepareLayout();
9
+ }
10
+ public function getProductHtml() {
11
+ return $this->getChildHtml('freetextsearch.product');
12
+ }
13
+ public function setListCollection() {
14
+ $this->getChild('freetextsearch.product')
15
+ ->setCollection($this->_getProductCollection());
16
+ }
17
+ protected function _getProductCollection(){
18
+ $results = Mage::registry("result");
19
+ $productIds = $results['product'];
20
+ $collection = Mage::getModel('catalog/product')->getCollection()
21
+ ->addAttributeToSelect('*')
22
+ ->addAttributeToFilter('entity_id', array('in' => $productIds));
23
+ $collection->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds());
24
+
25
+ return $collection;
26
+
27
+ }
28
+ }
app/code/community/Magebuzz/Freetextsearch/Helper/Data.php ADDED
@@ -0,0 +1,200 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magebuzz_Freetextsearch_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+ public function getResultUrl(){
6
+ $enableQuickSearch = $this->enableQuickSearch();
7
+ if($enableQuickSearch){
8
+ return $this->getUrl('freetextsearch/search/ajaxsearch');
9
+ }
10
+ else{
11
+ return $this->getUrl('freetextsearch/search/result');
12
+ }
13
+ }
14
+ public function enableQuickSearch(){
15
+ return Mage::getStoreConfig('freetextsearch/general/enable_quick_search');
16
+ }
17
+ public function isShowPageContent(){
18
+ return Mage::getStoreConfig('freetextsearch/search_setting/cms_pages_content');
19
+ }
20
+ public function getNumberResults(){
21
+ return (int)Mage::getStoreConfig('freetextsearch/quick_search_setting/number_results');
22
+ }
23
+ public function limitCharDescription(){
24
+ return (int)Mage::getStoreConfig('freetextsearch/quick_search_setting/limit_character_product_desc');
25
+ }
26
+ public function getSearchResultNotice(){
27
+ return Mage::getStoreConfig('freetextsearch/search_setting/search_result_notice');
28
+ }
29
+ public function prShortText($str,$numberChar){
30
+ $short_text = substr($str, 0, $numberChar);
31
+ if(substr($short_text, 0, strrpos($short_text, ' '))!=''){
32
+ $short_text = substr($short_text, 0, strrpos($short_text, ' '));
33
+ $short_text = $short_text.'...';
34
+ }
35
+ return $short_text;
36
+ }
37
+ public function getSearchResultProducts($keyword){
38
+ $result = array();
39
+ $limit = Mage::getStoreConfig('freetextsearch/search_setting/number_results');
40
+ /* Default search by Product Name */
41
+ $products = $this->searchProductByAttribute($keyword,"name");
42
+ $product_count = count($products);
43
+ if($product_count)
44
+ {
45
+ foreach($products as $productId)
46
+ {
47
+ $result[] = $productId;
48
+ }
49
+ }
50
+ /* Search Product By Sku */
51
+ /*-----------------------*/
52
+ $searchBySku = Mage::getStoreConfig('freetextsearch/search_setting/search_by_sku');
53
+ if($searchBySku){
54
+ $product_list_sku = $this->searchProductByAttribute($keyword,"sku");
55
+ if(count($product_list_sku))
56
+ {
57
+ foreach($product_list_sku as $productId)
58
+ {
59
+ if (!in_array($productId, $result)) {
60
+ $result[] = $productId;
61
+ }
62
+ }
63
+ }
64
+ }
65
+
66
+ /* Search Product By Manufacturer */
67
+ /*-----------------------*/
68
+ $searchByManufacturer = Mage::getStoreConfig('freetextsearch/search_setting/search_by_manufacturer');
69
+ if($searchByManufacturer){
70
+ $product_list_manufacturer = $this->searchProductByManufacturer($keyword);
71
+ if(count($product_list_manufacturer))
72
+ {
73
+ foreach($product_list_manufacturer as $productId)
74
+ {
75
+ if (!in_array($productId, $result)) {
76
+ $result[] = $productId;
77
+ }
78
+ }
79
+ }
80
+ }
81
+
82
+ /* Search Product By Description */
83
+ /*-----------------------*/
84
+ $searchByDescription = Mage::getStoreConfig('freetextsearch/search_setting/search_by_desc');
85
+ if($searchByDescription){
86
+ $product_list_desc = $this->searchProductByAttribute($keyword,"description");
87
+ if(count($product_list_desc))
88
+ {
89
+ foreach($product_list_desc as $productId)
90
+ {
91
+ if (!in_array($productId, $result)) {
92
+ $result[] = $productId;
93
+ }
94
+ }
95
+ }
96
+ }
97
+ return $result;
98
+ }
99
+ public function getSearchCMSPages($keyword){
100
+ $result = array();
101
+ $storeId = Mage::app()->getStore()->getId();
102
+ $cmspages = Mage::getModel('cms/page')->getCollection()
103
+ ->addFieldToFilter("is_active",1)
104
+ ->addFieldToFilter('title',array('like'=>'%'. $keyword.'%'))
105
+ ->setCurPage(1)
106
+ ->setOrder('title','ASC');
107
+ $cmspages->load();
108
+ if(count($cmspages))
109
+ {
110
+ foreach($cmspages as $_page)
111
+ {
112
+ $result[] = $_page->getId();
113
+ }
114
+ }
115
+ return $result;
116
+ }
117
+
118
+
119
+ /*
120
+ * Get Manufacturer Ids by keyword
121
+ */
122
+ public function getManufacturerIds($keyword) {
123
+ $attributeId = Mage::getResourceModel('eav/entity_attribute')->getIdByCode('catalog_product','manufacturer');
124
+ $manufacturerIds = array();
125
+ $read = Mage::getSingleton('core/resource')->getConnection('core_read');
126
+ /* Create search query from attribute option table by keyword */
127
+ $searchQuery = "SELECT DISTINCT eao.option_id";
128
+ $searchQuery .= " FROM ".Mage::getSingleton('core/resource')->getTableName('eav_attribute_option_value')." AS eaov";
129
+ $searchQuery .= " JOIN ".Mage::getSingleton('core/resource')->getTableName('eav_attribute_option')." AS eao ON eaov.option_id = eao.option_id";
130
+ $searchQuery .= " WHERE eaov.value LIKE '%".$keyword."' AND eao.attribute_id = '".$attributeId."'";
131
+
132
+ /* Read results */
133
+ $result = $read->fetchAll($searchQuery);
134
+
135
+ foreach($result as $item) {
136
+ array_push($manufacturerIds, $item['option_id']);
137
+ }
138
+ return $manufacturerIds;
139
+ }
140
+
141
+ public function searchProductByManufacturer($keyword)
142
+ {
143
+ $attributeId = Mage::getResourceModel('eav/entity_attribute')
144
+ ->getIdByCode('catalog_product','manufacturer');
145
+ //get manufacturer id by keyword
146
+ $manufacturerIds = $this->getManufacturerIds($keyword);
147
+ $attribute = Mage::getModel('catalog/resource_eav_attribute')->load($attributeId);
148
+ $attributeOptions = $attribute ->getSource()->getAllOptions();
149
+ $result = array();
150
+ $storeId = Mage::app()->getStore()->getId();
151
+
152
+ $products = Mage::getModel('catalog/product')->getCollection()
153
+ ->addAttributeToSelect('*')
154
+ ->setStoreId($storeId)
155
+ ->addStoreFilter($storeId)
156
+ ->addFieldToFilter("status", '1')
157
+ ->addFieldToFilter('manufacturer', array('in' => $manufacturerIds))
158
+ ->setCurPage(1)
159
+ ->setOrder('name','ASC');
160
+
161
+ Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($products);
162
+ Mage::getSingleton('catalog/product_visibility')->addVisibleInSiteFilterToCollection($products);
163
+ $products->load();
164
+
165
+ if(count($products))
166
+ {
167
+ foreach($products as $product)
168
+ {
169
+ $result[] = $product->getId();
170
+ }
171
+ }
172
+ return $result;
173
+ }
174
+ public function searchProductByAttribute($keyword,$attribute)
175
+ {
176
+ $result = array();
177
+ $storeId = Mage::app()->getStore()->getId();
178
+ $products = Mage::getModel('catalog/product')->getCollection()
179
+ ->addAttributeToSelect('*')
180
+ ->setStoreId($storeId)
181
+ ->addStoreFilter($storeId)
182
+ ->addFieldToFilter("status",1)
183
+ ->addFieldToFilter($attribute,array('like'=>'%'. $keyword.'%'))
184
+ ->setCurPage(1)
185
+ ->setOrder('name','ASC');
186
+
187
+ Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($products);
188
+ Mage::getSingleton('catalog/product_visibility')->addVisibleInSiteFilterToCollection($products);
189
+ $products->load();
190
+
191
+ if(count($products))
192
+ {
193
+ foreach($products as $product)
194
+ {
195
+ $result[] = $product->getId();
196
+ }
197
+ }
198
+ return $result;
199
+ }
200
+ }
app/code/community/Magebuzz/Freetextsearch/Helper/Quicksearch.php ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magebuzz_Freetextsearch_Helper_Quicksearch extends Mage_Core_Helper_Abstract
4
+ {
5
+ public function getSearchResultProducts($keyword){
6
+ $result = array();
7
+ $limit = Mage::getStoreConfig('freetextsearch/search_setting/number_results');
8
+ /* Default search by Product Name */
9
+ $products = $this->searchProductByAttribute($keyword,"name");
10
+ $product_count = count($products);
11
+ if($product_count)
12
+ {
13
+ foreach($products as $productId)
14
+ {
15
+ $result[] = $productId;
16
+ }
17
+ }
18
+ /* Search Product By Sku */
19
+ /*-----------------------*/
20
+ $searchBySku = Mage::getStoreConfig('freetextsearch/search_setting/search_by_sku');
21
+ if($searchBySku){
22
+ $product_list_sku = $this->searchProductByAttribute($keyword,"sku");
23
+ if(count($product_list_sku))
24
+ {
25
+ foreach($product_list_sku as $productId)
26
+ {
27
+ $result[] = $productId;
28
+ $product_count++;
29
+ if($product_count >= $limit)
30
+ {
31
+ break;
32
+ }
33
+ }
34
+ }
35
+ }
36
+
37
+ /* Search Product By Manufacturer */
38
+ /*-----------------------*/
39
+ $searchByManufacturer = Mage::getStoreConfig('freetextsearch/search_setting/search_by_manufacturer');
40
+ if($searchByManufacturer){
41
+ $product_list_manufacturer = $this->searchProductByManufacturer($keyword);
42
+ if(count($product_list_manufacturer))
43
+ {
44
+ foreach($product_list_manufacturer as $productId)
45
+ {
46
+ $result[] = $productId;
47
+ $product_count++;
48
+ if($product_count >= $limit)
49
+ {
50
+ break;
51
+ }
52
+ }
53
+ }
54
+ }
55
+ return $result;
56
+ }
57
+ public function getSearchCMSPages($keyword){
58
+ $result = array();
59
+ $storeId = Mage::app()->getStore()->getId();
60
+ $cmspages = Mage::getModel('cms/page')->getCollection()
61
+ ->addFieldToFilter("is_active",1)
62
+ ->addFieldToFilter('title',array('like'=>'%'. $keyword.'%'))
63
+ ->setCurPage(1)
64
+ ->setOrder('title','ASC');
65
+ $cmspages->load();
66
+ if(count($cmspages))
67
+ {
68
+ foreach($cmspages as $_page)
69
+ {
70
+ $result[] = $_page->getId();
71
+ }
72
+ }
73
+ return $result;
74
+ }
75
+
76
+
77
+ /*
78
+ * Get Manufacturer Ids by keyword
79
+ */
80
+ public function getManufacturerIds($keyword) {
81
+ $attributeId = Mage::getResourceModel('eav/entity_attribute')->getIdByCode('catalog_product','manufacturer');
82
+ $manufacturerIds = array();
83
+ $read = Mage::getSingleton('core/resource')->getConnection('core_read');
84
+ /* Create search query from attribute option table by keyword */
85
+ $searchQuery = "SELECT DISTINCT eao.option_id";
86
+ $searchQuery .= " FROM ".Mage::getSingleton('core/resource')->getTableName('eav_attribute_option_value')." AS eaov";
87
+ $searchQuery .= " JOIN ".Mage::getSingleton('core/resource')->getTableName('eav_attribute_option')." AS eao ON eaov.option_id = eao.option_id";
88
+ $searchQuery .= " WHERE eaov.value LIKE '%".$keyword."' AND eao.attribute_id = '".$attributeId."'";
89
+
90
+ /* Read results */
91
+ $result = $read->fetchAll($searchQuery);
92
+
93
+ foreach($result as $item) {
94
+ array_push($manufacturerIds, $item['option_id']);
95
+ }
96
+ return $manufacturerIds;
97
+ }
98
+
99
+ public function searchProductByManufacturer($keyword)
100
+ {
101
+ $attributeId = Mage::getResourceModel('eav/entity_attribute')
102
+ ->getIdByCode('catalog_product','manufacturer');
103
+ //get manufacturer id by keyword
104
+ $manufacturerIds = $this->getManufacturerIds($keyword);
105
+ $attribute = Mage::getModel('catalog/resource_eav_attribute')->load($attributeId);
106
+ $attributeOptions = $attribute ->getSource()->getAllOptions();
107
+ $result = array();
108
+ $storeId = Mage::app()->getStore()->getId();
109
+
110
+ $products = Mage::getModel('catalog/product')->getCollection()
111
+ ->addAttributeToSelect('*')
112
+ ->setStoreId($storeId)
113
+ ->addStoreFilter($storeId)
114
+ ->addFieldToFilter("status", '1')
115
+ ->addFieldToFilter('manufacturer', array('in' => $manufacturerIds))
116
+ ->setCurPage(1)
117
+ ->setOrder('name','ASC');
118
+
119
+ Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($products);
120
+ Mage::getSingleton('catalog/product_visibility')->addVisibleInSiteFilterToCollection($products);
121
+ $products->load();
122
+
123
+ if(count($products))
124
+ {
125
+ foreach($products as $product)
126
+ {
127
+ $result[] = $product->getId();
128
+ }
129
+ }
130
+ return $result;
131
+ }
132
+ public function searchProductByAttribute($keyword,$attribute)
133
+ {
134
+ $result = array();
135
+ $storeId = Mage::app()->getStore()->getId();
136
+ $products = Mage::getModel('catalog/product')->getCollection()
137
+ ->addAttributeToSelect('*')
138
+ ->setStoreId($storeId)
139
+ ->addStoreFilter($storeId)
140
+ ->addFieldToFilter("status",1)
141
+ ->addFieldToFilter($attribute,array('like'=>'%'. $keyword.'%'))
142
+ ->setCurPage(1)
143
+ ->setOrder('name','ASC');
144
+
145
+ Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($products);
146
+ Mage::getSingleton('catalog/product_visibility')->addVisibleInSiteFilterToCollection($products);
147
+ $products->load();
148
+
149
+ if(count($products))
150
+ {
151
+ foreach($products as $product)
152
+ {
153
+ $result[] = $product->getId();
154
+ }
155
+ }
156
+ return $result;
157
+ }
158
+ }
app/code/community/Magebuzz/Freetextsearch/Model/Freetextsearch.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magebuzz_Freetextsearch_Model_Freetextsearch extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('freetextsearch/freetextsearch');
9
+ }
10
+ }
app/code/community/Magebuzz/Freetextsearch/Model/Mysql4/Freetextsearch.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magebuzz_Freetextsearch_Model_Mysql4_Freetextsearch extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Note that the freetextsearch_id refers to the key field in your database table.
8
+ $this->_init('freetextsearch/freetextsearch', 'freetextsearch_id');
9
+ }
10
+ }
app/code/community/Magebuzz/Freetextsearch/Model/Mysql4/Freetextsearch/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magebuzz_Freetextsearch_Model_Mysql4_Freetextsearch_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('freetextsearch/freetextsearch');
9
+ }
10
+ }
app/code/community/Magebuzz/Freetextsearch/Model/Session.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magebuzz_Freetextsearch_Model_Session extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('freetextsearch');
9
+ }
10
+ }
app/code/community/Magebuzz/Freetextsearch/Model/Status.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magebuzz_Freetextsearch_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('freetextsearch')->__('Enabled'),
12
+ self::STATUS_DISABLED => Mage::helper('freetextsearch')->__('Disabled')
13
+ );
14
+ }
15
+ }
app/code/community/Magebuzz/Freetextsearch/Model/Wysiwyg/Config.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Magebuzz_Freetextsearch_Model_Wysiwyg_Config extends Mage_Cms_Model_Wysiwyg_Config
3
+ {
4
+ public function getConfig($data = array())
5
+ {
6
+ $config = new Varien_Object();
7
+
8
+ $config->setData(array(
9
+ 'enabled' => $this->isEnabled(),
10
+ 'hidden' => $this->isHidden(),
11
+ 'use_container' => false,
12
+ 'add_variables' => false,
13
+ 'add_widgets' => false,
14
+ 'no_display' => false,
15
+ 'translator' => Mage::helper('cms'),
16
+ 'files_browser_window_url' => Mage::getSingleton('adminhtml/url')->getUrl('adminhtml/cms_wysiwyg_images/index'),
17
+ 'files_browser_window_width' => (int) Mage::getConfig()->getNode('adminhtml/cms/browser/window_width'),
18
+ 'files_browser_window_height' => (int) Mage::getConfig()->getNode('adminhtml/cms/browser/window_height'),
19
+ 'encode_directives' => true,
20
+ 'directives_url' => Mage::getSingleton('adminhtml/url')->getUrl('adminhtml/cms_wysiwyg/directive'),
21
+ 'popup_css' => Mage::getBaseUrl('js').'mage/adminhtml/wysiwyg/tiny_mce/themes/advanced/skins/default/dialog.css',
22
+ 'content_css' => Mage::getBaseUrl('js').'mage/adminhtml/wysiwyg/tiny_mce/themes/advanced/skins/default/content.css',
23
+ 'width' => '100%',
24
+ 'plugins' => array()
25
+ ));
26
+
27
+ $config->setData('directives_url_quoted', preg_quote($config->getData('directives_url')));
28
+
29
+ if (is_array($data)) {
30
+ $config->addData($data);
31
+ }
32
+ return $config;
33
+ }
34
+ }
app/code/community/Magebuzz/Freetextsearch/controllers/IndexController.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Magebuzz_Freetextsearch_IndexController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ public function indexAction() {
5
+ $keyword = urldecode($this->getRequest()->getParam('keyword'));
6
+ $q = urldecode($this->getRequest()->getParam('q'));
7
+ if($q) {
8
+ $keyword = $q;
9
+ }
10
+ Mage::register('keyword',$keyword);
11
+ $this->loadLayout();
12
+ $this->renderLayout();
13
+ }
14
+ public function quicksearchAction() {
15
+ $keyword = urldecode($this->getRequest()->getParam('keyword'));
16
+ $_coreHelper = Mage::helper('core');
17
+
18
+ /* Result - Product */
19
+ $productIds = Mage::helper("freetextsearch")->getSearchResultProducts($keyword);
20
+ $results = array();
21
+ $items = array();
22
+ $thumb_width = Mage::getStoreConfig('freetextsearch/quick_search_setting/thumbnail_product_image_width');
23
+ /* Result - Product & CMS */
24
+ $allowSearchCMS = Mage::getStoreConfig('freetextsearch/search_setting/cms_pages_allow');
25
+ $html = "";
26
+ $html .= "<ul class='list-items'>";
27
+ if(count($productIds) > 0) {
28
+ foreach($productIds as $productId) {
29
+ $html .= "<li class='item product'>";
30
+ $product = Mage::getModel("catalog/product")->load($productId);
31
+ $img = Mage::helper('catalog/image')->init($product, 'image')->resize($thumb_width);
32
+ $img = $img->__toString();
33
+ $price = $_coreHelper->currency($product->getPrice(),true,false);
34
+ $product_url = $product->getProductUrl();
35
+ $product_name = $product->getName();
36
+ $product_desc = $product->getShortDescription();
37
+ $html .= "<a class='product-img' href='".$product_url."' title='".$product_name."' alt='".$product_name."' target='_blank'><img src='". $img ."' title='".$product_name."'></a>";
38
+ $html .= "<div class='product-info'>";
39
+ $html .= "<h3 class='product-name'><a class='product-img' href='".$product_url."' title='".$product_name."' target='_blank'>".$product_name."</a></h3>";
40
+ $html .= "<p class='desc'>".Mage::helper('freetextsearch')->prShortText($product_desc,70)."</p>";
41
+ $html .= "</div>";
42
+ $html .= "</li>";
43
+ }
44
+ }
45
+ if($allowSearchCMS) {
46
+ $cmspageIds = Mage::helper("freetextsearch")->getSearchCMSPages($keyword);
47
+ if(count($cmspageIds) > 0){
48
+ foreach($cmspageIds as $_pageId){
49
+ $html .= "<li class='item cms'>";
50
+ $pageInfo = Mage::getModel('cms/page')->load($_pageId,'page_id')->getData();
51
+ $pageId = $pageInfo['page_id'];
52
+ $pageTitle = $pageInfo['title'];
53
+ $pageUrl = Mage::getBaseUrl().'/'.$pageInfo['identifier'];
54
+ $pageContent = $pageInfo['content'];
55
+ $html .= "<h3 class='p-title'><a href='".$pageUrl."' title='".$pageTitle."' alt='".$pageTitle."' target='_blank'>".$pageTitle."</a></h3>";
56
+ $html .= "</li>";
57
+ }
58
+ }
59
+ }
60
+ $html .= "</ul>";
61
+ $result = array('html' => $html);
62
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
63
+ }
64
+ }
app/code/community/Magebuzz/Freetextsearch/controllers/SearchController.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Magebuzz_Freetextsearch_SearchController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ public function indexAction() {
5
+ $this->loadLayout();
6
+ $this->renderLayout();
7
+ }
8
+ public function resultAction() {
9
+ $_coreHelper = Mage::helper('core');
10
+ $items = array();
11
+ /* Get Keyword */
12
+ $keyword = urldecode($this->getRequest()->getParam('keyword'));
13
+ /* Result - Product */
14
+ $products = Mage::helper("freetextsearch")->getSearchResultProducts($keyword);
15
+ $result[] = $products;
16
+ /* Result - Product & CMS */
17
+ $allowSearchCMS = Mage::getStoreConfig('freetextsearch/search_setting/cms_pages_allow');
18
+ if($allowSearchCMS) {
19
+ $cmspage = Mage::helper("freetextsearch")->getSearchCMSPages($keyword);
20
+ $result = array("cms"=>$cmspage,"product"=>$products);
21
+ }
22
+ else {
23
+ $result = array("product"=>$products);
24
+ }
25
+ Mage::register("result",$result);
26
+ Mage::register("keyword",$keyword);
27
+ $this->loadLayout();
28
+ $this->renderLayout();
29
+ }
30
+ public function quicksearchAction() {
31
+ $keyword = urldecode($this->getRequest()->getParam('keyword'));
32
+ $_coreHelper = Mage::helper('core');
33
+ /* Result - Product */
34
+ $productIds = Mage::helper("freetextsearch")->getSearchResultProducts($keyword);
35
+ $cmspageIds = Mage::helper("freetextsearch")->getSearchCMSPages($keyword);
36
+ $limitResults = Mage::helper("freetextsearch")->getNumberResults();
37
+ $limitCharDesc = Mage::helper("freetextsearch")->limitCharDescription();
38
+ $results = array_merge((array)$productIds, (array)$cmspageIds);
39
+ $thumb_width = Mage::getStoreConfig('freetextsearch/quick_search_setting/thumbnail_product_image_width');
40
+ /* Result - Product & CMS */
41
+ $allowSearchCMS = Mage::getStoreConfig('freetextsearch/search_setting/cms_pages_allow');
42
+ $html = "";
43
+ if(count($results) > 0) {
44
+ if(count($productIds) > 0) {
45
+ $html .= "<h3 class='result-title'>Products</h3>";
46
+ $html .= "<ul class='list-products'>";
47
+ $resultCount = 0;
48
+ foreach($productIds as $productId) {
49
+ $html .= "<li class='item product'>";
50
+ $product = Mage::getModel("catalog/product")->load($productId);
51
+ $img = Mage::helper('catalog/image')->init($product, 'image')->resize($thumb_width);
52
+ $img = $img->__toString();
53
+ $price = $_coreHelper->currency($product->getPrice(),true,false);
54
+ $product_url = $product->getProductUrl();
55
+ $product_name = $product->getName();
56
+ $product_desc = $product->getShortDescription();
57
+ $html .= "<a class='product-img' href='".$product_url."' title='".$product_name."' alt='".$product_name."' target='_blank'><img src='". $img ."' title='".$product_name."'></a>";
58
+ $html .= "<div class='product-info'>";
59
+ $html .= "<h3 class='product-name'><a href='".$product_url."' title='".$product_name."' target='_blank'>".$product_name."</a></h3>";
60
+ $html .= "<p class='desc'>".Mage::helper('freetextsearch')->prShortText($product_desc,$limitCharDesc)."</p>";
61
+ $html .= "<div class='product-price'><h5>".$price."</h5></div>";
62
+ $html .= "</div>";
63
+ $html .= "</li>";
64
+ $resultCount++;
65
+ if($resultCount >= $limitResults) {
66
+ break;
67
+ }
68
+ }
69
+ $html .= "</ul>";
70
+ }
71
+ if(count($productIds) < $limitResults || count($productIds) <= 0) {
72
+ if($allowSearchCMS) {
73
+ if(count($cmspageIds) > 0) {
74
+ $html .= "<h3 class='result-title'>CMS Pages</h3>";
75
+ $html .= "<ul class='list-cms'>";
76
+ foreach($cmspageIds as $_pageId){
77
+ $html .= "<li class='item cms'>";
78
+ $pageInfo = Mage::getModel('cms/page')->load($_pageId,'page_id')->getData();
79
+ $pageId = $pageInfo['page_id'];
80
+ $pageTitle = $pageInfo['title'];
81
+ $pageUrl = Mage::getBaseUrl().$pageInfo['identifier'];
82
+ $pageContent = $pageInfo['content'];
83
+ $html .= "<h5 class='p-title'><a href='".$pageUrl."' title='".$pageTitle."' alt='".$pageTitle."' target='_blank'>".$pageTitle."</a></h5>";
84
+ $html .= "</li>";
85
+ $resultCount++;
86
+ if($resultCount >= $limitResults) {
87
+ break;
88
+ }
89
+ }
90
+ $html .= "</ul>";
91
+ }
92
+ }
93
+ }
94
+ }
95
+ $responseHtml = array('html' => $html);
96
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($responseHtml));
97
+ }
98
+ }
app/code/community/Magebuzz/Freetextsearch/etc/adminhtml.xml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <all>
6
+ <title>Allow Everything</title>
7
+ </all>
8
+ <admin>
9
+ <children>
10
+ <system>
11
+ <children>
12
+ <config>
13
+ <children>
14
+ <freetextsearch translate="title">
15
+ <title>Freetextsearch Permission Setting</title>
16
+ <sort_order>50</sort_order>
17
+ </freetextsearch>
18
+ </children>
19
+ </config>
20
+ </children>
21
+ </system>
22
+ </children>
23
+ </admin>
24
+ </resources>
25
+ </acl>
26
+ </config>
app/code/community/Magebuzz/Freetextsearch/etc/config.xml ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Magebuzz_Freetextsearch>
5
+ <version>0.1.2</version>
6
+ </Magebuzz_Freetextsearch>
7
+ </modules>
8
+ <frontend>
9
+ <secure_url>
10
+ <freetextsearch>/freetextsearch/</freetextsearch>
11
+ </secure_url>
12
+ <routers>
13
+ <freetextsearch>
14
+ <use>standard</use>
15
+ <args>
16
+ <module>Magebuzz_Freetextsearch</module>
17
+ <frontName>freetextsearch</frontName>
18
+ </args>
19
+ </freetextsearch>
20
+ </routers>
21
+ <layout>
22
+ <updates>
23
+ <freetextsearch>
24
+ <file>freetextsearch.xml</file>
25
+ </freetextsearch>
26
+ </updates>
27
+ </layout>
28
+ </frontend>
29
+ <admin>
30
+ <routers>
31
+ <freetextsearch>
32
+ <use>admin</use>
33
+ <args>
34
+ <module>Magebuzz_Freetextsearch</module>
35
+ <frontName>freetextsearch</frontName>
36
+ </args>
37
+ </freetextsearch>
38
+ </routers>
39
+ </admin>
40
+ <adminhtml>
41
+ <layout>
42
+ <updates>
43
+ <freetextsearch>
44
+ <file>freetextsearch.xml</file>
45
+ </freetextsearch>
46
+ </updates>
47
+ </layout>
48
+ </adminhtml>
49
+ <global>
50
+ <models>
51
+ <freetextsearch>
52
+ <class>Magebuzz_Freetextsearch_Model</class>
53
+ <resourceModel>freetextsearch_mysql4</resourceModel>
54
+ </freetextsearch>
55
+ <freetextsearch_mysql4>
56
+ <class>Magebuzz_Freetextsearch_Model_Mysql4</class>
57
+ <entities>
58
+ <freetextsearch>
59
+ <table>freetextsearch</table>
60
+ </freetextsearch>
61
+ </entities>
62
+ </freetextsearch_mysql4>
63
+ </models>
64
+ <resources>
65
+ <freetextsearch_setup>
66
+ <setup>
67
+ <module>Magebuzz_Freetextsearch</module>
68
+ </setup>
69
+ <connection>
70
+ <use>core_setup</use>
71
+ </connection>
72
+ </freetextsearch_setup>
73
+ <freetextsearch_write>
74
+ <connection>
75
+ <use>core_write</use>
76
+ </connection>
77
+ </freetextsearch_write>
78
+ <freetextsearch_read>
79
+ <connection>
80
+ <use>core_read</use>
81
+ </connection>
82
+ </freetextsearch_read>
83
+ </resources>
84
+ <blocks>
85
+ <freetextsearch>
86
+ <class>Magebuzz_Freetextsearch_Block</class>
87
+ </freetextsearch>
88
+ </blocks>
89
+ <helpers>
90
+ <freetextsearch>
91
+ <class>Magebuzz_Freetextsearch_Helper</class>
92
+ </freetextsearch>
93
+ </helpers>
94
+ <template>
95
+ <email>
96
+ <freetextsearch_general_email_template>
97
+ <label>Title Email</label>
98
+ <file>freetextsearch_example.html</file>
99
+ <type>html</type>
100
+ </freetextsearch_general_email_template>
101
+ </email>
102
+ </template>
103
+ </global>
104
+ <default>
105
+ <freetextsearch>
106
+ <general>
107
+ <enable>1</enable>
108
+ <enable_quick_search>1</enable_quick_search>
109
+ </general>
110
+ <search_setting>
111
+ <search_by_sku>1</search_by_sku>
112
+ <search_by_manufacturer>1</search_by_manufacturer>
113
+ <search_by_desc>1</search_by_desc>
114
+ <cms_pages_allow>1</cms_pages_allow>
115
+ <cms_pages_content>0</cms_pages_content>
116
+ <search_result_notice><![CDATA[Most relevant results for "<span class="keyword">{{keyword}}</span>". Click <strong>Search</strong> button to view more]]></search_result_notice>
117
+ </search_setting>
118
+ <quick_search_setting>
119
+ <number_character>3</number_character>
120
+ <number_results>5</number_results>
121
+ <thumbnail_product_image_width>75</thumbnail_product_image_width>
122
+ <limit_character_product_desc>75</limit_character_product_desc>
123
+ </quick_search_setting>
124
+ </freetextsearch>
125
+ </default>
126
+ <translate>
127
+ <modules>
128
+ <Magebuzz_Freetextsearch>
129
+ <files>
130
+ <default>Magebuzz_Freetextsearch.csv</default>
131
+ </files>
132
+ </Magebuzz_Freetextsearch>
133
+ </modules>
134
+ </translate>
135
+ </config>
app/code/community/Magebuzz/Freetextsearch/etc/system.xml ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <magebuzz translate="label">
5
+ <label>Magebuzz Add-ons</label>
6
+ <sort_order>71</sort_order>
7
+ </magebuzz>
8
+ </tabs>
9
+ <sections>
10
+ <freetextsearch translate="label" module="freetextsearch">
11
+ <label>Free Text Search</label>
12
+ <tab>magebuzz</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>299</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+ <groups>
19
+ <general translate="label">
20
+ <label>General Setting</label>
21
+ <frontend_type>text</frontend_type>
22
+ <sort_order>1</sort_order>
23
+ <show_in_default>1</show_in_default>
24
+ <show_in_website>1</show_in_website>
25
+ <show_in_store>1</show_in_store>
26
+ <fields>
27
+ <enable translate="label comment">
28
+ <label>Enable Free Text Search</label>
29
+ <frontend_type>select</frontend_type>
30
+ <source_model>adminhtml/system_config_source_yesno</source_model>
31
+ <sort_order>1</sort_order>
32
+ <show_in_default>1</show_in_default>
33
+ <show_in_website>1</show_in_website>
34
+ <show_in_store>1</show_in_store>
35
+ </enable>
36
+ <enable_quick_search translate="label comment">
37
+ <label>Enable Quick Search</label>
38
+ <frontend_type>select</frontend_type>
39
+ <source_model>adminhtml/system_config_source_yesno</source_model>
40
+ <sort_order>4</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
+ <comment>The result will be shown in the drop down</comment>
45
+ </enable_quick_search>
46
+ </fields>
47
+ </general>
48
+ <search_setting translate="label">
49
+ <label>Search Setting</label>
50
+ <frontend_type>text</frontend_type>
51
+ <sort_order>3</sort_order>
52
+ <show_in_default>1</show_in_default>
53
+ <show_in_website>1</show_in_website>
54
+ <show_in_store>1</show_in_store>
55
+ <fields>
56
+ <search_by_sku translate="label comment">
57
+ <label>Search product by SKU</label>
58
+ <frontend_type>select</frontend_type>
59
+ <source_model>adminhtml/system_config_source_yesno</source_model>
60
+ <sort_order>1</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
+ <comment>Allow search product by SKU</comment>
65
+ </search_by_sku>
66
+ <search_by_manufacturer translate="label comment">
67
+ <label>Search product by manufacturer</label>
68
+ <frontend_type>select</frontend_type>
69
+ <source_model>adminhtml/system_config_source_yesno</source_model>
70
+ <sort_order>2</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
+ <comment>Allow search product by manufacturer</comment>
75
+ </search_by_manufacturer>
76
+ <search_by_desc translate="label comment">
77
+ <label>Search product by product description</label>
78
+ <frontend_type>select</frontend_type>
79
+ <source_model>adminhtml/system_config_source_yesno</source_model>
80
+ <sort_order>3</sort_order>
81
+ <show_in_default>1</show_in_default>
82
+ <show_in_website>1</show_in_website>
83
+ <show_in_store>1</show_in_store>
84
+ <comment>Allow search product by product description</comment>
85
+ </search_by_desc>
86
+ <cms_pages_allow translate="label comment">
87
+ <label>Allow to search for CMS Pages</label>
88
+ <frontend_type>select</frontend_type>
89
+ <source_model>adminhtml/system_config_source_yesno</source_model>
90
+ <sort_order>4</sort_order>
91
+ <show_in_default>1</show_in_default>
92
+ <show_in_website>1</show_in_website>
93
+ <show_in_store>1</show_in_store>
94
+ <comment>Results will show products and CMS Pages</comment>
95
+ </cms_pages_allow>
96
+ <cms_pages_content translate="label comment">
97
+ <label>Show CMS page content</label>
98
+ <frontend_type>select</frontend_type>
99
+ <source_model>adminhtml/system_config_source_yesno</source_model>
100
+ <sort_order>5</sort_order>
101
+ <show_in_default>1</show_in_default>
102
+ <show_in_website>1</show_in_website>
103
+ <show_in_store>1</show_in_store>
104
+ <comment>Show CMS page content on search result page</comment>
105
+ </cms_pages_content>
106
+ <search_result_notice translate="label">
107
+ <label>The notice of search result</label>
108
+ <frontend_type>textarea</frontend_type>
109
+ <sort_order>6</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>{{keyword}} will be replaced by the keyword which is searched by customer</comment>
114
+ </search_result_notice>
115
+ </fields>
116
+ </search_setting>
117
+ <quick_search_setting translate="label">
118
+ <label>Quick Search Setting</label>
119
+ <frontend_type>text</frontend_type>
120
+ <sort_order>5</sort_order>
121
+ <show_in_default>1</show_in_default>
122
+ <show_in_website>1</show_in_website>
123
+ <show_in_store>1</show_in_store>
124
+ <fields>
125
+ <number_character translate="label comment">
126
+ <label>Limit of characters to start search</label>
127
+ <frontend_type>text</frontend_type>
128
+ <sort_order>1</sort_order>
129
+ <show_in_default>1</show_in_default>
130
+ <show_in_website>1</show_in_website>
131
+ <show_in_store>1</show_in_store>
132
+ <comment>After this number of character, search result will be shown.</comment>
133
+ </number_character>
134
+ <number_results translate="label comment">
135
+ <label>Number of results</label>
136
+ <frontend_type>text</frontend_type>
137
+ <sort_order>2</sort_order>
138
+ <show_in_default>1</show_in_default>
139
+ <show_in_website>1</show_in_website>
140
+ <show_in_store>1</show_in_store>
141
+ <comment>Number of results to show in the drop down</comment>
142
+ </number_results>
143
+ <thumbnail_product_image_width translate="label">
144
+ <label>Width of thumbnail product</label>
145
+ <frontend_type>text</frontend_type>
146
+ <sort_order>3</sort_order>
147
+ <show_in_default>1</show_in_default>
148
+ <show_in_website>1</show_in_website>
149
+ <show_in_store>1</show_in_store>
150
+ <comment>Width of thumbnail product will be shown in the drop down.</comment>
151
+ </thumbnail_product_image_width>
152
+ <limit_character_product_desc translate="label">
153
+ <label>Limit characters in product description</label>
154
+ <frontend_type>text</frontend_type>
155
+ <sort_order>4</sort_order>
156
+ <show_in_default>1</show_in_default>
157
+ <show_in_website>1</show_in_website>
158
+ <show_in_store>1</show_in_store>
159
+ </limit_character_product_desc>
160
+ </fields>
161
+ </quick_search_setting>
162
+ </groups>
163
+ </freetextsearch>
164
+ </sections>
165
+ </config>
app/design/frontend/base/default/layout/freetextsearch.xml ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ <reference name="head">
5
+ <action method="addCss" ifconfig="freetextsearch/general/enable"><stylesheet>css/magebuzz/freetextsearch.css</stylesheet></action>
6
+ <action method="addJs" ifconfig="freetextsearch/general/enable_quick_search"><script>magebuzz/quicksearch.js</script></action>
7
+ <action method="addCss" ifconfig="freetextsearch/general/enable_quick_search"><stylesheet>css/magebuzz/quicksearch.css</stylesheet></action>
8
+ </reference>
9
+ <reference name="top.search">
10
+ <action method="setTemplate" ifconfig="freetextsearch/general/enable">
11
+ <template>freetextsearch/form.phtml</template>
12
+ </action>
13
+ </reference>
14
+ </default>
15
+ <freetextsearch_index_index>
16
+ <reference name="root">
17
+ <action method="setTemplate"><template>page/2columns-right.phtml</template></action>
18
+ </reference>
19
+ <reference name="content">
20
+ <block type="freetextsearch/freetextsearch" name="freetextsearch" template="freetextsearch/form.phtml" />
21
+ </reference>
22
+ </freetextsearch_index_index>
23
+ <freetextsearch_search_result>
24
+ <reference name="root">
25
+ <action method="setTemplate"><template>page/2columns-right.phtml</template></action>
26
+ </reference>
27
+ <reference name="content">
28
+ <block type="freetextsearch/result" name="freetextsearch.result" template="freetextsearch/result.phtml">
29
+ <block type="catalog/product_list" name="freetextsearch.product" template="catalog/product/list.phtml">
30
+ <block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
31
+ <block type="page/html_pager" name="product_list_toolbar_pager"/>
32
+ </block>
33
+ </block>
34
+ <action method="setListCollection"/>
35
+ </block>
36
+ </reference>
37
+ </freetextsearch_search_result>
38
+ </layout>
app/design/frontend/base/default/template/freetextsearch/form.phtml ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $freetextsearchHelper = Mage::helper('freetextsearch');
3
+ $catalogSearchHelper = $this->helper('catalogsearch');
4
+ $resultNotice = $freetextsearchHelper->getSearchResultNotice();
5
+
6
+ ?>
7
+ <form id="freetextsearch_form" action="<?php echo $this->getUrl('freetextsearch/search/result') ?>" method="get">
8
+ <div class="form-search">
9
+ <label for="search"><?php echo $this->__('Search:') ?></label>
10
+ <input id="input_search" type="text" name="keyword" value="" class="input-text" maxlength="<?php echo $catalogSearchHelper->getMaxQueryLength();?>" />
11
+ <button type="submit" title="<?php echo $this->__('Search') ?>" class="button"><span><span><?php echo $this->__('Search') ?></span></span></button>
12
+ <div id="search_autocomplete" class="search-autocomplete"></div>
13
+ <script type="text/javascript">
14
+ //<![CDATA[
15
+ var searchForm = new Varien.searchForm('freetextsearch_form', 'input_search', '<?php echo $this->__('Search entire store here...') ?>');
16
+ //]]>
17
+ </script>
18
+ </div>
19
+ </form>
20
+ <?php if($freetextsearchHelper->enableQuickSearch()):?>
21
+ <div id="showResults" style="display:none;">
22
+ <a class="close-dropdown" href="javascript://" onclick="closeDropdown()" title="<?php echo $this->__('Close')?>" alt="<?php echo $this->__('Close')?>">X</a>
23
+ <div id="resultNotice">
24
+ <label id="resultLabel">Search result</label>
25
+ </div>
26
+ <div id="listResults" style="display:none;">
27
+ </div>
28
+ </div>
29
+ <script type="text/javascript">
30
+ var quicksearch = new Quicksearch(
31
+ '<?php echo $this->getUrl('freetextsearch/search/quicksearch') ?>',
32
+ '<?php echo $resultNotice ?>',
33
+ 'input_search'
34
+ );
35
+ var numberChar = <?php echo Mage::getStoreConfig('freetextsearch/quick_search_setting/number_character')?>;
36
+ Event.observe('input_search', 'keyup', function(event){
37
+ var searchBox = $('input_search');
38
+ if(searchBox.value.length >= numberChar){
39
+ quicksearch.search();
40
+ }
41
+ });
42
+ function closeDropdown() {
43
+ var showResults = $('showResults');
44
+ showResults.style.display = "none";
45
+ }
46
+ </script>
47
+ <?php endif; ?>
app/design/frontend/base/default/template/freetextsearch/result.phtml ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if(Mage::registry("result")):?>
2
+ <?php $results = Mage::registry("result"); ?>
3
+ <?php $keyword = Mage::registry("keyword");?>
4
+ <div class="search-result">
5
+ <div class="page-title">
6
+ <h1><?php echo $this->__("Search results for '%s'",$keyword)?></h1>
7
+ </div>
8
+ <div class="page-content">
9
+ <?php
10
+ $cmspages = $results['cms'];
11
+ $products = $results['product'];
12
+ ?>
13
+ <?php if(count($cmspages) > 0):?>
14
+ <h3 class="result-title"><span><?php echo $this->__('CMS Pages')?></span></h3>
15
+ <ul class="list-result-cms">
16
+ <?php foreach($cmspages as $_page):?>
17
+ <?php $pageInfo = Mage::getModel('cms/page')->load($_page,'page_id')->getData();?>
18
+ <li class="cms">
19
+ <h5 class="p-title">
20
+ <a target="_blank" title="<?php echo $pageInfo['title']?>" alt="<?php echo $pageInfo['title']?>" href="<?php echo $this->getUrl()?><?php echo $pageInfo['identifier']?>">
21
+ <?php echo $pageInfo['title']?>
22
+ </a>
23
+ </h5>
24
+ <?php if(Mage::helper('freetextsearch')->isShowPageContent()):?>
25
+ <div class="p-content">
26
+ <p><?php echo $pageInfo['content']?></p>
27
+ </div>
28
+ <?php endif; ?>
29
+ </li>
30
+ <?php endforeach;?>
31
+ </ul>
32
+ <?php endif;?>
33
+ <h3 class="result-title"><span><?php echo $this->__('Products')?></span></h3>
34
+ <?php echo $this->getProductHtml()?>
35
+ </div>
36
+ </div>
37
+ <?php endif; ?>
app/etc/modules/Magebuzz_Freetextsearch.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Magebuzz_Freetextsearch>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Magebuzz_Freetextsearch>
8
+ </modules>
9
+ </config>
app/locale/en_US/Magebuzz_Freetextsearch.csv ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Free Text Search, Free Text Search
2
+ Quick Search, Quick Search
3
+ Limit characters, Limit characters
4
+ Quick Search Setting, Quick Search Setting
5
+ Search product by SKU, Search product by SKU
6
+ Search product by manufacturer, Search product by manufacturer
7
+ Search product by product description, Search product by product description
8
+ Show CMS page content, Show CMS page content
9
+ Most relevant results, Most relevant results
10
+ Products, Products
11
+ Manufacturer, Manufacturer
12
+ Price, Price
13
+ SKU, SKU
14
+ CMS Pages, CMS Pages
15
+ Search results, Search results
16
+ Search entire store here�, Search entire store here�
17
+ Search results for '%s', Search results for '%s'
18
+ Search results for: '%s', Search results for: '%s'
19
+ Search:, Search:
js/magebuzz/quicksearch.js ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /********Javascript for FREE TEXT SEARCH ************/
2
+ var Quicksearch = Class.create();
3
+ var idSearchInput = '';
4
+ Quicksearch.prototype = {
5
+ initialize: function(searchUrl,resultNotice,idSearchInput){
6
+ this.idSearchInput = idSearchInput;
7
+ this.searchUrl = searchUrl;
8
+ this.onSuccess = this.onSuccess.bindAsEventListener(this);
9
+ this.onFailure = this.onFailure.bindAsEventListener(this);
10
+ this.currentSearch = '';
11
+ this.resultNotice = resultNotice;
12
+ },
13
+ search: function(){
14
+ var searchBox = $(this.idSearchInput);
15
+
16
+ if(searchBox.value=='')
17
+ {
18
+ return;
19
+ }
20
+
21
+ if ((this.currentSearch!="") &&(searchBox.value == this.currentSearch)) {
22
+ return;
23
+ }
24
+ this.currentSearch = searchBox.value;
25
+
26
+ searchBox.className = 'loading-result input-text';
27
+ var keyword = searchBox.value;
28
+
29
+
30
+ url = this.searchUrl+"keyword/" + escape(keyword);
31
+
32
+ new Ajax.Request(url, {
33
+ method: 'get',
34
+ onSuccess: this.onSuccess,
35
+
36
+ onFailure: this.onFailure
37
+ });
38
+ },
39
+ onFailure: function(transport){
40
+ $(this.idSearchInput).className ="input-text";
41
+ },
42
+ onSuccess: function(transport)
43
+ {
44
+ var showResults = $('showResults');
45
+ showResults.style.display = "block";
46
+ var listResults = $('listResults');
47
+ listResults.style.display = "block";
48
+ var searchBox = $(this.idSearchInput);
49
+ if (transport && transport.responseText) {
50
+ try{
51
+ response = eval('(' + transport.responseText + ')');
52
+ }
53
+ catch (e) {
54
+ response = {};
55
+ }
56
+
57
+ if (response.html != "") {
58
+ this.currentSearch = searchBox.value;
59
+ listResults.update(response.html);
60
+ var searchResultNotice = this.resultNotice;
61
+ var strNotice = searchResultNotice.replace("{{keyword}}",this.currentSearch);
62
+ this.updateResultLabel(strNotice);
63
+ searchBox.className = 'search-complete input-text';
64
+ }
65
+ else
66
+ {
67
+ listResults.update(response.html);
68
+ this.updateResultLabel('No results for "<span class="keyword">'+this.currentSearch+'</span>"');
69
+ searchBox.className ="search-complete input-text";
70
+ }
71
+ }
72
+ },
73
+ updateResultLabel: function(message)
74
+ {
75
+ $("resultLabel").update(message);
76
+ }
77
+ }
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Magebuzz_Free_Text_Search</name>
4
+ <version>0.1.2</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Include CMS pages in search result</summary>
10
+ <description>Free Text Search extension is a simple and effective solution for your Magento search feature. Instead of limited searching by specific product names, customers are able to search based on general keywords, SKU numbers and manufacturer names.</description>
11
+ <notes>Magento 0.1.2 supports all Magento versions</notes>
12
+ <authors><author><name>Magebuzz</name><user>magebuzz</user><email>magebuzz@gmail.com</email></author></authors>
13
+ <date>2014-06-10</date>
14
+ <time>07:35:29</time>
15
+ <contents><target name="magecommunity"><dir name="Magebuzz"><dir name="Freetextsearch"><dir name="Block"><file name="Freetextsearch.php" hash="89e397a4836b82f0f9c581d6e44db665"/><file name="Result.php" hash="88e84305eb635f9dd733170f14626e5f"/></dir><dir name="Helper"><file name="Data.php" hash="b1d2558af5415c5afcbd553cb963ad20"/><file name="Quicksearch.php" hash="6993cd06b3114782e3615ab8acbd1ee7"/></dir><dir name="Model"><file name="Freetextsearch.php" hash="56dbcca1feed11ca6277f8bc9b9f8dff"/><dir name="Mysql4"><dir name="Freetextsearch"><file name="Collection.php" hash="63c58b56e379ddb8f25c60d48d2d13b5"/></dir><file name="Freetextsearch.php" hash="6caa820b7e35749b617884e84eb44e34"/></dir><file name="Session.php" hash="aecd209275179d725acb13bc9688181a"/><file name="Status.php" hash="b0a7897dbb7a59726c00c44d067c6994"/><dir name="Wysiwyg"><file name="Config.php" hash="553a77680afb7e72fd0252ad86a4e2d4"/></dir></dir><dir name="controllers"><file name="IndexController.php" hash="4c6eb33c16dea2ce0523eb37d1d1373e"/><file name="SearchController.php" hash="515e9be3162b4e2bef67d3725681acb2"/></dir><dir name="etc"><file name="adminhtml.xml" hash="e23193d37ea6189a4ae9a1b9c75812e4"/><file name="config.xml" hash="45e7f7269a8cc65cbf61347c07986562"/><file name="system.xml" hash="e65871b6ab4c9b08828e9c70605707b3"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="freetextsearch.xml" hash="9cd0ff8624289234e68d59fa81512b44"/></dir><dir name="template"><dir name="freetextsearch"><file name="form.phtml" hash="8b4a684e10306758c110e52ddc349e1c"/><file name="result.phtml" hash="e51f7e812994b133505869cea24644d6"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="Magebuzz_Freetextsearch.csv" hash="0efc2454e95ba42f26dbdf7b848f9d06"/></dir></target><target name="mageweb"><dir><dir name="js"><dir name="magebuzz"><file name="quicksearch.js" hash="4a5da17a30822a0e17f18d0b7e742032"/></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="magebuzz"><file name="freetextsearch.css" hash="ab5c6e7f37196d9b7378737906790bc6"/><dir name="images"><file name="close-icon.png" hash="b94da2d715c62e91c9de77ae8cdf4e6f"/><file name="list-icon.png" hash="d9decb46410ff8d708675629dc8b9454"/><file name="search-loading.gif" hash="6969ff85a0515644cf10658ae1127a28"/><file name="search_complete.png" hash="2ef859aff87a9aa313316a47a59de268"/></dir><file name="quicksearch.css" hash="12ff8213d5b4937a7432adac335a13dd"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Magebuzz_Freetextsearch.xml" hash="30d5fc7594c5fc153623dd78869fac3f"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>
skin/frontend/base/default/css/magebuzz/freetextsearch.css ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* CSS for Search Result Page */
2
+ .search-result{}
3
+ .search-result .page-title{
4
+ margin:0 0 10px;
5
+ }
6
+ .search-result .page-content{
7
+ background: none repeat scroll 0 0 #FFFFFF;
8
+ border: 1px solid #E1E1E1;
9
+ box-shadow: 0 0 0 #F0F0F0 inset, 0 0 5px #E8E6E6;
10
+ padding:10px;
11
+ overflow:hidden;
12
+ }
13
+ .search-result .result-title{
14
+ background: none repeat scroll 0 0 #CCCCCC;
15
+ float: left;
16
+ padding: 2px 0;
17
+ text-align: left;
18
+ width: 100%;
19
+ color: #444444;
20
+ margin:0 0 15px;
21
+ }
22
+ .search-result .result-title span{padding-left:15px;}
23
+ .search-result .list-result-cms{float:left; width:100%; margin:0 0 15px;}
24
+ .search-result .list-result-cms{float:left; width:100%; margin:0 0 15px;}
25
+ .search-result .list-result-cms li{
26
+ border-bottom: 1px dashed #CCCCCC;
27
+ padding: 5px 0;
28
+ }
29
+ .search-result .list-result-cms li h5.p-title{
30
+ color:#333333;
31
+ font-size:13px;
32
+ font-weight:bold;
33
+ margin:0;
34
+ background:url(images/list-icon.png) left center no-repeat;
35
+ padding-left:10px;
36
+ }
37
+ .search-result .list-result-cms li h5.p-title a{
38
+ color:#333333;
39
+ font-size:13px;
40
+ font-weight:bold;
41
+ text-decoration: none;
42
+ }
skin/frontend/base/default/css/magebuzz/images/close-icon.png ADDED
Binary file
skin/frontend/base/default/css/magebuzz/images/list-icon.png ADDED
Binary file
skin/frontend/base/default/css/magebuzz/images/search-loading.gif ADDED
Binary file
skin/frontend/base/default/css/magebuzz/images/search_complete.png ADDED
Binary file
skin/frontend/base/default/css/magebuzz/quicksearch.css ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /********Css For freetextsearch************/
2
+ /* CSS for Quick Search */
3
+ #showResults{
4
+ position:absolute;
5
+ right:33px;
6
+ background: none repeat scroll 0 0 #FFFFFF;
7
+ border: 1px solid #E1E1E1;
8
+ box-shadow: 0 0 0 #F0F0F0 inset, 0 0 5px #E8E6E6;
9
+ padding:15px;
10
+ width:300px;
11
+ top:30px;
12
+ z-index:999;
13
+ text-align:left;
14
+ }
15
+ #freetextsearch_form .form-search input.input-text{}
16
+ #freetextsearch_form .form-search input.loading-result{background:#FFFFFF url(images/search-loading.gif) 95% center no-repeat;}
17
+ #freetextsearch_form .form-search input.search-complete{background:#FFFFFF url(images/search_complete.png) 95% center no-repeat;}
18
+ #showResults #resultNotice{
19
+ float: left;
20
+ margin: 5px 0;
21
+ width: 100%;
22
+ }
23
+ #showResults .close-dropdown{background:url(images/close-icon.png) top left no-repeat; float:right; width:16px; height:16px; text-indent:-999em;}
24
+ #showResults #resultNotice span.keyword{
25
+ background:#f6ff00;
26
+ font-weight:bold;
27
+ color:#555555;
28
+ padding:2px;
29
+ }
30
+ #showResults #resultLabel{
31
+ font-style:italic;
32
+ font-size:12px;
33
+ color:#ababab;
34
+ }
35
+ #showResults #listResults{
36
+
37
+ }
38
+ #listResults .result-title{
39
+ background: none repeat scroll 0 0 #CCCCCC;
40
+ float: left;
41
+ padding: 2px 0;
42
+ text-align: center;
43
+ width: 100%;
44
+ color: #444444;
45
+ }
46
+ #listResults .list-products{
47
+ float:left;
48
+ width:100%;
49
+ margin: 0 0 5px;
50
+ }
51
+ #listResults .list-products li.item{
52
+ border-bottom: 1px dashed #CCCCCC;
53
+ float: left;
54
+ padding: 10px 0;
55
+ width: 100%;
56
+ }
57
+ #listResults .list-products .product-img{float:left; border:1px solid #E1E1E1;}
58
+ #listResults .list-products .product-info{
59
+ float: left;
60
+ margin-left: 10px;
61
+ text-align: justify;
62
+ width: 210px;
63
+ }
64
+ #listResults .list-products .product-name{}
65
+ #listResults .list-products p.desc{color:#717171; margin:0 0 3px;}
66
+ #listResults .list-products .product-price h5{color:#FF0000; font-size:15px; font-weight:bold;}
67
+ #listResults .list-products .product-name a{
68
+ color: #333333;
69
+ font-weight: bold;
70
+ font-size:12px;
71
+ text-decoration: none;
72
+ }
73
+ #listResults .list-cms{
74
+ float:left;
75
+ width:100%;
76
+ margin: 0 0 5px;
77
+ padding:0 0 5px;
78
+ }
79
+ #listResults .list-cms li{
80
+ border-bottom: 1px dashed #CCCCCC;
81
+ padding: 3px 0 3px 10px;
82
+ background:url(images/list-icon.png) left center no-repeat;
83
+ }
84
+ #listResults .list-cms li h5.p-title{
85
+ color:#333333;
86
+ font-size:12px;
87
+ font-weight:bold;
88
+ margin:0;
89
+ }
90
+ #listResults .list-cms li h5.p-title a{
91
+ color:#333333;
92
+ font-size:12px;
93
+ font-weight:bold;
94
+ text-decoration: none;
95
+ }