Sitewards_InstantSearchResult - Version 1.0.0

Version Notes

Released new extension.

Download this release

Release Info

Developer Sitewards Magento Team
Extension Sitewards_InstantSearchResult
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/Sitewards/InstantSearchResult/Helper/Data.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Sitewards_InstantSearchResult_Helper_Data
4
+ *
5
+ * @category Sitewards
6
+ * @package Sitewards_InstantSearchResult
7
+ * @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
8
+ */
9
+ class Sitewards_InstantSearchResult_Helper_Data extends Mage_Captcha_Helper_Data {
10
+
11
+ /**
12
+ * The root node of extension configuration
13
+ */
14
+ const CONFIG_NODE = 'instantsearchresult';
15
+
16
+ /**
17
+ * The general settings node of extension configuration
18
+ */
19
+ const CONFIG_GENERAL_NODE = 'generalsettings';
20
+
21
+ /**
22
+ * Flag for extension enable/disable
23
+ */
24
+ const CONFIG_GENERAL_ACTIVE_FLAG = 'active';
25
+
26
+ /**
27
+ * Check to see if the extension is active
28
+ * Returns the extension's general setting "active"
29
+ *
30
+ * @return bool
31
+ */
32
+ public function isExtensionActive() {
33
+ return Mage::getStoreConfigFlag(
34
+ self::CONFIG_NODE . '/' .
35
+ self::CONFIG_GENERAL_NODE . '/' .
36
+ self::CONFIG_GENERAL_ACTIVE_FLAG
37
+ );
38
+ }
39
+ }
app/code/community/Sitewards/InstantSearchResult/Model/Observer.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Sitewards_InstantSearchResult_Model_Observer
4
+ * - redirect to product details
5
+ * - function return search result item url
6
+ *
7
+ * @category Sitewards
8
+ * @package Sitewards_InstantSearchResult
9
+ * @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
10
+ */
11
+ class Sitewards_InstantSearchResult_Model_Observer {
12
+ /**
13
+ * If there is only 1 product returned from the search redirect to detailpage of product
14
+ *
15
+ * @param Varien_Event_Observer $oObserver
16
+ */
17
+ public function onCoreBlockAbstractToHtmlBefore(Varien_Event_Observer $oObserver) {
18
+ if (!Mage::helper('instantsearchresult')->isExtensionActive()) {
19
+ return;
20
+ }
21
+ $oBlock = $oObserver->getBlock();
22
+ // only on block catalogsearch result
23
+ /* @var Mage_CatalogSearch_Block_Result $oBlock */
24
+ if ($oBlock instanceof Mage_CatalogSearch_Block_Result) {
25
+ $oRequest = Mage::app()->getRequest();
26
+ if (!$oRequest->isAjax()) {
27
+ if ($oBlock->getResultCount() == 1) {
28
+ $sUrl = $this->getProductUrl($oBlock);
29
+ Mage::app()->getFrontController()->getResponse()->setRedirect($sUrl);
30
+ }
31
+ }
32
+ }
33
+ }
34
+
35
+ /**
36
+ * Return product url of first item
37
+ *
38
+ * @param Mage_CatalogSearch_Block_Result $oBlock
39
+ * @throws Mage_Exception if the fetched item of the collection of not of type Mage_Catalog_Model_Product
40
+ * @return String
41
+ */
42
+ private function getProductUrl(Mage_CatalogSearch_Block_Result $oBlock) {
43
+ /* @var Mage_Catalog_Block_Product_List $oListBlock */
44
+ $oListBlock = $oBlock->getListBlock();
45
+ // we have to execute toHtml so all events get fired which filter the product collection
46
+ $oListBlock->toHtml();
47
+ /* @var Mage_Catalog_Model_Resource_Product_Collection $oProductCollection */
48
+ $oProductCollection = $oListBlock->getLoadedProductCollection();
49
+ /* @var Mage_Catalog_Model_Product $oProduct */
50
+ $oProduct = $oProductCollection->fetchItem();
51
+ if (!($oProduct instanceof Mage_Catalog_Model_Product)) {
52
+ throw new Mage_Exception('fetched item is not a product');
53
+ }
54
+ return $oProduct->getProductUrl() . $oProduct->getUrlPath();
55
+ }
56
+ }
app/code/community/Sitewards/InstantSearchResult/etc/adminhtml.xml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ *
5
+ * @category Sitewards
6
+ * @package Sitewards_InstantSearchResult
7
+ * @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
8
+ */
9
+ -->
10
+ <config>
11
+ <acl>
12
+ <resources>
13
+ <admin>
14
+ <children>
15
+ <system>
16
+ <children>
17
+ <config>
18
+ <children>
19
+ <instantsearchresult translate="title" module="instantsearchresult">
20
+ <title>Instant Search Result</title>
21
+ <sort_order>50</sort_order>
22
+ </instantsearchresult>
23
+ </children>
24
+ </config>
25
+ </children>
26
+ </system>
27
+ </children>
28
+ </admin>
29
+ </resources>
30
+ </acl>
31
+ </config>
app/code/community/Sitewards/InstantSearchResult/etc/config.xml ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * The main config file
5
+ *
6
+ * @category Sitewards
7
+ * @package Sitewards_InstantSearchResult
8
+ * @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
9
+ */
10
+ -->
11
+ <config>
12
+ <modules>
13
+ <Sitewards_InstantSearchResult>
14
+ <version>1.0.0</version>
15
+ </Sitewards_InstantSearchResult>
16
+ </modules>
17
+ <global>
18
+ <models>
19
+ <sitewards_instantsearchresult>
20
+ <class>Sitewards_InstantSearchResult_Model</class>
21
+ </sitewards_instantsearchresult>
22
+ </models>
23
+ <helpers>
24
+ <instantsearchresult>
25
+ <class>Sitewards_InstantSearchResult_Helper</class>
26
+ </instantsearchresult>
27
+ </helpers>
28
+ <events>
29
+ <core_block_abstract_to_html_before>
30
+ <observers>
31
+ <sitewards_instantsearchresult>
32
+ <class>sitewards_instantsearchresult/observer</class>
33
+ <method>onCoreBlockAbstractToHtmlBefore</method>
34
+ </sitewards_instantsearchresult>
35
+ </observers>
36
+ </core_block_abstract_to_html_before>
37
+ </events>
38
+ </global>
39
+ <adminhtml>
40
+ <translate>
41
+ <modules>
42
+ <Sitewards_InstantSearchResult>
43
+ <files>
44
+ <default>Sitewards_InstantSearchResult.csv</default>
45
+ </files>
46
+ </Sitewards_InstantSearchResult>
47
+ </modules>
48
+ </translate>
49
+ </adminhtml>
50
+ <default>
51
+ <instantsearchresult>
52
+ <generalsettings>
53
+ <active>1</active>
54
+ </generalsettings>
55
+ </instantsearchresult>
56
+ </default>
57
+ </config>
app/code/community/Sitewards/InstantSearchResult/etc/system.xml ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Sitewards
5
+ * @package Sitewards_InstantSearchResult
6
+ * @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
7
+ */
8
+ -->
9
+ <config>
10
+ <sections>
11
+ <instantsearchresult translate="label" module="instantsearchresult">
12
+ <label>Instant Search Result</label>
13
+ <tab>catalog</tab>
14
+ <frontend_type>text</frontend_type>
15
+ <sort_order>990</sort_order>
16
+ <show_in_default>1</show_in_default>
17
+ <show_in_website>1</show_in_website>
18
+ <show_in_store>1</show_in_store>
19
+ <groups>
20
+ <generalsettings translate="label">
21
+ <label>General settings</label>
22
+ <frontend_type>text</frontend_type>
23
+ <sort_order>1</sort_order>
24
+ <show_in_default>1</show_in_default>
25
+ <show_in_website>1</show_in_website>
26
+ <show_in_store>1</show_in_store>
27
+ <fields>
28
+ <active translate="label,comment">
29
+ <label>Enable extension</label>
30
+ <frontend_type>select</frontend_type>
31
+ <source_model>adminhtml/system_config_source_yesno</source_model>
32
+ <sort_order>1</sort_order>
33
+ <show_in_default>1</show_in_default>
34
+ <show_in_website>1</show_in_website>
35
+ <show_in_store>1</show_in_store>
36
+ <comment><![CDATA[Enable or disable extension.]]></comment>
37
+ </active>
38
+ </fields>
39
+ </generalsettings>
40
+ </groups>
41
+ </instantsearchresult>
42
+ </sections>
43
+ </config>
app/etc/modules/Sitewards_InstantSearchResult.xml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Sitewards_InstantSearchResult.xml
5
+ * - Activate module,
6
+ * - Specify code pool,
7
+ * - Set-up dependencies
8
+ *
9
+ * @category Sitewards
10
+ * @package Sitewards_InstantSearchResult
11
+ * @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
12
+ */
13
+ -->
14
+ <config>
15
+ <modules>
16
+ <Sitewards_InstantSearchResult>
17
+ <active>true</active>
18
+ <codePool>community</codePool>
19
+ <depends>
20
+ <Mage_CatalogSearch/>
21
+ <Mage_Catalog/>
22
+ </depends>
23
+ </Sitewards_InstantSearchResult>
24
+ </modules>
25
+ </config>
app/locale/de_DE/Sitewards_InstantSearchResult.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ "General settings","Allgemeine Einstellungen"
2
+ "Enable extension","Extension aktivieren"
3
+ "Enable or disable extension.","Aktivieren oder Deaktivieren der Extension."
app/locale/en_US/Sitewards_InstantSearchResult.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ "General settings","General settings"
2
+ "Enable extension","Enable extension"
3
+ "Enable or disable extension.","Enable or disable extension."
app/locale/ru_RU/Sitewards_InstantSearchResult.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ "General settings","Общие настройки"
2
+ "Enable extension","Включить модуль"
3
+ "Enable or disable extension.","Включить/выключить модуль."
app/locale/uk_UA/Sitewards_InstantSearchResult.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ "General settings","Основні налаштування"
2
+ "Enable extension","Включити модуль"
3
+ "Enable or disable extension.", "Включити/виключити модуль."
package.xml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Sitewards_InstantSearchResult</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.opensource.org/licenses/gpl-license.php">GPL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>This extension provides functionality of redirecting to detailpage if there is only 1 product returned from the search</summary>
10
+ <description>Installation instruction&#xD;
11
+ ------------------------&#xD;
12
+ &#xD;
13
+ 1. Install and activate the extension</description>
14
+ <notes>Released new extension.</notes>
15
+ <authors><author><name>Sitewards Magento Team</name><user>sitewards</user><email>magento@sitewards.com</email></author></authors>
16
+ <date>2013-09-24</date>
17
+ <time>11:31:51</time>
18
+ <contents><target name="magecommunity"><dir name="Sitewards"><dir name="InstantSearchResult"><dir name="Helper"><file name="Data.php" hash="68a8093f47b7f1853f75c78ff1bf8270"/></dir><dir name="Model"><file name="Observer.php" hash="39e6ceb4ec54b6317ff761c5146a4448"/></dir><dir name="etc"><file name="adminhtml.xml" hash="6638c2c5eda505cae95eb1309bb4feb8"/><file name="config.xml" hash="7ab8f85e10f1a52b44fa455f49bd126b"/><file name="system.xml" hash="db557429d97741a67cdd9967a9108290"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Sitewards_InstantSearchResult.xml" hash="34eb0addc62509eaeb585dd9c78897ac"/></dir></target><target name="magelocale"><dir name="de_DE"><file name="Sitewards_InstantSearchResult.csv" hash="197191ebf7610a42f70f80197cab2c25"/></dir><dir name="en_US"><file name="Sitewards_InstantSearchResult.csv" hash="4751b8e81fd80b8d334594acadbd7ae8"/></dir><dir name="ru_RU"><file name="Sitewards_InstantSearchResult.csv" hash="6f4e5ba2a6d7d11d019d8f9293aae068"/></dir><dir name="uk_UA"><file name="Sitewards_InstantSearchResult.csv" hash="1d05c82f8f33dd1671abdd880c59289d"/></dir></target></contents>
19
+ <compatible/>
20
+ <dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
21
+ </package>