|
first of all my code style is not very good
here in the forum i found a posting
where someone provides hompage.html and hompage .php
i think with the serch function you can find it.
with this code on the main page (can finde it an the admin area CMS)
{{block type="catalog/product_new" template="catalog/product/homepage.phtml""}}
products are seen which are set as “new products” (inside the product description)
if i understand it right
catalog/product_new means
inside the Template folder
in catalog/products/ and the filename is new.php
my new file was newCS.php so the new code for the mainpage is
{{block type="catalog/product_newCS" template="catalog/product/homepage.phtml""}}
my mistake was first that i wrote newcs not newCS
im not sure if newCS depends on the filname newCS.php
or on the classname
here the code
class Mage_Catalog_Block_Product_NewCS extends Mage_Catalog_Block_Product_Abstract
{
public function __construct()
{
parent::__construct();
$storeId = Mage::app()->getStore()->getId();
$product = Mage::getModel(’catalog/product’);
/* @var $product Mage_Catalog_Model_Product */
$todayDate = $product->getResource()->formatDate(time());
$products = $product->setStoreId($storeId)->getCollection()
->addAttributeToFilter(’relaese’, array(’date’=>true, ‘from’=> $todayDate))
->addAttributeToSelect(array(’name’, ‘price’, ‘small_image’), ‘inner’)
->addAttributeToSelect(array(’special_price’, ‘special_from_date’, ‘special_to_date’), ‘left’)
;
/* @var $products Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection */
Mage::getSingleton(’catalog/product_status’)->addVisibleFilterToCollection($products);
Mage::getSingleton(’catalog/product_visibility’)->addVisibleInCatalogFilterToCollection($products);
$products->setOrder(’news_from_date’)->setPageSize(5)->setCurPage(1);
$this->setProductCollection($products);
}
}
i dont understand everything
->addAttributeToFilter(’relaese’, array(’date’=>true, ‘from’=> $todayDate))
this line means products date from todayDate
->addAttributeToSelect(array(’name’, ‘price’, ‘small_image’), ‘inner’)
->addAttributeToSelect(array(’special_price’, ‘special_from_date’, ‘special_to_date’), ‘left’)
here what attribute are selected
|