Skip to content

Commit

Permalink
Merge pull request #1476 from magento-performance/perf_mpi
Browse files Browse the repository at this point in the history
Bugs
- MAGETWO-70163 Add quote generation ability for fixtures generation tool
- MAGETWO-66914 PAT with custom profile
- MAGETWO-72401 fix jenkins unittest
- MAGETWO-71870 Unable to place new order for a New Customer from backend
- MAGETWO-72184 PHP precision causes issues with float and rounded digits
- MAGETWO-72305 USPS First-Class Mail Parcel method no longer displaying checkout
- MAGETWO-71831 Unable to create a shipping label for a shipment with USPS
- MAGETWO-71759 Impossible place order from admin using saved PayPal Pro credit card
- MAGETWO-65688 Unable to configure products from products and wish list accordion when managing shopping cart
- MAGETWO-71969 Unable to finish checkout in Safari (private mode)
- MAGETWO-69210 [Google Tag Manager] Ajax "Add to Cart" / "Remove from Cart" do not fire any events
  • Loading branch information
VladimirZaets committed Sep 9, 2017
2 parents 1e87722 + b5cca13 commit 988b094
Show file tree
Hide file tree
Showing 28 changed files with 1,990 additions and 236 deletions.
6 changes: 3 additions & 3 deletions app/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@

date_default_timezone_set('UTC');

/* Adjustment of precision value for several versions of PHP */
ini_set('precision', 17);
ini_set('serialize_precision', 17);
/* For data consistency between displaying (printing) and serialization a float number */
ini_set('precision', 14);
ini_set('serialize_precision', 14);
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ $numColumns = sizeof($block->getColumns());
<?php endif; ?>

<?php if (strpos($block->getRowClickCallback(), 'order.') !== false): ?>
deps.push('Magento_Sales/order/create/form')
deps.push('Magento_Sales/order/create/form');
deps.push('jquery');
<?php endif; ?>

deps.push('mage/adminhtml/grid');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ $_helper = $this->helper('Magento\Catalog\Helper\Output');
<div class="actions-primary"<?= strpos($pos, $viewMode . '-primary') ? $position : '' ?>>
<?php if ($_product->isSaleable()): ?>
<?php $postParams = $block->getAddToCartPostParams($_product); ?>
<form data-role="tocart-form" action="<?= /* @escapeNotVerified */ $postParams['action'] ?>" method="post">
<form data-role="tocart-form" data-product-sku="<?= /* @NoEscape */ $_product->getSku() ?>" action="<?= /* @NoEscape */ $postParams['action'] ?>" method="post">
<input type="hidden" name="product" value="<?= /* @escapeNotVerified */ $postParams['data']['product'] ?>">
<input type="hidden" name="<?= /* @escapeNotVerified */ Action::PARAM_NAME_URL_ENCODED ?>" value="<?= /* @escapeNotVerified */ $postParams['data'][Action::PARAM_NAME_URL_ENCODED] ?>">
<?= $block->getBlockHtml('formkey') ?>
Expand Down Expand Up @@ -121,7 +121,9 @@ $_helper = $this->helper('Magento\Catalog\Helper\Output');
<script type="text/x-magento-init">
{
"[data-role=tocart-form], .form.map.checkout": {
"catalogAddToCart": {}
"catalogAddToCart": {
"product_sku": "<?= /* @NoEscape */ $_product->getSku() ?>"
}
}
}
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
<?php $_product = $block->getProduct(); ?>

