Skip to content

Instantly share code, notes, and snippets.

View SergeyZaigraev's full-sized avatar

Sergey Zaigraev SergeyZaigraev

View GitHub Profile
@SergeyZaigraev
SergeyZaigraev / dateText.php
Created January 16, 2018 04:47
Iblock custom property type
<?
class CCustomTypeElementDateText{
//описываем поведение пользовательского свойства
function GetUserTypeDescription() {
return array(
'PROPERTY_TYPE' => 'S',
'USER_TYPE' => 'history',
'DESCRIPTION' => 'История просрочки — дата со значением', //именно это будет выведено в списке типов свойств во вкладке редактирования свойств ИБ
//указываем необходимые функции, используемые в создаваемом типе
@SergeyZaigraev
SergeyZaigraev / smart_url_for_sitemap.php
Created October 27, 2017 03:27
Smart filter links for sitemap
<? require_once($_SERVER['DOCUMENT_ROOT'] . "/bitrix/modules/main/include/prolog_before.php");
use Bitrix\Main\Loader;
use Bitrix\Iblock\PropertyIndex;
Loader::includeModule("iblock");
CBitrixComponent::includeComponentClass('bitrix:catalog.smart.filter');
$iblockID = 3;
$iblockSkuID = 4;
@SergeyZaigraev
SergeyZaigraev / crontab_sitemap_delete_event_handlers_for_map.php
Created October 17, 2017 05:59
Cron site map with custom xml template
<?php
use \Bitrix\Main\Application;
require_once($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php");
global $APPLICATION;
$POST_RIGHT = $APPLICATION->GetGroupRight("main");
if ($POST_RIGHT < "W")
$APPLICATION->AuthForm("Доступ запрещен");
@SergeyZaigraev
SergeyZaigraev / result_modifier.php
Created October 13, 2017 07:59
Smart filter. Build smart url
// SMART FILTER LINK //
$arSectionInfo = CIBlockSection::GetByID($arSmartFilter['SECTION_ID'])->GetNext();
$sefSmartUrl = $arSectionInfo['SECTION_PAGE_URL'] . "filter/#SMART_FILTER_PATH#/";
foreach($arResult["ITEMS"] as $PID => $arItem)
{
$code = null;
if ($arItem["CODE"]){
$code = toLower($arItem["CODE"]);
@SergeyZaigraev
SergeyZaigraev / sitemap_runtime_custom.php
Created October 11, 2017 06:48
Custom sitemap runtime. Add new tag: changefreq, priority
<?
use Bitrix\Main\IO\File;
use Bitrix\Main\Text\Converter;
use Bitrix\Seo\SitemapRuntime;
class SitemapRuntimeCustom extends SitemapRuntime
{
const ENTRY_TPL_NEW = '<url><loc>%s</loc><lastmod>%s</lastmod><changefreq>weekly</changefreq><priority>0.9</priority></url>';
@SergeyZaigraev
SergeyZaigraev / sitemap_run.php
Last active March 17, 2024 22:25
Bitrix. Generation of site map on cron
<?
//Для запуска необходимой карты укажите в адресе ее ID, пример:
//sitemap_run.php?action=sitemap_run&ID=2&lang=ru
$_SERVER['DOCUMENT_ROOT'] = realpath(dirname(__FILE__) . '/../../..');
if($argv){
unset($argv[0]);
@SergeyZaigraev
SergeyZaigraev / translit-image.php
Created July 13, 2017 06:10
translit name all image in IB
<?php
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
$iblockId = (int)$_REQUEST['iblock'];
$page = isset($_REQUEST['page']) ? (int)$_REQUEST['page'] : 1;
$pageSize = 70;
$isEnd = true;
if ($iblockId <= 0)
{
@SergeyZaigraev
SergeyZaigraev / sql
Created June 20, 2017 02:53
Битрикс. Ошибка с БД. SQL fix request
/*
если при проверке системы появилась ошибка
ALTER TABLE `b_user_hit_auth` MODIFY `TIMESTAMP_X` datetime NULL DEFAULT NULL ;
лечится:
ALTER TABLE `b_user_hit_auth` CHANGE `TIMESTAMP_X` `TIMESTAMP_X` DATETIME NULL DEFAULT NULL; */
@SergeyZaigraev
SergeyZaigraev / .htaccess
Created June 19, 2017 08:31
Битрикс. Кэширование браузера. client cache
# Включаем кэш в браузерах посетителей
<ifModule mod_headers.c>
# Все html и htm файлы будут храниться в кэше браузера один день
<FilesMatch "\.(html|htm)$">
Header set Cache-Control "max-age=43200"
</FilesMatch>
# Все css, javascript и текстовые файлы будут храниться в кэше браузера одну неделю
<FilesMatch "\.(js|css|txt)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>
@SergeyZaigraev
SergeyZaigraev / class.php
Created June 7, 2017 05:16
Simple product price. Битрикс. Получить цену с учетом скидок на простой товар.
$price = CCatalogProduct::GetOptimalPrice($getElemData['ID'], 1, $USER->GetUserGroupArray(), 'N');
$arDiscounts = CCatalogDiscount::GetDiscountByProduct($getElemData['ID'], $USER->GetUserGroupArray(), "N", array(),SITE_ID);
if(is_array($arDiscounts) && sizeof($arDiscounts) > 0) {
$final_price = CCatalogProduct::CountPriceWithDiscount($price['PRICE']['PRICE'], $price['PRICE']['CURRENCY'], $arDiscounts);
$this->arResult['PRODUCT']['PRICE'] = CCurrencyLang::CurrencyFormat($final_price,$price['PRICE']['CURRENCY']);
}