magento2 customer error – Fix ‘Broken Reference: The Element with the ‘customer’ ID Wasn’t Found’ Error in Magento 2

customererrormagento2

I am getting lots of

Broken reference: The element with the "customer" ID wasn't found. Verify the ID and try again. [] []

errors in the error.log. I've googled around and tried to trace it with NetBeans but I can't track down what's causing it. Everything seems to be working perfectly except this error is getting written repeatedly.

Has anyone any idea what's causing it or how I might track it down?

As some background, I migrated my site from 1.8.1 to 2.3 (and have since upgraded to 2.3.1 but the error started in 2.3). I wonder if something hasn't migrated correctly. Note it occurs in both developer and production mode.

Best Answer

I eventually tracked this down to the following lines in my app/design/frontend/vendor-name/theme-name/Magento_Theme/layout/default.xml where I am adding the classes header and links to the <ul> tag for the panel header:

<referenceContainer name="header.panel">
  <block class="Magento\Framework\View\Element\Html\Links" name="header.links">
    <arguments>
      <argument name="css_class" xsi:type="string">header links</argument>
    </arguments>
  </block>
</referenceContainer>

I have no idea why this causes an error. I found the following does the same but without the error (I've highlighted the change from above in upper case although in reality it needs to be lower case). Again I have no idea why this is more successful!

<referenceContainer name="header.panel">
  <block class="Magento\Framework\View\Element\Html\Links" name="CUSTOMER-ACCOUNT-LOGIN">
    <arguments>
      <argument name="css_class" xsi:type="string">header links</argument>
    </arguments>
  </block>
</referenceContainer>
Related Topic