Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ public function beforeSave($object)
$attributeCode = $this->getAttribute()->getName();
if ($object->getData('use_config_' . $attributeCode)) {
$object->setData($attributeCode, BooleanSource::VALUE_USE_CONFIG);
return $this;
}
return $this;

return parent::beforeSave($object);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public function apply()
'visible' => false,
'required' => false,
'user_defined' => false,
'default' => '0',
'default' => null,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gelanivishal Thank you but that's not correct since this change won't apply to already installed instances of Magento. You need to create another named patch.

'searchable' => false,
'filterable' => false,
'comparable' => false,
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Downloadable/etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Magento_Downloadable" >
<module name="Magento_Downloadable">
<sequence>
<module name="Magento_Catalog"/>
</sequence>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,9 +416,7 @@ public function getIsVisibleOnFront()
}

/**
* Returns default value
*
* @return string|int|bool|float
* @return string|null
* @codeCoverageIgnore
*/
public function getDefaultValue()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,12 @@ public function getEntityValueId($entity)
/**
* Retrieve default value
*
* @return mixed
* @return string
*/
public function getDefaultValue()
{
if ($this->_defaultValue === null) {
if ($this->getAttribute()->getDefaultValue()) {
if ($this->getAttribute()->getDefaultValue() !== null) {
$this->_defaultValue = $this->getAttribute()->getDefaultValue();
} else {
$this->_defaultValue = "";
Expand Down Expand Up @@ -285,7 +285,7 @@ public function afterLoad($object)
public function beforeSave($object)
{
$attrCode = $this->getAttribute()->getAttributeCode();
if (!$object->hasData($attrCode) && $this->getDefaultValue()) {
if (!$object->hasData($attrCode) && $this->getDefaultValue() !== '') {
$object->setData($attrCode, $this->getDefaultValue());
}

Expand Down