Skip to content

Commit a0add9f

Browse files
author
nsyvokonenko
committed
MAGETWO-37608: Change install script
- some fields were changed
1 parent 857b69e commit a0add9f

File tree

2 files changed

+25
-19
lines changed

2 files changed

+25
-19
lines changed

app/code/Magento/Customer/Model/Resource/Customer.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,20 @@ protected function _saveAddresses(\Magento\Customer\Model\Customer $customer)
203203
}
204204
}
205205
//@TODO: find appropriate place
206-
$this->_getWriteAdapter()->update(
207-
$this->getTable('customer_entity'),
208-
[
209-
'default_billing' => $customer->getData('default_billing'),
210-
'default_shipping' => $customer->getData('default_shipping')
211-
],
212-
$this->_getWriteAdapter()->quoteInto('entity_id = ?', $customer->getId())
213-
);
206+
$changedAddresses = [];
207+
if ($defaultBillingId != $customer->getData('default_billing')) {
208+
$changedAddresses['default_billing'] = $customer->getData('default_billing');
209+
}
210+
if ($defaultShippingId != $customer->getData('default_shipping')) {
211+
$changedAddresses['default_shipping'] = $customer->getData('default_shipping');
212+
}
213+
if ($changedAddresses) {
214+
$this->_getWriteAdapter()->update(
215+
$this->getTable('customer_entity'),
216+
$changedAddresses,
217+
$this->_getWriteAdapter()->quoteInto('entity_id = ?', $customer->getId())
218+
);
219+
}
214220

215221
return $this;
216222
}

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
111111
'prefix',
112112
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
113113
40,
114-
[],
114+
['nullable' => true, 'default' => null],
115115
'Prefix'
116116
)->addColumn(
117117
'firstname',
@@ -123,7 +123,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
123123
'middlename',
124124
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
125125
255,
126-
[],
126+
['nullable' => true, 'default' => null],
127127
'Middle Name/Initial'
128128
)->addColumn(
129129
'lastname',
@@ -135,7 +135,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
135135
'suffix',
136136
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
137137
40,
138-
[],
138+
['nullable' => true, 'default' => null],
139139
'Suffix'
140140
)->addColumn(
141141
'dob',
@@ -146,11 +146,11 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
146146
)->addColumn(
147147
'password_hash',
148148
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
149-
255
149+
128
150150
)->addColumn(
151151
'rp_token',
152152
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
153-
255,
153+
128,
154154
['nullable' => true, 'default' => null],
155155
'Reset password token'
156156
)->addColumn(
@@ -163,13 +163,13 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
163163
'default_billing',
164164
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
165165
null,
166-
['nullable' => true],
166+
['unsigned' => true, 'nullable' => true, 'default' => null],
167167
'Default Billing Address'
168168
)->addColumn(
169169
'default_shipping',
170170
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
171171
null,
172-
['nullable' => true],
172+
['unsigned' => true, 'nullable' => true, 'default' => null],
173173
'Default Shipping Address'
174174
)->addColumn(
175175
'taxvat',
@@ -181,13 +181,13 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
181181
'confirmation',
182182
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
183183
64,
184-
[],
184+
['nullable' => true, 'default' => null],
185185
'Is Confirmed'
186186
)->addColumn(
187187
'gender',
188-
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
189-
10,
190-
[],
188+
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
189+
null,
190+
['unsigned' => true],
191191
'Gender'
192192
)->addIndex(
193193
$installer->getIdxName('customer_entity', ['store_id']),

0 commit comments

Comments
 (0)