Created
August 28, 2019 09:24
-
-
Save 0test/2c897070bb07cab08b50c2aafe6631b8 to your computer and use it in GitHub Desktop.
Prepare editDocs and set multitv values
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 | |
$process = isset($process) ? $process : ''; | |
$mode = isset($mode) ? $mode : ''; | |
switch ($process) { | |
case 'import': | |
//обработчик импорта | |
switch ($mode) { | |
case 'upd': | |
//обновляем ресурс | |
$data['img'] = 'assets/images/products/' . $data['art'] . '/' . $data['art'] . '.jpg'; | |
if($data['size']){ | |
$tvValue = array( | |
'fieldValue' => [], | |
'fieldSettings' => array("autoincrement" => 1) | |
); | |
$s_arr = explode(",",trim($data['size'])); | |
if(count($s_arr)){ | |
foreach($s_arr as $one_size){ | |
$tvValue['fieldValue'][] = array( | |
"value" => trim($one_size) | |
); | |
} | |
$data['size'] = json_encode($tvValue, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES ); | |
$data['color'] = mb_convert_encoding($data['color'], 'utf-8', mb_detect_encoding($data['color'])); | |
} | |
} | |
break; | |
case 'new': | |
//добавляем новый ресурс | |
$data['img'] = 'assets/images/products/' . $data['art'] . '/' . $data['art'] . '.jpg'; | |
if($data['size']){ | |
$tvValue = array( | |
'fieldValue' => [], | |
'fieldSettings' => array("autoincrement" => 1) | |
); | |
$s_arr = explode(",",trim($data['size'])); | |
if(count($s_arr)){ | |
foreach($s_arr as $one_size){ | |
$tvValue['fieldValue'][] = array( | |
"value" => trim($one_size) | |
); | |
} | |
$data['size'] = json_encode($tvValue, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES ); | |
} | |
} | |
break; | |
default: | |
break; | |
} | |
break; | |
case 'export': | |
//обработчик экспорта | |
//$data['pagetitle'] = 'export ' . $data['pagetitle']; | |
break; | |
default: | |
break; | |
} | |
return $data; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment