1

I use Magento2.4.6. When I upgraded to the latest version of the Mage fan Blog, after I entered the background Configuration, I could not save or open any other menus.

   Uncaught TypeError: locations.each is not a function
    at system.js:195:15
    at Object.execCb (require.js:1696:33)
    at Module.check (require.js:883:51)
    at Module.<anonymous> (require.js:1139:34)
    at require.js:134:23
    at require.js:1189:21
    at each (require.js:59:31)
    at Module.emit (require.js:1188:17)
    at Module.check (require.js:938:30)
    at Module.enable (require.js:1176:22)

https://prnt.sc/a6NwOndAK5q_

I tried this method, but it still didn't solve the problem.

Uncaught TypeError: locations.each is not a function in Magento admin showing occasionally on system configuration page in 2.4.5

https://prnt.sc/gYxCrLnMFLn6

How to solved this problem.

4
  • Could you kindly provide the system.xml file? Commented Oct 9, 2023 at 6:26
  • yes, the patch is not working because you used a different version of magento. the patch is for magento 2.4.5. Which magento version are using? I will provide you with a patch based on your magento version.
    – Msquare
    Commented Oct 9, 2023 at 11:03
  • You can create custom patch using this link magento.stackexchange.com/questions/256571/…
    – Msquare
    Commented Oct 9, 2023 at 11:06
  • I appreciate your help. I've solved this problem. I've put the method below.
    – Angelo
    Commented Oct 9, 2023 at 13:45

2 Answers 2

2

I see you already know there is a Patch for this issue and it work but if you want to directly apply patch then it not works because there always few changes in JS file based on versions

So you have to find the JS file vendor/paypal/module-braintree-core/view/adminhtml/web/js/system.js

After that find locations. Each( and replace it with $.each(locations, and also review if there is need of closing round bracket or not

If it works then create a patch for yourself and use composer as you are doing right now

Thanks

1
  • Thank you for your help. I may try it later, as it seems more manageable.
    – Angelo
    Commented Oct 9, 2023 at 14:03
0

I finally solved this problem by directly modifying the system.js file.

add the below lines in your vendor/paypal/module-braintree-core/view/adminhtml/web/js/system.js file

 locations.each(function (loc) {
    $('[data-ui-id="select-groups-braintree-section-groups-braintree-groups-braintree-paypal-groups-styling-groups-button-'+loc+'-fields-paypal-location-'+loc+'-button-type-value"]').change(function () {
        hidePaypalSections();
    });
});

to

 locations.each(function (loc) {
    buttonTypes.each(function (type) {
             $('[data-ui-id="select-groups-braintree-section-groups-braintree-groups-braintree-paypal-groups-styling-groups-button-' + loc + '-groups-button-location-' + loc + '-type-' + type + '-fields-button-location-' + loc + '-type-' + type + '-show-value"]').val(buttonShowStatus).click();
             $('[data-ui-id="select-groups-braintree-section-groups-braintree-groups-braintree-paypal-groups-styling-groups-button-' + loc + '-groups-button-location-' + loc + '-type-' + type + '-fields-button-location-' + loc + '-type-' + type + '-layout-value"]').val(buttonLayout).click();
    $('[data-ui-id="select-groups-braintree-section-groups-braintree-groups-braintree-paypal-groups-styling-groups-button-'+loc+'-fields-paypal-location-'+loc+'-button-type-value"]').change(function () {
        hidePaypalSections();
    });
});

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.