4

I'm building a custom Magento theme that relies on a couple of third party JS libraries (slick, bootstrap) and I've suddenly hit a problem that I cannot figure out. When on the homepage I receive the error:

TypeError: options is undefined

In the customer-data.js file on line 85:

return $.getJSON(options.sectionLoadUrl, parameters).fail(function (jqXHR) {

This only happens on the homepage and any other page such as search results I do not receive this error, this leads me to believe it is the cause of some third party js on the homepage conflicting.

The shopping cart and Bootstrap.js stop working due to this error but slick slider continues to work fine. I've tried removing all code related to Slick and temporarily removed it from the RequireJS-Config file however this didn't change anything :(

Here's a link to the site in progress: removed

If anybody has had any experience with this any input would be much appreciated.

3

After debug I found that in default magento inside the options variable object with next data:

debug data default magento

On your site the options object is undefined:

debug data on site

I think the problem comes from the block:

<block name="customer.customer.data"
    class="Magento\Customer\Block\CustomerData"
    template="Magento_Customer::js/customer-data.phtml"/>

defined in the default.xml layout (default magento):

magento/module-customer/view/frontend/layout/default.xml

I think this block was removed from the layout of your home page. You should add it, because the customer data is an important part of the Magento functionality.

  • 1
    Unfortunately this didn't work as of yet, but thank you for the screenshots, it's given me a better idea of the problem and how to further debug any issues :) I'll report back with any findings. Thanks once again – Joe Jun 1 '17 at 8:33
  • Life saver, been causing me issues this! – Hunter Sep 11 '17 at 10:06
3

The resolution for me was removing the following line:

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

I put this in to hide the CMS content of the page however it caused the following script:

<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>

To not load, thus causing the error. I guess i'll find another method to hide CMS content

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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