Как формируется MIGX_id? Можно ли через БД добавить опции цвета в TV поля?

Сейчас в ячейке value таблицы site_tmplvar_contentvalues прописаны так цвета для размеров:
[{"MIGX_id":"28","color_image":"site/cveta/1300f.jpg","color_code":"1300","exempel":"17","item_check":"1","size":"10x15","size_color_ignore":"18x24,24x30,30x45"},{"MIGX_id":"2","color_image":"site/cveta/1301f.jpg","color_code":"1301","exempel":"26","item_check":"1","size":"10x15","size_color_ignore":""},{"MIGX_id":"3","color_image":"site/cveta/1302f.jpg","color_code":"1302","exempel":"31","item_check":"1","size":"10x15","size_color_ignore":"18x24,24x30,30x45"},{"MIGX_id":"4","color_image":"site/cveta/1303f.jpg","color_code":"1303","exempel":"36","item_check":"1","size":"10x15","size_color_ignore":"18x24,24x30,30x45"},{"MIGX_id":"5","color_image":"site/cveta/1300f.jpg","color_code":"1300","exempel":"18","item_check":"","size":"13x18"},{"MIGX_id":"6","color_image":"site/cveta/1301f.jpg","color_code":"1301","exempel":"27","item_check":"","size":"13x18"},{"MIGX_id":"7","color_image":"site/cveta/1302f.jpg","color_code":"1302","exempel":"32","item_check":"","size":"13x18"},{"MIGX_id":"8","color_image":"site/cveta/1303f.jpg","color_code":"1303","exempel":"37","item_check":"","size":"13x18"},{"MIGX_id":"9","color_image":"site/cveta/1300f.jpg","color_code":"1300","exempel":"19","item_check":"","size":"15x21"},{"MIGX_id":"10","color_image":"site/cveta/1301f.jpg","color_code":"1301","exempel":"28","item_check":"","size":"15x21"},{"MIGX_id":"11","color_image":"site/cveta/1302f.jpg","color_code":"1302","exempel":"33","item_check":"","size":"15x21"},{"MIGX_id":"12","color_image":"site/cveta/1303f.jpg","color_code":"1303","exempel":"38","item_check":"","size":"15x21"},{"MIGX_id":"39","color_image":"site/cveta/1301f.jpg","color_code":"1301","exempel":"439","item_check":"","size":"18x24"},{"MIGX_id":"13","color_image":"site/cveta/1300f.jpg","color_code":"1300","exempel":"20","item_check":"","size":"21x30"},{"MIGX_id":"15","color_image":"site/cveta/1301f.jpg","color_code":"1301","exempel":"29","item_check":"","size":"21x30"},{"MIGX_id":"17","color_image":"site/cveta/1302f.jpg","color_code":"1302","exempel":"34","item_check":"","size":"21x30"},{"MIGX_id":"19","color_image":"site/cveta/1303f.jpg","color_code":"1303","exempel":"39","item_check":"","size":"21x30"},{"MIGX_id":"34","color_image":"site/cveta/1301f.jpg","color_code":"1301","exempel":"429","item_check":"","size":"24x30"},{"MIGX_id":"14","color_image":"site/cveta/1300f.jpg","color_code":"1300","exempel":"21","item_check":"","size":"30x40"},{"MIGX_id":"16","color_image":"site/cveta/1301f.jpg","color_code":"1301","exempel":"30","item_check":"","size":"30x40"},{"MIGX_id":"18","color_image":"site/cveta/1302f.jpg","color_code":"1302","exempel":"35","item_check":"","size":"30x40"},{"MIGX_id":"20","color_image":"site/cveta/1303f.jpg","color_code":"1303","exempel":"41","item_check":"","size":"30x40"},{"MIGX_id":"43","color_image":"site/cveta/1301f.jpg","color_code":"1301","exempel":"443","item_check":"","size":"30x45"},{"MIGX_id":"44","color_image":"site/cveta/1300f.jpg","color_code":"1300","exempel":"543","item_check":"","size":"15х20","size_color_ignore":"18x24,24x30,30x45"}]
Вручную сотни товаров так заполнять гемморно, тем более сортировка не работает. Задумался напрямую вставить в БД всевозможные размеры, но тут этот MIGX_id":«44» — как он формируется?
Alex3
30 октября 2019, 14:08
modx.pro
899
0

Комментарии: 3

Евгений Webinmd
30 октября 2019, 17:40
0
Пример добавления значения в поле migx через api modx

<?php
$input = $resource->getTVValue('myMigx');
$res = $modx->fromJSON($input);
$count = count($res);
 
$new = array(
    'MIGX_id'       => $count + 1,
    'name'          => $scriptProperties['fields']['name'],
    'message'       => $scriptProperties['fields']['message'],
    'email'         => $scriptProperties['fields']['email'],
    'date'          => $scriptProperties['fields']['date'],
);
$res[] = $new;
 
if (!$resource->setTVValue('myMigx', $modx->toJson($res))) {
  $modx->log(modX::LOG_LEVEL_ERROR,'There was a problem saving your data!');
  return false;
}
  
return true;
    Alex3
    30 октября 2019, 18:55
    0
    чет все в модх сложно и не удобно :(

    короче я тупо везде один id написал через phpmyadmin — вроде работает
      Евгений Webinmd
      30 октября 2019, 19:56
      0
      работает, пока не будет необходимости отредактировать данные.
      MIGX_id формируется просто +1 к максимальному значению
    Авторизуйтесь или зарегистрируйтесь, чтобы оставлять комментарии.
    3