1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2025 |
6
|
|
|
* @package Client |
7
|
|
|
* @subpackage Html |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
namespace Aimeos\Client\Html\Catalog; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Common methods for the catalog HTML client classes. |
16
|
|
|
* |
17
|
|
|
* @package Client |
18
|
|
|
* @subpackage Html |
19
|
|
|
*/ |
20
|
|
|
abstract class Base |
21
|
|
|
extends \Aimeos\Client\Html\Common\Client\Factory\Base |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* Returns the URL for retrieving the stock levels |
25
|
|
|
* |
26
|
|
|
* @param \Aimeos\Base\View\Iface $view View instance with helper |
27
|
|
|
* @param \Aimeos\MShop\Product\Item\Iface[] List of products with their IDs as keys |
28
|
|
|
* @return \Aimeos\Map URLs to retrieve the stock levels for the given products |
29
|
|
|
*/ |
30
|
|
|
protected function getStockUrl( \Aimeos\Base\View\Iface $view, \Aimeos\Map $products ) : \Aimeos\Map |
31
|
|
|
{ |
32
|
|
|
/** client/html/catalog/stock/url/target |
33
|
|
|
* Destination of the URL where the controller specified in the URL is known |
34
|
|
|
* |
35
|
|
|
* The destination can be a page ID like in a content management system or the |
36
|
|
|
* module of a software development framework. This "target" must contain or know |
37
|
|
|
* the controller that should be called by the generated URL. |
38
|
|
|
* |
39
|
|
|
* @param string Destination of the URL |
40
|
|
|
* @since 2014.03 |
41
|
|
|
* @see client/html/catalog/stock/url/controller |
42
|
|
|
* @see client/html/catalog/stock/url/action |
43
|
|
|
* @see client/html/catalog/stock/url/config |
44
|
|
|
* @see client/html/catalog/stock/url/filter |
45
|
|
|
* @see client/html/catalog/stock/url/max-items |
46
|
|
|
*/ |
47
|
|
|
|
48
|
|
|
/** client/html/catalog/stock/url/controller |
49
|
|
|
* Name of the controller whose action should be called |
50
|
|
|
* |
51
|
|
|
* In Model-View-Controller (MVC) applications, the controller contains the methods |
52
|
|
|
* that create parts of the output displayed in the generated HTML page. Controller |
53
|
|
|
* names are usually alpha-numeric. |
54
|
|
|
* |
55
|
|
|
* @param string Name of the controller |
56
|
|
|
* @since 2014.03 |
57
|
|
|
* @see client/html/catalog/stock/url/target |
58
|
|
|
* @see client/html/catalog/stock/url/action |
59
|
|
|
* @see client/html/catalog/stock/url/config |
60
|
|
|
* @see client/html/catalog/stock/url/filter |
61
|
|
|
* @see client/html/catalog/stock/url/max-items |
62
|
|
|
*/ |
63
|
|
|
|
64
|
|
|
/** client/html/catalog/stock/url/action |
65
|
|
|
* Name of the action that should create the output |
66
|
|
|
* |
67
|
|
|
* In Model-View-Controller (MVC) applications, actions are the methods of a |
68
|
|
|
* controller that create parts of the output displayed in the generated HTML page. |
69
|
|
|
* Action names are usually alpha-numeric. |
70
|
|
|
* |
71
|
|
|
* @param string Name of the action |
72
|
|
|
* @since 2014.03 |
73
|
|
|
* @see client/html/catalog/stock/url/target |
74
|
|
|
* @see client/html/catalog/stock/url/controller |
75
|
|
|
* @see client/html/catalog/stock/url/config |
76
|
|
|
* @see client/html/catalog/stock/url/filter |
77
|
|
|
* @see client/html/catalog/stock/url/max-items |
78
|
|
|
*/ |
79
|
|
|
|
80
|
|
|
/** client/html/catalog/stock/url/config |
81
|
|
|
* Associative list of configuration options used for generating the URL |
82
|
|
|
* |
83
|
|
|
* You can specify additional options as key/value pairs used when generating |
84
|
|
|
* the URLs, like |
85
|
|
|
* |
86
|
|
|
* client/html/<clientname>/url/config = array( 'absoluteUri' => true ) |
87
|
|
|
* |
88
|
|
|
* The available key/value pairs depend on the application that embeds the e-commerce |
89
|
|
|
* framework. This is because the infrastructure of the application is used for |
90
|
|
|
* generating the URLs. The full list of available config options is referenced |
91
|
|
|
* in the "see also" section of this page. |
92
|
|
|
* |
93
|
|
|
* @param string Associative list of configuration options |
94
|
|
|
* @since 2014.03 |
95
|
|
|
* @see client/html/catalog/stock/url/target |
96
|
|
|
* @see client/html/catalog/stock/url/controller |
97
|
|
|
* @see client/html/catalog/stock/url/action |
98
|
|
|
* @see client/html/catalog/stock/url/filter |
99
|
|
|
* @see client/html/catalog/stock/url/max-items |
100
|
|
|
*/ |
101
|
|
|
|
102
|
|
|
/** client/html/catalog/stock/url/filter |
103
|
|
|
* Removes parameters for the detail page before generating the URL |
104
|
|
|
* |
105
|
|
|
* This setting removes the listed parameters from the URLs. Keep care to |
106
|
|
|
* remove no required parameters! |
107
|
|
|
* |
108
|
|
|
* @param array List of parameter names to remove |
109
|
|
|
* @since 2022.10 |
110
|
|
|
* @see client/html/catalog/stock/url/target |
111
|
|
|
* @see client/html/catalog/stock/url/controller |
112
|
|
|
* @see client/html/catalog/stock/url/action |
113
|
|
|
* @see client/html/catalog/stock/url/config |
114
|
|
|
* @see client/html/catalog/stock/url/max-items |
115
|
|
|
*/ |
116
|
|
|
|
117
|
|
|
/** client/html/catalog/stock/url/max-items |
118
|
|
|
* Maximum number of product stock levels per request |
119
|
|
|
* |
120
|
|
|
* To avoid URLs that exceed the maximum amount of characters (usually 8190), |
121
|
|
|
* each request contains only up to the configured amount of product codes. |
122
|
|
|
* If more product codes are available, several requests will be sent to the |
123
|
|
|
* server. |
124
|
|
|
* |
125
|
|
|
* @param integer Maximum number of product codes per request |
126
|
|
|
* @since 2018.10 |
127
|
|
|
* @see client/html/catalog/stock/url/target |
128
|
|
|
* @see client/html/catalog/stock/url/controller |
129
|
|
|
* @see client/html/catalog/stock/url/action |
130
|
|
|
* @see client/html/catalog/stock/url/config |
131
|
|
|
*/ |
132
|
|
|
$max = $view->config( 'client/html/catalog/stock/url/max-items', 100 ); |
133
|
|
|
|
134
|
|
|
|
135
|
|
|
$urls = []; |
136
|
|
|
$ids = $products->getId()->sort(); |
137
|
|
|
|
138
|
|
|
while( !( $list = $ids->splice( -$max ) )->isEmpty() ) { |
139
|
|
|
$urls[] = $view->link( 'client/html/catalog/stock/url', ['st_pid' => $list->toArray()] ); |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
return map( $urls )->reverse(); |
143
|
|
|
} |
144
|
|
|
} |
145
|
|
|
|