Skip to content

Instantly share code, notes, and snippets.

View larascasse's full-sized avatar

FLorent Berenger larascasse

View GitHub Profile
@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
level street_address
city 3ème Arrondissement Paris
state Île-de-France
sw_lat 48.86710531970849
parent_hash[city] 3rd arrondissement of Paris
accuracy 8
sw_lng 2.354801119708498
parent_hash[accuracy] 5
parent_hash[ne_lat] 48.8711592
parent_hash[sw_lat] 48.8564786
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
MyCustomNavController* navController = (MyCustomNavController*)self.parentViewController;
if( [scrollView.panGestureRecognizer translationInView:self.view].y < 0.0f ) {
[navController setExpanded:YES animated:YES];
} else if ([scrollView.panGestureRecognizer translationInView:self.view].y > 0.0f ) {
[navController setExpanded:NO animated:YES];
}
}
<?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 / gist:7869671
Last active December 30, 2015 18:49
Magento _ cron import
<?php
//STEP 1: Save the below file as Cron_Import.php on the Magento base folder.
//STEP 3: Test this on your SSH login to check if this works on command line. Use the below command
//wget -T0 -t1 -O - http://<www.example.com>/Cron_Import.php/?files=3XSEEEE.csv
//uncommentwhen moved to server - to ensure this page is not accessed from anywhere else
//if ($_SERVER['REMOTE_ADDR'] !== '<your server ip address') {
// die("You are not a cron job!");
//}
@larascasse
larascasse / gist:7869810
Created December 9, 2013 09:47
Magmi Datapump
Sample Datapump API integration script example importing single item
// assuming that your script file is located in magmi/integration/scripts/myscript.php,
// include "magmi_defs.php" and "magmi_datapump.php" first (note: there are two folders "inc" in different subfolders).
require_once("../../inc/magmi_defs.php");
require_once("../inc/magmi_datapump.php");
// create a Product import Datapump using Magmi_DatapumpFactory
@larascasse
larascasse / gist:7984383
Last active December 31, 2015 12:09
Magento - load image gallery with product collection
function addMediaGalleryAttributeToCollection(Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $_productCollection) {
$_mediaGalleryAttributeId = Mage::getSingleton('eav/config')->getAttribute('catalog_product', 'media_gallery')->getAttributeId();
$_read = Mage::getSingleton('core/resource')->getConnection('catalog_read');
$_mediaGalleryData = $_read->fetchAll('
SELECT
main.entity_id, `main`.`value_id`, `main`.`value` AS `file`,
`value`.`label`, `value`.`position`, `value`.`disabled`, `default_value`.`label` AS `label_default`,
`default_value`.`position` AS `position_default`,
`default_value`.`disabled` AS `disabled_default`
@larascasse
larascasse / gist:8666779
Created January 28, 2014 12:27
Magento, restore all product attributes to default store
DELETE FROM catalog_product_bundle_option_value WHERE store_id <> 0;
DELETE FROM catalog_product_entity_datetime WHERE store_id <> 0;
DELETE FROM catalog_product_entity_decimal WHERE store_id <> 0;
DELETE FROM catalog_product_entity_gallery WHERE store_id <> 0;
DELETE FROM catalog_product_entity_int WHERE store_id <> 0;
DELETE FROM catalog_product_entity_media_gallery_value WHERE store_id <> 0;
DELETE FROM catalog_product_entity_text WHERE store_id <> 0;
DELETE FROM catalog_product_entity_varchar WHERE store_id <> 0;
DELETE FROM catalog_product_option_price WHERE store_id <> 0;

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

@larascasse
larascasse / gist:8835129
Created February 5, 2014 23:01
Magento order
$id=1; // get Customer Id
$customer = Mage::getModel('customer/customer')->load($id);
$transaction = Mage::getModel('core/resource_transaction');
$storeId = $customer->getStoreId();
$reservedOrderId = Mage::getSingleton('eav/config')->getEntityType('order')->fetchNewIncrementId($storeId);
$order = Mage::getModel('sales/order')
->setIncrementId($reservedOrderId)
->setStoreId($storeId)