Skip to content

Commit e283830

Browse files
committed
MAGETWO-77744: [Magento Cloud] - Error message when uploading unsupported file format
1 parent f947cad commit e283830

File tree

5 files changed

+40
-15
lines changed

5 files changed

+40
-15
lines changed

app/code/Magento/Catalog/view/frontend/web/js/catalog-add-to-cart.js

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,34 +62,28 @@ define([
6262
* @param {Object} form
6363
*/
6464
submitForm: function (form) {
65-
var addToCartButton, self = this;
66-
67-
if (form.has('input[type="file"]').length && form.find('input[type="file"]').val() !== '') {
68-
self.element.off('submit');
69-
// disable 'Add to Cart' button
70-
addToCartButton = $(form).find(this.options.addToCartButtonSelector);
71-
addToCartButton.prop('disabled', true);
72-
addToCartButton.addClass(this.options.addToCartButtonDisabledClass);
73-
form.submit();
74-
} else {
75-
self.ajaxSubmit(form);
76-
}
65+
this.ajaxSubmit(form);
7766
},
7867

7968
/**
8069
* @param {String} form
8170
*/
8271
ajaxSubmit: function (form) {
83-
var self = this;
72+
var self = this,
73+
formData;
8474

8575
$(self.options.minicartSelector).trigger('contentLoading');
8676
self.disableAddToCartButton(form);
77+
formData = new FormData(form[0]);
8778

8879
$.ajax({
8980
url: form.attr('action'),
90-
data: form.serialize(),
81+
data: formData,
9182
type: 'post',
9283
dataType: 'json',
84+
cache: false,
85+
contentType: false,
86+
processData: false,
9387

9488
/** @inheritdoc */
9589
beforeSend: function () {
@@ -125,7 +119,12 @@ define([
125119
parameters.push(eventData.redirectParameters.join('&'));
126120
res.backUrl = parameters.join('#');
127121
}
128-
window.location = res.backUrl;
122+
window.location.href = res.backUrl;
123+
124+
// page does not reload when anchor (#) is added
125+
if (res.backUrl.indexOf('#') !== -1) {
126+
window.location.reload();
127+
}
129128

130129
return;
131130
}

app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,8 @@ protected function _prepareProduct(\Magento\Framework\DataObject $buyRequest, $p
926926
return $result;
927927
}
928928
}
929+
} elseif (is_string($result)) {
930+
return __($result)->render();
929931
}
930932
}
931933

app/code/Magento/ConfigurableProduct/view/frontend/templates/product/view/type/options/configurable.phtml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ $_attributes = $block->decorateArray($block->getAllowAttributes());
2222
<div class="control">
2323
<select name="super_attribute[<?= /* @escapeNotVerified */ $_attribute->getAttributeId() ?>]"
2424
data-selector="super_attribute[<?= /* @escapeNotVerified */ $_attribute->getAttributeId() ?>]"
25+
data-attribute-code="<?= /* @escapeNotVerified */ $_attribute->getAttributeId() ?>"
2526
data-validate="{required:true}"
2627
id="attribute<?= /* @escapeNotVerified */ $_attribute->getAttributeId() ?>"
2728
class="super-attribute-select">
@@ -38,6 +39,9 @@ $_attributes = $block->decorateArray($block->getAllowAttributes());
3839
"gallerySwitchStrategy": "<?php /* @escapeNotVerified */ echo $block->getVar('gallery_switch_strategy',
3940
'Magento_ConfigurableProduct') ?: 'replace'; ?>"
4041
}
42+
},
43+
"*" : {
44+
"Magento_ConfigurableProduct/js/catalog-add-to-cart": {}
4145
}
4246
}
4347
</script>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
require([
6+
'jquery'
7+
], function ($) {
8+
'use strict';
9+
10+
$('body').on('catalogCategoryAddToCartRedirect', function (event, data) {
11+
$(data.form).find('select[name*="super"]').each(function (index, item) {
12+
var $item = $(item);
13+
14+
data.redirectParameters.push($item.attr('data-attribute-code') + '=' + $item.val());
15+
});
16+
});
17+
});

app/code/Magento/Swatches/view/frontend/templates/product/view/renderer.phtml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
"gallerySwitchStrategy": "<?php /* @escapeNotVerified */ echo $block->getVar('gallery_switch_strategy',
2121
'Magento_ConfigurableProduct') ?: 'replace'; ?>"
2222
}
23+
},
24+
"*" : {
25+
"Magento_Swatches/js/catalog-add-to-cart": {}
2326
}
2427
}
2528
</script>

0 commit comments

Comments
 (0)