Skip to content

Instantly share code, notes, and snippets.

View SergeyZaigraev's full-sized avatar

Sergey Zaigraev SergeyZaigraev

View GitHub Profile
@SergeyZaigraev
SergeyZaigraev / resize-image.php
Last active October 16, 2023 03:52
Bitrix resize image 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 / gulpfile.js
Created May 12, 2017 08:59
Gulp for project. Необходимый минимум для оптимизации проекта на битре
var gulp = require('gulp');
var rename = require("gulp-rename");
var uglify = require('gulp-uglify');
var cleanCSS = require('gulp-clean-css');
var templateName = 'main';
var imagemin = require('gulp-imagemin');
gulp.task('imagemin',function () {
return gulp.src([
templateName + '/**/*.{png,gif,jpg,jpeg,svg}',
@SergeyZaigraev
SergeyZaigraev / package.json
Created May 12, 2017 09:00
Package for project BX
{
"devDependencies": {
"gulp": "^3.9.1",
"gulp-clean-css": "^2.0.13",
"gulp-imagemin": "^3.2.0",
"gulp-rename": "^1.2.2",
"gulp-uglify": "^2.0.0"
}
}
@SergeyZaigraev
SergeyZaigraev / subscription_user_group.php
Created May 15, 2017 06:39
Trigger for Email distribution. Пример собственного триггера.
<?
class SenderTriggerUserGroup extends \Bitrix\Sender\Trigger {
public function getName() {
return 'Первый заход на сайт (+группа)';
}
public function getCode() {
return "user_group";
}
@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']);
}
@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 / 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 / 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 / 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 / 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>';