Skip to content

Instantly share code, notes, and snippets.

View larascasse's full-sized avatar

FLorent Berenger larascasse

View GitHub Profile
@larascasse
larascasse / product_attribute_installer.php
Created February 25, 2019 13:37 — forked from antoinekociuba/product_attribute_installer.php
Magento Product Attribute installer script.
<?php
/**
* Product Attribute Installer
*/
try {
/* @var $installer Mage_Catalog_Model_Resource_Setup */
$installer = $this;
$installer->startSetup();
@larascasse
larascasse / video-extract.rb
Created September 21, 2016 15:16 — forked from slhck/video-extract.rb
Video Extraction for Ruby/FFmpeg
#!/usr/bin/env ruby
# Batch encodes videos from a list of editing points
# Author: Werner Robitza <werner.robitza@univie.ac.at>
FFMPEG = "ffmpeg" # => path to the FFmpeg executable
COPY = false # => if set to true, just does a bitstream copy
# => if set to false, encoding options below are used
OVERWRITE = "-n" # => set to "-n" if you just want to keep files that exist
@larascasse
larascasse / gist:f74186e362897489f66a2290d212796f
Created May 30, 2016 09:46 — forked from vestman/gist:5d9ce0c51869b33a8f51
Magento - Copy/duplicate Categories
<?php
if(!is_numeric($_GET['id']))die('Please specify a category ID');
$catId = $_GET['id'];
$xml = simplexml_load_file('app/etc/local.xml');
$host = $xml->global->resources->default_setup->connection->host;
$username = $xml->global->resources->default_setup->connection->username;
$password = $xml->global->resources->default_setup->connection->password;
@larascasse
larascasse / Events fired during order submit process
Created April 29, 2016 15:38 — forked from adrian-green/Events fired during order submit process
Main events fired during one-page checkout in Magento
### Events during order submit process
`core_copy_fieldset_customer_account_to_quote`
`core_copy_fieldset_sales_convert_quote_to_order`
`sales_convert_quote_to_order`
`core_copy_fieldset_sales_convert_quote_address_to_order`
`sales_convert_quote_address_to_order`
`core_copy_fieldset_sales_convert_quote_address_to_order_address`
`sales_convert_quote_address_to_order_address`
@larascasse
larascasse / gist:07ae7136dbf307e46601
Created March 11, 2016 10:26 — forked from davekelly/gist:3918937
Add Intercom.io snippet to Magento site
<?php
/*
* /app/design/frontend/default/your_theme/template/page/intercom-io.phtml
*/
// Settings for the intercom.io app.
if( $this->helper('customer')->isLoggedIn() ): ?>
<?php $customer = Mage::helper('customer')->getCustomer()->getData(); ?>
<script id="IntercomSettingsScriptTag">
<?php
class EcomDev_Optimization_Model_Rule_Observer extends Mage_CatalogRule_Model_Observer
{
protected $_preloadedPrices = array();
public function beforeCollectTotals(Varien_Event_Observer $observer)
{
$quote = $observer->getQuote();
$date = Mage::app()->getLocale()->storeTimeStamp($quote->getStoreId());
<?php
/**
* Optimized version of attribute source options model
*
* That allows to preload options once and reuse them instead of doing calls to db all the time
*
*/
class EcomDev_Optimization_Model_Resource_Attribute_Source_Table
extends Mage_Eav_Model_Entity_Attribute_Source_Table

Magento Snippets

Download extension manually using pear/mage

Pear for 1.4, mage for 1.5. File downloaded into /downloader/.cache/community/

./pear download magento-community/Shipping_Agent
./mage download community Shipping_Agent

Clear cache/reindex

<?php
require_once 'app/Mage.php';
Mage::app('default');
$productIds = array(100, 101, 102);
$option = array(
'title' => 'Test Option',
'type' => 'file',
'is_require' => 1,
@larascasse
larascasse / config-haproxy.sh
Created February 9, 2012 11:36 — forked from jsermeno/config-haproxy.sh
Node.js server and Web Sockets on Amazon EC2 with Express.js and Socket.IO - http://catchvar.com/nodejs-server-and-web-sockets-on-amazon-ec2-w
# HAProxy config
mkdir /etc/haproxy
cat > /etc/haproxy/haproxy.cfg << EOF
global
maxconn 4096
defaults
mode http