diff --git a/app/code/core/Mage/Catalog/Model/Resource/Eav/Attribute.php b/app/code/core/Mage/Catalog/Model/Resource/Eav/Attribute.php index 76592f3769f..4ac2d25ec69 100644 --- a/app/code/core/Mage/Catalog/Model/Resource/Eav/Attribute.php +++ b/app/code/core/Mage/Catalog/Model/Resource/Eav/Attribute.php @@ -10,7 +10,7 @@ * @category Mage * @package Mage_Catalog * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2019-2024 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2019-2025 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -215,7 +215,7 @@ public function isScopeStore() /** * Retrieve store id * - * @return int + * @return int|null */ public function getStoreId() { @@ -223,7 +223,9 @@ public function getStoreId() if ($dataObject) { return $dataObject->getStoreId(); } - return (int) $this->getData('store_id'); + + $storeId = $this->getDataByKey('store_id'); + return is_null($storeId) ? null : (int) $storeId; } /** diff --git a/tests/unit/Mage/Catalog/Model/Resource/Eav/AttributeTest.php b/tests/unit/Mage/Catalog/Model/Resource/Eav/AttributeTest.php new file mode 100644 index 00000000000..2b0a588e64a --- /dev/null +++ b/tests/unit/Mage/Catalog/Model/Resource/Eav/AttributeTest.php @@ -0,0 +1,64 @@ +subject = Mage::getModel('catalog/resource_eav_attribute'); + } + + /** + * @dataProvider provideGetStoreId + * @group Mage_Catalog + * @group Mage_Catalog_Model + * @group Mage_Catalog_Model_Resource + */ + public function testGetStoreId($expectedResult, $withStoreId): void + { + if ($withStoreId) { + $this->subject->setStoreId($withStoreId); + } + $this->assertSame($expectedResult, $this->subject->getStoreId()); + } + + public function provideGetStoreId(): Generator + { + yield 'string' => [ + 1, + '1', + ]; + yield 'int' => [ + 1, + 1, + ]; + yield 'no store id' => [ + null, + null, + ]; + } +}