Version Notes
First Version Release
Download this release
Release Info
Developer | magecoders |
Extension | enhanced_defaultsearch |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
app/code/community/MageCoders/DefaultSearch/Helper/Data.php
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class MageCoders_DefaultSearch_Helper_Data extends Mage_Core_Helper_Abstract{
|
3 |
+
}
|
app/code/community/MageCoders/DefaultSearch/Model/Mysql4/Fulltext.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class MageCoders_DefaultSearch_Model_Mysql4_Fulltext extends Mage_CatalogSearch_Model_Mysql4_Fulltext{
|
3 |
+
|
4 |
+
public function prepareResult($object, $queryText, $query)
|
5 |
+
{
|
6 |
+
$adapter = $this->_getWriteAdapter();
|
7 |
+
|
8 |
+
if ($query->getIsProcessed()) { return $this; }
|
9 |
+
$mainTable = $this->getTable('catalogsearch/result');
|
10 |
+
$queryText = mysql_escape_string(trim($queryText));
|
11 |
+
$product = Mage::getModel('catalog/product')->loadByAttribute('sku',$queryText);
|
12 |
+
if($product){
|
13 |
+
$sql = "INSERT IGNORE INTO {$mainTable} SET query_id = '".$query->getId()."',
|
14 |
+
product_id = '".$product->getId()."',
|
15 |
+
relevance = '2'";
|
16 |
+
$adapter->query($sql);
|
17 |
+
}else{
|
18 |
+
$name = '%'.$queryText.'%';
|
19 |
+
$collection = Mage::getResourceModel('catalog/product_collection')
|
20 |
+
->addAttributeToFilter('name',array('like'=>$name));
|
21 |
+
|
22 |
+
if($collection->count()){
|
23 |
+
foreach($collection as $item){
|
24 |
+
$sql = "INSERT IGNORE INTO {$mainTable} SET query_id = '".$query->getId()."',
|
25 |
+
product_id = '".$item->getId()."',
|
26 |
+
relevance = '1'";
|
27 |
+
$adapter->query($sql);
|
28 |
+
}
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
}
|
33 |
+
|
34 |
+
}
|
app/code/community/MageCoders/DefaultSearch/etc/config.xml
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @author MageCoders
|
5 |
+
* @package MageCoders_DefaultSearch
|
6 |
+
*/
|
7 |
+
-->
|
8 |
+
<config>
|
9 |
+
<modules>
|
10 |
+
<MageCoders_DefaultSearch>
|
11 |
+
<version>1.0.0</version>
|
12 |
+
</MageCoders_DefaultSearch>
|
13 |
+
</modules>
|
14 |
+
<global>
|
15 |
+
<models>
|
16 |
+
<defaultsearch>
|
17 |
+
<class>MageCoders_DefaultSearch_Model</class>
|
18 |
+
</defaultsearch>
|
19 |
+
<catalogsearch_mysql4>
|
20 |
+
<rewrite>
|
21 |
+
<fulltext>MageCoders_DefaultSearch_Model_Mysql4_Fulltext</fulltext>
|
22 |
+
</rewrite>
|
23 |
+
</catalogsearch_mysql4>
|
24 |
+
</models>
|
25 |
+
<helpers>
|
26 |
+
<defaultsearch>
|
27 |
+
<class>MageCoders_DefaultSearch_Helper</class>
|
28 |
+
</defaultsearch>
|
29 |
+
</helpers>
|
30 |
+
</global>
|
31 |
+
</config>
|
app/etc/modules/MageCoders_DefaultSearch.xml
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @category MageCoders
|
5 |
+
* @package MageCoders_DefaultSearch
|
6 |
+
*/
|
7 |
+
-->
|
8 |
+
<config>
|
9 |
+
<modules>
|
10 |
+
<MageCoders_DefaultSearch>
|
11 |
+
<active>true</active>
|
12 |
+
<codePool>community</codePool>
|
13 |
+
</MageCoders_DefaultSearch>
|
14 |
+
</modules>
|
15 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>enhanced_defaultsearch</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>OSL</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Enhanced Default Search for Magento.
|
10 |
+
</summary>
|
11 |
+
<description>Enhanced Default Search for Magento.
|
12 |
+
</description>
|
13 |
+
<notes>First Version Release</notes>
|
14 |
+
<authors><author><name>MageCoders</name><user>magecoders</user><email>davew1982@gmail.com</email></author></authors>
|
15 |
+
<date>2012-03-08</date>
|
16 |
+
<time>13:06:55</time>
|
17 |
+
<contents><target name="magecommunity"><dir name="MageCoders"><dir><dir name="DefaultSearch"><dir name="Helper"><file name="Data.php" hash="4c387cd383da2202e54ed0cdf592d169"/></dir><dir name="Model"><dir name="Mysql4"><file name="Fulltext.php" hash="fece2ded01899b039e350779b9637b6b"/></dir></dir><dir name="etc"><file name="config.xml" hash="9e1ff61355facc8b968e218b0956d860"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="MageCoders_DefaultSearch.xml" hash="1e7f12fb79d2b3bf949d123a69f73785"/></dir></target></contents>
|
18 |
+
<compatible/>
|
19 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
20 |
+
</package>
|