Magento Interview Preparation Guide
Download PDF

Magento Interview Questions and Answers will guide us now that Magento is an open-source ecommerce web application launched on 2008. It was created by Varien, building on components of the Zend Framework. Magento is available under the Open Software License version 3.0. Since version 1.1.7 some parts are licensed under the Academic Free License version 3.0. Learn Magento and get preparation for the Job of Magento with the help of this Magento Interview Questions with Answers Guide

38 Magento Questions and Answers:

Table of Contents:

Magento Interview Questions and Answers
Magento Interview Questions and Answers

1 :: How to change admin url?

app/etc/local.xml
<admin>
<routers>
<adminhtml>
<args>
<frontName><![CDATA[admin]]></frontName>
</args>
</adminhtml>
</routers>
</admin>
OR:-
System=>Config=>Advanced=>Admin=>Admin Base URL
-> Use Custom Admin URL :- No
-> Use Custom Admin Path :- Yes
-> Custom Admin Path :- Your Choice

2 :: 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.

3 :: What are the 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.

1 <layout version="0.1.0">
2 <muster_index_index>
3 <reference name="root">
4 <block type="page/html" name="root" output="toHtml" template="../somepage.phtml">
5 </block></reference>
6 </muster_index_index>
7 </layout>

4 :: 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.

5 :: How 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 check-box to the right of each currency.
When finished, click the Save Currency Symbols button.

6 :: What are the addAttributeToFilter 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));

7 :: Explain the 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 private constructor, use private Destructor.
Because Constructor can be overloaded and Destructor can't be overloaded.

8 :: Explain 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.

9 :: 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.

10 :: How to fetch bestsellers products programmatically?

1) <!--?php
2) Mage::getResourceModel('reports/product_collection')--->addOrderedQty()
3) ->addAttributeToSelect('*')->setPage(1, 5)->load();
4) ?>

11 :: 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.

12 :: How to get the total price of items currently in the Cart?

<!--?php helper('checkout')--->formatPrice(Mage::getSingleton('checkout/cart')->getQuote()->getGrandTotal()); ?>

13 :: How to set different themes for logged in users?

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

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

1) <action method="addJs"><script>js/yourfile.js</script></action>
2) <action method="addCss"><stylesheet>css/yourstyle.css</stylesheet></action>
3) OR
4) <action method="addItem"><type>skin_js</type><name>js/ yourfile.js</name></action>
5) <action method="addItem"><type>skin_css</type><name>css/yourstyle. css</name></action>

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

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

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

16 :: What are the benefits 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

17 :: Explain 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.

18 :: What are the categories of modules hosted?

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.

19 :: What are 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.

20 :: Can we override community module?

Yes, we can override to the local.

21 :: What is Magendo's code pool?

It is a concept to pull the code in Magento structured format.
Magento
|_app
|_code
|_community
|_core
|_local

22 :: Tell me 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.

23 :: What permissions are required for files and folders In Magento?

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.

24 :: 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.
1) First is the "simple" i.e. Regular Models which is nothing but flat table or our regular table structure.
2) 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.

25 :: How Magento's MVC works?

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').