Design & Module Development Magento 1 Stenik Group Ltd. Martin Grozdanov <martin@stenik.bg> Software University http://softuni.bg © Software University Foundation – http://softuni.org This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike license. 1
Last time Magento Installation Administration & Frontend Basic File Architecture Basic Module Components © Software University Foundation – http://softuni.org This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike license. 2
Table of Contents Convention URLs’ structure Design elements Design Fallback Design Development Module Development 3 © Software University Foundation – http://softuni.org This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike license. 3
Magento Class Convention Magento uses Zend Framework’s convention All classes are named by their path. For example: No closing php tag in .php files! <?php # .../Mage/Catalog/Model/Product.php class Mage_Catalog_Model_Product extends … { … } 4
URL structure http://.../<frontName>/<controller>/<action>/param1/val1... http://.../<frontName>/<controller>/<action>?param1=val1... <frontName> – keyword defined by module <controller> – relative path&name of the controller <action> - The controller’s method’s name without the Action suffix. 5
Design – Blocks Module components used to provide information to the layout. 6
Design - Layouts .xml files used to describe the pages’ layout Basic components: handles blocks actions removes 7
Design - Templates .phtml files used to describe the HTML of some element Basic functions: Block’s methods getChildHtml 8
Design Fallback Magento first checks the sat up package’s theme Next - package’s default theme Next - base package’s theme 9
Creating a module Step 1. Tell Magento for your module by creating file in app/etc/modules/SoftUni_Submission.xml <?xml version="1.0"?> <config> <modules> <SoftUni_Submission> <active>true</active> <codePool>local</codePool> </ SoftUni_Submission > </modules> </config> 10
Creating a module Step 2. add config.xml for your module by creating file in app/code/local/SoftUni/Submission/config.xml <?xml version="1.0"?> <config> <modules> <SoftUni_Submission> <version>1.0.0</version> </ SoftUni_Submission > </modules> </config> 11
Creating a module Step x. Create Helper – you may need it. Define it in config.xml Create helper class in app/code/local/SoftUni/Submission/Helper/Data.php 12
Creating a module Step x. Create installer See Mage_Sales’s installer, how it’s defined in the ‘resources’ tag in it’s config.xml and how tables are created in the sql folder 13
Creating a module Step x. Create Models, Controllers, Blocks, layouts and etc. Define it in config.xml Create their class/file 14
© Software University Foundation – http://softuni.org This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike license. 15
Thank you 16
License This course (slides, examples, demos, videos, homework, etc.) is licensed under the "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International" license 17 © Software University Foundation – http://softuni.org This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike license. 17
Trainings @ Software University (SoftUni) Software University – High-Quality Education, Profession and Job for Software Developers softuni.bg Software University Foundation softuni.org Software University @ Facebook facebook.com/SoftwareUniversity Software University Forums forum.softuni.bg © Software University Foundation – http://softuni.org This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike license. 18