Get sample URL for downloadable product in Magento -
i'm trying sample file url downloadable product in cross sell block on product page.
the contents of 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 $_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()) ?> </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 $_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; ?>
you can try :
$_myprodsamples = mage::getmodel('downloadable/link'); $_mysamplecollection = $_myprodsamples->getcollection() ->addproducttofilter($_product->getid()); foreach ($_mysamplecollection $_sample){ echo $_samplelink = $this->geturl('downloadable/download/linksample/link_id/'.$_sample ->getid()); }
i hope work
Comments
Post a Comment