<div class="product-add-form">
<form action="<?= /* @escapeNotVerified */ $block->getSubmitUrl($_product) ?>" method="post"
<form data-product-sku="<?= /* @NoEscape */ $_product->getSku() ?>"
action="<?= /* @NoEscape */ $block->getSubmitUrl($_product) ?>" method="post"
id="product_addtocart_form"<?php if ($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
<input type="hidden" name="product" value="<?= /* @escapeNotVerified */ $_product->getId() ?>" />
<input type="hidden" name="selected_configurable_option" value="" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ define([
success: function (res) {
var eventData, parameters;

$(document).trigger('ajax:addToCart', form.data().productSku);

if (self.isLoaderEnabled()) {
$('body').trigger(self.options.processStop);
}
Expand Down
11 changes: 9 additions & 2 deletions app/code/Magento/Checkout/view/frontend/web/js/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,17 @@ define([
},

/**
* Update content after item remove.
* Update content after item remove
*
* @param {Object} elem
* @private
*/
_removeItemAfter: function () {
_removeItemAfter: function (elem) {
var productData = customerData.get('cart')().items.find(function (item) {
return Number(elem.data('cart-item')) === Number(item['item_id']);
});

$(document).trigger('ajax:removeFromCart', productData['product_sku']);
},

/**
Expand Down
3 changes: 3 additions & 0 deletions app/code/Magento/Sales/Model/AdminOrder/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -1586,6 +1586,9 @@ public function applyCoupon($code)
public function setAccountData($accountData)
{
$customer = $this->getQuote()->getCustomer();
if (empty($accountData['email'])) {
$accountData['email'] = $customer->getEmail();
}
$form = $this->_createCustomerForm($customer);

// emulate request
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,62 @@
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

?>
<?php if ($block->hasMethods()): ?>
<?php if ($block->hasMethods()) : ?>
<div id="order-billing_method_form">
<dl class="admin__payment-methods">
<?php
$_methods = $block->getMethods();
$_methodsCount = count($_methods);
$_methods = $block->getMethods();
$_methodsCount = count($_methods);
$_counter = 0;
?>
<?php foreach ($_methods as $_method): $_code = $_method->getCode(); $_counter++; ?>
<?php foreach ($_methods as $_method) :
$_code = $_method->getCode();
$_counter++;
?>
<dt class="admin__field-option">
<?php if ($_methodsCount > 1): ?>
<input id="p_method_<?= /* @escapeNotVerified */ $_code ?>" value="<?= /* @escapeNotVerified */ $_code ?>" type="radio" name="payment[method]"
title="<?= $block->escapeHtml($_method->getTitle()) ?>"
onclick="payment.switchMethod('<?= /* @escapeNotVerified */ $_code ?>')"<?php if ($block->getSelectedMethodCode() == $_code): ?> checked="checked"<?php endif; ?>
class="admin__control-radio<?php if ($_counter == $_methodsCount) : ?> validate-one-required-by-name<?php endif; ?>"/>
<?php if ($_methodsCount > 1) : ?>
<input id="p_method_<?= $block->escapeHtml($_code); ?>"
value="<?= $block->escapeHtml($_code); ?>"
type="radio" name="payment[method]"
title="<?= $block->escapeHtml($_method->getTitle()); ?>"
onclick="payment.switchMethod('<?= $block->escapeHtml($_code); ?>')"
<?php if ($block->getSelectedMethodCode() == $_code) : ?>
checked="checked"
<?php endif; ?>
<?php $className = ($_counter == $_methodsCount) ? ' validate-one-required-by-name' : ''; ?>
class="admin__control-radio<?= $block->escapeHtml($className); ?>"/>
<?php else :?>
<span class="no-display">
<input id="p_method_<?= /* @escapeNotVerified */ $_code ?>" value="<?= /* @escapeNotVerified */ $_code ?>" type="radio"
<input id="p_method_<?= $block->escapeHtml($_code); ?>"
value="<?= $block->escapeHtml($_code); ?>"
type="radio"
name="payment[method]" class="admin__control-radio"
checked="checked"/>
</span>
<?php endif;?>

<label class="admin__field-label" for="p_method_<?= /* @escapeNotVerified */ $_code ?>"><?= $block->escapeHtml($_method->getTitle()) ?></label>
<label class="admin__field-label"
for="p_method_<?= $block->escapeHtml($_code); ?>"><?= $block->escapeHtml($_method->getTitle()) ?>
</label>
</dt>
<dd class="admin__payment-method-wrapper">
<?= /* @escapeNotVerified */ $block->getChildHtml('payment.method.' . $_code) ?>
<?= /* @noEscape */ $block->getChildHtml('payment.method.' . $_code) ?>
</dd>
<?php endforeach; ?>
</dl>
</div>
<script>
require(["Magento_Sales/order/create/form"], function(){
<?php if ($_methodsCount != 1):?>
order.setPaymentMethod('<?= /* @escapeNotVerified */ $block->getSelectedMethodCode() ?>');
require([
'mage/apply/main',
'Magento_Sales/order/create/form'
], function(mage) {
mage.apply();
<?php if ($_methodsCount != 1) : ?>
order.setPaymentMethod('<?= $block->escapeHtml($block->getSelectedMethodCode()); ?>');
<?php endif; ?>
});
</script>
<?php else: ?>
<div class="admin__message-empty"><?= /* @escapeNotVerified */ __('No Payment Methods') ?></div>
<?php else : ?>
<div class="admin__message-empty"><?= $block->escapeHtml(__('No Payment Methods')); ?></div>
<?php endif; ?>
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
</head>
<body>
<referenceContainer name="after.body.start">
<block class="Magento\Framework\View\Element\Template" name="head.polyfill" as="polyfill" template="Magento_Theme::js/polyfill.phtml" before="-"/>
<block class="Magento\Framework\View\Element\Js\Components" name="head.components" as="components" template="Magento_Theme::js/components.phtml" before="-"/>
</referenceContainer>
</body>
Expand Down
132 changes: 132 additions & 0 deletions app/code/Magento/Theme/view/frontend/templates/js/polyfill.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

/**
* Polyfill for local storage and session storage for old browsers and with enabled private mode.
*
* Emulates behavior of the native local storage and session storage. Adds ability to use "getItem", "setItem",
* "removeItem" methods.
*/
?>

<script>
try {
if (!window.localStorage || !window.sessionStorage) {
throw new Error();
}

localStorage.setItem('storage_test', 1);
localStorage.removeItem('storage_test');
} catch(e) {
(function () {
var Storage = function (type) {
var data;

function createCookie(name, value, days) {
var date, expires;

if (days) {
date = new Date();
date.setTime(date.getTime()+(days * 24 * 60 * 60 * 1000));
expires = '; expires=' + date.toGMTString();
} else {
expires = '';
}
document.cookie = name + '=' + value+expires+'; path=/';
}

function readCookie(name) {
var nameEQ = name + '=',
ca = document.cookie.split(';'),
i = 0,
c;

for (i=0; i < ca.length; i++) {
c = ca[i];

while (c.charAt(0) === ' ') {
c = c.substring(1,c.length);
}

if (c.indexOf(nameEQ) === 0) {
return c.substring(nameEQ.length, c.length);
}
}

return null;
}

function setData(data) {
data = encodeURIComponent(JSON.stringify(data));
createCookie(type === 'session' ? getSessionName() : 'localStorage', data, 365);
}

function clearData() {
createCookie(type === 'session' ? getSessionName() : 'localStorage', '', 365);
}

function getData() {
var data = type === 'session' ? readCookie(getSessionName()) : readCookie('localStorage');

return data ? JSON.parse(decodeURIComponent(data)) : {};
}

function getSessionName() {
if (!window.name) {
window.name = new Date().getTime();
}

return 'sessionStorage' + window.name;
}

data = getData();

return {
length: 0,
clear: function () {
data = {};
this.length = 0;
clearData();
},

getItem: function (key) {
return data[key] === undefined ? null : data[key];
},

key: function (i) {
var ctr = 0,
k;

for (k in data) {
if (ctr.toString() === i.toString()) {
return k;
} else {
ctr++
}
}

return null;
},

removeItem: function (key) {
delete data[key];
this.length--;
setData(data);
},

setItem: function (key, value) {
data[key] = value.toString();
this.length++;
setData(data);
}
};
};

window.localStorage.__proto__ = window.localStorage = new Storage('local');
window.sessionStorage.__proto__ = window.sessionStorag = new Storage('session');
})();
}
</script>
8 changes: 4 additions & 4 deletions app/code/Magento/Usps/Model/Carrier.php
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ public function getCode($type, $code = '')
'method' => [
'0_FCLE' => __('First-Class Mail Large Envelope'),
'0_FCL' => __('First-Class Mail Letter'),
'0_FCP' => __('First-Class Mail Parcel'),
'0_FCP' => __('First-Class Package Service - Retail'),
'0_FCPC' => __('First-Class Mail Postcards'),
'1' => __('Priority Mail'),
'2' => __('Priority Mail Express Hold For Pickup'),
Expand Down Expand Up @@ -795,7 +795,7 @@ public function getCode($type, $code = '')
'method_to_code' => [
'First-Class Mail Large Envelope' => '0_FCLE',
'First-Class Mail Letter' => '0_FCL',
'First-Class Mail Parcel' => '0_FCP',
'First-Class Package Service - Retail' => '0_FCP',
],
'first_class_mail_type' => ['LETTER' => __('Letter'), 'FLAT' => __('Flat'), 'PARCEL' => __('Parcel')],
'container' => [
Expand Down Expand Up @@ -1795,10 +1795,10 @@ protected function _formIntlShipmentRequest(\Magento\Framework\DataObject $reque
}
$individualItemWeight = $itemWeight / $ceiledQty;
$itemDetail->addChild('Quantity', $ceiledQty);
$itemDetail->addChild('Value', $item->getCustomsValue() * $item->getQty());
$itemDetail->addChild('Value', sprintf('%.2F', $item->getCustomsValue() * $item->getQty()));
list($individualPoundsWeight, $individualOuncesWeight) = $this->_convertPoundOunces($individualItemWeight);
$itemDetail->addChild('NetPounds', $individualPoundsWeight);
$itemDetail->addChild('NetOunces', $individualOuncesWeight);
$itemDetail->addChild('NetOunces', sprintf('%.2F', $individualOuncesWeight));
$itemDetail->addChild('HSTariffNumber', 0);
$itemDetail->addChild('CountryOfOrigin', $countryOfManufacture);

Expand Down
Loading

0 comments on commit 988b094

Please sign in to comment.