Url 成功订购后如何获得可下载的产品链接
订单成功后,我想在success.phtml文件中直接建议买家购买的产品的可下载URL 我写这段代码是为了了解最新订单的产品值:Url 成功订购后如何获得可下载的产品链接,url,download,magento,hyperlink,product,Url,Download,Magento,Hyperlink,Product,订单成功后,我想在success.phtml文件中直接建议买家购买的产品的可下载URL 我写这段代码是为了了解最新订单的产品值: // Get the latest Order ID $order = Mage::getModel('sales/order')->load(Mage::getSingleton('checkout/session')->getLastOrderId()); // Get every products on the latest order $items
// Get the latest Order ID
$order = Mage::getModel('sales/order')->load(Mage::getSingleton('checkout/session')->getLastOrderId());
// Get every products on the latest order
$items = $order->getAllItems();
// Loop the products
foreach ($items as $item){
$product = Mage::getModel('catalog/product')->setStoreId($order->getStoreId())->load($item->getProductId());
// HERE I NEED FUNCTION TO GET DOWNLOADABLE URL LINK
}
这对我很有用:
$links = Mage::getModel('downloadable/link_purchased_item')->getCollection()
->addFieldToFilter('order_item_id', $item->getId());
foreach ($links as $link) {
echo Mage::helper('downloadable')->__('download') .
$this->getUrl('downloadable/download/link',
array('id' => $link->getLinkHash(), '_store' => $order()->getStore(),
'_secure' => true, '_nosid' => true));
}
这对我很有用:
$links = Mage::getModel('downloadable/link_purchased_item')->getCollection()
->addFieldToFilter('order_item_id', $item->getId());
foreach ($links as $link) {
echo Mage::helper('downloadable')->__('download') .
$this->getUrl('downloadable/download/link',
array('id' => $link->getLinkHash(), '_store' => $order()->getStore(),
'_secure' => true, '_nosid' => true));
}
我找到了一个解决方案,它是: 首先,在template/downloadable/中创建一个新的.phtml文件,我称之为mine downloadablelist.phtml 然后将所有模板/downloadable/customer/products/list.phtml复制到新的downloadablelist.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)) ?>"
href=“”
谢谢我找到了一个解决方案,它是: 首先,在template/downloadable/中创建一个新的.phtml文件,我称之为mine downloadablelist.phtml 然后将所有模板/downloadable/customer/products/list.phtml复制到新的downloadablelist.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)) ?>"
href=“”
首先感谢您当您可以将它们发送到他们的客户帐户,在那里所有这些工作都已经为您完成了,为什么还要麻烦呢?第二,如果您无法处理用户帐户页面中已经存在的此功能,您是否查看了显示可下载产品链接的代码,并尝试按照他们的代码建模?第一,当您可以将其发送到他们的客户帐户,在那里,所有这些工作都已经为您完成,为什么还要为此而烦恼?第二,如果您无法处理用户帐户页面中已经存在的此功能,您是否查看了显示可下载产品链接的代码,并尝试按照它们对代码进行建模?