Forked from KristianH/deleteDataFromOxidShop.php
Last active
August 29, 2015 14:11
-
-
Save kermie/2c19d1499144fdf3ca11 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
//WARNING: this file deletes content from DB! be careful! | |
// Use this in a oxid e-sales shop 4.7.0 or higher | |
//if you understand, remove or comment the next line: | |
die('Please read the comments!'); | |
include('bootstrap.php'); | |
/** | |
* defines 'php model class' => 'database table' | |
*/ | |
$aDeletes = array( | |
'oxcategory' => 'oxcategories', // categories will not deletet until child categories exist | |
'oxvendor' => 'oxvendor', | |
'oxmanufacturer' => 'oxmanufacturers', | |
'oxattribute' => 'oxattribute', | |
'oxarticle' => 'oxarticles', | |
'oxselectlist' => 'oxselectlist', | |
); | |
foreach ($aDeletes AS $class => $table) { | |
$sSelect = <<<MYSQL | |
SELECT oxid FROM $table | |
MYSQL; | |
$aArticles = oxDB::getDb(oxDb::FETCH_MODE_ASSOC)->getArray($sSelect); | |
$i = 0; | |
foreach ($aArticles as $sId) { | |
/** @var oxcategory $oArticle */ | |
$oArticle = oxNew($class); | |
$oArticle->init($table); | |
$oArticle->load($sId['oxid']); | |
$oArticle->delete(); | |
$i++; | |
} | |
echo $class . ': ' . $i . PHP_EOL; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment