本文整理汇总了PHP中CIBlockPropertyEnum::Update方法的典型用法代码示例。如果您正苦于以下问题:PHP CIBlockPropertyEnum::Update方法的具体用法?PHP CIBlockPropertyEnum::Update怎么用?PHP CIBlockPropertyEnum::Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIBlockPropertyEnum
的用法示例。
在下文中一共展示了CIBlockPropertyEnum::Update方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: UpdatePropertyList
public static function UpdatePropertyList($prop_id, $list)
{
foreach ($list as $id => $arEnum) {
$value = trim($arEnum["VALUE"], " \t\n\r");
if (strlen($value)) {
$dbEnum = CIBlockPropertyEnum::GetByID($id);
if (is_array($dbEnum)) {
$def = isset($arEnum["DEF"]) ? $arEnum["DEF"] : $dbEnum["DEF"];
$sort = intval($arEnum["SORT"]);
if ($dbEnum["VALUE"] != $value || $dbEnum["SORT"] != $sort || $dbEnum["DEF"] != $def) {
$dbEnum["VALUE"] = $value;
$dbEnum["SORT"] = $sort;
$dbEnum["DEF"] = $def;
unset($dbEnum["ID"]);
CIBlockPropertyEnum::Update($id, $dbEnum);
}
} else {
$arEnum["PROPERTY_ID"] = $prop_id;
CIBlockPropertyEnum::Add($arEnum);
}
} else {
CIBlockPropertyEnum::Delete($id);
}
}
}
示例2: CheckManufacturer
function CheckManufacturer($xml)
{
$propertyId = $this->PROPERTY_MAP["CML2_MANUFACTURER"];
$enumXmlId = $xml[$this->mess["IBLOCK_XML2_ID"]];
$enumName = $xml[$this->mess["IBLOCK_XML2_NAME"]];
$enumValue = CIBlockPropertyEnum::GetList(array(), array("PROPERTY_ID" => $propertyId, "XML_ID" => $enumXmlId));
$enum = $enumValue->Fetch();
if ($enum) {
if ($enum["VALUE"] !== $enumName) {
CIBlockPropertyEnum::Update($enum["ID"], array("VALUE" => $enumName));
}
return $enum["ID"];
} else {
return CIBlockPropertyEnum::Add(array("VALUE" => $enumName, "PROPERTY_ID" => $propertyId, "DEF" => "N", "XML_ID" => $enumXmlId));
}
}
示例3: Array
$PROP_ENUM_XML_ID = $xPropEnum->GetAttribute($nameUTF['ID']);
$PROP_ENUM_NAME = $xPropEnum->GetAttribute($nameUTF['Name']);
$PROP_ENUM_DEF = ($PROP_ENUM_XML_ID==$PROP_DEF?"Y":"N");
$arFields = Array(
"DEF"=>$PROP_ENUM_DEF,
"TMP_ID"=>$tmpid,
"VALUE"=>$PROP_ENUM_NAME,
"PROPERTY_ID"=>$PROP_ID,
"XML_ID"=>$PROP_ENUM_XML_ID
);
$res = CIBlockPropertyEnum::GetList(array(), Array("PROPERTY_ID"=>$PROP_ID, "XML_ID"=>$PROP_ENUM_XML_ID));
if($arr = $res->Fetch())
{
$PROP_ENUM_ID = $arr["ID"];
$pren->Update($PROP_ENUM_ID, $arFields);
}
else
{
$PROP_ENUM_ID = $pren->Add($arFields);
}
$arPropertiesEnum[$PROP_XML_ID][$PROP_ENUM_XML_ID] = $PROP_ENUM_ID;
}
}
}
if (function_exists("catalog_property_mutator_1c"))
catalog_property_mutator_1c();
$arGrTmp = array();
$groups = $xCatNode->select_nodes("/".$nameUTF['Category']);
示例4: ImportPropsFromXML
public static function ImportPropsFromXML($BID, $xmlPath, &$arOldNewID)
{
if (file_exists($xmlPath) && $BID && CModule::IncludeModule('iblock')) {
require_once $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/classes/general/xml.php';
$arExistProps = array();
$rsProp = CIBlockProperty::GetList(array(), array('IBLOCK_ID' => $BID));
while ($arProp = $rsProp->Fetch()) {
$arExistProps[$arProp['CODE']] = $arProp;
}
$arExistEnums = array();
$rsEnum = CIBlockPropertyEnum::GetList(array(), array('IBLOCK_ID' => $BID));
while ($arEnum = $rsEnum->Fetch()) {
$arExistEnums[$arEnum['PROPERTY_ID'] . '_' . $arEnum['XML_ID']] = $arEnum;
}
$arOldNewID = array();
$xml = new CDataXML();
$ep = new CIBlockProperty();
$en = new CIBlockPropertyEnum();
if ($xml->Load($xmlPath)) {
if ($node = $xml->SelectNodes('/asd_iblock_props/props/')) {
foreach ($node->children() as $child) {
$arProp = array_pop($child->__toArray());
$arFields = array('IBLOCK_ID' => $BID);
foreach ($arProp as $code => $v) {
$arFields[strtoupper($code)] = is_array($v[0]['#']['cdata-section']) ? $v[0]['#']['cdata-section'][0]['#'] : $v[0]['#'];
}
if (isset($arExistProps[$arFields['CODE']])) {
$arOldNewID[$arFields['OLD_ID']] = $arExistProps[$arFields['CODE']]['ID'];
$ep->Update($arExistProps[$arFields['CODE']]['ID'], $arFields);
} else {
$arOldNewID[$arFields['OLD_ID']] = $arFields['ID'] = $ep->Add($arFields);
$arExistProps[$arFields['CODE']] = $arFields;
}
}
}
if ($node = $xml->SelectNodes('/asd_iblock_props/enums/')) {
foreach ($node->children() as $child) {
$arProp = array_pop($child->__toArray());
$arFields = array('IBLOCK_ID' => $BID);
foreach ($arProp as $code => $v) {
$arFields[strtoupper($code)] = is_array($v[0]['#']['cdata-section']) ? $v[0]['#']['cdata-section'][0]['#'] : $v[0]['#'];
}
$arFields['PROPERTY_ID'] = $arExistProps[$arFields['PROPERTY_CODE']]['ID'];
if (isset($arExistEnums[$arFields['PROPERTY_ID'] . '_' . $arFields['XML_ID']])) {
$en->Update($arExistEnums[$arFields['PROPERTY_ID'] . '_' . $arFields['XML_ID']]['ID'], $arFields);
} else {
$en->Add($arFields);
}
}
}
}
}
}
示例5: process
/**
*
*/
public function process()
{
if ($this->processed) {
return;
}
$this->processed = true;
foreach ($this->generateData() as $k => $v) {
$this->data[$k] = $v;
}
$this->update();
$o = new \CIBlock();
$mesages = $this->messages();
$o->SetMessages($this->getId(), $mesages);
$fields = $this->fields();
$o->SetFields($this->getId(), $fields);
$props = $this->loadProperties();
$newProps = $this->properties();
foreach ($this->urlsProps() as $key => $data) {
$newProps[$key] = $data;
}
$o = new \CIBlockProperty();
foreach ($props as $prop => $data) {
if (!isset($newProps[$prop])) {
$o->Delete($data['ID']);
}
}
foreach ($newProps as $prop => $data) {
$data['CODE'] = $prop;
if ($data['PROPERTY_TYPE'] == 'E' || $data['PROPERTY_TYPE'] == 'G') {
if (!isset($data['LINK_IBLOCK_ID'])) {
if (isset($data['LINK_IBLOCK_CODE'])) {
$data['LINK_IBLOCK_ID'] = self::codeToId($data['LINK_IBLOCK_CODE']);
}
}
}
if (isset($props[$prop])) {
$id = $props[$prop]['ID'];
$o->Update($id, $data);
} else {
$data['IBLOCK_ID'] = $this->getId();
$id = $o->Add($data);
}
if ($data['PROPERTY_TYPE'] == 'L' && isset($data['ITEMS']) && is_array($data['ITEMS'])) {
$items = array();
$newItems = $data['ITEMS'];
$res = \CIBlockPropertyEnum::GetList(array(), array('PROPERTY_ID' => $id, 'CHECK_PERMISSIONS' => 'N'));
while ($row = $res->Fetch()) {
$iid = $row['ID'];
$eid = $row['EXTERNAL_ID'];
if (!isset($newItems[$eid])) {
\CIBlockPropertyEnum::Delete($iid);
} else {
$items[$eid] = $row;
}
}
$eo = new \CIBlockPropertyEnum();
foreach ($newItems as $eid => $edata) {
if (is_string($edata)) {
$edata = array('VALUE' => $edata);
}
$edata['PROPERTY_ID'] = $id;
$edata['EXTERNAL_ID'] = $eid;
$edata['XML_ID'] = $eid;
if (isset($items[$eid])) {
$eo->Update($items[$eid]['ID'], $edata);
} else {
$eo->Add($edata);
}
}
}
}
}