Skip to content

Instantly share code, notes, and snippets.

@qwertik17
qwertik17 / redirect_domain.php
Created June 3, 2019 06:55
redirect form multidomain for modx revo
<?php
$parent_id = $modx->resource->parent;
if ($parent_id == 0) {
return;
}
$parents = $modx->getParentIds($modx->resource->id, 10, array('context' => 'web'));
$parents = array_reverse($parents);
if ($parents[1] == 21) {
if ($cur_catalog = $modx->getObject('modResource',$parents[3])) {
if ($only_moskow = $cur_catalog->getTVvalue('only_moskow')){
@qwertik17
qwertik17 / priority_by_cron.php
Created June 3, 2019 06:58
change priority resources for modx revo
<?php
$templates = array(13,18,19);
foreach ($templates as $template) {
//Получаем количество товаров с положительным рейтингом
$query = $modx->newQuery('modResource');
$query->select(array('modResource.id as id','TemplateVarResources.value as value'));
$query->innerJoin('modTemplateVarResource','TemplateVarResources');
$query->where(array(
'TemplateVarResources.tmplvarid:=' => '133',
@qwertik17
qwertik17 / get_parent_tv.php
Created June 3, 2019 07:05
Get parent tv for modx revo
<?php
if (!$tv) return;
$tv_value = $modx->resource->getTVvalue($tv);
if (!$tv_value) {
$catalog_sections = false;
$parents_array = $modx->getParentIds($modx->resource->id);
foreach ($parents_array as $parent) {
if ($parent !== 0) {
$obj = $modx->getObject('modResource',$parent);
$tv_value = $obj->getTVvalue($tv);
@qwertik17
qwertik17 / domclick.php
Created June 3, 2019 07:08
Domclick feed for modx revo
<?php
require_once MODX_ASSETS_PATH . 'ArrayToXML.php';
$feeds = $developer = $complexes = $sales_info = array();
$site_url = $modx->getOption('site_url');
//Информация о застройщике
$developer['id'] = $developer_id;
$developer['name'] = $developer_name;
$developer['phone'] = $developer_phone;
@qwertik17
qwertik17 / custom_plugin.php
Created June 3, 2019 07:13
Custom plugin for resources modx revo
<?php
$id = $resource->get('id');
$currentRes = $modx->getObject('modResource', $id);
$template = $currentRes->get('template');
//Шаблон товара "Кухня"
if ($template == 13) {
$cg = 'k_color_groups';
$sg = 'k_style_groups';
@qwertik17
qwertik17 / crm_class.php
Created June 3, 2019 07:15
Service crm
<?php
class mcrm {
public $baseUrl = "******";
public $resto_key = "****";
function __construct(modX &$modx, array $config = array())
{
$this->modx =& $modx;
@qwertik17
qwertik17 / webconnector.php
Created June 3, 2019 07:51
webconnector for ajax requests in frontend
<?php
require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/config.core.php';
require_once MODX_CORE_PATH . 'model/modx/modx.class.php';
$modx = new modX();
$modx->initialize('web');
$modx->getService('error', 'error.modError', '', '');
$path = MODX_CORE_PATH.'components/ajax/processors/web/';
@qwertik17
qwertik17 / client_config
Created November 14, 2019 07:40
Add groups & fields for MODx ClientConfig
<?php
//СОЗДАНИЕ ИЛИ ОБНОВЛЕНИЕ ГРУПП
$groups = array(
array('id' => 1,'sortorder' => 1,'label' => 'Общие'),
array('id' => 2,'sortorder' => 2,'label' => 'Почта'),
array('id' => 3,'sortorder' => 3,'label' => 'Политика и куки'),
array('id' => 4,'sortorder' => 4,'label' => 'Социальные сети'),
);
foreach ($groups as $group)
@qwertik17
qwertik17 / add_new_products.php
Last active June 17, 2020 07:04
Добавляем и обновление товаров с сайта донора
<?php
define(PICTURE_UPLOAD_PATH, MODX_ASSETS_PATH . 'images/vhodnye/');
$mes = array();
$bravo = $modx->getService('bravo', 'bravo', MODX_CORE_PATH.'components/bravo/');
$data = $bravo->getImport(); //Весь каталог
$products = $bravo->getProducts($data); //Все товары с Браво
$colors = $bravo->getIdsColors($data); //Все цвета с Браво
$categories = $bravo->getCategoriesIds(); //Список категорий
$siteProducts = $bravo->getSiteProductsBravo([28]); //Все товары входных дверей с сайта
@qwertik17
qwertik17 / getTVvalues
Created June 17, 2020 06:54
Получаем все уникальные значения ТВ во всех ресурсах
<?php
$res = array();
$q = $modx->newQuery('modTemplateVarResource', array('tmplvarid' => $tv_id));
$template_id = 28;
$template_id = explode(',',$template_id);
$q->innerJoin('modResource', 'modResource', "modResource.id = modTemplateVarResource.contentid");
$q->select('contentid,value,modResource.template');
$q->where(array(
'modResource.template:IN' => $template_id,
'modResource.published' => 1,