|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2016 |
|
6
|
|
|
* @package Controller |
|
7
|
|
|
* @subpackage Frontend |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
namespace Aimeos\Controller\Frontend\Index\Decorator; |
|
12
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Base for index frontend controller decorators |
|
16
|
|
|
* |
|
17
|
|
|
* @package Controller |
|
18
|
|
|
* @subpackage Frontend |
|
19
|
|
|
*/ |
|
20
|
|
|
abstract class Base |
|
21
|
|
|
implements \Aimeos\Controller\Frontend\Common\Decorator\Iface |
|
|
|
|
|
|
22
|
|
|
{ |
|
23
|
|
|
private $context; |
|
24
|
|
|
private $controller; |
|
25
|
|
|
|
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Initializes the controller decorator. |
|
29
|
|
|
* |
|
30
|
|
|
* @param \Aimeos\Controller\Frontend\Iface $controller Controller object |
|
31
|
|
|
* @param \Aimeos\MShop\Context\Item\Iface $context Context object with required objects |
|
32
|
|
|
*/ |
|
33
|
|
|
public function __construct( \Aimeos\Controller\Frontend\Iface $controller, \Aimeos\MShop\Context\Item\Iface $context ) |
|
34
|
|
|
{ |
|
35
|
|
|
$this->context = $context; |
|
36
|
|
|
$this->controller = $controller; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Passes unknown methods to wrapped objects. |
|
42
|
|
|
* |
|
43
|
|
|
* @param string $name Name of the method |
|
44
|
|
|
* @param array $param List of method parameter |
|
45
|
|
|
* @return mixed Returns the value of the called method |
|
46
|
|
|
* @throws \Aimeos\Controller\Frontend\Exception If method call failed |
|
47
|
|
|
*/ |
|
48
|
|
|
public function __call( $name, array $param ) |
|
49
|
|
|
{ |
|
50
|
|
|
return call_user_func_array( array( $this->controller, $name ), $param ); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Returns the given search filter with the conditions attached for filtering by attribute. |
|
56
|
|
|
* |
|
57
|
|
|
* @param \Aimeos\MW\Criteria\Iface $filter Criteria object used for product search |
|
58
|
|
|
* @param array $attrIds List of attribute IDs for faceted search |
|
59
|
|
|
* @param array $optIds List of OR-combined attribute IDs for faceted search |
|
60
|
|
|
* @param array $attrIds Associative list of OR-combined attribute IDs per attribute type for faceted search |
|
61
|
|
|
* @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
|
62
|
|
|
* @since 2017.03 |
|
63
|
|
|
*/ |
|
64
|
|
|
public function addFilterAttribute( \Aimeos\MW\Criteria\Iface $filter, array $attrIds, array $optIds, array $oneIds ) |
|
65
|
|
|
{ |
|
66
|
|
|
return $this->getController()->addFilterAttribute( $filter, $attrIds, $optIds, $oneIds ); |
|
|
|
|
|
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* Returns the given search filter with the conditions attached for filtering by category. |
|
72
|
|
|
* |
|
73
|
|
|
* @param \Aimeos\MW\Criteria\Iface $filter Criteria object used for product search |
|
74
|
|
|
* @param string|array $catId Selected category by the user |
|
75
|
|
|
* @param integer $level Constant for current category only, categories of next level (LEVEL_LIST) or whole subtree (LEVEL_SUBTREE) |
|
76
|
|
|
* @param string|null $sort Sortation of the product list like "name", "code", "price" and "position", null for no sortation |
|
77
|
|
|
* @param string $direction Sort direction of the product list ("+", "-") |
|
78
|
|
|
* @param string $listtype List type of the product associated to the category, usually "default" |
|
79
|
|
|
* @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
|
80
|
|
|
* @since 2017.03 |
|
81
|
|
|
*/ |
|
82
|
|
|
public function addFilterCategory( \Aimeos\MW\Criteria\Iface $filter, $catId, |
|
|
|
|
|
|
83
|
|
|
$level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE, $sort = null, $direction = '+', $listtype = 'default' ) |
|
84
|
|
|
{ |
|
85
|
|
|
return $this->getController()->addFilterCategory( $search, $catid, $level, $sort, $direction, $listtype ); |
|
|
|
|
|
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* Returns the given search filter with the conditions attached for filtering by text. |
|
91
|
|
|
* |
|
92
|
|
|
* @param \Aimeos\MW\Criteria\Iface $filter Criteria object used for product search |
|
93
|
|
|
* @param string $input Search string entered by the user |
|
94
|
|
|
* @param string|null $sort Sortation of the product list like "name", "code", "price" and "position", null for no sortation |
|
95
|
|
|
* @param string $direction Sort direction of the product list ("+", "-") |
|
96
|
|
|
* @param string $listtype List type of the text associated to the product, usually "default" |
|
97
|
|
|
* @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
|
98
|
|
|
* @since 2017.03 |
|
99
|
|
|
*/ |
|
100
|
|
|
public function addFilterText( \Aimeos\MW\Criteria\Iface $filter, $input, $sort = null, $direction = '+', $listtype = 'default' ) |
|
|
|
|
|
|
101
|
|
|
{ |
|
102
|
|
|
return $this->getController()->addIndexFilterText( $search, $input, $sort, $direction, $listtype ); |
|
|
|
|
|
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* Returns the aggregated count of products from the index for the given key. |
|
108
|
|
|
* |
|
109
|
|
|
* @param \Aimeos\MW\Criteria\Iface $filter Critera object which contains the filter conditions |
|
110
|
|
|
* @param string $key Search key to aggregate for, e.g. "index.attribute.id" |
|
111
|
|
|
* @return array Associative list of key values as key and the product count for this key as value |
|
112
|
|
|
* @since 2015.08 |
|
113
|
|
|
*/ |
|
114
|
|
|
public function aggregate( \Aimeos\MW\Criteria\Iface $filter, $key ) |
|
115
|
|
|
{ |
|
116
|
|
|
return $this->getController()->aggregate( $filter, $key ); |
|
|
|
|
|
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
|
|
120
|
|
|
/** |
|
121
|
|
|
* Returns the default index filter. |
|
122
|
|
|
* |
|
123
|
|
|
* @param string|null $sort Sortation of the product list like "name", "code", "price" and "position", null for no sortation |
|
124
|
|
|
* @param string $direction Sort direction of the product list ("+", "-") |
|
125
|
|
|
* @param integer $start Position in the list of found products where to begin retrieving the items |
|
126
|
|
|
* @param integer $size Number of products that should be returned |
|
127
|
|
|
* @param string $listtype Type of the product list, e.g. default, promotion, etc. |
|
128
|
|
|
* @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
|
129
|
|
|
* @since 2015.08 |
|
130
|
|
|
*/ |
|
131
|
|
|
public function createFilter( $sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default' ) |
|
132
|
|
|
{ |
|
133
|
|
|
return $this->getController()->createFilter( $sort, $direction, $start, $size, $listtype ); |
|
|
|
|
|
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
|
|
137
|
|
|
/** |
|
138
|
|
|
* Returns the product for the given product ID from the index |
|
139
|
|
|
* |
|
140
|
|
|
* @param string $productId Unique product ID |
|
141
|
|
|
* @param string[] $domains Domain names of items that are associated with the products and that should be fetched too |
|
142
|
|
|
* @return \Aimeos\MShop\Product\Item\Iface Product item including the referenced domains items |
|
143
|
|
|
* @since 2017.03 |
|
144
|
|
|
*/ |
|
145
|
|
|
public function getItem( $productId, array $domains = array( 'attribute', 'media', 'price', 'product', 'product/property', 'text' ) ) |
|
146
|
|
|
{ |
|
147
|
|
|
return $this->getController()->getItem( $productId, $domains ); |
|
|
|
|
|
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
|
|
151
|
|
|
/** |
|
152
|
|
|
* Returns the product for the given product ID from the index |
|
153
|
|
|
* |
|
154
|
|
|
* @param string[] $productIds List of unique product ID |
|
155
|
|
|
* @param string[] $domains Domain names of items that are associated with the products and that should be fetched too |
|
156
|
|
|
* @return \Aimeos\MShop\Product\Item\Iface[] Associative list of product IDs as keys and product items as values |
|
157
|
|
|
* @since 2017.03 |
|
158
|
|
|
*/ |
|
159
|
|
|
public function getItems( array $productIds, array $domains = array( 'media', 'price', 'text' ) ) |
|
160
|
|
|
{ |
|
161
|
|
|
return $this->getController()->getItems( $productIds, $domains ); |
|
|
|
|
|
|
162
|
|
|
} |
|
163
|
|
|
|
|
164
|
|
|
|
|
165
|
|
|
/** |
|
166
|
|
|
* Returns the products from the index filtered by the given criteria object. |
|
167
|
|
|
* |
|
168
|
|
|
* @param \Aimeos\MW\Criteria\Iface $filter Critera object which contains the filter conditions |
|
169
|
|
|
* @param string[] $domains Domain names of items that are associated with the products and that should be fetched too |
|
170
|
|
|
* @param integer &$total Parameter where the total number of found products will be stored in |
|
171
|
|
|
* @return array Ordered list of product items implementing \Aimeos\MShop\Product\Item\Iface |
|
172
|
|
|
* @since 2015.08 |
|
173
|
|
|
*/ |
|
174
|
|
|
public function searchItems( \Aimeos\MW\Criteria\Iface $filter, array $domains = array( 'media', 'price', 'text' ), &$total = null ) |
|
175
|
|
|
{ |
|
176
|
|
|
return $this->getController()->searchItems( $filter, $domains, $total ); |
|
|
|
|
|
|
177
|
|
|
} |
|
178
|
|
|
|
|
179
|
|
|
|
|
180
|
|
|
/** |
|
181
|
|
|
* Returns the context item |
|
182
|
|
|
* |
|
183
|
|
|
* @return \Aimeos\MShop\Context\Item\Iface Context item object |
|
184
|
|
|
*/ |
|
185
|
|
|
protected function getContext() |
|
186
|
|
|
{ |
|
187
|
|
|
return $this->context; |
|
188
|
|
|
} |
|
189
|
|
|
|
|
190
|
|
|
|
|
191
|
|
|
/** |
|
192
|
|
|
* Returns the frontend controller |
|
193
|
|
|
* |
|
194
|
|
|
* @return \Aimeos\Controller\Frontend\Common\Iface Frontend controller object |
|
195
|
|
|
*/ |
|
196
|
|
|
protected function getController() |
|
197
|
|
|
{ |
|
198
|
|
|
return $this->controller; |
|
199
|
|
|
} |
|
200
|
|
|
} |
|
201
|
|
|
|