Skip to content

Commit fca00a7

Browse files
committed
Merge pull request #332 from magento-firedrakes/MAGETWO-28011
[Firedrakes] Sprint 43
2 parents 2015f5c + 60ca806 commit fca00a7

File tree

31 files changed

+596
-319
lines changed

31 files changed

+596
-319
lines changed

app/code/Magento/Config/Model/Config/Source/Locale/Timezone.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@
1111

1212
class Timezone implements \Magento\Framework\Option\ArrayInterface
1313
{
14+
/**
15+
* Timezones that works incorrect with php_intl extension
16+
*/
17+
protected $ignoredTimezones = [
18+
'Antarctica/Troll',
19+
'Asia/Chita',
20+
'Asia/Srednekolymsk',
21+
'Pacific/Bougainville'
22+
];
23+
1424
/**
1525
* @var \Magento\Framework\Locale\ListsInterface
1626
*/
@@ -29,6 +39,14 @@ public function __construct(\Magento\Framework\Locale\ListsInterface $localeList
2939
*/
3040
public function toOptionArray()
3141
{
32-
return $this->_localeLists->getOptionTimezones();
42+
$timezones = $this->_localeLists->getOptionTimezones();
43+
$timezones = array_filter($timezones, function ($value) {
44+
if (in_array($value['value'], $this->ignoredTimezones)) {
45+
return false;
46+
}
47+
return true;
48+
});
49+
50+
return $timezones;
3351
}
3452
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Config\Test\Unit\Model\Config\Source\Locale;
7+
8+
class TimezoneTest extends \PHPUnit_Framework_TestCase
9+
{
10+
/**
11+
* @var \PHPUnit_Framework_MockObject_MockObject
12+
*/
13+
protected $listMock;
14+
15+
/**
16+
* @var \Magento\Config\Model\Config\Source\Locale\Timezone
17+
*/
18+
protected $model;
19+
20+
protected function setUp()
21+
{
22+
$this->listMock = $this->getMockBuilder('Magento\Framework\Locale\TranslatedLists')
23+
->disableOriginalConstructor()
24+
->getMock();
25+
$this->model = new \Magento\Config\Model\Config\Source\Locale\Timezone($this->listMock);
26+
}
27+
28+
public function testToOptionArray()
29+
{
30+
$ignoredTimezones = [
31+
'Antarctica/Troll',
32+
'Asia/Chita',
33+
'Asia/Srednekolymsk',
34+
'Pacific/Bougainville'
35+
];
36+
$list = \DateTimeZone::listIdentifiers();
37+
$preparedList = [];
38+
foreach ($list as $value) {
39+
$preparedList[] = ['value' => $value, 'label' => $value];
40+
}
41+
$this->listMock->expects($this->once())
42+
->method('getOptionTimezones')
43+
->willReturn($preparedList);
44+
$result = $this->model->toOptionArray();
45+
foreach ($result as $value) {
46+
if (in_array($value['value'], $ignoredTimezones)) {
47+
$this->fail('Locale ' . $value['value'] . ' shouldn\'t be presented');
48+
}
49+
}
50+
}
51+
}

app/code/Magento/Customer/Api/Data/CustomerInterface.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ interface CustomerInterface extends \Magento\Framework\Api\CustomAttributesDataI
3232
const DEFAULT_BILLING = 'default_billing';
3333
const DEFAULT_SHIPPING = 'default_shipping';
3434
const KEY_ADDRESSES = 'addresses';
35+
const DISABLE_AUTO_GROUP_CHANGE = 'disable_auto_group_change';
3536
/**#@-*/
3637

3738
/**
@@ -276,15 +277,15 @@ public function setSuffix($suffix);
276277
* Get gender
277278
*
278279
* @api
279-
* @return string|null
280+
* @return int|null
280281
*/
281282
public function getGender();
282283

283284
/**
284285
* Set gender
285286
*
286287
* @api
287-
* @param string $gender
288+
* @param int $gender
288289
* @return $this
289290
*/
290291
public function setGender($gender);
@@ -357,6 +358,23 @@ public function getAddresses();
357358
*/
358359
public function setAddresses(array $addresses = null);
359360

361+
/**
362+
* Get disable auto group change flag.
363+
*
364+
* @api
365+
* @return int|null
366+
*/
367+
public function getDisableAutoGroupChange();
368+
369+
/**
370+
* Set disable auto group change flag.
371+
*
372+
* @api
373+
* @param int $disableAutoGroupChange
374+
* @return $this
375+
*/
376+
public function setDisableAutoGroupChange($disableAutoGroupChange);
377+
360378
/**
361379
* Retrieve existing extension attributes object or create a new one.
362380
*

app/code/Magento/Customer/Controller/Adminhtml/Index/Save.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ protected function _extractCustomerData()
4545
}
4646

4747
if (isset($customerData['disable_auto_group_change'])) {
48-
$customerData['disable_auto_group_change'] = (int)$customerData['disable_auto_group_change'];
48+
$customerData['disable_auto_group_change'] = (int) filter_var(
49+
$customerData['disable_auto_group_change'],
50+
FILTER_VALIDATE_BOOLEAN
51+
);
4952
}
5053

5154
return $customerData;

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,16 @@ public function getAddresses()
237237
return $this->_get(self::KEY_ADDRESSES);
238238
}
239239

240+
/**
241+
* Get disable auto group change flag.
242+
*
243+
* @return int|null
244+
*/
245+
public function getDisableAutoGroupChange()
246+
{
247+
return $this->_get(self::DISABLE_AUTO_GROUP_CHANGE);
248+
}
249+
240250
/**
241251
* Set customer id
242252
*
@@ -446,6 +456,17 @@ public function setAddresses(array $addresses = null)
446456
return $this->setData(self::KEY_ADDRESSES, $addresses);
447457
}
448458

459+
/**
460+
* Set disable auto group change flag.
461+
*
462+
* @param int $disableAutoGroupChange
463+
* @return $this
464+
*/
465+
public function setDisableAutoGroupChange($disableAutoGroupChange)
466+
{
467+
return $this->setData(self::DISABLE_AUTO_GROUP_CHANGE, $disableAutoGroupChange);
468+
}
469+
449470
/**
450471
* {@inheritdoc}
451472
*

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,15 @@ protected function _saveAddresses(\Magento\Customer\Model\Customer $customer)
202202
}
203203
}
204204
}
205-
$this->saveAttribute($customer, 'default_billing');
206-
$this->saveAttribute($customer, 'default_shipping');
205+
$changedAddresses = [];
206+
207+
$changedAddresses['default_billing'] = $customer->getData('default_billing');
208+
$changedAddresses['default_shipping'] = $customer->getData('default_shipping');
209+
$this->_getWriteAdapter()->update(
210+
$this->getTable('customer_entity'),
211+
$changedAddresses,
212+
$this->_getWriteAdapter()->quoteInto('entity_id = ?', $customer->getId())
213+
);
207214

208215
return $this;
209216
}
@@ -274,7 +281,6 @@ public function loadByEmail(\Magento\Customer\Model\Customer $customer, $email)
274281
public function changePassword(\Magento\Customer\Model\Customer $customer, $newPassword)
275282
{
276283
$customer->setPassword($newPassword);
277-
$this->saveAttribute($customer, 'password_hash');
278284
return $this;
279285
}
280286

@@ -383,8 +389,6 @@ public function changeResetPasswordLinkToken(\Magento\Customer\Model\Customer $c
383389
$customer->setRpTokenCreatedAt(
384390
(new \DateTime())->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT)
385391
);
386-
$this->saveAttribute($customer, 'rp_token');
387-
$this->saveAttribute($customer, 'rp_token_created_at');
388392
}
389393
return $this;
390394
}

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

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public function getDefaultEntities()
154154
'adminhtml_only' => 1,
155155
],
156156
'created_in' => [
157-
'type' => 'varchar',
157+
'type' => 'static',
158158
'label' => 'Created From',
159159
'input' => 'text',
160160
'required' => false,
@@ -163,7 +163,7 @@ public function getDefaultEntities()
163163
'adminhtml_only' => 1,
164164
],
165165
'prefix' => [
166-
'type' => 'varchar',
166+
'type' => 'static',
167167
'label' => 'Prefix',
168168
'input' => 'text',
169169
'required' => false,
@@ -173,15 +173,15 @@ public function getDefaultEntities()
173173
'position' => 30,
174174
],
175175
'firstname' => [
176-
'type' => 'varchar',
176+
'type' => 'static',
177177
'label' => 'First Name',
178178
'input' => 'text',
179179
'sort_order' => 40,
180180
'validate_rules' => 'a:2:{s:15:"max_text_length";i:255;s:15:"min_text_length";i:1;}',
181181
'position' => 40,
182182
],
183183
'middlename' => [
184-
'type' => 'varchar',
184+
'type' => 'static',
185185
'label' => 'Middle Name/Initial',
186186
'input' => 'text',
187187
'required' => false,
@@ -191,15 +191,15 @@ public function getDefaultEntities()
191191
'position' => 50,
192192
],
193193
'lastname' => [
194-
'type' => 'varchar',
194+
'type' => 'static',
195195
'label' => 'Last Name',
196196
'input' => 'text',
197197
'sort_order' => 60,
198198
'validate_rules' => 'a:2:{s:15:"max_text_length";i:255;s:15:"min_text_length";i:1;}',
199199
'position' => 60,
200200
],
201201
'suffix' => [
202-
'type' => 'varchar',
202+
'type' => 'static',
203203
'label' => 'Suffix',
204204
'input' => 'text',
205205
'required' => false,
@@ -228,7 +228,7 @@ public function getDefaultEntities()
228228
'admin_checkout' => 1,
229229
],
230230
'dob' => [
231-
'type' => 'datetime',
231+
'type' => 'static',
232232
'label' => 'Date Of Birth',
233233
'input' => 'date',
234234
'frontend' => 'Magento\Eav\Model\Entity\Attribute\Frontend\Datetime',
@@ -243,15 +243,30 @@ public function getDefaultEntities()
243243
'admin_checkout' => 1,
244244
],
245245
'password_hash' => [
246-
'type' => 'varchar',
246+
'type' => 'static',
247247
'input' => 'hidden',
248248
'backend' => 'Magento\Customer\Model\Customer\Attribute\Backend\Password',
249249
'required' => false,
250250
'sort_order' => 81,
251251
'visible' => false,
252252
],
253+
'rp_token' => [
254+
'type' => 'static',
255+
'input' => 'hidden',
256+
'required' => false,
257+
'sort_order' => 115,
258+
'visible' => false,
259+
],
260+
'rp_token_created_at' => [
261+
'type' => 'static',
262+
'input' => 'date',
263+
'validate_rules' => 'a:1:{s:16:"input_validation";s:4:"date";}',
264+
'required' => false,
265+
'sort_order' => 120,
266+
'visible' => false,
267+
],
253268
'default_billing' => [
254-
'type' => 'int',
269+
'type' => 'static',
255270
'label' => 'Default Billing Address',
256271
'input' => 'text',
257272
'backend' => 'Magento\Customer\Model\Customer\Attribute\Backend\Billing',
@@ -260,7 +275,7 @@ public function getDefaultEntities()
260275
'visible' => false,
261276
],
262277
'default_shipping' => [
263-
'type' => 'int',
278+
'type' => 'static',
264279
'label' => 'Default Shipping Address',
265280
'input' => 'text',
266281
'backend' => 'Magento\Customer\Model\Customer\Attribute\Backend\Shipping',
@@ -269,7 +284,7 @@ public function getDefaultEntities()
269284
'visible' => false,
270285
],
271286
'taxvat' => [
272-
'type' => 'varchar',
287+
'type' => 'static',
273288
'label' => 'Tax/VAT Number',
274289
'input' => 'text',
275290
'required' => false,
@@ -281,7 +296,7 @@ public function getDefaultEntities()
281296
'admin_checkout' => 1,
282297
],
283298
'confirmation' => [
284-
'type' => 'varchar',
299+
'type' => 'static',
285300
'label' => 'Is Confirmed',
286301
'input' => 'text',
287302
'required' => false,
@@ -298,7 +313,7 @@ public function getDefaultEntities()
298313
'system' => false,
299314
],
300315
'gender' => [
301-
'type' => 'int',
316+
'type' => 'static',
302317
'label' => 'Gender',
303318
'input' => 'select',
304319
'source' => 'Magento\Eav\Model\Entity\Attribute\Source\Table',
@@ -311,6 +326,15 @@ public function getDefaultEntities()
311326
'admin_checkout' => 1,
312327
'option' => ['values' => ['Male', 'Female']],
313328
],
329+
'disable_auto_group_change' => [
330+
'type' => 'static',
331+
'label' => 'Disable Automatic Group Change Based on VAT ID',
332+
'input' => 'boolean',
333+
'backend' => 'Magento\Customer\Model\Attribute\Backend\Data\Boolean',
334+
'position' => 28,
335+
'required' => false,
336+
'adminhtml_only' => true
337+
]
314338
],
315339
],
316340
'customer_address' => [

0 commit comments

Comments
 (0)