Skip to content

Instantly share code, notes, and snippets.

View magefast's full-sized avatar
🥶

Alex S magefast

🥶
View GitHub Profile
@magefast
magefast / get report sales count for email
Last active January 9, 2020 07:53
Magento - get report sales count for phone/email
<pre>
<?php
require_once dirname(__FILE__) . '/app/Mage.php';
Mage::app();
$fromDate = date('Y-m-d H:i:s', strtotime('2019-07-01 00:00:00'));
$toDate = date('Y-m-d H:i:s', strtotime('2019-07-31 23:59:59'));
$o = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('status','complete')->addAttributeToFilter('created_at', array('from'=>$fromDate, 'to'=>$toDate));
@magefast
magefast / Magento - get report sales count for email
Last active March 28, 2019 20:36
Magento - get report sales count for email
<pre>
<?php
require_once dirname(__FILE__) . '/app/Mage.php';
Mage::app();
$fromDate = date('Y-m-d H:i:s', strtotime("-2 years"));
$toDate = date('Y-m-d H:i:s', strtotime("-1 week"));
@magefast
magefast / XML - read and search by Tag attribute
Created February 25, 2019 09:05
XML - read and search by Tag attribute
<?php
$xml = simplexml_load_file('ppp.xml');
foreach ($xml->shop->offers->offer as $offer) {
$offerArray = _xml2array($offer);
$offerId = $offerArray['@attributes']['id'];
foreach ($offer->param as $p) {
@magefast
magefast / Magento - get Manufacturers, from SKU list
Created February 24, 2019 16:04
Magento - get Manufacturers, from SKU list
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
ini_set('time_limit', 180);
set_time_limit(180);
require_once dirname(__FILE__) . '/app/Mage.php';
$app = Mage::app('admin');
umask(0);
$skuList = '7038973, 7000845, 7039052, 7036176";
@magefast
magefast / Magento 1 - check if list of products without pictures
Created February 19, 2019 19:05
Magento 1 - check if list of products without pictures
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
ini_set('time_limit', 180);
set_time_limit(180);
require_once dirname(__FILE__) . '/app/Mage.php';
$app = Mage::app('admin');
umask(0);
@magefast
magefast / default.vcl
Created February 12, 2019 18:44
turpentine_varnish4_default.vcl
vcl 4.0;
C{
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <pthread.h>
static pthread_mutex_t lrand_mutex = PTHREAD_MUTEX_INITIALIZER;
void generate_uuid(char* buf) {
pthread_mutex_lock(&lrand_mutex);
long a = lrand48();
@magefast
magefast / crawler_detect.php
Created February 12, 2019 10:55 — forked from geerlingguy/crawler_detect.php
Detect crawlers/bots/spiders in PHP (simple and fast)
<?php
/**
* Check if the given user agent string is one of a crawler, spider, or bot.
*
* @param string $user_agent
* A user agent string (e.g. Googlebot/2.1 (+http://www.google.com/bot.html))
*
* @return bool
* TRUE if the user agent is a bot, FALSE if not.
@magefast
magefast / SCRIPT TO CHECK MAGENTO 1 SERVER REQUIREMENTS
Created February 10, 2019 11:47
SCRIPT TO CHECK MAGENTO 1 SERVER REQUIREMENTS
<?php
extension_check(array(
'curl',
'dom',
'gd',
'hash',
'iconv',
'mcrypt',
'pcre',
'pdo',
@magefast
magefast / JavaScript - test event keyup - for Barcode scaner test
Created February 3, 2019 17:50
JavaScript - test event keyup - for Barcode scaner test
<input type="text" name="test" id="test">
<script>
var t = '';
document.getElementById("test").addEventListener( 'keyup', function (e) {
console.log(e.keyCode);
if ( e.keyCode == 13 ) {
// Simulate clicking on the submit button.
// submitButton.click();
@magefast
magefast / Magento - add attribute to Attribute Set
Last active August 7, 2020 17:15
Magento - add attribute to all Attribute Sets
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once './app/Mage.php';
$attributeCode = 'faktstock_sklad';
$groupName = 'Для Заказа';
Mage::app();
Mage::getSingleton('core/translate')->setLocale('en_US')->init('frontend', true);