Search

Mar 28, 2023

Magento2: Editing a product on website removed its sale price

Steps to reproduce: 

Step 1: We have a Catalog Price Rule for 10% Off Site Wide Sale (Active: Yes) 

Step 2: View frontend product all product have sale 10%(sku 15100 have sale price 10%) 

Step 3: Go to backend and edit any product 

Step 4: Clear cache and View frontend, previously edited and saved product has lost its sale price (sku 15100 has been removed sale price 10%) 

*Expected result: Not removed sale price. 

*Actual result: Previously edited and saved product has lost its sale price.


SOLUTION ON MAGENTO CLOUD:

1. Install the latest QPT package: composer update magento/ece-tools --with-dependencies
 
2. Add to .magento.env.yaml environment variable QUALITY_PATCHES with a <PATCH_ID> to apply. PATCH_ID is MDVA-31763:

Example:
stage:
   build:
      QUALITY_PATCHES:
          - <PATCH_ID>

Magento 2.3.3 Bug Javascript on Google Tag Manager module

We are using Google tag manager and got a bug on product detail page. After click add to cart button, the mini cart didn't update qty. The main reason is by google tag manager js. 


Step by step:

1. Go to detail page

2. Choose Color, Size and click add to cart 

3. Item is added but the mini cart didn't update qty 

4. Open web console log via F12 button and saw javascript error Uncaught TypeError: Cannot read property 'forEach' of undefined at the file /Magento_GoogleTagManager/js/google-tag-manager-cart.js


SOLUTION:

Please follow the patch file

diff --git a/vendor/magento/module-google-tag-manager/view/frontend/web/js/google-tag-manager-cart.js b/vendor/magento/module-google-tag-manager/view/frontend/web/js/google-tag-manager-cart.js
index 2d6e9ac7..2a9c115b 100644
--- a/vendor/magento/module-google-tag-manager/view/frontend/web/js/google-tag-manager-cart.js
+++ b/vendor/magento/module-google-tag-manager/view/frontend/web/js/google-tag-manager-cart.js
@@ -172,15 +172,17 @@ define([
             var product;

             this.options.temporaryEventStorage.forEach(function (item, index) {
-                item.productIds.forEach(function (productId) {
-                    product = this.getProductById(productId);
+                if (item.productIds) {
+                    item.productIds.forEach(function (productId) {
+                        product = this.getProductById(productId);

-                    if (!_.isUndefined(product['product_sku']) && parseInt(product.qty, 10) > 0) {
-                        this.options.actions[item.type](product);
-                    }
+                        if (!_.isUndefined(product['product_sku']) && parseInt(product.qty, 10) > 0) {
+                            this.options.actions[item.type](product);
+                        }

-                    this.options.temporaryEventStorage.splice(index, 1);
-                }.bind(this));
+                        this.options.temporaryEventStorage.splice(index, 1);
+                    }.bind(this));
+                }
             }.bind(this));
         },