Ejemplo n.º 1
0
 public static function properties($primary)
 {
     if (!$primary) {
         throw new ArgumentException('Не указан идентификатор инфоблока');
     }
     $cache = new \CPHPCache();
     $path = self::createPath(__METHOD__);
     $cacheId = md5($primary);
     if ($cache->InitCache(86400, $cacheId, $path)) {
         $props = $cache->GetVars();
     } else {
         $field = is_numeric($primary) ? 'IBLOCK_ID' : 'IBLOCK.CODE';
         $db = PropertyTable::query()->addFilter($field, $primary)->addSelect('*')->exec();
         $props = array();
         while ($prop = $db->fetch()) {
             $code = $prop['CODE'];
             if (isset($props[$code])) {
                 throw new \LogicException("В инфоблокe {$primary} свойство {$code} используется дважды");
             }
             if (strlen($code) === 0) {
                 throw new \LogicException("В инфоблоке {$primary} для свойства {$prop['NAME']} не задан символьный код");
             }
             $props[$code] = $prop;
         }
         if ($cache->StartDataCache()) {
             $cache->EndDataCache($props);
         }
     }
     return $props;
 }
Ejemplo n.º 2
0
 public static function getMap()
 {
     $arMap = parent::getMap();
     foreach (static::$arAlias as $code => $alias) {
         $arMap[] = new ExpressionField($alias, '%s', [$code], []);
     }
     return $arMap;
 }
 public function testExistsReferencesRegister()
 {
     Module::getInstance()->install();
     $dbRsRef = DbVersionReferencesTable::getList(array('filter' => array('GROUP' => ReferenceController::GROUP_IBLOCK)));
     $dbRsIblock = IblockTable::getList();
     $this->assertEquals($dbRsIblock->getSelectedRowsCount(), $dbRsRef->getSelectedRowsCount(), $this->errorMessage('number of links to the information block and the information block entries must match'));
     $dbRsRef = DbVersionReferencesTable::getList(array('filter' => array('GROUP' => ReferenceController::GROUP_IBLOCK_PROPERTY)));
     $dbRsProp = PropertyTable::getList();
     $this->assertEquals($dbRsProp->getSelectedRowsCount(), $dbRsRef->getSelectedRowsCount(), $this->errorMessage('number of links on the properties of information blocks and records must match'));
     $dbRsRef = DbVersionReferencesTable::getList(array('filter' => array('GROUP' => ReferenceController::GROUP_IBLOCK_SECTION)));
     $dbRsSection = SectionTable::getList();
     $this->assertEquals($dbRsSection->getSelectedRowsCount(), $dbRsRef->getSelectedRowsCount(), $this->errorMessage('number of links to information block sections and records must match'));
 }
 public function testReinitIblockReference()
 {
     $beforeApplyFix = array('iblocks' => IblockTable::getList()->getSelectedRowsCount(), 'properties' => PropertyTable::getList()->getSelectedRowsCount(), 'sections' => SectionTable::getList()->getSelectedRowsCount());
     $collector = Collector::createByFile(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . 'add_collection.json');
     $this->assertNotEmpty($collector->getFixes());
     Module::getInstance()->applyFixesList($collector->getFixes());
     $afterApplyFix = array('iblocks' => IblockTable::getList()->getSelectedRowsCount(), 'properties' => PropertyTable::getList()->getSelectedRowsCount(), 'sections' => SectionTable::getList()->getSelectedRowsCount());
     Module::getInstance()->rollbackLastChanges();
     $afterRollback = array('iblocks' => IblockTable::getList()->getSelectedRowsCount(), 'properties' => PropertyTable::getList()->getSelectedRowsCount(), 'sections' => SectionTable::getList()->getSelectedRowsCount());
     Module::getInstance()->applyFixesList($collector->getFixes());
     $afterRollbackApply = array('iblocks' => IblockTable::getList()->getSelectedRowsCount(), 'properties' => PropertyTable::getList()->getSelectedRowsCount(), 'sections' => SectionTable::getList()->getSelectedRowsCount());
     $this->assertEquals($beforeApplyFix['iblocks'], $afterApplyFix['iblocks'] - 1, $this->errorMessage('iblock not created after apply fix'));
     $this->assertEquals($beforeApplyFix['properties'], $afterApplyFix['properties'] - 2, $this->errorMessage('properties not created after apply fix'));
     $this->assertEquals($beforeApplyFix['sections'], $afterApplyFix['sections'] - 1, $this->errorMessage('sections not created after apply fix'));
     $this->assertEquals($beforeApplyFix['iblocks'], $afterRollback['iblocks'], $this->errorMessage('iblock not removed after rollback fix'));
     $this->assertEquals($beforeApplyFix['properties'], $afterRollback['properties'], $this->errorMessage('properties not removed after rollback fix'));
     $this->assertEquals($beforeApplyFix['sections'], $afterRollback['sections'], $this->errorMessage('sections not removed after rollback fix'));
     $this->assertEquals($afterRollback['iblocks'] + 1, $afterRollbackApply['iblocks'], $this->errorMessage('iblock not created after apply rollback fix'));
     $this->assertEquals($afterRollback['properties'] + 2, $afterRollbackApply['properties'], $this->errorMessage('properties not created after apply rollback fix'));
     $this->assertEquals($afterRollback['sections'] + 1, $afterRollbackApply['sections'], $this->errorMessage('sections not created after apply rollback fix'));
 }
Ejemplo n.º 5
0
 /**
  * @inheritdoc
  */
 public function create(ParameterDictionary $parameters)
 {
     $iblockId = (int) $parameters->get('ID');
     $queryBuilder = new Entity\Query(Iblock\IblockTable::getEntity());
     $iblockData = $queryBuilder->setSelect(array('ID', 'NAME'))->setFilter(array('ID' => $iblockId))->setOrder(array())->exec()->fetch();
     if (empty($iblockData)) {
         throw new BuilderException(sprintf('Not found iblock with id = %d', $iblockId));
     }
     // Get settings iblock
     $iblockDataFields = \CIBlock::GetArrayByID($iblockData['ID']);
     $queryBuilder = new Entity\Query(Iblock\PropertyTable::getEntity());
     $propertyResult = $queryBuilder->setSelect(array('*'))->setFilter(array('IBLOCK_ID' => $iblockData['ID']))->setOrder(array())->exec();
     $propertyList = array();
     while ($property = $propertyResult->fetch()) {
         if (!empty($property['USER_TYPE_SETTINGS'])) {
             $property['USER_TYPE_SETTINGS'] = ($unserialize = @unserialize($property['USER_TYPE_SETTINGS'])) === false ? $property['USER_TYPE_SETTINGS'] : $unserialize;
         }
         $propertyList[$property['CODE']] = $property;
     }
     $this->iblockProperty = $propertyList;
     $this->setElementValue();
     $this->setSectionValue();
     $this->setEnumValue();
     $sectionValueList = array();
     if (in_array($iblockData['ID'], $this->getListByType('G'))) {
         foreach ($this->iblockProperty as $field) {
             if ($field['PROPERTY_TYPE'] == 'G' && $field['LINK_IBLOCK_ID'] == $iblockData['ID']) {
                 $sectionValueList = isset($field['VALUE_LIST']) ? $field['VALUE_LIST'] : array();
                 break;
             }
         }
     } else {
         $queryBuilder = new Entity\Query(Iblock\SectionTable::getEntity());
         $sectionValueList = $queryBuilder->setSelect(array('ID', 'NAME'))->setFilter(array('IBLOCK_ID' => $iblockData['ID']))->setOrder(array())->exec()->fetchAll();
     }
     $upperLevel[] = array('ID' => 0, 'NAME' => GetMessage('IBLOCK_UPPER_LEVEL'));
     $sectionValueList = $upperLevel + $sectionValueList;
     return array('DATA' => $iblockData, 'DEFAULT_FIELDS' => $this->getDefaultFields($iblockDataFields, $sectionValueList), 'FIELDS' => $this->iblockProperty);
 }
 /**
  * Parses the filter, we describe the properties of the
  * filter type and description price
  *
  * @return $this
  */
 public function parse()
 {
     if (sizeof($this->filterList) <= 0) {
         return array();
     }
     $property = $price = array();
     foreach ($this->filterList as $key => $items) {
         foreach ($items as $filterQuery => $filterValue) {
             if (preg_match($this->pattern['property'], $filterQuery, $match)) {
                 $property[] = $match[2];
             } elseif (preg_match($this->pattern['price'], $filterQuery, $match)) {
                 $price[] = $match[2];
             }
             if (is_array($match)) {
                 unset($this->filterList[$key][$filterQuery]);
                 $this->filterList[$key][$match[1]] = $filterValue;
             }
         }
     }
     if (sizeof($property)) {
         $queryBuilder = new Entity\Query(Iblock\PropertyTable::getEntity());
         $propertyResult = $queryBuilder->setSelect(array('*'))->setFilter(array('ID' => $property))->exec();
         while ($property = $propertyResult->fetch()) {
             $key = sprintf('PROPERTY_%d', $property['ID']);
             $this->propertyList[$key] = $property;
         }
     }
     if (sizeof($price)) {
         $priceTypeResult = \CCatalogGroup::GetList(array('SORT' => 'ASC'), array('ID' => $price));
         while ($price = $priceTypeResult->Fetch()) {
             $key = sprintf('CATALOG_PRICE_%d', $price['ID']);
             $this->priceTypeList[$key] = $price;
         }
     }
     $this->getValueList();
     return $this;
 }
Ejemplo n.º 7
0
    unset($countQuery);
    $totalCount = (int) $totalCount['CNT'];
    if ($totalCount > 0) {
        $totalPages = ceil($totalCount / $navyParams['SIZEN']);
        if ($navyParams['PAGEN'] > $totalPages) {
            $navyParams['PAGEN'] = $totalPages;
        }
        $getListParams['limit'] = $navyParams['SIZEN'];
        $getListParams['offset'] = $navyParams['SIZEN'] * ($navyParams['PAGEN'] - 1);
    } else {
        $navyParams['PAGEN'] = 1;
        $getListParams['limit'] = $navyParams['SIZEN'];
        $getListParams['offset'] = 0;
    }
}
$propertyIterator = new CAdminResult(Iblock\PropertyTable::getList($getListParams), $sTableID);
if ($usePageNavigation) {
    $propertyIterator->NavStart($getListParams['limit'], $navyParams['SHOW_ALL'], $navyParams['PAGEN']);
    $propertyIterator->NavRecordCount = $totalCount;
    $propertyIterator->NavPageCount = $totalPages;
    $propertyIterator->NavPageNomer = $navyParams['PAGEN'];
} else {
    $propertyIterator->NavStart();
}
$lAdmin->NavText($propertyIterator->GetNavPrint(GetMessage("IBP_ADM_PAGER")));
while ($property = $propertyIterator->Fetch()) {
    $property['ID'] = (int) $property['ID'];
    $property['USER_TYPE'] = (string) $property['USER_TYPE'];
    if ($property['USER_TYPE'] != '') {
        $property['PROPERTY_TYPE'] .= ':' . $property['USER_TYPE'];
    }
Ejemplo n.º 8
0
			$arSProperty_LNS[$FIELD_NAME] = $arProperty_UF[$FIELD_NAME];
	}
	unset($arUserFields);
}

