Answer the question
In order to leave comments, you need to log in
Why does php crash after 6 iterations with memory overflow?
Modx 2.7.1
Upgraded the modResource table by adding extId and parentExtId
after importing the categories, fixing the resource parent dependencies with this script.
foreach ($this->modx->getIterator('modResource', ['extId:!=' => null]) as $obj) {//Берем все р-сы где не пусто extID
$parentObj = $this->modx->getObject('modResource', ['extId' => $obj->parentExtId]); //Ищем родителя по extId родителя и parentExtId текущего рес-са
$parentId = null !== $parentObj ? $parentObj->id : $this->getConfig('root_catalog_id'); //Если такого нет, то ставим дефолного родителя.
$obj->set('parent', $parentId); //Установка родителя
if ($obj->save()) { //сохраняем
$this->log("Succes set parent {$parentId} for {$obj->id}");
} else {
$this->log("Error set parent {$parentId} for {$obj->id}");
}
unset($obj, $parentObj, $parentId);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question