5
5
*/
6
6
namespace Magento \Customer \Model \ResourceModel \Online \Grid ;
7
7
8
- use Magento \Framework \View \Element \UiComponent \DataProvider \SearchResult ;
9
8
use Magento \Customer \Model \Visitor ;
10
- use Magento \Framework \Api ;
11
- use Magento \Framework \Event \ManagerInterface as EventManager ;
12
9
use Magento \Framework \Data \Collection \Db \FetchStrategyInterface as FetchStrategy ;
13
10
use Magento \Framework \Data \Collection \EntityFactoryInterface as EntityFactory ;
11
+ use Magento \Framework \Event \ManagerInterface as EventManager ;
12
+ use Magento \Framework \Exception \LocalizedException ;
13
+ use Magento \Framework \Stdlib \DateTime \DateTime ;
14
+ use Magento \Framework \View \Element \UiComponent \DataProvider \SearchResult ;
14
15
use Psr \Log \LoggerInterface as Logger ;
15
16
16
17
/**
@@ -23,17 +24,17 @@ class Collection extends SearchResult
23
24
/**
24
25
* Value of seconds in one minute
25
26
*/
26
- const SECONDS_IN_MINUTE = 60 ;
27
+ public const SECONDS_IN_MINUTE = 60 ;
27
28
28
29
/**
29
- * @var \Magento\Framework\Stdlib\DateTime\ DateTime
30
+ * @var DateTime
30
31
*/
31
- protected $ date ;
32
+ protected DateTime $ date ;
32
33
33
34
/**
34
35
* @var Visitor
35
36
*/
36
- protected $ visitorModel ;
37
+ protected Visitor $ visitorModel ;
37
38
38
39
/**
39
40
* @param EntityFactory $entityFactory
@@ -43,7 +44,8 @@ class Collection extends SearchResult
43
44
* @param string $mainTable
44
45
* @param string $resourceModel
45
46
* @param Visitor $visitorModel
46
- * @param \Magento\Framework\Stdlib\DateTime\DateTime $date
47
+ * @param DateTime $date
48
+ * @throws LocalizedException
47
49
*/
48
50
public function __construct (
49
51
EntityFactory $ entityFactory ,
@@ -53,7 +55,7 @@ public function __construct(
53
55
$ mainTable ,
54
56
$ resourceModel ,
55
57
Visitor $ visitorModel ,
56
- \ Magento \ Framework \ Stdlib \ DateTime \ DateTime $ date
58
+ DateTime $ date
57
59
) {
58
60
$ this ->date = $ date ;
59
61
$ this ->visitorModel = $ visitorModel ;
@@ -65,7 +67,7 @@ public function __construct(
65
67
*
66
68
* @return $this
67
69
*/
68
- protected function _initSelect ()
70
+ protected function _initSelect (): Collection
69
71
{
70
72
parent ::_initSelect ();
71
73
$ connection = $ this ->getConnection ();
@@ -78,6 +80,7 @@ protected function _initSelect()
78
80
'main_table.last_visit_at >= ? ' ,
79
81
$ connection ->formatDate ($ lastDate )
80
82
);
83
+ $ this ->addFilterToMap ('customer_id ' , 'main_table.customer_id ' );
81
84
$ expression = $ connection ->getCheckSql (
82
85
'main_table.customer_id IS NOT NULL AND main_table.customer_id != 0 ' ,
83
86
$ connection ->quote (Visitor::VISITOR_TYPE_CUSTOMER ),
@@ -92,9 +95,9 @@ protected function _initSelect()
92
95
*
93
96
* @param string|array $field
94
97
* @param string|int|array|null $condition
95
- * @return \Magento\Cms\Model\ResourceModel\Block\ Collection
98
+ * @return Collection
96
99
*/
97
- public function addFieldToFilter ($ field , $ condition = null )
100
+ public function addFieldToFilter ($ field , $ condition = null ): Collection
98
101
{
99
102
if ($ field == 'visitor_type ' ) {
100
103
$ field = 'customer_id ' ;
0 commit comments