예제 #1
0
 protected function saveCategoryMap($bitrixCategoryId, $iblockId, array $ebayCategoriesIds, $params = array())
 {
     $result = true;
     $catMapEntId = MapHelper::getCategoryEntityId($iblockId);
     foreach ($ebayCategoriesIds as $ebayCategoryId) {
         if (strlen(trim($ebayCategoryId)) <= 0) {
             continue;
         }
         $fields = array("ENTITY_ID" => $catMapEntId, "VALUE_INTERNAL" => $bitrixCategoryId);
         $dbRes = MapTable::getList(array('filter' => $fields));
         $fields["VALUE_EXTERNAL"] = $ebayCategoryId;
         if (!empty($params)) {
             $fields["PARAMS"] = $params;
         }
         if ($map = $dbRes->fetch()) {
             $res = MapTable::update($map['ID'], $fields);
         } else {
             $res = MapTable::add($fields);
         }
         $result = $result && $res->isSuccess();
     }
     return $result;
 }