Hi wannabe Magento Certified Developers, here are the answers we prepared to help you for solving the Study Guide’s confusing questions. If you don’t already have Study Guide, go get it here. Please note that by preparing this you are not going to pass the exam, it’s just intented as a last day revision. You SHOULD go through each question yourself and dig into the Magento code base in order to pass this exam. This is JUST to make your life easier while you are stuck on some questions and want a backup for a straight answer. Although we don’t guarantee 100% correct answers for these questions, you should be good to have it.
Q. What is the DDL class in Magento?
– The only DDL class in Magento is Varien_Db_Ddl_Table
– Mage_Page_Block_Html_Head:: addJs(), addJsIe(), addItem(), getCssJsHtml()
Q. Which product types exist in Magento?
– Magento has 6 standard product types, including: Simple product, grouped product, configurable product, virtual product, bundle product and downloadable product.
Q. Which product types are implemented as part of the Mage_Catalog module, and which are not?
– Mage_Catalog – simple, grouped, configurable, virtual
Mage_Bundle – bundle
Mage_Downloadable – downloadable
Q. Which product types implement a parent-child relationship between product entities?
– configurable, bundle and grouped
Q. Which database tables are shared between product types, and which ones are specific to one product type?
– specific to one product type, configurable – catalog_product_super_link
for configurable, grouped and bundle – catalog_product_relation
Q. What steps need to be taken in order to implement a custom product type?
– product types config…..
<configurable translate=”label” module=”catalog”>
class Magestore_Newmodule_Model_Product_Type_Simple extends Mage_Catalog_Model_Product_Type_Simple
Q. How do the different product types handle price calculation?
Q. Which indexing processes does the product type influence?
– Product Price
Q. Which product types implement a parent-child relationship between product entities?
– configurable product type – configurable(parent) – simple(child)
may be grouped and bundle as well.
prepareForCartAdvanced() – initialize product for add to cart process..
calls to prepareProduct() – process product and prepare options
calls to prepareOptions() – Process custom defined options for product
Q. What are total models responsible for in Magento?
quote, invoice, creditmemo
– grand total
dispatches event “sales_quote_address_discount_item” in collect method of Mage_Sales_Model_Quote_Address_Total_*
getCollectors() – Get total models array ordered for right *calculation logic*
getRetrievers() – Get total models array ordered for right *display sequence*
Q. How and when is the include path set up and the auto loader registered?
– in Mage.php (Varien_Autoload::register();)
Q. How and when does Magento load the base configuration, the module configuration, and the database configuration?
– Magento loads the base configuration: Mage_Core_Model_Config::init() calls loadBase() first
Magento loads the module and database configuration: Mage_Core_Model_Config::init() then calls loadModules() & loadDb()
Q. How does Magento process requests that cannot be mapped?
– It will send user to 404 page.. cms/index/noRoute
Q. After a matching action controller is found, what steps occur before the action method is executed?
– It then instantiates controller class; then sets module name, controller name, action name, controller module name & parameters.
Finally it calls:
to dispatch the request
Q. What is the difference regarding module loading between Mage::run() and Mage::app()?
– Mage::app() :: Get initialized application object. It provides all those required variables, objects which are required to access magento functionalities out of magento boostrap i.e. index.php.
Mage::run() :: Frontend entry point which means it loads the configuration files, modules configuration, load Database. This constructs all of the necessary xml data in configuraiton tree object.
Mage::app() – Initialize application without request processing.
Mage::run() – Run application. Run process responsible for request processing and sending response.
Q. Which classes are responsible for the layout being loaded?
Q. How are layout xml directives processed?
– Mage_Core_Controller_Varien_Action::loadLayout() – processes the request to load layout
Mage_Core_Model_Layout::__construct() – loads layout xml
Mage_Core_Model_Layout_Update::load() – load layout updates by handles
Q. Which ways exist to specify the layout update handles that will be processed during a request?
<update handle=”add_jquery_first” />
<action method=”addJs” block=”head”>
Q. Which class is responsible for sending output?
Magento uses a response object to send all output. All output is added to this object, and then its sendResponse method is called.
Q. What is the responsibility of Front Controller?
– Directly receive the request from browser.
All requests call the function Mage_Core_Controller_Varien_Front::dispatch()
– URL rewriting process.
– Load the module and action controller corresponding with the requests through routers to process the requirements which are sent from clients.
Collect routers: admin, standard, default.
Use the function match() of routers to define the module and controller that are requested.
Call the function dispatch() of the controller requested.
Call the action requested.
– Return HTML for browser
Call the function sendResponse() of Mage_Core_Model_Response_Http (extend from Zend_Controller_Response_Abstract).
Call the function sendHeaders() – use the header() function of PHP.
Call the function outputBody() to show the whole content of the body part:
echo implode(”, $this->_body);
Q. How to pass variables from layout to block?
– <action method=”setData”><name>category_id</name><value>3</value></action>
In the block, this can be retrieved by..
$categoryId = $this->getCategoryId();
$categoryId = $this->getData(‘category_id’);
in js folder,
in skin js folder,
Q. Which events are associated with sending output?
Q. How and when are the two main types of setup script executed?
Q. Under which circumstances are setup scripts executed?
Q. How and where does Magento differentiate between install, upgrade, and downgrade scripts?
– In Mage_Core_Model_App::_initModules(), calls Mage_Core_Model_Resource_Setup::applyAllUpdates(), and it then calls applyUpdates() to check version number from config.xml.. if lower version number, it rollbacks; if greater version number, it upgrades. The config.xml version number is checked against core_resource table’s version of the module.
Q. Which is the base setup class for flat table entities, and which one the base for EAV entities?
– Flat table: Mage_Core_Model_Resource_Setup
EAV table: Mage_Eav_Model_Entity_Setup
Q. When does Magento decide which store view to use, and when is the current locale set?
– 1. Index.php calls Mage::run()
2. It calls app/mage.php :: run()
3. run function has self::$_app->run(…) line of code which ultimatately calls Mage_Core_Model_App::run() function
4. Mage_Core_Model_App::run() includes $this->_initCurrentStore($scopeCode, $scopeType);
5. _initCurrentStore() :: Loads all websites, group and stores into website, group and store object using _initStores() method. this function checks whether the site is website or store group or store, if it is one these then there it sets current store. If scope is base, then it goes through $this->_checkCookieStore()
6. $this->_checkCookieStore() :: this gets the store type from cookie this->getCookie()->get(Mage_Core_Model_Store::COOKIE_NAME);, there it checks whether it is website, group or store and set current store in $this->_currentStore = $store; on the base of value returned by cookie.
7. Mage_Core_Model_App::_checkGetStore() , this checks current store with the xpath_of_store_url , updates cookie
FINALLY, Current locale is set when Mage_Core_Model_App::init() is called , init() function has $this->_initEnvironment(); which has a setting of locale
Q. When are the request and response objects initialized?
– Mage_Core_Model_App::getRequest() & getResponse() initializes..
Q. Which ways exist in Magento to add router classes?
<routers> <!– declare default routers–>
Then you should declare your module router in a normal way, using the parameter <use>your_custom_router</use> instead of “standard”.
2. using event observer
then in observer class,
public function initControllerRouters($observer)
/* @var $front Mage_Core_Controller_Varien_Front */
$front = $observer->getEvent()->getFront();
Q. Which routers exist in a native Magento implementation?
– admin, standard, cms, default
Q. How does the framework discover active modules and their configuration?
Q. Explain how Magento loads and manipulates configuration information?
– $this->loadBase(); //config.xml and local.xml
$this->loadModules(); //load all modules xml from app/etc/modules/ directory
$this->_loadDeclaredModules(); //load each modules xml file
$this->loadDb(); //load configuration from db
load data from core_config_data into our configuration:
1. We add data about websites (see core_website table)
2. We add data about stores for the existing websites (see core_store table)
3. We add data from core_config_data according to the scope
a. Create <default> block first
b. Then create <websites> block
c. And, finally – <stores>
d. Each iteration replaces data from more general area of the scope with more specific one
Q. What are the common methods with which the framework accesses its configuration values and areas?
– getStoreConfig(), getStoreConfigFlag(),
$enable = Mage::getStoreConfig(‘socialrecommend/general/enable’,’default’);
$enable = Mage::app()->getStore()-> getConfig(‘socialrecommend/general/enable’);
$enable = Mage::getConfig()-> getNode(‘socialrecommend/general/enable’,’store’,’default’);
$enable = Mage::getConfig()-> getNode(‘stores/default/socialrecommend/general/enable’);
Q. Which class runs total models processing?
– Mage_SalesRule_Model_Validator::process() (applies and processes rules for each item of total models)
Basically, rules are sorted by the priority and Magento applies rule by rule for each item
Q. What configuration parameters are available for event observers?
– type (model, object, none, singleton), class (class name of observer), method (method to invoke)
Q. What is the structure of event observers, and how are properties accessed therein?
– for checkout/cart after adding product,
Mage::dispatchEvent(’checkout_cart_product_add_after’, array(’quote_item’=>$result, ‘product’=>$product));
$observer->getEvent()->getQuoteItem() and $observer->getEvent()->getProduct()
Q. What configuration parameters are available for cron jobs?
– cron_expr (to schedule), model (to run, with method name)
Q. Explain lifecycle of a Block?
_prepareLayout() method is called immediately after a block has been added to the layout object for the first time.
_beforeToHtml() method is called immediately before a block’s HTML content is rendered.
_afterToHtml() method is called immediately after a block’s HTML content is generated.
_beforeChildToHtml() is called when a parent renders one of its children (through a call to $this->getChildHtml(‘name’)).
Q. What is the difference between payment method and payment classes (such as order_payment, quote_payment, etc.)?
– Payment model is the abstract of an instance payment method and it works with database. Payment model can be Mage_Sales_Model_Order_Payment or Mage_Sales_Model_Quote_Payment depending on checkout stage. And the database is stored corresponding with tables sales_flat_order_payment and sales_flat_quote_payment. However, Quote_Payment doesn’t have any method to process the order.
Q. Which method is used for translating strings, and on which types of objects is it generally available?
– Mage_Core_Helper_Abstract::__() .. helper objects
Q. What is the difference between “pay” and “capture” operations?
– pay() – Register payment fact: update self totals from the invoice / Update totals…
capture() – Capture the payment online
* Requires an invoice. If there is no invoice specified, will automatically prepare an invoice for order
* Updates transactions hierarchy, if required
* Updates payment totals, updates order status and adds proper comments
Q. Which classes and methods are responsible for credit card operations (for example authorization or capturing)?
Mage_Payment_Model_Method_Abstract::authorize() and capture()
Q. Which classes are involved, and which tables are used to store refund information?
Q. How does Magento process taxes when refunding an order?
– tax get refunded with order
Q. How does Magento process shipping fees when refunding an order?
– It is equal to the full Shipping Amount from the order minus the Shipping Refund, which is the amount that has already been refunded. Like the quantity, the amount can be reduced, but not increased.
Q. What is the difference between online and offline refunding?
– If you do an online refund the money will actually be transferred back to the customer.
If you choose offline refund (or offline is the only available option) you need to make sure the customer gets his/her money back via other means. Most often you would log into the control panel for your payment gateway and process the refund there.
The same applies to the online and offline capture of previously authorized amounts. When online capture is available and chosen the money will actually be transferred into your name. If you can only do offline you again need to capture the amounts outside of Magento via the provided means offered by the payment gateway.
Q. Can a customer be added to two customer groups at the same time?
Q. How is customer information validated?
– customer address validation at checkout:
Mage_Sales_Model_Quote_Address extends Mage_Customer_Model_Address_Abstract
Q. What is adminhtml.xml used for? Which class parses it, and which class applies it?
Q. Where is the code located that processes the ACL XML and where is the code that applies it?
– adminhtml.xml is used for: creating admin Menus and ACLs.
Class parses/processes it: Mage_Admin_Model_Config::loadAclResources() and __construct()
Class applies it: Mage_Adminhtml_Block_Page_Menu::_checkAcl() => calls to => Mage_Adminhtml_Controller_Action::isAllowed()
Mage_Adminhtml_Block_Page_Menu::_buildMenuArray() builds admin navigation menu
Q. What is the relationship between Magento and Zend_Acl?
– for acl roles, rules and resources
Q. How is ACL information stored in the database?
– Magento stores the role in the tables:
parent_id: the parent role of the current role
role_type: the user role or the group role
admin_rule table stores the list of permissions of a user or a role with the resource
role_id: the id of the role to apply in the ACL (foregin key, admin_role table)
resource_id: the resource to access the system (e.g. admin/system/config)
permission: permission for a role to access the resource (allow/deny)
CLASS: Mage_Admin_Model_Mysql4_Rules::saveRel() – save Acl resources
Q. What is the role of the downloader?
– This is the storage of the web downloader files. They are used for the installation and upgrade of Magento through your browser.
Q. How is the category hierarchy reflected in the database? Does it differ when multiple root categories are present?
Q. How is a catalog tree read from the database tables, with and without flat catalog tables enabled?
– Magento uses Adjacency List Model, where we have to recursively query database to find out the depth/level of a node.
To address the problem of Adjacency List Model, Magento’s category table has three extra columns:level, path, children_count. As the names suggest, ‘level’ stores the level of a node, ‘path’ saves the path from the root node to this node and ‘children_count’ records the number of children the node has.
To manage the category tree, Magento uses the model Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Tree which is extended from Varien_Data_Tree_Dbp. This model provides some methods to work with the tree structure such as: move a node, append child, add a node.
Magento stores database of categories by two types: EAV and Flat
In EAV, the category is stored in some tables:
catalog_category_entity, catalog_category_entity_datetime, catalog_category_entity_varchar, …
The main table is catalog_category_entity. This table has some basic fields:
parent_id: used to store the parent category. This value is zero (0) if the category is the root category
path: the path to the category from the root category
children_count: the number of children category of this category
When the category is stored in Flat database, a flat table catalog_category_flat_store_<StoreID> is created.
e.g. catalog_category_flat_store_1, catalog_category_flat_store_2 and catalog_category_flat_store_3
along with catalog_category_product table with values of category_id, product_id and position
Q. Which methods exist to read category children and how do they differ?
– $category = Mage::getModel(‘catalog/category’)->load(3);
1. $category->getChildrenCategories(); //get children categories of current category
2. $category->getChildren(); //get all the children ids comma separated
3. $category->getAllChildren(); //get all the children ids comma separated, with current category id
4. $category->getCategories($category); //get grand-childrens too.. retrieve categories by parent..
Q. Which factors are used by the Mage_Tax module to apply the correct tax rate (or rates) to a product price?
* country_id (->getCountryId())
* region_id (->getRegionId())
* postcode (->getPostcode())
* product_class_id (->getProductClassId())
* customer_class_id (->getCustomerClassId())
* store (->getStore())
Q. What classes are typically involved in Magento widget architecture?
– Mage_Widget_Block_Interface & Mage_Core_Block_Abstract
The interface declaration includes 3 methods:
toHtml(), addData(array $arr), setData($key, $value = null)
Q. How are admin-configurable parameters and their options specified?
– in widget.xml,
Q. Describe the different Web Service APIs available within the Magento Core
– XML-RPC, SOAP (API v1 and v2)
Q. What are the syntactical differences between API versions?
– When using Magento v1 API, we access resources via call method and provide API method name and parameters as parameters of call method.
When using Magento v2 API, we access resources via real method name and we provide parameters as defined in WSDL for each specific method.
Q. API – How are existing methods overwritten? How can additional methods be added?
Q. Identify the configuration files used for the v2 SOAP API
– config.xml, api.xml, wsdl.xml, wsi.xml
Q. How does the storage of quotes for multishipping and onepage checkouts differ?
– In multishipping, one more db table is used i.e. sales_flat_quote_address_item
Q. Which quotes in a multishipping checkout flow will be virtual?
Q. What is the difference in the multishipping processing for a quote with virtual products in it?
– If all items in the quote are virtual, then billing address is used for calculation of all the totals of the order, since items will be assigned to billing address. If items are not virtual, then shipping address will be used.
Q. Which model is responsible for multishipping checkout in Magento?
Q. Which classes are responsible for rendering the layered navigation?
Q. Which indexes are used for the layered navigation?
– Product Attributes, (Product Price?)
Magento uses an index table to filter and count the result for each filter item.
The index table for the general attribute is catalog/product_index_eav
For price attribute, it is table catalog/product_index_price
Q. How can attributes with custom source models be integrated into layered navigation filtering?
Q. How are custom product options stored on quote and order items?
– quote: sales_flat_quote_item_option
Q. How can you specify custom product options on-the-fly on quote items?
Q. Which areas in configuration are only loaded for the admin area?
– admin, adminhtml
Q. What are the roles of adminhtml config?
– admin menu, acl, layout
Q. Which class do most Magento adminhtml blocks extend?
Q. At which moment does Magento check if a user is logged in or not?
Q. Which block does a standard Magento form extend?
Q. What is the default template for a Magento form?
Q. Which class is responsible for creating an instance of the block?
Q. How is the tree of blocks typically rendered?
– here, tree of blocks = layout.
loadLayout() renders all the nested blocks
renderLayout() renders it.
Q. Describe the concept of Form elements, and list system elements implemented in Magento.
– awlink, buttons, checkbox, date, editor, fieldset, file, gallery, hidden, imagefile, image, label, link, multiline, multiselect, note, obscure, password, radio, reset, select, submit, textarea, text, time
Q. Describe the concept of Fieldsets.
– Magento configuration scheme separated into four parts: Tabs, Sections, Groups, Fields. Tabs contains sections, sections contains groups (i.e. fieldsets), groups contains fields. All of them are defined in system.xml.
Q. What protected methods are specific to adminhtml grids, and how are they used?
– _prepareLayout(), _setFilterValues(), _addColumnFilterToCollection(), _setCollectionOrder(), _prepareCollection(), _decodeFilter(), _preparePage(), _prepareMassactionBlock(), _prepareMassaction(), _prepareMassactionColumn(), _prepareGrid(), _beforeToHtml(), _afterLoadCollection(), _exportCsvItem()
Q. What is the standard column class in a grid, and what is its role?
role: apply decorators, css, renderer, get row field, filters
Q. What is the difference between Mage::getStoreConfig(…) and Mage::getConfig()->getNode(…)?
– Mage::getStoreConfig(…) – gets the value as a string; retrieves data from database (core_config_data)
Mage::getConfig()->getNode(…) – gets the value as an object; retries data from configuration xml file
Q. How does Magento store data for system configuration?
– In the database table core_config_data table with scope information.
Q. Which classes are used to parse and render system configuration XML?
– system.xml is loaded by Mage_Core_Model_Config_System
Q. What are the common methods with which the framework accesses its configuration values and areas?
– getDistroServerVars (Get default server variables values ),
getStoresConfigByPath(Retrieve store Ids for $path with checking ),
$_eventAreas( Configurationfor events by area)
Q. Which methods of which classes can be used to instantiate Magento classes?
Q. How can block output be caught using an observer?
Q. What events do Mage_Core_Block_Abstract and Mage_Core_Block_Template fire?
Q. What are the events fired in block?
– a. Prepare Layout Event: core_block_abstract_prepare_layout_before: is fired before calling _prepareLayout function of the block.
core_block_abstract_prepare_layout_after: is fired after calling _prepareLayout function of the block.
The parameter of this event is also block.
b. Render toHtml Event: core_block_abstract_to_html_before: is fired before the block is rendered to html.
Block is theparameter of this event.
core_block_abstract_to_html_after: The Parameters of this event are block and transport.
This event is fired right after the block is rendered to html
Q. purpose of Mage_Core_Block_Text_List & Mage_Core_Block_Text
– core/text_list is a container to render all it’s child blocks like left, right, content.
core/text is a parent class of text_list, it allows to setText, getText and addText methods
Q. Which block type renders its children automatically?
Q. Which block type is usually used for a “content” block on Magento pages?
Q. How can a template’s block instance be accessed inside the template file, and how can other block instances be accessed?
Q. How can block instances be accessed from the controller?
– template block instance inside it’s template file: $this
other block instances inside template file, and from controller: $this->getLayout()->createBlock(‘foo/bar’)
Q. Which classes are responsible for figuring out the absolute path for including the template file?
Q. Can adminhtml system configuration source models also be used for EAV attributes?
Q. Which methods exist to access the table of a resource model?
Q. Which methods exist to create joins between tables on collections and on select instances?
– joinLeft(), joinRight(), joinInner(), joinFull(), joinCross(), joinNatural(), joinStraight()
Q. How does Magento figure out if a save() call needs to create an INSERT or an UPDATE query?
– Mage_Core_Model_Abstract::save(), checks if $object->getId() is set or not. If set, then the “update” ($this->_getWriteAdapter()->update()) method is called, otherwise “insert” ($this->_getWriteAdapter()->insert()) method is called. It also checks if $object->isObjectNew() and $this->_isPkAutoIncrement is set or not to do this action.
Q. Which events are fired automatically during CRUD operations?
model_load_before (in _beforeLoad())
model_load_after (in _afterLoad())
model_save_before (in _beforeSave())
model_save_after (in _afterSave())
model_delete_before (in _beforeDelete())
model_delete_after (in _afterDelete())
* = core_abstract
Q. Which methods exist to influence the ordering of the result set for flat table collections? How do the methods differ?
– $coll->getSelect()->order(‘entity_id desc’);