Last active
March 26, 2019 12:16
-
-
Save MasterHans/f49201062df3611c66daacdc09e6e305 to your computer and use it in GitHub Desktop.
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
$arrFilter = | |
array( | |
[ | |
"LOGIC" => "OR", | |
["ID" => 85416], | |
["ID" => 86535], | |
] | |
) |
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
для Конкретных товаров | |
function ($arOrder) | |
{ | |
$salecond_0_0 = function ($row) { | |
return (((isset($row['CATALOG']['PARENT_ID']) ? ((isset($row['CATALOG']['ID']) && ($row['CATALOG']['ID'] == 87660 || $row['CATALOG']['ID'] == 88501 || $row['CATALOG']['ID'] == 88503 || $row['CATALOG']['ID'] == 90111)) || ($row['CATALOG']['PARENT_ID'] == 87660 || $row['CATALOG']['PARENT_ID'] == 88501 || $row['CATALOG']['PARENT_ID'] == 88503 || $row['CATALOG']['PARENT_ID'] == 90111)) : (isset($row['CATALOG']['ID']) && ($row['CATALOG']['ID'] == 87660 || $row['CATALOG']['ID'] == 88501 || $row['CATALOG']['ID'] == 88503 || $row['CATALOG']['ID'] == 90111))))); | |
}; | |
return (((CSaleBasketFilter::ProductFilter($arOrder, $salecond_0_0)))); | |
} | |
; | |
//для каталога(папки) товаров | |
function ($arOrder) | |
{ | |
$salecond_0_0 = function ($row) { | |
return (((isset($row['CATALOG']['SECTION_ID']) && in_array(4110, $row['CATALOG']['SECTION_ID'])))); | |
}; | |
return (((CSaleBasketFilter::ProductFilter($arOrder, $salecond_0_0)))); | |
} | |
; | |
function (&$arOrder) | |
{ | |
$saleact_0_0 = function ($row) { | |
return (((isset($row['CATALOG']['SECTION_ID']) && in_array(4110, $row['CATALOG']['SECTION_ID'])))); | |
}; | |
\Bitrix\Sale\Discount\Actions::applyToBasket($arOrder, array( | |
'VALUE' => -50.0, | |
'UNIT' => 'P', | |
'LIMIT_VALUE' => 0, | |
), $saleact_0_0); | |
}; | |
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
$arIDS = array(); | |
$groupDiscountIterator = Bitrix\Sale\Internals\DiscountGroupTable::getList(array( | |
'select' => array('DISCOUNT_ID'), | |
'filter' => array('@GROUP_ID' => CUser::GetUserGroup($USER->GetID()), '=ACTIVE' => 'Y') | |
)); | |
while ($groupDiscount = $groupDiscountIterator->fetch()) { | |
$groupDiscount['DISCOUNT_ID'] = (int)$groupDiscount['DISCOUNT_ID']; | |
if ($groupDiscount['DISCOUNT_ID'] > 0) { | |
$arIDS[$groupDiscount['DISCOUNT_ID']] = $groupDiscount['DISCOUNT_ID'];; | |
} | |
} | |
if ($arIDS) { | |
$discountIterator = Bitrix\Sale\Internals\DiscountTable::getList(array( | |
'select' => array( | |
"ID", "NAME", "PRIORITY", "SORT", "LAST_DISCOUNT", "UNPACK", "APPLICATION", "USE_COUPONS", "DISCOUNT_VALUE" | |
), | |
'filter' => array( | |
'@ID' => $arIDS | |
), | |
'order' => array( | |
"PRIORITY" => "DESC", | |
"SORT" => "ASC", | |
"ID" => "ASC" | |
) | |
)); | |
while ($discount = $discountIterator->fetch()) { | |
echo '<pre>'; | |
print_r($discount); | |
echo '</pre>'; | |
} | |
} |
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
bitrix:catalog.section Можно использовать фильтр без каких либо дополнительных компонентов | |
Что бы фильтр для bitrix:catalog.section заработал | |
нужно следующие параметры | |
"FILTER_NAME">"arrFilter" | |
"USE_FILTER"=>"Y" | |
"SHOW_ALL_WO_SECTION"=>"Y" |
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
/** | |
* Получает ID всех элементов каталога с учётом подкаталогов и вставляем в массив фильтра для отбора товаров со скидкой | |
*/ | |
function POV_AllElementsIDsFromSectionToArrFilter($SectionID, $in_arrFilter) | |
{ | |
//Формируем массив ид подразделов раздела | |
$arrayID = []; | |
$arrayID[] = $SectionID; | |
$arFilter = Array('IBLOCK_ID' => 49, 'SECTION_ID' => $SectionID); | |
$db_list = CIBlockSection::GetList(Array(), $arFilter, true); | |
while ($ar_result = $db_list->GetNext()) { | |
$arrayID[] = $ar_result['ID']; | |
// echo '<br>'; | |
// echo $ar_result['ID']; | |
} | |
//Формируем массив | |
$arSelect = Array("ID", "NAME"); | |
$arFilter = Array("IBLOCK_ID" => 49, "SECTION_ID" => $arrayID); | |
$res = CIBlockElement::GetList(Array(), $arFilter, false, false, $arSelect); | |
while ($ob = $res->GetNextElement()) { | |
// echo '<pre>'; | |
// print_r($ob->fields['ID']); | |
// print_r($ob->fields['NAME']); | |
// echo '</pre>'; | |
$in_arrFilter[] = ['ID' => $ob->fields['ID']]; | |
//Добавляем елементы в массив для фильтра | |
}; | |
return $in_arrFilter; | |
} |
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("catalog"); | |
CModule::IncludeModule("sale"); | |
//фильтрация по ID скидки из правил работы с корзиной. я поставил 2, т.к. у меня ID 2. | |
$discountIterator = Bitrix\Sale\Internals\DiscountTable::getList([ | |
'select' => ['ID', 'ACTIONS_LIST'], | |
// 'filter' => ['ID' => '2'] | |
]); | |
while ($discount = $discountIterator->fetch()) { | |
// | |
// echo '<pre>'; | |
// print_r($discount); | |
// echo '</pre>'; | |
/*Разделы*/ | |
foreach ($discount['ACTIONS_LIST']['CHILDREN']['0']['CHILDREN']['0']['CHILDREN'] as $key) { | |
if ($key['CLASS_ID'] == 'CondIBSection') { | |
echo "Разделы: "; | |
if (count($key['DATA']['value']) == 1) { | |
echo $key['DATA']['value']; | |
} else { | |
foreach ($key['DATA']['value'] as $val) { | |
echo $val . ", "; | |
} | |
} | |
} else { | |
echo " Элементы: "; | |
if (count($key['DATA']['value']) == 1) { | |
echo $key['DATA']['value']; | |
} else { | |
foreach ($key['DATA']['value'] as $val) { | |
echo $val . ", "; | |
} | |
} | |
} | |
} | |
/*Товары*/ | |
foreach ($discount['ACTIONS_LIST']['CHILDREN']['0']['CHILDREN']['1']['CHILDREN'] as $key) { | |
if ($key['CLASS_ID'] == 'CondIBSection') { | |
echo "Разделы: "; | |
if (count($key['DATA']['value']) == 1) { | |
echo $key['DATA']['value']; | |
} else { | |
foreach ($key['DATA']['value'] as $val) { | |
echo $val . ", "; | |
} | |
} | |
} else { | |
echo " Элементы: "; | |
if (count($key['DATA']['value']) == 1) { | |
echo $key['DATA']['value']; | |
} else { | |
foreach ($key['DATA']['value'] as $val) { | |
echo $val . ", "; | |
} | |
} | |
} | |
} | |
} |
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\Sale\Internals\DiscountTable; | |
$res = DiscountTable::getList()->fetchAll(); | |
foreach ($res as $item){ | |
echo '<pre>'; | |
print_r($item); | |
echo '</pre>'; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment