Magento remove zoom from product image - magento

Im not really familiar with Magento and i need to remove zoom effect from product image.
This is the code from /catalog/product/view/media.phtml inside template directory.
I tried to play around with if-else statement, but it seems im missing something because i am getting errors.
Is anybody more familiar with this to take a look?
Thanks a bunch!
<div class="product-image">
<?php if ($scrollStatus): ?>
<div id="jp-container" class="jp-container" style="height:500px;">
<a href="javascript:void(0);"><?php
$_img = '<img src="'.$helpImg->getImg($_product, 'image', $imgSize, null).'" alt="'.$this->escapeHtml($this->getImageLabel()).'" title="'.$this->escapeHtml($this->getImageLabel()).'" />';
echo $_img;
?></a>
<?php foreach ($this->getGalleryImages() as $_image): ?>
<img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile()); ?>" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" />
<?php endforeach; ?>
</div>
<script type="text/javascript">
jQuery(window).load(function(){
function jspaneStart(){
setTimeout(function(){
maxHeight = 0;
jQuery('#jp-container a').each(function(){
if(jQuery(this).height() > maxHeight){
maxHeight = jQuery(this).height();
}
});
maxHeight = maxHeight+(maxHeight/100)*<?php echo $scrollimagesHeight; ?>;
jQuery('#jp-container').css('height', maxHeight);
jQuery('#jp-container').jScrollPane();
}, 500);
}
jspaneStart();
jQuery(window).resize(function(){
jspaneStart();
});
});
</script>
<?php else: ?>
<a id='zoom' class="cloud-zoom" data-zoom="showTitle: false, adjustX: -5, adjustY:-5, tint: '#fff', tintOpacity:0.6, position:'inside'" href="<?php echo $this->helper('catalog/image')->init($_product, 'image'); ?>"><?php
$_img = '<img id="image" src="'.$helpImg->getImg($_product, 'image', $imgSize, null).'" alt="'.$this->escapeHtml($this->getImageLabel()).'" title="'.$this->escapeHtml($this->getImageLabel()).'" />';
echo $_helper->productAttribute($_product, $_img, 'image');
?></a>
<?php /* Label New */ echo MAGE::helper('ThemeOptionsMinimalism')->getProductLabels($_product); ?>
<?php if (count($this->getGalleryImages()) > 0): ?>
<div class="more-views-container">
<div class="more-views<?php if ($productpage_moreviews == 'moreviews_slider' && count($this->getGalleryImages()) > 3){echo ' slider-on';} ?>">
<h2><?php echo $this->__('More Views') ?></h2>
<?php if ($productpage_moreviews == 'moreviews_slider' && count($this->getGalleryImages()) > 3): ?>
<div id="more-views-slider" class="es-carousel-wrapper">
<ul class="carousel-ul">
<?php foreach ($this->getGalleryImages() as $_image): ?>
<li>
<a class='cloud-zoom-gallery' data-zoom="useZoom: 'zoom', smallImage: '<?php echo $helpImg->getImg($_product, 'thumbnail', $imgSize, null, $_image->getFile()); ?>' " href="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile()); ?>" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>"><img <?php echo $helpImg->getImgSources($_product, 'thumbnail', 200, null, $_image->getFile()); ?> alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" /></a>
</li>
<?php endforeach; ?>
</ul>
</div>
<div class = 'next'><i class="fa fa-angle-right"></i></div>
<div class = 'prev unselectable'><i class="fa fa-angle-left"></i></div>
<?php else: ?>
<ul class="no-slider">
<?php foreach ($this->getGalleryImages() as $_image): ?>
<li>
<a class='cloud-zoom-gallery' data-zoom="useZoom: 'zoom', smallImage: '<?php echo $helpImg->getImg($_product, 'thumbnail', $imgSize, null, $_image->getFile()); ?>' " href="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile()); ?>" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>"><img <?php echo $helpImg->getImgSources($_product, 'thumbnail', 200, null, $_image->getFile()); ?> alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" /></a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
<?php endif; ?>
<?php if ($this->displayProductStockStatus()): ?>
<?php if ($_product->isAvailable()): ?>
<p class="availability in-stock"><i class="fa fa-check"></i><?php echo $this->__('In stock') ?></p>
<?php else: ?>
<p class="availability out-of-stock"><i class="fa fa-times"></i><?php echo $this->__('Out of stock') ?></p>
<?php endif; ?>
<?php endif; ?>
</div>

