我想在函数中包含Magento DB中表可下载链接的链接文件字段
我试图用$_prodId = $this->getProduct()->getLinkFile();
获取当前产品的链接文件,但没有成功
最佳答案
<?php
$table = Mage::getModel('downloadable/link');
$collection = $table->getCollection()->addProductToFilter($product_id);
foreach ($collection as $downloadable){
echo $downloadable->getLinkFile();
}
?>
所以你只能找到第一张唱片。
<?php
$product = Mage::registry('current_product');
if ($product->getTypeId() == 'downloadable') {
$table = Mage::getModel('downloadable/link');
$collection = $table->getCollection()->addProductToFilter($product->getId());
foreach ($collection as $downloadable){
$linkFile = $downloadable->getLinkFile();
break;
}
echo $linkFile;
}
?>