7
7
8
8
use Magento \Sales \Api \Data \OrderAddressSearchResultInterface ;
9
9
use Magento \Sales \Model \ResourceModel \Order \Collection \AbstractCollection ;
10
- use Magento \Framework \Locale \ResolverInterface ;
11
- use Magento \Framework \Data \Collection \EntityFactoryInterface ;
12
- use Magento \Framework \Data \Collection \Db \FetchStrategyInterface ;
13
- use Magento \Framework \Event \ManagerInterface ;
14
- use Magento \Framework \Model \ResourceModel \Db \VersionControl \Snapshot ;
15
- use Magento \Framework \DB \Adapter \AdapterInterface ;
16
- use Magento \Framework \Model \ResourceModel \Db \AbstractDb ;
17
- use Magento \Framework \App \ObjectManager ;
18
- use Psr \Log \LoggerInterface ;
10
+ use Magento \Sales \Model \Order \Address ;
11
+ use Magento \Sales \Model \ResourceModel \Order \Address as AddressResource ;
19
12
20
13
/**
21
14
* Order addresses collection
@@ -36,44 +29,6 @@ class Collection extends AbstractCollection implements OrderAddressSearchResultI
36
29
*/
37
30
protected $ _eventObject = 'order_address_collection ' ;
38
31
39
- /**
40
- * @var ResolverInterface
41
- */
42
- private $ localeResolver ;
43
-
44
- /**
45
- * @param EntityFactoryInterface $entityFactory
46
- * @param LoggerInterface $logger
47
- * @param FetchStrategyInterface $fetchStrategy
48
- * @param ManagerInterface $eventManager
49
- * @param Snapshot $entitySnapshot
50
- * @param AdapterInterface|null $connection
51
- * @param AbstractDb|null $resource
52
- * @param ResolverInterface|null $localeResolver
53
- */
54
- public function __construct (
55
- EntityFactoryInterface $ entityFactory ,
56
- LoggerInterface $ logger ,
57
- FetchStrategyInterface $ fetchStrategy ,
58
- ManagerInterface $ eventManager ,
59
- Snapshot $ entitySnapshot ,
60
- AdapterInterface $ connection = null ,
61
- AbstractDb $ resource = null ,
62
- ResolverInterface $ localeResolver = null
63
- ) {
64
- $ this ->localeResolver = $ localeResolver ?: ObjectManager::getInstance ()
65
- ->get (ResolverInterface::class);
66
- parent ::__construct (
67
- $ entityFactory ,
68
- $ logger ,
69
- $ fetchStrategy ,
70
- $ eventManager ,
71
- $ entitySnapshot ,
72
- $ connection ,
73
- $ resource
74
- );
75
- }
76
-
77
32
/**
78
33
* Model initialization
79
34
*
@@ -82,21 +37,11 @@ public function __construct(
82
37
protected function _construct ()
83
38
{
84
39
$ this ->_init (
85
- \ Magento \ Sales \ Model \ Order \ Address::class,
86
- \ Magento \ Sales \ Model \ ResourceModel \ Order \Address ::class
40
+ Address::class,
41
+ AddressResource ::class
87
42
);
88
43
}
89
44
90
- /**
91
- * @inheritdoc
92
- */
93
- protected function _initSelect ()
94
- {
95
- parent ::_initSelect ();
96
- $ this ->joinRegions ();
97
- return $ this ;
98
- }
99
-
100
45
/**
101
46
* Redeclare after load method for dispatch event
102
47
*
@@ -110,31 +55,4 @@ protected function _afterLoad()
110
55
111
56
return $ this ;
112
57
}
113
-
114
- /**
115
- * Join region name table with current locale
116
- *
117
- * @return $this
118
- */
119
- private function joinRegions ()
120
- {
121
- $ locale = $ this ->localeResolver ->getLocale ();
122
- $ connection = $ this ->getConnection ();
123
-
124
- $ defaultNameExpr = $ connection ->getIfNullSql (
125
- $ connection ->quoteIdentifier ('rct.default_name ' ),
126
- $ connection ->quoteIdentifier ('main_table.region ' )
127
- );
128
- $ expression = $ connection ->getIfNullSql ($ connection ->quoteIdentifier ('rnt.name ' ), $ defaultNameExpr );
129
-
130
- $ regionId = $ connection ->quoteIdentifier ('main_table.region_id ' );
131
- $ condition = $ connection ->quoteInto ("rnt.locale=? " , $ locale );
132
- $ rctTable = $ this ->getTable ('directory_country_region ' );
133
- $ rntTable = $ this ->getTable ('directory_country_region_name ' );
134
-
135
- $ this ->getSelect ()
136
- ->joinLeft (['rct ' => $ rctTable ], "rct.region_id= {$ regionId }" , [])
137
- ->joinLeft (['rnt ' => $ rntTable ], "rnt.region_id= {$ regionId } AND {$ condition }" , ['region ' => $ expression ]);
138
- return $ this ;
139
- }
140
58
}
0 commit comments