$offers = false;
$arProperty_Offers = array();
$arProperty_OffersWithoutFile = array();
if ($catalogIncluded && $iblockExists)
{
	$offers = CCatalogSKU::GetInfoByProductIBlock($arCurrentValues['IBLOCK_ID']);
	if (!empty($offers))
	{
		$propertyIterator = Iblock\PropertyTable::getList(array(
			'select' => array('ID', 'IBLOCK_ID', 'NAME', 'CODE', 'PROPERTY_TYPE', 'MULTIPLE', 'LINK_IBLOCK_ID', 'USER_TYPE'),
			'filter' => array('=IBLOCK_ID' => $offers['IBLOCK_ID'], '=ACTIVE' => 'Y', '!=ID' => $offers['SKU_PROPERTY_ID']),
			'order' => array('SORT' => 'ASC', 'NAME' => 'ASC')
		));
		while ($property = $propertyIterator->fetch())
		{
			$propertyCode = (string)$property['CODE'];
			if ($propertyCode == '')
				$propertyCode = $property['ID'];
			$propertyName = '['.$propertyCode.'] '.$property['NAME'];

			$arProperty_Offers[$propertyCode] = $propertyName;
			if ($property['PROPERTY_TYPE'] != Iblock\PropertyTable::TYPE_FILE)
				$arProperty_OffersWithoutFile[$propertyCode] = $propertyName;
		}
		unset($propertyCode, $propertyName, $property, $propertyIterator);
	}
Ejemplo n.º 9
0
 public function setFields(array $fields)
 {
     parent::setFields($fields);
     if (is_array($this->fields) && $this->iblock_id > 0) {
         $properties = array();
         $propertyList = \Bitrix\Iblock\PropertyTable::getList(array("select" => array("*"), "filter" => array("=IBLOCK_ID" => $this->iblock_id)));
         while ($row = $propertyList->fetch()) {
             if ($row["USER_TYPE_SETTINGS"]) {
                 $row["USER_TYPE_SETTINGS"] = unserialize($row["USER_TYPE_SETTINGS"]);
             }
             $properties[$row["ID"]] = $row;
             if ($row["CODE"] != "") {
                 $properties[$row["CODE"]] =& $properties[$row["ID"]];
             }
         }
         foreach ($fields as $propertyCode => $propertyValues) {
             if (is_array($propertyValues)) {
                 foreach ($propertyValues as $i => $propertyValue) {
                     if (is_array($propertyValue) && array_key_exists("VALUE", $propertyValue)) {
                         if ($propertyValue["VALUE"] != "") {
                             $propertyValues[$i] = $propertyValue["VALUE"];
                         } else {
                             unset($propertyValues[$i]);
                         }
                     }
                 }
             }
             if (isset($properties[$propertyCode])) {
                 $property = $properties[$propertyCode];
                 $fieldCode = strtolower($propertyCode);
                 if ($property["PROPERTY_TYPE"] === "L") {
                     if (is_numeric($propertyValues)) {
                         $value = new ElementPropertyEnum($propertyValues);
                     } elseif (is_array($propertyValues)) {
                         $value = array();
                         foreach ($propertyValues as $propertyValue) {
                             if (is_numeric($propertyValue)) {
                                 $value[] = new ElementPropertyEnum($propertyValue);
                             }
                         }
                     } else {
                         $value = $propertyValues;
                     }
                 } elseif ($property["PROPERTY_TYPE"] === "E") {
                     if ($propertyValues instanceof Element) {
                         $this->element_link_properties[$fieldCode] = $propertyValues;
                         $value = $propertyValues->getField("name");
                     } elseif (is_numeric($propertyValues)) {
                         $this->element_link_properties[$fieldCode] = $propertyValues;
                         $value = new ElementPropertyElement($propertyValues);
                     } else {
                         $value = $propertyValues;
                     }
                 } elseif ($property["PROPERTY_TYPE"] === "G") {
                     if ($propertyValues instanceof Section) {
                         $this->section_link_properties[$fieldCode] = $propertyValues;
                         $value = $propertyValues->getField("name");
                     } elseif (is_numeric($propertyValues)) {
                         $this->section_link_properties[$fieldCode] = $propertyValues;
                         $value = new ElementPropertySection($propertyValues);
                     } else {
                         $value = $propertyValues;
                     }
                 } else {
                     if (strlen($property["USER_TYPE"])) {
                         $value = new ElementPropertyUserField($propertyValues, $property);
                     } else {
                         $value = $propertyValues;
                     }
                 }
                 $this->fieldMap[$fieldCode] = $property["ID"];
                 $this->fieldMap[$property["ID"]] = $property["ID"];
                 if ($property["CODE"] != "") {
                     $this->fieldMap[strtolower($property["CODE"])] = $property["ID"];
                 }
                 $this->fields[$property["ID"]] = $value;
             }
         }
     }
 }
Ejemplo n.º 10
0
 /**
  * Returns list of recommended products for specific product.
  *
  * @param int $USER_ID							User id.
  * @param string $LID							Site id.
  * @param array $arFilterRecomendet				Recomendation filter.
  * @param string $recomMore						Get more.
  * @param int $cntProductDefault				Max count.
  * @return array
  */
 function GetRecommendetProduct($USER_ID, $LID, $arFilterRecomendet = array(), $recomMore = 'N', $cntProductDefault = 2)
 {
     $arRecomendetResult = array();
     if (CModule::IncludeModule('catalog') && !empty($arFilterRecomendet)) {
         $arRecomendet = array();
         if (!is_array($arFilterRecomendet)) {
             $arFilterRecomendet = array($arFilterRecomendet);
         }
         Main\Type\Collection::normalizeArrayValuesByInt($arFilterRecomendet);
         if (empty($arFilterRecomendet)) {
             return $arRecomendetResult;
         }
         $iblockRecommended = array();
         $productIterator = Iblock\ElementTable::getList(array('select' => array('ID', 'IBLOCK_ID'), 'filter' => array('@ID' => $arFilterRecomendet, '=ACTIVE' => 'Y')));
         while ($product = $productIterator->fetch()) {
             $product['ID'] = (int) $product['ID'];
             $product['IBLOCK_ID'] = (int) $product['IBLOCK_ID'];
             if (!isset($iblockRecommended[$product['IBLOCK_ID']])) {
                 $iblockRecommended[$product['IBLOCK_ID']] = array();
             }
             $iblockRecommended[$product['IBLOCK_ID']][] = $product['ID'];
         }
         unset($product, $productIterator);
         if (empty($iblockRecommended)) {
             return $arRecomendetResult;
         }
         $propertyList = array();
         $propertyIterator = Iblock\PropertyTable::getList(array('select' => array('ID', 'IBLOCK_ID'), 'filter' => array('@IBLOCK_ID' => array_keys($iblockRecommended), '=CODE' => 'RECOMMEND', '=PROPERTY_TYPE' => Iblock\PropertyTable::TYPE_ELEMENT)));
         while ($property = $propertyIterator->fetch()) {
             $property['ID'] = (int) $property['ID'];
             $property['IBLOCK_ID'] = (int) $property['IBLOCK_ID'];
             $propertyList[$property['IBLOCK_ID']] = $property['ID'];
         }
         unset($property, $propertyIterator);
         if (empty($propertyList)) {
             return $arRecomendetResult;
         }
         foreach ($propertyList as $iblockID => $propertyID) {
             $propertyValue = 'PROPERTY_' . $propertyID;
             $filter = array('ID' => $iblockRecommended[$iblockID], 'IBLOCK_ID' => $iblockID);
             $select = array('ID', 'IBLOCK_ID', $propertyValue);
             $propertyValue .= '_VALUE';
             $elementIterator = CIBlockElement::GetList(array(), $filter, false, false, $select);
             while ($element = $elementIterator->Fetch()) {
                 if (empty($element[$propertyValue])) {
                     continue;
                 }
                 if (is_array($element[$propertyValue])) {
                     foreach ($element[$propertyValue] as &$recId) {
                         $recId = (int) $recId;
                         if ($recId > 0) {
                             $arRecomendet[$recId] = true;
                         }
                     }
                     unset($recId);
                 } else {
                     $recId = (int) $element[$propertyValue];
                     if ($recId > 0) {
                         $arRecomendet[$recId] = true;
                     }
                 }
             }
         }
         unset($element, $elementIterator, $select, $filter, $propertyValue, $propertyID, $iblockID, $propertyList);
         if (!empty($arRecomendet)) {
             $arRecomendet = array_keys($arRecomendet);
             $arBuyerGroups = CUser::GetUserGroup($USER_ID);
             $arFilter = array("ID" => $arRecomendet, "ACTIVE" => "Y");
             $rsElement = CIBlockElement::GetList(array(), $arFilter, false, false, array("NAME", "ID", "LID", 'IBLOCK_ID', 'IBLOCK_SECTION_ID', "DETAIL_PICTURE", "PREVIEW_PICTURE", "DETAIL_PAGE_URL"));
             $currentVatMode = CCatalogProduct::getPriceVatIncludeMode();
             $currentUseDiscount = CCatalogProduct::getUseDiscount();
             CCatalogProduct::setUseDiscount(true);
             CCatalogProduct::setPriceVatIncludeMode(true);
             CCatalogProduct::setUsedCurrency(CSaleLang::GetLangCurrency($LID));
             $i = 0;
             while ($arElement = $rsElement->GetNext()) {
                 if (in_array($arElement["ID"], $arFilterRecomendet)) {
                     continue;
                 }
                 if ($recomMore == "N" && $i < $cntProductDefault || $recomMore == "Y") {
                     $arElement["MODULE"] = "catalog";
                     $arElement["PRODUCT_PROVIDER_CLASS"] = "CCatalogProductProvider";
                     $arElement["PRODUCT_ID"] = $arElement["ID"];
                     $arPrice = CCatalogProduct::GetOptimalPrice($arElement["ID"], 1, $arBuyerGroups, "N", array(), $LID, array());
                     $currentPrice = $arPrice['RESULT_PRICE']['DISCOUNT_PRICE'];
                     $arElement["PRICE"] = $currentPrice;
                     $arElement["CURRENCY"] = $arPrice["RESULT_PRICE"]["CURRENCY"];
                     $arElement["DISCOUNT_PRICE"] = $arPrice['RESULT_PRICE']['DISCOUNT'];
                     if ($arElement["IBLOCK_ID"] > 0 && $arElement["IBLOCK_SECTION_ID"] > 0) {
                         $arElement["EDIT_PAGE_URL"] = CIBlock::GetAdminElementEditLink($arElement["IBLOCK_ID"], $arElement["PRODUCT_ID"], array("find_section_section" => $arElement["IBLOCK_SECTION_ID"], 'WF' => 'Y'));
                     }
                     $arRecomendetResult[] = $arElement;
                     $i++;
                 }
             }
             CCatalogProduct::clearUsedCurrency();
             CCatalogProduct::setPriceVatIncludeMode($currentVatMode);
             CCatalogProduct::setUseDiscount($currentUseDiscount);
             unset($currentUseDiscount, $currentVatMode);
         }
     }
     return $arRecomendetResult;
 }
Ejemplo n.º 11
0
 function setIBlock($IBLOCK_ID, $propertyID = array())
 {
     $this->VERSION = CIBlockElement::GetIBVersion($IBLOCK_ID);
     if (!empty($propertyID)) {
         Collection::normalizeArrayValuesByInt($propertyID);
     }
     $this->arProperties = array();
     if (!empty($propertyID) || empty($propertyID) && !isset(self::$propertiesCache[$IBLOCK_ID])) {
         $propertyIterator = PropertyTable::getList(array('select' => array('ID', 'IBLOCK_ID', 'NAME', 'ACTIVE', 'SORT', 'CODE', 'DEFAULT_VALUE', 'PROPERTY_TYPE', 'MULTIPLE', 'LINK_IBLOCK_ID', 'VERSION', 'USER_TYPE', 'USER_TYPE_SETTINGS'), 'filter' => empty($propertyID) ? array('IBLOCK_ID' => $IBLOCK_ID) : array('ID' => $propertyID, 'IBLOCK_ID' => $IBLOCK_ID), 'order' => array('ID' => 'ASC')));
         while ($property = $propertyIterator->fetch()) {
             if ($property['USER_TYPE']) {
                 $userType = CIBlockProperty::GetUserType($property['USER_TYPE']);
                 if (isset($userType["ConvertFromDB"])) {
                     if (array_key_exists("DEFAULT_VALUE", $property)) {
                         $value = array("VALUE" => $property["DEFAULT_VALUE"], "DESCRIPTION" => "");
                         $value = call_user_func_array($userType["ConvertFromDB"], array($property, $value));
                         $property["DEFAULT_VALUE"] = $value["VALUE"];
                     }
                 }
             }
             if ($property['USER_TYPE_SETTINGS'] !== '' || $property['USER_TYPE_SETTINGS'] !== null) {
                 $property['USER_TYPE_SETTINGS'] = unserialize($property['USER_TYPE_SETTINGS']);
             }
             $this->arProperties[$property['ID']] = $property;
         }
         unset($property, $propertyIterator);
         if (empty($propertyID)) {
             self::$propertiesCache[$IBLOCK_ID] = $this->arProperties;
         }
     } else {
         $this->arProperties = self::$propertiesCache[$IBLOCK_ID];
     }
 }
Ejemplo n.º 12
0
     }
     if ($ID > 0) {
         $canWrite = CBPDocument::CanUserOperateDocument(CBPCanUserOperateOperation::WriteDocument, $USER->GetID(), array(MODULE_ID, ENTITY, $ID), array("AllUserGroups" => $arCurrentUserGroups, "DocumentStates" => $arDocumentStates));
         $canRead = CBPDocument::CanUserOperateDocument(CBPCanUserOperateOperation::ReadDocument, $USER->GetID(), array(MODULE_ID, ENTITY, $ID), array("AllUserGroups" => $arCurrentUserGroups, "DocumentStates" => $arDocumentStates));
     } else {
         $canWrite = CBPDocument::CanUserOperateDocumentType(CBPCanUserOperateOperation::WriteDocument, $USER->GetID(), array(MODULE_ID, ENTITY, DOCUMENT_TYPE), array("AllUserGroups" => $arCurrentUserGroups, "DocumentStates" => $arDocumentStates));
         $canRead = false;
     }
     if (!$canWrite && !$canRead) {
         $error = new _CIBlockError(1, "ACCESS_DENIED", GetMessage("IBLOCK_ACCESS_DENIED_STATUS"));
         break;
     }
 }
 //Find out files properties
 $arFileProps = array();
 $propertyIterator = Iblock\PropertyTable::getList(array('select' => array('ID'), 'filter' => array('=IBLOCK_ID' => $IBLOCK_ID, '=PROPERTY_TYPE' => Iblock\PropertyTable::TYPE_FILE, '=ACTIVE' => 'Y')));
 while ($property = $propertyIterator->fetch()) {
     $arFileProps[] = $property['ID'];
 }
 unset($property, $propertyIterator);
 //Assembly properties values from $_POST and $_FILES
 $PROP = array();
 if (isset($_POST['PROP'])) {
     $PROP = $_POST['PROP'];
 }
 //Recover some user defined properties
 if (is_array($PROP)) {
     foreach ($PROP as $k1 => $val1) {
         if (is_array($val1)) {
             foreach ($val1 as $k2 => $val2) {
                 $text_name = preg_replace("/([^a-z0-9])/is", "_", "PROP[" . $k1 . "][" . $k2 . "][VALUE][TEXT]");
Ejemplo n.º 13
0
if ($catalogIncluded) {
    $arSort = array_merge($arSort, CCatalogIBlockParameters::GetCatalogSortFields());
    $arPrice = CCatalogIBlockParameters::getPriceTypesList();
} else {
    $arPrice = $arProperty_N;
}
$arIBlock_LINK = array();
$iblockFilter = !empty($arCurrentValues['LINK_IBLOCK_TYPE']) ? array('TYPE' => $arCurrentValues['LINK_IBLOCK_TYPE'], 'ACTIVE' => 'Y') : array('ACTIVE' => 'Y');
$rsIblock = CIBlock::GetList(array('SORT' => 'ASC'), $iblockFilter);
while ($arr = $rsIblock->Fetch()) {
    $arIBlock_LINK[$arr['ID']] = '[' . $arr['ID'] . '] ' . $arr['NAME'];
}
unset($iblockFilter);
$arProperty_LINK = array();
if (!empty($arCurrentValues['LINK_IBLOCK_ID']) && (int) $arCurrentValues['LINK_IBLOCK_ID'] > 0) {
    $propertyIterator = Iblock\PropertyTable::getList(array('select' => array('ID', 'IBLOCK_ID', 'NAME', 'CODE', 'PROPERTY_TYPE', 'MULTIPLE', 'LINK_IBLOCK_ID', 'USER_TYPE'), 'filter' => array('=IBLOCK_ID' => $arCurrentValues['LINK_IBLOCK_ID'], '=PROPERTY_TYPE' => Iblock\PropertyTable::TYPE_ELEMENT, '=ACTIVE' => 'Y'), 'order' => array('SORT' => 'ASC', 'NAME' => 'ASC')));
    while ($property = $propertyIterator->fetch()) {
        $propertyCode = (string) $property['CODE'];
        if ($propertyCode == '') {
            $propertyCode = $property['ID'];
        }
        $arProperty_LINK[$propertyCode] = '[' . $propertyCode . '] ' . $property['NAME'];
    }
    unset($propertyCode, $property, $propertyIterator);
}
$arAscDesc = array("asc" => GetMessage("IBLOCK_SORT_ASC"), "desc" => GetMessage("IBLOCK_SORT_DESC"));
$arComponentParameters = array("GROUPS" => array("ACTION_SETTINGS" => array("NAME" => GetMessage('IBLOCK_ACTIONS')), "COMPARE" => array("NAME" => GetMessage("IBLOCK_COMPARE")), "PRICES" => array("NAME" => GetMessage("IBLOCK_PRICES")), "BASKET" => array("NAME" => GetMessage("IBLOCK_BASKET")), "LINK" => array("NAME" => GetMessage("IBLOCK_LINK"))), "PARAMETERS" => array("SEF_MODE" => array(), "SEF_RULE" => array("VALUES" => array("SECTION_ID" => array("TEXT" => GetMessage("IBLOCK_SECTION_ID"), "TEMPLATE" => "#SECTION_ID#", "PARAMETER_LINK" => "SECTION_ID", "PARAMETER_VALUE" => '={$_REQUEST["SECTION_ID"]}'), "SECTION_CODE" => array("TEXT" => GetMessage("IBLOCK_SECTION_CODE"), "TEMPLATE" => "#SECTION_CODE#", "PARAMETER_LINK" => "SECTION_CODE", "PARAMETER_VALUE" => '={$_REQUEST["SECTION_CODE"]}'), "SECTION_CODE_PATH" => array("TEXT" => GetMessage("CP_BCE_SECTION_CODE_PATH"), "TEMPLATE" => "#SECTION_CODE_PATH#", "PARAMETER_LINK" => "SECTION_CODE_PATH", "PARAMETER_VALUE" => '={$_REQUEST["SECTION_CODE_PATH"]}'), "ELEMENT_ID" => array("TEXT" => GetMessage("IBLOCK_ELEMENT_ID"), "TEMPLATE" => "#ELEMENT_ID#", "PARAMETER_LINK" => "ELEMENT_ID", "PARAMETER_VALUE" => '={$_REQUEST["ELEMENT_ID"]}'), "ELEMENT_CODE" => array("TEXT" => GetMessage("IBLOCK_ELEMENT_CODE"), "TEMPLATE" => "#ELEMENT_CODE#", "PARAMETER_LINK" => "ELEMENT_CODE", "PARAMETER_VALUE" => '={$_REQUEST["ELEMENT_CODE"]}'))), "IBLOCK_TYPE" => array("PARENT" => "BASE", "NAME" => GetMessage("IBLOCK_TYPE"), "TYPE" => "LIST", "VALUES" => $arIBlockType, "REFRESH" => "Y"), "IBLOCK_ID" => array("PARENT" => "BASE", "NAME" => GetMessage("IBLOCK_IBLOCK"), "TYPE" => "LIST", "ADDITIONAL_VALUES" => "Y", "VALUES" => $arIBlock, "REFRESH" => "Y"), "ELEMENT_ID" => array("PARENT" => "BASE", "NAME" => GetMessage("IBLOCK_ELEMENT_ID"), "TYPE" => "STRING", "DEFAULT" => '={$_REQUEST["ELEMENT_ID"]}'), "ELEMENT_CODE" => array("PARENT" => "BASE", "NAME" => GetMessage("IBLOCK_ELEMENT_CODE"), "TYPE" => "STRING", "DEFAULT" => ''), "SECTION_ID" => array("PARENT" => "BASE", "NAME" => GetMessage("IBLOCK_SECTION_ID"), "TYPE" => "STRING", "DEFAULT" => '={$_REQUEST["SECTION_ID"]}'), "SECTION_CODE" => array("PARENT" => "BASE", "NAME" => GetMessage("IBLOCK_SECTION_CODE"), "TYPE" => "STRING", "DEFAULT" => ''), "SECTION_URL" => CIBlockParameters::GetPathTemplateParam("SECTION", "SECTION_URL", GetMessage("IBLOCK_SECTION_URL"), "", "URL_TEMPLATES"), "DETAIL_URL" => CIBlockParameters::GetPathTemplateParam("DETAIL", "DETAIL_URL", GetMessage("IBLOCK_DETAIL_URL"), "", "URL_TEMPLATES"), "SECTION_ID_VARIABLE" => array("PARENT" => "URL_TEMPLATES", "NAME" => GetMessage("IBLOCK_SECTION_ID_VARIABLE"), "TYPE" => "STRING", "DEFAULT" => "SECTION_ID"), "CHECK_SECTION_ID_VARIABLE" => array("PARENT" => "URL_TEMPLATES", "NAME" => GetMessage("CP_BCE_CHECK_SECTION_ID_VARIABLE"), "TYPE" => "CHECKBOX", "DEFAULT" => "N"), "SET_TITLE" => array(), "SET_CANONICAL_URL" => array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("CP_BCE_SET_CANONICAL_URL"), "TYPE" => "CHECKBOX", "DEFAULT" => "N"), "SET_BROWSER_TITLE" => array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("CP_BCE_SET_BROWSER_TITLE"), "TYPE" => "CHECKBOX", "DEFAULT" => "Y", "REFRESH" => "Y"), "BROWSER_TITLE" => array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("CP_BCE_BROWSER_TITLE"), "TYPE" => "LIST", "MULTIPLE" => "N", "DEFAULT" => "-", "VALUES" => array_merge(array("-" => " ", "NAME" => GetMessage("IBLOCK_FIELD_NAME")), $arProperty_LS), "HIDDEN" => isset($arCurrentValues['SET_BROWSER_TITLE']) && $arCurrentValues['SET_BROWSER_TITLE'] == 'N' ? 'Y' : 'N'), "SET_META_KEYWORDS" => array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("CP_BCE_SET_META_KEYWORDS"), "TYPE" => "CHECKBOX", "DEFAULT" => "Y", "REFRESH" => "Y"), "META_KEYWORDS" => array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("T_IBLOCK_DESC_KEYWORDS"), "TYPE" => "LIST", "MULTIPLE" => "N", "DEFAULT" => "-", "VALUES" => array_merge(array("-" => " "), $arProperty_LS), "HIDDEN" => isset($arCurrentValues['SET_META_KEYWORDS']) && $arCurrentValues['SET_META_KEYWORDS'] == 'N' ? 'Y' : 'N'), "SET_META_DESCRIPTION" => array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("CP_BCE_SET_META_DESCRIPTION"), "TYPE" => "CHECKBOX", "DEFAULT" => "Y", "REFRESH" => "Y"), "META_DESCRIPTION" => array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("T_IBLOCK_DESC_DESCRIPTION"), "TYPE" => "LIST", "MULTIPLE" => "N", "DEFAULT" => "-", "VALUES" => array_merge(array("-" => " "), $arProperty_LS), "HIDDEN" => isset($arCurrentValues['SET_META_DESCRIPTION']) && $arCurrentValues['SET_META_DESCRIPTION'] == 'N' ? 'Y' : 'N'), "SET_LAST_MODIFIED" => array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("CP_BCE_SET_LAST_MODIFIED"), "TYPE" => "CHECKBOX", "DEFAULT" => "N"), "USE_MAIN_ELEMENT_SECTION" => array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("CP_BCE_USE_MAIN_ELEMENT_SECTION"), "TYPE" => "CHECKBOX", "DEFAULT" => "N"), "ADD_SECTIONS_CHAIN" => array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("CP_BCE_ADD_SECTIONS_CHAIN"), "TYPE" => "CHECKBOX", "DEFAULT" => "Y"), "ADD_ELEMENT_CHAIN" => array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("CP_BCE_ADD_ELEMENT_CHAIN"), "TYPE" => "CHECKBOX", "DEFAULT" => "N"), "PROPERTY_CODE" => array("PARENT" => "VISUAL", "NAME" => GetMessage("IBLOCK_PROPERTY"), "TYPE" => "LIST", "MULTIPLE" => "Y", "VALUES" => $arProperty, "SIZE" => count($arProperty) > 5 ? 8 : 3, "ADDITIONAL_VALUES" => "Y"), "OFFERS_FIELD_CODE" => CIBlockParameters::GetFieldCode(GetMessage("CP_BCE_OFFERS_FIELD_CODE"), "VISUAL"), "OFFERS_PROPERTY_CODE" => array("PARENT" => "VISUAL", "NAME" => GetMessage("CP_BCE_OFFERS_PROPERTY_CODE"), "TYPE" => "LIST", "MULTIPLE" => "Y", "VALUES" => $arProperty_Offers, "SIZE" => count($arProperty_Offers) > 5 ? 8 : 3, "ADDITIONAL_VALUES" => "Y"), "OFFERS_SORT_FIELD" => array("PARENT" => "VISUAL", "NAME" => GetMessage("CP_BCE_OFFERS_SORT_FIELD"), "TYPE" => "LIST", "VALUES" => $arSort, "ADDITIONAL_VALUES" => "Y", "DEFAULT" => "sort"), "OFFERS_SORT_ORDER" => array("PARENT" => "VISUAL", "NAME" => GetMessage("CP_BCE_OFFERS_SORT_ORDER"), "TYPE" => "LIST", "VALUES" => $arAscDesc, "DEFAULT" => "asc", "ADDITIONAL_VALUES" => "Y"), "OFFERS_SORT_FIELD2" => array("PARENT" => "VISUAL", "NAME" => GetMessage("CP_BCE_OFFERS_SORT_FIELD2"), "TYPE" => "LIST", "VALUES" => $arSort, "ADDITIONAL_VALUES" => "Y", "DEFAULT" => "id"), "OFFERS_SORT_ORDER2" => array("PARENT" => "VISUAL", "NAME" => GetMessage("CP_BCE_OFFERS_SORT_ORDER2"), "TYPE" => "LIST", "VALUES" => $arAscDesc, "DEFAULT" => "desc", "ADDITIONAL_VALUES" => "Y"), "OFFERS_LIMIT" => array("PARENT" => "VISUAL", "NAME" => GetMessage('CP_BCE_OFFERS_LIMIT'), "TYPE" => "STRING", "DEFAULT" => 0), "PRICE_CODE" => array("PARENT" => "PRICES", "NAME" => GetMessage("IBLOCK_PRICE_CODE"), "TYPE" => "LIST", "MULTIPLE" => "Y", "SIZE" => count($arPrice) > 5 ? 8 : 3, "VALUES" => $arPrice), "USE_PRICE_COUNT" => array("PARENT" => "PRICES", "NAME" => GetMessage("IBLOCK_USE_PRICE_COUNT"), "TYPE" => "CHECKBOX", "DEFAULT" => "N"), "SHOW_PRICE_COUNT" => array("PARENT" => "PRICES", "NAME" => GetMessage("IBLOCK_SHOW_PRICE_COUNT"), "TYPE" => "STRING", "DEFAULT" => "1"), "PRICE_VAT_INCLUDE" => array("PARENT" => "PRICES", "NAME" => GetMessage("IBLOCK_VAT_INCLUDE"), "TYPE" => "CHECKBOX", "DEFAULT" => "Y"), "PRICE_VAT_SHOW_VALUE" => array("PARENT" => "PRICES", "NAME" => GetMessage("IBLOCK_VAT_SHOW_VALUE"), "TYPE" => "CHECKBOX", "DEFAULT" => "N"), "BASKET_URL" => array("PARENT" => "BASKET", "NAME" => GetMessage("IBLOCK_BASKET_URL"), "TYPE" => "STRING", "DEFAULT" => "/personal/basket.php"), "ACTION_VARIABLE" => array("PARENT" => "ACTION_SETTINGS", "NAME" => GetMessage("IBLOCK_ACTION_VARIABLE"), "TYPE" => "STRING", "DEFAULT" => "action"), "PRODUCT_ID_VARIABLE" => array("PARENT" => "ACTION_SETTINGS", "NAME" => GetMessage("IBLOCK_PRODUCT_ID_VARIABLE"), "TYPE" => "STRING", "DEFAULT" => "id"), "USE_PRODUCT_QUANTITY" => array("PARENT" => "BASKET", "NAME" => GetMessage("CP_BCE_USE_PRODUCT_QUANTITY"), "TYPE" => "CHECKBOX", "DEFAULT" => "N", "REFRESH" => "Y"), "PRODUCT_QUANTITY_VARIABLE" => array("PARENT" => "BASKET", "NAME" => GetMessage("CP_BCE_PRODUCT_QUANTITY_VARIABLE"), "TYPE" => "STRING", "DEFAULT" => "quantity", "HIDDEN" => isset($arCurrentValues['USE_PRODUCT_QUANTITY']) && $arCurrentValues['USE_PRODUCT_QUANTITY'] == 'Y' ? 'N' : 'Y'), "ADD_PROPERTIES_TO_BASKET" => array("PARENT" => "BASKET", "NAME" => GetMessage("CP_BCE_ADD_PROPERTIES_TO_BASKET"), "TYPE" => "CHECKBOX", "DEFAULT" => "Y", "REFRESH" => "Y"), "PRODUCT_PROPS_VARIABLE" => array("PARENT" => "BASKET", "NAME" => GetMessage("CP_BCE_PRODUCT_PROPS_VARIABLE"), "TYPE" => "STRING", "DEFAULT" => "prop", "HIDDEN" => isset($arCurrentValues['ADD_PROPERTIES_TO_BASKET']) && $arCurrentValues['ADD_PROPERTIES_TO_BASKET'] == 'N' ? 'Y' : 'N'), "PARTIAL_PRODUCT_PROPERTIES" => array("PARENT" => "BASKET", "NAME" => GetMessage("CP_BCE_PARTIAL_PRODUCT_PROPERTIES"), "TYPE" => "CHECKBOX", "DEFAULT" => "N", "HIDDEN" => isset($arCurrentValues['ADD_PROPERTIES_TO_BASKET']) && $arCurrentValues['ADD_PROPERTIES_TO_BASKET'] == 'N' ? 'Y' : 'N'), "PRODUCT_PROPERTIES" => array("PARENT" => "BASKET", "NAME" => GetMessage("CP_BCE_PRODUCT_PROPERTIES"), "TYPE" => "LIST", "MULTIPLE" => "Y", "VALUES" => $arProperty_X, "SIZE" => count($arProperty_X) > 5 ? 8 : 3, "HIDDEN" => isset($arCurrentValues['ADD_PROPERTIES_TO_BASKET']) && $arCurrentValues['ADD_PROPERTIES_TO_BASKET'] == 'N' ? 'Y' : 'N'), "DISPLAY_COMPARE" => array("PARENT" => "COMPARE", "NAME" => GetMessage('CP_BCE_DISPLAY_COMPARE'), "TYPE" => "CHECKBOX", "DEFAULT" => "N", "REFRESH" => "Y"), "LINK_IBLOCK_TYPE" => array("PARENT" => "LINK", "NAME" => GetMessage("IBLOCK_LINK_IBLOCK_TYPE"), "TYPE" => "LIST", "ADDITIONAL_VALUES" => "Y", "VALUES" => $arIBlockType, "REFRESH" => "Y"), "LINK_IBLOCK_ID" => array("PARENT" => "LINK", "NAME" => GetMessage("IBLOCK_LINK_IBLOCK_ID"), "TYPE" => "LIST", "ADDITIONAL_VALUES" => "Y", "VALUES" => $arIBlock_LINK, "REFRESH" => "Y"), "LINK_PROPERTY_SID" => array("PARENT" => "LINK", "NAME" => GetMessage("IBLOCK_LINK_PROPERTY_SID"), "TYPE" => "LIST", "ADDITIONAL_VALUES" => "Y", "VALUES" => $arProperty_LINK), "LINK_ELEMENTS_URL" => array("PARENT" => "LINK", "NAME" => GetMessage("IBLOCK_LINK_ELEMENTS_URL"), "TYPE" => "STRING", "DEFAULT" => "link.php?PARENT_ELEMENT_ID=#ELEMENT_ID#"), "BACKGROUND_IMAGE" => array("PARENT" => "VISUAL", "NAME" => GetMessage("T_IBLOCK_BACKGROUND_IMAGE"), "TYPE" => "LIST", "MULTIPLE" => "N", "DEFAULT" => "-", "VALUES" => array_merge(array("-" => " "), $arProperty_F)), "CACHE_TIME" => array("DEFAULT" => 36000000), "CACHE_GROUPS" => array("PARENT" => "CACHE_SETTINGS", "NAME" => GetMessage("CP_BCE_CACHE_GROUPS"), "TYPE" => "CHECKBOX", "DEFAULT" => "Y"), "USE_ELEMENT_COUNTER" => array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage('CP_BCE_USE_ELEMENT_COUNTER'), "TYPE" => "CHECKBOX", "DEFAULT" => "Y"), "SHOW_DEACTIVATED" => array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage('CP_BCE_SHOW_DEACTIVATED'), "TYPE" => "CHECKBOX", "DEFAULT" => "N")));
if ($arCurrentValues["SEF_MODE"] == "Y") {
    $arComponentParameters["PARAMETERS"]["SECTION_CODE_PATH"] = array("NAME" => GetMessage("CP_BCE_SECTION_CODE_PATH"), "TYPE" => "STRING", "DEFAULT" => "");
}
if ($catalogIncluded) {
Ejemplo n.º 14
0
 private function getIblockProps($iblockID)
 {
     $arProps = [];
     $propsOb = \Bitrix\Iblock\PropertyTable::getList(['filter' => ['IBLOCK_ID' => $iblockID, 'ACTIVE' => 'Y'], 'select' => ['NAME', 'CODE', 'ID']]);
     while ($props = $propsOb->fetch()) {
         $arProps[$props['CODE']] = $props['ID'];
     }
     return $arProps;
 }
Ejemplo n.º 15
0
 protected function getVisibleColumns()
 {
     if (self::$iblockIncluded === null) {
         self::$iblockIncluded = Main\Loader::includeModule('iblock');
     }
     if (!self::$iblockIncluded) {
         return array();
     }
     $result = array();
     $arTmpColumns = array();
     $arColumnsOptions = static::loadVisibleColumns($this->idPrefix);
     if (is_array($arColumnsOptions) && isset($arColumnsOptions["columns"]) && strlen($arColumnsOptions["columns"]) > 0) {
         $arTmpColumns = explode(",", $arColumnsOptions["columns"]);
     }
     if (is_array($arTmpColumns) && !empty($arTmpColumns)) {
         $arTmpColumns = explode(",", $arColumnsOptions["columns"]);
         $iBlockProps = array();
         foreach ($arTmpColumns as $id => $columnCode) {
             if (substr($columnCode, 0, 9) == "PROPERTY_") {
                 $iBlockProps[] = substr($columnCode, 9);
             } else {
                 $result[$columnCode] = Loc::getMessage("SALE_ORDER_BASKET_SETTINGS_COL_" . $columnCode);
             }
         }
         $dbRes = \Bitrix\Iblock\PropertyTable::getList(array('filter' => array('=CODE' => $iBlockProps), 'select' => array('ID', 'NAME', 'CODE')));
         while ($arPropData = $dbRes->fetch()) {
             $result["PROPERTY_" . $arPropData['CODE']] = $arPropData["NAME"];
         }
     } else {
         $result = static::getDefaultVisibleColumns();
     }
     return $result;
 }
Ejemplo n.º 16
0
        if ($propertyCode == '') {
            $propertyCode = $property['ID'];
        }
        $propertyName = '[' . $propertyCode . '] ' . $property['NAME'];
        $arProperty[$propertyCode] = $propertyName;
        if ($property['PROPERTY_TYPE'] == Iblock\PropertyTable::TYPE_NUMBER) {
            $arProperty_N[$propertyCode] = $propertyName;
        }
    }
    unset($propertyCode, $propertyName, $property, $propertyIterator);
}
$arOffers = CIBlockPriceTools::GetOffersIBlock($arCurrentValues["IBLOCK_ID"]);
$OFFERS_IBLOCK_ID = is_array($arOffers) ? $arOffers["OFFERS_IBLOCK_ID"] : 0;
$arProperty_Offers = array();
if ($OFFERS_IBLOCK_ID) {
    $propertyIterator = Iblock\PropertyTable::getList(array('select' => array('ID', 'IBLOCK_ID', 'NAME', 'CODE', 'PROPERTY_TYPE'), 'filter' => array('=IBLOCK_ID' => $OFFERS_IBLOCK_ID, '=ACTIVE' => 'Y', '!=PROPERTY_TYPE' => Iblock\PropertyTable::TYPE_FILE), 'order' => array('SORT' => 'ASC', 'NAME' => 'ASC')));
    while ($property = $propertyIterator->fetch()) {
        $propertyCode = (string) $property['CODE'];
        if ($propertyCode == '') {
            $propertyCode = $property['ID'];
        }
        $propertyName = '[' . $propertyCode . '] ' . $property['NAME'];
        $arProperty_Offers[$propertyCode] = $propertyName;
    }
    unset($propertyCode, $propertyName, $property, $propertyIterator);
}
$arSort = CIBlockParameters::GetElementSortFields(array('SHOWS', 'SORT', 'TIMESTAMP_X', 'NAME', 'ID', 'ACTIVE_FROM', 'ACTIVE_TO'), array('KEY_LOWERCASE' => 'Y'));
$arPrice = array();
if ($boolCatalog) {
    $arSort = array_merge($arSort, CCatalogIBlockParameters::GetCatalogSortFields());
    $arPrice = CCatalogIBlockParameters::getPriceTypesList();
Ejemplo n.º 17
0
    /**
     * @return string
     * @throws \Bitrix\Main\ArgumentException
     */
    public function getForm()
    {
        /*
         * select iblock list
         */
        $iblockList = array();
        $iblockDb = IblockTable::getList(array('select' => array('ID', 'NAME')));
        while ($iblock = $iblockDb->fetch()) {
            $iblockList[] = $iblock;
        }
        if (!empty($iblockList)) {
            $iblockList = array_merge(array(array('ID' => '', 'NAME' => Loc::getMessage('sender_connector_iblock_select'))), $iblockList);
        } else {
            $iblockList = array_merge(array(array('ID' => '', 'NAME' => Loc::getMessage('sender_connector_iblock_empty'))), $iblockList);
        }
        /*
         * select properties from all iblocks
         */
        $propertyToIblock = array();
        $propertyList = array();
        $propertyList[''][] = array('ID' => '', 'NAME' => Loc::getMessage('sender_connector_iblock_select'));
        $propertyList['EMPTY'][] = array('ID' => '', 'NAME' => Loc::getMessage('sender_connector_iblock_prop_empty'));
        $iblockFieldsDb = PropertyTable::getList(array('select' => array('ID', 'NAME', 'IBLOCK_ID'), 'filter' => array('=PROPERTY_TYPE' => PropertyTable::TYPE_STRING)));
        while ($iblockFields = $iblockFieldsDb->fetch()) {
            // add default value
            if (!array_key_exists($iblockFields['IBLOCK_ID'], $propertyList)) {
                $propertyList[$iblockFields['IBLOCK_ID']][] = array('ID' => '', 'NAME' => Loc::getMessage('sender_connector_iblock_field_select'));
            }
            // add property
            $propertyList[$iblockFields['IBLOCK_ID']][] = array('ID' => $iblockFields['ID'], 'NAME' => $iblockFields['NAME']);
            // add property link to iblock
            $propertyToIblock[$iblockFields['ID']] = $iblockFields['IBLOCK_ID'];
        }
        /*
         * create html-control of iblock list
         */
        $iblockInput = '<select name="' . $this->getFieldName('IBLOCK') . '" id="' . $this->getFieldId('IBLOCK') . '" onChange="IblockSelect' . $this->getFieldId('IBLOCK') . '()">';
        foreach ($iblockList as $iblock) {
            $inputSelected = $iblock['ID'] == $this->getFieldValue('IBLOCK') ? 'selected' : '';
            $iblockInput .= '<option value="' . $iblock['ID'] . '" ' . $inputSelected . '>';
            $iblockInput .= htmlspecialcharsbx($iblock['NAME']);
            $iblockInput .= '</option>';
        }
        $iblockInput .= '</select>';
        /*
         * create html-control of properties list for name
         */
        $iblockPropertyNameInput = '<select name="' . $this->getFieldName('PROPERTY_NAME') . '" id="' . $this->getFieldId('PROPERTY_NAME') . '">';
        if (array_key_exists($this->getFieldValue('PROPERTY_NAME', 0), $propertyToIblock)) {
            $propSet = $propertyList[$propertyToIblock[$this->getFieldValue('PROPERTY_NAME', 0)]];
        } else {
            $propSet = $propertyList[''];
        }
        foreach ($propSet as $property) {
            $inputSelected = $property['ID'] == $this->getFieldValue('PROPERTY_NAME') ? 'selected' : '';
            $iblockPropertyNameInput .= '<option value="' . $property['ID'] . '" ' . $inputSelected . '>';
            $iblockPropertyNameInput .= htmlspecialcharsbx($property['NAME']);
            $iblockPropertyNameInput .= '</option>';
        }
        $iblockPropertyNameInput .= '</select>';
        /*
         *  create html-control of properties list for email
         */
        $iblockPropertyEmailInput = '<select name="' . $this->getFieldName('PROPERTY_EMAIL') . '" id="' . $this->getFieldId('PROPERTY_EMAIL') . '">';
        if (array_key_exists($this->getFieldValue('PROPERTY_EMAIL', 0), $propertyToIblock)) {
            $propSet = $propertyList[$propertyToIblock[$this->getFieldValue('PROPERTY_EMAIL', 0)]];
        } else {
            $propSet = $propertyList[''];
        }
        foreach ($propSet as $property) {
            $inputSelected = $property['ID'] == $this->getFieldValue('PROPERTY_EMAIL') ? 'selected' : '';
            $iblockPropertyEmailInput .= '<option value="' . $property['ID'] . '" ' . $inputSelected . '>';
            $iblockPropertyEmailInput .= htmlspecialcharsbx($property['NAME']);
            $iblockPropertyEmailInput .= '</option>';
        }
        $iblockPropertyEmailInput .= '</select>';
        $jsScript = "\n\t\t<script>\n\t\t\tfunction IblockSelect" . $this->getFieldId('IBLOCK') . "()\n\t\t\t{\n\t\t\t\tvar iblock = BX('" . $this->getFieldId('IBLOCK') . "');\n\t\t\t\tIblockPropertyAdd(iblock, BX('" . $this->getFieldId('PROPERTY_NAME') . "'));\n\t\t\t\tIblockPropertyAdd(iblock, BX('" . $this->getFieldId('PROPERTY_EMAIL') . "'));\n\t\t\t}\n\t\t\tfunction IblockPropertyAdd(iblock, iblockProperty)\n\t\t\t{\n\t\t\t\tif(iblockProperty.length>0)\n\t\t\t\t{\n\t\t\t\t\tfor (var j in iblockProperty.options)\n\t\t\t\t\t{\n\t\t\t\t\t\tiblockProperty.options.remove(j);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tvar propList = {};\n\t\t\t\tif(iblockProperties[iblock.value] && iblockProperties[iblock.value].length>0)\n\t\t\t\t\tpropList = iblockProperties[iblock.value];\n\t\t\t\telse\n\t\t\t\t\tpropList = iblockProperties['EMPTY'];\n\t\t\t\tfor(var i in propList)\n\t\t\t\t{\n\t\t\t\t\tvar optionName = propList[i]['NAME'];\n\t\t\t\t\tvar optionValue = propList[i]['ID'];\n\t\t\t\t\tiblockProperty.options.add(new Option(optionName, optionValue));\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tvar iblockProperties = " . \CUtil::PhpToJSObject($propertyList) . ";\n\t\t</script>\n\t\t";
        return '
			' . Loc::getMessage('sender_connector_iblock_required_settings') . '
			<br/><br/>
			<table>
				<tr>
					<td>' . Loc::getMessage('sender_connector_iblock_field_iblock') . '</td>
					<td>' . $iblockInput . '</td>
				</tr>
				<tr>
					<td>' . Loc::getMessage('sender_connector_iblock_field_name') . '</td>
					<td>' . $iblockPropertyNameInput . '</td>
				</tr>
				<tr>
					<td>' . Loc::getMessage('sender_connector_iblock_field_email') . '</td>
					<td>' . $iblockPropertyEmailInput . '</td>
				</tr>
			</table>
			' . $jsScript . '
		';
    }
Ejemplo n.º 18
0
if (!Loader::includeModule('sale')) {
    return;
}
$arColumns = array("NAME" => GetMessage("SBB_BNAME"), "DISCOUNT" => GetMessage("SBB_BDISCOUNT"), "WEIGHT" => GetMessage("SBB_BWEIGHT"), "PROPS" => GetMessage("SBB_BPROPS"), "DELETE" => GetMessage("SBB_BDELETE"), "DELAY" => GetMessage("SBB_BDELAY"), "TYPE" => GetMessage("SBB_BTYPE"), "PRICE" => GetMessage("SBB_BPRICE"), "QUANTITY" => GetMessage("SBB_BQUANTITY"), "SUM" => GetMessage("SBB_BSUM"));
if (Loader::includeModule('catalog')) {
    $arIblockIDs = array();
    $arIblockNames = array();
    $catalogIterator = Catalog\CatalogIblockTable::getList(array('select' => array('IBLOCK_ID', 'NAME' => 'IBLOCK.NAME'), 'order' => array('IBLOCK_ID' => 'ASC')));
    while ($catalog = $catalogIterator->fetch()) {
        $catalog['IBLOCK_ID'] = (int) $catalog['IBLOCK_ID'];
        $arIblockIDs[] = $catalog['IBLOCK_ID'];
        $arIblockNames[$catalog['IBLOCK_ID']] = $catalog['NAME'];
    }
    unset($catalog, $catalogIterator);
    $arProps = array();
    $propertyIterator = Iblock\PropertyTable::getList(array('select' => array('ID', 'CODE', 'NAME', 'IBLOCK_ID'), 'filter' => array('@IBLOCK_ID' => $arIblockIDs, 'ACTIVE' => 'Y', '!XML_ID' => CIBlockPropertyTools::XML_SKU_LINK), 'order' => array('IBLOCK_ID' => 'ASC', 'SORT' => 'ASC', 'ID' => 'ASC')));
    while ($property = $propertyIterator->fetch()) {
        $property['ID'] = (int) $property['ID'];
        $property['IBLOCK_ID'] = (int) $property['IBLOCK_ID'];
        $property['CODE'] = (string) $property['CODE'];
        if ($property['CODE'] == '') {
            $property['CODE'] = $property['ID'];
        }
        if (!isset($arProps[$property['CODE']])) {
            $arProps[$property['CODE']] = array('CODE' => $property['CODE'], 'TITLE' => $property['NAME'] . ' [' . $property['CODE'] . ']', 'ID' => array($property['ID']), 'IBLOCK_ID' => array($property['IBLOCK_ID'] => $property['IBLOCK_ID']), 'IBLOCK_TITLE' => array($property['IBLOCK_ID'] => $arIblockNames[$property['IBLOCK_ID']]), 'COUNT' => 1);
        } else {
            $arProps[$property['CODE']]['ID'][] = $property['ID'];
            $arProps[$property['CODE']]['IBLOCK_ID'][$property['IBLOCK_ID']] = $property['IBLOCK_ID'];
            if ($arProps[$property['CODE']]['COUNT'] < 5) {
                $arProps[$property['CODE']]['IBLOCK_TITLE'][$property['IBLOCK_ID']] = $arIblockNames[$property['IBLOCK_ID']];
            }
 public function testDelete()
 {
     $this->_applyFixtures(self::FIXTURE_TYPE_SECTION_DELETE);
     $rsSection = SectionTable::getList(array('filter' => array('=IBLOCK_ID' => $this->_processIblockId)));
     $this->assertEmpty($rsSection->getSelectedRowsCount(), $this->errorMessage('section should not be'));
     $this->_applyFixtures(self::FIXTURE_TYPE_PROPERTY_DELETE);
     $rsProps = PropertyTable::getList(array('filter' => array('=IBLOCK_ID' => $this->_processIblockId)));
     $this->assertEquals($rsProps->getSelectedRowsCount(), 1, $this->errorMessage('in the information block is only one property'));
     $dbList = \CIBlock::GetList();
     $ibCountBefore = $dbList->SelectedRowsCount();
     $this->_applyFixtures(self::FIXTURE_TYPE_IBLOCK_DELETE);
     $dbList = \CIBlock::GetList();
     $ibCountAfter = $dbList->SelectedRowsCount();
     $this->assertNotEquals($ibCountBefore, $ibCountAfter, $this->errorMessage('iblock not been deleted'));
     $arIblock = IblockTable::getList(array('filter' => array('=ID' => $this->_processIblockId)))->fetch();
     $this->assertEmpty($arIblock, $this->errorMessage('iblock exists'));
 }
Ejemplo n.º 20
0
                     }
                 }
             }
         }
     }
 }
 if ($blogExist) {
     if ($arParams['BLOG_FROM_AJAX'] === 'N') {
         if ($blog['EMAIL_NOTIFY'] != $arParams['EMAIL_NOTIFY']) {
             CBlog::Update($blogID, array('EMAIL_NOTIFY' => $arParams['EMAIL_NOTIFY']));
         }
     }
 }
 if ($blogID > 0) {
     $arResult['BLOG_DATA']['BLOG_ID'] = $blogID;
     $propertyIterator = Iblock\PropertyTable::getList(array('select' => array('ID', 'CODE'), 'filter' => array('=IBLOCK_ID' => $arParams['IBLOCK_ID'], '=PROPERTY_TYPE' => Iblock\PropertyTable::TYPE_NUMBER, '=MULTIPLE' => 'N', '=CODE' => array(CIBlockPropertyTools::CODE_BLOG_POST, CIBlockPropertyTools::CODE_BLOG_COMMENTS_COUNT))));
     while ($propIBlock = $propertyIterator->fetch()) {
         if ($propIBlock['CODE'] == CIBlockPropertyTools::CODE_BLOG_POST) {
             $propBlogPostID = (int) $propIBlock['ID'];
         } elseif ($propIBlock['CODE'] == CIBlockPropertyTools::CODE_BLOG_COMMENTS_COUNT) {
             $propBlogCommentsCountID = (int) $propIBlock['ID'];
         }
     }
     unset($propIBlock, $propertyIterator);
     if (($propBlogPostID == 0 || $propBlogCommentsCountID == 0) && $arParams['BLOG_FROM_AJAX'] === 'N') {
         if ($propBlogPostID == 0) {
             $propBlogPostID = (int) CIBlockPropertyTools::createProperty($arParams['IBLOCK_ID'], CIBlockPropertyTools::CODE_BLOG_POST);
             if ($propBlogPostID == 0) {
                 $arResult['ERRORS'] = array_merge($arResult['ERRORS'], CIBlockPropertyTools::getErrors());
                 CIBlockPropertyTools::clearErrors();
             }
Ejemplo n.º 21
0
    return;
}
$catalogIncluded = Loader::includeModule('catalog');
$iblockExists = !empty($arCurrentValues['IBLOCK_ID']) && (int) $arCurrentValues['IBLOCK_ID'] > 0;
$arIBlockType = CIBlockParameters::GetIBlockTypes();
$arIBlock = array();
$iblockFilter = !empty($arCurrentValues['IBLOCK_TYPE']) ? array('TYPE' => $arCurrentValues['IBLOCK_TYPE'], 'ACTIVE' => 'Y') : array('ACTIVE' => 'Y');
$rsIBlock = CIBlock::GetList(array('SORT' => 'ASC'), $iblockFilter);
while ($arr = $rsIBlock->Fetch()) {
    $arIBlock[$arr['ID']] = '[' . $arr['ID'] . '] ' . $arr['NAME'];
}
unset($arr, $rsIBlock, $iblockFilter);
$arProperty = array();
$arProperty_N = array();
if ($iblockExists) {
    $propertyIterator = Iblock\PropertyTable::getList(array('select' => array('ID', 'IBLOCK_ID', 'NAME', 'CODE', 'PROPERTY_TYPE'), 'filter' => array('IBLOCK_ID' => $arCurrentValues['IBLOCK_ID'], '=ACTIVE' => 'Y'), 'order' => array('SORT' => 'ASC', 'NAME' => 'ASC')));
    while ($property = $propertyIterator->fetch()) {
        $propertyCode = (string) $property['CODE'];
        if ($propertyCode == '') {
            $propertyCode = $property['ID'];
        }
        $propertyName = '[' . $propertyCode . '] ' . $property['NAME'];
        if ($property['PROPERTY_TYPE'] != Iblock\PropertyTable::TYPE_FILE) {
            $arProperty[$propertyCode] = $propertyName;
        }
        if ($property['PROPERTY_TYPE'] == Iblock\PropertyTable::TYPE_NUMBER) {
            $arProperty_N[$propertyCode] = $propertyName;
        }
    }
    unset($propertyCode, $propertyName, $property, $propertyIterator);
}
Ejemplo n.º 22
0
 /**
  * @after testDelete
  */
 public function testRollbackDelete()
 {
     /** @var $list AppliedChangesLogModel[] */
     $list = AppliedChangesLogModel::find(array('limit' => 3, 'order' => array('id' => 'DESC')));
     $this->assertCount($list, 3, $this->errorMessage('should be in an amount of writable', array(':count' => 3)));
     foreach ($list as $lItem) {
         $this->assertTrue($lItem->processName == DeleteProcess::className(), $this->errorMessage('logging process should be - Disposal'));
     }
     $rsIblock = \CIBlock::getList();
     $countIbBefore = $rsIblock->SelectedRowsCount();
     $iblocksBefore = array();
     while ($arIb = $rsIblock->Fetch()) {
         $iblocksBefore[] = $arIb['ID'];
     }
     Module::getInstance()->rollbackByLogs($list ?: array());
     $rsIblock = \CIBlock::getList();
     $countIbAfter = $rsIblock->SelectedRowsCount();
     $iblocksAfter = array();
     while ($arIb = $rsIblock->Fetch()) {
         $iblocksAfter[] = $arIb['ID'];
     }
     $rebuildIblockId = array_diff($iblocksAfter, $iblocksBefore);
     $rebuildIblockId = array_shift($rebuildIblockId);
     $this->assertEquals($countIbAfter, $countIbBefore + 1, $this->errorMessage('information block data to be restored'));
     $this->assertEquals($rebuildIblockId, $this->_iblockId, $this->errorMessage('iblock restored identifier changed'));
     $rsProp = PropertyTable::getList(array('filter' => array('=IBLOCK_ID' => $rebuildIblockId)));
     $this->assertTrue($rsProp->getSelectedRowsCount() > 0, $this->errorMessage('must present properties of reduced information iblock'), array(':iblockId' => $rebuildIblockId));
     $rsSections = SectionTable::getList(array('filter' => array('=IBLOCK_ID' => $rebuildIblockId)));
     $this->assertTrue($rsSections->getSelectedRowsCount() > 0, $this->errorMessage('must present sections of reduced information iblock', array(':iblockId' => $rebuildIblockId)));
 }
Ejemplo n.º 23
0
 /**
  * Validate and modify exist property.
  *
  * @param string $propertyCode			Property code.
  * @param array $property				Current property data.
  * @return bool
  * @throws Exception
  */
 protected static function validateExistProperty($propertyCode, $property)
 {
     $result = true;
     switch ($propertyCode) {
         case self::CODE_SKU_LINK:
             $fields = array();
             if ($property['USER_TYPE'] != self::USER_TYPE_SKU_LINK) {
                 $fields['USER_TYPE'] = self::USER_TYPE_SKU_LINK;
             }
             if ($property['XML_ID'] != self::XML_SKU_LINK) {
                 $fields['XML_ID'] = self::XML_SKU_LINK;
             }
             if (!empty($fields)) {
                 $propertyResult = Iblock\PropertyTable::update($property['ID'], $fields);
                 if (!$propertyResult->isSuccess()) {
                     self::$errors = $propertyResult->getErrorMessages();
                     $result = false;
                 }
                 unset($propertyResult);
             }
             unset($fields);
             break;
     }
     return $result;
 }
Ejemplo n.º 24
0
\Bitrix\Main\Loader::includeModule('iblock');
CJSCore::init('jquery');
// подключим языковой файл
Loc::loadMessages(__FILE__);
$aTabs = [["DIV" => "edit1", "TAB" => "Основное", "ICON" => "main_user_edit", "TITLE" => "Настройки"]];
$tabControl = new CAdminTabControl("tabControl", $aTabs);
$ID = intval($ID);
// идентификатор редактируемой записи
$message = null;
// сообщение об ошибке
$bVarsFromForm = false;
// флаг "Данные получены с формы", обозначающий, что выводимые данные получены с формы, а не из БД.
$iblockID = COption::GetOptionInt(ADMIN_MODULE_NAME, 'IBLOCK_ID');
if ($iblockID) {
    $arProps = [];
    $propsOb = \Bitrix\Iblock\PropertyTable::getList(['filter' => ['IBLOCK_ID' => $iblockID, 'ACTIVE' => 'Y'], 'select' => ['NAME', 'CODE']]);
    while ($props = $propsOb->fetch()) {
        $arProps[$props['CODE']] = $props['NAME'];
    }
    // ******************************************************************** //
    //                ОБРАБОТКА ИЗМЕНЕНИЙ ФОРМЫ                             //
    // ******************************************************************** //
    if ($arProps) {
        if ($REQUEST_METHOD == "POST" && ($save != "" || $apply != "") && check_bitrix_sessid()) {
            // обработка данных формы
            $arFields = ["LOTINFO_FIELD" => $LOTINFO_FIELD, "PROP_ID" => $PROP_ID, "FIELD_ID" => $FIELD_ID];
            // сохранение данных
            if ($ID > 0) {
                $res = LotinfoFieldsToPropsTable::update($ID, $arFields);
            } else {
                $res = LotinfoFieldsToPropsTable::add($arFields);
            $message = new CAdminMessage($error_message);
            break;
        }
        $bVarsFromForm = true;
    }
}
// ******************************************************************** //
//                ВЫБОРКА И ПОДГОТОВКА ДАННЫХ ФОРМЫ                     //
// ******************************************************************** //
$allProperties = [];
// выборка данных
if ($ID > 0) {
    $seoProperty = \Xpage\SeoFilter\PropertyTable::getById($ID)->fetch();
    $APPLICATION->SetTitle("Edit {$seoProperty['ID']}");
}
$obProperties = \Bitrix\Iblock\PropertyTable::getList(['select' => ['ID', 'NAME'], 'filter' => ['IBLOCK_ID' => \Bitrix\Main\Config\Option::get('xpage.seofilter', 'IBLOCK', 1), 'SECTION_PROPERTY.SMART_FILTER' => 'Y', 'PROPERTY_TYPE' => \Bitrix\Iblock\PropertyTable::TYPE_LIST], 'runtime' => [new Bitrix\Main\Entity\ReferenceField('SECTION_PROPERTY', 'Bitrix\\Iblock\\SectionProperty', ['this.ID' => 'ref.PROPERTY_ID'], ['join_type' => 'LEFT'])]]);
while ($arProperty = $obProperties->fetch()) {
    $allProperties[] = $arProperty;
}
// ******************************************************************** //
//                ВЫВОД ФОРМЫ                                           //
// ******************************************************************** //
// не забудем разделить подготовку данных и вывод
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php";
// конфигурация административного меню
$aMenu = [["TEXT" => "Список", "TITLE" => "Список", "LINK" => "seofilter_property.php", "ICON" => "btn_list"], ["TEXT" => "Удалить", "TITLE" => "Удалить", "LINK" => "javascript:if(confirm('" . "Да, прошу вас" . "')) window.location='/bitrix/admin/seofilter_property.php?ID=" . $ID . "&action=delete&lang=" . LANGUAGE_ID . "&" . bitrix_sessid_get() . "';", "ICON" => "btn_delete"]];
// создание экземпляра класса административного меню
$context = new CAdminContextMenu($aMenu);
// вывод административного меню
$context->Show();
?>
Ejemplo n.º 26
0
	public static function getTreeProperties($skuInfo, $propertiesCodes, $defaultFields = array())
	{
		$requireFields = array(
			'ID',
			'UF_XML_ID',
			'UF_NAME',
		);

		$result = array();
		if (empty($skuInfo))
			return $result;
		if (!is_array($skuInfo))
		{
			$skuInfo = (int)$skuInfo;
			if ($skuInfo <= 0)
				return $result;
			if (self::$catalogIncluded === null)
				self::$catalogIncluded = Loader::includeModule('catalog');
			if (!self::$catalogIncluded)
				return $result;
			$skuInfo = CCatalogSKU::GetInfoByProductIBlock($skuInfo);
			if (empty($skuInfo))
				return $result;
		}
		if (empty($propertiesCodes) || !is_array($propertiesCodes))
			return $result;

		$showMode = '';

		$propertyIterator = PropertyTable::getList(array(
			'select' => array(
				'ID', 'IBLOCK_ID', 'CODE', 'NAME', 'SORT', 'LINK_IBLOCK_ID', 'PROPERTY_TYPE', 'USER_TYPE', 'USER_TYPE_SETTINGS'
			),
			'filter' => array(
				'IBLOCK_ID' => $skuInfo['IBLOCK_ID'],
				'PROPERTY_TYPE' => array(
					PropertyTable::TYPE_LIST,
					PropertyTable::TYPE_ELEMENT,
					PropertyTable::TYPE_STRING
				),
				'ACTIVE' => 'Y', 'MULTIPLE' => 'N'
			),
			'order' => array(
				'SORT' => 'ASC', 'ID' => 'ASC'
			)
		));
		while ($propInfo = $propertyIterator->fetch())
		{
			$propInfo['ID'] = (int)$propInfo['ID'];
			if ($propInfo['ID'] == $skuInfo['SKU_PROPERTY_ID'])
				continue;
			$propInfo['CODE'] = (string)$propInfo['CODE'];
			if ($propInfo['CODE'] === '')
				$propInfo['CODE'] = $propInfo['ID'];
			if (!in_array($propInfo['CODE'], $propertiesCodes))
				continue;
			$propInfo['SORT'] = (int)$propInfo['SORT'];
			$propInfo['USER_TYPE'] = (string)$propInfo['USER_TYPE'];
			if ($propInfo['PROPERTY_TYPE'] == PropertyTable::TYPE_STRING)
			{
				if ('directory' != $propInfo['USER_TYPE'])
					continue;
				$propInfo['USER_TYPE_SETTINGS'] = (string)$propInfo['USER_TYPE_SETTINGS'];
				if ($propInfo['USER_TYPE_SETTINGS'] == '')
					continue;
				$propInfo['USER_TYPE_SETTINGS'] = unserialize($propInfo['USER_TYPE_SETTINGS']);
				if (!isset($propInfo['USER_TYPE_SETTINGS']['TABLE_NAME']) || empty($propInfo['USER_TYPE_SETTINGS']['TABLE_NAME']))
					continue;
				if (self::$highLoadInclude === null)
					self::$highLoadInclude = Loader::includeModule('highloadblock');
				if (!self::$highLoadInclude)
					continue;

				$highBlock = HighloadBlockTable::getList(array(
					'filter' => array('TABLE_NAME' => $propInfo['USER_TYPE_SETTINGS']['TABLE_NAME'])
				))->fetch();
				if (!isset($highBlock['ID']))
					continue;

				$entity = HighloadBlockTable::compileEntity($highBlock);
				$entityDataClass = $entity->getDataClass();
				$fieldsList = $entityDataClass::getEntity()->getFields();
				if (empty($fieldsList))
					continue;

				$flag = true;
				foreach ($requireFields as &$fieldCode)
				{
					if (!isset($fieldsList[$fieldCode]) || empty($fieldsList[$fieldCode]))
					{
						$flag = false;
						break;
					}
				}
				unset($fieldCode);
				if (!$flag)
					continue;
				$propInfo['USER_TYPE_SETTINGS']['FIELDS_MAP'] = $fieldsList;
				$propInfo['USER_TYPE_SETTINGS']['ENTITY'] = $entity;
			}
			switch ($propInfo['PROPERTY_TYPE'])
			{
				case PropertyTable::TYPE_ELEMENT:
					$showMode = 'PICT';
					break;
				case PropertyTable::TYPE_LIST:
					$showMode = 'TEXT';
					break;
				case PropertyTable::TYPE_STRING:
					$showMode = (isset($fieldsList['UF_FILE']) ? 'PICT' : 'TEXT');
					break;
			}
			$treeProp = array(
				'ID' => $propInfo['ID'],
				'CODE' => $propInfo['CODE'],
				'NAME' => $propInfo['NAME'],
				'SORT' => $propInfo['SORT'],
				'PROPERTY_TYPE' => $propInfo['PROPERTY_TYPE'],
				'USER_TYPE' => $propInfo['USER_TYPE'],
				'LINK_IBLOCK_ID' => $propInfo['LINK_IBLOCK_ID'],
				'USER_TYPE_SETTINGS' => $propInfo['USER_TYPE_SETTINGS'],
				'VALUES' => array(),
				'SHOW_MODE' => $showMode,
				'DEFAULT_VALUES' => array(
					'PICT' => false,
					'NAME' => '-'
				)
			);
			if ($showMode == 'PICT')
			{
				if (isset($defaultFields['PICT']))
				{
					$treeProp['DEFAULT_VALUES']['PICT'] = $defaultFields['PICT'];
				}
			}
			if (isset($defaultFields['NAME']))
			{
				$treeProp['DEFAULT_VALUES']['NAME'] = $defaultFields['NAME'];
			}
			$result[$treeProp['CODE']] = $treeProp;
		}
		return $result;
	}
Ejemplo n.º 27
0
 public static function GetPropertyValuesArray(&$result, $iblockID, $filter, $propertyFilter = array())
 {
     $iblockExtVersion = CIBlockElement::GetIBVersion($iblockID) == 2;
     $propertiesList = array();
     $mapCodes = array();
     $userTypesList = array();
     $existList = array();
     $selectListMultiply = array('SORT' => SORT_ASC, 'VALUE' => SORT_STRING);
     $selectAllMultiply = array('PROPERTY_VALUE_ID' => SORT_ASC);
     $propertyListFilter = array('IBLOCK_ID' => $iblockID);
     $propertyID = array();
     if (isset($propertyFilter['ID'])) {
         $propertyID = is_array($propertyFilter['ID']) ? $propertyFilter['ID'] : array($propertyFilter['ID']);
         Collection::normalizeArrayValuesByInt($propertyID);
     }
     if (!empty($propertyID)) {
         $propertyListFilter['@ID'] = $propertyID;
     } elseif (isset($propertyFilter['CODE'])) {
         if (!is_array($propertyFilter['CODE'])) {
             $propertyFilter['CODE'] = array($propertyFilter['CODE']);
         }
         $propertyCodes = array();
         if (!empty($propertyFilter['CODE'])) {
             foreach ($propertyFilter['CODE'] as &$code) {
                 $code = (string) $code;
                 if ($code !== '') {
                     $propertyCodes[] = $code;
                 }
             }
             unset($code);
         }
         if (!empty($propertyCodes)) {
             $propertyListFilter['@CODE'] = $propertyCodes;
         }
         unset($propertyCodes);
     }
     $propertyListFilter['=ACTIVE'] = isset($propertyFilter['ACTIVE']) && ($propertyFilter['ACTIVE'] == 'Y' || $propertyFilter['ACTIVE'] == 'N') ? $propertyFilter['ACTIVE'] : 'Y';
     $propertyID = array();
     $propertyIterator = PropertyTable::getList(array('select' => array('ID', 'IBLOCK_ID', 'NAME', 'ACTIVE', 'SORT', 'CODE', 'DEFAULT_VALUE', 'PROPERTY_TYPE', 'ROW_COUNT', 'COL_COUNT', 'LIST_TYPE', 'MULTIPLE', 'XML_ID', 'FILE_TYPE', 'MULTIPLE_CNT', 'LINK_IBLOCK_ID', 'WITH_DESCRIPTION', 'SEARCHABLE', 'FILTRABLE', 'IS_REQUIRED', 'VERSION', 'USER_TYPE', 'USER_TYPE_SETTINGS', 'HINT'), 'filter' => $propertyListFilter, 'order' => array('SORT' => 'ASC', 'ID' => 'ASC')));
     while ($property = $propertyIterator->fetch()) {
         $propertyID[] = (int) $property['ID'];
         $property['CODE'] = trim((string) $property['CODE']);
         if ($property['CODE'] === '') {
             $property['CODE'] = $property['ID'];
         }
         $code = $property['CODE'];
         $property['~NAME'] = $property['NAME'];
         if (preg_match("/[;&<>\"]/", $property['NAME'])) {
             $property['NAME'] = htmlspecialcharsex($property['NAME']);
         }
         if ($property['USER_TYPE']) {
             $userType = CIBlockProperty::GetUserType($property['USER_TYPE']);
             if (isset($userType['ConvertFromDB'])) {
                 $userTypesList[$property['ID']] = $userType;
                 if (array_key_exists("DEFAULT_VALUE", $property)) {
                     $value = array("VALUE" => $property["DEFAULT_VALUE"], "DESCRIPTION" => "");
                     $value = call_user_func_array($userType["ConvertFromDB"], array($property, $value));
                     $property["DEFAULT_VALUE"] = $value["VALUE"];
                 }
             }
         }
         if ($property['USER_TYPE_SETTINGS'] !== '' || $property['USER_TYPE_SETTINGS'] !== null) {
             $property['USER_TYPE_SETTINGS'] = unserialize($property['USER_TYPE_SETTINGS']);
         }
         $property['~DEFAULT_VALUE'] = $property['DEFAULT_VALUE'];
         if (is_array($property['DEFAULT_VALUE']) || preg_match("/[;&<>\"]/", $property['DEFAULT_VALUE'])) {
             $property['DEFAULT_VALUE'] = htmlspecialcharsex($property['DEFAULT_VALUE']);
         }
         if ($property['PROPERTY_TYPE'] == PropertyTable::TYPE_LIST) {
             $existList[] = $property['ID'];
         }
         $mapCodes[$property['ID']] = $code;
         $propertiesList[$code] = $property;
     }
     unset($property, $propertyIterator);
     if (empty($propertiesList)) {
         return;
     }
     if (!empty($existList)) {
         $enumList = array();
         $enumIterator = PropertyEnumerationTable::getList(array('select' => array('ID', 'PROPERTY_ID', 'VALUE', 'SORT', 'XML_ID'), 'filter' => array('PROPERTY_ID' => $existList), 'order' => array('PROPERTY_ID' => 'ASC', 'SORT' => 'ASC', 'VALUE' => 'ASC')));
         while ($enum = $enumIterator->fetch()) {
             if (!isset($enumList[$enum['PROPERTY_ID']])) {
                 $enumList[$enum['PROPERTY_ID']] = array();
             }
             $enumList[$enum['PROPERTY_ID']][$enum['ID']] = array('ID' => $enum['ID'], 'VALUE' => $enum['VALUE'], 'SORT' => $enum['SORT'], 'XML_ID' => $enum['XML_ID']);
         }
         unset($enum, $enumIterator);
     }
     $valuesRes = !empty($propertyID) ? CIBlockElement::GetPropertyValues($iblockID, $filter, true, array('ID' => $propertyID)) : CIBlockElement::GetPropertyValues($iblockID, $filter, true);
     while ($value = $valuesRes->Fetch()) {
         $elementID = $value['IBLOCK_ELEMENT_ID'];
         if (!isset($result[$elementID])) {
             continue;
         }
         $elementValues = array();
         $existDescription = isset($value['DESCRIPTION']);
         foreach ($propertiesList as $code => $property) {
             $existElementDescription = isset($value['DESCRIPTION']) && array_key_exists($property['ID'], $value['DESCRIPTION']);
             $existElementPropertyID = isset($value['PROPERTY_VALUE_ID']) && array_key_exists($property['ID'], $value['PROPERTY_VALUE_ID']);
             $elementValues[$code] = $property;
             $elementValues[$code]['VALUE_ENUM'] = null;
             $elementValues[$code]['VALUE_XML_ID'] = null;
             $elementValues[$code]['VALUE_SORT'] = null;
             $elementValues[$code]['VALUE'] = null;
             if ('Y' === $property['MULTIPLE']) {
                 $elementValues[$code]['PROPERTY_VALUE_ID'] = false;
                 if (!isset($value[$property['ID']]) || empty($value[$property['ID']])) {
                     $elementValues[$code]['DESCRIPTION'] = false;
                     $elementValues[$code]['VALUE'] = false;
                     $elementValues[$code]['~DESCRIPTION'] = false;
                     $elementValues[$code]['~VALUE'] = false;
                     if ('L' == $property['PROPERTY_TYPE']) {
                         $elementValues[$code]['VALUE_ENUM_ID'] = false;
                         $elementValues[$code]['VALUE_ENUM'] = false;
                         $elementValues[$code]['VALUE_XML_ID'] = false;
                         $elementValues[$code]['VALUE_SORT'] = false;
                     }
                 } else {
                     if ($existElementPropertyID) {
                         $elementValues[$code]['PROPERTY_VALUE_ID'] = $value['PROPERTY_VALUE_ID'][$property['ID']];
                     }
                     if (isset($userTypesList[$property['ID']])) {
                         foreach ($value[$property['ID']] as $valueKey => $oneValue) {
                             $raw = call_user_func_array($userTypesList[$property['ID']]['ConvertFromDB'], array($property, array('VALUE' => $oneValue, 'DESCRIPTION' => $existElementDescription ? $value['DESCRIPTION'][$property['ID']][$valueKey] : '')));
                             $value[$property['ID']][$valueKey] = $raw['VALUE'];
                             if (!$existDescription) {
                                 $value['DESCRIPTION'] = array();
                                 $existDescription = true;
                             }
                             if (!$existElementDescription) {
                                 $value['DESCRIPTION'][$property['ID']] = array();
                                 $existElementDescription = true;
                             }
                             $value['DESCRIPTION'][$property['ID']][$valueKey] = (string) $raw['DESCRIPTION'];
                         }
                         if (isset($oneValue)) {
                             unset($oneValue);
                         }
                     }
                     if ('L' == $property['PROPERTY_TYPE']) {
                         if (empty($value[$property['ID']])) {
                             $elementValues[$code]['VALUE_ENUM_ID'] = $value[$property['ID']];
                             $elementValues[$code]['DESCRIPTION'] = $existElementDescription ? $value['DESCRIPTION'][$property['ID']] : array();
                         } else {
                             $selectedValues = array();
                             foreach ($value[$property['ID']] as $listKey => $listValue) {
                                 if (isset($enumList[$property['ID']][$listValue])) {
                                     $selectedValues[$listKey] = $enumList[$property['ID']][$listValue];
                                     $selectedValues[$listKey]['DESCRIPTION'] = $existElementDescription && array_key_exists($listKey, $value['DESCRIPTION'][$property['ID']]) ? $value['DESCRIPTION'][$property['ID']][$listKey] : '';
                                     $selectedValues[$listKey]['PROPERTY_VALUE_ID'] = $existElementPropertyID && array_key_exists($listKey, $value['PROPERTY_VALUE_ID'][$property['ID']]) ? $value['PROPERTY_VALUE_ID'][$property['ID']][$listKey] : '';
                                 }
                             }
                             if (empty($selectedValues)) {
                                 $elementValues[$code]['VALUE_ENUM_ID'] = $value[$property['ID']];
                                 $elementValues[$code]['DESCRIPTION'] = $existElementDescription ? $value['DESCRIPTION'][$property['ID']] : array();
                             } else {
                                 Collection::sortByColumn($selectedValues, $selectListMultiply);
                                 $elementValues[$code]['VALUE_ENUM_ID'] = array();
                                 $elementValues[$code]['VALUE'] = array();
                                 $elementValues[$code]['VALUE_ENUM'] = array();
                                 $elementValues[$code]['VALUE_XML_ID'] = array();
                                 $elementValues[$code]['DESCRIPTION'] = array();
                                 $elementValues[$code]['PROPERTY_VALUE_ID'] = array();
                                 foreach ($selectedValues as $listValue) {
                                     if (!isset($elementValues[$code]['VALUE_SORT'])) {
                                         $elementValues[$code]['VALUE_SORT'] = array($listValue['SORT']);
                                     }
                                     $elementValues[$code]['VALUE_ENUM_ID'][] = $listValue['ID'];
                                     $elementValues[$code]['VALUE'][] = $listValue['VALUE'];
                                     $elementValues[$code]['VALUE_ENUM'][] = $listValue['VALUE'];
                                     $elementValues[$code]['VALUE_XML_ID'][] = $listValue['XML_ID'];
                                     $elementValues[$code]['PROPERTY_VALUE_ID'][] = $listValue['PROPERTY_VALUE_ID'];
                                     $elementValues[$code]['DESCRIPTION'][] = $listValue['DESCRIPTION'];
                                 }
                                 unset($selectedValues);
                             }
                         }
                     } else {
                         if (empty($value[$property['ID']]) || !$existElementPropertyID || isset($userTypesList[$property['ID']])) {
                             $elementValues[$code]['VALUE'] = $value[$property['ID']];
                             $elementValues[$code]['DESCRIPTION'] = $existElementDescription ? $value['DESCRIPTION'][$property['ID']] : array();
                         } else {
                             $selectedValues = array();
                             foreach ($value['PROPERTY_VALUE_ID'][$property['ID']] as $propKey => $propValueID) {
                                 $selectedValues[$propKey] = array('PROPERTY_VALUE_ID' => $propValueID, 'VALUE' => $value[$property['ID']][$propKey]);
                                 if ($existElementDescription) {
                                     $selectedValues[$propKey]['DESCRIPTION'] = $value['DESCRIPTION'][$property['ID']][$propKey];
                                 }
                             }
                             unset($propValueID, $propKey);
                             Collection::sortByColumn($selectedValues, $selectAllMultiply);
                             $elementValues[$code]['PROPERTY_VALUE_ID'] = array();
                             $elementValues[$code]['VALUE'] = array();
                             $elementValues[$code]['DESCRIPTION'] = array();
                             foreach ($selectedValues as &$propValue) {
                                 $elementValues[$code]['PROPERTY_VALUE_ID'][] = $propValue['PROPERTY_VALUE_ID'];
                                 $elementValues[$code]['VALUE'][] = $propValue['VALUE'];
                                 if ($existElementDescription) {
                                     $elementValues[$code]['DESCRIPTION'][] = $propValue['DESCRIPTION'];
                                 }
                             }
                             unset($propValue, $selectedValues);
                         }
                     }
                 }
                 $elementValues[$code]['~VALUE'] = $elementValues[$code]['VALUE'];
                 if (is_array($elementValues[$code]['VALUE'])) {
                     foreach ($elementValues[$code]['VALUE'] as &$oneValue) {
                         $isArr = is_array($oneValue);
                         if ($isArr || '' !== $oneValue && null !== $oneValue) {
                             if ($isArr || preg_match("/[;&<>\"]/", $oneValue)) {
                                 $oneValue = htmlspecialcharsEx($oneValue);
                             }
                         }
                     }
                     if (isset($oneValue)) {
                         unset($oneValue);
                     }
                 } else {
                     if ('' !== $elementValues[$code]['VALUE'] && null !== $elementValues[$code]['VALUE']) {
                         if (preg_match("/[;&<>\"]/", $elementValues[$code]['VALUE'])) {
                             $elementValues[$code]['VALUE'] = htmlspecialcharsEx($elementValues[$code]['VALUE']);
                         }
                     }
                 }
                 $elementValues[$code]['~DESCRIPTION'] = $elementValues[$code]['DESCRIPTION'];
                 if (is_array($elementValues[$code]['DESCRIPTION'])) {
                     foreach ($elementValues[$code]['DESCRIPTION'] as &$oneDescr) {
                         $isArr = is_array($oneDescr);
                         if ($isArr || !$isArr && '' !== $oneDescr && null !== $oneDescr) {
                             if ($isArr || preg_match("/[;&<>\"]/", $oneDescr)) {
                                 $oneDescr = htmlspecialcharsEx($oneDescr);
                             }
                         }
                     }
                     if (isset($oneDescr)) {
                         unset($oneDescr);
                     }
                 } else {
                     if ('' !== $elementValues[$code]['DESCRIPTION'] && null !== $elementValues[$code]['DESCRIPTION']) {
                         if (preg_match("/[;&<>\"]/", $elementValues[$code]['DESCRIPTION'])) {
                             $elementValues[$code]['DESCRIPTION'] = htmlspecialcharsEx($elementValues[$code]['DESCRIPTION']);
                         }
                     }
                 }
             } else {
                 $elementValues[$code]['VALUE_ENUM'] = $iblockExtVersion ? '' : null;
                 $elementValues[$code]['PROPERTY_VALUE_ID'] = $iblockExtVersion ? $elementID . ':' . $property['ID'] : null;
                 if (!isset($value[$property['ID']]) || false === $value[$property['ID']]) {
                     $elementValues[$code]['DESCRIPTION'] = '';
                     $elementValues[$code]['VALUE'] = '';
                     $elementValues[$code]['~DESCRIPTION'] = '';
                     $elementValues[$code]['~VALUE'] = '';
                     if ('L' == $property['PROPERTY_TYPE']) {
                         $elementValues[$code]['VALUE_ENUM_ID'] = null;
                     }
                 } else {
                     if ($existElementPropertyID) {
                         $elementValues[$code]['PROPERTY_VALUE_ID'] = $value['PROPERTY_VALUE_ID'][$property['ID']];
                     }
                     if (isset($userTypesList[$property['ID']])) {
                         $raw = call_user_func_array($userTypesList[$property['ID']]['ConvertFromDB'], array($property, array('VALUE' => $value[$property['ID']], 'DESCRIPTION' => $existElementDescription ? $value['DESCRIPTION'][$property['ID']] : '')));
                         $value[$property['ID']] = $raw['VALUE'];
                         if (!$existDescription) {
                             $value['DESCRIPTION'] = array();
                             $existDescription = true;
                         }
                         $value['DESCRIPTION'][$property['ID']] = (string) $raw['DESCRIPTION'];
                         $existElementDescription = true;
                     }
                     if ('L' == $property['PROPERTY_TYPE']) {
                         $elementValues[$code]['VALUE_ENUM_ID'] = $value[$property['ID']];
                         if (isset($enumList[$property['ID']][$value[$property['ID']]])) {
                             $elementValues[$code]['VALUE'] = $enumList[$property['ID']][$value[$property['ID']]]['VALUE'];
                             $elementValues[$code]['VALUE_ENUM'] = $elementValues[$code]['VALUE'];
                             $elementValues[$code]['VALUE_XML_ID'] = $enumList[$property['ID']][$value[$property['ID']]]['XML_ID'];
                             $elementValues[$code]['VALUE_SORT'] = $enumList[$property['ID']][$value[$property['ID']]]['SORT'];
                         }
                         $elementValues[$code]['DESCRIPTION'] = $existElementDescription ? $value['DESCRIPTION'][$property['ID']] : null;
                     } else {
                         $elementValues[$code]['VALUE'] = $value[$property['ID']];
                         $elementValues[$code]['DESCRIPTION'] = $existElementDescription ? $value['DESCRIPTION'][$property['ID']] : '';
                     }
                 }
                 $elementValues[$code]['~VALUE'] = $elementValues[$code]['VALUE'];
                 $isArr = is_array($elementValues[$code]['VALUE']);
                 if ($isArr || '' !== $elementValues[$code]['VALUE'] && null !== $elementValues[$code]['VALUE']) {
                     if ($isArr || preg_match("/[;&<>\"]/", $elementValues[$code]['VALUE'])) {
                         $elementValues[$code]['VALUE'] = htmlspecialcharsEx($elementValues[$code]['VALUE']);
                     }
                 }
                 $elementValues[$code]['~DESCRIPTION'] = $elementValues[$code]['DESCRIPTION'];
                 $isArr = is_array($elementValues[$code]['DESCRIPTION']);
                 if ($isArr || '' !== $elementValues[$code]['DESCRIPTION'] && null !== $elementValues[$code]['DESCRIPTION']) {
                     if ($isArr || preg_match("/[;&<>\"]/", $elementValues[$code]['DESCRIPTION'])) {
                         $elementValues[$code]['DESCRIPTION'] = htmlspecialcharsEx($elementValues[$code]['DESCRIPTION']);
                     }
                 }
             }
         }
         if (isset($result[$elementID]['PROPERTIES'])) {
             $result[$elementID]['PROPERTIES'] = $elementValues;
         } else {
             $result[$elementID] = $elementValues;
         }
         unset($elementValues);
     }
 }
Ejemplo n.º 28
0
     $arFieldsTmp = $productProvider::GetProductData(array("PRODUCT_ID" => $newProductId['ID'], "QUANTITY" => $arItem['QUANTITY'], "RENEWAL" => "N", "USER_ID" => $USER->GetID(), "SITE_ID" => SITE_ID, "BASKET_ID" => $arItem['ID'], "CHECK_QUANTITY" => "Y", "CHECK_PRICE" => "Y", "NOTES" => $arItem["NOTES"]));
 } elseif (isset($arItem["CALLBACK_FUNC"]) && !empty($arItem["CALLBACK_FUNC"])) {
     $arFieldsTmp = CSaleBasket::ExecuteCallbackFunction($arItem["CALLBACK_FUNC"], $arItem["MODULE"], $newProductId['ID'], $arItem['QUANTITY'], "N", $USER->GetID(), SITE_ID);
 }
 if (!empty($arFieldsTmp) && is_array($arFieldsTmp)) {
     $arFields = array('PRODUCT_ID' => $newProductId['ID'], 'PRODUCT_PRICE_ID' => $arFieldsTmp["PRODUCT_PRICE_ID"], 'PRICE' => $arFieldsTmp["PRICE"], 'CURRENCY' => $arFieldsTmp["CURRENCY"], 'QUANTITY' => $arFieldsTmp['QUANTITY'], 'WEIGHT' => $arFieldsTmp['WEIGHT']);
     $arProps = array();
     if (strpos($newProductId['XML_ID'], '#') === false) {
         $parentIterator = \Bitrix\Iblock\ElementTable::getList(array('select' => array('ID', 'XML_ID'), 'filter' => array('ID' => $parentId)));
         if ($parentProduct = $parentIterator->fetch()) {
             $newProductId['XML_ID'] = $parentProduct['XML_ID'] . '#' . $newProductId['XML_ID'];
         }
         unset($parentProduct, $parentIterator);
     }
     $arFields["PRODUCT_XML_ID"] = $newProductId['XML_ID'];
     $propertyIterator = \Bitrix\Iblock\PropertyTable::getList(array('select' => array('ID', 'CODE'), 'filter' => array('IBLOCK_ID' => $newProductId['IBLOCK_ID'], '!ID' => $sku['SKU_PROPERTY_ID'])));
     while ($property = $propertyIterator->fetch()) {
         $property['CODE'] = (string) $property['CODE'];
         $arPropsSku[] = $property['CODE'] != '' ? $property['CODE'] : $property['ID'];
     }
     unset($property, $propertyIterator);
     $product_properties = CIBlockPriceTools::GetOfferProperties($newProductId['ID'], $sku['PRODUCT_IBLOCK_ID'], $arPropsSku);
     $newValues = array();
     foreach ($product_properties as $productSkuProp) {
         $bFieldExists = false;
         foreach ($strOffersProps as $existingSkuProp) {
             if ($existingSkuProp == $productSkuProp["CODE"]) {
                 $bFieldExists = true;
                 break;
             }
         }
Ejemplo n.º 29
0
function getAdditionalColumns()
{
	static $propList = null;

	if ($propList === null && Loader::includeModule('catalog'))
	{
		$arIblockIDs = array();
		$arIblockNames = array();
		$catalogIterator = Catalog\CatalogIblockTable::getList(array(
			'select' => array('IBLOCK_ID', 'NAME' => 'IBLOCK.NAME'),
			'order' => array('IBLOCK_ID' => 'ASC')
		));
		while ($catalog = $catalogIterator->fetch())
		{
			$catalog['IBLOCK_ID'] = (int)$catalog['IBLOCK_ID'];
			$arIblockIDs[] = $catalog['IBLOCK_ID'];
			$arIblockNames[$catalog['IBLOCK_ID']] = $catalog['NAME'];
		}
		unset($catalog, $catalogIterator);

		if (!empty($arIblockIDs))
		{
			$arProps = array();
			$propertyIterator = Iblock\PropertyTable::getList(array(
				'select' => array('ID', 'CODE', 'NAME', 'IBLOCK_ID'),
				'filter' => array('@IBLOCK_ID' => $arIblockIDs, '=ACTIVE' => 'Y'),
				'order' => array('IBLOCK_ID' => 'ASC', 'SORT' => 'ASC', 'ID' => 'ASC')
			));
			while ($property = $propertyIterator->fetch())
			{
				$property['ID'] = (int)$property['ID'];
				$property['IBLOCK_ID'] = (int)$property['IBLOCK_ID'];
				$property['CODE'] = (string)$property['CODE'];
				if ($property['CODE'] == '')
					$property['CODE'] = $property['ID'];
				if (!isset($arProps[$property['CODE']]))
				{
					$arProps[$property['CODE']] = array(
						'CODE' => $property['CODE'],
						'TITLE' => $property['NAME'].' ['.$property['CODE'].']',
						'ID' => array($property['ID']),
						'IBLOCK_ID' => array($property['IBLOCK_ID'] => $property['IBLOCK_ID']),
						'IBLOCK_TITLE' => array($property['IBLOCK_ID'] => $arIblockNames[$property['IBLOCK_ID']]),
						'COUNT' => 1
					);
				}
				else
				{
					$arProps[$property['CODE']]['ID'][] = $property['ID'];
					$arProps[$property['CODE']]['IBLOCK_ID'][$property['IBLOCK_ID']] = $property['IBLOCK_ID'];
					if ($arProps[$property['CODE']]['COUNT'] < 5)
						$arProps[$property['CODE']]['IBLOCK_TITLE'][$property['IBLOCK_ID']] = $arIblockNames[$property['IBLOCK_ID']];
					$arProps[$property['CODE']]['COUNT']++;
				}
			}
			unset($property, $propertyIterator, $arIblockNames, $arIblockIDs);

			$propList = array();
			foreach ($arProps as &$property)
			{
				$iblockList = '';
				if ($property['COUNT'] > 1)
				{
					$iblockList = ($property['COUNT'] > 5 ? ' ( ... )' : ' ('.implode(', ', $property['IBLOCK_TITLE']).')');
				}
				$propList['PROPERTY_'.$property['CODE']] = $property['TITLE'].$iblockList;
			}
			unset($property, $arProps);
		}
	}

	return (empty($propList) ? array() : $propList);
}
Ejemplo n.º 30
0
 /**
  * Return exist property list.
  *
  * @param int $iblockID							Iblock id.
  * @param array|string $propertyCodes			Property codes.
  * @param bool $indexCode						Return codes as key.
  * @return array|bool
  */
 public static function getExistProperty($iblockID, $propertyCodes, $indexCode = true)
 {
     $indexCode = $indexCode === true;
     $iblockID = (int) $iblockID;
     if ($iblockID <= 0) {
         return false;
     }
     $propertyCodes = self::clearPropertyList($propertyCodes);
     if (empty($propertyCodes)) {
         return false;
     }
     $result = array();
     $propertyIterator = Iblock\PropertyTable::getList(array('select' => array('ID', 'CODE'), 'filter' => array('IBLOCK_ID' => $iblockID, '@CODE' => $propertyCodes)));
     if ($indexCode) {
         while ($property = $propertyIterator->fetch()) {
             $property['ID'] = (int) $property['ID'];
             if (!isset($result[$property['CODE']])) {
                 $result[$property['CODE']] = $property['ID'];
             } else {
                 if (!is_array($result[$property['CODE']])) {
                     $result[$property['CODE']] = array($result[$property['CODE']]);
                 }
                 $result[$property['CODE']][] = $property['ID'];
             }
         }
         unset($property, $propertyIterator);
     } else {
         while ($property = $propertyIterator->fetch()) {
             $property['ID'] = (int) $property['ID'];
             $result[$property['ID']] = $property['CODE'];
         }
         unset($property, $propertyIterator);
     }
     return $result;
 }