|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2022 |
|
6
|
|
|
* @package Client |
|
7
|
|
|
* @subpackage Html |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
namespace Aimeos\Client\Html\Catalog\Suggest; |
|
12
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Default implementation of catalog suggest section HTML clients. |
|
16
|
|
|
* |
|
17
|
|
|
* @package Client |
|
18
|
|
|
* @subpackage Html |
|
19
|
|
|
*/ |
|
20
|
|
|
class Standard |
|
21
|
|
|
extends \Aimeos\Client\Html\Common\Client\Factory\Base |
|
22
|
|
|
implements \Aimeos\Client\Html\Common\Client\Factory\Iface |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* Sets the necessary parameter values in the view. |
|
26
|
|
|
* |
|
27
|
|
|
* @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output |
|
28
|
|
|
* @param array &$tags Result array for the list of tags that are associated to the output |
|
29
|
|
|
* @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) |
|
30
|
|
|
* @return \Aimeos\MW\View\Iface Modified view object |
|
31
|
|
|
*/ |
|
32
|
|
|
public function data( \Aimeos\MW\View\Iface $view, array &$tags = [], string &$expire = null ) : \Aimeos\MW\View\Iface |
|
33
|
|
|
{ |
|
34
|
|
|
$context = $this->context(); |
|
35
|
|
|
$config = $context->config(); |
|
36
|
|
|
|
|
37
|
|
|
$cntl = \Aimeos\Controller\Frontend::create( $context, 'product' ) |
|
38
|
|
|
->text( $view->param( 'f_search' ) ); // sort by relevance first |
|
39
|
|
|
|
|
40
|
|
|
|
|
41
|
|
|
/** client/html/catalog/suggest/domains |
|
42
|
|
|
* List of domain items that should be fetched along with the products |
|
43
|
|
|
* |
|
44
|
|
|
* The suggsted entries for the full text search in the catalog filter component |
|
45
|
|
|
* usually consist of the names of the matched products. By default, only the |
|
46
|
|
|
* product item including the localized name is available. You can add more domains |
|
47
|
|
|
* like e.g. "media" to get the images of the product as well. |
|
48
|
|
|
* |
|
49
|
|
|
* **Note:** The more domains you will add, the slower the autocomplete requests |
|
50
|
|
|
* will be! Keep it to an absolute minium for user friendly response times. |
|
51
|
|
|
* |
|
52
|
|
|
* @param array List of domain names |
|
53
|
|
|
* @since 2016.08 |
|
54
|
|
|
* @see client/html/catalog/suggest/template-body |
|
55
|
|
|
* @see client/html/catalog/suggest/restrict |
|
56
|
|
|
* @see client/html/catalog/suggest/size |
|
57
|
|
|
*/ |
|
58
|
|
|
$domains = $config->get( 'client/html/catalog/suggest/domains', ['text'] ); |
|
59
|
|
|
|
|
60
|
|
|
/** client/html/catalog/suggest/size |
|
61
|
|
|
* The number of products shown in the list of suggestions |
|
62
|
|
|
* |
|
63
|
|
|
* Limits the number of products that are shown in the list of suggested |
|
64
|
|
|
* products. |
|
65
|
|
|
* |
|
66
|
|
|
* @param integer Number of products |
|
67
|
|
|
* @since 2018.10 |
|
68
|
|
|
* @see client/html/catalog/suggest/domains |
|
69
|
|
|
* @see client/html/catalog/suggest/restrict |
|
70
|
|
|
*/ |
|
71
|
|
|
$size = $config->get( 'client/html/catalog/suggest/size', 24 ); |
|
72
|
|
|
|
|
73
|
|
|
/** client/html/catalog/suggest/restrict |
|
74
|
|
|
* Restricts suggestions to category and attribute facets |
|
75
|
|
|
* |
|
76
|
|
|
* Limits the shown suggestions to the current category and selected |
|
77
|
|
|
* attribute facets. If disabled, suggestions are limited by the |
|
78
|
|
|
* entered text only. |
|
79
|
|
|
* |
|
80
|
|
|
* @param boolean True to use category and facets, false for all results |
|
81
|
|
|
* @since 2019.07 |
|
82
|
|
|
* @see client/html/catalog/suggest/domains |
|
83
|
|
|
* @see client/html/catalog/suggest/size |
|
84
|
|
|
*/ |
|
85
|
|
|
if( $config->get( 'client/html/catalog/suggest/restrict', true ) == true ) |
|
86
|
|
|
{ |
|
87
|
|
|
$level = $config->get( 'client/html/catalog/lists/levels', \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE ); |
|
88
|
|
|
$catids = $view->param( 'f_catid', $config->get( 'client/html/catalog/lists/catid-default' ) ); |
|
89
|
|
|
|
|
90
|
|
|
$cntl->category( $catids, 'default', $level ) |
|
91
|
|
|
->allOf( $view->param( 'f_attrid', [] ) ) |
|
92
|
|
|
->oneOf( $view->param( 'f_optid', [] ) ) |
|
93
|
|
|
->oneOf( $view->param( 'f_oneid', [] ) ); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
$view->suggestItems = $cntl->uses( $domains )->slice( 0, $size )->search(); |
|
97
|
|
|
|
|
98
|
|
|
return parent::data( $view, $tags, $expire ); |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
|
|
102
|
|
|
/** client/html/catalog/suggest/template-body |
|
103
|
|
|
* Relative path to the HTML body template of the catalog suggest client. |
|
104
|
|
|
* |
|
105
|
|
|
* The template file contains the HTML code and processing instructions |
|
106
|
|
|
* to generate the result shown in the body of the frontend. The |
|
107
|
|
|
* configuration string is the path to the template file relative |
|
108
|
|
|
* to the templates directory (usually in client/html/templates). |
|
109
|
|
|
* |
|
110
|
|
|
* You can overwrite the template file configuration in extensions and |
|
111
|
|
|
* provide alternative templates. These alternative templates should be |
|
112
|
|
|
* named like the default one but suffixed by |
|
113
|
|
|
* an unique name. You may use the name of your project for this. If |
|
114
|
|
|
* you've implemented an alternative client class as well, it |
|
115
|
|
|
* should be suffixed by the name of the new class. |
|
116
|
|
|
* |
|
117
|
|
|
* @param string Relative path to the template creating code for the HTML page body |
|
118
|
|
|
* @since 2015.02 |
|
119
|
|
|
* @see client/html/catalog/suggest/template-header |
|
120
|
|
|
* @see client/html/catalog/suggest/domains |
|
121
|
|
|
*/ |
|
122
|
|
|
|
|
123
|
|
|
/** client/html/catalog/suggest/template-header |
|
124
|
|
|
* Relative path to the HTML header template of the catalog suggest client. |
|
125
|
|
|
* |
|
126
|
|
|
* The template file contains the HTML code and processing instructions |
|
127
|
|
|
* to generate the HTML code that is inserted into the HTML page header |
|
128
|
|
|
* of the rendered page in the frontend. The configuration string is the |
|
129
|
|
|
* path to the template file relative to the templates directory (usually |
|
130
|
|
|
* in client/html/templates). |
|
131
|
|
|
* |
|
132
|
|
|
* You can overwrite the template file configuration in extensions and |
|
133
|
|
|
* provide alternative templates. These alternative templates should be |
|
134
|
|
|
* named like the default one but suffixed by |
|
135
|
|
|
* an unique name. You may use the name of your project for this. If |
|
136
|
|
|
* you've implemented an alternative client class as well, it |
|
137
|
|
|
* should be suffixed by the name of the new class. |
|
138
|
|
|
* |
|
139
|
|
|
* @param string Relative path to the template creating code for the HTML page head |
|
140
|
|
|
* @since 2015.02 |
|
141
|
|
|
* @see client/html/catalog/suggest/template-body |
|
142
|
|
|
* @see client/html/catalog/suggest/domains |
|
143
|
|
|
*/ |
|
144
|
|
|
} |
|
145
|
|
|
|