获取Magento中可下载产品的示例URL

获取Magento中可下载产品的示例URL,magento,Magento,我试图在产品页面的交叉销售块中获取可下载产品的示例文件url 我的crosssell.phtml的内容 <?php $_helper = $this->helper('catalog/output'); ?> <?php $_product = $this->getProduct(); ?> <?php if($_crossSellProducts = $_product->getCrossSellProducts()): ?>

我试图在产品页面的交叉销售块中获取可下载产品的示例文件url

我的crosssell.phtml的内容

<?php $_helper = $this->helper('catalog/output'); ?>
<?php $_product = $this->getProduct(); ?>

    <?php if($_crossSellProducts = $_product->getCrossSellProducts()): ?>

    <div id="music-crosssell-modal" style="display:none;">
        <div class="modal-inner">
        <span id="music-crosssell-header">Featured Music</span>

    <ul id="music-crosssell-products-list">
    <?php foreach ($_crossSellProducts as $_item): ?>

        <?php $_item = Mage::getModel('catalog/product')->load($_item->getId()); ?>

        <li class="music-item paused" id="<?php echo urlencode($this->htmlEscape($_item->getSongTitle())) ?>">
                <span class="player">Loading...</span>
                <span class="track-title"><?php echo $this->htmlEscape($_item->getSongTitle()) ?> by </span> <span class="music-track-artist"><?php echo $this->htmlEscape($_item->getMusicianName()) ?></span>
                <button type="button" title="<?php echo $this->__('Buy Now') ?>" class="button btn-primary" onclick="setLocation('<?php echo $this->getAddToCartUrl($_item) ?>')">
                    <?php echo $this->__('Buy Now') ?>
                </button>
        </li>

        <?php
        $_myprodsamples = Mage::getModel('downloadable/sample');
        $_mySampleCollection = $_myprodsamples->getCollection()
        ->addProductToFilter($_item->getId());
        ?>

        <?php
        foreach ($_mySampleCollection as $_sample):
            $_samplelink = $this->getUrl('downloadable/download/sample/sample_id/'.$_sample->getId());
        ?>

        <?php echo Mage::getModel('downloadable/sample')->load($_samplelink)->getUrl() ?>

        <script type="text/javascript">
            jwplayer("#<?php echo urlencode($this->htmlEscape($_item->getSongTitle())) ?> .player").setup({
                flashplayer: "/skin/frontend/default/datura/js/jwplayer/player.swf') ?>",
                file: "<?php echo Mage::getModel('downloadable/sample')->load($sampleId)->getUrl() ?>",
                height: 25,
                width: 25,
                controlbar: "bottom"
            });
        </script>


        <?php
            endforeach;
        ?>



        <script type="text/javascript">
            jwplayer("#<?php echo urlencode($this->htmlEscape($_item->getSongTitle())) ?>").setup({
            flashplayer: "/skin/frontend/default/datura/js/jwplayer/player.swf') ?>",
            file: "",
            height: 25,
            width: 300,
            controlbar: "bottom"
            });
        </script>



    <?php endforeach; ?>
    </ul>
</div>
    <span id="music-crosssell-close-btn" class="close-modal-btn">X</span>
</div>

<?php endif; ?>

特色音乐
    您可以尝试以下方法:

    $_myprodsamples = Mage::getModel('downloadable/link');
    $_mySampleCollection = $_myprodsamples->getCollection()
                       ->addProductToFilter($_product->getId());
    foreach ($_mySampleCollection as $_sample){
       echo $_samplelink = $this->getUrl('downloadable/download/linkSample/link_id/'.$_sample ->getId());
    } 
    

    我希望这对您有用

    您也可以使用

     <?php $sampleColl = Mage_Downloadable_Block_Catalog_Product_Samples::getSamples($_product); 
        foreach ($sampleColl as $_sample){  
            echo "<pre>";
            print_r($_sample);      
        }
      ?>
    
    
    
    我希望这对你有帮助