You can disable zoom from magento js.
just locate this file js\varien\product.js and comment this line
Event.observe(this.imageEl, 'dblclick', this.toggleFull.bind(this));
this line is responsible for image zoom by default.

Go to Admin, then to System -> Configuration.Then go to Manage -> Advanced -> Disable Modules Output -> EcommerceTeam_CloudZoom -> Disable. Click Save Config.
then Go to
System -> Configuration ->Catalog
On the next page under Cloud Image Zoom you will find a list of options to configure the module.
Enable Cloud Zoom – when no is selected, the option disables the Cloud Zoom in your product images.
Click ‘Save Config’ at the top right when you are done.

You could always try disabling the module completely via the module's xml file in app/etc/modules
Your xml file that relates to the zoom module will look something like this:
<?xml version="1.0" encoding="utf-8"?>
<config>
<modules>
<module_name>
<active>true</active>
<codePool>community</codePool>
</module_name>
</modules>
</config>
Simply set active to false

This answer worked for me:
Add JS in media.phtml in your theme.
// ProductMediaManager is outside document.read scope
if (typeof ProductMediaManager !== 'undefined') {
// Override image zoom in /skin/frontend/rwd/default/js/app.js
// and prevent the zooming of images on hover
ProductMediaManager.createZoom = function(image) { return; }
}
I have found the answer form here
Thanks "Patrick Ward" for the great and simple Solution...

Related

Magento SEO Pagination like /page/2

