Skip to content

Commit 624c108

Browse files
committed
Merge branch 'ACP2E-3329' of https://github.com/adobe-commerce-tier-4/magento2ce into PR-VK-2024-11-27-CE
2 parents 445209c + 26fd991 commit 624c108

File tree

3 files changed

+14
-34
lines changed

3 files changed

+14
-34
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2014 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -35,10 +35,10 @@
3535
*/
3636
class Visitor extends AbstractModel
3737
{
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';
4242
private const SECONDS_24_HOURS = 86400;
4343

4444
/**
@@ -213,7 +213,6 @@ public function afterSave()
213213
return parent::afterSave();
214214
}
215215

216-
217216
/**
218217
* Save visitor by request
219218
*
@@ -293,6 +292,7 @@ public function bindCustomerLogin($observer)
293292
if (!$this->getCustomerId()) {
294293
$this->setDoCustomerLogin(true);
295294
$this->setCustomerId($customer->getId());
295+
$this->setCreatedAt((new \DateTime())->format(DateTime::DATETIME_PHP_FORMAT));
296296
}
297297
return $this;
298298
}
Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,18 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2015 Adobe
4+
* All Rights Reserved.
55
*/
66

77
namespace Magento\Customer\Observer\Visitor;
88

9-
use Magento\Customer\Model\Visitor;
109
use Magento\Framework\Event\Observer;
11-
use Magento\Framework\Session\SessionManagerInterface;
1210

1311
/**
1412
* Visitor Observer
15-
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
1613
*/
1714
class InitByRequestObserver extends AbstractVisitorObserver
1815
{
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-
3616
/**
3717
* Init visitor by request
3818
*
@@ -41,9 +21,6 @@ public function __construct(
4121
*/
4222
public function execute(Observer $observer)
4323
{
44-
if ($observer->getRequest()->getFullActionName() === 'customer_account_loginPost') {
45-
$this->sessionManager->setVisitorData(['do_customer_login' => true]);
46-
}
4724
$this->visitor->initByRequest($observer);
4825
}
4926
}

dev/tests/integration/testsuite/Magento/Customer/Model/VisitorTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2014 Adobe
4+
* All Rights Reserved.
55
*/
66
namespace Magento\Customer\Model;
77

@@ -25,11 +25,14 @@ public function testBindCustomerLogin()
2525
// Visitor has not customer ID yet
2626
$this->assertTrue($visitor->getDoCustomerLogin());
2727
$this->assertEquals($customer->getId(), $visitor->getCustomerId());
28+
$this->assertNotNull($visitor->getCreatedAt());
2829

2930
// Visitor already has customer ID
31+
$createdAt = $visitor->getCreatedAt();
3032
$visitor->unsDoCustomerLogin();
3133
$this->_loginCustomer('customer@example.com', 'password');
3234
$this->assertNull($visitor->getDoCustomerLogin());
35+
$this->assertEquals($createdAt, $visitor->getCreatedAt());
3336
}
3437

3538
/**

0 commit comments

Comments
 (0)