This is the list.phtml where I display the newest products on homepage.
<?php
$collection = $this->getProductCollection();
$_collectionSize = count($collection);
$_columnCount = $this->getColumnCount();
?>
<div class="sama_productblocks_grid">
<h3 class="divider-h3"><?php echo $this->getTitle();?></h3>
<div class="sama_productblocks_descrition"><?php echo $this->getDescription();?></div>
<?php $i=0; foreach ($collection as $item): ?>
<?php if ($i++%$_columnCount==0): ?>
<ul class="products-grid column-<?php echo $_columnCount;?> newest-products-list">
<?php endif;?>
<li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
<a href="<?php echo $item['url']?>" title="<?php echo $item['name']?>" class="product-image">
<img src="<?php echo $item['image']?>" width="<?php echo $this->getThumbnailWidth();?>" alt="<?php echo $item['name']?>">
</a>
<h2 class="product-name">
<a href="<?php echo $item['url']?>" title="<?php echo $item['name']?>"><?php echo $item['name']?></a>
</h2>
<div class="price-box">
<p class="regular-price">
<?php echo Mage::helper('core')->currency($item['finalprice'], true, false);?>
</p>
</div>
<div class="add-to-cart-main">
<a href = "<?php echo $item['url']?>" class="add-to-cart">
<div class="cart-elements">
<span class='add-to-cart-img fa fa-arrow-right'></span>
<span class='add-to-cart-text'><?php echo $this->__('View details');?></span>
</div>
</a>
<a href = "#Ineed here a wishlist url" class="wishlist fa fa-heart-o" >
</a>
</div>
</li>
<?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?>
</ul>
<?php endif ?>
<?php endforeach; ?>
</ul>
</div>
I tried to introduce this piece of code to get the wishlist url:
<?php echo $this->getChildHtml('addto') ?>
but with no result. So how do I get a wishlist button ? or a wishlist url where I typed "I need a wishlist url" ? on the homepage. Thx in advance
This is the getProductCollection function:
public function getProductCollection()
{
$useCache = Mage::app()->useCache('SAMA_PRODUCTBLOCKS');
$cacheData = Mage::app()->loadCache($this->getCacheTags());
if ((empty($cacheData) && $useCache) || !$useCache) {
$productCollection = $this->_currentList->getSelectedProductsCollection();
$collection = array();
foreach ($productCollection as $product) {
$product = Mage::getModel('catalog/product')->load($product->getId());
$collection[] = array(
'name' => $product->getName(),
'image' => (string)$this->helper('catalog/image')->init($product, 'small_image')->resize(max(100, (int)$this->_currentList->getThumbnailWidth())),
'url' => $product->getProductUrl(),
'price' => $product->getPrice(),
'finalprice' => $product->getFinalPrice(),
'sku' => $product->getId(),
'qty' => $product->getIsInStock()
);
}
Mage::app()->saveCache(json_encode($collection), $this->getCacheTags(), array($this->getCacheTags()));
} else {
$collection = json_decode($cacheData, true);
}
return $collection;
}