magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.48k stars 9.29k forks source link

Upgrade 2.1.7 -> 2.1.8: Attribute Sets and Cart Price Rules not working #10586

Closed storepeinture closed 6 years ago

storepeinture commented 7 years ago

I have merged two issues together, because the workaround is the same and I believe they are somewhat related:

Preconditions

  1. Install Magento 2.1.7
  2. Create some products with different Attribute Sets
  3. Create some Cart Price Rules

A. Attribute Sets

Steps to reproduce

  1. Upgrade to Magento 2.1.8
  2. Add new product an choose one of the originally added attribute sets

Expected result

The specific attribute set is added to the new product

Actual result

The Cart Price Rule is not applied. The "Please wait ..." spinner is turning indefinitely

B. Cart Price Rule

Steps to reproduce

  1. Upgrade to Magento 2.1.8
  2. Create a new order in Magento Admin Backend
  3. Apply one of the Cart Price Rules

Expected result

The Cart Price Rule is applied

Actual result

The Cart Price Rule is not applied. I receive the following message:

"CODE_XXX" coupon code is not valid.

Workaround

In both cases it worked to delete the attribute set / cart price rule and create a new identical rule. For the attribute set, it is important to create the attribute set based on DEFAULT!

The problem seems to have existed under similar circumstances in prior installations. https://github.com/magento/magento2/issues/7825 In my case it only started after the upgrade from 2.1.7 -> 2.1.8.

jordanbrauer commented 7 years ago

The exact same attribute problem happened to me a while back in 2.1.2 / 2.1.4

It was in fact related to Magento system attributes for Default being moved from one category to another. In my case it was the price attribute.

What shows up in your dev tool console when your loading overlay hangs?

storepeinture commented 7 years ago

I get the following feedback from chrome dev tools console:

codemirror.js:3507 Uncaught TypeError: Cannot read property 'value' of null at Function.window.CodeMirror.CodeMirror.fromTextArea (codemirror.js:3507) at chrome-extension://akgknbhjhjdjhjgpknnblckigmofmopb/init.js:1

multiselect.js:52 Uncaught TypeError: Cannot read property 'length' of undefined at UiClass.setPrepareToSendData (multiselect.js:52) at setNested (objects.js:43) at Object.nested (objects.js:117) at UiClass.set (element.js:301) at updateValue (links.js:57) at Function.notifySubscribers (knockout.js:1103) at Function.observable.valueHasMutated (knockout.js:1300) at UiClass.observable [as value] (knockout.js:1285) at setNested (objects.js:43) at Object.nested (objects.js:117)

jordanbrauer commented 7 years ago

Looks to be the same error I got @storepeinture.

Compare the layout of the new Default attribute set to one of your attribute sets for the positions of any price/cost, image, stock levels, sku, etc (any & all system) attributes.

storepeinture commented 7 years ago

Hi Jordanbrauer, brillant advice!! Since I have customized the product attribute sets quite a bit to fit my needs, it took me a while to figure it out ... but in the end it all came down to one item that has moved to another category in the default version. I already saw myself creating a duplicate attribute set, but this way my installation stays clean 👍

Do you have any idea about the cart price rules issue? If I delete the current cart price rules, and create identical new ones everything works again. But I assume if you have 100s or coupon codes or so that might not be so practical.

Thank you!

Nino10 commented 7 years ago

Hey,

Can anyone post how the new default attribute set looks? We have the same problem and I have compared our default attribute set to our custom ones and they are the same with same order.

jordanbrauer commented 7 years ago

@storepeinture Glad that helped.

As for the cart price rules I have not a clue what would be causing that. Probably something related to storeid's like everything seems to be in Magento 2 though lol... ¯\_(ツ)/¯ Sorry dude.

Nino10 commented 7 years ago

I managed to get coupons working when recreating them but other cart price rules doesn't work. Does anyone have any ideas?

vityakopin commented 7 years ago

We have already created created internal ticket MAGETWO-58212 for the first issue. But second issue i can't reproduce, as described. Please add some additional information about cart price rule configuration or any information which would be helpful to reproduce it.

amenk commented 7 years ago

Is there a workaround?

storepeinture commented 7 years ago

Amenk, the workaround so far was: Save the rules somewhere, delete them, and recreate them ... then it worked again. But that's not how it should be.

vityakopin I have setup the cart price rule as follows:

Websites: Main Website Customer Groups: All Groups except NOT LOGGED IN Coupon: Specific Coupon Coupon Code: discount_10 Uses per Coupon: 0 Uses per Customer: 0 Conditions: Blank

Actions: Apply -> Percent of Product Price Discount Discount Amount -> 10

The rest is standard setting (ZERO, or turned off, or blank).

I hope this helps. If you need more info, I'm glad to help.

pankajpragma commented 7 years ago

I am facing the same issue with attribute set change. Getting error message in console "multiselect.js:52 Uncaught TypeError: Cannot read property 'length' of undefined" .

Is any fix available for Magento 2.1.8?

magento-engcom-team commented 7 years ago

@storepeinture thank you for your report. We were not able to reproduce this issue (part B) by following the steps you provided. Please try to reproduce this issue on a clean installation of Magento.

jordanbrauer commented 7 years ago

@pankajpragma Read my comment in this thread for the fix.


@magento-engcom-team The bug comes from the shops' current (previous version, before upgrading) Default attribute sets' attribute order not matching the new order of the attributes on the Default attribute set (after upgrading). This is true because after matching your attribute sets' system attributes to the order of the new Default attribute sets' attributes, the error goes away (see my linked comment above and @storepeinture\'s success with the fix)

For some reason that throws an error with the JS (assumably a Knockout thing). I'm not sure why the dev team feels the need to reorder the Default attribute sets' attributes so often (this has happened to us in two previous release upgrades lol), but if they do – then they probably need to consider taking a different approach on how the Default attribute set is handled. I see two ways upfront:

1) Decouple the order/category of the system attributes from whatever is causing the JS error within multiselect.js:52.

multiselect.js:52 Uncaught TypeError: Cannot read property 'length' of undefined
at UiClass.setPrepareToSendData (multiselect.js:52)
at setNested (objects.js:43)
at Object.nested (objects.js:117)
at UiClass.set (element.js:301)
at updateValue (links.js:57)
at Function.notifySubscribers (knockout.js:1103)
at Function.observable.valueHasMutated (knockout.js:1300)
at UiClass.observable [as value] (knockout.js:1285)
at setNested (objects.js:43)
at Object.nested (objects.js:117)

I am not JS expert, so I can't give much input here, but..... the error leads me to believe that Knockout is expecting the system attribute to be in a particular category, however it is not there due to being moved by shop owners/admins/devs.

2) Make system attributes un-editable/movable.

A simple but limiting fix /shrug.

Tjitse-E commented 6 years ago

@jordanbrauer fix worked for me. Just delete the new attribute set and recreate it based on the default attribute set.

magento-engcom-team commented 6 years ago

@storepeinture, thank you for your report. We were not able to reproduce this issue by following the steps you provided. If you'd like to update it, please reopen the issue. We tested the issue on 2.1.7, 2.1.8