Last active
May 5, 2022 07:38
-
-
Save andrei99/9a79febd63e19d7e83b84e47fe2645be to your computer and use it in GitHub Desktop.
Getlist goods
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//404 add statys | |
if(count($arSectionCurrent) === 0){ | |
@define('ERROR_404', 'Y'); | |
CHTTP::SetStatus('404 Not Found'); | |
} | |
//404 show error page | |
global $APPLICATION; | |
if ((defined('ERROR_404')) && (ERROR_404=='Y')) | |
{ | |
$APPLICATION->RestartBuffer(); | |
CHTTP::SetStatus("404 Not Found"); | |
include($_SERVER["DOCUMENT_ROOT"].SITE_TEMPLATE_PATH."/header.php"); | |
require ($_SERVER["DOCUMENT_ROOT"]."/404.php"); | |
//include($_SERVER["DOCUMENT_ROOT"].SITE_TEMPLATE_PATH."/footer.php"); | |
die(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$el = new CIBlockElement; | |
$arProp = array( | |
248 => $arItem['SELECTED_ITEM_ID'], | |
249 => $arItem2['SELECTED_ITEM_ID'], | |
); | |
$arFields = array( | |
"NAME" => $arItem['NAME'] . ' vs ' . $arItem2['NAME'], | |
"ACTIVE" => "Y", | |
"IBLOCK_ID" => 48, | |
"PROPERTY_VALUES" => $arProp, | |
"CODE" => $arItem['CODE'] . '-vs-' . $arItem2['CODE'], | |
); | |
$id = $el->Add($arFields); | |
if ($id === false) { | |
echo $el->LAST_ERROR; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Bitrix\Main\Loader; | |
Loader::includeModule("iblock"); | |
Loader::includeModule("sale"); | |
$arListOrder = array(); | |
$arFilter = Array(); | |
$arNavStartParams = array( | |
'nTopCount' => 100 | |
); | |
$arSelectFields = array( | |
'ID' | |
); | |
$db_sales = CSaleOrder::GetList(array("DATE_INSERT" => "DESC"), $arFilter, false, $arNavStartParams, $arSelectFields); | |
while ($ar_sales = $db_sales->Fetch()) | |
{ | |
$arListOrder[] = $ar_sales; | |
} | |
foreach ($arListOrder as $arItem){ | |
CSaleOrder::Delete($arItem['ID']); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$price = CCatalogProduct::GetOptimalPrice($productID, 1, $USER->GetUserGroupArray(), 'N'); | |
print_r(price); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foreach ($arAdvantageSection['ITEMS'] as &$arItem){ | |
$arButtons = CIBlock::GetPanelButtons( | |
ADVANTAGES_SECTION_ID, | |
$arItem["ID"], | |
0, | |
array("SECTION_BUTTONS"=>false, "SESSID"=>false) | |
); | |
$arItem["EDIT_LINK"] = $arButtons["edit"]["edit_element"]["ACTION_URL"]; | |
$arItem["DELETE_LINK"] = $arButtons["edit"]["delete_element"]["ACTION_URL"]; | |
} | |
unset($arItem); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//сохранение свойств в файл | |
$filename = 'prop_list.txt'; | |
$IBLOCK_ID = 5; | |
$properties = CIBlockProperty::GetList(Array("sort" => "asc", "name" => "asc"), Array("ACTIVE" => "Y", "IBLOCK_ID" => $IBLOCK_ID)); | |
while ($prop_fields = $properties->GetNext()) { | |
$arPropList[] = $prop_fields; | |
} | |
$data = serialize($arPropList); | |
file_put_contents($filename, $data); | |
//запись свойств в инфоблок | |
$data = file_get_contents($filename); | |
$bookshelf = unserialize($data); | |
if (!empty($bookshelf)) { | |
$intIblockID = 10; | |
foreach ($bookshelf as $arItem) { | |
$arFields = Array( | |
"NAME" => $arItem['NAME'], | |
"ACTIVE" => $arItem['ACTIVE'], | |
"SORT" => $arItem['SORT'], | |
"CODE" => $arItem['CODE'], | |
"PROPERTY_TYPE" => $arItem['PROPERTY_TYPE'], | |
"IBLOCK_ID" => $intIblockID, | |
"MULTIPLE" => $arItem['MULTIPLE'], | |
); | |
if(!empty($arItem['USER_TYPE'])){ | |
$arFields['USER_TYPE'] = $arItem['USER_TYPE']; | |
} | |
$ibp = new CIBlockProperty; | |
$PropID = $ibp->Add($arFields); | |
} | |
} | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$strPropertyCodePrice = 'PRICE'; | |
$arPropertyID = array(); | |
$resPropertyEnums = CIBlockPropertyEnum::GetList(Array(), Array("IBLOCK_ID" => BASE_CATALOG_ID, "CODE" => $strPropertyCodePrice)); | |
while ($arFieldsEnums = $resPropertyEnums->GetNext()) { | |
$arPropertyID[] = $arFieldsEnums['ID']; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$arResult = array(); | |
$arSelect = array( | |
"IBLOCK_ID", | |
"ID", | |
"CATALOG_GROUP_1" | |
); | |
$arFilter = array( | |
"IBLOCK_ID"=>3, | |
"ACTIVE_DATE"=>"Y", | |
"ACTIVE"=>"Y", | |
"SECTION_ID" => 6, | |
"INCLUDE_SUBSECTIONS" => "Y", | |
"CATALOG_AVAILABLE" => "Y" | |
); | |
$dbElement = CIBlockElement::GetList( | |
array("RAND" => "ASC"), | |
$arFilter, | |
false, | |
array("nPageSize"=>10), | |
$arSelect | |
); | |
while($arFields = $dbElement->GetNextElement()) | |
{ | |
$arResult['ITEMS'][] = $arFields->GetFields(); | |
$arResult['PROP'][] = $arFields->GetProperties(); | |
//multi | |
$arProperties[] = $arFields->GetProperties(array(), array('CODE' => 'name-code-property')); | |
} | |
//simple select no property | |
while($arFields = $dbElement->GetNext()) | |
{ | |
$arResult['ITEMS'][] = $arFields; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CModule::IncludeModule("iblock"); | |
$arSectionList = array(); | |
$arSelect = array( | |
"IBLOCK_ID", | |
"ID", | |
"NAME", | |
"CODE" | |
); | |
$arFilter = array( | |
"IBLOCK_ID" => 5, | |
"DEPTH_LEVEL" => 1, | |
"ACTIVE" => "Y", | |
"GLOBAL_ACTIVE" => "Y" | |
); | |
$dbSection = CIBlockSection::GetList( | |
array("SORT" => "ASC"), | |
$arFilter, | |
true, | |
$arSelect | |
); | |
while ($arFieldsSection = $dbSection->GetNext()) { | |
$arSectionList[] = $arFieldsSection; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$res = \Bitrix\Iblock\Model\PropertyFeature::setFeatures($intPropertyID, [ | |
["FEATURE_ID"=>"DETAIL_PAGE_SHOW", "IS_ENABLED" => "Y", "MODULE_ID" => "iblock"], //деталка | |
["FEATURE_ID"=>"LIST_PAGE_SHOW", "IS_ENABLED" => "N", "MODULE_ID" => "iblock"] //список | |
]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$strPropertyCodePrice = 'PRICE'; | |
$arPropertyID = array(1,2,3,4); | |
CIBlockElement::SetPropertyValuesEx($intProductID, false, array($strPropertyCodePrice => $arPropertyID)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$intID = 'ID items'; | |
$arSelect = Array( | |
"IBLOCK_ID", | |
"ID" | |
); | |
$arFilter = Array( | |
"IBLOCK_ID"=>37, | |
"ACTIVE"=>"Y" | |
); | |
$res = CIBlockElement::GetList( | |
array('ID' => 'DESC'), | |
$arFilter, | |
false, | |
array('nPageSize' => 1, 'nElementID' => $intID), | |
$arSelect | |
); | |
while($ob = $res->GetNextElement()) | |
{ | |
$arFields = $ob->GetFields(); | |
$arItemsID[] = $arFields['ID']; | |
} | |
if(count($arItemsID) == 2 && $intID == $arItemsID[0]){ | |
$arResult['ITEMS'][0]['PREV_ITEM'] = 0; | |
$arResult['ITEMS'][0]['NEXT_ITEM'] = $arItemsID[1]; | |
}elseif(count($arItemsID) == 3){ | |
$arResult['ITEMS'][0]['PREV_ITEM'] = $arItemsID[0]; | |
$arResult['ITEMS'][0]['NEXT_ITEM'] = $arItemsID[2]; | |
}else{ | |
$arResult['ITEMS'][0]['PREV_ITEM'] = $arItemsID[0]; | |
$arResult['ITEMS'][0]['NEXT_ITEM'] = 0; | |
} | |
//html | |
<? if (!empty($arItem['PREV_ITEM']) && $arItem['PREV_ITEM'] != 0): ?> | |
<a href="#" data-item="<?= $arItem['PREV_ITEM'] ?>">PREV</a> | |
<? endif; ?> | |
<? if (!empty($arItem['NEXT_ITEM']) && $arItem['NEXT_ITEM'] != 0): ?> | |
<a href="#" data-item="<?= $arItem['NEXT_ITEM'] ?>">NEXT</a> | |
<? endif; ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (\Bitrix\Main\Loader::includeModule('iblock')) { | |
$IBLOCK_ID = CATALOG; // Идентификатор инфоблока | |
$properties = CIBlockProperty::GetList( | |
Array("sort"=>"asc", "name"=>"asc"), | |
Array("ACTIVE"=>"Y", "IBLOCK_ID"=>$IBLOCK_ID) | |
); | |
while ($prop_fields = $properties->GetNext()) | |
{ | |
if($prop_fields["SORT"]>=500) { | |
\Bitrix\Iblock\Model\PropertyFeature::setFeatures( | |
$prop_fields["ID"],[[ | |
"MODULE_ID"=>"iblock", | |
"IS_ENABLED"=>"Y", | |
"FEATURE_ID" => "DETAIL_PAGE_SHOW" | |
]] | |
); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// мульти сортировка в catalog.section | |
$arParams["CUSTOM_SORT_ORDER"] = ["PROPERTY_AVAILABILITY" => "desc", "catalog_PRICE_1" => "desc", ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://tokmakov.msk.ru/blog/item/227 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment