File tree Expand file tree Collapse file tree 3 files changed +14
-34
lines changed
app/code/Magento/Customer
dev/tests/integration/testsuite/Magento/Customer/Model Expand file tree Collapse file tree 3 files changed +14
-34
lines changed Original file line number Diff line number Diff line change 1
1
<?php
2
2
/**
3
- * Copyright © Magento, Inc. All rights reserved.
4
- * See COPYING.txt for license details .
3
+ * Copyright 2014 Adobe
4
+ * All Rights Reserved .
5
5
*/
6
6
declare (strict_types=1 );
7
7
35
35
*/
36
36
class Visitor extends AbstractModel
37
37
{
38
- const VISITOR_TYPE_CUSTOMER = 'c ' ;
39
- const VISITOR_TYPE_VISITOR = 'v ' ;
40
- const DEFAULT_ONLINE_MINUTES_INTERVAL = 15 ;
41
- const XML_PATH_ONLINE_INTERVAL = 'customer/online_customers/online_minutes_interval ' ;
38
+ public const VISITOR_TYPE_CUSTOMER = 'c ' ;
39
+ public const VISITOR_TYPE_VISITOR = 'v ' ;
40
+ public const DEFAULT_ONLINE_MINUTES_INTERVAL = 15 ;
41
+ public const XML_PATH_ONLINE_INTERVAL = 'customer/online_customers/online_minutes_interval ' ;
42
42
private const SECONDS_24_HOURS = 86400 ;
43
43
44
44
/**
@@ -213,7 +213,6 @@ public function afterSave()
213
213
return parent ::afterSave ();
214
214
}
215
215
216
-
217
216
/**
218
217
* Save visitor by request
219
218
*
@@ -293,6 +292,7 @@ public function bindCustomerLogin($observer)
293
292
if (!$ this ->getCustomerId ()) {
294
293
$ this ->setDoCustomerLogin (true );
295
294
$ this ->setCustomerId ($ customer ->getId ());
295
+ $ this ->setCreatedAt ((new \DateTime ())->format (DateTime::DATETIME_PHP_FORMAT ));
296
296
}
297
297
return $ this ;
298
298
}
Original file line number Diff line number Diff line change 1
1
<?php
2
2
/**
3
- * Copyright © Magento, Inc. All rights reserved.
4
- * See COPYING.txt for license details .
3
+ * Copyright 2015 Adobe
4
+ * All Rights Reserved .
5
5
*/
6
6
7
7
namespace Magento \Customer \Observer \Visitor ;
8
8
9
- use Magento \Customer \Model \Visitor ;
10
9
use Magento \Framework \Event \Observer ;
11
- use Magento \Framework \Session \SessionManagerInterface ;
12
10
13
11
/**
14
12
* Visitor Observer
15
- * @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
16
13
*/
17
14
class InitByRequestObserver extends AbstractVisitorObserver
18
15
{
19
- /**
20
- * @var SessionManagerInterface
21
- */
22
- private $ sessionManager ;
23
-
24
- /**
25
- * @param Visitor $visitor
26
- * @param SessionManagerInterface $sessionManager
27
- */
28
- public function __construct (
29
- Visitor $ visitor ,
30
- SessionManagerInterface $ sessionManager
31
- ) {
32
- parent ::__construct ($ visitor );
33
- $ this ->sessionManager = $ sessionManager ;
34
- }
35
-
36
16
/**
37
17
* Init visitor by request
38
18
*
@@ -41,9 +21,6 @@ public function __construct(
41
21
*/
42
22
public function execute (Observer $ observer )
43
23
{
44
- if ($ observer ->getRequest ()->getFullActionName () === 'customer_account_loginPost ' ) {
45
- $ this ->sessionManager ->setVisitorData (['do_customer_login ' => true ]);
46
- }
47
24
$ this ->visitor ->initByRequest ($ observer );
48
25
}
49
26
}
Original file line number Diff line number Diff line change 1
1
<?php
2
2
/**
3
- * Copyright © Magento, Inc. All rights reserved.
4
- * See COPYING.txt for license details .
3
+ * Copyright 2014 Adobe
4
+ * All Rights Reserved .
5
5
*/
6
6
namespace Magento \Customer \Model ;
7
7
@@ -25,11 +25,14 @@ public function testBindCustomerLogin()
25
25
// Visitor has not customer ID yet
26
26
$ this ->assertTrue ($ visitor ->getDoCustomerLogin ());
27
27
$ this ->assertEquals ($ customer ->getId (), $ visitor ->getCustomerId ());
28
+ $ this ->assertNotNull ($ visitor ->getCreatedAt ());
28
29
29
30
// Visitor already has customer ID
31
+ $ createdAt = $ visitor ->getCreatedAt ();
30
32
$ visitor ->unsDoCustomerLogin ();
31
33
$ this ->_loginCustomer ('customer@example.com ' , 'password ' );
32
34
$ this ->assertNull ($ visitor ->getDoCustomerLogin ());
35
+ $ this ->assertEquals ($ createdAt , $ visitor ->getCreatedAt ());
33
36
}
34
37
35
38
/**
You can’t perform that action at this time.
0 commit comments