我的 magento 商店中有可下载的产品。 我的可下载产品是付费软件工具。 我们会根据每个版本的变化更新这些可下载的软件工具,并增强软件工具中的新功能。
当客户完成每笔成功的支付交易时,软件包就可以下载了。
我的问题是:
Version - 1:
客户将为 order id #101
购买和使用 Version - 1
包。
Version - 2:
当我们在相应产品的管理面板中更新 Version - 2
时。我们需要放置
Version - 2
为 order id #101
下载包,而不是 id Version - 1
。
magento CE 1.7.0.0 中是否可以使用此选项?
目前订单 id #101 仅在客户可下载页面中下载版本 -1 包。
但是我们需要为每个购买的订单打包文件吗?
请指教。
最佳答案
我将以下代码放入 Magento 根目录中的 .php 脚本中。您可以通过 CRON 或您的网络浏览器调用它。
<?php
require('app/Mage.php');
umask(0);
Mage::app();
$select = getDb()->select()
->from(getTable('downloadable/link'), array('link_id', 'link_file', 'product_id'));
if (($links = getDb()->fetchAll($select)) !== false) {
foreach($links as $link) {
$linkId = $link['link_id'];
$productId = $link['product_id'];
$file = $link['link_file'];
$select = getDb()->select()
->from(getTable('downloadable/link_title'), 'title')
->where('link_id=?', $linkId)
->limit(1);
$title = getDb()->fetchOne($select);
echo sprintf("Updating %s to %s<br />", $file, $title);
$cond = getDb()->quoteInto('product_id=?', $productId);
getDb()->update(getTable('downloadable/link_purchased_item'), array('link_id' =>$linkId,'link_title'=>$title,'link_file'=>$file), $cond);
}
}
function getDb($conn = 'core_read') {
return Mage::getSingleton('core/resource')->getConnection($conn);
}
function getTable($table) {
return Mage::getSingleton('core/resource')->getTableName($table);
}
关于magento - 如何在 magento 中为已下订单更新新的可下载产品附件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17468869/