Guest User

Untitled

a guest
Apr 1st, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.58 KB | None | 0 0
  1. /template/random/random.phtml CODE
  2.  
  3. <?php
  4. $manufacturer = Mage::registry('current_product')->getMerchantName();
  5.  
  6. $productCollection = Mage::getModel('catalog/product')->getCollection()
  7. ->addAttributeToSelect('*')
  8. ->addAttributeToFilter('merchant_name',$manufacturer);
  9. $productCollection->getSelect()->order('RAND()');
  10. $productCollection->getSelect()->limit(5);
  11.  
  12. foreach ($productCollection as $_product) {
  13. echo $_product->getName();
  14. }
  15.  
  16. <div class="products-list-grid columns<?php echo $_columnCount ?>">
  17. <?php $i=0; foreach ($_productCollection as $_product): $i++; ?>
  18. <div class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
  19. <?php if($_product->getRatingSummary()): ?>
  20. <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
  21. <?php endif; ?>
  22. <?php include('view/labels.phtml') ?>
  23. <?php $mainImg = $this->helper('catalog/image')->init($_product, 'small_image')->resize($imgSize); ?>
  24. <?php if($hoverSwap): $backImg = $this->getLayout()->createBlock("ajax/listmedia")->setTemplate("catalog/product/list/media.phtml")->setData('size', $imgSize)->setData('product', $_product)->toHtml(); endif; ?>
  25.  
  26. <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image">
  27. <?php if($backImg != 'null' && $backImg): ?><img src="<?php echo $backImg ?>" width="<?php echo $imgSize ?>" height="<?php echo $imgSize ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /><?php endif; ?>
  28. <img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($imgSize) ?>" <?php if($backImg != 'null' && $backImg): ?>onmouseover="hideImage(this)" onmouseout="showImage(this)"<?php endif; ?> width="<?php echo $imgSize ?>" height="<?php echo $imgSize ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
  29. </a>
  30.  
  31. <div id="productimgover<?php echo $_product->getId()?>" style="display: none;"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(64); ?>" width="64" height="64" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></div>
  32.  
  33. <div class="moreinfo">
  34. <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></a></h2>
  35. <div id='productname<?php echo $_product->getId()?>' style='display:none'><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></div>
  36.  
  37.  
  38. <?php
  39. $merchant_name = $_product->getAttributeText('merchant_name');
  40. if ($merchant_name){?>
  41. <div>by <?php echo $merchant_name;?> </div>
  42. <?php }
  43.  
  44. else if ($_product->getIsEbayaffiliate()) { ?>
  45. <div>by eBay</div>
  46. <?php }
  47.  
  48. else { ?>
  49. <div>by Home Done</div>
  50. <?php } ?>
  51.  
  52.  
  53. <?php echo $this->getPriceHtml($_product, true) ?>
  54. <?php if($_product->isSaleable()): ?>
  55. <?php if ( !($_product->getTypeInstance(true)->hasRequiredOptions($_product) || $_product->isGrouped()) ) { ?>
  56. <p>
  57. <?php if ($product = Mage::getModel('catalog/product')->load($_product->getId())); { ?>
  58. <?php if ($merchant_name){ ?>
  59. <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>">
  60. <button type="button" title="View Product Detail" class="button btn-cart"><span><span>View Product Detail</span></span> </button>
  61. </a>
  62. <?php } else if ($product->getIsEbayaffiliate()) { ?>
  63. <a href="<?php echo $product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>">
  64. <button type="button" title="View Product Detail" class="button btn-cart"><span><span>View Product Detail</span></span> </button>
  65. </a>
  66. <?php } else { ?>
  67.  
  68. <button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="<?php if($enableAjax): ?>setLocationAjax<?php else: ?>setLocation<?php endif; ?>('<?php echo $this->getAddToCartUrl($_product) ?>','<?php echo $_product->getId()?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
  69. <?php } ?>
  70. <?php } ?>
  71. </p>
  72.  
  73. <?php } else { ?>
  74. <button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="<?php if($enableAjax): ?>showOptions('<?php echo $_product->getId()?>')<?php else: ?>setLocation('<?php echo $this->getAddToCartUrl($_product) ?>','<?php echo $_product->getId()?>')<?php endif;?>"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
  75. <a href='<?php echo $this->getUrl('ajax/index/options',array('product_id'=>$_product->getId()));?>' class='fancybox' id='fancybox<?php echo $_product->getId()?>' style="display: none;" ><?php echo $this->__('Add to Cart') ?></a>
  76. <?php } ?>
  77. <?php else: ?>
  78. <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
  79. <?php endif; ?>
  80. <div class="clear"></div>
  81. <?php if(themeOptions('addto')): ?>
  82. <ul class="add-to-links">
  83. <?php if ($this->helper('wishlist')->isAllow()) : ?>
  84. <li>+ <a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
  85. <?php endif; ?>
  86. <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
  87. <li>+ <span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
  88. <?php endif; ?>
  89. </ul>
  90. <?php endif; ?>
  91. <div class="clear"></div>
  92. </div>
  93. </div>
  94. <?php endforeach ?>
Advertisement
Add Comment
Please, Sign In to add comment