Last active
March 17, 2017 18:21
-
-
Save dimitriipro/b98595fcbf3a55b9a6d207df64a7f74e to your computer and use it in GitHub Desktop.
Перенаправление с 404 если в utm метке было название товара (Bitrix)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
$utmSearch = urldecode($_GET['utm_content']); // utm_content - меняем на метку в которой может быть название товара | |
if($utmSearch) { | |
if (CModule::IncludeModule('search')) { | |
$obSearch = new CSearch; | |
$obSearch->Search(array(//при желании, фильтр можете еще сузить, см.документацию | |
'QUERY' => $utmSearch, | |
'SITE_ID' => SITE_ID, | |
'MODULE_ID' => 'iblock', | |
'PARAM2' => 2 // ID каталога | |
)); | |
// перебрасываем на первый попващийся товар если посик что то показал | |
if ($resultSearch = $obSearch->fetch()) { | |
LocalRedirect($resultSearch['URL']); | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment