60 [UPDATED] MAGENTO Interview Questions and Answers pdf

MAGENTO Interview Questions and Answers pdf :-


1 What is Magento?


2 What technology used by Magento?


3 Explain Magento latest Versions and License.


4 What The History Behind Magento?


5 Explain features use of Magento.


6 What is EAV in Magento?


7 Explain Magento’s MVC architecture.


8 How Magento’s MVC works:


9 How Magento ORM works?


10 What permissions required for file and folder In Magento?
Magento Interview Questions and Answers
MAGENTO Interview Questions and Answers
11 How to upgrade to the latest version using Magento Connect?


12 What is code pool?


13 Can we override Community Module?


14 Explain about the Modules of Magento?


15 What is the difference between Mage::getSingletone() andMage::getModel() in Magento?


16 What is benefit of namespace (package) in magento?


17 How to include CMS block in template file(.phtml)?


18 How to add an external javascript/css file to Magento?


19 What are handles in magento (layout)?


20 How to improve magento performance?


21 How to get the Total Price of items currently in the Cart?


22 How to set different themes for logged in users?


23 How to create magento custom module?


24 How to fetch 5 bestsellers products programmatically?


25 What is the difference between Mage::getSingletone() and Mage::getModel() in Magento?


26 What is Module conflict?


27 Difference between javascript and jquery?


28 Difference between Final Class and Abstract Class.


29 What are the addAttributeToFilter Conditionals in Magento?


30 How to change Currency in INR in magento?


31. Difference between EAV and flat model


32. Is it mandatory to give Namespace while creating custom module in Magento?


33. How will you add/remove content from core’s system.xml file?


34.Can you have more than one Grid in a module?


35.How will you join flat table and EAV table in Magento?


36.How will you enable maintenance mode of your Magento website?


37.What are “magic methods” in Magento?


38.How many database tables will Magento create when you make a new EAV module?


39.Where will you write your module’s business logic in Magento?


40. Explain different types of sessions in Magento (e.g. customer/session, checkout/session, core/session) and the reason why you store data in different session types? 

Explain different types of sessions in Magento (e.g. customer/session, checkout/session, core/session) and the reason why you store data in different session types?

Customer sessions stores data related to customer, checkout session stores data related to quote and order. They are actuall under one session in an array. So firstname in customer/session will be $_SESSION['customer']['firstname'] and cart items count in checkout/session will be $_SESSION['checkout']['items_count']. The reason Magento uses session types separately is because once the order gets placed, the checkout session data information should get flushed which can be easily done by just unsetting $_SESSION['checkout'] session variable. So that the session is not cleared, just session data containing checkout information is cleared and rest all the session types are still intact.

Where will you write your module’s business logic in Magento?

inside Model

How many database tables will Magento create when you make a new EAV module?

Magento creates 6 tables when you create new EAV module. Tables: module, module_datetime, module_decimal, module_int, module_text and module_varchar. one is the main entity table, and rest 5 tables which holds attribute’s data in different data types. So that integer values will go to module_int table, price values to module_decimal, etc.

What are “magic methods” in Magento?

Magento uses __call(), __get(), __set(), __uns(), __has(), __isset(), __toString(), __construct(), etc. magic methods. You can find more details inside class Varien_Object
For more information about magic methods: http://php.net/manual/en/language.oop5.magic.php

How will you enable maintenance mode of your Magento website?

If you want your Magento website to show in maintenance mode, you will have to do two things.

1. Create a file name maintenance.flag in your magento root directory. Contents under this file doesn’t matter, you can keep it empty.

2. Change the maintenance file (located in magento root -> errors -> default directory) to show proper message when user visits your website.  

How will you join flat table and EAV table in Magento?

Joining tables in Magento when it comes to EAV with Flat table is quite complicated. Consider you want to join sales_flat_order table with customer EAV tables to get Customer’s firstname and lastname, it becomes difficult as customer’s name comes from customer_entity_varchar table.

Below code will join sales order flat table with customer EAV to get customer’s full name in the collection along with all the order details.
 

$coll = Mage::getModel('sales/order')->getCollection();

$fn = Mage::getModel('eav/entity_attribute')->loadByCode('1', 'firstname');
$ln = Mage::getModel('eav/entity_attribute')->loadByCode('1', 'lastname');

