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 / mage_form_validation.markdown
Last active December 6, 2016 10:26
Magento. Form validation

Form validation

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

How to

Need form id attribute and add to required fields required-entry class for define what that field must be filled and validate-email for check that current field must be valid email.

@evgv
evgv / mage_load_layout_section.markdown
Created December 3, 2016 14:10
Magento. Load layout section

Load layout section

Mostly uses for build a system with Ajax asynchronous reload some blocks without reload full page.

Load section

Loaded section name checkout_onepage_shippingmethod example from _getShippingMethodsHtml() method of class Mage_Checkout_OnepageController

    
    $layout = $this->getLayout();
    
@evgv
evgv / cron.markdown
Last active February 22, 2017 14:27
Cron

Cron

The list will be supplemented

Usage

View user crontab

    cronab -l
@evgv
evgv / mage_varien_backtrace.markdown
Created December 1, 2016 15:40
Magento. Varien backtrace

Varien backtrace

  Mage::log(Varien_Debug::backtrace(true, true), null, 'backtrace.log');
@evgv
evgv / mage_close_controller_for_unauthenticated_users.markdown
Created November 30, 2016 14:32
Magento. Close controller for not unauthenticated users.

Close controller for not unauthenticated users

Add into your controller

    /**
     * Action predispatch    
     *   
     * Check customer authentication for some actions     
 */ 
$this->getLayout()->getBlock('head')->getTitle();
@evgv
evgv / mage_add_pagination_to_custom_collection.markdown
Created November 30, 2016 10:10
Magento. Add pagination to custom collection.

Add pagination to custom collection

Modify _prepareLayout() method of class what render your template

    protected function _prepareLayout()
    {
        parent::_prepareLayout();
@evgv
evgv / chrome_browser_dev_tools.markdown
Last active December 1, 2016 09:38
Chrome browser. Developer tools

Chrome rowser developer tools tricks

Quick file switching

If you’ve used Sublime Text, you probably can’t live without its "Go to anything" overlay. You will be happy to hear that dev tools has it too. Press Ctrl + P (Cmd + P on Mac) when DevTools is opened, to quickly search for, and open any file in your project.

Go to line

After you’ve opened a file in the Sources tab, DevTools allows you to easily jump to any line in it. To do so press Ctrl + G for Windows and Linux, (or Cmd + L for Mac), and type in your line number.

@evgv
evgv / mage_subscribe_customer_on_checkout.markdown
Last active November 28, 2016 15:54
Magento. Subscribe customer on chekout.

Subscribe customer on chekout

Add input to html

  
   <input type="checkbox" name="is_subscribed" value="1"/>
@evgv
evgv / mage_progammatically_subscribe_and_unsubscribe_newsletter_subscribers.markdown
Created November 28, 2016 13:03
Magento. Programmatically Subscribe and Unsubscribe Newsletter Subscribers

Programmatically Subscribe and Unsubscribe Newsletter Subscribers

Subscribe

  Mage::getModel('newsletter/subscriber')->subscribe('[email protected]');

Unsubscribe