Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script for saving old seo urls. Redirects old seo urls (e. g. from an other shop software after relaunch) to the new oxid shop seo urls.
<?php
/**
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @copyright (c) Proud Sourcing GmbH | 2013
* @link https://gist.github.com/proudcommerce
* @version 1.0.0
**/
class daten
{
var $dbServer; // database host name
var $dbName; // database name
var $dbUser; // database user name
var $dbPassword; // database user password
function daten()
{
require "config.inc.php";
}
}
function newID() {
return substr(uniqid( "", true), 0, 3) . uniqid( "", true);
}
$config = new daten();
$dbServer = $config->dbHost;
$dbName = $config->dbName;
$dbUser = $config->dbUser;
$dbPassword = $config->dbPwd;
$db = mysql_connect($dbServer, $dbUser, $dbPassword) or die(mysql_error());
mysql_select_db($dbName, $db) or die(mysql_error());
$sSQL = "SELECT oxid, nm_oldseourl FROM oxarticles WHERE nm_oldseourl != ''";
$aRes = mysql_query($sSQL);
if(mysql_num_rows($aRes) > 0)
{
echo "saving old article seo urls ...<br>";
while($aData = mysql_fetch_array($aRes))
{
$sArticleId = $aData["oxid"];
$sSeoUrl = substr($aData["nm_oldseourl"], 1);
$sSQL2 = "INSERT INTO oxseohistory (OXOBJECTID, OXSHOPID, OXIDENT) SELECT oxarticles.oxid, oxarticles.oxshopid, MD5(LOWER('$sSeoUrl')) from oxarticles where oxid = '$sArticleId'";
echo $sSQL2."<br>";
mysql_query($sSQL2);
}
}
$sSQL = "SELECT oxid, nm_oldseourl FROM oxcategories WHERE nm_oldseourl != ''";
$aRes = mysql_query($sSQL);
if(mysql_num_rows($aRes) > 0)
{
echo "<br>saving old category seo urls ...<br>";
while($aData = mysql_fetch_array($aRes))
{
$sCategoryId = $aData["oxid"];
$sSeoUrl = substr($aData["nm_oldseourl"], 1);
$sSQL2 = "INSERT INTO oxseohistory (OXOBJECTID, OXSHOPID, OXIDENT) SELECT oxcategories.oxid, oxcategories.oxshopid, MD5(LOWER('$sSeoUrl')) from oxcategories where oxid = '$sCategoryId'";
echo $sSQL2."<br>";
mysql_query($sSQL2);
}
}
mysql_close($db);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.