Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /template/random/random.phtml CODE
- <?php
- $manufacturer = Mage::registry('current_product')->getMerchantName();
- $productCollection = Mage::getModel('catalog/product')->getCollection()
- ->addAttributeToSelect('*')
- ->addAttributeToFilter('merchant_name',$manufacturer);
- $productCollection->getSelect()->order('RAND()');
- $productCollection->getSelect()->limit(5);
- foreach ($productCollection as $_product) {
- echo $_product->getName();
- }
- <div class="products-list-grid columns<?php echo $_columnCount ?>">
- <?php $i=0; foreach ($_productCollection as $_product): $i++; ?>
- <div class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
- <?php if($_product->getRatingSummary()): ?>
- <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
- <?php endif; ?>
- <?php include('view/labels.phtml') ?>
- <?php $mainImg = $this->helper('catalog/image')->init($_product, 'small_image')->resize($imgSize); ?>
- <?php if($hoverSwap): $backImg = $this->getLayout()->createBlock("ajax/listmedia")->setTemplate("catalog/product/list/media.phtml")->setData('size', $imgSize)->setData('product', $_product)->toHtml(); endif; ?>
- <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image">
- <?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; ?>
- <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) ?>" />
- </a>
- <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>
- <div class="moreinfo">
- <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>
- <div id='productname<?php echo $_product->getId()?>' style='display:none'><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></div>
- <?php
- $merchant_name = $_product->getAttributeText('merchant_name');
- if ($merchant_name){?>
- <div>by <?php echo $merchant_name;?> </div>
- <?php }
- else if ($_product->getIsEbayaffiliate()) { ?>
- <div>by eBay</div>
- <?php }
- else { ?>
- <div>by Home Done</div>
- <?php } ?>
- <?php echo $this->getPriceHtml($_product, true) ?>
- <?php if($_product->isSaleable()): ?>
- <?php if ( !($_product->getTypeInstance(true)->hasRequiredOptions($_product) || $_product->isGrouped()) ) { ?>
- <p>
- <?php if ($product = Mage::getModel('catalog/product')->load($_product->getId())); { ?>
- <?php if ($merchant_name){ ?>
- <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>">
- <button type="button" title="View Product Detail" class="button btn-cart"><span><span>View Product Detail</span></span> </button>
- </a>
- <?php } else if ($product->getIsEbayaffiliate()) { ?>
- <a href="<?php echo $product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>">
- <button type="button" title="View Product Detail" class="button btn-cart"><span><span>View Product Detail</span></span> </button>
- </a>
- <?php } else { ?>
- <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>
- <?php } ?>
- <?php } ?>
- </p>
- <?php } else { ?>
- <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>
- <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>
- <?php } ?>
- <?php else: ?>
- <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
- <?php endif; ?>
- <div class="clear"></div>
- <?php if(themeOptions('addto')): ?>
- <ul class="add-to-links">
- <?php if ($this->helper('wishlist')->isAllow()) : ?>
- <li>+ <a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
- <?php endif; ?>
- <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
- <li>+ <span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
- <?php endif; ?>
- </ul>
- <?php endif; ?>
- <div class="clear"></div>
- </div>
- </div>
- <?php endforeach ?>
Advertisement
Add Comment
Please, Sign In to add comment