Sunday, 27 November 2022

Magento 2 Frontend Developer Interview Questions

What are the Components of Magento, and make a little brief about them?

Magento has three components – modules, themes, and language packages.

Module: It is a directory that consists of PHP and XML files in the form of blocks, helpers, controllers, and models. It is a logical group that provides essential business features to Magento applications.
Themes: These are templates, layouts, images, and styles that form the visual part of Magento applications. Know that themes are provided as additional packages in Magento.
Language Packages: These are yet another standalone component of Magento. Generally, language packages have the whole dictionary in one directory.

What are meta tags in HTML?

  • Meta tags are those tags that go inside the Head tag of the HTML page
  • Meta tags are not for the interface they are important for the browser. 
  • Meta Tags are always in name or value pairs 
  • Meta tags consist of character encoding, title, or even description. 

State some basic design element

Some of the basic elements of design are 

  • Line - a line mark made with any pen or brush or even any edge created when two shape meets 
  • Size - it is the area occupied by one shape with the other 
  • Texture- the surface of the shape - Smooth, soft, hard, glossy, and such 
  • Color - The light reflected from the objects. The three characteristics of color are hue, value, and intensity. 

What is the scope of JavaScript?

In JavaScript, every function has its own scope. It is basically a collection of rules for how variables are accessed and variables themselves.


How are JavaScript and jQuery different?

JQuery is a library built with the JavaScript language, and JavaScript is the language itself.

What is Content Security Policy?

Content security Policy also known as CSP is a header in HTML which lets the site operators gain the whole control over the resources which are loading on the site.

What is Cross-Site Scripting (XSS)?

XSS, Cross-Site Scripting is an attack that takes place when any attacker uses a web application to send any malicious code, in the form of a browser-side script, to another user. 

What is User-Centered Design?

User-centered designs are those designs the designer solely focuses on which are according to the needs of users and them in every phase of designing. 

What is callback hell?

JavaScript uses callbacks and is hard to get the right intuitively. The callbacks are stacked in the form of a pyramid structure.

What is Strict Mode?

A new feature of ECMAScript 5 is Strict mode which lets you place a function or a program in a “strict” context of operating. 

What does SOLID stand for?

S.O.L.I.D is an acronym for object-oriented design principles 
S- single responsibility principle 
O- open-closed principle 
L- Liskov Substitution principle 
I- interface segregation principle 
D- dependency. 

What is a grid system in CSS?

A structure that lets the content be placed both horizontally and vertically in a consistent and manageable way. There are two key components of the Grid system; Rows and Columns.

What is Mixin?

A Mixin is a code block that lets the group of CSS declarations that we can reuse in our site.

What is Stringify?

To transform a JavaScript object into a string Stringify is used.

State the elements of the CSS Box Model.

CSS Box Model consists of 4 elements 

  • Content
  • Padding
  • Border
  • Margin

What is the benefit of Srcset?

When we want to generate many new solutions of exact images on several devices, Srcset is used. This helps improve the UI.

Explain Git Push and Git Pull

Git push is a command that pushes the contents of a local repository to a remote repository. It runs a push after it has changed a local repository to share the changes with remote team members.

Git pull is a command that pulls changes from a remote repository and merges them into the local repository. It's made up of two commands: git fetch followed by git merge.

Name a few Git Commands and function

  • Git Config - Configure the username and email address
  • Git init - Initialize a local Git repository
  • Git Add - Add one or more files to the staging area
  • Git Diff - View the changes made to the file
  • Git Commit - Commit changes to the head but not to the remote repository
  • Git reset - Undo local changes to the state of a Git repo
  • Git Status - Displays the state of the working directory and staging area
  • Git Merge - Merge a branch into an active branch
  • Git Push - Upload content from the local repository to a remote repository
  • Git Pull - Fetch and download content from a remote repository

Explain the Difference Between Git Pull and Git Fetch

Git Fetch 

  • It downloads only new data from a remote repository using Git fetch
  • It does not include any of this new information in your working files
  • To update the remote-tracking branches, run Git fetch at any time
  • Command - git fetch origin

              git fetch –-all

Git Pull

  • Git pulls new data and integrates it with the current working files, updating the current HEAD branch with the latest modifications from the remote server
  • It attempts to combine remote modifications with those made locally
  • Command - git pull origin master

What is Semantic HTML? How does it work?

  • Semantic HTML is a type of coding.
  • It is the use of HTML markup to emphasize the content's semantics or meaning.
  • Consider the following scenario: The <b></b> tag is not used for bold statements in semantic HTML, while the <i></i> element is used for italic.
  • Instead, you use the <em></em> and <strong></strong> tags.

What is SVG in HTML?

<svg width="100" height="100">

      <circle cx="50" cy="50" r="40" stroke="yellow" stroke-width="4" fill="red" />

    </svg>

  • HTML SVG is a markup language that describes vector and raster graphics. XML text files define SVG pictures and associated behaviors.
  • It's typically used for X and Y coordinate system diagrams like pie charts and 2-Dimensional graphs.

In HTML, how do you separate a section of text?

In HTML, you use the following tags to divide a chunk of text:

<br> tag–It's a character that's used to break up a line of text. It transfers the text flow to a new line by breaking the existing line.

<p> tag–This tag is used to create a text paragraph.

<blockquote> This tag is used to indicate big quoted passages.

Mention the different types of CSS Selectors

//Universal Selector

* {

        color: "green";

        font-size: 20px;

        line-height: 25px;

      } 

//Element type Selector 

ul {

    line-style: none;

    border: solid 1px #ccc;

  } 

// ID Selector 

#container {

    width: 960px;

    margin: 0 auto;

  } 

  <div id="container"></div>

//Class Selector 

 .box {

    padding: 10px;

    margin: 10px;

    width: 240px;

  }  

  <div class="box"></div>

//Descendent Combinator

 #container .box {

    float: left;

    padding-bottom: 15px;

}  

<div id="container">

    <div class="box"></div>    

    <div class="box-2"></div>

</div> 

<div class=”box”></div>

//Child Combinator

 #container> .box {

    float: left;

    padding-bottom: 15px;

}

<div id="container">

    <div class="box"></div>   

    <div>

        <div class="box"></div>

    </div>

</div> 

// General Sibling Combinator

h2 ~ p {

    margin-bottom: 20px;

}

<h2>Title</h2>

<p>Paragraph example.</p>

<div class=”box”>

    <p>Paragraph example.</p>

</div>

//Attribute Selector 

input [type=” text”] {

    background-color: #444;

    width: 200px;

}

<input type="text">

What are Sass, Less, and Stylus?

Sass - Sass is the acronym for “Syntactically Awesome Style Sheets”. A ‘$’ sign commonly precedes it.

$font-color: #fff 

        $bg-color: #00f       
#box

          color: $font-color

          background: $bg-color

Less - LESS is an acronym for “Leaner Stylesheets”. Less uses ‘@’ to define the variables.

@font-color: #fff;

          @bg-color: #00f          

          #box{

            color: @font-color;

            background: @bg-color;

          }

Stylus - Stylus offers a great deal of flexibility in writing syntax. It doesn’t use @ or $ for defining variables. 

font-color= #fff;

        bg-color = #00f;    
#box {

          color: font-color;

          background: bg-color; }

What are the different ways to hide an Element using CSS?

display: none

Hides the content and doesn’t store it in the DOM

visibility: hidden

It adds the element to the DOM and takes up space. However, it is not visible to the user

position: absolute

You can make the element appear outside the screen

What does ‘Important’ in CSS mean?

The ‘important’ keyword indicates the highest precedence, and it overrides the cascaded property.

p {

                color: blue !important;

            }

            #thing {

                color: green;

            }

            
<p id="thing">Will be RED.</p>

What are CSS Sprites?

  • Since each image sends out an HTTP request separately, a web page with a high number of photos takes longer to load.
  • CSS sprites are used to minimize the loading time of a web page by combining multiple small pictures into a single image.
  • It decreases the number of HTTP requests and, as a result, the time it takes for pages to load.

What’s the difference between Function Declaration and Function

 Expression?

Function Declaration 

function abc(){

    return 5;

}

Within the main JavaScript code, it declares this as a separate statement. It is possible to invoke it before the function has been defined. It provides improved code readability.

Function Expression 

var a = function abc(){

    return

}

It is created inside an expression or some other construct. It is generally used when there is a need for a conditional declaration of a function. 

What is the difference between Undefined, Undeclared, and Null in JavaScript?

var x 

console.log(x) //Undefined variable

var y=NULL

console.log(y) //Null Variable

console.log(z) //Undeclared Variable

Undefined - Undefined means a variable has been declared but a value has not yet been assigned to that variable.

Null - Null is an assignment value that you can assign to any variable that is meant to contain no value.

Undeclared - Variables that are not declared or that do not exist in a program or application.

What is the best way to remove Duplicates from a JavaScript Array?

You can delete duplicates from a JavaScript array in one of two ways:

By employing the filtering technique - Three arguments are required to call the filter() function. These are the array, current element, and current element index.

The For loop is used to store all the repeated elements in an empty array.

How is a Web Developer different from a Web Designer?

Web Developer

Web Designer

Build web applications using languages
like HTML, CSS, and JavaScript

Design web applications using tools like Adobe Photoshop, Sketch

They frequently use JavaScript frameworks
for more streamlined development

They frequently use Adobe Creative Cloud for most of their design needs

It requires good coding skills

It requires good graphic design skills

Have to keep themselves up to date with
the latest web frameworks and libraries

Have to keep themselves up to date with the latest design trends and color palettes


Friday, 15 April 2022

Magento 2 Interview Questions & Answers

 Magento2 Upgradation and Migration?

First we need to keep backup the whole db and code file by running this command 

php <magento_root>/bin/magento setup:backup --code --db

We have to download the data migration tool - composer require magento/data-migration-tool:2.1.2


Magento2 Optimisation?

- Steps to Optimize Performance

Enable Flat Categories and Products

Merge CSS and JS Files

Content Delivery Network

Caching

Image Optimization

Enable Compression

Reduce Server Response Time

Magento Updates

Update to the latest version of Magento.

Change Hosting Provider.

Audit Third-Party Extensions.

Use Lightweight Magento Themes.

Delete Unnecessary Fonts.

Optimize Images.

Use Next-Gen File Format.

Disable Flat Catalogs.


UI Components

- Magento Ui Components are used the represent the distinct UI, such as tables, buttons, dialogs, and others.

In Magento, there are 2 primary UI components

Listing Components

Form components 

Rest are secondary components 

All components can be configured in both Admin and Frontend.

XML declaration

JavaScript

Related template(s)



What are Proxies?

- In Magento is used to replace resource hungry classes. It will work on behalf of others. A proxy implements the same interface as the original class and so can be used as a dependency anywhere the original class can.


What is the source model, backend model?

-Source model - It is a Model class that serves the existing values. Which are already exist and store in a File, database.

- Backend Model - A class which is allow to operate with configuration data. _afterLoad(), _beforeSave() and _afterSave().


Steps to create API? Authentication Methods in API. resource types in Magento 2.

- In Magento, developers are allowed to define web API resources and their permissions in a configuration file called webapi.xml.

Administrator or Integration - admin 

Customer - anonymous or self

Guest user - anonymous

Magento 2 API Authentication

Token authentication

OAuth authentication

Session authentication


What is Extension Attributes?

They are used to extend functionality and often use more complex data types than custom attributes. These attributes do not appear in the Admin.

File name is extension_attributes.xml


Magento upgrade command?

php bin/magento setup:upgrade


Cache working mechanism?

Magento collects configuration from all modules, merges it, and saves the merged result to the cache. This cache also contains store-specific settings stored in the file system and database. Clean or flush this cache type after modifying configuration files


What is redis, working of redis?

Redis can also be used for PHP session storage, making it possible to completely replace memcached with Redis. The Redis backend works by indexing tags in files so that tag operations do not require a full scan of every cache file. Magento provides command line options to configure the Redis page and default caching. Although you can configure caching by editing the <Magento install dir>app/etc/env. php file


