5
5
*/
6
6
namespace Magento \Framework \DB ;
7
7
8
+ use Magento \Framework \App \ObjectManager ;
8
9
use Magento \Framework \DB \Adapter \AdapterInterface ;
9
10
use Magento \Framework \DB \Query \Generator ;
10
11
use Magento \Framework \DB \DataConverter \DataConverterInterface ;
@@ -26,68 +27,51 @@ class FieldDataConverter
26
27
*/
27
28
private $ dataConverter ;
28
29
30
+ /**
31
+ * @var SelectFactory
32
+ */
33
+ private $ selectFactory ;
34
+
29
35
/**
30
36
* Constructor
31
37
*
32
38
* @param Generator $queryGenerator
33
39
* @param DataConverterInterface $dataConverter
40
+ * @param SelectFactory $selectFactory
34
41
*/
35
42
public function __construct (
36
43
Generator $ queryGenerator ,
37
- DataConverterInterface $ dataConverter
44
+ DataConverterInterface $ dataConverter ,
45
+ SelectFactory $ selectFactory = null
38
46
) {
39
47
$ this ->queryGenerator = $ queryGenerator ;
40
48
$ this ->dataConverter = $ dataConverter ;
49
+ $ this ->selectFactory = $ selectFactory ?: ObjectManager::getInstance ()->get (SelectFactory::class);
41
50
}
42
51
43
52
/**
44
- * Get converter select
53
+ * Convert table field data from one representation to another uses DataConverterInterface
45
54
*
46
55
* @param AdapterInterface $connection
47
56
* @param string $table
48
57
* @param string $identifier
49
58
* @param string $field
50
59
* @param QueryModifierInterface|null $queryModifier
51
- *
52
- * @return Select
53
- *
54
- * @deprecated The method will be removed in MAGETWO-63944.
60
+ * @return void
55
61
*/
56
- public function getSelect (
62
+ public function convert (
57
63
AdapterInterface $ connection ,
58
64
$ table ,
59
65
$ identifier ,
60
66
$ field ,
61
67
QueryModifierInterface $ queryModifier = null
62
68
) {
63
- $ select = $ connection -> select ( )
69
+ $ select = $ this -> selectFactory -> create ( $ connection )
64
70
->from ($ table , [$ identifier , $ field ])
65
71
->where ($ field . ' IS NOT NULL ' );
66
72
if ($ queryModifier ) {
67
73
$ queryModifier ->modify ($ select );
68
74
}
69
-
70
- return $ select ;
71
- }
72
-
73
- /**
74
- * Convert table field data from one representation to another uses DataConverterInterface
75
- *
76
- * @param AdapterInterface $connection
77
- * @param string $table
78
- * @param string $identifier
79
- * @param string $field
80
- * @param QueryModifierInterface|null $queryModifier
81
- * @return void
82
- */
83
- public function convert (
84
- AdapterInterface $ connection ,
85
- $ table ,
86
- $ identifier ,
87
- $ field ,
88
- QueryModifierInterface $ queryModifier = null
89
- ) {
90
- $ select = $ this ->getSelect ($ connection , $ table , $ identifier , $ field , $ queryModifier );
91
75
$ iterator = $ this ->queryGenerator ->generate ($ identifier , $ select );
92
76
foreach ($ iterator as $ selectByRange ) {
93
77
$ rows = $ connection ->fetchAll ($ selectByRange );
0 commit comments