|
Hi every one,
I have an issue here. I could find the codes to show new products and on sale items. Now, I want to use , list.phtml template for them. I really appreciate if anyone can help me.
Just for your information, I used following block to call new items:
{{block type="catalog/product_new" name="home.catalog.product.new" alias="product_homepage" template="catalog/product/new.phtml"}}
And use following codes to get the items on sale:
<?php
$product = Mage::getModel('catalog/product');
$collection = $product->getCollection();
foreach ($collection as $product)
{
$result[] = $product->getId();
}
$i = 0;
$j = 0;
$product_ = array();
foreach ($result as $_product_id)
{
$in_stock = 0;
$i++;
$_product = new Mage_Catalog_Model_Product();
$_product->load($_product_id);
$time = time();
if(strtotime($_product->getSpecialFromDate()) < time() && strtotime($_product->getSpecialToDate()) > $time) {
$product_[$j]['price'] = $_product->getPrice();
$product_[$j]['special_price'] = $_product->getSpecialPrice();
$product_[$j]['name'] = $_product->getName();
$product_[$j]['image'] = $_product->getSmallImageUrl();
$product_[$j]['url'] = $_product->getProductUrl();
$in_stock = $_product->isInStock();
if($in_stock) {
$in_stock = 'In Stock';
}else {
$in_stock = 'Out of Stock';
}
$product_[$j]['in_stock'] = $in_stock;
$j ++;
}
}
?>
<?php
if(empty($product_)) {
echo $this->__('There is no product on sale');
}
foreach($product_ as $item)
{
?>
<div class="Item">
<a href="<?php echo $item['url'];?>"><img src="<?php echo $item['image'];?>” alt="<?php echo $item['name'];?>” /></a><br />
<a href="<?php echo $item['url'];?>"><?php echo $item['name'];?></a><br />
<span class="RegularPrice"><?php echo $item['price'];?></span>
<span class="SpecialPrice"><?php echo $item['special_price'];?></span>
<div class="Stock"><?php echo $item['in_stock'];?></div>
</div>
<?php
}
?>
|