11<?php
22/**
3- * Copyright © Magento, Inc. All rights reserved.
4- * See COPYING.txt for license details .
3+ * Copyright 2020 Adobe
4+ * All Rights Reserved .
55 */
66
77declare (strict_types=1 );
@@ -21,12 +21,20 @@ class OptionValueProvider
2121 */
2222 private $ connection ;
2323
24+ /**
25+ * @var \Magento\Store\Model\StoreManagerInterface
26+ */
27+ private $ storeManager ;
2428 /**
2529 * @param ResourceConnection $connection
30+ * @param \Magento\Store\Model\StoreManagerInterface $storeManager
2631 */
27- public function __construct (ResourceConnection $ connection )
28- {
32+ public function __construct (
33+ ResourceConnection $ connection ,
34+ \Magento \Store \Model \StoreManagerInterface $ storeManager
35+ ) {
2936 $ this ->connection = $ connection ->getConnection ();
37+ $ this ->storeManager = $ storeManager ;
3038 }
3139
3240 /**
@@ -37,16 +45,16 @@ public function __construct(ResourceConnection $connection)
3745 */
3846 public function get (int $ optionId ): ?string
3947 {
48+ $ storeId = $ this ->storeManager ->getStore ()->getId ();
4049 $ 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 '] )
4251 ->where ('option_id = ? ' , $ optionId );
4352
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 ;
4856 }
4957
50- return null ;
58+ return $ records [ $ storeId ][ ' value ' ] ?? $ records [ 0 ][ ' value ' ] ;
5159 }
5260}
0 commit comments