$coll->getSelect()
    ->join(array('ce1' => 'customer_entity_varchar'), 'ce1.entity_id=main_table.customer_id', array('firstname' => 'value'))
    ->where('ce1.attribute_id='.$fn->getAttributeId())
    ->join(array('ce2' => 'customer_entity_varchar'), 'ce2.entity_id=main_table.customer_id', array('lastname' => 'value'))
    ->where('ce2.attribute_id='.$ln->getAttributeId())
    ->columns(new Zend_Db_Expr("CONCAT(`ce1`.`value`, ' ',`ce2`.`value`) AS fullname"));

print_r($coll->getData());

Can you have more than one Grid in a module?

YES

How will you add/remove content from core’s system.xml file?

<config>
    <sections>
        <catalog>
            <groups>
                <frontend>
                    <label>Overriding Catalog Frontend in system config</label>
                </frontend>
            </groups>
        </catalog>
    </sections>
</config>

<config>
   <sections>
        <payment>
            <groups>
                <cashondelivery>
                    <fields>
                        <!--changing cashondelivery payment method settings-->
                    </fields>
                </cashondelivery>
            </groups>
         </payment>
    </sections>
</config>

Is it mandatory to give Namespace while creating custom module in Magento?

No

Difference between EAV and flat model

EAV is entity attribute value database model, where data is fully in normalized form. Each column data value is stored in their respective data type table. Example, for a product, product ID is stored in

catalog_product_entity_int table, product name in

catalog_product_entity_varchar, product price in

catalog_product_entity_decimal, product created date in

catalog_product_entity_datetime and product description in

catalog_product_entity_text table.

EAV is complex as it joins 5-6 tables even if you want to get just one product’s details. Columns are called attributes in EAV.

Flat model uses just one table, so it’s not normalized and uses more database space. It clears the EAV overhead, but not good for dynamic requirements where you may have to add more columns in database table in future. It’s good when comes to performance, as it will only require one query to load whole product instead of joining 5-6 tables to get just one product’s details. Columns are called fields in flat model.

How to change Currency in INR in magento?

In Magento, Currency change is very easy just we need to follow below step: 

1. From the Admin panel, select System > Configuration.

2. From the Configuration panel on the left, under General, select the Currency Setup tab.

Click to expand the Currency Options section. Then, do the following:

1. In the Base Currency list, select the primary currency that is used for store transactions.

2. In the Default Display Currency list, select the primary currency that is used to display pricing in your store.

3. In the Allowed Currencies list, select all currencies that are accepted as payment by your store. When finished, click the Save Config button.

To customize currency symbols:

Currency symbols appear in the Admin panel of your store, and are also used throughout your storefront in orders, customer checkout, and so on.

1. From the Admin panel, select System > Manage Currency > Symbols.

2. Each enabled currency for your store appears in the Currency list.

3. Enter a custom symbol to use for each currency, or select the standard symbol selecting the Use Standard checkbox to the right of each currency. When finished, click the Save Currency Symbols button.

What are the add Attribute To Filter Conditionals in Magento?

In Magento we can use addAttributeToFilter Conditions same as WHERE in SQL
Below are the all condtions

Equals: eq
$_products->addAttributeToFilter('status', array('eq' => 1));

Not Equals - neq
$_products->addAttributeToFilter('sku', array('neq' => 'test-product'));

Like - like
$_products->addAttributeToFilter('sku', array('like' => 'UX%'));

One thing to note about like is that you can include SQL wildcard characters such as the percent sign.

Not Like - nlike
$_products->addAttributeToFilter('sku', array('nlike' => 'err-prod%'));

In - in
$_products->addAttributeToFilter('id', array('in' => array(1,4,98)));

When using in, the value parameter accepts an array of values.

Not In - nin
$_products->addAttributeToFilter('id', array('nin' => array(1,4,98)));

NULL - null
$_products->addAttributeToFilter('description', 'null');

Not NULL - notnull
$_products->addAttributeToFilter('description', 'notnull');

Greater Than - gt
$_products->addAttributeToFilter('id', array('gt' => 5));

Less Than - lt
$_products->addAttributeToFilter('id', array('lt' => 5));

Greater Than or Equals To- gteq
$_products->addAttributeToFilter('id', array('gteq' => 5));

Less Than or Equals To - lteq
$_products->addAttributeToFilter('id', array('lteq' => 5));

Difference between Final Class and Abstract Class

