Skip to content

Commit 2627ccf

Browse files
committed
MAGETWO-67283: quote_address.free_shipping is different depending on whether Magento was upgraded vs installed
1 parent d63d7e7 commit 2627ccf

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\OfflineShipping\Setup;
8+
9+
use Magento\Framework\Setup\ModuleContextInterface;
10+
use Magento\Framework\Setup\ModuleDataSetupInterface;
11+
use Magento\Framework\Setup\UpgradeDataInterface;
12+
use Magento\Quote\Model\Quote\Address;
13+
14+
/**
15+
* Upgrade Data script.
16+
*/
17+
class UpgradeData implements UpgradeDataInterface
18+
{
19+
/**
20+
* {@inheritdoc}
21+
*/
22+
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
23+
{
24+
$setup->startSetup();
25+
if ($context->getVersion() && version_compare($context->getVersion(), '2.0.1') < 0) {
26+
$this->updateQuoteShippingAddresses($setup);
27+
}
28+
$setup->endSetup();
29+
}
30+
31+
/**
32+
* Replace Null with '0' for free_shipping in quote shipping addresses.
33+
*
34+
* @param ModuleDataSetupInterface $setup
35+
* @return void
36+
*/
37+
private function updateQuoteShippingAddresses(ModuleDataSetupInterface $setup)
38+
{
39+
$setup->getConnection()->update(
40+
$setup->getTable('quote_address'),
41+
['free_shipping' => 0],
42+
[
43+
'address_type = ?' => Address::ADDRESS_TYPE_SHIPPING,
44+
new \Zend_Db_Expr('free_shipping IS NULL'),
45+
]
46+
);
47+
}
48+
}

app/code/Magento/OfflineShipping/etc/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
9-
<module name="Magento_OfflineShipping" setup_version="2.0.0">
9+
<module name="Magento_OfflineShipping" setup_version="2.0.1">
1010
<sequence>
1111
<module name="Magento_Store"/>
1212
<module name="Magento_Sales"/>

0 commit comments

Comments
 (0)