Ask your Question



Software Developer

NOIDA,  India

Web Developer

Elkhart,  United States

Delhi,  India

Android developer | Blogger | Writer

Noida,  India

Cluster Credit Manager

Patna,  India

Write to us

Ask Question

Magento 2 Interview Questions

Add Your Magento2 Question
  • 1 In which directory we can write our own custom module in Magento2

  • 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="" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
        <preference for="MagentoCatalogControllerProductView" type="LetsknowitHelloControllerRewriteProductView" />

    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)

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