118 $photoSaveResults = array();
122 foreach ($data as $item)
125 if (!array_key_exists($this->params[
'keyPhotoBx'], $item) || empty($item[$this->params[
'keyPhotoBx']]))
131 $getServerParams = array(
"group_id" => str_replace(
"-",
"", $this->vkGroupId));
132 if ($this->type ==
'PRODUCT_MAIN_PHOTO')
134 $getServerParams += self::setUploadServerMainPhotoParams($item[$this->params[
'keyPhotoBx']]);
137 $uploadServer = $this->api->run($this->params[
'uploadServerMethod'], $getServerParams);
139 $this->logger->addLog(
"Get photo upload server", [
140 'PARAMS' => $getServerParams,
141 'RESULT' => $uploadServer,
143 $uploadServer = $uploadServer[
"upload_url"];
147 $this->logger->addLog(
"Upload photo HTTP before", array(
148 "UPLOAD_TYPE" => $this->type,
149 "ITEM" => array_key_exists(
"BX_ID", $item) ?
150 $item[
"BX_ID"] .
': ' . $item[
"NAME"] :
151 $item[
"SECTION_ID"] .
': ' . $item[
"TITLE"],
152 "PHOTO_BX_ID" => array_key_exists(
"PHOTO_MAIN_BX_ID",
153 $item) ? $item[
"PHOTO_MAIN_BX_ID"] : $item[
"PHOTO_BX_ID"],
154 "PHOTO_URL" => array_key_exists(
"PHOTO_MAIN_URL", $item) ? $item[
"PHOTO_MAIN_URL"] : $item[
"PHOTO_URL"],
155 "PHOTOS" => $item[
"PHOTOS"]
157 $uploadHttpResult = $this->uploadHttp($item, $uploadServer);
159 if($uploadHttpResult ===
false)
161 if(!$photoSaveResults[
'errors'])
163 $photoSaveResults[
'errors'] = [];
165 $photoSaveResults[
'errors'][] = $item[$this->params[
'keyReference']];
169 $savePhotoResult = $this->savePhoto($uploadHttpResult);
171 $photoSaveResults[$item[$this->params[
'keyReference']]] = array(
172 $this->params[
'keyReference'] => $item[$this->params[
'keyReference']],
173 $this->params[
'keyPhotoVk'] => $savePhotoResult[0][
"id"],
178 return $photoSaveResults;