Skip to content

Commit de49e22

Browse files
authored
Merge pull request #1518 from magento-mpi/MPI-PR-2.1.10
[MPI] 2.1.10 Bug fixes
2 parents fa59b15 + 9759929 commit de49e22

File tree

8 files changed

+128
-55
lines changed

8 files changed

+128
-55
lines changed

app/code/Magento/Braintree/view/frontend/web/template/payment/form.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,11 @@
140140
type="submit"
141141
data-bind="
142142
click: placeOrderClick,
143-
attr: {title: $t('Place Order')}
144-
">
143+
attr: {title: $t('Place Order')},
144+
css: {disabled: !isPlaceOrderActionAllowed()},
145+
enable: isActive()
146+
"
147+
disabled>
145148
<span data-bind="i18n: 'Place Order'"></span>
146149
</button>
147150
</div>

app/code/Magento/Catalog/Cron/DeleteOutdatedPriceValues.php

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
/**
1515
* Cron operation is responsible for deleting all product prices on WEBSITE level
16-
* in case 'Catalog Price Scope' configuratoin parameter is set to GLOBAL.
16+
* in case 'Catalog Price Scope' configuration parameter is set to GLOBAL.
1717
*/
1818
class DeleteOutdatedPriceValues
1919
{
@@ -48,27 +48,46 @@ public function __construct(
4848
}
4949

5050
/**
51-
* Delete all price values for non-admin stores if PRICE_SCOPE is global
51+
* Delete all price values for non-admin stores if PRICE_SCOPE is set to global.
5252
*
5353
* @return void
5454
*/
5555
public function execute()
5656
{
57-
$priceScope = $this->scopeConfig->getValue(Store::XML_PATH_PRICE_SCOPE);
58-
if ($priceScope == Store::PRICE_SCOPE_GLOBAL) {
59-
/** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $priceAttribute */
60-
$priceAttribute = $this->attributeRepository
61-
->get(ProductAttributeInterface::ENTITY_TYPE_CODE, ProductAttributeInterface::CODE_PRICE);
62-
$connection = $this->resource->getConnection();
63-
$conditions = [
64-
$connection->quoteInto('attribute_id = ?', $priceAttribute->getId()),
65-
$connection->quoteInto('store_id != ?', Store::DEFAULT_STORE_ID),
66-
];
57+
if ($this->isPriceScopeSetToGlobal() === false) {
58+
return;
59+
}
60+
61+
/** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $priceAttribute */
62+
$priceAttribute = $this->attributeRepository
63+
->get(ProductAttributeInterface::ENTITY_TYPE_CODE, ProductAttributeInterface::CODE_PRICE);
64+
$connection = $this->resource->getConnection();
65+
$conditions = [
66+
$connection->quoteInto('attribute_id = ?', $priceAttribute->getId()),
67+
$connection->quoteInto('store_id != ?', Store::DEFAULT_STORE_ID),
68+
];
6769

68-
$connection->delete(
69-
$priceAttribute->getBackend()->getTable(),
70-
$conditions
71-
);
70+
$connection->delete(
71+
$priceAttribute->getBackend()->getTable(),
72+
$conditions
73+
);
74+
}
75+
76+
/**
77+
* Checks if price scope config option explicitly equal to global value.
78+
*
79+
* Such strict comparision is required to prevent price deleting when
80+
* price scope config option is null for some reason.
81+
*
82+
* @return bool
83+
*/
84+
private function isPriceScopeSetToGlobal()
85+
{
86+
$priceScope = $this->scopeConfig->getValue(Store::XML_PATH_PRICE_SCOPE);
87+
if ($priceScope === null) {
88+
return false;
7289
}
90+
91+
return (int)$priceScope === Store::PRICE_SCOPE_GLOBAL;
7392
}
7493
}

app/code/Magento/Checkout/CustomerData/DefaultItem.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ protected function doGetItemData()
7070
'item_id' => $this->item->getId(),
7171
'configure_url' => $this->getConfigureUrl(),
7272
'is_visible_in_site_visibility' => $this->item->getProduct()->isVisibleInSiteVisibility(),
73+
'product_id' => $this->item->getProduct()->getId(),
7374
'product_name' => $this->item->getProduct()->getName(),
7475
'product_sku' => $this->item->getProduct()->getSku(),
7576
'product_url' => $this->getProductUrl(),

app/code/Magento/Checkout/view/frontend/layout/checkout_cart_configure.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
*/
77
-->
88
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
9+
<head>
10+
<link src="Magento_Checkout::js/view/configure/product-customer-data.js"/>
11+
</head>
912
<update handle="catalog_product_view"/>
1013
<body>
1114
<referenceBlock name="head.components">

app/code/Magento/Checkout/view/frontend/templates/cart/item/configure/updatecart.phtml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,20 @@
1515
<fieldset class="fieldset">
1616
<?php if ($block->shouldRenderQuantity()): ?>
1717
<div class="field qty">
18-
<label class="label" for="qty"><span><?php /* @escapeNotVerified */ echo __('Qty') ?></span></label>
18+
<label class="label" for="qty"><span><?php echo $block->escapeHtml(__('Qty')); ?></span></label>
1919
<div class="control">
20-
<input type="number" name="qty" id="qty" maxlength="12" value="<?php /* @escapeNotVerified */ echo $block->getProductDefaultQty() * 1 ?>" title="<?php /* @escapeNotVerified */ echo __('Qty') ?>" class="input-text qty" data-validate="{'required-number':true,digits:true}"/>
20+
<input type="number" name="qty" id="qty" maxlength="12" value=""
21+
title="<?php echo $block->escapeHtml(__('Qty')); ?>"
22+
class="input-text qty" data-validate="{'required-number':true,digits:true}"/>
2123
</div>
2224
</div>
2325
<?php endif; ?>
2426
<div class="actions">
2527
<button type="submit"
26-
title="<?php /* @escapeNotVerified */ echo $buttonTitle ?>"
28+
title="<?php echo $block->escapeHtml($buttonTitle); ?>"
2729
class="action primary tocart"
2830
id="product-updatecart-button">
29-
<span><?php /* @escapeNotVerified */ echo $buttonTitle ?></span>
31+
<span><?php echo $block->escapeHtml($buttonTitle); ?></span>
3032
</button>
3133
<?php echo $block->getChildHtml('', true) ?>
3234
</div>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
require([
2+
'jquery',
3+
'Magento_Customer/js/customer-data'
4+
], function ($, customerData) {
5+
'use strict';
6+
7+
var selectors = {
8+
qtySelector: '#product_addtocart_form [name="qty"]',
9+
productIdSelector: '#product_addtocart_form [name="product"]'
10+
},
11+
cartData = customerData.get('cart'),
12+
productId = $(selectors.productIdSelector).val(),
13+
productQty,
14+
productQtyInput,
15+
16+
/**
17+
* Updates product's qty input value according to actual data
18+
*/
19+
updateQty = function () {
20+
21+
if (productQty || productQty === 0) {
22+
productQtyInput = productQtyInput || $(selectors.qtySelector);
23+
24+
if (productQtyInput && productQty.toString() !== productQtyInput.val()) {
25+
productQtyInput.val(productQty);
26+
}
27+
}
28+
},
29+
30+
/**
31+
* Sets productQty according to cart data from customer-data
32+
*
33+
* @param {Object} data - cart data from customer-data
34+
*/
35+
setProductQty = function (data) {
36+
var product;
37+
38+
if (!(data && data.items && data.items.length && productId)) {
39+
return;
40+
}
41+
product = data.items.find(function (item) {
42+
return item['product_id'] === productId ||
43+
item['item_id'] === productId;
44+
});
45+
46+
if (!product) {
47+
return;
48+
}
49+
productQty = product.qty;
50+
};
51+
52+
cartData.subscribe(function (updateCartData) {
53+
setProductQty(updateCartData);
54+
updateQty();
55+
});
56+
57+
setProductQty(cartData());
58+
updateQty();
59+
});

app/code/Magento/Paypal/Model/Express/Checkout.php

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
use Magento\Quote\Model\Quote\Address;
1313
use Magento\Framework\DataObject;
1414
use Magento\Paypal\Model\Cart as PaypalCart;
15-
use Magento\Framework\App\ObjectManager;
16-
use Magento\Sales\Api\OrderRepositoryInterface;
1715

1816
/**
1917
* Wrapper that performs Paypal Express and Checkout communication
@@ -270,13 +268,6 @@ class Checkout
270268
*/
271269
protected $totalsCollector;
272270

273-
/**
274-
* Order repository interface.
275-
*
276-
* @var OrderRepositoryInterface
277-
*/
278-
private $orderRepository;
279-
280271
/**
281272
* @param \Psr\Log\LoggerInterface $logger
282273
* @param \Magento\Customer\Model\Url $customerUrl
@@ -805,8 +796,7 @@ public function place($token, $shippingMethodCode = null)
805796

806797
$this->ignoreAddressValidation();
807798
$this->_quote->collectTotals();
808-
$orderId = $this->quoteManagement->placeOrder($this->_quote->getId());
809-
$order = $this->getOrderRepository()->get($orderId);
799+
$order = $this->quoteManagement->submit($this->_quote);
810800

811801
if (!$order) {
812802
return;
@@ -1174,21 +1164,4 @@ protected function prepareGuestQuote()
11741164
->setCustomerGroupId(\Magento\Customer\Model\Group::NOT_LOGGED_IN_ID);
11751165
return $this;
11761166
}
1177-
1178-
/**
1179-
* Returns order repository instance.
1180-
*
1181-
* @return OrderRepositoryInterface
1182-
*
1183-
* @deprecated
1184-
*/
1185-
private function getOrderRepository()
1186-
{
1187-
if ($this->orderRepository === null) {
1188-
$this->orderRepository = ObjectManager::getInstance()
1189-
->get(OrderRepositoryInterface::class);
1190-
}
1191-
1192-
return $this->orderRepository;
1193-
}
11941167
}