i am trying to play around with pager.phtml, basicaly i do not like the ?p=2 etc that magento use.
I have come through this code that will change the pagination to what i want but this brings of course 404 pages as there is no /page/2 etc.
Should i use a rewrite rule?Can somebody point me on this?
<div class="pages">
<strong><?php
$url= ($this->getCurrentPage()==1)?
$this->getPagerUrl(array($this->getOrderVarName()=>$order, $this->getDirectionVarName()=>$direction,$this->getPageVarName()=>null )).'/':
$this->getPagerUrl(array($this->getOrderVarName()=>$order, $this->getDirectionVarName()=>$direction,$this->getPageVarName()=>null )).'/';
echo $this->__('Page:') ?></strong>
<ol>
<?php if (!$this->isFirstPage()): ?>
<li>
<a class="previous<?php if(!$this->getAnchorTextForPrevious()): ?> i-previous<?php endif;?>"
href="<?php echo $url.'p='.($this->getCurrentPage()-1);?>" title="<?php echo $this->__('Previous') ?>">
<?php if(!$this->getAnchorTextForPrevious()): ?>
<img src="<?php echo $this->getSkinUrl('images/pager_arrow_left.png') ?>" alt="<?php echo $this->__('Previous') ?>" class="v-middle" />
<?php else: ?>
<?php echo $this->getAnchorTextForPrevious() ?>
<?php endif;?>
</a>
</li>
<?php endif;?>
<?php
$pages_Num= ($this->getTotalNum()%$this->getLimit())?(($this->getTotalNum()/$this->getLimit())+1):$this->getTotalNum()/$this->getLimit();
for($_page=1;$_page<=$pages_Num;$_page++){
if($this->getCurrentPage()==$_page) echo '<li class="current"><a class="current" href="'.$url.'page/'.$_page.'">'.$_page.'</a></li>';
else echo '<li>'.$_page.'</li>';
}
?>
<?php if (($this->getCurrentPage()+1)<$pages_Num): ?>
<li><a class="next<?php if(!$this->getAnchorTextForNext()): ?> i-next<?php endif; ?>"
href="<?php echo $url.'p='.($this->getCurrentPage()+1);?>" title="<?php echo $this->__('Next') ?>">
<?php if(!$this->getAnchorTextForNext()): ?>
<img src="<?php echo $this->getSkinUrl('images/pager_arrow_right.png') ?>" alt="<?php echo $this->__('Next') ?>" class="v-middle" />
<?php else: ?>
<?php echo $this->getAnchorTextForNext() ?>
<?php endif;?>
</a></li>
<?php endif;?>
</ol>
</div>
First, you need to create a custom router which will parse the requested URL.
The method match () of the router may be implemented with this piece of code like this:
public function match(Zend_Controller_Request_Http $request) {
$this->_beforeModuleMatch();
$url = $request->getRequestUri();
$suffix = Mage::getStoreConfig('catalog/seo/category_url_suffix');
$pagerUrlFormat = "\/page\/([0-9]+)";
if (preg_match('/' . $pagerUrlFormat . preg_quote($suffix, '/') . '/', $url, $match)) {
$url = str_replace($match[0], $suffix, $url);
$request->setRequestUri($url);
$path = $request->getPathInfo();
$path = str_replace($match[0], $suffix, $path);
$request->setPathInfo($path);
$request->setParam('p', $match[1]);
return true;
}
return false;
}
This code will generate a URL of such a kind: http://example.com/category/p/2.html
NB! Please note that the code above hasn't been tested. It's just a simplified version of the more advanced code that is used in our SEO module (SEO Suite Ultimate)
Here is the description of the feature that does what you actually need:
Ability to create a pager URL format for paginated pages Examples:
-page[page_number] will transform URL into /mobile-phones-page2.html /p/[page_number] will transform URL into /mobile-phones/p/2.html

Magento FancyBox confirmation dialogue

