magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

Layout xml update breaks minicart.

Open LiamFielding opened this issue 10 years ago • 11 comments

Steps to reproduce

  1. Install Magento from develop branch.
  2. Move or place Cart\Sidebar (Minicart?) block in another container through Magento_checkout_layout_default.xml. I chose header.panel.

Expected result

  1. Minicart moved but works exactly the same way.

Actual result

  1. Minicart breaks, fails to show products in dropdown, template broken.
  2. Error message appears:
Uncaught TypeError: Unable to process binding "if: function (){return cart().summary_count }"
Message: Unable to process binding "foreach: function (){return { data:cart().items,as:'item'} }"
Message: Unable to process binding "foreach: function (){return $parent.getRegion($parent.getItemRenderer(item.product_type)) }"
Message: Cannot read property 'simple' of undefined

erro

LiamFielding avatar May 23 '16 11:05 LiamFielding

@LiamFielding Thank you for reporting the issue. cart().summary_count is not used anymore in the develop branch, could you please update and recheck?

ishakhsuvarov avatar May 24 '16 06:05 ishakhsuvarov

According to contributor guide, tickets without response for two weeks should be closed. Please feel free to reopen if it's needed.

palamar avatar Jul 07 '16 13:07 palamar

Have the same issue from the 2.1. master branch, any updates on this?

jan-dh avatar Aug 11 '16 15:08 jan-dh

Having the same issue still using magento 2.1 Enterprise version. any update on this issue? That is happening when we create custom theme

hbhardik avatar Aug 22 '16 10:08 hbhardik

Having the same issue I am seeing.

I have installed the Magento 2.1.0

I have made the custom theme and move the mini cart to custom header.

After Adding the product to cart.

In console this error is coming http://prntscr.com/cqu1cd

Mini cart is display this content http://prntscr.com/cqu1fj

Cache is enabled only mini cart dispplay totoal items

jigar48 avatar Oct 07 '16 06:10 jigar48

I also have same problem but on Magento version: 2.0.7 http://prntscr.com/cy4lkj Cart display: http://prntscr.com/cy4lmx

blackworm avatar Oct 24 '16 02:10 blackworm

I also have problem regarding on creating custom theme, Im using Magento 2.1.1 version. Screenshots: http://screencast.com/t/Zc9phqMMQ http://screencast.com/t/S8cETnk84

noprobz09 avatar Oct 26 '16 10:10 noprobz09

I also have problem, Im using Magento 2.1.3 version.

http://www.screencast.com/t/AN3xRUGU

davinanaya avatar Mar 11 '17 17:03 davinanaya

@jan-dh @hbhardik @jigar48 @blackworm @noprobz09 @davinanaya to bring attention just open new issue, properly formatted, stating it is for 2.1 version, referring to this one and mentioning fix is present in develop branch.

I see new boards dedicated for 2.0 and 2.1 came into sight recently: https://github.com/magento/magento2/projects They may help with issues in stable releases management, but it is obviously NOT possible to manage closed issues.

Another option could be to monitor comments in closed issues and reopening when necessary but we cannot rely on this until such process is established and announced. From my personal experience with various bug tracking systems reopening is only good within short amount of time, like 2-3 sprints, after that it is better to report a new issue referring to old one even if we have exactly the same steps.

orlangur avatar Mar 12 '17 09:03 orlangur

@hbhardik @noprobz09 @jigar48

I had experienced trouble with moving the minicart in a custom theme. I had the same problem and fixed it.

The problem (for me) was I was only including the jsLayout argument from app/code/Magento/Checkout/view/frontend/layout/default.xml. I had deleted the minicart block in my xml and then tried to copy and paste the minicart block declaration from the previously mentioned default.xml file into another xml file I had created. But if you look around inside other files in the app/code/Magento/Checkout/view/frontend/layout directory, you'll find more files that prepend data to the jsLayout argument. In my situation, I was not including that extra data from the other files.

The easiest way I found to include the entire jsLayout argument was to move the minicart in your xml before it got deleted it.

app/code/<My_Vendor>/Theme/view/frontend/layout/default.xml

<move element="minicart" destination="<my desired header container>" />
<!-- the following reference container contains the minicart -->
<referenceContainer name="header.container" remove="true" />

The block is availble to output within my customer header: app/code/<My_Vendor>/Theme/view/frontend/templates/html/header.phtml

....
echo $this->getLayout()->getBlock('minicart')->toHtml();
....

This fixed it for me, but one last thing to note, that might be of help to some.

Inside app/code/Magento/Checkout/view/frontend/templates/cart/minicart.phtml you can see here where the jsLayout argument gets rendered into json to load all of the neccessary javascript components. It might be helpful to compare the data of what magento outputs by default and what your custom theme is outputting.

dambrogia avatar Mar 12 '17 16:03 dambrogia

@dambrogia Thank you. It was help me a lot :D

voquockhanh avatar Mar 12 '18 10:03 voquockhanh