Skip to content

Instantly share code, notes, and snippets.

View dleone81's full-sized avatar
💭
I may be slow to respond.

Domenico dleone81

💭
I may be slow to respond.
View GitHub Profile
@dleone81
dleone81 / varnish
Last active January 3, 2016 06:13
Varnish configuration /etc/default/varnish
# Configuration file for varnish
#
# /etc/init.d/varnish expects the variables $DAEMON_OPTS, $NFILES and $MEMLOCK
# to be set from this shell script fragment.
#
# Note: If systemd is installed, this file is obsolete and ignored. You will
# need to copy /lib/systemd/system/varnish.service to /etc/systemd/system/ and
# edit that file.
# Should we start varnishd at boot? Set to "no" to disable.
@dleone81
dleone81 / default_3.0.vcl
Created January 3, 2016 16:33
Adding ESI support to PHOENIX-PageCache
C{
#include <errno.h>
#include <netinet/in.h>
#include <pthread.h>
#include <stdlib.h>
#include <string.h>
typedef void vas_f(const char *, const char *, int, const char *, int, int);
extern vas_f *VAS_Fail;
@dleone81
dleone81 / Magento_status_complete_array
Last active January 5, 2016 15:05
Set status COMPLETE for order array via PHP script
<?php
require_once 'app/Mage.php';
umask(0);
Mage::app();
$orders = array('200000674','200000676','200000678');
foreach ($orders as $k => $v) {
$order_id = $v;
$order = Mage::getModel('sales/order')->loadByIncrementId($order_id);
@dleone81
dleone81 / Magento_status_complete_single
Created January 5, 2016 15:04
Set status COMPLETE for single order via PHP script
<?php
require_once 'app/Mage.php';
umask(0);
Mage::app();
$order_id = '200000832';
$order = Mage::getModel('sales/order')->loadByIncrementId($order_id);
$order->setData('state', "complete");
$order->setStatus("complete");
$history = $order->addStatusHistoryComment('Order status changed via script.', false);
@dleone81
dleone81 / magento_flushcache.php
Last active January 8, 2016 16:53
Clean Magento cache via PHP file
<?php
/** Use this file to flush your cache via cron job
is useful to invalidate varnish cache
Magento 1.8.1
**/
require_once('app/Mage.php');
Mage::app()->getCacheInstance()->flush();
?>
@dleone81
dleone81 / functions.php
Last active January 13, 2016 14:51
Set required input checkout field
/**
Update functions.php into child theme
this script works for
http://www.iograficathemes.com/documentation/woocommerce-iva-field-premium/
See: https://docs.woothemes.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/
**/
remove_action( 'woocommerce_billing_fields', 'wciva_custom_billing_fields');
add_action( 'woocommerce_billing_fields', 'override_cf');
function override_cf( $fields ) {
@dleone81
dleone81 / functions.php
Last active June 27, 2024 18:42
Woocommerce get product type
/**
* is_type can be simple, variable, grouped, external
* woocommerce_single_product_summary is hook!
* Put this into your functions.php (child-theme)
**/
add_action( 'woocommerce_single_product_summary', 'get_product_type', 5 );
function get_product_type() {
global $post;
if( function_exists('get_product') ){
$product = get_product( $post->ID );
@dleone81
dleone81 / functions.php
Last active January 27, 2016 16:33
Add new column to woocommerce product grid, add custom fields value
add_filter( 'manage_edit-product_columns', 'admin_add_in_promo', 10, 2 );
function admin_add_in_promo($columns){
//remove column
//unset( $columns['tags'] );
//add column
$columns['in_promo'] = __( 'Promo');
return $columns;
}
add_action( 'manage_posts_custom_column', 'admin_show_in_promo', 10 );
function admin_show_in_promo( $column) {
@dleone81
dleone81 / functions.php
Last active February 1, 2016 14:59
Add or remove product to specific category based on product custom attributes
/**
* Add / Remove product to 'Angolo delle offerte' on product save action
**/
function update_product_category( $post_id ) {
global $post;
if(function_exists('get_product')) {
$product = get_product($post->ID);
if($product->is_type('variable')) {
$available_variations = $product->get_available_variations();
$catarray = array();
@dleone81
dleone81 / catalog_product_update.php
Created February 2, 2016 10:41
Magento update custom attribute via API SOAP2
<?php
$proxy = new SoapClient("http://www.mydomain.com/api/v2_soap/?wsdl");
$sessionId = $proxy->login("myuser", "mypass");
$update_data = array (
'additional_attributes' => array (
'single_data' => array (
array ('key' => 'foreign_visibility', 'value' => '1')
)