Skip to content

Commit fd682b1

Browse files
committed
Merge remote-tracking branch 'act4/ACP2E-2974' into PR_13_OCT_2024
2 parents 0a935ad + b744678 commit fd682b1

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/OptionValueProvider.php

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
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

77
declare(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

Comments
 (0)