7

I'm getting this error on the firebug while loading homepage. Due to this error the pages are not loading fully. only the Header, Nav Menu and Footer and showing. The main content sections are not showing.

Tried a lot to debug the error but not successful. Any help ??

enter image description here

Google Chrome console error

enter image description here

enter image description here

17
  • have you tried static-content deploy Feb 20, 2017 at 6:07
  • 1
    @MurtuzaZabuawala : Yes... But didn't worked
    – Zammuuz
    Feb 20, 2017 at 6:37
  • please let me know which command Have you used for deploy, give full command. Feb 20, 2017 at 6:56
  • @RakeshJesadiya : Hi I used this command C:\wamp\bin\php\php5.6.30> php C:\wamp\www\magento\bin\magento setup:static-content:deploy and the result was Successful: 2217 files; errors: 0
    – Zammuuz
    Feb 20, 2017 at 6:59
  • please run command, C:\wamp\bin\php\php5.6.30> php C:\wamp\www\magento\bin\magento setup:static-content:deploy en_US en_GB let me know after run this command. Feb 20, 2017 at 7:00

9 Answers 9

7

The data that code references (sectionLoadUrl) is usually set in the following snippet that (should) be on every Magento front-end page

<script type="text/x-magento-init">
{"*":{"Magento_Customer\/js\/customer-data":{"sectionLoadUrl":"http:\/\/magento-2-1-4.dev\/customer\/section\/load\/","cookieLifeTime":"3600","updateSessionUrl":"http:\/\/magento-2-1-4.dev\/customer\/account\/updateSession\/"}}}    
</script>

So, either something in your system removed this snippet, or you're somehow invoking the functionality in Magento_Customer/js/customer-data before the snippet's had a chance to run.

4
  • 1
    M using this in footer.phtml file require([ 'Magento_Customer/js/customer-data' ], function (customerData) { var sections = ['cart']; customerData.invalidate(sections); customerData.reload(sections, true); }); And getting error as above. How to solve this?
    – Magecode
    Aug 26, 2017 at 13:23
  • @Magecode You should probably post that as a new question with more more details, and not as a comment. Aug 27, 2017 at 20:41
  • It's possible that this is an example of this issue: github.com/magento/magento2/pull/12314 Nov 16, 2017 at 20:45
  • @Magecode could you fix this error?
    – bpoiss
    Dec 7, 2017 at 9:53
3

I fixed it by adding following code to <Magento_directry>/app/design/frontend/<Vendor>/<theme>/Magento_Theme/layout/default.xml

  <referenceContainer name="content">
        <block name="customer.section.config" class="Magento\Customer\Block\SectionConfig"
               template="Magento_Customer::js/section-config.phtml"/>
        <block name="customer.customer.data"
               class="Magento\Customer\Block\CustomerData"
               template="Magento_Customer::js/customer-data.phtml"/>
    </referenceContainer>
1

Check your custom Module model files If you have installed some. There must be some typo error. I have faced the same problem and for me, it works as I have mistaken in Namespace path and due to that typo error it was generating same js error on all pages if not then remove module-customer from pub and try deploy theme again

5
  • Hi I have updated my question with a new image from chrome console. It shows sectionLoadUrl is undefined in options.sectionLoadUrl in Magento/Customer/view/frontend/web/js/customer-data.js.. Any idea how to resolve this?
    – Zammuuz
    Feb 20, 2017 at 8:32
  • I dont have any custom Module model files.. Anyhow i have double checked the namespaces of my custom Module Block files. This was working fine till morning. I was doing some style changes in my cms pages and footer. :( after that this error is showing while accessing home,login,register pages. CMS pages are fine.
    – Zammuuz
    Feb 20, 2017 at 11:03
  • can you please explain the changes you have done in CMS page ? Feb 20, 2017 at 11:35
  • Can you please send me the complete right side of chrome screenshot which you have attached. i cannot see the URL where it's generating error in pub file Feb 20, 2017 at 11:39
  • I have updated the chrome error image. the error is occurring in customer-data.js file. The changes I have made so far are 1) created custom theme with custom header, navigation menu, custom store switcher in header,custom footer. that's it.
    – Zammuuz
    Feb 21, 2017 at 2:02
1

I solved it removing the default.xml from my theme Magento_Customer.

app/design/frontend/Theme/Name/Magento_Customer/layout/default.xml

I think this custom module is loading before the snipped and the url for ajax call is not defined.

1

Fixed this using window on load:

    <script type="text/javascript">
require([
        'jquery'
    ],
    function($) {
        $(window).on("load", function() {
            require([
                'Magento_Checkout/js/model/cart/totals-processor/default',
                'Magento_Customer/js/customer-data',
                'Magento_Checkout/js/model/quote',
                'Magento_Checkout/js/model/shipping-rate-processor/new-address',
                'Magento_Checkout/js/model/shipping-rate-processor/customer-address',
                'Magento_Checkout/js/model/shipping-rate-registry'
            ], function(defaultTotal, customerData, quote, defaultProcessor, customerAddressProcessor, rateRegistry) {
                $(document).ready(function() {

                    /** Do your code here */
                });

            });
        });
    });
</script>
1
  • It is calling twice and when i click any additional fee button it is submitting twice. Mar 25, 2019 at 12:15
0

In our case this was a bit of code in a default template which was loading the customer-data.js file after it had already been called on the success page.

We found file: vendor/magento/module-checkout/view/frontend/templates/success.phtml

was loading this code:

<script>
    require([
        'Magento_Customer/js/customer-data'
    ], function (customerData) {
        var sections = ['cart'];
        customerData.invalidate(sections);
        customerData.reload(sections, true);
    });
</script>

Removing this code fixed it, which we did by creating a copy of this file in our theme templates directory and removing the offending code snippet.

You can use Chrome Dev tools to find out where the error was happening and then just before in that file on your local dev add in a console.trace(); call to establish what was calling the function which is throwing the error in the console. Follow the chain to where you are loading things improperly.

0

I had previously removed "content" container from theme.xml, I fixed it by adding following code to the theme.xml:

<referenceContainer name="content">
    <block name="customer.section.config" class="Magento\Customer\Block\SectionConfig"
           template="Magento_Customer::js/section-config.phtml"/>
    <block name="customer.customer.data"
           class="Magento\Customer\Block\CustomerData"
           template="Magento_Customer::js/customer-data.phtml"/>
</referenceContainer>
0

I removed content block which caused this error:

<referenceBlock name="content" display="false"/>

You can better hide it with css and not remove it in your xml

  .cms-index-index {
    .column.main {
      display: none;
    }
  }
0

In my case I had removed the 'main' container in a template.

Your Answer

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

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