From d7ecbf3dddbb5345d731a2322f47fb33884b5ba3 Mon Sep 17 00:00:00 2001 From: simon vianen Date: Mon, 18 Mar 2024 11:31:12 +0100 Subject: [PATCH] [FEATURE][IN23-62] added collumn last visited --- Api/Data/PageNotFoundInterface.php | 34 +++++++++++++------ Model/PageNotFound.php | 19 +++++++++++ Observer/Controller/ActionPredispatch.php | 4 ++- etc/db_schema.xml | 1 + .../experius_page_not_found_index.xml | 10 +++++- 5 files changed, 56 insertions(+), 12 deletions(-) diff --git a/Api/Data/PageNotFoundInterface.php b/Api/Data/PageNotFoundInterface.php index 395c4a7..1a5afa6 100644 --- a/Api/Data/PageNotFoundInterface.php +++ b/Api/Data/PageNotFoundInterface.php @@ -8,6 +8,7 @@ interface PageNotFoundInterface const TO_URL = 'to_url'; const COUNT_REDIRECT = 'count_redirect'; + const LAST_VISITED = 'last_visited'; const COUNT = 'count'; const FROM_URL = 'from_url'; const PAGE_NOT_FOUND_ID = 'page_not_found_id'; @@ -17,7 +18,7 @@ interface PageNotFoundInterface * Get page_not_found_id * @return string|null */ - + public function getPageNotFoundId(); /** @@ -25,14 +26,14 @@ public function getPageNotFoundId(); * @param string $page_not_found_id * @return \Experius\PageNotFound\Api\Data\PageNotFoundInterface */ - + public function setPageNotFoundId($pageNotFoundId); /** * Get from_url * @return string|null */ - + public function getFromUrl(); /** @@ -40,14 +41,14 @@ public function getFromUrl(); * @param string $from_url * @return \Experius\PageNotFound\Api\Data\PageNotFoundInterface */ - + public function setFromUrl($from_url); /** * Get to_url * @return string|null */ - + public function getToUrl(); /** @@ -55,14 +56,14 @@ public function getToUrl(); * @param string $to_url * @return \Experius\PageNotFound\Api\Data\PageNotFoundInterface */ - + public function setToUrl($to_url); /** * Get count * @return string|null */ - + public function getCount(); /** @@ -70,14 +71,14 @@ public function getCount(); * @param string $count * @return \Experius\PageNotFound\Api\Data\PageNotFoundInterface */ - + public function setCount($count); /** * Get count_redirect * @return string|null */ - + public function getCountRedirect(); /** @@ -85,6 +86,19 @@ public function getCountRedirect(); * @param string $count_redirect * @return \Experius\PageNotFound\Api\Data\PageNotFoundInterface */ - + public function setCountRedirect($count_redirect); + + /** + * Get last_visited + * @return string|null + */ + public function getLastVisited(); + + /** + * Set last_visited + * @param string $last_visited + * @return \Experius\PageNotFound\Api\Data\PageNotFoundInterface + */ + public function setLastVisited($last_visited); } diff --git a/Model/PageNotFound.php b/Model/PageNotFound.php index f674c23..8997d1b 100644 --- a/Model/PageNotFound.php +++ b/Model/PageNotFound.php @@ -110,4 +110,23 @@ public function setCountRedirect($count_redirect) { return $this->setData(self::COUNT_REDIRECT, $count_redirect); } + + /** + * Get last_visited + * @return string + */ + public function getLastVisited() + { + return $this->getData(self::LAST_VISITED); + } + + /** + * Set last_visited + * @param string $last_visited + * @return \Experius\PageNotFound\Api\Data\PageNotFoundInterface + */ + public function setLastVisited($last_visited) + { + return $this->setData(self::LAST_VISITED, $last_visited); + } } diff --git a/Observer/Controller/ActionPredispatch.php b/Observer/Controller/ActionPredispatch.php index b4ee030..5d3b2ff 100644 --- a/Observer/Controller/ActionPredispatch.php +++ b/Observer/Controller/ActionPredispatch.php @@ -19,7 +19,7 @@ class ActionPredispatch implements \Magento\Framework\Event\ObserverInterface protected $request; protected $action; - + protected $urlParts = []; private $resultFactory; @@ -112,6 +112,8 @@ protected function savePageNotFound($fromUrl){ $pageNotFoundModel = $this->pageNotFoundFactory->create(); $pageNotFoundModel->load($fromUrl,'from_url'); + $curentDate = date("Y-m-d"); + $pageNotFoundModel->setLastVisited($curentDate); if($pageNotFoundModel->getId()){ $count = $pageNotFoundModel->getCount(); diff --git a/etc/db_schema.xml b/etc/db_schema.xml index adc9205..b1bd32d 100644 --- a/etc/db_schema.xml +++ b/etc/db_schema.xml @@ -10,6 +10,7 @@ comment="count"/> + diff --git a/view/adminhtml/ui_component/experius_page_not_found_index.xml b/view/adminhtml/ui_component/experius_page_not_found_index.xml index 32bb494..790e753 100644 --- a/view/adminhtml/ui_component/experius_page_not_found_index.xml +++ b/view/adminhtml/ui_component/experius_page_not_found_index.xml @@ -128,7 +128,15 @@ - + + + dateRange + date + yyyy-MM-dd + + + + page_not_found_id