Skip to content

Commit a01bd6a

Browse files
committed
Merge branch '2.2-develop' of github.com:magento/magento2ce into composer-test-convention-update-2.2
2 parents ec22cec + 30ed829 commit a01bd6a

File tree

8 files changed

+219
-140
lines changed

8 files changed

+219
-140
lines changed

app/code/Magento/Checkout/view/frontend/templates/cart/form.phtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
method="post"
1515
id="form-validate"
1616
data-mage-init='{"Magento_Checkout/js/action/update-shopping-cart":
17-
{"validationURL" : "/checkout/cart/updateItemQty"}
17+
{"validationURL" : "/checkout/cart/updateItemQty",
18+
"updateCartActionContainer": "#update_cart_action_container"}
1819
}'
1920
class="form form-cart">
2021
<?= $block->getBlockHtml('formkey') ?>

app/code/Magento/Checkout/view/frontend/web/js/action/update-shopping-cart.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ define([
1414
$.widget('mage.updateShoppingCart', {
1515
options: {
1616
validationURL: '',
17-
eventName: 'updateCartItemQty'
17+
eventName: 'updateCartItemQty',
18+
updateCartActionContainer: ''
1819
},
1920

2021
/** @inheritdoc */
@@ -31,7 +32,9 @@ define([
3132
* @return {Boolean}
3233
*/
3334
onSubmit: function (event) {
34-
if (!this.options.validationURL) {
35+
var action = this.element.find(this.options.updateCartActionContainer).val();
36+
37+
if (!this.options.validationURL || action === 'empty_cart') {
3538
return true;
3639
}
3740

app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurablePanel.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
*/
66
namespace Magento\ConfigurableProduct\Ui\DataProvider\Product\Form\Modifier;
77

8+
use Magento\Catalog\Model\Locator\LocatorInterface;
89
use Magento\Catalog\Model\Product\Attribute\Backend\Sku;
910
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AbstractModifier;
11+
use Magento\Framework\UrlInterface;
1012
use Magento\Ui\Component\Container;
11-
use Magento\Ui\Component\Form;
1213
use Magento\Ui\Component\DynamicRows;
14+
use Magento\Ui\Component\Form;
1315
use Magento\Ui\Component\Modal;
14-
use Magento\Framework\UrlInterface;
15-
use Magento\Catalog\Model\Locator\LocatorInterface;
1616

1717
/**
1818
* Data provider for Configurable panel
@@ -90,15 +90,15 @@ public function __construct(
9090
}
9191

9292
/**
93-
* {@inheritdoc}
93+
* @inheritdoc
9494
*/
9595
public function modifyData(array $data)
9696
{
9797
return $data;
9898
}
9999

100100
/**
101-
* {@inheritdoc}
101+
* @inheritdoc
102102
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
103103
*/
104104
public function modifyMeta(array $meta)
@@ -197,7 +197,7 @@ public function modifyMeta(array $meta)
197197
'autoRender' => false,
198198
'componentType' => 'insertListing',
199199
'component' => 'Magento_ConfigurableProduct/js'
200-
.'/components/associated-product-insert-listing',
200+
. '/components/associated-product-insert-listing',
201201
'dataScope' => $this->associatedListingPrefix
202202
. static::ASSOCIATED_PRODUCT_LISTING,
203203
'externalProvider' => $this->associatedListingPrefix
@@ -328,14 +328,12 @@ protected function getButtonSet()
328328
'component' => 'Magento_Ui/js/form/components/button',
329329
'actions' => [
330330
[
331-
'targetName' =>
332-
$this->dataScopeName . '.configurableModal',
331+
'targetName' => $this->dataScopeName . '.configurableModal',
333332
'actionName' => 'trigger',
334333
'params' => ['active', true],
335334
],
336335
[
337-
'targetName' =>
338-
$this->dataScopeName . '.configurableModal',
336+
'targetName' => $this->dataScopeName . '.configurableModal',
339337
'actionName' => 'openModal',
340338
],
341339
],
@@ -574,6 +572,7 @@ protected function getColumn(
574572
'dataType' => Form\Element\DataType\Text::NAME,
575573
'dataScope' => $name,
576574
'visibleIfCanEdit' => false,
575+
'labelVisible' => false,
577576
'imports' => [
578577
'visible' => '!${$.provider}:${$.parentScope}.canEdit'
579578
],
@@ -592,6 +591,7 @@ protected function getColumn(
592591
'component' => 'Magento_Ui/js/form/components/group',
593592
'label' => $label,
594593
'dataScope' => '',
594+
'showLabel' => false
595595
];
596596
$container['children'] = [
597597
$name . '_edit' => $fieldEdit,

app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Orders.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ protected function _construct()
6363
{
6464
parent::_construct();
6565
$this->setId('customer_orders_grid');
66-
$this->setDefaultSort('created_at', 'desc');
66+
$this->setDefaultSort('created_at');
67+
$this->setDefaultDir('desc');
6768
$this->setUseAjax(true);
6869
}
6970

app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Cart.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ protected function _construct()
7777
{
7878
parent::_construct();
7979
$this->setId('customer_view_cart_grid');
80-
$this->setDefaultSort('added_at', 'desc');
80+
$this->setDefaultSort('added_at');
81+
$this->setDefaultDir('desc');
8182
$this->setSortable(false);
8283
$this->setPagerVisibility(false);
8384
$this->setFilterVisibility(false);

app/code/Magento/Sales/Setup/UpgradeData.php

Lines changed: 84 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Magento\Framework\Setup\ModuleDataSetupInterface;
1616
use Magento\Framework\Setup\UpgradeDataInterface;
1717
use Magento\Quote\Model\QuoteFactory;
18+
use Magento\Sales\Model\Order\Address;
1819
use Magento\Sales\Model\OrderFactory;
1920
use Magento\Sales\Model\ResourceModel\Order\Address\CollectionFactory as AddressCollectionFactory;
2021

@@ -42,27 +43,14 @@ class UpgradeData implements UpgradeDataInterface
4243
*/
4344
private $aggregatedFieldConverter;
4445

45-
/**
46-
* @var AddressCollectionFactory
47-
*/
48-
private $addressCollectionFactory;
49-
50-
/**
51-
* @var OrderFactory
52-
*/
53-
private $orderFactory;
54-
55-
/**
56-
* @var QuoteFactory
57-
*/
58-
private $quoteFactory;
59-
6046
/**
6147
* @var State
6248
*/
6349
private $state;
6450

6551
/**
52+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
53+
*
6654
* @param SalesSetupFactory $salesSetupFactory
6755
* @param Config $eavConfig
6856
* @param AggregatedFieldDataConverter $aggregatedFieldConverter
@@ -83,9 +71,6 @@ public function __construct(
8371
$this->salesSetupFactory = $salesSetupFactory;
8472
$this->eavConfig = $eavConfig;
8573
$this->aggregatedFieldConverter = $aggregatedFieldConverter;
86-
$this->addressCollectionFactory = $addressCollFactory;
87-
$this->orderFactory = $orderFactory;
88-
$this->quoteFactory = $quoteFactory;
8974
$this->state = $state;
9075
}
9176

@@ -125,6 +110,7 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
125110
* @param string $setupVersion
126111
* @param SalesSetup $salesSetup
127112
* @return void
113+
* @throws \Magento\Framework\DB\FieldDataConversionException
128114
*/
129115
private function convertSerializedDataToJson($setupVersion, SalesSetup $salesSetup)
130116
{
@@ -173,32 +159,95 @@ private function convertSerializedDataToJson($setupVersion, SalesSetup $salesSet
173159

174160
/**
175161
* Fill quote_address_id in table sales_order_address if it is empty.
176-
*
177162
* @param ModuleDataSetupInterface $setup
178163
*/
179164
public function fillQuoteAddressIdInSalesOrderAddress(ModuleDataSetupInterface $setup)
180165
{
181-
$addressTable = $setup->getTable('sales_order_address');
182-
$updateOrderAddress = $setup->getConnection()
166+
$this->fillQuoteAddressIdInSalesOrderAddressByType($setup, Address::TYPE_SHIPPING);
167+
$this->fillQuoteAddressIdInSalesOrderAddressByType($setup, Address::TYPE_BILLING);
168+
}
169+
170+
/**
171+
* @param ModuleDataSetupInterface $setup
172+
* @param string $addressType
173+
*/
174+
private function fillQuoteAddressIdInSalesOrderAddressByType(ModuleDataSetupInterface $setup, $addressType)
175+
{
176+
$salesConnection = $setup->getConnection('sales');
177+
178+
$orderTable = $setup->getTable('sales_order', 'sales');
179+
$orderAddressTable = $setup->getTable('sales_order_address', 'sales');
180+
181+
$query = $salesConnection
183182
->select()
183+
->from(
184+
['sales_order_address' => $orderAddressTable],
185+
['entity_id', 'address_type']
186+
)
184187
->joinInner(
185-
['sales_order' => $setup->getTable('sales_order')],
186-
$addressTable . '.parent_id = sales_order.entity_id',
187-
['quote_address_id' => 'quote_address.address_id']
188+
['sales_order' => $orderTable],
189+
'sales_order_address.parent_id = sales_order.entity_id',
190+
['quote_id' => 'sales_order.quote_id']
191+
)
192+
->where('sales_order_address.quote_address_id IS NULL')
193+
->where('sales_order_address.address_type = ?', $addressType)
194+
->order('sales_order_address.entity_id');
195+
196+
$batchSize = 5000;
197+
$result = $salesConnection->query($query);
198+
$count = $result->rowCount();
199+
$batches = ceil($count / $batchSize);
200+
201+
for ($batch = $batches; $batch > 0; $batch--) {
202+
$query->limitPage($batch, $batchSize);
203+
$result = $salesConnection->fetchAssoc($query);
204+
205+
$this->fillQuoteAddressIdInSalesOrderAddressProcessBatch($setup, $result, $addressType);
206+
}
207+
}
208+
209+
/**
210+
* @param ModuleDataSetupInterface $setup
211+
* @param array $orderAddresses
212+
* @param string $addressType
213+
*/
214+
private function fillQuoteAddressIdInSalesOrderAddressProcessBatch(
215+
ModuleDataSetupInterface $setup,
216+
array $orderAddresses,
217+
$addressType
218+
) {
219+
$salesConnection = $setup->getConnection('sales');
220+
$quoteConnection = $setup->getConnection('checkout');
221+
222+
$quoteAddressTable = $setup->getTable('quote_address', 'checkout');
223+
$quoteTable = $setup->getTable('quote', 'checkout');
224+
$salesOrderAddressTable = $setup->getTable('sales_order_address', 'sales');
225+
226+
$query = $quoteConnection
227+
->select()
228+
->from(
229+
['quote_address' => $quoteAddressTable],
230+
['quote_id', 'address_id']
188231
)
189232
->joinInner(
190-
['quote_address' => $setup->getTable('quote_address')],
191-
'sales_order.quote_id = quote_address.quote_id
192-
AND ' . $addressTable . '.address_type = quote_address.address_type',
233+
['quote' => $quoteTable],
234+
'quote_address.quote_id = quote.entity_id',
193235
[]
194236
)
195-
->where(
196-
$addressTable . '.quote_address_id IS NULL'
197-
);
198-
$updateOrderAddress = $setup->getConnection()->updateFromSelect(
199-
$updateOrderAddress,
200-
$addressTable
201-
);
202-
$setup->getConnection()->query($updateOrderAddress);
237+
->where('quote.entity_id in (?)', array_column($orderAddresses, 'quote_id'))
238+
->where('address_type = ?', $addressType);
239+
240+
$quoteAddresses = $quoteConnection->fetchAssoc($query);
241+
242+
foreach ($orderAddresses as $orderAddress) {
243+
$bind = [
244+
'quote_address_id' => $quoteAddresses[$orderAddress['quote_id']]['address_id'] ?? null,
245+
];
246+
$where = [
247+
'entity_id = ?' => $orderAddress['entity_id']
248+
];
249+
250+
$salesConnection->update($salesOrderAddressTable, $bind, $where);
251+
}
203252
}
204253
}

0 commit comments

Comments
 (0)