What is Indexer?

Indexing is the way Magento 2 converts refreshable data (products, categories, prices, etc.) to enhance the storefront performance. When you refresh the converted data it needs an update or Magento 2 to be reindex programmatically or manually.


 Virtual Type?

- Virtual Types are the classes that are instantiated by the ObjectManager but have no physical / concrete class located in /app/code or in /generated. Type adjusts existing classes, whereas Virtual Types creates a new class.


Magento 2 ways to Override core classes

- You have to put the path of the class override the target class in the "type" attribute and set sortOrder for you plugin. Magento 2 will run your plugin based on sortOrder. You can also use the preference.


How To Set and Configure Custom Cron Jobs In Magento 2?

Step 1: Create a sample module.

Step 2: Create a class to run cron.

Step 3: Create crontab. xml.

Step 4: Run the cron job.

Step 5: Create custom cron group.

Step 6 : Run the custom cron group.

bin/magento cron:run



Thursday, 23 September 2021

Magento 2.4 reindex issue with elasticsearch

This configures your ES installation to work properly with Magento 2. 


curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_cluster/settings -d '{ "transient": { "cluster.routing.allocation.disk.threshold_enabled": false } }'


curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}'

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.

Tuesday, 15 December 2020

Magento 2 Interview Questions and Answers

 --- the main differences between INNODB and MyISAM

The most commonly used storage engine in MySQL is MyISAM and InnoDB.With this storage engine, there are some advantages and disadvantages according to application needs. As you all know, the default storage engine chosen by the MySQL database is MyISAM.

The main difference between MyISAM and InnoDB are :

MyISAM does not support transactions by tables while InnoDB supports.

There are no possibility of row-level locking, relational integrity in MyISAM but with InnoDB this is possible. MyISAM has table-level locking.

InnoDB does not support FULLTEXT index while MyISAM supports.

Performance speed of MyISAM table is much higher as compared with tables in InnoDB.

InnoDB is better option while you are dealing with larger database because it supports transactions, volume while MyISAM is suitable for small project.

As InnoDB supports row-level locking which means inserting and updating is much faster as compared with MyISAM.

InnoDB supports ACID (Atomicity, Consistency, Isolation and Durability) property while MyISAM does not support.

In InnoDB table,AUTO_INCREMENT field is a part of index.

Once table in InnoDB is deleted then it can not re-establish.

InnoDB does not save data as table level so while implementation of select count(*) from table will again scan the whole table to calculate the number of rows while MyISAM save data as table level so you can easily read out the saved row number.

MyISAM does not support FOREIGN-KEY referential-integrity constraints while InnoDB supports.


-- What is proxy and why we use it


 Inject Proxy class when you feel object creation will be expensive and class’s constructor is particularly resource-intensive. - when you don't want unnecessary performance impact due to object creation. - when you feel object creation should happen when you call a particular method in a particular condition not always. For example, the Layout constructor is resource-intensive.

 Proxy behaves acts on behalf of others.


-- What is virtual type and type

Virtual types are a way to inject different dependencies into existing classes without affecting other classes.


Type lets us manipulate the dependencies injected into class constructors. It’s a powerful tool that e.g. allows us to add new Routers in Magento.


--What caching by default use in magento2

File system


--why we use static version and what is effect if we dont use it

Static files are the files that can be cached on the site, which increases page loading speed. These include CSS, fonts, images, and JavaScript used by the theme. Such files are located in the / pub / static and / var / view_preprocessed / pub / static folders, which get there after deployment. From this article you will learn how to deploy static files.


--Where static version defined and where we use it.

We are using from Store - Configuration - Advance - Developer - Static File Setting - Yes

Such files are located in pub/static and var/view_preprocessed/pub/static


--Stpes for create around plugin

A plugin is a great way to expand or edit a public method’s behavior by using code before, after or around method.


app/code/vendorname/modulename/registration.php

app/code/vendorname/modulename/etc/module.xml

app/code/vendorname/modulename/etc/di.xml

