Docker Compose Network

This example shows that how the static ip can be assigned to container and how to add another container network to a container. This can be done only for version 2 compose.

version: '2'

services:
  app:
    image: busybox
    command: ping www.google.com
    networks:
      app_net:
        ipv4_address: 10.0.0.10
  webapp:
    image: busybox
    command: ping www.yahoo.com
    network_mode: service:app
        

networks:
  app_net:
    driver: bridge
    ipam:
      driver: default
      config:
      - subnet: 10.0.0.0/24
        g...

Magento 2 Tips : Conditionally Loading Javascript and css in layout xml

First create your conditions in the system.xml..

Second add your css and js in your local xml.

<reference name="head">
    <action method="addCss" ifconfig="my_config_section/advanced/load_css"><stylesheet>css/my_module/my_module.css</stylesheet></action>
    <action method="addItem" ifconfig="my_config_section/advanced/load_js"><type>skin_js</type><name>js/my_module/my_module.js</name></action>
</reference>

Changing magento template file / content on the fly

The template file or content of the magento page can be changed on the fly using observer.

For example, if you want to change the product listing in the category view , just write observer for render before event and remove the specific block and add new block or just replace the template file with new template file with new content.

    $categoryProductBlock->setChild('product_list',$specificBlock);

Display Product Price without GST based on customer group

Following methods of the Config.php(app/code/core/Mage/Tax/Model) need to be changed as follows to display the product price excluding GST

public function getPriceDisplayType($store = null)
{
    $groupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
    if (isset($groupId) && ($groupId == 2) &&
        ((int)$this->_getStoreConfig(self::CONFIG_XML_PATH_PRICE_DISPLAY_TYPE, $store)) == self::DISPLAY_TYPE_INCLUDING_TAX){
        return self::DISPLAY_TYPE_EXCLUDING_TAX;
    }

   ...

Getting Magento Category Paths for a specific product

public function getCategoryPath($sku)
    {
        $product = Mage::getModel('catalog/product')->loadByAttribute('sku',$sku);
        
        $pathArray = array();
        $collection1 = $product->getCategoryCollection()
            ->setStoreId(Mage::app()->getStore()->getId())
            ->addAttributeToSelect('path')
            ->addAttributeToSelect('is_active');
            

        foreach($collection1 as $cat1){            
            $pathIds = explode('/', $cat1->getPath()); ...

Linux Help

How to show line number in vi editor
: Run

:set nu

How to show line number in gedit
: 1)Click on Edit menu
2)Select the Preference

3)Tick the Display line numbers

How to clear the screen

: ctrl + l

How to check the IP

: ifconfig

How to check the running process

: ps aux | grep redis

How to add users

  1. Open the terminal application.
  2. Login to Ubuntu server using ssh.
  3. Add a new user named foo to www-data group by running
 useradd -g www-data foo

com...