Skip to content

Instantly share code, notes, and snippets.

View evgv's full-sized avatar
🏠
Working from home

Eugene Zubkov evgv

🏠
Working from home
View GitHub Profile
@evgv
evgv / php_setlocale.markdown
Last active February 8, 2017 13:29
PHP. Setlocale.

Set ru locale for date

Use [setlocale][setlocale-man], [strftime][strftime-man], [strtotime][strtotime-man], [date][date-man] and [time][time-man].

Unix hosting

Meta with charset utf-8

 
@evgv
evgv / mage_add_customer_attribute.markdown
Last active May 15, 2017 13:46
Magento. Add customer attribute.

Add customer attribute

Resources in config.xml

        
<resources>
    <{{MODEL_ALIAS}}_setup>
        <setup>
            <module>{{Vendor_Extension}}</module>
@evgv
evgv / mage2_remove_block_from_layout.markdown
Last active January 2, 2017 14:05
Magento 2. Remove block from layout

Remove block from layout

As example remove footer block from homepage.

We need change/rewrite layout cms_index_index.xml in base/luma or in any custom theme, namely add

Full code example:

    
@evgv
evgv / mage_get_product_options_from_quote_item.markdown
Created December 27, 2016 09:16
Magento. Get product options from quote item

Get product options from quote item

  
    /* @var $quote Mage_Sales_Model_Quote */
    $quote = Mage::getSingleton('checkout/session')->getQuote()
    
    $items = $quote->getAllVisibleItems();
    
    $orderedItemsOptions = array();
@evgv
evgv / Cart.php
Last active December 15, 2016 15:12
Magento. Use quote currency for PayPal
<?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
@evgv
evgv / mage_fluch_varnich_cache.markdown
Last active January 5, 2017 13:28
Magento. Flush varnish cache

Flush varnish cache, work with extension Phoenix_VarnishCache

Use method clean() from class Phoenix_VarnishCache_Model_Control for flush varnich cache, more info you can see in this class.

  
    /**
     * Flush all varnish cache
     * 
 * @var cache Phoenix_VarnishCache_Model_Control
@evgv
evgv / mage_remove_use_select_links_for_grid.markdown
Created December 12, 2016 14:49
Magento. Remove use select all links in grid
<a href="mailto:?subject=I wanted you to see this site&amp;body=Check out this site http://www.website.com."
title="Share by Email">
<img src="http://png-2.findicons.com/files/icons/573/must_have/48/mail.png">
</a>
@evgv
evgv / mage_ajax_form_validation
Created December 6, 2016 11:42
Magento. Ajax form validation
# Ajax form validation
@evgv
evgv / mage_add_custom_form_validation_pattern.markdown
Last active December 6, 2016 11:48
Magento. Add custom form validation pattern

Add custom form validation pattern

Resource for test [regular expression][test-regexp].

Examples lookin for into js/prototype/validation.js on line 414 and there you can add newcustom validation pattern.

Structure
    ['{className}', '{error message}', function(v) {