app/code/vendorname/modulename/controller/index.php

app/code/vendorname/modulename/Plugin/example.php


--What is the usage of di.xml file

Dependency Injection is a design pattern that allows an object A to declare its dependencies to an external object B

you can map your own implementation of a Magento interface to a dependent class or service using the di.xml file.


--what is interface and where we use it

Object interfaces allow you to create code which specifies which methods a class must implement, without having to define how these methods are handled.


--Difference bewteen interface and abstractclass

Abstract classes can have constants, members, method stubs (methods without a body) and defined methods, whereas interfaces can only have constants and methods stubs.



-- how we cached specific block

Setting cache_lifetime via layout XML:

Setting cache_lifetime via DI.XML

Setting cache_lifetime via block file.


--We need to add custom fields in checkout page and what are the steps

Create the JS implementation of the form UI component. In your <your_module_dir>/view/frontend/web/js/view/ directory, create a custom-checkout-form.js file

Create the knockout.js HTML template for rendering the form. <your_module_dir>/view/frontend/web/template directory called custom-checkout-form.html

Declare the form in the checkout page layout. <Checkout_module_dir>/view/frontend/layout/checkout_index_index.xml.


-- What is security tool we use in magento2

Use security scan

Use frontend/backend CAPTCHA

Use two-factor authentication

Use strong passwords

Use advanced admin access permissions


--How will you manage the security if you will create custom API?

We have to set the resouce ref to the vendor_Module ACL key in etc/webapi.xml

in the acl.xml file need to setup for the roles group

then set permissions in the backend system -> permissions -> user roles



--What is repository

Repositories give service requestors the ability to perform create, read, update, and delete (CRUD) operations on entities or a list of entities.


--What is di.xml?

Magento reads all the di.xml configuration files declared in the system and merges them all together by appending all nodes


--What is the use of di:compile command

The above setup:di:compile command basically generates the contents of var/di folder in Magento < 2.2 and for >=2.2.


--Whats is the use sttaic-content:deploy command

Simple run the following command line to deploy static content your store when install / update an extension


--How will you remove fpc from specific block.

cacheable = "false" has only one meaning.



-- Payment Method

Create file registration.php

Declare module.xml file

Declare payment method module

Now we create file payment.xml file in etc folder etc/payment.xml

Create config.xml file in etc folder.

Create file Model/Payment/Simple.php

Create layout file: view/frontend/layout/checkout_index_index.xml

/view/frontend/web/js/view/payment/simple.js



-- what is difference between compiler and interpreter


Interpreter translates just one statement of the program at a time into machine code. Compiler scans the entire program and translates the whole of it into machine code at once. An interpreter takes very less time to analyze the source code. However, the overall time to execute the process is much slower


--Difference between abstract class and interface


1) Abstract class can have abstract and non-abstract methods. Interface can have only abstract methods. Since Java 8, it can have default and static methods also.

2) Abstract class doesn't support multiple inheritance. Interface supports multiple inheritance.

3) Abstract class can have final, non-final, static and non-static variables. Interface has only static and final variables.

4) Abstract class can provide the implementation of interface. Interface can't provide the implementation of abstract class.

5) The abstract keyword is used to declare abstract class. The interface keyword is used to declare interface.

6) An abstract class can extend another Java class and implement multiple Java interfaces. An interface can extend another Java interface only.

7) An abstract class can be extended using keyword "extends". An interface can be implemented using keyword "implements".

8) A Java abstract class can have class members like private, protected, etc. Members of a Java interface are public by default.

9)Example:

public abstract class Shape{

public abstract void draw();

} Example:

public interface Drawable{

void draw();

}



-- difference between abstraction and encapsulation in php

Encapsulation: Wrapping code and data together into a single unit. Class is an example of encapsulation, because it wraps the method and property.


Abstraction: Hiding internal details and showing functionality only. Abstraction focus on what the object does instead of how it does. It provides generalized view of classes.


--HOW CAN YOU IMPROVE THE PERFORMANCE OF MAGENTO 2?

Optimizing image size

MySQL Query Caching

