Magento TopLink Cache My Cart (#)

I have a problem with "My Car (#)" in the header and cache.

I am using Magento Enterprise 1.12. The problem is that when I add or remove an item to the cart in the header, I have "My car (#)" and does not update every time I add or remove an item from the cart, because the cache and I donโ€™t I know how to solve it ...

Steps:

1) Clear admin cache

2) Enter the main page ("My basket" will appear in the title)

3) Go to the product page

4) Add some product to cart

5) Redirecting to the "My Cart" page (the heading displays "My Cart (1 item)")

6) Go to the Homepage Again (and the heading still displays โ€œMy Cartโ€) without โ€œ1 itemโ€

If I go to the admin site and clear the cache on the home page, select "My Cart (1 item)." And I have the same problem when I have 1 item, and then I delete that item from the recycle bin.

I need to be dynamic, black, and I do not know how to do this.

Tnks to read! :)

+4
source share
1 answer

Well, there can be a lot of problems here, but perhaps a decent way to debug this problem is to override the Minicart JavaScript methods to see where it works.

In your module layout.xml file add a custom script following this post

Further, Minicart.prototype has many functions, console.log (Minicart.prototype); to view them.

I suspect something is not working properly in the updateItem method. Override this by adding this to your JS file:

if (typeof Minicart != "undefined") { Minicart.prototype.updateItem = function(el) { var cart = this; var input = $j(this.selectors.quantityInputPrefix + $j(el).data('item-id')); var quantity = parseInt(input.val(), 10); cart.hideMessage(); cart.showOverlay(); $j.ajax({ type: 'POST', dataType: 'json', url: input.data('link'), data: {qty: quantity, form_key: cart.formKey} }).done(function(result) { cart.hideOverlay(); if (result.success) { cart.updateCartQty(result.qty); if (quantity !== 0) { cart.updateContentOnUpdate(result); } else { cart.updateContentOnRemove(result, input.closest('li')); } } else { cart.showMessage(result); } }).error(function() { cart.hideOverlay(); cart.showError(cart.defaultErrorMessage); }); return false; }; } 

And start logging out where it doesn't work. If this does not cause an error, try a different method.

Happy coding!

0
source

All Articles