© 2014 Irish Titan Anatomy of a Magento Extension Jon Saverda
© 2014 Irish Titan Understanding Extension Flow Local Community Core (Please do not edit these)
© 2014 Irish Titan Starting your extensions local true
© 2014 Irish Titan It Works!
© 2014 Irish Titan Finally getting started 0.1.0
© 2014 Irish Titan Setting up a controller..... standard Irishtitan_Example example.....
© 2014 Irish Titan The controller file class Irishtitan_Example_IndexController extends Mage_Core_Controller_Front_Action { public function indexAction() { echo 'You now have text on the page!!!'; } }
© 2014 Irish Titan Blocks Irishtitan_Example_Block
© 2014 Irish Titan /* Updated controller */ class Irishtitan_Example_IndexController extends Mage_Core_Controller_Front_Action { public function indexAction() { $this->loadLayout(); $block = $this->getLayout()- >createBlock('irishtitan_example/example'); $this->getLayout()->getBlock('content')->insert($block); $this->renderLayout(); } } class Irishtitan_Example_Block_Example extends Mage_Core_Block_Template { public function __construct() { parent::__construct(); $this->setTemplate('irishtitan_example/example.phtml'); } }
© 2014 Irish Titan
Model Model - This is where you place most of your business logic and also represents an entity in the db ●Models need four files in order to work properly ○The model file ○The model resource file ○Model Collection File ○Installation script Irishtitan_Example_Model
© 2014 Irish Titan SQL $installer = $this; $installer>startSetup(); $installer->run(" DROP TABLE IF EXISTS `{$this->getTable(example)}`; CREATE TABLE `fabric` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `example_name` varchar(255) NOT NULL, `example_img` varchar(1000) DEFAULT NULL, `description` text, `active` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `id` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 "); $installer->endSetup();
© 2014 Irish Titan Helpers Irishtitan_Example_Helper class Irishtitan_Example_Helper_Data extends Mage_Core_Helper_Abstract { public function exampleHelper() { return 'Here is a example of the helper'; } } exampleHelper(); ?>
© 2014 Irish Titan
Events / Observers Irishtitan_Example_Model_Observer sendProductToThirdParty class Irishtitan_Example_Model_Observer { public function sendProductToThirdPartyAction($observer) { /* Here is the code to send a product to a third party */ $product = $observer->getEvent()->getProduct(); } }
© 2014 Irish Titan Resources