0

I've created a custom release calendar block for my magento website but, I'm having trouble figuring out how to make my product names link to the product page. This is the final step before my calendar is ready to go live and any pointers will be greatly appreciated.

Here's what I have so far:

<?php 

class LSC_ReleaseCalendar_Block_Calendar extends Mage_Core_Block_Template 
{    
    public function getReleasesCollection()
  { 
    $preorderAttribute = 'preorder';
    $preorderValue = 'yes';
    $products = Mage::getModel('catalog/product')->getCollection()  
        ->addAttributeToSelect('*')
        ->addFieldToFilter(
            $preorderAttribute,
                array(
                    'eq' => Mage::getResourceModel('catalog/product')
                        ->getAttribute($preorderAttribute)
                        ->getSource()
                        ->getOptionId($preorderValue)
            )   
        )
        ->addAttributeToSort('ReleaseDate', 'DESC');
    echo '<table class="release_calendar" style="text-align: left;">';
    echo '<tr><th>Release Date</th><th>Product Name</th></tr>';
    foreach ($products as $product) {
        $releaseDate = date("m/d/Y", strtotime ($product->getReleaseDate()));
        $productName = $product->getName(); 
        echo '<tr>';
        echo "<td width='15%'>{$releaseDate}</td>";
        echo "<td width='85%'>{$productName}</td>";
        echo '</tr>';   
    }
    echo '</table>';
  }

}
4

1 回答 1

2

您应该能够链接到 productURL

    $productName = $product->getName(); 
    $productURL = $product->getProductUrl();
    echo '<tr>';
    echo "<td width='15%'>{$releaseDate}</td>";
    echo "<td width='85%'><a href='{$productURL}'>{$productName}</a></td>";
于 2013-06-07T18:36:39.257 回答