Magento

Q1. Explain Magento’s MVC architecture?
Q2. What is EAV in Magento?
Q3. How Magento ORM works?
A: ORM stands for Object Relational Mapping. It is programming technique used to convert different types of data to Objects and vice versa.

Q4. What is the difference between Mage::getSingleton() and Mage::getModel()?
A: 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.
Q5. What is codePool in Magento?
A: codePool is a tag which you have to specify when registering new module in app/etc/modules/Company_Module.xml
Q6. How will you call a CMS page in your module’s PHTML file?
A: $this->getLayout()->createBlock(‘cms/block’)->setBlockId(‘blockidentifier’)->toHtml();
Q7. How to enable product’s custom attribute visibility in frontend?
A: In Manage Attributes section of the custom attribute, select Visible on Product View Page on Front-end and Used in Product Listing to Yes.
Q8. What is the Difference between EAV and flat model?
A: 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
Flat model uses just one table, so it’s not normalized and uses more database space
Q9. Can WE have more than one Grid in a module? (Yes)
Q10. What are “magic methods” in Magento?
A: Magento uses __call(), __get(), __set(), __uns(), __has(), __isset(), __toString(), __construct(), etc. magic methods
Q11. How many database tables will Magento create while making a new EAV module?
A: Magento creates 6 tables when you create new EAV module.
Q12. Where to write your module’s business logic?
A: Inside Model
Q13. What are different types of sessions in Magento?
A: customer/session, checkout/session, core/session
Q14. How to log current collection’s SQL query?
A: $collection->printLogQuery(true); OR $collection->getSelect()->__toString();
Q15. How to get first item or last item from the collection?
A: $collection->getFirstItem() and $collection->getLastItem();
Q16. What are handles in magento (layout)?
Q17. How to get the Total Price of items currently in the Cart?
A: helper(‘checkout’)->formatPrice(Mage::getSingleton(‘checkout/cart’)->getQuote()->getGrandTotal());
Q18. How to include CMS block in template file(.phtml)?
A: echo $this->getLayout()->createBlock(“cms/block”) ->setBlockId(“static_block_id”)->toHTML();
Q19. What are handles in magento (layout)?
Q20. What are handles in magento (layout)?
A: Handles are basically used for controlling the structure of the page like which block will be displayed and where.
Q21. What is benefit of namespace (package) in magento?
A: We can have more than one module with same name but they should be placed in different namespaces.
Q22. How to set different themes for logged in users?
A: if(Mage::getSingleton(‘customer/session’)->isLoggedIn()):
Mage::getDesign()->setPackageName(‘package_name’)->setTheme(‘themename’);
Q23. Explain steps to create magento custom module?
A: Namespace : Zag
Module Name : Newmodule
1. Create directory Newmodule 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/Newmodule/etc/config.xml).
4. Create xml file (app/etc/modules/Zag_Newmodule.xml)to enable/disable module and tell magento system from which code pool that module will be taken.
Q24. How to fetch 3 bestsellers products?
A: Mage::getResourceModel(‘reports/product_collection’)
->addOrderedQty()
->addAttributeToSelect(‘*’)
->setPage(1, 3)
->load();
Q25. How to make product’s custom attribute searchable in adavance search?
A: Catalog > Attribues > Manage Attribues
Edit attribute > select “Yes” for Use in Advanced Search.
Q26. How to set different themes for each store?
A: System > Designs
Add new design change or edit existing. You can select Store and Custom Design.
Q27. What are different types of products in Magento?
A: There are 6 different product types in Magento:-
1/ Simple Products
2/ Grouped Products
3/ Configurable Products
4/ Virtual Products
5/ Bundle Products
6/ Downloadable Products
Q28. What is MVC and its types?
A: MVC stands for Model-View-Controller. An application that separates data access, business logic and user interface is called MVC.
There are two types of MVC:
1. Convention based: CakePHP is convention based. (You need to follow instructions of the core system to get your module ready in just few lines.)
2. Configuration based: Magento is configuration based. (You need to specify each and every thing to your module’s config file). Magento has Controller (for Routing), Block (for Business Logic), Model (for DB access, sql) and Template file (for Presentation i.e. View).