Magento Study Set

  1. What is Magento?
    Magento is an e-commerce platform created on open source technology, which provides online merchants with an exceptional flexibility and control over the content, look and functionality of their e-commerce store.  Designed to be completely scalable and backed by Variens support network, Magento offers companies the ultimate eCommerce solution.
  2. What is the architecture of Magento?
    Magento architecture is a typical PHP MVC (Model-View-Controller) application, where all the Controllers will be in one folder and all the Models in another, etc.  Based on their functionality files are grouped together, which are referred as modules in Magento.
  3. What are the different versions of Magento?
    Different version of Magento includes;

    • Magento Enterprise
    • Magento .go
    • Magento Community
  4. What technology does Magento use?
    Magento uses PHP as a web server scripting language and MySQL for database.
  5. What is the difference between Mage::getModel() and Mage::getSingleton() in Magento?
    Mage::getModel(): It always creates a new object

    Mage: :getSingleton(): It always look for an existing object and if not then creates a new object
  6. What are the basic features of Magento?
    There are mainly 11 features;

    • Reporting and Analytics
    • Product and Catalog Browsing
    • Customer Accounts
    • Order Management
    • Payment
    • Site Management
    • Shipping
    • Search engine optimization
    • Marketing promotions and tools
    • Checkout
    • International Support
  7. What are the limitations of Magento?
    Magento is supported by PHP, comparatively to other e-commerce solutions, Magento might be slow in performance

    It becomes a complex system if it is not using object-oriented programming

    Magento requires much space and memory
  8. Explain how you can enhance the Magento performance?
    To enhance the Magento performance there are 10 recommended adjustments;

    • In General;
    • Use SSD hard drives
    • Don't run your MySQL server and webserver (ngnix, Apache) on the same machine

    • The 8 key things to do are;
    • Disable the Magento log
    • Combine external CSS/JS into one file
    • Disable any unused modules
    • MySQL Query Caching
    • Enable Magento caching
    • Enable Gzip compression
    • Optimize your image
    • Enable Apache KeepAlives: Make sure your Apache configuration has KeepAlives enabled.
  9. Explain how you can show a certain number of products for guests in Magento?
    • In the toolbar block you will see;
    • app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php

    • There is a method;
    • Public function setCollection($collection);

    • Inside there is a piece of code;
    • $limit= (int)$this->get Limit();
    •      If ($limit) {
    •             $this ->_collection >setPageSize($limit);
    •       } 

    You have to change variable $limit; you should override that block in the local pool, not change directly in the core.  In order to see whether the customer is a guest, you can use this code;

    Mage:: getSingleton(‘customer/session’) -> isLoggedIn()
  10. What code should you use to see whether a customer is a guest?
    In order to see whether the customer is a guest, you can use this code;

    Mage:: getSingleton(‘customer/session’) -> isLoggedIn()
  11. How can all billing information be managed through Magento?
    From the client Magento account, you can do the following 5 things;

    • Update your billing address
    • Add a credit card
    • View your billing history
    • Add a PayPal account
    • Produce a print ready receipt
  12. How can you change Magento Core API settings?
    To change Magento Core API settings, you have to

    • Go to Admin menu, choose System -> Configuration
    • Select Magento Core API on the left side of the Configuration Panel, under Services
    • Tap to expand the General Settings section and you can
    • Type the name of the Default Response Charset that you want to use
    • Determine the Client Session Timeout in seconds
    • Click the Save Config button when complete
  13. How can you make Magento secure for the client?
    Best practices for Magento includes;

    • Using a strong password and changing them at regular intervals
    • Disable remote access to Magento Connect Manager
    • Disable Downloader on production sites
    • Restrict access to safe IP addresses
  14. What is the benefit of applying Connect Patches in Magento?
    In Magento, applying connect patch;

    • Enables easy installation of packages with installation; it overwrites any existing translations for the same time
    • For enhancing security, by default Magento Connect uses HTTP to download extensions instead of FTP
    • With a dash character in the name, extension developers can now create extensions
    • Magento administrators will be informed now who tries to install an extension with insufficient file system privileges
  15. How can extension developers create extensions in Magento?
    With a dash character in the name, extension developers can now create extensions
  16. How you can move Magento to another directory?
    To move Magento to another directory you have to follow these steps;

    Suppose you have Magento installed in the following location

    • On visiting your site, you want Magento to be the first thing to come up

    • Let's assume you have a directory structure like this;
    • /home/username/public_html/
    • Which means Magento would be installed here;
    • /home/username/public_html/store/

    • Login to the backend of the Magento first and go to;
    • System -> Configuration -> Web

    • Update the Secure and Unsecure URL for your store and then link to your site via SSH and then go to the directory, where you will be shifting Magento;
    • cd public_html/

    • Now, transfer all the files from the store directory to the directory you are in
    • mv store/* store/.htaccess

    • Delete the cache data;
    • rm –vf var/cache/

    Now Magento is moved to another directory.
  17. Explain how you can reset Magento file & Directory permissions?
    You can reset Magento file & Directory to their default and secure permissions, by following commands from the directory where Magento is installed;

    • find . –type f –exec chmod 644 {};
    • find . –type d –exec chmod 755 {};
    • chmod +x mage
  18. Explain how you can configure Magento to work with another domain?
    To do that, in the admin area, you have to change the Magento Base URL option.

    • To do this, navigate to your Magento admin area> System > Configuration and click Web on the left menu.
    • Select the Unsecure option and after that edit the base URL field to change the URL that will be used for normal (HTTP) connections.
  19. Why does Magento use the EAV database model?
    In the EAV database model, data is stored in different smaller tables rather than storing in a single larger table.

    • 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 uses the EAV database model for easy upgrade and development as this model givesmore flexibility to play with data and attributes.
  20. What database model does Magento use and explain something about it;
    Magento uses the EAV database model.

    • Entity–attribute–value model (EAV) is a data model to describe entities where the number of attributes (properties, parameters) that can be used to describe them is potentially vast, but the number that will actually apply to a given entity is relatively modest. In mathematics, this model is known as a sparse matrix.
    • EAV is also known as object–attribute–value model, vertical database model and open schema.
    • Magento uses the EAV database model for easy upgrade and development as this model givesmore flexibility to play with data and attributes.
  21. Using Magento Connect, how do you upgrade to the latest version of Magento?
    • 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.
  22. What are the various modules available in 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.
  23. What are the technologies used by Magento?
    Magento uses PHP as a web server scripting language and the MySQL Database. 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.
  24. What is a PEAR server?
    • PEAR is short for "PHP Extension and Application Repository" and is pronounced just like the fruit. The purpose of PEAR is to provide;
    • A structured library of open-source code for PHP users
    • A system for code distribution and package maintenance
    • A standard style for code written in PHP
    • The PHP Extension Community Library (PECL)
    • A web site, mailing lists and download mirrors to support the PHP/PEAR community

    PEAR is a community-driven project governed by its developers. PEAR's governing bodies are subdivided into the PEAR Group, Collectives, and a President. PEAR's constitution (adopted in March 2007) defines these groups. The PEAR project was founded in 1999 by Stig S. Bakken and quite a lot of people have joined the project.
  25. Describe the MVC structure in Magento;
    The Model-View-Controller (MVC) architecture traces itsorigins back to the Smalltalk Programming language and XeroxParc. Since then, there have been many systems that describetheir architecture as MVC. Each system is slightlydifferent, but all have the goal of separating data access,business logic, and user-interface code from one another.
  26. 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

    • and all custom modules are placed in;
    • local/CustomModule
  27. How do you include a 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();
  28. What are the ways to add an external CSS or Javascript file to a Magento app?


    • skin_jsjs/ yourfile.js
    • skin_csscss/yourstyle. css
  29. 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 the 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 /zag/index/index url is accessed.
  30. Which factors affect performance of magento?
    • 1. EAV structure of magento database, even for retrieving single entity the query becomes very complex .
    • 2. Magento’s template system involves a lot of recursive rendering
    • 3. Huge XML trees built up for layout configuration, application configuration settings
  31. How can you improve magento performance?
    • Use SSD hard drives
    • Don't run your MySQL server and webserver (ngnix, Apache) on the same machine
    • 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.
  32. Since Magento is built on PHP what is a way to tweak the PHP configuration to help it perform better?
    • Seeing that Magento is built on PHP, tweaking the PHP configuration will help make it perform better. One way of doing so is to increase the memory limit to at least 64MB.
    • To increase, follow these steps;
    • locate your php.ini used by your webserver, e.g. /etc/php5/apache2/php.ini on Ubuntu
    • open php.ini and change the value for memory_limit to at least 64MB (set it higher if your system configuration allows for it);
    • memory_limit=64M

    Also have a  look at php.ini.sample in your Magento document root folder as it provides some more basic parameters to play around with.
  33. Why is it beneficial in Magento to enable Apache KeepAlives?
    If you're running the Apache webserver (, the keep-alive directive is used to to keep an already established TCP session open between the server and a user's browser for it to be reused. This uses more memory on the webserver but increases the performance because the overhead of terminating and creating a new TCP connection for every single asset to be downloaded from the server is eliminated.

    • To enable it, add the following to your http.conf or .htaccess file;
    • <IfModule mod_headers.c>
    •      Header set Connection keep-alive
    • </IfModule>

    For a more in-depth discussion, see here:
  34. Describe the procedure of moving Magento's var/cache to tmpfs;
    The default installation of Magento uses var/cache in your Magento document root as the slow cache location, i.e. reads and writes from the hard-drive. These reads/writes are very slow and will quickly become a performance killer for all but the smallest online stores. 

    Therefore, we can speed things up by having tmpfs take care of var/cache;

    • 1. stop your webserver, e.g.:
    •      sudo service apache2 stop

    • 2. Clear the cache:
    •      rm -rf /var/www/magento/var/cache/*

    • 3. Mount var/cache using tmpfs:
    •      mount tmpfs /var/www/html/magento/var/cache -t tmpfs -o size=64m

    • 4. restart your webserver, e.g.:
    • sudo server apache2 restart

    Play around with the allocated memory size (here: 64MB). Try 128MB or even 256MB but this depends on your system configuration and available RAM.
  35. Describe the benefits of Page Caching in Magento;
    • Using Magento's page caching, load is taken off from the webserver by serving pages already visited before from a cache which makes it a lot faster. There are a few page caching extensions available for Magento, we recommend one of the following:
    • Zoom Full-Page Cache (free):
    • Full Page Cache Pro (commercial):
    • Brim's Full Page Cache:

    Also have a look at if you want to know in more detail how page caching and hole punching works.
  36. Describe the 2-level caching system provided by the Zend framework within Magento;
    Magento uses the 2-level caching system provided by the Zend framework, a fast front-end cache (in-memory, specialised solutions) and a slower backend cache (database, file-system).
  37. Describe the steps and benefots of enabling APC for Magento;
    APC which caches the compiled PHP opcode so that subsequent requests to the same PHP resource can be served from the cache, and don't need to be re-interpreted and re-compiled for every request.

    To enable APC on a Linux system, do the following;

    1. install the PHP extension for APC:

    •      sudo apt-get install php-apc
    • OR
    •      sudo apt-get install php5-apc

    • 2. find the apc.ini configuration file and edit it accordingly. In Ubuntu 12.04, it is located here;
    • /etc/php5/conf.d/apc.ini

    3. Enable APC in app/etc/local.xml.additional under config > global > cache > backend:

    • 4. Once done, restart your web server, for example;
    •      sudo service apache2 restart

    5. By now, APC should be working and you should see a noticeable performance enhancement.

    Our own tests with APC enabled shows a performance boost of factor 3!
  38. Discuss the use of Redis cache in Magento
    Redis ( is another top-shelf cache solution, which unlike APC, supports tagging, i.e. logical groupings of cache entries (which really are key-value pairs). Since Magento uses tagging quite a bit, a cache that supports tagging is performing better and faster than one without.
  39. Discuss the use of a CDN in Magento and what are the derived benefits?
    Using a content delivery network (CDN) such as MetaCDN enables serving your assets from a location geographically closest to your customers and hence reduces latency and increases download speed for those assets. Fast and responsive website make customers happy.

    Magento lets you define where certain assets (CSS, javascript, images, etc.) are loaded from such as a URL pointing to a CDN.
  40. Describe the syntax of the code needed to get the total price of items currently in the cart;
    helper(‘checkout’)->formatPrice(Mage::getSingleton(‘checkout/cart’)->getQuote()->getGrandTotal()); ?>
  41. How can you set different themes for logged in users in Magento?
  42. What is the syntax to create a magento custom module?
    Steps to create custom magento module:

    • Namespace : Zag
    • Module Name : Mymodule

    • 1. Create directory Mymodule in app/code/local/Zag
    • 2. Create Block, controllers, etc, Module directories. Create controller, block and module file as required.
    • 3. Create module configuration file (app/code/local/Zag/Mymodule/etc/config.xml).
    • 4. Create xml file (app/etc/modules/Zag_ Mymodule.xml)to enable/disable module and tell magento system from which code pool that module will be taken.
  43. How can you set different themes for each store in Magento?
    • Navigate to;
    • System>Designs

    Then, add new design change or edit existing. You can select Store and Custom Design.
  44. How can you make a product’s custom attributes searchable in advance search?
    • Go to;
    • Catalog > Attributes > Manage Attributes

    Edit the attribute and select “Yes” for Use in Advanced Search.
  45. How can you fetch 5 bestsellers products programmatically in Magento?
    • Mage::getResourceModel(‘reports/product_collection’)
    • ->addOrderedQty()
    • ->addAttributeToSelect(‘*’)
    • ->setPage(1, 5)
    • ->load();
  46. Explain what is MVC?
    MVC stands for Model-View-Controller. Any application that separates it’s data access, business logic and 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).
  47. Describe how Magento's MVC works;
    • 1. When you enter the URL (something like, this URL is intercepted by one PHP file called index.php which instantiates the 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 the controller name and method name in the URL, which is finally called.
    • 6. Now depending on what is written in the 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 which is requested.
    • 7. Then the controller action (method) instantiate the Layout object, which calls the Block specified for this action (method) name (Each controller action name has a 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 the DB.
    • 10. If either Block, Template file or Controller needs to get/set some data from/to database, they can call the Model directly like Mage::getModel(‘modulename/modelname’).
  48. What is ORM and describe how it is implemented in Magento;
    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 the 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 are nothing but a flat table or our regular table structure.
    • The Second Model is EAV (Entity Attribute Value), which is quite complicated and expensive to query. All Magento Models interacting with the database are inherited from Mage_Core_Model_Abstract class, which is further inherited from Varien_Object.

    The difference between the two Models is that Simple Model is inherited from Mage_Core_Model_Resource_Db_Abstract class, while EAV is inherited from Mage_Eav_Model_Entity_Abstract.
  49. What is a codePool in Magento?
    codePool helps Magento to locate modules inside app/code/ for processing.

    • codePool is a tag which you have to specify when registering new module in;
    •      app/etc/modules/Company_Module.xml

    There are 3 codePools in Magento: core, community and local, which are resided at app/code/ directory.

    Core codePool is used by the Magento core team, Community is generally used by 3rd party extensions and Local codePool should be used for in-hour module development and overriding of core and community modules for custom requirement.
  50. When will you need to clear cache to see the changes in Magento?
    When you have added/modified XML, JS, CSS file(s).
  51. Using Magento how will you enable the product’s custom attribute visibility in the frontend?
    In the Manage Attributes section of the custom attribute, select Visible on Product View Page on Front-end and Used in Product Listing to Yes.
  52. What is the difference between EAV and the 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.
  53. Can you have more than one grid in a module in Magento?
    Yes, but grids in Magento are complicated and there isn't a lot of instruction available on the Internet.  This is for very advanced Magento programmers.

    A Magento Grid is constructed from a set of files that you will find in the file Block/Adminhtml from your module.
  54. What are “magic methods” in Magento?
    Magento uses __call(), __get(), __set(), __uns(), __has(), __isset(), __toString(), __construct(), etc. magic methods.
  55. 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.
  56. Where will you write your module’s business logic in Magento?
    inside the Model

    In a MVC framework, the business logic is put into models and delegated to display components called templates, or view scripts, by the controller. Routing, business logic, and display code are decoupled into their own separate components. The benefits are that when you need to change some business logic, you do not need to look through a spaghetti mess of mixed HTML and PHP.
  57. Explain the 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 actually under one session in an array. So firstname in customer/session will be $_SESSION['customer']['firstname'] and the cart items count in checkout/session will be in $_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 the $_SESSION['checkout'] session variable. So that the session is not cleared, just session data containing checkout information is cleared and the rest of all the session types are still intact.
  58. What are the commonly used block types? What is special in the core/text_list block type?
    Commonly used block types: core/template, page/html, page/html_head, page/html_header, page/template_links, core/text_list, page/html_wrapper, page/html_breadcrumbs, page/html_footer, core/messages, page/switch.

    Some blocks like content, left, right etc. are of type core/text_list. When these blocks are rendered, all their child blocks are rendered automatically without the need to call getChildHtml() method.
  59. Which Magento Design Pattern can be used to store information throughout your application?
    Registry: It is a way to store information throughout your application.

    • 1  Mage::register('key',$value); //stores
    • 2  $currentCategory = Mage::registry('key'); //retrives
  60. What is the purpose of the Object Pool in Magento?
    Object Pool:  It is used to reuse and share objects that are expensive to create.

    • 1  $id = Mage::objects()->save($object);
    • 2  $object = Mage::objects($id);
Card Set
Magento Study Set
Magento Interview Study set