Skip to content

Instantly share code, notes, and snippets.

View ilyautkin's full-sized avatar

Ilya Utkin ilyautkin

View GitHub Profile
<?php
define('MODX_API_MODE', true);
require 'index.php';
// Instantiate the Commerce class
$path = $modx->getOption('commerce.core_path', null, MODX_CORE_PATH . 'components/commerce/') . 'model/commerce/';
$params = ['mode' => $modx->getOption('commerce.mode')];
/** @var Commerce|null $commerce */
$commerce = $modx->getService('commerce', 'Commerce', $path, $params);
if (!($commerce instanceof Commerce)) {
<?php
$client = $modx->getService('rest', 'rest.modRest', null, ['headers' => ['X-Auth-Token' => $token]]);
$client->setOption('format','json');
$client->setOption('suppressSuffix','true');
$data = $client->get(self::API_URL . 'Positions/', ['delta' => '2023-01-01'])->process();
<?php
/**
* pThumb
* Copyright 2013, 2014 Jason Grant
*
* Please see the GitHub page for documentation or to report bugs:
* https://github.com/oo12/phpThumbOf
*
* Forked from phpThumbOf 1.4.0
* Copyright 2009-2012 by Shaun McCormick <shaun@modx.com>
@ilyautkin
ilyautkin / download-db.php
Created January 31, 2023 04:40 — forked from bezumkin/download-db.php
Download MODX database from production server
<?php
require 'config.core.php';
require MODX_CORE_PATH . 'config/' . MODX_CONFIG_KEY . '.inc.php';
$filename = $dbase . '-' . date('Y-m-d') . '.sql.gz';
$mime = "application/x-gzip";
header('Content-Type: ' . $mime);
header('Content-Disposition: attachment; filename="' . $filename . '"');
#!/bin/bash
FILE=`date '+%Y%m%d-%H%M'`
USER=`whoami`
cd ~
mysqldump --skip-lock-tables -u$USER -p $USER > dump.sql
rm -rf www/core/cache/*
zip -r $FILE www dump.sql
rm dump.sql
<?xml version="1.0" encoding="UTF-8"?>
<data package="contentblocks" exported="2021-05-04@16:36:10" total="4">
<cbCategory>
<id>1</id>
<name><![CDATA[Content]]></name>
<description><![CDATA[]]></description>
<sortorder>0</sortorder>
</cbCategory>
<cbCategory>
<id>2</id>
<?php
$modxminify = $modx->getService('modxminify','modxMinify', MODX_CORE_PATH . 'components/modxminify/model/modxminify/',[]);
$files = $modx->getCollection('modxMinifyFile');
$list = [];
foreach ($files as $file) {
if (empty($list[$file->group]) || !in_array($file->filename, $list[$file->group])) {
echo $file->filename . '<br>';
<?php
$resource_id = 39;
$priceList = [
'1000' => ['name' => '1 liter', 'price' => 2250],
'2500' => ['name' => '2,5 liter', 'price' => 5023],
];
$resource = $modx->getObject('modResource', $resource_id);
<?php
// Instantiate the Commerce class
$path = $modx->getOption('commerce.core_path', null, MODX_CORE_PATH . 'components/commerce/') . 'model/commerce/';
$params = ['mode' => $modx->getOption('commerce.mode')];
/** @var Commerce|null $commerce */
$commerce = $modx->getService('commerce', 'Commerce', $path, $params);
if (!($commerce instanceof Commerce)) {
return '<p class="error">Oops! It is not possible to view your cart currently. We\'re sorry for the inconvenience. Please try again later.</p>';
}