Passed
Push — master ( 283bfd...df9032 )
by Aimeos
04:29
created

Standard::body()   A

Complexity

Conditions 3
Paths 9

Size

Total Lines 46
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 14
nc 9
nop 1
dl 0
loc 46
rs 9.7998
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Metaways Infosystems GmbH, 2013
6
 * @copyright Aimeos (aimeos.org), 2015-2022
7
 * @package Client
8
 * @subpackage Html
9
 */
10
11
12
namespace Aimeos\Client\Html\Catalog\Stock;
13
14
15
/**
16
 * Default implementation of catalog stock HTML clients.
17
 *
18
 * @package Client
19
 * @subpackage Html
20
 */
21
class Standard
22
	extends \Aimeos\Client\Html\Common\Client\Factory\Base
23
	implements \Aimeos\Client\Html\Common\Client\Factory\Iface
24
{
25
	/**
26
	 * Sets the necessary parameter values in the view.
27
	 *
28
	 * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output
29
	 * @param array &$tags Result array for the list of tags that are associated to the output
30
	 * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
31
	 * @return \Aimeos\MW\View\Iface Modified view object
32
	 */
33
	public function data( \Aimeos\MW\View\Iface $view, array &$tags = [], string &$expire = null ) : \Aimeos\MW\View\Iface
34
	{
35
		$stockItemsByProducts = [];
0 ignored issues
show
Unused Code introduced by
The assignment to $stockItemsByProducts is dead and can be removed.
Loading history...
36
		$context = $this->context();
37
		$prodIds = (array) $view->param( 'st_pid', [] );
38
39
		/** client/html/catalog/stock/sort
40
		 * Sortation key if stock levels for different types exist
41
		 *
42
		 * Products can be shipped from several warehouses with a different
43
		 * stock level for each one. The stock levels for each warehouse will
44
		 * be shown in the product detail page. To get a consistent sortation
45
		 * of this list, the configured key will be used by the stock manager.
46
		 *
47
		 * Possible keys for sorting are ("-stock.type" for descending order):
48
		 *
49
		 * * stock.productid
50
		 * * stock.stocklevel
51
		 * * stock.type
52
		 * * stock.dateback
53
		 *
54
		 * @param array List of key/value pairs for sorting
55
		 * @since 2017.01
56
		 * @category Developer
57
		 * @see client/html/catalog/stock/level/low
58
		 */
59
		$sort = $context->config()->get( 'client/html/catalog/stock/sort', 'stock.type' );
60
		$type = $context->locale()->getSiteItem()->getConfigValue( 'stocktype' );
61
62
		$view->stockProductIds = $prodIds;
63
		$view->stockItemsByProducts = \Aimeos\Controller\Frontend::create( $context, 'stock' )
64
			->product( $prodIds )->type( $type )->sort( $sort )
65
			->slice( 0, count( $prodIds ) )
66
			->search()
67
			->groupBy( 'stock.productid' );
68
69
		return parent::data( $view, $tags, $expire );
70
	}
71
72
73
	/** client/html/catalog/stock/template-body
74
	 * Relative path to the HTML body template of the catalog stock client.
75
	 *
76
	 * The template file contains the HTML code and processing instructions
77
	 * to generate the result shown in the body of the frontend. The
78
	 * configuration string is the path to the template file relative
79
	 * to the templates directory (usually in client/html/templates).
80
	 *
81
	 * You can overwrite the template file configuration in extensions and
82
	 * provide alternative templates. These alternative templates should be
83
	 * named like the default one but suffixed by
84
	 * an unique name. You may use the name of your project for this. If
85
	 * you've implemented an alternative client class as well, it
86
	 * should be suffixed by the name of the new class.
87
	 *
88
	 * @param string Relative path to the template creating code for the HTML page body
89
	 * @since 2014.03
90
	 * @category Developer
91
	 * @see client/html/catalog/stock/template-header
92
	 */
93
94
	/** client/html/catalog/stock/template-header
95
	 * Relative path to the HTML header template of the catalog stock client.
96
	 *
97
	 * The template file contains the HTML code and processing instructions
98
	 * to generate the HTML code that is inserted into the HTML page header
99
	 * of the rendered page in the frontend. The configuration string is the
100
	 * path to the template file relative to the templates directory (usually
101
	 * in client/html/templates).
102
	 *
103
	 * You can overwrite the template file configuration in extensions and
104
	 * provide alternative templates. These alternative templates should be
105
	 * named like the default one but suffixed by
106
	 * an unique name. You may use the name of your project for this. If
107
	 * you've implemented an alternative client class as well, it
108
	 * should be suffixed by the name of the new class.
109
	 *
110
	 * @param string Relative path to the template creating code for the HTML page head
111
	 * @since 2014.03
112
	 * @category Developer
113
	 * @see client/html/catalog/stock/template-body
114
	 */
115
}
116