Magento Interview Questions | Eklavya Online

Magento Interview Questions

ORM stands for Object Relational Mapping. It is a programming technique used to convert different types of data into objects and vice versa.

There are two types of ORM:

  • Converts different types of data into objects.
  • Converts objects to various types of data.

Create a file named as maintenance.flag and upload it to Magento home directory containing following code.

$maintenanceFile = ‘maintenance.flag’;

if (file_exists($maintenanceFile)) {
include_once dirname(__FILE__) . ‘/errors/503.php’;
exit;
}

In Magento, PHP is used as a scripting language while MySQL is used as the database.

To run custom query,

$db = Mage::getSingleton(‘core/resource’)->getConnection(‘core_write’);
$result=$db->query(‘SELECT * FROM users where id=4’);

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

EAV stands for Entity Attribute Value. It is a technique that facilitates users to add unlimited columns to their table virtually

Change the directory to the directory where Magento is installed and execute the following commands.

1.

find. -type d -exec chmod 755
2.

chmod+x magento

To let the Magento working with another domain, URL option of Magento base can be changed.

Follow these steps:

  • select Magento admin -? System ? configuration and then click Web.
  • Choose unsecure option
  • Replace the base URL filed
  • Core modules
  • Commercial modules
  • Community modules

To convert default currency to others, select the currency and import currency rates from System-> Manage currency-> Rates.

Syntax:

$convertedPrice = Mage::helper(‘directory’)->currencyConvert($price, currentCurrency, newCurrency);

Magento has following basic features.

  • SEO Friendly
  • Google sitemap support
  • Accounts of Customers
  • Managing orders
  • Report and analysis
  • Site management
  • Payment
  • Marketing promotion and tools
  • International support
  • Extremely modular architecture

In Manage Attributes section under custom attribute, select Yes for “Visible on Product View Page on Frontend” and “Used in Product Listing”.

Code pool is a concept to pull the code in Magento structured format. It is specified when you register new module in app/etc/modules/Company_Module.xml

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

CodePools:

_community: It is generally used by 3rd party extensions.

_core: It is used by Magento core team.

_local: Local codePool should be used for in-hour module development and overriding of core and community modules for custom requirement.

Residing directory:

_app

_code

So in short, you can say that codePool helps Magento to locate module inside app/code/ for processing

EAV stands for Entity Attribute Value. It is a technique that facilitates users to add unlimited columns to their table virtually.

$collection->getFirstItem() and $collection->getLastItem();

Magento is an e-commerce platform written in PHP and released under the open source license. It was released by Varien, Inc. on March, 31 2008. It provides flexibility and control to the On-line merchants over the look and content.

To change theme for login users,

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

Magento allows the integration of online stores with Google checkout. Google checkout is the online payments service provided by the Google. It works like PayPal.

There are the following limitations of Magento.

  • Due to the fact that it is written in PHP, it is slower in performance as compare to other platforms.
  • It consumes more space in the memory. It can consume gigabytes of RAM during heavy processes.
  • In the absence of Object oriented programming, it can become complex.

No, namespace is not mandatory while creating custom module.

EAV module will create 6 tables in database.

They are as follows:

  • module
  • module_datetime
  • module_decimal
  • module_int
  • module_text
  • module_varchar

EAV database model is fully in normalized form. Each column’s value is stored in their respective data type table which makes it more complex as they have to join 5-6 tables even if you need only one detail. In EAV, columns are called attributes.

Flat model uses just one table. It is not normalized and uses more database space. It is not good for dynamic requirements where you may have to add some more columns in future. Its performance is fast as it needs only one query instead of joining 5-6 tables. In flat model, columns are called fields.

Magento core modules are placed in mage namespace, core/Mage/Catalog and all custom modules are placed in local/CustomModule.

You can have more than one module with same name but they need to be placed in different namespaces.

Magento was initially released on 31st March, 2008.

css/yourstyle.css
or

skin_jsjs/ yourfile.js
skin_csscss/yourstyle. css

You have to follow these steps to change Magento core API setting.

  • Go to Admin menu, choose System -> Configuration
  • Select Magento Core API on the left side of the Configuration Panel, under Services
  • Click on to expand the General Settings section
  • Type name of the Default Response Charset that you want to use
  • Determine the Client Session Timeout in seconds
  • Click the Save Config button when completed

There are various ways to improve Magento performance.

  • Disable any unused modules
  • Magento Caching
  • Optimize your Server
  • Use a Content Delivery Network (CDN)
  • Put Stylesheets at the Top
  • Put Scripts at the Bottom
  • Avoid CSS Expressions
  • Disabling Magento Log
  • improve the image

Magento simple product: It is used for a single item without any specific selectable variations. For example, a pen, copy, etc.
Magento grouped product: It is used for a combination of Magento simple product. For example, a pen and copy together.
Magento configurable product: It is used for a single item with specific selectable variations. For example, a pen with different color options.
Magento virtual product: It is used for a virtual item i.e: non touchable item. For example, reservation, insurance, etc.
Magento bundle product: It is used for a bundle of simple products. For example, laptop with various items such as processor, hard disk, RAM, etc.
Magento downloadable product: It is used for online software items. For example, PowerPoint presentation, MP3 files, servers, etc.

Handles control the structure of the page to be displayed. It decides which block will be placed where in the page. Handle is called for every page and every page request can have several unique handles.

Following are the different versions of Magento:

  • Magento Enterprise Edition
  • Magento Community Edition
  • Magento Professional Edition
  • Magento .go Edition

$this->getLayout()->createBlock(‘cms/block’)->setBlockId(‘blockidentifier’)->toHtml();

You can do the following things through client Magento account:

  • You can update your billing address.
  • You can add a credit card.
  • You can view your billing history.
  • You can add a PayPal account.
  • You can produce a print ready receipt.

You can use following instructions to improve the security of magneto.

  • Have some complex passwords and change them time to time.
  • Do not let the Magento Content Manager remotely accessed.
  • Don’t provide the download facilities on production sites.

Magic methods in Magento:

  • __get()
  • __set()
  • __isset()
  • __call()
  • __tostring()
  • __construct()
  • __has()
  • __uns()

Mage::getModel(): It creates a new object.
Mage::getSingletone(): It first checks the existence of object and if object doesn?t exist, then it creates a new one.

Compilation feature allows us to compile all Magento files to create a single include path to increase performance.

Magento is a typical MVC application where controller remains at one place while the models at the other.

When you have added or modified XML, CSS or JS files.

In Magento, applying Connect Patches provides following features:

  • Enable easy installation of packages with installation and overwrite any existing translations for the same time
  • Enhance security, by default Magento Connect uses HTTP to download extensions instead of FTP
  • Facilitate the extension developers to create new extensions with a dash character in the name
  • Magento administrators will be informed now who tries to install an extension with insufficient file system privileges.

Magento is mainly used for shopping cart software.

There are namely three sessions in Magento:

  • customer session
  • checkout session
  • core session
    All these sessions are stored in one session only. We use different sessions because sometimes we need to clear only a particular session data and not all session data.