Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Helper/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Settings extends AbstractHelper
const IS_CRON_ENABLED = 'pagenotfound/cron_config/is_cron_enabled';
const CONFIG_DAYS_TO_CLEAN = 'pagenotfound/cron_config/days_to_clean';
const DELETE_NOT_EMPTY_REDIRECT = 'pagenotfound/cron_config/delete_not_empty_redirect';
const GET_EXCLUDED_URLS = 'pagenotfound/general/exclude_url';

/**
* @param Context $context
Expand Down Expand Up @@ -50,4 +51,16 @@ public function getDeleteNotEmpyRedirect()
return $this->scopeConfig->getValue(self::DELETE_NOT_EMPTY_REDIRECT);
}

/**
* @return array|string[]
*/
public function getExcludedUrls()
{
$excludedUrls = $this->scopeConfig->getValue(self::GET_EXCLUDED_URLS);
if ($excludedUrls) {
return explode(',', $excludedUrls);
}
return [];
}

}
10 changes: 9 additions & 1 deletion Observer/Controller/ActionPredispatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ class ActionPredispatch implements \Magento\Framework\Event\ObserverInterface
protected $urlParts = [];

protected $storeManager;

private $resultFactory;

protected $setting;

public function __construct(
\Magento\Framework\UrlInterface $url,
\Experius\PageNotFound\Model\PageNotFoundFactory $pageNotFoundFactory,
Expand All @@ -38,6 +41,7 @@ public function __construct(
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Magento\Framework\Controller\ResultFactory $resultFactory,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Experius\PageNotFound\Helper\Settings $setting

) {
$this->url = $url;
Expand All @@ -48,6 +52,7 @@ public function __construct(
$this->scopeConfig = $scopeConfig;
$this->resultFactory = $resultFactory;
$this->storeManager = $storeManager;
$this->setting = $setting;

}

Expand Down Expand Up @@ -86,8 +91,11 @@ public function execute(

$this->urlParts = parse_url($this->url->getCurrentUrl());

$this->savePageNotFound($this->getCurrentUrl());
if(in_array($this->urlParts['path'],$this->setting->getExcludedUrls())) {
return;
}

$this->savePageNotFound($this->getCurrentUrl());
}

/* @return \Magento\Framework\App\RequestInterface */
Expand Down
4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
{
"name": "Simon Vianen",
"email": "simonvianen@experius.nl"
},
{
"name": "Jeffrey Leeuw",
"email": "jeffreyleeuw@happyhorizon.com"
}
],
"minimum-stability": "dev",
Expand Down
4 changes: 4 additions & 0 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
<label>Included Params in To Url</label>
<comment>comma separated. For example language,p,id</comment>
</field>
<field id="exclude_url" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="50" translate="label" type="textarea">
<label>Exclude url</label>
<comment>Enter all the URLs you want to exclude from the 'Page Not Found' module, separated by commas.</comment>
</field>
</group>
<group id="cron_config" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="10" translate="label">
<label>config</label>
Expand Down