添加成功页面上的下载链接

问题描述:

可能重复:
How to get downloadable product links after successfull order添加成功页面上的下载链接

我不知道是否有可能订购后添加Magento的成功页面上有多个下载链接。

我能得到一个有效链接可下载文件与此代码:

$incrementId = $this->getOrderId(); 

$linkPurchased = Mage::getModel('downloadable/link_purchased')->load($incrementId, 'order_increment_id'); 

$downloadableItems = Mage::getResourceModel('downloadable/link_purchased_item_collection')->addFieldToFilter('purchased_id', $linkPurchased->getPurchasedId()); 
foreach ($downloadableItems as $item) { 

$links = Mage::getModel('core/url')->getUrl('downloadable/download/link', array('id' => $item->getLinkHash(), '_secure' => true)); 
echo $this->__('Download').' le <a href="'.$links.'" target="_blank">file</a>'; 

它给了我成功的页面上一个完美的连接,即使我的订单有多个项目。

问题: 在$ linkPurchased目的只有一个项目。

为什么

Mage::getModel('downloadable/link_purchased')->load($incrementId, 'order_increment_id'); 

只返回一个项目?

谢谢

我找到了解决办法,那就是:

首先,创建一个新的文件一个.phtml模板/下载/,我打电话给我downloadablelist.phtml

然后复制所有的模板/下载/立方米的在我们的新downloadablelist.phtml stomer /产品/ list.phtml

这将给我们的客户帐户的副本我下载的产品列表。

拨打我们的成功页面块:

<?php echo $this->getLayout()->createBlock('downloadable/customer_products_list')->setTemplate('downloadable/checkout/downloadablelist.phtml')->toHtml(); ?> 

现在我清理了什么,我不从产品列表中所需要的。我删除了表格并添加了一个ul。

接下来是只显示从上一个定做的产品。

<?php 
$_items = $this->getItems(); 
$orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); 
if(count($_items)): 
$_group_id = Mage::helper('customer')->getCustomer()->getGroupId(); 
echo '<p><strong>'.$this->__('Downloadable products').' : </strong></p>'; ?> 
<ul style="margin-left: 30px; list-style: disc;"> 
     <?php foreach ($_items as $_item): 
      $itemOrderId = $_item->getPurchased()->getOrderIncrementId(); 
      if($itemOrderId == $orderId) {?> 
      <li><?php echo $this->htmlEscape($_item->getPurchased()->getProductName()) ?> - <a href="<?php echo $this->getUrl('downloadable/download/link/', array('id' => $_item->getLinkHash(), '_secure' => true)) ?>" title="<?php echo Mage::helper('downloadable')->__('Start Download') ?>" <?php echo $this->getIsOpenInNewWindow()?'onclick="this.target=\'_blank\'"':''; ?>><?php echo $_item->getLinkTitle() ?></a></li> 
      <?php } 
      endforeach; ?> 
    </ul> 
<?php endif; ?> 

我改变了URL原来下载的文件必须:

href="<?php echo $this->getUrl('downloadable/download/link/', array('id' => $_item->getLinkHash(), '_secure' => true)) ?>" 

谢谢

+0

,我开始从那里,那家伙只需要阵列返回一个链接,但我需要更多的从“可下载/ link_purchased”模型返回的项目。 – Petedabeast 2012-03-08 15:15:25