1
1
<?php
2
2
/**
3
- * Copyright © Magento, Inc. All rights reserved.
4
- * See COPYING.txt for license details .
3
+ * Copyright 2020 Adobe
4
+ * All Rights Reserved .
5
5
*/
6
6
7
7
declare (strict_types=1 );
@@ -21,12 +21,20 @@ class OptionValueProvider
21
21
*/
22
22
private $ connection ;
23
23
24
+ /**
25
+ * @var \Magento\Store\Model\StoreManagerInterface
26
+ */
27
+ private $ storeManager ;
24
28
/**
25
29
* @param ResourceConnection $connection
30
+ * @param \Magento\Store\Model\StoreManagerInterface $storeManager
26
31
*/
27
- public function __construct (ResourceConnection $ connection )
28
- {
32
+ public function __construct (
33
+ ResourceConnection $ connection ,
34
+ \Magento \Store \Model \StoreManagerInterface $ storeManager
35
+ ) {
29
36
$ this ->connection = $ connection ->getConnection ();
37
+ $ this ->storeManager = $ storeManager ;
30
38
}
31
39
32
40
/**
@@ -37,16 +45,16 @@ public function __construct(ResourceConnection $connection)
37
45
*/
38
46
public function get (int $ optionId ): ?string
39
47
{
48
+ $ storeId = $ this ->storeManager ->getStore ()->getId ();
40
49
$ select = $ this ->connection ->select ()
41
- ->from ($ this ->connection ->getTableName ('eav_attribute_option_value ' ), ' value ' )
50
+ ->from ($ this ->connection ->getTableName ('eav_attribute_option_value ' ), [ ' store_id ' , ' value '] )
42
51
->where ('option_id = ? ' , $ optionId );
43
52
44
- $ result = $ this ->connection ->fetchOne ($ select );
45
-
46
- if ($ result !== false ) {
47
- return $ result ;
53
+ $ records = $ this ->connection ->fetchAssoc ($ select );
54
+ if (empty ($ records )) {
55
+ return null ;
48
56
}
49
57
50
- return null ;
58
+ return $ records [ $ storeId ][ ' value ' ] ?? $ records [ 0 ][ ' value ' ] ;
51
59
}
52
60
}
0 commit comments