Skip to content

Multiselect EAV Product Attribute not working in Mass Action #5459

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bh-ref opened this issue Jul 5, 2016 · 14 comments
Closed

Multiselect EAV Product Attribute not working in Mass Action #5459

bh-ref opened this issue Jul 5, 2016 · 14 comments
Labels
bug report Component: Catalog Fixed in 2.1.x The issue has been fixed in 2.1 release line Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development

Comments

@bh-ref
Copy link
Contributor

bh-ref commented Jul 5, 2016

Steps to reproduce

  1. Install Magento 2.1
  2. Create a product attribute with frontend input "multiselect" (and assign it to the necessary attribute sets).

Expected result

  1. You can set values via mass action.

Actual result

  1. If you want to use it via mass action from the grid, it does not set the selected values on the product(s).
@wardcapp
Copy link
Contributor

This issue was indeed not resolved with release 2.1 (as stated in your previous tickets). Seems like it is caused by some changes made to the admin frontend without taking the consequences to the bulk attribute update feature into account.

The following changes should address the problem:

diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/Attributes.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/Attributes.php
index 9c5d72f..0b857b5 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/Attributes.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/Attributes.php
@@ -128,15 +128,13 @@ class Attributes extends \Magento\Catalog\Block\Adminhtml\Form implements
      */
     protected function _getAdditionalElementHtml($element)
     {
-        // Add name attribute to checkboxes that correspond to multiselect elements
-        $nameAttributeHtml = $element->getExtType() === 'multiple' ? 'name="' . $element->getId() . '_checkbox"' : '';
         $elementId = $element->getId();
         $dataAttribute = "data-disable='{$elementId}'";
         $dataCheckboxName = "toggle_" . "{$elementId}";
         $checkboxLabel = __('Change');
         $html = <<<HTML
 <span class="attribute-change-checkbox">
-    <input type="checkbox" id="$dataCheckboxName" name="$dataCheckboxName" class="checkbox" $nameAttributeHtml onclick="toogleFieldEditMode(this, '{$elementId}')" $dataAttribute />
+    <input type="checkbox" id="$dataCheckboxName" name="$dataCheckboxName" class="checkbox" onclick="toogleFieldEditMode(this, '{$elementId}')" $dataAttribute />
     <label class="label" for="$dataCheckboxName">
         {$checkboxLabel}
     </label>
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php
index abe72e1..f878b89 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php
@@ -132,7 +132,7 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Product\Action\Attribut
                         $attributesData[$attributeCode] = $value;
                     } elseif ($attribute->getFrontendInput() == 'multiselect') {
                         // Check if 'Change' checkbox has been checked by admin for this attribute
-                        $isChanged = (bool)$this->getRequest()->getPost($attributeCode . '_checkbox');
+                        $isChanged = (bool)$this->getRequest()->getPost('toggle_' . $attributeCode);
                         if (!$isChanged) {
                             unset($attributesData[$attributeCode]);
                             continue;

Download / patch: 5459_multiselect_bulk_update_patch.txt

@bh-ref
Copy link
Contributor Author

bh-ref commented Jul 12, 2016

@wardcapp thank you for the patch!

@KevinMace
Copy link
Member

KevinMace commented Jul 27, 2016

I can confirm this issue exists when trying to save a single product with a multiselect element using 2.1 EE, the patch from @wardcapp resolved the issue for me, thank you.

@jvreeken
Copy link

jvreeken commented Aug 10, 2016

How can I apply this patch on 2.0.7 ? I am having the same problem with multiselect attibutes not changing when bulk editing in the catalog.

Edit - the paths for 2.0.7 are different:
vendor/magento/module-catalog/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/Attributes.php
vendor/magento/module-catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php

Manually editing these two files fixed the issue for me on 2.0.7 :) thanks!

@veloraven veloraven self-assigned this Aug 11, 2016
@veloraven
Copy link
Contributor

@bh-ref thank you for your report.
We already have internal ticket MAGETWO-55054 for this issue.
I have linked it to this one.

@veloraven veloraven added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Aug 12, 2016
@veloraven veloraven removed their assignment Aug 15, 2016
@ghost
Copy link

ghost commented Aug 21, 2016

Thank you so much for this patch.

@ghost
Copy link

ghost commented Aug 25, 2016

worked for me but to clarify in the attributes.php I removed the old line and in the save.php I added the new one underneath the old one.
Also in 2.1 the file paths are as jvreeken said:
vendor/magento/module-catalog/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/Attributes.php
vendor/magento/module-catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php

@afavata
Copy link

afavata commented Aug 31, 2016

Just upgraded to 2.1.1
Issue does still exist!

@wardcapp's solution has resolved defenetely the issue.
As per @rosandrest and @jvreeken the paths to the files are:
vendor/magento/module-catalog/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/Attributes.php
vendor/magento/module-catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php

@okorshenko can please take a look to this issue and get this done for the next release.
From past and current release notes this issue was meant to be already resolved but it is still present in 2.1.1

Thanks

@jvreeken
Copy link

Just upgraded to 2.1.2 and the issue still exists.
The patch at:
6278314
fixed the issue for me :)

@ghost
Copy link

ghost commented Oct 17, 2016

This patch worked for me on 2.1.2. Thanks @jvreeken.

@AgenturSchroeder
Copy link

Yep, this patch works fine on 2.1.2! Thanks @jvreeken

@Bashev
Copy link
Contributor

Bashev commented Dec 15, 2016

If field is required you must skip unchecked fields from validation. My fix -> webcodebg@c2a5e57

ver. 2.1.3

@jvreeken
Copy link

jvreeken commented Jan 5, 2017

It looks like they've included the patch 6278314 in v2.1.3 as I finally didn't have to fix this after upgrading... however the Attributes.php file was still the same....

@magento-engcom-team magento-engcom-team added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development bug report Component: Catalog Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed labels Sep 11, 2017
@magento-engcom-team
Copy link
Contributor

@bh-ref, thank you for your report.
The issue is already fixed in develop branch, 2.2.0, 2.1.9

@magento-engcom-team magento-engcom-team added Fixed in 2.1.x The issue has been fixed in 2.1 release line Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Oct 18, 2017
@magento-engcom-team magento-engcom-team added the Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed label Oct 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Component: Catalog Fixed in 2.1.x The issue has been fixed in 2.1 release line Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development
Projects
None yet
Development

No branches or pull requests