Magento Interview Questions and Answers

Q 1. What is Magento?

Ans. 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.

Q 2. What is the difference between Mage::getSingletone() andMage::getModel() in Magento

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

Q 3. Why Magento use EAV database model ?

Ans. In EAV database model, data are stored in different smaller tables rather than storing in asingle table.product name is stored in catalog_product_entity_varchar tableproduct id is stored in catalog_product_entity_int tableproduct price is stored in catalog_product_entity_decimal tableMagento Use EAV database model for easy upgrade and development as this model givesmore flexibility to play with data and attributes.

Q 4. How to upgrade to the latest version using Magento Connect?

Ans. 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.

Q 5. Explain about the Modules of Magento?

Ans. 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.

Q 6. What technology used by Magento?

Ans. 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.

Q 7. What is MVC structure in Magento?

Ans. The Model-View-Controller (MVC) architecture traces its

origins back to the Smalltalk Programming language and Xerox

Parc. Since then, there have been many systems that describe

their architecture as MVC. Each system is slightly

different, but all have the goal of separating data access,

business logic, and user-interface code from one another.

Q 8. What is benefit of namespace (package) in magento?

Ans. 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

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

Ans. Access block’s content from .phtml template file by :

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

Q 10. How to add an external javascript/css file to Magento?

Ans.

css/yourstyle.css

or

skin_jsjs/ yourfile.js

skin_csscss/yourstyle. css

Q 11. What are handles in magento (layout)?

Ans. 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 /zag/index/index url is accessed.

Q 12. What is in magento?

Ans. The routers tag allow us to decide frontname for each module. The tag is defined in config.xml file of module. For Namespace_MyModule frontname is moduleurl so the url will be like :

websiteurl.com/moduleurl/controllername/actionname

standard

Namespace_MyModule

moduleurl

Q 13. Which factors affect performance of magento?

Ans.

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

Q 14. How to improve magento performance?

Ans.

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.

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

helper(‘checkout’)->formatPrice(Mage::getSingleton(‘checkout/cart’)->getQuote()->getGrandTotal()); ?>

Q 16. How to set different themes for logged in users?

if(Mage::getSingleton(‘customer/session’)->isLoggedIn()):

Mage::getDesign()->setPackageName(‘package_name’)->setTheme(‘themename’);

endif;

Q 17. How to create magento custom module?

Ans. 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.

Q 18. How to set different themes for each store?

Ans. Go to : System>Designs

Then, add new design change or edit existing. You can select Store and Custom Design.

Q 19. How to make product’s custom attribute searchable in adavance search?

Ans. Go to : Catalog > Attribues > Manage Attribues

Edit the attribute and select “Yes” for Use in Advanced Search.

Q 20. How to fetch 5 bestsellers products programmatically?

Ans.

Mage::getResourceModel(‘reports/product_collection’)

->addOrderedQty()

->addAttributeToSelect(‘*’)

->setPage(1, 5)

->load();


 21-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 andconfiguration-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).


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

For diagramatic view: click here (courtsey: Alan Storm)


22 =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.

For those who don’t know what EAV is, please read my 3rd answer below.

So, to end up this question,
when you want to get some data in Magento, you call it like this:

Mage::getModel('module/model')->load(1);

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.

23. What is EAV in Magento?

EAV, stands for Entity Attribute Value, is a technique which allows you to add unlimited columns to your table virtually. Means, the fields which is represented in “column” way in a regular table, is represented in a “row” (records) way in EAV. In EAV, you have one table which holds all the “attribute” (table field names) data, and other tables which hold the “entity” (id or primary id) and value (value for that id) against each attribute.

In Magento, there is one table to hold attribute values called eav_attribute and 5-6 tables which holds entity and data in fully normalized form,

- eav_entity, eav_entity_int (for holding Integer values),
- eav_entity_varchar (for holding Varchar values),
- eav_entity_datetime (for holding Datetime values),
- eav_entity_decimal (for holding Decimal/float values),
- eav_entity_text (for holding text (mysql Text type) values).

EAV is expensive and should only be used when you are not sure about number of fields in a table which can vary in future. To just get one single record, Magento joins 4-5 tables to get data in EAV. But this doesn’t mean that EAV only has drawbacks. The main advantage of EAV is when you may want to add table field in future, when there are thousands or millions of records already present in your table. In regular table, if you add table field with these amount of data, it will screw up your table, as for each empty row also some bytes will be allocated as per data type you select. While in EAV, adding the table column will not affect the previously saved records (also the extra space will not get allocated!) and all the new records will seamlessly have data in these columns without any problem.

