Skip to content

Commit 3bc378c

Browse files
Merge pull request #367 from magento-folks/2.1.3_bugs_pr
Fixed issues: - MAGETWO-56397: Unable to Upgrade with Split Databases - MAGETWO-57387: Unable to print Invoices and Credit memo from Sales>Orders - MAGETWO-58064: Unable to upgrade with split databases. Part 2 - MAGETWO-58036: Reloading page on checkout causes shipping method to go "undefined"
2 parents e5cf9f4 + 6a90c6a commit 3bc378c

File tree

28 files changed

+537
-150
lines changed

28 files changed

+537
-150
lines changed

app/code/Magento/Checkout/view/frontend/web/js/model/checkout-data-resolver.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ define(
165165
}
166166

167167
if (!availableRate && window.checkoutConfig.selectedShippingMethod) {
168-
availableRate = true;
168+
availableRate = window.checkoutConfig.selectedShippingMethod;
169169
selectShippingMethodAction(window.checkoutConfig.selectedShippingMethod);
170170
}
171171

app/code/Magento/OfflineShipping/Setup/InstallSchema.php

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@
1515
*/
1616
class InstallSchema implements InstallSchemaInterface
1717
{
18+
/**
19+
* @var string
20+
*/
21+
private static $quoteConnectionName = 'checkout';
22+
23+
/**
24+
* @var string
25+
*/
26+
private static $salesConnectionName = 'sales';
27+
1828
/**
1929
* {@inheritdoc}
2030
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
@@ -105,32 +115,32 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
105115
['unsigned' => true, 'nullable' => false, 'default' => '0'],
106116
'Simple Free Shipping'
107117
);
108-
$installer->getConnection()->addColumn(
109-
$installer->getTable('sales_order_item'),
118+
$installer->getConnection(self::$salesConnectionName)->addColumn(
119+
$installer->getTable('sales_order_item', self::$salesConnectionName),
110120
'free_shipping',
111121
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
112122
null,
113123
['unsigned' => true, 'nullable' => false, 'default' => '0'],
114124
'Free Shipping'
115125
);
116-
$installer->getConnection()->addColumn(
117-
$installer->getTable('quote_address'),
126+
$installer->getConnection(self::$quoteConnectionName)->addColumn(
127+
$installer->getTable('quote_address', self::$quoteConnectionName),
118128
'free_shipping',
119129
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
120130
null,
121131
['unsigned' => true, 'nullable' => false, 'default' => '0'],
122132
'Free Shipping'
123133
);
124-
$installer->getConnection()->addColumn(
125-
$installer->getTable('quote_item'),
134+
$installer->getConnection(self::$quoteConnectionName)->addColumn(
135+
$installer->getTable('quote_item', self::$quoteConnectionName),
126136
'free_shipping',
127137
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
128138
null,
129139
['unsigned' => true, 'nullable' => false, 'default' => '0'],
130140
'Free Shipping'
131141
);
132-
$installer->getConnection()->addColumn(
133-
$installer->getTable('quote_address_item'),
142+
$installer->getConnection(self::$quoteConnectionName)->addColumn(
143+
$installer->getTable('quote_address_item', self::$quoteConnectionName),
134144
'free_shipping',
135145
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
136146
null,

app/code/Magento/OfflineShipping/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
"magento/module-backend": "100.1.*",
99
"magento/module-shipping": "100.1.*",
1010
"magento/module-catalog": "101.0.*",
11-
"magento/module-sales": "100.1.*",
1211
"magento/module-sales-rule": "100.1.*",
1312
"magento/module-directory": "100.1.*",
1413
"magento/module-quote": "100.1.*",
1514
"magento/framework": "100.1.*"
1615
},
1716
"suggest": {
1817
"magento/module-checkout": "100.1.*",
18+
"magento/module-sales": "100.1.*",
1919
"magento/module-offline-shipping-sample-data": "Sample Data version:100.1.*"
2020
},
2121
"type": "magento2-module",

app/code/Magento/Persistent/Setup/InstallSchema.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
*/
1616
class InstallSchema implements InstallSchemaInterface
1717
{
18+
/**
19+
* @var string
20+
*/
21+
private static $connectionName = 'checkout';
22+
1823
/**
1924
* {@inheritdoc}
2025
*/
@@ -97,8 +102,8 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
97102
* Alter quote table with is_persistent flag
98103
*
99104
*/
100-
$installer->getConnection()->addColumn(
101-
$installer->getTable('quote'),
105+
$installer->getConnection(self::$connectionName)->addColumn(
106+
$installer->getTable('quote', self::$connectionName),
102107
'is_persistent',
103108
[
104109
'type' => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Quote\Model\Product\Plugin;
7+
8+
class RemoveQuoteItems
9+
{
10+
/**
11+
* @var \Magento\Quote\Model\Product\QuoteItemsCleanerInterface
12+
*/
13+
private $quoteItemsCleaner;
14+
15+
/**
16+
* @param \Magento\Quote\Model\Product\QuoteItemsCleanerInterface $quoteItemsCleaner
17+
*/
18+
public function __construct(\Magento\Quote\Model\Product\QuoteItemsCleanerInterface $quoteItemsCleaner)
19+
{
20+
$this->quoteItemsCleaner = $quoteItemsCleaner;
21+
}
22+
23+
/**
24+
* @param \Magento\Catalog\Model\ResourceModel\Product $subject
25+
* @param \Closure $proceed
26+
* @param \Magento\Catalog\Api\Data\ProductInterface $product
27+
* @return \Magento\Catalog\Model\ResourceModel\Product
28+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
29+
*/
30+
public function aroundDelete(
31+
\Magento\Catalog\Model\ResourceModel\Product $subject,
32+
\Closure $proceed,
33+
\Magento\Catalog\Api\Data\ProductInterface $product
34+
) {
35+
$result = $proceed($product);
36+
$this->quoteItemsCleaner->execute($product);
37+
return $result;
38+
}
39+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Quote\Model\Product;
7+
8+
class QuoteItemsCleaner implements \Magento\Quote\Model\Product\QuoteItemsCleanerInterface
9+
{
10+
/**
11+
* @var \Magento\Quote\Model\ResourceModel\Quote\Item
12+
*/
13+
private $itemResource;
14+
15+
/**
16+
* @param \Magento\Quote\Model\ResourceModel\Quote\Item $itemResource
17+
*/
18+
public function __construct(\Magento\Quote\Model\ResourceModel\Quote\Item $itemResource)
19+
{
20+
$this->itemResource = $itemResource;
21+
}
22+
23+
/**
24+
* {@inheritdoc}
25+
*/
26+
public function execute(\Magento\Catalog\Api\Data\ProductInterface $product)
27+
{
28+
$this->itemResource->getConnection()->delete(
29+
$this->itemResource->getMainTable(),
30+
'product_id = ' . $product->getId()
31+
);
32+
}
33+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Quote\Model\Product;
7+
8+
use Magento\Catalog\Api\Data\ProductInterface;
9+
10+
interface QuoteItemsCleanerInterface
11+
{
12+
/**
13+
* @param ProductInterface $product
14+
* @return void
15+
*/
16+
public function execute(ProductInterface $product);
17+
}

app/code/Magento/Quote/Setup/InstallSchema.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -964,12 +964,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
964964
$installer->getTable('quote_item'),
965965
'item_id',
966966
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
967-
)->addForeignKey(
968-
$installer->getFkName('quote_item', 'product_id', 'catalog_product_entity', 'entity_id'),
969-
'product_id',
970-
$installer->getTable('catalog_product_entity'),
971-
'entity_id',
972-
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
973967
)->addForeignKey(
974968
$installer->getFkName('quote_item', 'quote_id', 'quote', 'entity_id'),
975969
'quote_id',

app/code/Magento/Quote/Setup/QuoteSetup.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ class QuoteSetup extends EavSetup
2929
*/
3030
protected $_encryptor;
3131

32+
/**
33+
* @var string
34+
*/
35+
private static $connectionName = 'checkout';
36+
3237
/**
3338
* @param ModuleDataSetupInterface $setup
3439
* @param Context $context
@@ -70,8 +75,11 @@ public function __construct(
7075
*/
7176
protected function _flatTableExist($table)
7277
{
73-
$tablesList = $this->getSetup()->getConnection()->listTables();
74-
return in_array(strtoupper($this->getSetup()->getTable($table)), array_map('strtoupper', $tablesList));
78+
$tablesList = $this->getSetup()->getConnection(self::$connectionName)->listTables();
79+
return in_array(
80+
strtoupper($this->getSetup()->getTable($table, self::$connectionName)),
81+
array_map('strtoupper', $tablesList)
82+
);
7583
}
7684

7785
/**
@@ -107,13 +115,15 @@ public function addAttribute($entityTypeId, $code, array $attr)
107115
*/
108116
protected function _addFlatAttribute($table, $attribute, $attr)
109117
{
110-
$tableInfo = $this->getSetup()->getConnection()->describeTable($this->getSetup()->getTable($table));
118+
$tableInfo = $this->getSetup()
119+
->getConnection(self::$connectionName)
120+
->describeTable($this->getSetup()->getTable($table, self::$connectionName));
111121
if (isset($tableInfo[$attribute])) {
112122
return $this;
113123
}
114124
$columnDefinition = $this->_getAttributeColumnDefinition($attribute, $attr);
115-
$this->getSetup()->getConnection()->addColumn(
116-
$this->getSetup()->getTable($table),
125+
$this->getSetup()->getConnection(self::$connectionName)->addColumn(
126+
$this->getSetup()->getTable($table, self::$connectionName),
117127
$attribute,
118128
$columnDefinition
119129
);

app/code/Magento/Quote/Setup/Recurring.php

Lines changed: 0 additions & 73 deletions
This file was deleted.

app/code/Magento/Quote/Setup/UpgradeSchema.php

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
*/
1515
class UpgradeSchema implements UpgradeSchemaInterface
1616
{
17+
/**
18+
* @var string
19+
*/
20+
private static $connectionName = 'checkout';
21+
1722
/**
1823
* {@inheritdoc}
1924
*/
@@ -22,16 +27,16 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con
2227
$setup->startSetup();
2328

2429
if (version_compare($context->getVersion(), '2.0.1', '<')) {
25-
$setup->getConnection()->addIndex(
26-
$setup->getTable('quote_id_mask'),
27-
$setup->getIdxName('quote_id_mask', ['masked_id']),
30+
$setup->getConnection(self::$connectionName)->addIndex(
31+
$setup->getTable('quote_id_mask', self::$connectionName),
32+
$setup->getIdxName('quote_id_mask', ['masked_id'], '', self::$connectionName),
2833
['masked_id']
2934
);
3035
}
3136

3237
if (version_compare($context->getVersion(), '2.0.2', '<')) {
33-
$setup->getConnection()->changeColumn(
34-
$setup->getTable('quote_address'),
38+
$setup->getConnection(self::$connectionName)->changeColumn(
39+
$setup->getTable('quote_address', self::$connectionName),
3540
'street',
3641
'street',
3742
[
@@ -41,7 +46,15 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con
4146
]
4247
);
4348
}
44-
49+
//drop foreign key for single DB case
50+
if (version_compare($context->getVersion(), '2.0.3', '<')
51+
&& $setup->tableExists($setup->getTable('quote_item'))
52+
) {
53+
$setup->getConnection()->dropForeignKey(
54+
$setup->getTable('quote_item'),
55+
$setup->getFkName('quote_item', 'product_id', 'catalog_product_entity', 'entity_id')
56+
);
57+
}
4558
$setup->endSetup();
4659
}
4760
}

0 commit comments

Comments
 (0)