dev/tests/integration/testsuite/Magento/Catalog/Cron/DeleteOutdatedPriceValuesTest.php

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,13 @@ public function setUp()
4242
/**
4343
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
4444
* @magentoDataFixture Magento/Store/_files/second_website_with_two_stores.php
45-
* @magentoConfigFixture current_store catalog/price/scope 2
45+
* @magentoConfigFixture current_store catalog/price/scope 1
4646
* @magentoDbIsolation enabled
4747
*/
4848
public function testExecute()
4949
{
50+
$defaultStorePrice = 10.00;
51+
$secondStorePrice = 9.99;
5052
$secondStoreId = $this->store->load('fixture_second_store')->getId();
5153
/** @var \Magento\Catalog\Model\Product\Action $productAction */
5254
$productAction = $this->objectManager->create(
@@ -64,7 +66,7 @@ public function testExecute()
6466
);
6567
$product->setOrigData();
6668
$product->setStoreId($secondStoreId);
67-
$product->setPrice(9.99);
69+
$product->setPrice($secondStorePrice);
6870

6971
$productResource->save($product);
7072
$attribute = $this->objectManager->get(\Magento\Eav\Model\Config::class)
@@ -73,22 +75,33 @@ public function testExecute()
7375
'price'
7476
);
7577
$this->assertEquals(
76-
'9.99',
78+
$secondStorePrice,
7779
$productResource->getAttributeRawValue($productId, $attribute->getId(), $secondStoreId)
7880
);
7981
/** @var MutableScopeConfigInterface $config */
8082
$config = $this->objectManager->get(
8183
MutableScopeConfigInterface::class
8284
);
85+
86+
$config->setValue(
87+
\Magento\Store\Model\Store::XML_PATH_PRICE_SCOPE,
88+
null,
89+
ScopeConfigInterface::SCOPE_TYPE_DEFAULT
90+
);
91+
$this->cron->execute();
92+
$this->assertEquals(
93+
$secondStorePrice,
94+
$productResource->getAttributeRawValue($productId, $attribute->getId(), $secondStoreId)
95+
);
96+
8397
$config->setValue(
8498
\Magento\Store\Model\Store::XML_PATH_PRICE_SCOPE,
8599
\Magento\Store\Model\Store::PRICE_SCOPE_GLOBAL,
86100
ScopeConfigInterface::SCOPE_TYPE_DEFAULT
87101
);
88-
/** @var \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig */
89102
$this->cron->execute();
90103
$this->assertEquals(
91-
'10.0000',
104+
$defaultStorePrice,
92105
$productResource->getAttributeRawValue($productId, $attribute->getId(), $secondStoreId)
93106
);
94107
}

0 commit comments

Comments
 (0)