55 */
66namespace Magento \Customer \Model \ResourceModel \Online \Grid ;
77
8- use Magento \Framework \View \Element \UiComponent \DataProvider \SearchResult ;
98use Magento \Customer \Model \Visitor ;
10- use Magento \Framework \Api ;
11- use Magento \Framework \Event \ManagerInterface as EventManager ;
129use Magento \Framework \Data \Collection \Db \FetchStrategyInterface as FetchStrategy ;
1310use 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 ;
1415use Psr \Log \LoggerInterface as Logger ;
1516
1617/**
@@ -23,17 +24,17 @@ class Collection extends SearchResult
2324 /**
2425 * Value of seconds in one minute
2526 */
26- const SECONDS_IN_MINUTE = 60 ;
27+ public const SECONDS_IN_MINUTE = 60 ;
2728
2829 /**
29- * @var \Magento\Framework\Stdlib\DateTime\ DateTime
30+ * @var DateTime
3031 */
31- protected $ date ;
32+ protected DateTime $ date ;
3233
3334 /**
3435 * @var Visitor
3536 */
36- protected $ visitorModel ;
37+ protected Visitor $ visitorModel ;
3738
3839 /**
3940 * @param EntityFactory $entityFactory
@@ -43,7 +44,8 @@ class Collection extends SearchResult
4344 * @param string $mainTable
4445 * @param string $resourceModel
4546 * @param Visitor $visitorModel
46- * @param \Magento\Framework\Stdlib\DateTime\DateTime $date
47+ * @param DateTime $date
48+ * @throws LocalizedException
4749 */
4850 public function __construct (
4951 EntityFactory $ entityFactory ,
@@ -53,7 +55,7 @@ public function __construct(
5355 $ mainTable ,
5456 $ resourceModel ,
5557 Visitor $ visitorModel ,
56- \ Magento \ Framework \ Stdlib \ DateTime \ DateTime $ date
58+ DateTime $ date
5759 ) {
5860 $ this ->date = $ date ;
5961 $ this ->visitorModel = $ visitorModel ;
@@ -65,7 +67,7 @@ public function __construct(
6567 *
6668 * @return $this
6769 */
68- protected function _initSelect ()
70+ protected function _initSelect (): Collection
6971 {
7072 parent ::_initSelect ();
7173 $ connection = $ this ->getConnection ();
@@ -78,6 +80,7 @@ protected function _initSelect()
7880 'main_table.last_visit_at >= ? ' ,
7981 $ connection ->formatDate ($ lastDate )
8082 );
83+ $ this ->addFilterToMap ('customer_id ' , 'main_table.customer_id ' );
8184 $ expression = $ connection ->getCheckSql (
8285 'main_table.customer_id IS NOT NULL AND main_table.customer_id != 0 ' ,
8386 $ connection ->quote (Visitor::VISITOR_TYPE_CUSTOMER ),
@@ -92,9 +95,9 @@ protected function _initSelect()
9295 *
9396 * @param string|array $field
9497 * @param string|int|array|null $condition
95- * @return \Magento\Cms\Model\ResourceModel\Block\ Collection
98+ * @return Collection
9699 */
97- public function addFieldToFilter ($ field , $ condition = null )
100+ public function addFieldToFilter ($ field , $ condition = null ): Collection
98101 {
99102 if ($ field == 'visitor_type ' ) {
100103 $ field = 'customer_id ' ;
0 commit comments