|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2017 |
|
6
|
|
|
* @package Controller |
|
7
|
|
|
* @subpackage Frontend |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
namespace Aimeos\Controller\Frontend\Attribute; |
|
12
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Default implementation of the attribute frontend controller |
|
16
|
|
|
* |
|
17
|
|
|
* @package Controller |
|
18
|
|
|
* @subpackage Frontend |
|
19
|
|
|
*/ |
|
20
|
|
|
class Standard |
|
21
|
|
|
extends \Aimeos\Controller\Frontend\Base |
|
|
|
|
|
|
22
|
|
|
implements Iface, \Aimeos\Controller\Frontend\Common\Iface |
|
|
|
|
|
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* Returns the given search filter with the conditions attached for filtering by type code |
|
26
|
|
|
* |
|
27
|
|
|
* @param \Aimeos\MW\Criteria\Iface $filter Criteria object used for attribute search |
|
28
|
|
|
* @param array $codes List of attribute type codes |
|
29
|
|
|
* @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
|
30
|
|
|
* @since 2017.03 |
|
31
|
|
|
*/ |
|
32
|
|
|
public function addFilterTypes( \Aimeos\MW\Criteria\Iface $filter, array $codes ) |
|
33
|
|
|
{ |
|
34
|
|
|
if( !empty( $codes ) ) |
|
35
|
|
|
{ |
|
36
|
|
|
$expr = [ |
|
37
|
|
|
$filter->compare( '==', 'attribute.type.code', $codes ), |
|
38
|
|
|
$filter->getConditions(), |
|
39
|
|
|
]; |
|
40
|
|
|
$filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
return $filter; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Returns the default attribute filter |
|
49
|
|
|
* |
|
50
|
|
|
* @param boolean True to add default criteria |
|
51
|
|
|
* @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
|
52
|
|
|
* @since 2017.03 |
|
53
|
|
|
*/ |
|
54
|
|
|
public function createFilter() |
|
55
|
|
|
{ |
|
56
|
|
|
$filter = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' )->createSearch( true ); |
|
57
|
|
|
|
|
58
|
|
|
$expr = array( |
|
59
|
|
|
$filter->compare( '==', 'attribute.domain', 'product' ), |
|
60
|
|
|
$filter->getConditions(), |
|
61
|
|
|
); |
|
62
|
|
|
|
|
63
|
|
|
$filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
64
|
|
|
$filter->setSortations( array( $filter->sort( '+', 'attribute.position' ) ) ); |
|
65
|
|
|
|
|
66
|
|
|
return $filter; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* Returns the attribute item for the given attribute ID |
|
72
|
|
|
* |
|
73
|
|
|
* @param string $id Unique attribute ID |
|
74
|
|
|
* @param string[] $domains Domain names of items that are associated with the attributes and that should be fetched too |
|
75
|
|
|
* @return \Aimeos\MShop\Attribute\Item\Iface Attribute item including the referenced domains items |
|
76
|
|
|
* @since 2017.03 |
|
77
|
|
|
*/ |
|
78
|
|
|
public function getItem( $id, array $domains = array( 'media', 'price', 'text' ) ) |
|
79
|
|
|
{ |
|
80
|
|
|
return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' )->getItem( $id, $domains ); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* Returns the attributes filtered by the given criteria object |
|
86
|
|
|
* |
|
87
|
|
|
* @param \Aimeos\MW\Criteria\Iface $filter Critera object which contains the filter conditions |
|
88
|
|
|
* @param string[] $domains Domain names of items that are associated with the attributes and that should be fetched too |
|
89
|
|
|
* @param integer &$total Parameter where the total number of found attributes will be stored in |
|
90
|
|
|
* @return array Ordered list of attribute items implementing \Aimeos\MShop\Attribute\Item\Iface |
|
91
|
|
|
* @since 2017.03 |
|
92
|
|
|
*/ |
|
93
|
|
|
public function searchItems( \Aimeos\MW\Criteria\Iface $filter, array $domains = array( 'media', 'price', 'text' ), &$total = null ) |
|
94
|
|
|
{ |
|
95
|
|
|
return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' )->searchItems( $filter, $domains, $total ); |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
|