Enable Magento caching

Enable Gzip caching

Disabling modules that aren’t in use

Write clean code

Use dedicated hosting services because it’s a resource-hungry platform.



--WHICH COMMAND IS USED TO ENABLE OR DISABLE A MAGENTO 2 CACHE?

php bin/magento cache:enable

php bin/magento cache:disable


--WHAT IS THE DIFFERENCE BETWEEN A CACHE:CLEAN AND CACHE:FLUSH?

Cache:clean deletes all the cache that has been enabled for Magento. Cache: flush on the other hand deletes all the cache storage whether it is from a third party or Magento cache.



--HOW MANY TABLES WILL BE CREATED WHEN YOU MAKE A NEW EAV MODEL?

Six tables will be created. These include:


Module_datetime

Module

 module_decimal,

module_int

module_text

Module_varchar




--HOW CAN YOU RESET MAGENTO FILE & DIRECTORY PERMISSIONS?

You can reset them by following commands through the directory where Magento is installed.


find . –type f –exec chmod 644 {} ;


find . –type d –exec chmod 755 {} ;


chmod +x mage



--WHICH FILE STORES THE VENDOR PATH?

It’s vendor_path.php situated at app/etc/ folder



--WHAT ARE THE DIFFERENT DEPLOY MODES IN MAGENTO 2?

The different deploy modes are:


Default mode: Through this mode, you can deploy Magento applications on a single server. This mode is not optimized for production.

Developer mode: used when you’re extending the functionality of your website or customizing it.

Production: This mode is enabled when your Magento 2 website is in production.

Maintenance: this mode prevents access to a Magento website when it is being updated or reconfigured


--WHAT IS A FACTORY CLASS IN MAGENTO 2?

Factory classes are used to create, change, or get an entity without having to access the object manager since it is discouraged by Magento. These classes are created during code generation and do not need to be manually defined.



--WHAT IS DEPENDENCY INJECTION IN MAGENTO 2?

Dependency injection is used in Magento 2 to replace the Mage class functionality that Magento 1 used.


It’s a pattern in which object 1 can declare its dependencies on object 2, and then object 1 doesn’t have to worry about procuring its own dependency requirements. Object 2 will do that based on desired behavior or configurations.



--PHP OOP - Constructor

A constructor allows you to initialize an object's properties upon creation of the object.


If you create a __construct() function, PHP will automatically call this function when you create an object from a class.


--12 Design Patterns Found In Magento

Model View Controller Pattern

Front Controller Pattern

Factory Pattern

Singleton Pattern

Registry Pattern

Prototype Pattern

Object Pool Pattern

Iterator Pattern

Lazy Loading Pattern

Service Locator Pattern

Module Pattern

Observer Pattern

--20 Design Patterns Found In Magento

Factory Pattern

Singleton Pattern

Model View Controller Pattern

Front Controller Pattern

Registry Pattern

Prototype Pattern

Iterator Pattern

Object Pool Pattern

Service Locator Pattern

Lazy Loading Pattern

Observer Pattern

Module Pattern

Service Contract

Object Manager (which consist of 11+ Design Patterns)

Proxy Pattern

Factory Classes

Dependency Injection

Injectable Objects

Non-injectable objects

Active records

The main difference between plugins and observers is

Plugins can modify only public methods while observers can modify private, protected as well.

There is a sort order for plugins but there is no sort order for observers.

You can add observer only to the events that are already dispatched in Magento. Plugins are more flexible here.




Monday, 11 November 2019

Magento 2 admin product disabled filter issues

You have to copy the vendor\magento\module-catalog\Ui\DataProvider\Product\ProductCollection.php  
to
app/code/Magento/Catalog/Ui/DataProvider/Product/ProductCollection.php  

Replace the following code in addAttributeToFilterAllStores(Attribute $attributeModel, array $condition): void function

$condition = "({$pKey} = {$fKey}) AND ("
            . $this->_getConditionSql("{$tableName}.value", $condition)

            . ')';


With 


