Skip to content

Instantly share code, notes, and snippets.

@EscApp2
EscApp2 / txt.txt
Last active May 1, 2024 09:23
Добавить кнопку таб страницу текст в админке admin add button add page tab tabs
В init.php, а лучше в подключаемом в нем файле:
подписываемся на событие OnAdminTabControlBegin (событие OnAdminTabControlBegin вызывается в функции CAdminTabControl::Begin() при выводе в административном интерфейсе формы редактирования).
подписываемся на событие OnAdminListDisplay (Событие OnAdminListDisplay вызывается в функции CAdminList::Display() при выводе в административном разделе списка элементов).
use \Bitrix\Main\EventManager;
$eventManager = EventManager::getInstance();
$eventManager->addEventHandler('main', 'OnAdminTabControlBegin', ['\LocalNamespase\Handlers', 'onAdminTabControlBegin']);
$eventManager->addEventHandler('main', 'OnAdminListDisplay', ['\LocalNamespase\Handlers', 'onAdminListDisplay']);
@EscApp2
EscApp2 / init.php
Last active April 24, 2024 13:22
twinpx delivery yadelivery hack if default city non moscow Если первый город не москва, кнопки выбора интервала и пвз не появляются regex class
<?
Bitrix\Main\EventManager::getInstance()->addEventHandler(
'sale',
'OnSaleComponentOrderJsData',
'OnSaleComponentOrderJsData_twinpx_yadelivery_hack'
);
function OnSaleComponentOrderJsData_twinpx_yadelivery_hack(&$arResult,&$arParams)
{
if(\Bitrix\Main\Loader::includeModule('twinpx.yadelivery')){
$headStings = \Bitrix\Main\Page\Asset::getInstance()->getStrings();
@EscApp2
EscApp2 / WebSiteHelp.php
Last active April 24, 2024 13:20
__OrderHelp setSalePropertyD7 getSalePropertyD7 setOrderProperty set sale order property d7 SaleOrderAjaxHelp SaleOrderSavedHelp SaleBasketHelp WebSiteHelp IblockCatalogHelp collectUnusedCoupons saveUnusedCoupons
<?
class __WebSiteHelp{
public static function getComponent($object){
$component = false;
if($object instanceof CBitrixComponentTemplate){
$component = $object->getComponent();
}elseif($object instanceof CBitrixComponent){
$component = $object;
}
return $component;
@EscApp2
EscApp2 / classPict.php
Last active April 22, 2024 14:39
pic jpg jpeg png to webp pict
<?
namespace Bas;
use Bitrix\Main\IO;
use Bitrix\Main\Application;
use CFile;
class Pict {
private static $isPng = true;
@EscApp2
EscApp2 / init.php
Created April 19, 2024 16:04
union element
<?php
class makeIblockElementUnion{
static function GetListFilter($IBLOCK_ID, $arFilter, $arUnionBy, $limit, $arInputSort = array()){
\Bitrix\Main\Loader::includeModule('iblock');
$CIBlockElement = \Bitrix\Iblock\Iblock::wakeUp($IBLOCK_ID)->getEntityDataClass();
if($CIBlockElement){
if(empty($arInputSort)){
$arInputSort["ID"] = "ASC";
@EscApp2
EscApp2 / init.php
Last active April 19, 2024 09:04
bitrix get last viewed products
// sku_id=>element_id
function GetLastViewed($limit = false){
// \bitrix\components\bitrix\catalog.viewed.products\class.php #657
$map = array();
if (!Bitrix\Main\Loader::includeModule('catalog')){
return array();
}
if (!Bitrix\Main\Loader::includeModule('sale')){
return array();
@EscApp2
EscApp2 / event.php
Created April 17, 2024 13:50
Stop add check, Stop Print Check For Empty Delivery Service
<?
$eventManager = \Bitrix\Main\EventManager::getInstance();
$eventManager->addEventHandler('sale', '\Bitrix\Sale\Cashbox\Internals\CashboxCheck::OnBeforeAdd', 'StopPrintCheckForEmptyDeliveryService');
function StopPrintCheckForEmptyDeliveryService(\Bitrix\Main\Event $event){
$BITRIX_EMPTY_DELIVERY_ID = \Bitrix\Sale\Delivery\Services\EmptyDeliveryService::getEmptyDeliveryServiceId();
$arParameters = $event->getParameters();
$arFields = $arParameters['fields'];
if("sell" == $arFields['TYPE']){
@EscApp2
EscApp2 / init.php
Last active April 17, 2024 08:13
selected sku by filter, выбрать ID SKU для установки SKU по умолчанию, исходя из умного фильтра.
<?
/*
* выбрать ID SKU для установки SKU по умолчанию, исходя из умного фильтра.
* */
function getOffersSelectedByFilter(&$arResult, &$arParams, $component){
//https://pai-bx.com/wiki/1c-bitrix/2357-filtered-sku-in-products-list/
if(!empty($arParams['FILTER_NAME'])){
global ${$arParams['FILTER_NAME']};
$FILTER = ${$arParams['FILTER_NAME']};
if(!empty($FILTER) && !empty($FILTER['OFFERS']) ) {
@EscApp2
EscApp2 / bitrix import\export users
Created April 16, 2024 08:12 — forked from SeRGei93/bitrix import\export users
перенос пользователей битрикс
Если перед вами встала задача по переносу пользователей из одного Битрикс в другой, то сделать это достаточно просто.
Для начала составьте таблицу соответствия групп пользователей, где ключи - id группы пользователей на первом сайте, а значения id соответствующей ему группы пользователей на втором. Примерно так:
$tableOfGroups = [
'1' => 1,
'2' => 2,
'3' => 3,
'4' => 4,
'5' => 9,
@EscApp2
EscApp2 / auto_wrap.css
Last active April 13, 2024 10:16
Get Vk video thumb thumbnail embed iframe
.youtube_auto_wrap{
position:relative;
}
.youtube_auto_wrap .youtube_auto_wrap__preview{
z-index: 10;
top: 0;
bottom: 0px;
left: 0px;
right: 0px;