When I add an item to cart from the search results page in Magento it does not display the FancyBox confirmation box. The item DOES get added to the cart though. On the main category page it displays the confirmation box OK upon adding an item to cart.
The JS & CSS for FancyBox are included in both the category and search results pages, I have manually checked in the source.
If I replace
jQuery.fancybox.close();
with
alert(data.message);
then it displays a standard Javascript alert saying it's added to cart and shows the correct item details. The FancyBox is preferred though with the product image.
Here's the code for app\design\frontend\custom_package\default\template\catalog\product\list.phtml, the Javascript is at the end. Thanks for taking a look :D
<?php
$_productCollection=$this->getLoadedProductCollection();
$columnCount = themeOptions('column_count');
$this->setColumnCount($columnCount);
$_helper = $this->helper('catalog/output');
?>
<?php if(!$_productCollection->count()): ?>
<p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p>
<?php else: ?>
<div class="category-products">
<?php echo $this->getToolbarHtml() ?>
<?php // List mode ?>
<?php if($this->getMode()!='grid'): ?>
<?php $_iterator = 0; ?>
<?php $imgSize = 192; ?>
<ol class="products-list" id="products-list">
<?php foreach ($_productCollection as $_product): ?>
<li class="item<?php if( ++$_iterator == sizeof($_productCollection) ): ?> last<?php endif; ?>">
<?php include('view/labels.phtml') ?>
<?php $mainImg = $this->helper('catalog/image')->init($_product, 'small_image')->resize($imgSize); ?>
<?php $backImg = $this->getLayout()->createBlock("ajax/listmedia")->setTemplate("catalog/product/list/media.phtml")->setData('size', $imgSize)->setData('product', $_product)->toHtml(); ?>
<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'): ?><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'): ?>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>
<?php // Product description ?>
<div class="product-shop">
<div class="f-fix">
<?php $_productNameStripped = $this->stripTags($_product->getName(), null, true); ?>
<h2 class="product-name"><?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?></h2>
<?php if($_product->getRatingSummary()): ?>
<?php echo $this->getReviewsSummaryHtml($_product) ?>
<?php endif; ?>
<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 id='productname<?php echo $_product->getId()?>' style='display:none'><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></div>
<div class="desc std">
<?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?>
<?php echo $this->__('Learn More') ?>
</div>
<?php if(themeOptions('addto')): ?>
<ul class="add-to-links">
<?php if ($this->helper('wishlist')->isAllow()) : ?>
<li><?php echo $this->__('Add to Wishlist') ?></li>
<?php endif; ?>
<?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
<li><span class="separator">|</span> <?php echo $this->__('Add to Compare') ?></li>
<?php endif; ?>
</ul>
<?php endif; ?>
</div>
<div style="clear: both;"></div>
</div>
<div class="addtocont">
<?php echo $this->getPriceHtml($_product, true) ?>
<?php if($_product->isSaleable()): ?>
<?php if ( !($_product->getTypeInstance(true)->hasRequiredOptions($_product) || $_product->isGrouped()) ) { ?>
<p><button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocationAjax('<?php echo $this->getAddToCartUrl($_product) ?>','<?php echo $_product->getId()?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button></p>
<?php } else { ?>
<button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="showOptions('<?php echo $_product->getId()?>')"><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>
</li>
<?php endforeach; ?>
</ol>
<script type="text/javascript">decorateList('products-list', 'none-recursive')</script>
<?php else: ?>
<?php // Grid Mode ?>
<?php $_collectionSize = $_productCollection->count() ?>
<?php
$_columnCount = $this->getColumnCount();
if($_columnCount == 4){
$imgSize = 180;
}elseif($_columnCount == 3){
$imgSize = 245;
}
?>
<?php $i=0; foreach ($_productCollection as $_product): ?>
<?php if ($i++%$_columnCount==0): ?>
<ul class="products-grid columns<?php echo $_columnCount ?>">
<?php endif ?>
<li 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 $backImg = $this->getLayout()->createBlock("ajax/listmedia")->setTemplate("catalog/product/list/media.phtml")->setData('size', $imgSize)->setData('product', $_product)->toHtml(); ?>
<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'): ?><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'): ?>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"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></h2>
<div id='productname<?php echo $_product->getId()?>' style='display:none'><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></div>
<?php echo $this->getPriceHtml($_product, true) ?>
<?php if($_product->isSaleable()): ?>
<?php if ( !($_product->getTypeInstance(true)->hasRequiredOptions($_product) || $_product->isGrouped()) ) { ?>
<p><button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocationAjax('<?php echo $this->getAddToCartUrl($_product) ?>','<?php echo $_product->getId()?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button></p>
<?php } else { ?>
<button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="showOptions('<?php echo $_product->getId()?>')"><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><?php echo $this->__('Add to Wishlist') ?></li>
<?php endif; ?>
<?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
<li><span class="separator">|</span> <?php echo $this->__('Add to Compare') ?></li>
<?php endif; ?>
</ul>
<?php endif; ?>
<div class="clear"></div>
</div>
</li>
<?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?>
</ul>
<?php endif ?>
<?php endforeach ?>
<script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
<?php endif; ?>
<script type="text/javascript">
jQuery.noConflict();
jQuery('.fancybox').fancybox({
hideOnContentClick : true,
width: 582,
autoDimensions: true,
type : 'iframe',
showTitle: false,
scrolling: 'no',
onComplete: function(){ //Resize the iframe to correct size
jQuery('#fancybox-frame').load(function() { // wait for frame to load and then gets it's height
jQuery('#fancybox-content').height(jQuery(this).contents().find('body').height()+30);
jQuery.fancybox.resize();
});
}
});
function showOptions(id){
jQuery('#fancybox'+id).trigger('click');
}
function setAjaxData(data,iframe){
if(data.status == 'ERROR'){
alert(data.message);
}else{
if(jQuery('.block-cart')){
jQuery('.block-cart').replaceWith(data.sidebar);
}
if(jQuery('.header .block-cart-header')){
jQuery('.header .block-cart-header').replaceWith(data.topcart);
}
jQuery.fancybox.close();
}
}
function setLocationAjax(url,id){
url += 'isAjax/1';
url = url.replace("checkout/cart","ajax/index");
var msgHtml;
var productImg = jQuery('#productimgover' + id).html();
var windowOver = jQuery('#addedoverlay');
var windowBox = jQuery('#added');
var titleForBox = jQuery('#productname' + id).text();
windowOver.show();
windowBox.show().css({
backgroundImage: "url('<?php echo $this->getSkinUrl('images/loading.gif')?>')"
});
try {
jQuery.ajax( {
url : url,
dataType : 'json',
success : function(data) {
if(data.status == 'SUCCESS'){
msgHtml = '<div class="added-content"><div style="float:left;">' + productImg + '</div><em>' + titleForBox + '</em> <?php echo $this->__('was successfully added to your shopping cart.') ?><div style="clear:both;"></div><a id="hidewindow" href="javascript:void(0);"><?php echo $this->__('Continue shopping') ?></a> <?php echo $this->__('View cart & checkout') ?></div>';
}else{
msgHtml = '<div class="added-content"><p class="error-msg" style="margin-bottom:15px;">' + data.message + '</p><a id="hidewindow" href="javascript:void(0);"><?php echo $this->__('Continue shopping') ?></a> <?php echo $this->__('View cart & checkout') ?></div>';
}
setAjaxData(data,false);
windowBox.css({
backgroundImage: 'none'
}).html(msgHtml);
windowOver.one('click',function(){
hidewindow(windowBox,windowOver);
});
jQuery('#hidewindow').click(function(){
hidewindow(windowBox,windowOver);
});
}
});
} catch (e) {
}
}
function hidewindow(windowBox,windowOver){
windowOver.fadeOut(400);
windowBox.fadeOut(400).html('');
}
function hideImage(img){
jQuery(img).animate({
'opacity' : 0
},150);
}
function showImage(img){
jQuery(img).animate({
'opacity' : 1
},150);
}
</script>
<div class="toolbar-bottom">
<?php echo $this->getToolbarHtml() ?>
</div>
</div>
<?php endif; ?>
You seem to have a lot of code, that i'm not 100% sure what purpose they serve. Take a look # fancybox options/apis
Try this
success : function(data) {
if(data.status == 'SUCCESS'){
msgHtml = '<div class="added-content"><div style="float:left;">' + productImg + '</div><em>' + titleForBox + '</em> <?php echo $this->__('was successfully added to your shopping cart.') ?><div style="clear:both;"></div><a id="hidewindow" href="javascript:void(0);"><?php echo $this->__('Continue shopping') ?></a> <?php echo $this->__('View cart & checkout') ?></div>';
}else{
msgHtml = '<div class="added-content"><p class="error-msg" style="margin-bottom:15px;">' + data.message + '</p><a id="hidewindow" href="javascript:void(0);"><?php echo $this->__('Continue shopping') ?></a> <?php echo $this->__('View cart & checkout') ?></div>';
}
jQuery.fancybox({
content: msgHtml,
modal: true
});
}
See How to programatically trigger fancybox with an inline div?
Also in function setAjaxData(data,iframe) on success you seem to be closing the fancybox using jQuery.fancybox.close();
Change this
<a id="hidewindow" href="javascript:void(0);">?php echo $this->__('Continue shopping') ?>...
to (something like)
<a href="#" onclick="jQuery.fancybox.close();">...

Magento new product widget image resize

I'm running magento with a custom template. I have been trying for the past week to enlarge the image size of the new product widget (whether grid or list) to be 232px width and 280px length. I have successfully located the new_grid.phtml and new_list.phtml files at
app/design/frontend/base/default/template/catalog/product/widget/new/content.
I have also changed the images sizes from I think 85px width and 85px length to my desired 232px width by 280px length. Instead of enlarging the frame of the image and the image itself, the image seems to be enlarged but the frame remains the same at 85px 85px. So then you are only able to see a small portion of the image within the 85px by 85px image frame.
The widget I'm talking about is the new product widget that you can insert from the CMS pages. I'm running magento community edition 1.7
Here's the code snippet for the new_grid.phtml. Any help is appreciated. Thanks
<div class="widget-products">
<?php $_columnCount = $this->getColumnCount(); ?>
<?php $i=0; foreach ($_products->getItems() as $_product): ?>
<?php if ($i++%$_columnCount==0): ?>
<ul class="products-grid">
<?php endif ?>
<li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(232,280) ?>" width="232" height="280" alt="<?php echo $this->stripTags($_product->getName(), null, true) ?>" />
<h3 class="product-name"><?php echo $this->helper('catalog/output')->productAttribute($_product, $_product->getName() , 'name') ?></h3>
<?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
<?php echo $this->getPriceHtml($_product, true, '-widget-new-grid') ?>
<div class="actions">
<?php if ($_product->isSaleable()): ?>
<button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
<?php else: ?>
<p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
<?php endif; ?>
<ul class="add-to-links">
<?php if ($this->helper('wishlist')->isAllow()) : ?>
<li><?php echo $this->__('Add to Wishlist') ?></li>
<?php endif; ?>
<?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
<li><span class="separator">|</span> <?php echo $this->__('Add to Compare') ?></li>
<?php endif; ?>
</ul>
</div>
</li>
<?php if ($i%$_columnCount==0 || $i==count($_products)): ?>
</ul>
<?php endif ?>
<?php endforeach; ?>
This is almost certainly a css issue.
You seem to be correctly resizing the image here:
<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(232,280) ?>
To ensure that your new templates are getting processed the layout, you can enable template hints in system/configuration/developer tab.
Assuming you've got that right, its quite likely getting reset to 85px in the css.
from widgets.css
.widget-new-products .products-grid .product-image,
.widget-new-products .products-list .product-image { width:85px; height:85px; }
I highly recommend poking around in your favorite browser's inspection tool to figure out what rule exactly is overriding your server side change.
cheers
For anyone who comes across this like I did...
Mine was corrected by changing the grid list in new.phtml:
<ul class="products-grid">
to:
<ul class="products-grid products-grid--max-<?php echo $_columnCount; ?>-col">
You Can Use CSS For Image To set Height And Width TO your Desired Values, no need to update templates like
<Your Image class/id>{
width:50%;
max-width:100%;
}
2) Or You Can Use js as
jQuery("document").ready(function() {
jQuery(".product-image img").attr({ width: "100%", height: "auto" });
});

Get sample URL for downloadable product in Magento

I'm trying to get sample file url for a downloadable product in my cross sell block on a product page.
The contents of my 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; ?>
You can try this :
$_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());
}
I hope this will work for you
You can also get sample data array using
<?php $sampleColl = Mage_Downloadable_Block_Catalog_Product_Samples::getSamples($_product);
foreach ($sampleColl as $_sample){
echo "<pre>";
print_r($_sample);
}
?>
I hope this will help you

