6
6
* See COPYING.txt for license details.
7
7
*/
8
8
namespace Magento \ConfigurableProduct \Model ;
9
-
10
9
class SuggestedAttributeList
11
10
{
12
11
/**
13
12
* Attribute collection factory
14
13
*
15
14
* @var \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory
16
15
*/
17
- protected $ attributeCollectionFactory ;
18
-
16
+ protected $ _attributeColFactory ;
19
17
/**
20
18
* Catalog resource helper
21
19
*
22
20
* @var \Magento\Catalog\Model\Resource\Helper
23
21
*/
24
- protected $ resourceHelper ;
25
-
22
+ protected $ _resourceHelper ;
26
23
/**
27
- * Application Event Dispatcher
28
- *
29
- * @var \Magento\Framework\Event\ManagerInterface
30
- */
31
- protected $ eventManager ;
32
-
33
- /**
34
- * Object Factory
35
- *
36
- * @var \Magento\Framework\ObjectFactory
37
- */
38
- protected $ objectFactory ;
39
-
40
- /**
41
- * @param \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory
24
+ * @param \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $attributeColFactory
42
25
* @param \Magento\Catalog\Model\Resource\Helper $resourceHelper
43
- * @param \Magento\Framework\Event\ManagerInterface $eventManager
44
- * @param \Magento\Framework\ObjectFactory $objectFactory
45
26
*/
46
27
public function __construct (
47
- \Magento \Catalog \Model \Resource \Product \Attribute \CollectionFactory $ attributeCollectionFactory ,
48
- \Magento \Catalog \Model \Resource \Helper $ resourceHelper ,
49
- \Magento \Framework \Event \ManagerInterface $ eventManager ,
50
- \Magento \Framework \ObjectFactory $ objectFactory
28
+ \Magento \Catalog \Model \Resource \Product \Attribute \CollectionFactory $ attributeColFactory ,
29
+ \Magento \Catalog \Model \Resource \Helper $ resourceHelper
51
30
) {
52
- $ this ->attributeCollectionFactory = $ attributeCollectionFactory ;
53
- $ this ->resourceHelper = $ resourceHelper ;
54
- $ this ->objectFactory = $ objectFactory ;
55
- $ this ->eventManager = $ eventManager ;
31
+ $ this ->_attributeColFactory = $ attributeColFactory ;
32
+ $ this ->_resourceHelper = $ resourceHelper ;
56
33
}
57
-
58
34
/**
59
35
* Retrieve list of attributes with admin store label containing $labelPart
60
36
*
@@ -63,14 +39,12 @@ public function __construct(
63
39
*/
64
40
public function getSuggestedAttributes ($ labelPart )
65
41
{
66
- $ escapedLabelPart = $ this ->resourceHelper ->addLikeEscape ($ labelPart , ['position ' => 'any ' ]);
67
- $ availableFrontendTypes = $ this ->getAvailableFrontendTypes ();
68
-
42
+ $ escapedLabelPart = $ this ->_resourceHelper ->addLikeEscape ($ labelPart , ['position ' => 'any ' ]);
69
43
/** @var $collection \Magento\Catalog\Model\Resource\Product\Attribute\Collection */
70
- $ collection = $ this ->attributeCollectionFactory ->create ();
44
+ $ collection = $ this ->_attributeColFactory ->create ();
71
45
$ collection ->addFieldToFilter (
72
- 'main_table. frontend_input ' ,
73
- [ ' in ' => $ availableFrontendTypes -> getData ( ' values ' )]
46
+ 'frontend_input ' ,
47
+ ' select '
74
48
)->addFieldToFilter (
75
49
'frontend_label ' ,
76
50
['like ' => $ escapedLabelPart ]
@@ -81,7 +55,6 @@ public function getSuggestedAttributes($labelPart)
81
55
'is_global ' ,
82
56
\Magento \Catalog \Model \Resource \Eav \Attribute::SCOPE_GLOBAL
83
57
);
84
-
85
58
$ result = [];
86
59
$ types = [
87
60
\Magento \Catalog \Model \Product \Type::TYPE_SIMPLE ,
@@ -101,22 +74,4 @@ public function getSuggestedAttributes($labelPart)
101
74
}
102
75
return $ result ;
103
76
}
104
-
105
- /**
106
- * @return \Magento\Framework\Object
107
- */
108
- private function getAvailableFrontendTypes ()
109
- {
110
- $ availableFrontendTypes = $ this ->objectFactory ->create ();
111
- $ availableFrontendTypes ->setData (
112
- [
113
- 'values ' => ['select ' ]
114
- ]
115
- );
116
- $ this ->eventManager ->dispatch (
117
- 'product_suggested_attribute_frontend_type_init_after ' ,
118
- ['types_dto ' => $ availableFrontendTypes ]
119
- );
120
- return $ availableFrontendTypes ;
121
- }
122
77
}
0 commit comments