Skip to content

Commit 821e2dc

Browse files
committed
MAGETWO-50123: Login failed after new custom attribute was added
- removing SelectBackend class and fixing the problem from the javascript side by ensuring that select is posted even on empty value
1 parent 451634a commit 821e2dc

File tree

4 files changed

+8
-35
lines changed

4 files changed

+8
-35
lines changed

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -523,11 +523,11 @@ private function getPreviousSetAttributes()
523523
}
524524

525525
/**
526-
* Check is product already exists or we trying to create one
526+
* Check is product already new or we trying to create one
527527
*
528528
* @return bool
529529
*/
530-
private function isProductExists()
530+
private function isProductNew()
531531
{
532532
return (bool) $this->locator->getProduct()->getId();
533533
}
@@ -552,7 +552,7 @@ private function isProductHasValueForAttribute(ProductAttributeInterface $attrib
552552
*/
553553
private function isShowDefaultValue(ProductAttributeInterface $attribute)
554554
{
555-
if (!$this->isProductExists()) {
555+
if (!$this->isProductNew()) {
556556
return true;
557557
} elseif ($attribute->getIsRequired() && !$this->isProductHasValueForAttribute($attribute)) {
558558
return true;

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,6 @@ protected function _getDefaultBackendModel()
167167
break;
168168
}
169169

170-
// we should override default behaviour of Magento\Framework\Exception\LocalizedException\AbstractBackend
171-
// but can't do this in abstract model and can't update DB records because of backward compatibility
172-
if ($this->getFrontendInput() == 'select'
173-
&& !$this->getIsRequired()
174-
&& !$this->getBackendModel()
175-
) {
176-
return \Magento\Eav\Model\Entity\Attribute\Backend\SelectBackend::class;
177-
}
178-
179170
return parent::_getDefaultBackendModel();
180171
}
181172

app/code/Magento/Eav/Model/Entity/Attribute/Backend/SelectBackend.php

Lines changed: 0 additions & 22 deletions
This file was deleted.

app/code/Magento/Ui/view/base/web/js/form/element/select.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ define([
163163
this.observe('options')
164164
.setOptions(this.options());
165165

166+
if (_.isUndefined(this.value()) && !this.default) {
167+
this.clear();
168+
}
169+
166170
return this;
167171
},
168172

@@ -194,7 +198,7 @@ define([
194198
},
195199

196200
/**
197-
* Matches specfied value with existing options
201+
* Matches specified value with existing options
198202
* or, if value is not specified, returns value of the first option.
199203
*
200204
* @returns {*}

0 commit comments

Comments
 (0)