After couple hours together with XDebug I've found that attributes returned by \Magento\Eav\Model\Entity\AbstractEntity::getAttributesByCode depend on previous calls of \Magento\Catalog\Model\Product\Type\AbstractType::getSetAttributes . If the first product passed to it was having different attribute set than saved one then the result of \Magento\Eav\Model\Entity\AbstractEntity::_isApplicableAttribute was false negative inside of walkAttributes loop, form values are not applied to the stock model.
Having this issue as well
Done a hacky fix for now which seems to work.
Find the function addAttribute() in file module-eav/Model/Entity/AbstractEntity.php
And change the line:
$this->_attributesByCode[$attributeCode] = $attribute;
To:
if (!array_key_exists($attributeCode, $this->_attributesByCode)) {
$this->_attributesByCode[$attributeCode] = $attribute;
}
@Fel1xx Hi, thanks for reporting this issue. Internal ticket was created MAGETWO-70387.
@Fel1xx, thank you for your report.
The issue is already fixed in 2.2.0
Most helpful comment
Done a hacky fix for now which seems to work.
Find the function addAttribute() in file module-eav/Model/Entity/AbstractEntity.php
And change the line:
$this->_attributesByCode[$attributeCode] = $attribute;
To:
if (!array_key_exists($attributeCode, $this->_attributesByCode)) {
$this->_attributesByCode[$attributeCode] = $attribute;
}