Skip to content

Instantly share code, notes, and snippets.

@nhp
nhp / gist:3456902
Created August 24, 2012 23:03 — forked from fbrnc/gist:3418992
Magento Cache Warming
curl --silent http://example.com/sitemap.xml | xpath -q -e "/urlset/url/loc/text()" > tmp.urls && siege -v -c 1 -r `cat tmp.urls | wc -l` -f tmp.urls
@nhp
nhp / gist:3618629
Created September 4, 2012 08:42 — forked from Vinai/gist:1205913
Bug with store cookie handling in Magento up to 1.6 if specifying a non-default store MAGE_RUN_CODE
--- a/app/code/core/Mage/Core/Model/App.php
+++ b/app/code/core/Mage/Core/Model/App.php
@@ -511,11 +511,7 @@ class Mage_Core_Model_App
if ($this->_currentStore == $store) {
$store = $this->getStore($store);
- if ($store->getWebsite()->getDefaultStore()->getId() == $store->getId()) {
- $this->getCookie()->delete(Mage_Core_Model_Store::COOKIE_NAME);
- } else {
- $this->getCookie()->set(Mage_Core_Model_Store::COOKIE_NAME, $this->_currentStore, true);
{
{I have|I've} been {surfing|browsing} online more than {three|3|2|4} hours today, yet I never found any interesting article like yours. {It's|It
is} pretty worth enough for me. {In my opinion|Personally|In my view}, if all {webmasters|site owners|website owners|web owners} and bloggers made good content as
you did, the {internet|net|web} will be {much more|a lot more}
useful than ever before.|
I {couldn't|could not} {resist|refrain from} commenting. {Very well|Perfectly|Well|Exceptionally well} written!|
{I will|I'll} {right away|immediately} {take hold of|grab|clutch|grasp|seize|snatch}
your {rss|rss feed} as I {can not|can't} {in finding|find|to find} your {email|e-mail} subscription {link|hyperlink} or {newsletter|e-newsletter} service. Do {you have|you've} any?
{Please|Kindly} {allow|permit|let} me {realize|recognize|understand|recognise|know} {so that|in order that} I {may just|may|could} subscribe.
Thanks.|
<?php
/*
To make the cleaning expired carts automatic, override cleanExpiredQuotes with the following
version which will also take care of the old active carts: app/code/core/Mage/Sales/Model/Observer.php
*/
public function cleanExpiredQuotes($schedule)
{
// extending limit
delimiter ;;
drop procedure if exists build_catalog;;
create procedure build_catalog(IN categories INT, IN products INT)
begin
SET @category_count = 1;
SET @CATNAMEPREFIX = "Category ";
SET @CATURLKEYPREFIX = "cat-";
SET @CATURLPATHPREFIX = "catpath-";
SET @ROOTCATEGORY = 2;
SET @INCLUDEINMENU = 1;
#!/usr/bin/env php
<?php
//
// PHP REPL with initialized Magento environment
//
// Thanks to https://github.com/d11wtq/boris
//
// Drop this script in your $PATH and run it anywhere in a Magento directory tree to start the REPL
//
<?php
/**
* Generate modman file from Magento Connect 2.0 package.xml
*
* Usage:
*
* php package2modman.php path/to/package.xml > path/to/modman
*
*/
require_once(__DIR__ . "/../www/app/Mage.php");

Magento Code Snippets

Download extension manually using mage

./mage config-set preferred_state stable
./mage clear-cache
./mage sync
./mage download community Module_Name
@nhp
nhp / Observer.php
Last active December 15, 2016 17:27 — forked from bastianccm/Observer.php
<?php
/**
* Class Extra_Static_Model_Observer
*
* @category Model
* @package Extra_Static
* @author AOE Magento Team <[email protected]>
* @license none none
* @link www.aoe.com
@nhp
nhp / Magento\Framework\Console\Cli
Created April 27, 2016 17:57 — forked from antonkril/Magento\Framework\Console\Cli
Hackathon Extension Point for Setup App
<?php
namespace Magento\Framework\Console;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Application as SymfonyApplication;
use Magento\Framework\App\Bootstrap;
use Magento\Framework\Filesystem\Driver\File;