51 $siteId = static::checkSiteId($siteId);
54 $res = self::getList(array(
'filter' => array(
'SITE_ID' => $siteId)));
55 while($item = $res->fetch())
56 $existed[$item[
'LOCATION_CODE']] =
true;
58 if(is_array($locationCodeList))
60 foreach($locationCodeList as $location)
62 if(!isset($existed[$location]))
64 $opRes = self::add(array(
66 'LOCATION_CODE' => $location[
'LOCATION_CODE'],
67 'SORT' => $location[
'SORT'],
69 if(!$opRes->isSuccess())
77 $GLOBALS[
'CACHE_MANAGER']->ClearByTag(
'sale-location-data');
83 public static function updateMultipleForOwner($siteId, $locationCodeList = array(), $behaviour = array(
'REMOVE_ABSENT' =>
true))
85 $siteId = static::checkSiteId($siteId);
87 if(!is_array($locationCodeList))
92 $locationCodeListTemp = array();
93 foreach($locationCodeList as $location)
95 $index[$location[
'LOCATION_CODE']] =
true;
96 $locationCodeListTemp[$location[
'LOCATION_CODE']] = $location;
98 $locationCodeList = $locationCodeListTemp;
100 $res = self::getList(array(
'filter' => array(
'SITE_ID' => $siteId)));
103 while($item = $res->Fetch())
105 if(!isset($index[$item[
'LOCATION_CODE']]))
106 $delete[$item[
'LOCATION_CODE']] =
true;
109 unset($index[$item[
'LOCATION_CODE']]);
110 $update[$item[
'LOCATION_CODE']] =
true;
114 if($behaviour[
'REMOVE_ABSENT'])
116 foreach($delete as $code => $void)
118 $res = self::delete(array(
'SITE_ID' => $siteId,
'LOCATION_CODE' => $code));
119 if(!$res->isSuccess())
124 foreach($update as $code => $void)
126 $res = self::update(array(
'SITE_ID' => $siteId,
'LOCATION_CODE' => $code), array(
'SORT' => $locationCodeList[$code][
'SORT']));
127 if(!$res->isSuccess())
131 foreach($index as $code => $void)
133 $res = self::add(array(
134 'SORT' => $locationCodeList[$code][
'SORT'],
135 'SITE_ID' => $siteId,
136 'LOCATION_CODE' => $code
138 if(!$res->isSuccess())
142 $GLOBALS[
'CACHE_MANAGER']->ClearByTag(
'sale-location-data');