Skip to content

Commit d4901af

Browse files
authored
Hotfix: Incorrect attribute localization (#4441)
* fixes #4437 * php-cs * changed tests * reverted unrelated changes * minor improvement
1 parent 6bd652a commit d4901af

File tree

2 files changed

+69
-3
lines changed

2 files changed

+69
-3
lines changed

app/code/core/Mage/Catalog/Model/Resource/Eav/Attribute.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* @category Mage
1111
* @package Mage_Catalog
1212
* @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com)
13-
* @copyright Copyright (c) 2019-2024 The OpenMage Contributors (https://www.openmage.org)
13+
* @copyright Copyright (c) 2019-2025 The OpenMage Contributors (https://www.openmage.org)
1414
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
1515
*/
1616

@@ -215,15 +215,17 @@ public function isScopeStore()
215215
/**
216216
* Retrieve store id
217217
*
218-
* @return int
218+
* @return int|null
219219
*/
220220
public function getStoreId()
221221
{
222222
$dataObject = $this->getDataObject();
223223
if ($dataObject) {
224224
return $dataObject->getStoreId();
225225
}
226-
return (int) $this->getData('store_id');
226+
227+
$storeId = $this->getDataByKey('store_id');
228+
return is_null($storeId) ? null : (int) $storeId;
227229
}
228230

229231
/**
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
3+
/**
4+
* OpenMage
5+
*
6+
* This source file is subject to the Open Software License (OSL 3.0)
7+
* that is bundled with this package in the file LICENSE.txt.
8+
* It is also available at https://opensource.org/license/osl-3-0-php
9+
*
10+
* @category OpenMage
11+
* @package OpenMage_Tests
12+
* @copyright Copyright (c) 2025 The OpenMage Contributors (https://www.openmage.org)
13+
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14+
*/
15+
16+
declare(strict_types=1);
17+
18+
namespace OpenMage\Tests\Unit\Mage\Catalog\Model\Resource\Eav;
19+
20+
use Generator;
21+
use Mage;
22+
use Mage_Catalog_Model_Resource_Eav_Attribute;
23+
use PHPUnit\Framework\TestCase;
24+
25+
class AttributeTest extends TestCase
26+
{
27+
public Mage_Catalog_Model_Resource_Eav_Attribute $subject;
28+
29+
public function setUp(): void
30+
{
31+
Mage::app();
32+
$this->subject = Mage::getModel('catalog/resource_eav_attribute');
33+
}
34+
35+
/**
36+
* @dataProvider provideGetStoreId
37+
* @group Mage_Catalog
38+
* @group Mage_Catalog_Model
39+
* @group Mage_Catalog_Model_Resource
40+
*/
41+
public function testGetStoreId($expectedResult, $withStoreId): void
42+
{
43+
if ($withStoreId) {
44+
$this->subject->setStoreId($withStoreId);
45+
}
46+
$this->assertSame($expectedResult, $this->subject->getStoreId());
47+
}
48+
49+
public function provideGetStoreId(): Generator
50+
{
51+
yield 'string' => [
52+
1,
53+
'1',
54+
];
55+
yield 'int' => [
56+
1,
57+
1,
58+
];
59+
yield 'no store id' => [
60+
null,
61+
null,
62+
];
63+
}
64+
}

0 commit comments

Comments
 (0)