|
hello ohminu!
I´ve used the code people posted in the forum, like:
in CMS>Homepage>Contens
“{{block type="catalog/product_new" template="catalog/product/new.phtml" “}}
and used the new.php and new.phtml provided with the package.
new.phtml
<?php if (($_products = $this->getProductCollection()) && $_products->getSize()): ?>
<div class="box recently">
<h3><?php echo $this->__('New Products') ?></h3>
<table cellspacing="0" class="recently-list" id="recently-compared-list-table">
<tr>
<?php $i=0; foreach ($_products->getItems() as $_product): ?>
<?php if ($i>10): continue; endif; ?>
<td>
<div>
<a href="<?php echo $_product->getProductUrl() ?>” title="<?php echo $this->htmlEscape($_product->getName()) ?>">
<img class="product-image" src="<?php echo $_product->getSmallImageUrl() ?>” width="100" height="75" alt="<?php echo $this->htmlEscape($_product->getName()) ?>"/>
</a>
</div>
<p><a class="product-name" href="<?php echo $_product->getProductUrl() ?>” title="<?php echo $this->htmlEscape($_product->getName()) ?>)"><?php echo $this->htmlEscape($_product->getName()) ?></a></p>
<?php echo $this->helper('review/product')->getSummaryHtml($_product, 'short') ?>
<?php echo $this->helper('catalog/product')->getPriceHtml($_product) ?>
<?php if($_product->isSaleable()): ?>
<button class="form-button" onclick="setLocation(’<?php echo $this->getAddToCartUrl($_product) ?>’)"><span><?php echo $this->__('Add to Cart') ?></span></button>
<?php else: ?>
<div class="out-of-stock"><?php echo $this->__('Out of stock') ?></div>
<?php endif; ?>
<div class="clear"></div>
<p class="add-to">
<?php if ($this->helper('wishlist')->isAllow()) : ?>
<a href="<?php echo $this->getAddToWishlistUrl($_product) ?>” class="link-cart"><?php echo $this->__('Add to Wishlist') ?></a>
<?php endif; ?>
<?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?><br/>
<a href="<?php echo $_compareUrl ?>"><?php echo $this->__('Add to Compare') ?></a>
<?php endif; ?>
</p>
</td>
<?php $i++; endforeach; ?>
<?php for($i;$i%4!=0;$i++): ?>
<td> </td>
<?php endfor ?>
</tr>
</table></div>
<?php endif; ?>
and new.php
class Mage_Catalog_Block_Product_New 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(’news_from_date’, array(’date’=>true, ‘to’=> $todayDate))
->addAttributeToFilter(array(array(’attribute’=>’news_to_date’, ‘date’=>true, ‘from’=>$todayDate), array(’attribute’=>’news_to_date’, ‘is’ => new Zend_Db_Expr(’null’))),’’,’left’)
->addAttributeToSort(’news_from_date’,’desc’)
->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(4)->setCurPage(1);
$this->setProductCollection($products);
}
}
thanks:)
|