Skip to content

Instantly share code, notes, and snippets.

@xcommerce-gists
xcommerce-gists / Item.php
Created January 21, 2014 19:13
Sample Magento block for an individual news article
<?php
/**
* News Item block
*
* @author Magento
*/
class Magentostudy_News_Block_Item extends Mage_Core_Block_Template
{
/**
* Current news item instance
@xcommerce-gists
xcommerce-gists / List.php
Created January 21, 2014 19:12
Sample Magento block for the news article list view
<?php
/**
* News List block
*
* @author Magento
*/
class Magentostudy_News_Block_List extends Mage_Core_Block_Template
{
/**
* News collection
@xcommerce-gists
xcommerce-gists / magentostudy_news.xml
Created January 21, 2014 18:56
Sample Magento layout file
<?xml version="1.0"?>
<!--
/**
* Magento frontend layout
*
* @author Magento
*/
-->
<layout version="0.1.0">
<default>
@xcommerce-gists
xcommerce-gists / IndexActionController.php
Created January 21, 2014 01:05
Sample Magento controller
<?php
/**
* News frontend controller
*
* @author Magento
*/
class Magentostudy_News_IndexController extends Mage_Core_Controller_Front_Action
{
/**
* Pre dispatch action that allows to redirect to no route page in case of disabled extension through admin panel
@xcommerce-gists
xcommerce-gists / Collection.php
Created January 21, 2014 00:44
Sample Magento collection
<?php
/**
* News collection
*
* @author Magento
*/
class Magentostudy_News_Model_Resource_News_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
{
/**
* Define collection model
@xcommerce-gists
xcommerce-gists / News.php
Created January 21, 2014 00:43
Sample Magento resource model
<?php
/**
* News item resource model
*
* @author Magento
*/
class Magentostudy_News_Model_Resource_News extends Mage_Core_Model_Resource_Db_Abstract
{
/**
* Initialize connection and define main table and primary key
@xcommerce-gists
xcommerce-gists / config.xml
Last active January 3, 2016 22:49
Sample Magento config.xml showing how models are defined
<config>
<modules>
<!-- omitted for brevity -->
</modules>
<global>
<models>
<magentostudy_news>
<class>Magentostudy_News_Model</class>
<resourceModel>news_resource</resourceModel> <!-- Resource model name -->
</magentostudy_news>
@xcommerce-gists
xcommerce-gists / install-1.0.0.0.1.php
Created January 20, 2014 22:40
Sample Magento module database installation script
<?php
/**
* News installation script
*
* @author Magento
*/
/**
* @var $installer Mage_Core_Model_Resource_Setup
*/
@xcommerce-gists
xcommerce-gists / config.xml
Last active January 3, 2016 22:39
Sample Magento config.xml showing how to alias a database table
<?xml version="1.0"?>
<!--
/**
* Module configuration
*
* @author Magento
*/
-->
<config>
<modules>
@xcommerce-gists
xcommerce-gists / config.xml
Created January 17, 2014 22:01
Sample /app/code/community/Magentostudy/News/etc for the News Management extension
<?xml version="1.0"?>
<!--
/**
* Module configuration
*
* @author Magento
*/
-->
<config>
<modules>