$attributeId = $attributeModel->getAttributeId();
        $condition = "({$pKey} = {$fKey}) AND ("
            . $this->_getConditionSql("{$tableName}.value", $condition)
            . ') AND ('
            . $this->_getConditionSql("{$tableName}.attribute_id", $attributeId)

            . ')';

Friday, 8 November 2019

Magento 2 Order Grid not showing NEW orders

1 - Go to Admin panel
2 - Click Stores - Configuration
3 - Advanced - Developer - Grid Settings
4 - Set Asynchronous Indexing to "Enable"
5 - Flush cache - (php bin/magento cache:flush;)
6 - Go to the database table "sales_order_grid". You can truncate this table.
7 - run this command twice - php bin/magento cron:run
8 - Flush cache - (php bin/magento cache:flush;)
9 - Set Asynchronous Indexing to "Disable"
10 - Flush cache - (php bin/magento cache:flush;)

Saturday, 5 October 2019

10 Top Unix Shell Scripting Interview Questions And Answers

1) What is Shell?

Ans: Shell is a command interpreter, which interprets the command which the user gives to the kernel. It can also be defined as an interface between a user and operating system.

2) What is Shell Scripting?

Ans: Shell scripting is nothing but series or sequence of UNIX commands written in a plain text file. Instead of specifying one job/command at a time, in shell scripting we give a list of UNIX commands like a to-do list in a file to execute it.

3) What is the Importance of writing Shell Scripts?

Ans: The points given below explain the importance of writing shell scripts.

Shell script takes input from the user, file and displays it on the screen.
Shell scripting is very useful in creating your own commands.
It is helpful in automating some tasks of the day to day life.
It is useful for automating system administration tasks.
Mainly it saves time.

4) What are the Advantages of C Shell over Bourne Shell?

Ans: The advantages of C Shell over Bourne Shell are:

C shell allows aliasing of commands i.e. a user can give any name of his choice to the command. This feature is mainly useful when a user has to type the lengthy command again and again. At that point of time, instead of typing a lengthy command a user can type the name that he has given.
C shell provides command history feature. C shell remembers the previously typed command. Thus, it avoids typing the command again and again.

5) How many shell scripts come with UNIX operating system?

Ans: There are approximately 280 shell scripts that come with the UNIX operating system.

6) What are the default permissions of a file when it is created?

Ans: 666 i.e. rw-rw-rw- is the default permission of a file when it is created.


7) What are Shell Variables?

Ans: Shell variables are the main part of shell programming or scripting. They mainly provide the ability to store and manipulate information within a shell program.


8) What is the lifespan of a variable inside a shell script?

Ans: The lifespan of a variable inside shell script is only until the end of execution.


9) Generally, each block in UNIX is how many bytes?

Ans: Generally, each block in UNIX is of 1024 bytes.

10) What is a file system?

Ans: The file system is a collection of files which contain related information of the files.

How to check cronjob details in Magento 2?

Use the following command


crontab -l

Git fetch all data without checkout

git fetch origin master:master

MySql Database Export Command

mysqldump -u dbusername -p databasename> database.sql
then press enter, they you have to paste the password.

Install SSL Free lets encrypt

sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository universe
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install certbot python-certbot-nginx

sudo certbot --nginx

sudo service nginx restart


You have to check the 60 and 442 port are open or not in the inbout and outbound area.

Magento 2 with ZipPay payment method

Command 1: cd your Magento install dir

Command 2: composer require zipmoney/magento2

Command 3: composer update

Command 4: php bin/magento setup:upgrade

Command 5: php bin/magento setup:di:compile

How to Install Magento 2 on Ubuntu 18.04

#######   How to Install Magento 2 on Ubuntu 18.04 ######

Login with your server and follow the steps


sudo apt update && sudo apt upgrade
sudo apt install unzip

sudo apt install mysql-server mysql-client


sudo mysql

CREATE DATABASE magento2;

GRANT ALL ON magento2.* TO 'magento2'@'localhost' IDENTIFIED BY 'Z6TyZnMux0gcNRXk!1';   #magento 2 is db name and user name