Final Class: A Class which Can't be inherited by other class, that class is called final class. You all knows that final class is inbuilt in java. But in C++ you have to create final class.Two types of Final class, you can create . One who want to create object of final class on Heap and other who wants to create object of Final class on stack.

1.It makes use of private constructor, virtual inheritance and friend class.

2.In place of priavte constructor, use private Destructor. Because Constructor can be overloaded and Destructor can'nt be overloaded.

Difference between javascript and jquery?

Javascript: Javascript is Client side scripting/programming language.

Jquery: Jquery is library buit in javascript.

What is Module conflict?

We install one module(Extension Conflict) to findout that Class which is Conflict. We have to written only one config file for both module.

What is the difference between Mage::getSingletone() and Mage::getModel() in Magento?

Mage::getSingletone() always finds for an existing object if not then create that a new object but Mage::getModel() always creates a new object.

How to fetch 5 bestsellers products programmatically?

<!--?php
Mage::getResourceModel(‘reports/product_collection’)--->addOrderedQty()
->addAttributeToSelect(‘*’)->setPage(1, 5)->load();
?>

How to create magento custom module?

Steps to create custom magento module: 

Namespace : Viral

Module Name : Mymodule

1. Create directory Mymodule in app/code/local/Viral

2. Create Block, controllers, etc, Module directories. Create controller, block and module file as required.

3. Create module configuration file (app/code/local/Viral/Mymodule/etc/config.xml).

4. Create xml file (app/etc/modules/Viral_ Mymodule.xml)to enable/disable module and tell magento system from which code pool that module will be taken.

How to set different themes for logged in users?

if(Mage::getSingleton('customer/session')->isLoggedIn()):
Mage::getDesign()->setPackageName('package_name')->setTheme('themename');
endif;

How to get the Total Price of items currently in the Cart?

