Skip to content

Commit 6e99004

Browse files
committed
MAGETWO-90569: Empty product attributes of dropdown/swatch types display as "No" of the storefront
1 parent a2a2a5d commit 6e99004

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

app/code/Magento/Eav/Model/Entity/Attribute/Frontend/AbstractFrontend.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public function getValue(\Magento\Framework\DataObject $object)
165165
$options = $opt->getAllOptions();
166166
if ($options) {
167167
foreach ($options as $option) {
168-
if ($option['value'] == $value) {
168+
if ($option['value'] === $value) {
169169
$valueOption = $option['label'];
170170
}
171171
}

dev/tests/integration/testsuite/Magento/Catalog/_files/dropdown_attribute.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
'is_filterable_in_search' => 0,
3333
'is_used_for_promo_rules' => 0,
3434
'is_html_allowed_on_front' => 1,
35-
'is_visible_on_front' => 0,
36-
'used_in_product_listing' => 0,
35+
'is_visible_on_front' => 1,
36+
'used_in_product_listing' => 1,
3737
'used_for_sort_by' => 0,
3838
'frontend_label' => ['Drop-Down Attribute'],
3939
'backend_type' => 'varchar',

dev/tests/integration/testsuite/Magento/Eav/Model/Entity/Attribute/Frontend/DefaultFrontendTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,21 @@ public function testGetSelectOptions()
7878
);
7979
}
8080

81+
/**
82+
* @magentoDataFixture Magento/Catalog/_files/dropdown_attribute.php
83+
* @return void
84+
*/
85+
public function testAttributeEntityValueNotSet()
86+
{
87+
$entity = $this->objectManager->create(\Magento\Catalog\Model\Product::class);
88+
$entity->setStoreId(0);
89+
$entity->load(1);
90+
$frontEnd = $this->attribute->loadByCode('catalog_product', 'dropdown_attribute');
91+
$value = $frontEnd->getFrontend()->getValue($entity);
92+
93+
$this->assertFalse($value);
94+
}
95+
8196
/**
8297
* Cache key generation
8398
* @return string

0 commit comments

Comments
 (0)