我想在一个函数中包含 Magento DB 中表 downloadable_link 的 link_file 字段
我尝试使用 $_prodId = $this->getProduct()->getLinkFile();
获取当前产品的 LinkFile ,但没有成功
最佳答案
<?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;
}
?>
关于php - Magento 如何 getLinkFile(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27622900/