4
4
* See COPYING.txt for license details.
5
5
*/
6
6
7
-
8
7
/**
9
8
* CatalogWidget Rule Product Condition data model
10
9
*/
11
10
namespace Magento \CatalogWidget \Model \Rule \Condition ;
12
11
12
+ use \Magento \Catalog \Model \ResourceModel \Product \Collection as ProductCollection ;
13
+ use \Magento \Catalog \Model \ResourceModel \Eav \Attribute as EavAttribute ;
14
+ use \Magento \Store \Model \StoreManagerInterface ;
15
+ use \Magento \Catalog \Api \ProductRepositoryInterface ;
16
+ use \Magento \Framework \Locale \FormatInterface ;
17
+ use \Magento \Catalog \Model \ResourceModel \Category ;
18
+ use \Magento \Eav \Model \ResourceModel \Entity \Attribute \Set \Collection as AttributeSetCollection ;
19
+ use \Magento \Catalog \Model \ProductFactory ;
20
+ use \Magento \Eav \Model \Config ;
21
+ use \Magento \Rule \Model \Condition \Context ;
22
+ use \Magento \Backend \Helper \Data as BackendData ;
23
+
13
24
/**
14
25
* Class Product
15
- *
16
- * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
17
26
*/
18
27
class Product extends \Magento \Rule \Model \Condition \Product \AbstractProduct
19
28
{
@@ -30,36 +39,36 @@ class Product extends \Magento\Rule\Model\Condition\Product\AbstractProduct
30
39
/**
31
40
* Store manager
32
41
*
33
- * @var \Magento\Store\Model\ StoreManagerInterface
42
+ * @var StoreManagerInterface
34
43
*/
35
44
protected $ storeManager ;
36
45
37
46
/**
38
- * @param \Magento\Rule\Model\Condition\ Context $context
39
- * @param \Magento\Backend\Helper\Data $backendData
40
- * @param \Magento\Eav\Model\ Config $config
41
- * @param \Magento\Catalog\Model\ ProductFactory $productFactory
42
- * @param \Magento\Catalog\Api\ ProductRepositoryInterface $productRepository
47
+ * @param Context $context
48
+ * @param BackendData $backendData
49
+ * @param Config $config
50
+ * @param ProductFactory $productFactory
51
+ * @param ProductRepositoryInterface $productRepository
43
52
* @param \Magento\Catalog\Model\ResourceModel\Product $productResource
44
- * @param \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\Collection $attrSetCollection
45
- * @param \Magento\Framework\Locale\ FormatInterface $localeFormat
46
- * @param \Magento\Store\Model\ StoreManagerInterface $storeManager
53
+ * @param AttributeSetCollection $attrSetCollection
54
+ * @param FormatInterface $localeFormat
55
+ * @param StoreManagerInterface $storeManager
47
56
* @param array $data
48
- * @param \Magento\Catalog\Model\ResourceModel\ Category $category
57
+ * @param Category $category
49
58
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
50
59
*/
51
60
public function __construct (
52
- \ Magento \ Rule \ Model \ Condition \ Context $ context ,
53
- \ Magento \ Backend \ Helper \ Data $ backendData ,
54
- \ Magento \ Eav \ Model \ Config $ config ,
55
- \ Magento \ Catalog \ Model \ ProductFactory $ productFactory ,
56
- \ Magento \ Catalog \ Api \ ProductRepositoryInterface $ productRepository ,
61
+ Context $ context ,
62
+ BackendData $ backendData ,
63
+ Config $ config ,
64
+ ProductFactory $ productFactory ,
65
+ ProductRepositoryInterface $ productRepository ,
57
66
\Magento \Catalog \Model \ResourceModel \Product $ productResource ,
58
- \ Magento \ Eav \ Model \ ResourceModel \ Entity \ Attribute \ Set \ Collection $ attrSetCollection ,
59
- \ Magento \ Framework \ Locale \ FormatInterface $ localeFormat ,
60
- \ Magento \ Store \ Model \ StoreManagerInterface $ storeManager ,
67
+ AttributeSetCollection $ attrSetCollection ,
68
+ FormatInterface $ localeFormat ,
69
+ StoreManagerInterface $ storeManager ,
61
70
array $ data = [],
62
- \ Magento \ Catalog \ Model \ ResourceModel \ Category $ category = null
71
+ Category $ category = null
63
72
) {
64
73
$ this ->storeManager = $ storeManager ;
65
74
parent ::__construct (
@@ -111,7 +120,7 @@ protected function _addSpecialAttributes(array &$attributes)
111
120
/**
112
121
* Add condition to collection
113
122
*
114
- * @param \Magento\Catalog\Model\ResourceModel\Product\Collection $collection
123
+ * @param ProductCollection $collection
115
124
* @return $this
116
125
*/
117
126
public function addToCollection ($ collection )
@@ -142,14 +151,12 @@ public function addToCollection($collection)
142
151
}
143
152
144
153
/**
145
- * @param \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute
146
- * @param \Magento\Catalog\Model\ResourceModel\Product\Collection $collection
154
+ * @param EavAttribute $attribute
155
+ * @param ProductCollection $collection
147
156
* @return $this
148
157
*/
149
- protected function addGlobalAttribute (
150
- \Magento \Catalog \Model \ResourceModel \Eav \Attribute $ attribute ,
151
- \Magento \Catalog \Model \ResourceModel \Product \Collection $ collection
152
- ) {
158
+ protected function addGlobalAttribute (EavAttribute $ attribute , ProductCollection $ collection )
159
+ {
153
160
$ storeId = $ this ->storeManager ->getStore ()->getId ();
154
161
155
162
switch ($ attribute ->getBackendType ()) {
@@ -175,14 +182,12 @@ protected function addGlobalAttribute(
175
182
}
176
183
177
184
/**
178
- * @param \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute
179
- * @param \Magento\Catalog\Model\ResourceModel\Product\Collection $collection
185
+ * @param EavAttribute $attribute
186
+ * @param ProductCollection $collection
180
187
* @return $this
181
188
*/
182
- protected function addNotGlobalAttribute (
183
- \Magento \Catalog \Model \ResourceModel \Eav \Attribute $ attribute ,
184
- \Magento \Catalog \Model \ResourceModel \Product \Collection $ collection
185
- ) {
189
+ protected function addNotGlobalAttribute (EavAttribute $ attribute , ProductCollection $ collection )
190
+ {
186
191
$ storeId = $ this ->storeManager ->getStore ()->getId ();
187
192
$ values = $ collection ->getAllAttributeValues ($ attribute );
188
193
$ validEntities = [];
0 commit comments