24. Difference between Mage::getSingleton() and Mage::getModel()

The difference between Mage:getSingleton() and Mage::getModel() is that the former one does not create an object if the object for same class is already created, while the later creates new objects every time for the class when it’s called.

Mage::getSingleton() uses the “singleton design pattern” of PHP. If the object is not created, it will create it.

Mage::getSingleton() is mostly used when you want to create an object once, modify it and later fetch from it. Popular example is session, you first create a session object, and then add/remove values from session across different pages, so that it retains your values (e.g. cart values, logged in customer details, etc.) and doesn’t create new session object losing your last changes.

Mage::getModel() is used when you want to have the fresh data from the database. Example is when you want to show records from database.

79 comments:

  1. nice post thanks for this

    ReplyDelete
  2. very nice post and its very use full for me..

    ReplyDelete
  3. Nice artical very usefull Thanks....!

    ReplyDelete
  4. Really nice collection of question..

    ReplyDelete
  5. Really Good for preparation for interview... Thnaks

    ReplyDelete
  6. Nice blog for preparation for interview thanks for help

    Visit My website for pass magento certification 100%
    http://magentocertificationexamguide.com/

    ReplyDelete
    Replies
    1. Site is not working. Please check your site before posting public site..

      Delete
  7. This comment has been removed by the author.

    ReplyDelete
  8. Very useful article for Magento Preparation!!!

    ReplyDelete
  9. Your post urges me to create a business website, of course I will free download magento as soon as possible. As I research, Magento is the best platform which can be used in professional website.

    ReplyDelete
  10. There are many useful extensions for Magento. I suggest you using magento pdf invoice and magento login extension right now.

    ReplyDelete
  11. Comparison between Magento & Martjack whioch one better???
    Magento Hide Price

    ReplyDelete
  12. This comment has been removed by the author.

    ReplyDelete
  13. Great article! I think this article will support and complement your point
    Florida Web Development

    ReplyDelete
  14. This comment has been removed by the author.

    ReplyDelete
  15. Do you know what is Magento 2. This is the new era of Magento E-commerce

    ReplyDelete
  16. Hi! I have 1.5 years experience. I search in Google so Many Websites & Blog but you’re blog and post really is too good its title, description, images your content style is really good and I feel glad when post read Magento CMS Development

    ReplyDelete
  17. Thank you for your post, I will think about buying Magento banner slider extension now

    ReplyDelete
  18. Thanks for the PHP magento interview questions and answers. Wonderful collection to crack the interview.

    ReplyDelete
  19. Great information for the beginners of Magento!

    magento developer California

    ReplyDelete
  20. Magento is helpful in building best e-commerce websites with great security and appearance. Thanks for sharing this great piece of information!!!
    Logo Designers in Bangalore | Web Design in Bangalore

    ReplyDelete
  21. The article is very interesting and truly informative. Its really helpful for me, awaiting for more new post. Keep Blogging!
    Magento Development Company in Bangalore

    ReplyDelete
  22. wordpress websites are developed with modern functionalities which are necessary for the website development.Magento Development India

    ReplyDelete
  23. wordpress websites are developed with modern functionalities which are necessary for the website development.Magento Development India

    ReplyDelete
  24. These questions is very useful and good. Thanks for the giving these all questions, need more updates. I'm waiting for your updates. Web Design Companies Bangalore | Web Designing Bangalore

    ReplyDelete
  25. Syntax:
    magento development

    Good Design,from this post i found interview question on magento interview questions

    ReplyDelete
  26. Magento Development India website are developed so that the website looks attractive and with modernized look. nice post.

    ReplyDelete
  27. This comment has been removed by the author.

    ReplyDelete
  28. The blog was absolutely fantastic! Lot of great information which can be helpful in some or the other way. Keep updating the blog, looking forward for more contents...Great job, keep it up..
    Web Designing Company Bangalore | Website Development Company Bangalore

    ReplyDelete
  29. Article is very good and interesting. Thanks for sharing this valuable information

    Magento ecommerce Services

    ReplyDelete
  30. Article is very good and interesting. Thanks for sharing this valuable information

    Magento ecommerce Services

    ReplyDelete

  31. I simply want to say I’m very new to blogs and actually loved you’re blog site. Almost certainly I’m going to bookmark your blog post . You absolutely come with great well written articles. Thanks a lot for sharing your blog.


    Web designing Training in Chennai | Digital Marketing Company in Chennai

    ReplyDelete
  32. Amazing Article. Thank you and keep sharing.
    Contact Us for any Magento E-commerce Development & Customization work.
    Check our Magento Services :
    Magento Extension Development
    Magento Marketplace Multi Vendor Solution
    Magento Theme Development and Customization
    Magento Payment Gateways Integration
    Magento Website Maintenance services
    Magento Website Optimization
    Magento Upgrade Service
    Parsys Media : Magento Ecommerce Development & Customization company India

    ReplyDelete
  33. I'm continually scouring the Internet for new data and realizing whatever I can, and in doing as such I some of the time leave remarks on web journals. Magento Development Service in Bangalore | Magento Development Company in Bangalore

    ReplyDelete
  34. You have shared a very useful information, keep updating these. I have also list some of the Magento question asked from me in interviews, you can have a look over here Interview Question

    ReplyDelete
  35. Thanks for the best blog.it was very useful for me.keep sharing such ideas in the future as well.this was actually what i was looking for,and i am glad to came here!
    magento development company in bangalore 

    ReplyDelete
  36. In fact, the Modern theme alone made me take a better look into the whole framework making it my profession today. For best and cheap manual Seo services, Web designings. Must check Web Development Company Bangalore

    ReplyDelete
  37. Hello, nice to meet you.
    And really a nice article about this esisting topic.
    By the away here i have written an article about thrive themes.
    You know know about thrive themes and thrive plugins.
    Thrive plugins like thrive content builder, clever widgets, thrive landing page,
    thrive leads plugin as well. here you can visit my blog for
    thrive themes discount coupon and lot more. thanks

    ReplyDelete
  38. Why To Approach Magento Web Development Company? Ask me Benefits of Working With Magento Web Development Magento, formed on open-source platform, is a Best feature-rich e-commerce technology with the help of which online merchants can control over the content, look and functionality of their e-commerce store. In order to give a similar kind of environment and experience to users on desktops, laptops, tablets and Smartphones an individual website is designed by Magento developers. Source-https://www.acmewebtechnology.com/blog/benefits-of-working-with-magento-web-development-service-provider

    ReplyDelete
  39. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon.

    Java Training in Chennai

    Salesforce Training in Chennai

    ReplyDelete
  40. That's wonderful stuff you've written up here. Been searching for it all around. Great blogWeb Designing Companies Bangalore | Top Web Design Company in Bangalore

    ReplyDelete
  41. Thanks for sharing the interview question with us.
    It will really help me in interview.
    Magento Development Companies

    ReplyDelete
  42. Nice to read this article... Thanks for sharing.....
    magento 2 training

    ReplyDelete
  43. EGainz.com is a core MAgento Development Company Completed 450 + projects
    Check our website for Demo.

    ReplyDelete
  44. Lovely blog with much more interesting article, I will keep on reading your update. Thanks for the share | Ear Plugs for Swimming | Ear plugs for Sleeping Custom Ear Plugs| Motorcycle Ear Plugs | Musicians Earplugs

    ReplyDelete
  45. Thanks for the magento interview questions and answers.Best for interview questions with basics explained very well. Thanks!!

    ReplyDelete
  46. Very amazing blog on a fresh new topic. I am definitely going to use the information provided in this blog because of its novel and fresh. Thanks for sharing such valuable information with everyone.

    best web designer companies in bangalore
    best seo service companies in bangalore
    Best Website Company in Bangalore
    Ecommerce Website Design Company in Bangalore

    ReplyDelete
  47. Searching for Magento Development Company visit us at webgensis for custom web development services and hire magento developer who code your dreams live.

    ReplyDelete
  48. This comment has been removed by the author.

    ReplyDelete
  49. Magento modules are a helpful addition to the crew of any online shop. That is why there is demand of magento developers in the industry. You have shared useful interview tips for magento developer.

    ReplyDelete
  50. Looking for WordPress Developer for Hire ? Visit Us at webgensis a Custom WordPress Development Company having team of experienced and skilled developers.

    ReplyDelete
  51. If you are thinking about developing your ecommerce website with the Magento Ecommerce Platform and having trouble in Hire Magento Developer then get in touch with us Best Magento Development Company in USA.

    ReplyDelete
  52. Thank you so much for taking effort to share such a useful information. I will definitely share this Magento Web Development Company

    ReplyDelete
  53. hi Thanks for sharing this valuable Information about Interview Question and Answer this is very Helpful for Freshers and Experienced Candidate.
    WordPress Interview Questions and Answers

    ReplyDelete

Note: only a member of this blog may post a comment.