From 3c7480a36dde02f9f520dade361a4fa6bd2d96d4 Mon Sep 17 00:00:00 2001 From: Ievgen Shakhsuvarov Date: Thu, 29 Oct 2015 16:39:05 +0200 Subject: [PATCH] MAGETWO-44642: Every call to non-cached page generates errors in the exception logs because of layout errors in the Magento 2 core code - Fixed "Broken reference" log entry and Msrp display for minicart subtotal section. --- .../checkout_cart_sidebar_total_renderers.xml | 42 +++++++++++++++++++ .../Msrp/view/frontend/layout/default.xml | 18 -------- .../view/checkout/minicart/subtotal/totals.js | 40 ++++++++++++++++++ .../checkout/minicart/subtotal/totals.html | 7 ++++ .../view/checkout/minicart/subtotal/totals.js | 8 +++- .../checkout/minicart/subtotal/totals.html | 33 +++++++++------ 6 files changed, 116 insertions(+), 32 deletions(-) create mode 100644 app/code/Magento/Msrp/view/frontend/layout/checkout_cart_sidebar_total_renderers.xml delete mode 100644 app/code/Magento/Msrp/view/frontend/layout/default.xml create mode 100644 app/code/Magento/Msrp/view/frontend/web/js/view/checkout/minicart/subtotal/totals.js create mode 100644 app/code/Magento/Msrp/view/frontend/web/template/checkout/minicart/subtotal/totals.html diff --git a/app/code/Magento/Msrp/view/frontend/layout/checkout_cart_sidebar_total_renderers.xml b/app/code/Magento/Msrp/view/frontend/layout/checkout_cart_sidebar_total_renderers.xml new file mode 100644 index 0000000000000..b6f0d5aa106b0 --- /dev/null +++ b/app/code/Magento/Msrp/view/frontend/layout/checkout_cart_sidebar_total_renderers.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + Magento_Msrp/js/view/checkout/minicart/subtotal/totals + + minicart-subtotal-hidden + Magento_Msrp/checkout/minicart/subtotal/totals + + + + + + + + + + + + + + + + diff --git a/app/code/Magento/Msrp/view/frontend/layout/default.xml b/app/code/Magento/Msrp/view/frontend/layout/default.xml deleted file mode 100644 index ab943b1e1f8f6..0000000000000 --- a/app/code/Magento/Msrp/view/frontend/layout/default.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - minicart.subtotal - - - - - diff --git a/app/code/Magento/Msrp/view/frontend/web/js/view/checkout/minicart/subtotal/totals.js b/app/code/Magento/Msrp/view/frontend/web/js/view/checkout/minicart/subtotal/totals.js new file mode 100644 index 0000000000000..9f03ac5bd18e6 --- /dev/null +++ b/app/code/Magento/Msrp/view/frontend/web/js/view/checkout/minicart/subtotal/totals.js @@ -0,0 +1,40 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +define([ + 'Magento_Tax/js/view/checkout/minicart/subtotal/totals', + 'underscore' +], function (Component, _) { + 'use strict'; + + return Component.extend({ + + /** + * @override + */ + initialize: function () { + this._super(); + this.displaySubtotal(this.isMsrpApplied(this.cart().items)); + this.cart.subscribe(function (updatedCart) { + + this.displaySubtotal(this.isMsrpApplied(updatedCart.items)); + }, this); + }, + + /** + * Determine if subtotal should be hidden. + * @param {Array} cartItems + * @return {Boolean} + */ + isMsrpApplied: function (cartItems) { + return !_.find(cartItems, function (item) { + if (_.has(item, 'canApplyMsrp')) { + return item.canApplyMsrp; + } + + return false; + }); + } + }); +}); diff --git a/app/code/Magento/Msrp/view/frontend/web/template/checkout/minicart/subtotal/totals.html b/app/code/Magento/Msrp/view/frontend/web/template/checkout/minicart/subtotal/totals.html new file mode 100644 index 0000000000000..446755608a316 --- /dev/null +++ b/app/code/Magento/Msrp/view/frontend/web/template/checkout/minicart/subtotal/totals.html @@ -0,0 +1,7 @@ + + diff --git a/app/code/Magento/Tax/view/frontend/web/js/view/checkout/minicart/subtotal/totals.js b/app/code/Magento/Tax/view/frontend/web/js/view/checkout/minicart/subtotal/totals.js index 2de0bfbda639b..62d8a63a8196f 100644 --- a/app/code/Magento/Tax/view/frontend/web/js/view/checkout/minicart/subtotal/totals.js +++ b/app/code/Magento/Tax/view/frontend/web/js/view/checkout/minicart/subtotal/totals.js @@ -3,12 +3,18 @@ * See COPYING.txt for license details. */ define([ + 'ko', 'uiComponent', 'Magento_Customer/js/customer-data' -], function (Component, customerData) { +], function (ko, Component, customerData) { 'use strict'; return Component.extend({ + displaySubtotal: ko.observable(true), + + /** + * @override + */ initialize: function () { this._super(); this.cart = customerData.get('cart'); diff --git a/app/code/Magento/Tax/view/frontend/web/template/checkout/minicart/subtotal/totals.html b/app/code/Magento/Tax/view/frontend/web/template/checkout/minicart/subtotal/totals.html index c3c28a5813822..63afce061a333 100644 --- a/app/code/Magento/Tax/view/frontend/web/template/checkout/minicart/subtotal/totals.html +++ b/app/code/Magento/Tax/view/frontend/web/template/checkout/minicart/subtotal/totals.html @@ -6,21 +6,28 @@ -->
- - - + + + + - - - + + + - - - + + + - - + + + + + + + +