Skip to content

Commit 2654a22

Browse files
committed
MAGETWO-97311: 2.3 only - creating attribute option value using API returns unexpected response
- Clear attribte options after saving attribute.
1 parent 46a307e commit 2654a22

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

app/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,9 @@ public function afterSave()
236236
) {
237237
$this->_indexerEavProcessor->markIndexerAsInvalid();
238238
}
239+
if ($this->_source !== null) {
240+
$this->_source->clearOptions();
241+
}
239242

240243
return parent::afterSave();
241244
}

app/code/Magento/Eav/Model/Entity/Attribute/Source/AbstractSource.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ public function getOptionText($value)
8080
}
8181

8282
/**
83+
* Get option id.
84+
*
8385
* @param string $value
8486
* @return null|string
8587
*/
@@ -93,6 +95,16 @@ public function getOptionId($value)
9395
return null;
9496
}
9597

98+
/**
99+
* Clear cached options.
100+
*
101+
* @return void
102+
*/
103+
public function clearOptions() : void
104+
{
105+
$this->_options = null;
106+
}
107+
96108
/**
97109
* Add Value Sort To Collection Select
98110
*

0 commit comments

Comments
 (0)