Magento Ecommerce - How to call and display a product's details into a CMS page?

I would like to be able to insert and display a product the same way it is displayed in the product page, but into a CMS page (with attributes, prices, order button, etc...)
I've succeeded in creating a single page by inserting copied parts of the source code of a product page but this is quite a lenghty and time consuming process considering that I'm planning to have quite a few pages done.
Therefore I would like to be able to call the product details into a CMS page.
I thought I could use the view.phtml and insert it into the desired CMS page but I couldn't figure out how to define the product_id either...
Thank you all in advance for your comments
Hmm, CMS Macro like this:
{{block type="catalog/product" template="catalog/product/line-item.phtml" sku_id="CI 101"}}
Referencing template catalog/product/line-item.phtml:
<?php //Template_Name/catalog/product/line-item.phtml
//{{block type="catalog/product" template="catalog/product/line-item.phtml" sku_id="CI 100"}}
//Feed template SKU for product listing
?>
<?php $_product = Mage::getModel('catalog/product')->loadByAttribute('sku',$this->getData('sku_id')); ?>
<?php /* get special freight messages from custom variables */
$freightfree = Mage::getModel('core/variable')->loadByCode('free_freight_text')->getValue('plain');
$hazmat = Mage::getModel('core/variable')->loadByCode('hazmat_text')->getValue('plain');
$ormd = Mage::getModel('core/variable')->loadByCode('ormd_text')->getValue('plain');
?>
<!-- <div class="single-product"> -->
<div class="listing-type-list catalog-listing">
<div class="listing-item last">
<?php $specialshipping = $_product->getAttributeText('special_shipping_group') ?>
<?php // Product Image ?>
<div class="product-image">
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getSmallImageLabel()) ?>">
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135, 135); ?>" width="135" height="135" alt="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" />
</a>
</div>
<?php // Product description ?id= echo $_product->getId();?>
<div class="product-shop">
<h2><?php echo $this->htmlEscape($_product->getName())?></h5>
<?php if($_product->getRatingSummary()): ?>
<?php echo $this->getReviewsSummaryHtml($_product) ?>
<?php endif; ?>
<?php echo $this->getPriceHtml($_product, true) ?>
<?php if(!$_product->getNotforsale()): ?>
<?php if(!$_product->getReplace_add_button()): ?>
<?php if($_product->isGrouped()): ?>
<button class="form-button" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><?php echo $this->__('View Selection') ?></span></button>
<?php elseif($_product->getHasOptions()): ?>
<button class="form-button" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><?php echo $this->__('View Options') ?></span></button>
<?php else: ?>
<button class="form-button" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><?php echo $this->__('Add to Cart') ?></span></button>
<?php endif; ?>
<?php else: ?>
<button class="form-button" onclick="setLocation('<?php echo $_product->getProductUrl() ?>')"><span><?php echo $_product->getAttributeText('replace_add_button') ?></span></button>
<?php endif; ?>
<?php endif; ?>
<div class="clear"></div>
<?php /* display special freight messages from custom variables */ ?>
<?php if($specialshipping == "Free Ground" || $specialshipping == "Free Gnd ORMD"): ?>
<?php echo '<span class="regular-price"><span class="freightfree">' . $freightfree . '</span></span>' ?>
<?php endif; ?>
<?php if($specialshipping == "ORM-D"): ?>
<?php echo '<span class="freightfree">' . $ormd . '</span>' ?>
<?php elseif($specialshipping == "Free Gnd ORMD"): ?>
<?php echo '<br><span class="freightfree">' . $ormd . '</span>' ?>
<?php elseif($specialshipping == "HazMat"): ?>
<?php echo '<span class="freightfree">' . $hazmat . '</span>' ?>
<?php endif; ?>
<div class="description">
<?php echo nl2br($_product->getShortDescription()) ?>
<small><?php echo $this->__('Learn More') ?></small>
</div>
<p class="add-to">
Brand Name: <?php echo $_product->getBrand() ?>
</p>
</div>
</div>
</div>
Be aware this is pulling in several custom attributes and variables you probably won't find on your system. The most important is the CMS Macro
{{block type="catalog/product" template="catalog/product/line-item.phtml" sku_id="CI 101"}}
and this line:
<?php $_product = Mage::getModel('catalog/product')->loadByAttribute('sku',$this->getData('sku_id')); ?>
Use Macro as many times on the CMS page as you want.

Resources