【问题标题】:How to make product name link to product page in magento如何在magento中将产品名称链接到产品页面
【发布时间】:2013-06-07 18:21:51
【问题描述】:

我已经为我的 magento 网站创建了一个自定义发布日历块,但是我无法弄清楚如何让我的产品名称链接到产品页面。这是我的日历准备好上线之前的最后一步,我们将不胜感激。

这是我目前所拥有的:

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

}

【问题讨论】:

    标签: php magento magento-1.7


    【解决方案1】:

    您应该能够链接到 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>";
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-11
      • 1970-01-01
      • 2013-08-23
      相关资源
      最近更新 更多