UPDATE mysql.user SET Super_Priv='Y' WHERE user='magentotheme2' AND host='%';
UPDATE mysql.user SET Super_Priv='Y' WHERE user='magento2' AND host='%';
GRANT SUPER ON *.* TO magentotheme2@localhost;
GRANT SUPER ON *.* TO magento2@localhost;
flush privileges;

EXIT;


###################  Create system user

sudo useradd -m -U -r -d /home/www www
sudo usermod -a -G www www-data

#sudo chmod 750 /home/www

#########################   Installing and configuration php

sudo apt install php7.2-common php7.2-cli php7.2-fpm php7.2-opcache php7.2-gd php7.2-mysql php7.2-curl php7.2-intl php7.2-xsl php7.2-mbstring php7.2-zip php7.2-bcmath php7.2-soap

sudo systemctl status php7.2-fpm


sudo sed -i "s/memory_limit = .*/memory_limit = 2048M/" /etc/php/7.2/fpm/php.ini
sudo sed -i "s/upload_max_filesize = .*/upload_max_filesize = 256M/" /etc/php/7.2/fpm/php.ini
sudo sed -i "s/zlib.output_compression = .*/zlib.output_compression = on/" /etc/php/7.2/fpm/php.ini
sudo sed -i "s/max_execution_time = .*/max_execution_time = 18000/" /etc/php/7.2/fpm/php.ini
sudo sed -i "s/;date.timezone.*/date.timezone = UTC/" /etc/php/7.2/fpm/php.ini
sudo sed -i "s/;opcache.save_comments.*/opcache.save_comments = 1/" /etc/php/7.2/fpm/php.ini


sudo nano /etc/php/7.2/fpm/pool.d/www.conf

write the following

[www]
user = www
group = www

listen = /run/php/php7.2-fpm.sock
listen.owner = www
listen.group = www

;pm = dynamic
;pm.max_children = 5
;pm.start_servers = 2
;pm.min_spare_servers = 1
;pm.max_spare_servers = 3

pm = dynamic
pm.max_children = 25
pm.start_servers = 10
pm.min_spare_servers = 5
pm.max_spare_servers = 20
pm.max_requests = 500


Then

sudo systemctl restart php7.2-fpm

ls -al /var/run/php/php7.2-fpm.sock


#Installing Composer

curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer


########  Change user
sudo su www
then go to cd /home/www

run the following command to download the magento

composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition

To Install magento through command then run the following command

php bin/magento setup:install --base-url=http://limextechnology.com/ \
        --base-url-secure=https://limextechnology.com/ \
        --admin-firstname="Debendra" \
        --admin-lastname="Prusty" \
        --admin-email="debendra@limextechnology.com" \
        --admin-user="debendra" \
        --admin-password="admin1234@" \
        --db-name="magento2" \
        --db-host="localhost" \
        --db-user="magento2" \
        --currency=USD \
        --timezone=America/Chicago \
        --use-rewrites=1 \
        --db-password="Z6TyZnMux0gcNRXk!1"




############  If Nginx is not installed then run the following commands only ##############################
sudo apt update
sudo apt install nginx
sudo systemctl status nginx
sudo systemctl restart nginx

$$$$$$$$$  Some Command $$$$$$$$$$$$$$$$$$$$
sudo systemctl stop nginx
sudo systemctl start nginx
sudo systemctl restart nginx
sudo systemctl reload nginx
sudo systemctl disable nginx
sudo systemctl enable nginx
###############################  End Nginx installation #########################################



sudo nano /etc/nginx/sites-available/default

Add the followng lines


upstream fastcgi_backend {
server unix:/run/php/php7.2-fpm.sock;
}

server {

server_name limextechnology.com;

access_log /var/log/nginx/access-limex.log;
error_log /var/log/nginx/error-limex.log;

set $MAGE_ROOT /home/www;
set $MAGE_MODE developer; # or production
include /home/www/nginx.conf.sample;


}

server {
server_name limextechnology.com;
listen 80;

}



sudo nginx -t

sudo systemctl restart php7.2-fpm
sudo systemctl restart nginx

##################  End the Magento 2 Installation ###################################################