What is Magento2?
Magento 2 is an open source large ecommerce system .Magento 2 is Model View View Model (MVVM) architecture. While being closely related to its sibling Model View Controller (MVC), MVVM architecture provides a more robust separation between the Model and the View layers
Why use Magento 2?
Magento was stripped down and rebuilt from scratch to what is now a quicker, easier, and safer Magento 2 version.
- It is very fast better than magento 1
- New File Structure
- New, more modern front-end codebase
- Reduced number of conflicts between modules trying to customize the same functionality
- New Layout Elements
- CSS Pre-processing
- Magento UI Library
- Improved performance and scalability
- Reducing upgrade efforts and costs
How can you customize the Magento 2 theme?
To customize a Magento 2 theme, you can follow these steps:
- Create a child theme based on an existing theme.
- Modify the theme’s XML, PHTML, CSS, and JavaScript files.
- Override parent theme templates as needed.
- Clear the cache and deploy static files to see the changes on the frontend.
How can you extend or override Magento 2 core functionality?
Magento 2 provides various ways to extend or override its core functionality:
- Plugins (formerly known as Observers): Modify or extend a class’s behavior by intercepting its public methods.
- Preferences: Override a class with your custom implementation.
- Extension attributes: Add additional attributes to existing entities without modifying their core structure.
- Interceptors: Modify or extend a class’s behavior by intercepting its public methods.
- Events: Listen for specific events and execute custom code when they occur.
Explain the concept of dependency injection in Magento 2
Dependency injection is a design pattern used in Magento 2 to provide loose coupling between classes and enhance maintainability and testability. It allows you to inject dependencies into a class from an external source instead of the class creating its dependencies internally. Magento 2 utilizes constructor injection, where dependencies are passed through a class’s constructor and automatically resolved by the dependency injection container.
How can you create a new module in Magento 2?
To create a new module in Magento 2, you can follow these general steps:
- Create the necessary module files and folder structure.
- Define the module’s configuration file, registration.php, and module.xml.
- Create the necessary controllers, models, blocks, and views as per your module’s requirements.
- Enable the module, clear the cache, and run the setup upgrade command.
How can you optimize the performance of a Magento 2 website?
To optimize the performance of a Magento 2 website, you can implement various techniques:
- Enable full-page caching.
- Minify and combine CSS and JavaScript files.
- Optimize images.
- Utilize lazy loading for images and content.
- Enable flat catalog for product and category data.
- Implement server-side optimizations like PHP opcode caching and Varnish cache.
- Use a Content Delivery Network (CDN) for static assets.
How does Magento 2 handle multi-store setups?
Magento 2 supports multi-store setups by allowing you to create multiple websites, stores, and store views within a single installation. Each store can have its own catalog, product prices, payment methods, and shipping configurations. Magento 2 uses a hierarchical structure to manage stores, and you can assign different themes, languages, and currencies to each store view.
What are the important new features in Magento 2.3?
- PWA-Progressive Web App
- Asynchronous web API
- Message Queue
- GraphQL
- RabbitMQ
- Libsodium
- Klarna Integration
- Declarative Database Scheme
- Cache Management ACL
- Google reCAPTCHA
- Multi stock inventory
- Business Friendly page builder
- Two factor authentication
- Support elasticsearch
- Amazon 3rd party sales
What are new features in Magento 2.2?
Magento 2.2 Features:
- New B2B Functionality
- Improved Security
- Better Fraud Protection
- Enhanced Reporting
- Enhanced Developer Experience
- Mass Technology Stack Update
- New Deployment Process (Pipeline)
- Better Performance: Improved Indexing, Cache, and Cart.
What is the difference between Cache:clean and Cache:flush?
Typically, cache:clean deletes all enabled cache related to magento whereas cache:flush deletes the whole cache storage, whether its magento cache or any third party cache (whether enabled or disabled)
What are the two methods in component Root directory location?
<Magento install directory>/app
<Magento install directory>/vendor
Which command is used to enable or disable a magento2 module?
php bin/magento module:enable NameSpace_ModuleName
php bin/magento module:disable NameSpace_ModuleName
How can you get customer collection in Magento 2?
By using below code: object->getCollection()
customerCollection = $customer->getCollection();
Which class Magento 2 helper extend?
Magento Framework App Helper AbstractHelper
How to reset admin password in Magento 2?
Using these three methods:
Method 1: From Magento 2 user Interface
Method 2: To reset Magneto 2 admin password from PhpMyAdmin or Mysql interface
Method 3:Command line interface(CLI)
How to add new js file to Magento 2?
In the root of your theme add a file named requirejs-config.js and then declare new javascript file in requirejs-config.js
Which command is used to re-generate all Url rewrites of the categories/products in all stores run?
All stores command:
bin/magento ok:urlrewrites:regenerate
Specific store command:
bin/magento ok:urlrewrites:regenerate 2 or $> bin/magento ok:urlrewrites:regenerate –storeId=2
What is EAV in Magento?
EAV, stands for Entity Attribute Value, is a technique which allows you to add unlimited columns to your table virtually. EAV also known as object attribute value model and open schema.
Entity (E): Entity actually refers to data item. For example we can consider it as customer, category or product.
Attribute (A): Attribute refers to the different attributes of the Entity. Like for example product have different attributes like color, size, price, etc.
Value (V): Value refers to the actual value of the attribute of the entity. Like color has value red, price has value $25, etc.
How to create new address in Magento 2?
If you want to create a new address for a customer and set it as default shipping or billing address, you only need to create a new address object from factory:
$address = $this->_addressFactory->create();
A set its data. Depending on its type you need to set it as default shipping or default billing. You can also set both, so that a customer has only one address:
if($type == “shipping”)
$address->setIsDefaultShipping(‘1’);
if($type == “billing”)
$address->setIsDefaultBilling(‘1’);
How can you get or set values in Magento 2?
By using, these two methods:
\Magento\Framework\App\Config\Storage\WriteInterface
to write config values to database
\Magento\Framework\App\Config\ScopeConfigInterface
to read config values from database
What is the location of modules in Magento 2?
The modules are located at vendor/magento directory.
Can you explain Magento 2 Folder Structure?
Magento 2 folder structure has been changed a lot from the previous version of Magento platform. If you navigate through the root directory of Magento 2, you’ll see the following folder structure:
/RootDirectory
/app: The core files of Magento 2 including configuration, modules and themes files.
/bin: It contains the Magento 2 CLI feature
/dev: Developer Tool such as Magento Test Framework (MTF).
/lib: core libraries.
/phpserver: It contains Router.php file.
/pub: generated static files and site media. It should be set as your web root on the server side. As the name of the folder says, it contains all the publicly accessible files.
/setup: In this setup directory, several important packages such as the performance toolkit are available
/var: Same as Magento v1, the var folder contains raw cache files, logs, sessions, and reports.
/vendor: It is generated by composer using composer.json file. This folder includes various packages that have been defined under composer.json file.
What version control systems have you used?
Git, Subversion, Mercurial and so on
Can you show the Theme file structure?
├── composer.json
├── etc
│ └── view.xml
├── i18n
│ └── en_US.csv
├── LICENSE_AFL.txt
├── LICENSE.txt
├── media
│ └── preview.jpg
├── registration.php
└── web
├── css
│ ├── email.less
│ ├── print.less
│ ├── source
│ │ ├── _actions-toolbar.less
│ │ ├── _breadcrumbs.less
│ │ ├── _buttons.less
│ │ ├── components
│ │ │ └── _modals_extend.less
│ │ ├── _icons.less
│ │ ├── _layout.less
│ │ ├── _theme.less
│ │ ├── _tooltips.less
│ │ ├── _typography.less
│ │ └── _variables.less
│ ├── _styles.less
│ ├── styles-l.less
│ └── styles-m.less
├── images
│ └── logo.svg
└── js
├── navigation-menu.js
├── responsive.js
└── theme.js
How many types of sessions are available in Magento?
There are two types of sessions being used, customer and checkout sessions. All customers’ related data is locked with customer session whereas data related to order and quotes are stored in checkout session. Session types are utilized separately since order gets placed; check out session data information needs to be flushed. Thus, having two different sessions for order and customer related data makes sense. Example – customer session’s first name will be $_SESSION [‘customer’][‘firstname’]. The similar example works for checkout session as well.
What is the command line used to clear and flush magento cache?
To clean the cache: php bin/magento cache:clean
To flush cache :php bin/magento cache:flush
How to add custom js file in require js file?
To add js file in your magento 2 custom modules, you need to add
“requirejs-config.js” file in your module at path “app/code/Webkul/Test/view/frontend”.
What are the different ways of enhancing the performance of Magento?
There are several ways with which we can enhance the performance in Magento, some of them are listed below:
- Disable any unused modules
- Enable Magento caching
- Optimize images
- Disable Magento log
- Combine external CSS/JS into a single file
- MySQL query caching
- Enable gzip compression
What task management system have you used?
JIRA, Asana, Redmine and so on
Which command line is used to static content deploy?
php bin/magento setup:static-content:deploy
For particular Language:
php bin/magento setup:static-content:deploy en_US
For magento backend theme:
php bin/magento setup:static-content:deploy—theme=” magento/backend”
For specific themes:
phpbin/magentosetup:static-content:deploy—themeMagento/luma—theme Magento/second_ theme
Exclude themes and does not minify HTML files:
php bin/magento setup:static-content:deploy en_US — exclude -theme Magento /luma—no-heml-minify
Which command line is used to show the mode of all indexers?
php bin/magento indexer:show-mode
Which command line is used to enable, disable and uninstall module?
Enable Module: php bin/magento module: enable Namespace_Module
Disable Module: php bin/magento module: disable Namespace_Module
Uninstall Module: php bin/magento module: uninstall Namespace_Module
Which command line is used to see all modules status?
php bin/magento module:status
Which command line is used to set Magento crontab?
php bin/magento cron-install—force
Which command line is used to change to developer mode and production mode and check current mode?
Change to developer mode: php bin/magento deploy: mode: set developer
Change to production mode: php bin/magento deploy: mode: set production
Check current mode: php bin/magento deploy: Mode: show
Which command line is used to unlock admin user?
php bin/magento admin :user: unlock adminusername
Which command line is used to check maintenance and disable maintenance?
Check maintenance: php bin/magento maintenance: status
Disable maintenance: php bin/magento maintenance: disable
Which command line is used to allow IP on maintenance mode?
Php bin/magento maintenance:allow-ips—ip=192.0.0.1—ip=192.0.0.2
Which command line is used to reindexing, view the list of indexers and view indexer status?
For reindexing: php bin/magento indexer: reindex
For view the list of indexers: php bin/magento indexer: info
For view indexer status: php bin/magento indexer: status