1.Magento 2.4-develop
1.Create attribute called Test Attribute ( Catalog Input Type for Store Owner=Dropdown)
Attribute value is not changed
The attribute moves to the other folder just fine, but the value of "dog" clears out.
Original issue description:
I have two attribute sets (Default and Test Attribute set). I have an attribute called Test Attribute. In the default set, I put the attribute in the main folder. In the test attribute set, I put the same attribute in a different folder.
I create a product in the default attribute set and set the value of the attribute to "dog". Save. Page reloads, and I change to the other attribute set. The attribute moves to the other folder just fine, but the value of "dog" clears out.
Is that an intentional behavior?
Just a quick thought, without looking into current code.
I don't see any specific reason to do it that way, attribute can be uniquely distinguished by attribute_code. If I remember correctly in some 2.0 RCs, when it was possible to add custom attribute to any folder right from Product Edit page, this scenario worked fine.
Probably data is mapped not using product[attribute_code] but some two-dimensional product[attribute_group][attribute_code] data structure. I'd suggest you or anyone else to treat current behavior as a bug and try to fix it.
@mzenner1, thank you for your report.
We've created internal ticket(s) MAGETWO-82631 to track progress on the issue.
Has this been fixed in 2.2.x?
Hi @engcom-Delta. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:
Component: XXXXX label(s) to the ticket, indicating the components it may be related to.[ ] 2. Verify that the issue is reproducible on 2.4-develop branchDetails
- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!
[ ] 3. If the issue is not relevant or is not reproducible any more, feel free to close it.
:white_check_mark: Confirmed by @engcom-Delta
Thank you for verifying the issue. Based on the provided information internal tickets MC-30076 were created
Issue Available: @engcom-Delta, _You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself._
Hello, guys. Me and @gabrielonbi developed a workaround for this. It's very simple. Do the modification on an existing module or create a new one .
Create the XML file with below content. This will make product form do not reload on attribute set change.
view/adminhtml/ui_component/product_form.xml
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<settings>
<reloadItem>false</reloadItem>
</settings>
</form>
Now we'll create a mixin to add new behaviour to attribute set change.
view/adminhtml/requirejs-config.js
var config = {
config: {
mixins: {
'Magento_Catalog/js/components/attribute-set-select': {
'Onbi_Core/js/attribute-set-select-mixin': true
}
}
}
};
view/adminhtml/web/js/attribute-set-select-mixin.js
/**
* Copyright 漏 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
define([
'Magento_Ui/js/form/element/ui-select',
'jquery',
'mage/url'
], function (Select, $, url) {
'use strict';
return function(attributeSetSelect){
return Select.extend({
toggleOptionSelected: function (data) {
var isSelected = this.isSelected(data.value);
if (this.lastSelectable && data.hasOwnProperty(this.separator)) {
return this;
}
if (!this.multiple) {
if (!isSelected) {
this.value(data.value);
}
this.listVisible(false);
} else {
if (!isSelected) { /*eslint no-lonely-if: 0*/
this.value.push(data.value);
} else {
this.value(_.without(this.value(), data.value));
}
}
window.location.href = window.location.origin + window.location.pathname + '?set=' + data.value;
return this;
}
});
};
});
And that's it. Basically we reload product page with the "set=[id]" parameter. Magento already has the rest of the code which make product form to load on attribute set sent on set parameter. User will have to save product yet to get the change saved to database, as it is on Magento default behaviour.
We've tested on Magento 2.3.2. Hope it helps.
@magento-engcom-team with a few more minor adjustments this can be a solution to be integrated to core. E.g. a confirmation message before reload page would be great to avoid loose data; but currently users are already loosing data if they do not pay attention for the wiped out input values.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 14 days if no further activity occurs. Thank you for your contributions.
Most helpful comment
Hello, guys. Me and @gabrielonbi developed a workaround for this. It's very simple. Do the modification on an existing module or create a new one .
Create the XML file with below content. This will make product form do not reload on attribute set change.
view/adminhtml/ui_component/product_form.xml
Now we'll create a mixin to add new behaviour to attribute set change.
view/adminhtml/requirejs-config.js
view/adminhtml/web/js/attribute-set-select-mixin.js
And that's it. Basically we reload product page with the "set=[id]" parameter. Magento already has the rest of the code which make product form to load on attribute set sent on set parameter. User will have to save product yet to get the change saved to database, as it is on Magento default behaviour.
We've tested on Magento 2.3.2. Hope it helps.
@magento-engcom-team with a few more minor adjustments this can be a solution to be integrated to core. E.g. a confirmation message before reload page would be great to avoid loose data; but currently users are already loosing data if they do not pay attention for the wiped out input values.