Friday, 5 March 2021

Magento 2 Interview Questions and Answers

 -- Magento cloud steps to process

1. Add the new Production domain to the Domains tab in the Cloud UI

2. Update A and CNAME records for each of your domains and hostnames (see above)

3. Change Magento Base URLs to www.yourdomain.com

4. Wait for the TTL time to pass, then restart the web browser

5. Test your website


-- Have you developed a custom payment gateway extension for magento2

Yes, I have developed a custom payment gateway. Here are the steps.

1 - create registration.php file

2 - create etc/module.xml file

3 - declare payment methods, so we need to create another file under the etc/payment.xml folder.

4 - create config.xml file under the etc folder to declare the payment method.

5 - Create a model file

6 - to display payment methods on the checkout page then we create a checkout_index_index.xml page

7 - Create js files to load KO template in checkout page: /view/frontend/web/js/view/payment/simple.js

8 - Now we need to create /view/frontend/web/js/view/payment/method-renderer/simple-method.js

9 - Finally, create KO template file /view/frontend/web/template/payment/simple.html


-- What classes used in payment gateway for developing an extension

Payment classes


-- What is the Plugin and type of plugin

Magento 2 Plugin is a technical plugin for your better writing code. Interception Plugin allows editing the behavior of any public class or method by intercepting a function call and running code either before or after or around the function call.

There are 3 types of plugins available on Magento 2, before, after, and around.


--Difference between around and before the plugin

Around methods allow codes to run before and after observed methods. so you can override a method. and the prefix should be Around.

Before methods are the first methods to run in observed methods. and the prefix should be Before.


-- What is used of preference tag in magento2

Preference is used for overriding class


--How to create a database table in Mysql

Use a CREATE TABLE statement to specify the layout of your table


--Have you worked on Rest API

- etc/module.xml

- registration.php

- Create a webapi.xml file under the etc directory

- create a di.xml file to define an interface and model that defines which model will be called by the defined interface.

- Interface: Api/AddressInterface.php

- Create model - CustomerAddress.php


-- Custom module works, schema uses

db_schema.xml file declares a module’s database structure. If you want to rename a column then use the schema.xml file.

Before running the upgrade command you need to add your schema to the db_whitelist_schema.json file by running the following command :

php bin/magento setup:db-declaration:generate-whitelist --module-name=RH_Helloworld


-- CLI commands do cache clean & flush

php bin/magento cache:clean;

php bin/magento cache:flush;


-- What is the difference between Preference and Plugin?

With Preference, it must extend a core class. Preference can rewrite function. When you declare a Preference, your new class is expected to be a complete implementation of the class you want to override.


While a plugin allows you to execute your functions before, after, or around (before & after) the core function is executed. It's NOT really rewritten function like Preference. 


-- Creating a migration plan

Review extensions on your current site

Build and prepare Magento 2 store for migration

Copy the Magento 1 store data to Magento 2 staging environment

Start your migration

Use the Data Migration Tool to migrate settings and websites

Copy your Magento 1.x media files to Magento 2.x.

Reindex all Magento 2.x indexers


--What Does the setup:di:compile Command Do? 

The above setup:di:compile command basically generates the contents of var/di folder in Magento < 2.2 and for >=2.2. According to the official Magento docs, it compiles code like Factories, Proxies, Interceptors, etc. and puts them in generated or var/generation directory.


Magento2 Service Contract?

- In general understanding, a service contract is an agreement between the two parties, where one is the service provider and the other is the service consumer. A service contract is a set of PHP interfaces that are defined for a module. A service contract includes data interfaces, which preserve data integrity, and service interfaces, which hide business logic details from service requestors such as controllers, web services, and other modules.


Explain RabbitMQ?

- Magento 2 supports MySQL and RabbitMQ systems to create message queues. Magento 2 RabbitMQ works as a message intermediator between sender and receiver. It is an open-source communication broker that provides your applications with a common platform while offering a secure and convenient messaging system.

No comments:

Post a Comment

Thanks for your comments.