Create a local.xml under app/design/frontend/yourpackage/yourtemplate/layout/local.xml
code of this file are
< ?xml version="1.0"?>
<layout version="0.1.0">
<cms_index_index>
<reference name="content">
<block type="core/template" name="my_default_home_page" template="cms/home.phtml"/>
</reference>
</cms_index_index>
</layout>
and create home.phtml under app/design/frontend/yourpackage/yourtemplate/template/cms and code is this file below
here the code
$catgorcollection=Mage:getModel('catalog/category')->getCollection();
foreach($catgorcollection as $category ){
$todayStartOfDayDate = Mage::app()->getLocale()->date()
->setTime('00:00:00')
->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
$todayEndOfDayDate = Mage::app()->getLocale()->date()
->setTime('23:59:59')
->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
$collection = Mage::getResourceModel('catalog/product_collection');
$collection->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds());
$collection
->addMinimalPrice()
->addFinalPrice()
->addTaxPercents()
->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
->addUrlRewrite();
$collection = $this->_addProductAttributesAndPrices($collection)
->addStoreFilter()
->addAttributeToFilter('news_from_date', array('or'=> array(
0 => array('date' => true, 'to' => $todayEndOfDayDate),
1 => array('is' => new Zend_Db_Expr('null')))
), 'left')
->addAttributeToFilter('news_to_date', array('or'=> array(
0 => array('date' => true, 'from' => $todayStartOfDayDate),
1 => array('is' => new Zend_Db_Expr('null')))
), 'left')
->addAttributeToFilter(
array(
array('attribute' => 'news_from_date', 'is'=>new Zend_Db_Expr('not null')),
array('attribute' => 'news_to_date', 'is'=>new Zend_Db_Expr('not null'))
)
)
->addAttributeToSort('news_from_date', 'desc')
->setPageSize(7)
->setCurPage(1);
$collection->addCategoryFilter($category);
}