Created
May 12, 2017 09:44
-
-
Save alexsoin/c184381ccbb877ddd9f55edbb4e1aee1 to your computer and use it in GitHub Desktop.
Обновление фото товаров после переустановки минишоп (подходит для ms2Gallery но можно переделать под miniShop, запускать через SSH)
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
<?php | |
//set_time_limit(00); | |
define('MODX_API_MODE', true); | |
require 'index.php'; | |
$basePath = getcwd(); | |
$modx->getService('error', 'error.modError'); | |
$modx->setLogLevel(modX::LOG_LEVEL_ERROR); | |
$modx->setLogTarget(array | |
( | |
'target' => 'FILE', | |
'options' => array | |
( | |
'filename' => 'gallery.' . strftime('%Y-%m-%dT%H:%M:%S') | |
) | |
) | |
); | |
chdir($basePath . '/assets/images/resources/'); | |
$folders = scandir(getcwd(),0); | |
foreach ($folders as $folder) { | |
if (($folder != '.') && ($folder != '..')) { | |
if (is_dir($folder)) { | |
$catalog = getcwd() . '/' . $folder; | |
chdir($catalog); | |
$files = scandir(getcwd(),0); | |
foreach ($files as $file) { | |
if (is_dir($file) == FALSE) { | |
//для лога выведем все файлы и id ресурсов | |
//echo 'Грузим: ' . getcwd() . '/' . $file . ' ID ресурса: ' . $folder . ' | |
'; | |
$res = $modx->runProcessor('gallery/upload', array( | |
'file' => getcwd() . '/' . $file, | |
'id' => $folder | |
), array( | |
'processors_path' => MODX_CORE_PATH . 'components/ms2gallery/processors/mgr/' | |
) | |
); | |
if ($res->isError()) { | |
print_r($res->getAllErrors()); | |
} else { | |
print_r($res->getObject()); | |
} | |
} | |
} | |
chdir(getcwd() . '/..'); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment