Ask your Question

PEOPLE YOU MIGHT KNOW

gourav
gourav

Moradabad,  India
Lonnie
Lonnie

Jacobus,  United States
Praveen
Praveen

Software Developer

NOIDA,  India
William
William

Web Developer

Elkhart,  United States
Vivek
Vivek

PHP Developer

Noida,  India

Write to us

Ask Question

Magento 2 Interview Questions

Add Your Magento2 Question
  • 1 What is a Plugin

    A plugin, or interceptor, is a class that modifies the behavior of public class functions by intercepting a function call and running code before, after, or around that function call. This allows you to substitute or extend the behavior of original, public methods for any class or interface.
    Extensions that wish to intercept and change the behavior of a public method can create a Plugin class.

  • 2 In which directory we write our own custom module in Magento2

     If we need to create our own module e.g Hello World then we define it in

    app/code folder. It will be app/code/VendorName/moduleName.

    e.g : app/code/Letsknowit/Hello_world.

  • 3 From where in admin panel we can enable/disable cache

    Admin->System->Tools->Cache Management

  • 4 What is the command to enable/disable a module in Magento2

    php bin/magento module:enable module_name

    php bin/magento module:disable module_name

  • 5 Which method a controller loads by default in Magento2

     execute method

    public function execute()

        {

        }

  • 6 How to enable/disable module in magento2

    To enable we need to run
         php bin/magento module:enable Namespace_modulename
      
       e.g php bin/magento module:enable Letsknowit_Custommodule
     
        to disable we need to run 
        
        php bin/magento module:disable Namespace_modulename
      
       e.g php bin/magento module:disable Letsknowit_Custommodule
  • 7 What is the command to know the status of all modules in magento2

     php bin/magento module:status

  • 8 What is the command to clear and flush magento cache

     To clean the cache 

      php bin/magento cache:clean
      To flush cache
      php bin/magento cache:flush
  • 9 How to override controller in Magento2

    To override controller we need to create a basic module structure. In our below code we have Hello module that will override Product view controller.

     

    1. Create di.xml file in Folder Letsknowit/Hello/etc
       our complete path is app/code/Letsknowit/Hello/etc/di.xml

    <?xml version="1.0"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
        <preference for="MagentoCatalogControllerProductView" type="LetsknowitHelloControllerRewriteProductView" />
    </config>

    2. Now we need to create view.php controller file in LetsknowitHelloControllerRewriteProduct
        /**
         * Hello Rewrite Product View Controller
         *
         */
        namespace LetsknowitHelloControllerRewriteProduct;
     
        class View extends MagentoCatalogControllerProductView
        {
            /**
             * @return MagentoFrameworkControllerResultRedirect|MagentoFrameworkViewResultPage
             */
            public function execute()
            {
                // Do your stuff here
                return parent::execute();
            }
        }

    In the same way we can override other controllers

  • 10 What is a UI component in Magento2

    In Magento UI component is a combination of:

    1. XML declaration that specifies the component’s configuration settings and inner structure.

    2. JavaScript class inherited from one of the Magento JavaScript framework UI components base classes (such as UIElement, UIClass or UICollection).

    3. Related template(s)
     

  • 11 What is Object Manager in Magento2

    Object manager is a class that intiates the object before begining of Bootstrapping process.

  • 12 What is the command to enable developer/production mode.

    To see on which mode it is currently on :

           bin/magento deploy:mode:show

    To enable developer mode

            bin/magento deploy:mode:set developer

    To enable production mode

          bin/magento deploy:mode:set production

Please rotate your device

We don't support landscape mode on your device. Please rotate to portrait mode for the best view of our site