Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Use List.phtml template for new products and on sale items
 
hamedm
Jr. Member
 
Total Posts:  2
Joined:  2009-10-07
 

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
}
?>

 
Magento Community Magento Community
Magento Community
Magento Community
 
BaluErtl
Jr. Member
 
Total Posts:  11
Joined:  2009-09-03
 

I’m looking for a solution for the same problem as well for a long time ago.

Half-solution is adding only a toolbar above (and below) new.phtml written about in this thread: http://www.magentocommerce.com/boards/viewthread/31159 , but it’s functionality not as full, as list.phtml’s.

Thanks in advance if anybody could give tip, how to hack this.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top