File tree Expand file tree Collapse file tree 5 files changed +98
-6
lines changed
Block/Adminhtml/System/Config/Form/Field Expand file tree Collapse file tree 5 files changed +98
-6
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Algolia \AlgoliaSearch \Block \Adminhtml \System \Config \Form \Field ;
4
+
5
+ use Magento \Config \Block \System \Config \Form \Field ;
6
+ use Magento \Framework \Data \Form \Element \AbstractElement ;
7
+
8
+ class Checkboxes extends Field
9
+ {
10
+ protected function _getElementHtml (AbstractElement $ element )
11
+ {
12
+ $ html = '' ;
13
+ $ elementId = $ element ->getHtmlId ();
14
+ $ name = $ element ->getName ();
15
+ $ options = $ element ->getValues ();
16
+ $ values = $ element ->getValue () ? explode (', ' , $ element ->getValue ()) : []; // store as CSV in config
17
+
18
+ foreach ($ options as $ option ) {
19
+ $ value = $ option ['value ' ];
20
+ $ label = $ option ['label ' ];
21
+ $ checked = in_array ($ value , $ values ) ? 'checked ' : '' ;
22
+ $ html .= '<label style="display:block"> ' ;
23
+ $ html .= sprintf (
24
+ '<input type="checkbox" name="%s[]" value="%s" %s /> %s ' ,
25
+ $ name ,
26
+ $ value ,
27
+ $ checked ,
28
+ $ label
29
+ );
30
+ $ html .= '</label> ' ;
31
+ }
32
+
33
+ return $ html ;
34
+ }
35
+ }
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ class AutocompleteRedirectMode implements OptionSourceInterface
13
13
/** @return array */
14
14
public function toOptionArray ()
15
15
{
16
- $ options = [
16
+ return [
17
17
[
18
18
'value ' => self ::SUBMIT_ONLY ,
19
19
'label ' => __ ('Do not display the redirect (handle on form submit only) ' ),
@@ -27,7 +27,5 @@ public function toOptionArray()
27
27
'label ' => __ ('Display both search hits and a selectable redirect ' ),
28
28
]
29
29
];
30
-
31
- return $ options ;
32
30
}
33
31
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Algolia \AlgoliaSearch \Model \Source ;
4
+
5
+ use Magento \Framework \Data \OptionSourceInterface ;
6
+
7
+ class InstantSearchRedirectOptions implements OptionSourceInterface
8
+ {
9
+ public const REDIRECT_ON_PAGE_LOAD = 1 ;
10
+ public const REDIRECT_ON_SEARCH_AS_YOU_TYPE = 2 ;
11
+ public const SELECTABLE_REDIRECT = 3 ;
12
+ public const OPEN_IN_NEW_WINDOW = 4 ;
13
+
14
+ /** @return array */
15
+ public function toOptionArray ()
16
+ {
17
+ return [
18
+ [
19
+ 'value ' => self ::REDIRECT_ON_PAGE_LOAD ,
20
+ 'label ' => __ ('Redirect on page load (if InstantSearch loads with a redirect, immediately take the user to that URL.) ' ),
21
+ ],
22
+ [
23
+ 'value ' => self ::REDIRECT_ON_SEARCH_AS_YOU_TYPE ,
24
+ 'label ' => __ ('Trigger redirect on "search as you type" ' ),
25
+ ],
26
+ [
27
+ 'value ' => self ::SELECTABLE_REDIRECT ,
28
+ 'label ' => __ ('Display the redirect as a selectable item above search result hits ' ),
29
+ ],
30
+ [
31
+ 'value ' => self ::OPEN_IN_NEW_WINDOW ,
32
+ 'label ' => __ ('Open redirect URL in a new window (applies to clickable links only) ' ),
33
+ ]
34
+ ];
35
+ }
36
+ }
Original file line number Diff line number Diff line change 334
334
<source_model >Magento\Config\Model\Config\Source\Yesno</source_model >
335
335
<comment >
336
336
<![CDATA[
337
- When enabled, Algolia-powered search results and listing pages can be redirected to a different URL based on rules configured in either the Dashboard or Merchandising Studio.
337
+ When enabled, Autocomplete can redirect searches to a different URL based on rules configured in either the Dashboard or Merchandising Studio.
338
338
]]>
339
339
</comment >
340
340
</field >
343
343
<source_model >Algolia\AlgoliaSearch\Model\Source\AutocompleteRedirectMode</source_model >
344
344
<comment >
345
345
<![CDATA[
346
- Use this setting to configure how redirects behave with Autocomplete.
346
+ Use this setting to configure how redirects behave within Autocomplete.
347
347
]]>
348
348
</comment >
349
349
<depends ><field id =" enable" >1</field ></depends >
555
555
</comment >
556
556
</field >
557
557
</group >
558
+ <group id =" instant_redirects" translate =" label" type =" text" sortOrder =" 10" showInDefault =" 1" showInWebsite =" 1" showInStore =" 1" >
559
+ <label >Redirects</label >
560
+ <attribute type =" expanded" >1</attribute >
561
+ <field id =" enable" translate =" label comment" type =" select" sortOrder =" 100" showInDefault =" 1" showInWebsite =" 1" showInStore =" 1" >
562
+ <label >Enable redirects</label >
563
+ <source_model >Magento\Config\Model\Config\Source\Yesno</source_model >
564
+ <comment >
565
+ <![CDATA[
566
+ When enabled, InstantSearch powered pages can be redirected to a different URL based on rules configured in either the Dashboard or Merchandising Studio.
567
+ ]]>
568
+ </comment >
569
+ </field >
570
+ <field id =" options" translate =" label comment" type =" select" sortOrder =" 100" showInDefault =" 1" showInWebsite =" 1" showInStore =" 1" >
571
+ <label >Redirect options</label >
572
+ <frontend_model >Algolia\AlgoliaSearch\Block\Adminhtml\System\Config\Form\Field\Checkboxes</frontend_model >
573
+ <source_model >Algolia\AlgoliaSearch\Model\Source\InstantSearchRedirectOptions</source_model >
574
+ <depends ><field id =" enable" >1</field ></depends >
575
+ </field >
576
+ </group >
558
577
</section >
559
578
<section id =" algoliasearch_products" translate =" label" type =" text" sortOrder =" 30" showInDefault =" 1" showInWebsite =" 1" showInStore =" 1" >
560
579
<label >Products</label >
Original file line number Diff line number Diff line change 28
28
</autocomplete >
29
29
<redirects >
30
30
<enable >1</enable >
31
- <mode >0 </mode >
31
+ <mode >1 </mode >
32
32
<target >0</target >
33
33
</redirects >
34
34
</algoliasearch_autocomplete >
45
45
<instantsearch_searchbox >1</instantsearch_searchbox >
46
46
<hide_pagination >0</hide_pagination >
47
47
</instant_options >
48
+ <instant_redirects >
49
+ <enable >1</enable >
50
+ <options >1,3</options >
51
+ </instant_redirects >
48
52
</algoliasearch_instant >
49
53
<algoliasearch_products >
50
54
<products >
You can’t perform that action at this time.
0 commit comments