<!--?php helper(‘checkout’)--->formatPrice(Mage::getSingleton(‘checkout/cart’)->getQuote()->getGrandTot

How to improve magento performance?

Enabled magento caching
MySQL Query caching
Enable Gzip Compression
Disable any unused modules
Disable the Magento log
Optimise your images
Combine external CSS/JS into one file
Enable Apache KeepAlives: Make sure your Apache configuration has KeepAlives enabled.

What are handles in magento (layout)?

Handles are basically used for controlling the structure of the page like which block will be displayed and where. First level child elements of the node are called layout handles. Every page request can have several unique Handles. The handle is called for every page. handle for products belongs to virtual product type, PRODUCT_TYPE_simple is called for product details page of simple product type and PRODUCT_TYPE_virtual is called for the virtual product detail page and customer_logged_in handle is called only if customer is logged in. The muster_index_index handle is created by combining the frontName (muster), Action Controller (index), and Action Controller Action Method (index) into a single string and this handle will be called only when /muster/index/index url is accessed.

<layout version="0.1.0">
<muster_index_index>
<reference name="root">
<block type="page/html" name="root" output="toHtml" template="../somepage.phtml">
</block></reference>
</muster_index_index>
</layout>

How to add an external javascript/css file to Magento?

<action method="addJs"><script>js/yourfile.js</script></action>
<action method="addCss"><stylesheet>css/yourstyle.css</stylesheet></action>
OR
<action method="addItem"><type>skin_js</type><name>js/ yourfile.js</name></action>
<action method="addItem"><type>skin_css</type><name>css/yourstyle. css</name></action>

How to include CMS block in template file(.phtml)?

Access block's content from .phtml template file by :

1 echo $this->getLayout()->createBlock('cms/block')->setBlockId('static_block_id')->toHTML();

What is benefit of namespace (package) in magento?

We can have more than one module with same name but they should be placed in different namespaces. All magento core modules are contained in mage namespace.

core/Mage/Catalog
local/Muster/CustomModule 

What is the difference between Mage::getSingletone() andMage::getModel() in Magento?

Mage::getSingletone() always finds for an existing object if not then create that a newobject but Mage::getModel() always creates a new object.

Explain about the Modules of Magento?

Magento supports installation of modules through a web-based interface accessible through the administration area of a Magento installation. Modules are hosted on the Magento eCommerce website as a PEAR server. Any community member can upload a module through the website and is made available once confirmed by a member of the Magento team. Modules are installed by entering a module key, available on the module page, into the web based interface. There are three categories of modules hosted on Magento Connect:

  • Core Modules 
  • Community Modules 
  • Commercial Modules 

Core and Community modules can be installed via the administration area. Commercial module pages provide price information and a link to an external website.

Can we override Community Module?

Yes we can override to the local.

What is code pool?

It is a concept to pull the code in magento structured format.
magento 

|_app
|_code
|_community
|_core
|_local

How to upgrade to the latest version using Magento Connect?

Upgrading Magento to the latest version is a fairly simple task. Copy and Paste this key magento-core/Mage_All_Latest VIA Magento Connect where it states Paste extension key to install. This will upgrade Magento to the newest version.

What permissions required for file and folder In Magento?

A security Issue happen if Setting all the files & folders to 777 will make them writable by everyone.!

Normal Operation For the normal operation or installation of a Magento store, only 2 folders need to be writable:

/media - for web accessible files, such as product images

/var - for temporary (cache, session) and import/export files

Installation During installation Magento Install Wizard will create app/etc/local.xml file which contains database configuration and global encryption key for your Magento copy. Meaning app/etc folder has to be writable to web service.

Web based MagentoConnect manager If you wish to use web based downloader for installation, upgrades or MagentoConnect extensions installation, you will need to have write permissions on ALL magento files including the root Magento folder. Files and folders will need to be returned to 655 non-writable permissions after installation.

How Magento ORM works?

ORM stands for Object Relational Mapping. It’s a programming technique used to convert different types of data to Objects and vice versa.

In Magento, ORM is shown as Model (based on Zend Framework’s Zend_Db_Adapter), which further breaks down to two types of Models.

- First is the “simple” i.e. Regular Models which is nothing but flat table or our regular table structure.

- Second Model is EAV (Entity Attribute Value), which is quite complicated and expensive to query.

All Magento Models interacting with database are inherited from Mage_Core_Model_Abstract class, which is further inherited from Varien_Object.

Difference between two Models is, Simple Model is inherited from Mage_Core_Model_Resource_Db_Abstract class, while EAV is inherited from Mage_Eav_Model_Entity_Abstract.

When you want to get some data in Magento, you can call it like this: Mage::getModel('module/model')->load(1);

ie. Where 1 is the primary key id for some Regular/Simple table, while in EAV so many tables are joined to fetch just single row of data.

How Magento’s MVC works

It work like below:

1. When you enter the URL (something like http://mysite.com/frontname/controller/method/param1/value1/param2/value2), this URL is intercepted by one PHP file called index.php which instantiates Magento application

2. Magento application instantiates Front Controller object

3. Further, front controller instantiates Router objects (specified in module’s config.xml, global tag)

4. Now, Router is responsible to “match” the frontname which is in our URL

5. If “match” is found, it sees controller name and method name in the URL, which is finally called.

6. Now depending on what is written in action name (method name), it is executed. If any models are called in it, the controller method will instantiate that model and call the method in it which is requested.

7. Then the controller action (method) instantiate the Layout object, which calls Block specified for this action (method) name (Each controller action name have block and template file associated with it, which can be found at app/design/frontend or adminhtml/namespace/module/layout/module.xml file, name of layout file (module.xml) can be found in config.xml of that module, in layout updates tag).

8. Template file (.phtml) now calls the corresponding block for any method request. So, if you write $this->methodName in .phtml file, it will check “methodName” in the block file which is associated in module.xml file.

9. Block contains PHP logic. It references Models for any data from DB.

10. If either Block, Template file or Controller need to get/set some data from/to database, they can call Model directly like Mage::getModel(‘modulename/modelname’).

Explain Magento’s MVC architecture

First of all, what is MVC?
MVC stands for Model-View-Controller. Any application that separates it’s data access, business logicand user interface is called MVC. There can be two types of MVC:
convention-based and configuration-based.

Example, 
- CakePHP is convention-based, i.e. you just need to follow the instructions of the core system to get your module ready in just few lines.
- Magento is configuration-based, i.e. you need to specify each and every thing to your module’s config file in order to get it work. Magento has Controller (for Routing),
Block (for Business Logic), Model (for DB access, sql) and Template file (for Presentation i.e. View).

What is EAV in Magento?

In EAV database model, data are stored in different smaller tables rather than storing in a single table. Example: Product name is stored in catalog_product_entity_varchar table. Product id is stored in catalog_product_entity_int table. Product price is stored in catalog_product_entity_decimal table. Magento Use EAV database model for easy upgrade and development as this model gives more flexibility to play with data and attributes. 

Explain features use of Magento.

In addition to a solid architecture and framework, there are several unique reasons why Magento makes a great choice for an eCommerce solution.
• One of the most amazing features about Magento is that you can design and develop multiple web sites and they store and share one administrative interface.
This extremely flexible feature allows you to modify and control multiple web sites. All of your products inventory and pricing can be controlled from one
central location. There is no longer a need to login to multiple locations to handle multiple web sites. Magento has the ability to control them all.

• Magento supports over sixty languages, multiple currencies, and tax rates. This gives you the ability to easily expand in the global market.

• Layered navigation gives users customized browsing options when viewing products by categories. You can now sort products by price, size, color, and other
customizable attributes.

• Magento also has built-in web services. This flexibility allows external applications to access magento’s data without changing the underlying core code. Currently,
SOAP and XML-RPC protocols are available out of the box.

• Magento has Search Engine Optimization (SEO) built in from the start. It has the ability to handle friendly URL rewrites which make it easy for search engines to
index your store and products.

• Not only does Magento offer real-time carrier rates and quotes, users can ship products from one order to multiple shipping address. This makes gift shopping
especially easy.

• Magento also has several reporting features built in. These allows for easy view of sales reports, best-selling products, and customer reporting. They can even be
exported in a CSV format to integrate with excel and other database programs.

• Magento has designed its file structure to three major sections: core, functionality, and design. This allows for easy updating of images and CSS styling without
affecting the functionality of the site. Store functionality can also be easily customized without affecting the Magento’s core. As a result, you can modify
Magento without having to worry about upgrading to newer versions in the future.

• Magento has a huge community backing. In addition to a public forum and bug tracking, Magento also has its own public repository of extensions called Magento
Connect. Magento Connect features both free and commercial extensions to enhance the functionality of your web site.

• Since Magento is released under the Open Software License (OSL), the Magento Community Edition is available at no cost. In turn, this allows web site developers
and eCommerce web site owners to cut down on software costs.

What The History Behind Magento?

Varien began developing Magento in January of 2007. It was their vision to establish an eCommerce platform unlike anything else on the market. Varien originally planned on building an eCommerce platform based on a fork of osCommerce, but decided to write their own system using the Zend Framework instead. During Varien’s six month beta period, they had over 225,000 downloads of Magento. The first public release of Magento, version 1.0, was released on March 31, 2008. Shortly after, Magento 1.1 was released.

Magento 1.1 fixed many bugs found in version 1.0, but also included a faster and more informative administrative user interface. Magento 1.2 was released on December 29, 2008.

This version included several upgraded Zend Framework libraries and a new feature: downloadable products. Magento 1.3 was released on March 30, 2009. This version increased Magento’s speed in both public and administrative views. The Magento Enterprise Edition version 1.3 Enterprise was released on April 15, 2009. This version requires a service agreement with Varien and costs $8,900 USD per year and it includes technical support which is not available with the Community Edition.

In February 2011, eBay announced it had made an investment in Magento in 2010, worth a 49% ownership share of the company. As of June 6, 2011 eBay owns 100% of Magento. eBay announced that Magento would join eBay's new X.Commerce initiative Magento's CEO and co-founder Roy Rubin wrote on the Magento blog stating that "Magento will continue to operate out of Los Angeles, with Yoav Kutner and me as its leaders.". As of February 2, 2012 Magento passed 4 million downloads of its software platform.

Explain Magento latest Versions and License

Latest Magento stable version is 1.7 and new version is 1.8. Magento is a open source eCommerce platform for a complete eCommerce web site solution. Magento’s open source architecture enables the user to maintain complete control over the structure and functionality of a web site.

What technology used by Magento?

Magento uses PHP as a web server scripting language and the MySQL Database. One of the most impressive aspects of Magento is the use of the Zend Framework. This allows for separation of the Model-View-Controller (MVC) which separates its core operations from functionality and appearance. The data model is based on the Entity-attribute-value model that stores data objects in tree structures, thus allowing a change to a data structure without changing the database definition.

What is Magento?

Magento is a feature-rich eCommerce platform built on open-source technology that provides online merchants with unprecedented flexibility and control over the look, content and functionality of their eCommerce store. Magentos intuitive administration interface features powerful marketing, search engine optimization and catalog-management tools to give merchants the power to create sites that are tailored to their unique business needs. Designed to be completely scalable and backed by Variens support network, Magento offers companies the ultimate eCommerce solution.