Skip to content

Instantly share code, notes, and snippets.

View SchumacherFM's full-sized avatar

Cyrill Schumacher SchumacherFM

View GitHub Profile
@SchumacherFM
SchumacherFM / Config.php
Last active March 4, 2018 19:44 — forked from colinmollenhour/Config.php
Magento config.php -> Stampede-Resistant Config Cache
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
@SchumacherFM
SchumacherFM / bench_test.go
Last active May 18, 2022 08:50
GoLang Benchmark: Map, StringSlice, Array, StructSlice
package main
// run with: $ go test --bench=. -test.benchmem .
// @see https://twitter.com/karlseguin/status/524452778093977600
import (
"math/rand"
"strconv"
"testing"
)
@SchumacherFM
SchumacherFM / PATCH_SUPEE-389_EE_1.12.0.2_v2.sh
Created September 16, 2014 07:28 — forked from piotrekkaminski/PATCH_SUPEE-389_EE_1.12.0.2_v2.sh
Magento PATCH_SUPEE-389 to fix URL reindex bug. This bug regenerates in every run new URLs for existing product URLs.
#!/bin/bash
# Patch apllying tool template
# v0.1.2
# (c) Copyright 2013. Magento Inc.
#
# DO NOT CHANGE ANY LINE IN THIS FILE.
# 1. Check required system tools
_check_installed_tools() {
local missed=""
@SchumacherFM
SchumacherFM / compare.md
Last active August 29, 2015 14:06
GoLang ListenAndServeTLS vs ListenAndServe
@SchumacherFM
SchumacherFM / cron.sh
Created August 18, 2014 00:06
Magento cron.sh file for OSX
#!/bin/sh
# location of the php binary
if [ ! "$1" = "" ] ; then
CRONSCRIPT=$1
else
CRONSCRIPT=cron.php
fi
MODE=""
if [ ! "$2" = "" ] ; then
@SchumacherFM
SchumacherFM / createTestCustomers.sql
Last active April 3, 2020 20:45
Magento: Different SQL Queries to truncate tables, create anonymous, test customers out of your existing and round all prices to get rid of the decimals.
UPDATE `customer_entity`
SET `email` = concat('test+', entity_id, '@aGmailDomain.com');
UPDATE `customer_entity_varchar`
SET `value` = CONCAT(MD5(concat('qXpassword', entity_id)), ':qX')
WHERE `attribute_id` = 12;
UPDATE `sales_flat_order`
SET customer_email = concat('test+', IFNULL(customer_id, entity_id), '@aGmailDomain.com');
@SchumacherFM
SchumacherFM / CatalogDeleteNull.sql
Last active January 15, 2023 15:41
Magento: Remove all NULL values from catalog_*_entity_* tables
DELETE FROM catalog_category_entity_datetime WHERE `value` IS NULL;
DELETE FROM catalog_category_entity_decimal WHERE `value` IS NULL;
DELETE FROM catalog_category_entity_int WHERE `value` IS NULL;
DELETE FROM catalog_category_entity_text WHERE `value` IS NULL;
DELETE FROM catalog_category_entity_varchar WHERE `value` IS NULL;
DELETE FROM catalog_product_entity_datetime WHERE `value` IS NULL;
DELETE FROM catalog_product_entity_decimal WHERE `value` IS NULL;
DELETE FROM catalog_product_entity_gallery WHERE `value` IS NULL;
DELETE FROM catalog_product_entity_group_price WHERE `value` IS NULL;
@SchumacherFM
SchumacherFM / aExplanation.md
Last active April 20, 2023 10:58
Magento Backend Reindex and fastcgi_finish_request()

Backend Section: Index Management

  • Nginx 1.4
  • PHP 5.5 FPM

Doc: fastcgi_finish_request

Clicking on one of the Reindex Data links executes the reindex process and immediately shows the URL from action preReindexProcess() but clicking on that link to initiate a new request takes as long as it takes to wait for the reindexing.

So something is still using the same connection and waits to finish the previous request. How to initiate a new request without waiting for the previous one?

@SchumacherFM
SchumacherFM / collection.php
Last active August 29, 2015 14:01
Singelton Collection Pattern #Magento
<?php
class Zookal_Core_Helper_Data extends Mage_Core_Helper_Abstract
{
private $_objectCache = [];
public function getCollectionSingleton($modelClass, array $collectionOptions = null, $cacheKey = null)
{
$cacheKey = null === $cacheKey ? $modelClass . '/' . json_encode($collectionOptions) : (string)$cacheKey;
// $cacheKey = md5($cacheKey); if preferred
@SchumacherFM
SchumacherFM / Explanation.md
Last active December 9, 2019 18:19
Magento: Optimize URL rewrite frontend select for categories

After I have seen that some 3rd party modules duplicate the core_url_rewrite table to store there additional category rewrite information in it (1), I came to the conclusion that it should be save to remove the joinLeft() in the flat table classes.

Instead of the joinLeft() you simply refer to the column main_table.url_path as request_path in the tables catalog_category_flat_store_[StoreId]. Please see the new methods.

Downside: To get the correct rewrites in the frontend you need to run the reindex for catalog_category_flat. During this reindex the correct rewrites will be inserted into the column catalog_category_flat_store_X.url_path.

Footnotes:

(1) the join with the core_url_rewrite takes for large product collection really long when you only need the correct rewrite for the categories. This can save per request around ~0.Xsec.