If there is a common functionality/method which you might going to use for other modules as well, better you add those methods inside a helper class.
Now for this instance, you can use either block or helper to write method in order to retrieve a set of simple products. But my suggestion is use the block to retrieve data you want and call the block (block method) in home page.
I'll elaborate the answer here itself.
Suppose we have a module name "Home" inside a namespace as "Test".
I hope you know how to create module activation file, so I'll eliminate it here.
So the config.xml is like this:
app\code\local\Test\Home\etc\config.xml
<?xml version="1.0"?> <config>
<modules>
<Test_Home>
<version>0.1.0</version>
</Test_Home>
</modules>
<frontend>
<routers>
<home>
<use>standard</use>
<args>
<module>Test_Home</module>
<frontName>home</frontName>
</args>
</home>
</routers>
<layout>
<updates>
<home>
<file>home.xml</file>
</home>
</updates>
</layout>
</frontend>
<global>
<blocks>
<home>
<class>Test_Home_Block</class>
</home>
</blocks>
<models>
<home>
<class>Test_Home_Model</class>
</home>
</models>
</global>
<admin>
<routers>
<home>
<use>admin</use>
<args>
<module>Test_Home</module>
<frontName>home</frontName>
</args>
</home>
</routers>
</admin>
</config>
And the block file is like below:
app\code\local\Test\Home\Block\Featuredproducts.php
<?php
class Test_Home_Block_Featuredproducts extends Mage_Core_Block_Template{
public function _construct() {
parent::_construct();
$this->setTemplate('test/featured_products.phtml');
}
public function getFeaturedProducts()
{
$collection = Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect("*")
->addFieldToFilter('status','1')
->addFieldToFilter('visibility',array('in' => array(2,4))); // 2 = Search, 4 = Catalog, Search
return $collection;
}
}
Inside template file name as "featured_products.phtml"
app\design\frontend\default\home\template\test\featured_products.phtml
Now we can call getFeaturedProducts method which is written on the block.
$product_collection = $this->getFeaturedProducts();
Hope this answer will help you.
you can learn from this post, they provide a nice tutorial:
http://excellencemagentoblog.com/admin-part1-series-magento-admin-forms-grids-controllers-tabs
http://excellencemagentoblog.com/admin-part2-series-magento-admin-forms-grids-controllers-tabs
http://excellencemagentoblog.com/module-development-series-magento-admin-module-part3
http://excellencemagentoblog.com/magento-admin-form-field
Best Answer
1) I Assume you have created Model and Collection file associated with that tables.
2) In a Block PHP file constructor add one argument (Dependency Injection) like below and store it in a class member variable.
3) Prepare a public method in your block to access collection like below.
4) Loop through each of the collection result.