Hey guys…
I need your help. I´m getting some issues in system.log
ERR (3): Warning: Division by zero in /www/…/…/…/app/design/frontend/default/jm_casual/template/catalog/product/list.phtml on line 230
ERR (3): Notice: Undefined variable: labeltype in /www/…/…/…/app/design/frontend/default/jm_casual/template/catalog/product/list.phtml on line 241
ERR (3): Notice: Undefined variable: numberchar in /www/…/…/…/app/design/frontend/default/jm_casual/template/catalog/product/list.phtml on line 279
ERR (3): Notice: Undefined variable: config in /www/…/…/…/app/design/frontend/default/jm_casual/template/catalog/product/list.phtml on line 230
Here is my code of the list.phtml ( I have put some new line inside)
Start your code here<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE_AFL.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magentocommerce.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category design
* @package base_default
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
?>
<?php
/**
* Product list template
*
* @see Mage_Catalog_Block_Product_List
*/
?>
<div class="category-page">
<?php
$_productCollection=$this->getLoadedProductCollection();
$_helper = $this->helper('catalog/output');
$baseconfig = Mage::helper("jmbasetheme")->getactiveprofile();
if ($baseconfig) :
$productlistimagewidth = $baseconfig["productlistimagewidth"];
$productlistimageheight = $baseconfig["productlistimageheight"];
$productlistdeslenght = $baseconfig["productlistdeslenght"];
$productgridimageheight = $baseconfig["productgridimageheight"];
$productgridimagewidth = $baseconfig["productgridimagewidth"];
$showlabel = $baseconfig["showlabel"];
else :
$productlistimagewidth = 150;
$productlistimageheight = 225;
$productlistdeslenght = 0;
$productgridimageheight = 225;
$productgridimagewidth = 150;
$showlabel = 0;
endif;
?>
<?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; ?>
<ol class="products-list" id="products-list">
<?php
foreach ($_productCollection as $_product):
$product = Mage::getModel('catalog/product')->load($_product->getId());
$attribute = $product->getResource()->getAttribute('label');
if(is_object($attribute)){
$_options= $attribute->getSource()->getAllOptions(true, true);
foreach($_options as $option){
if ($option['value'] == $product->getData("label")){
$class = $option['label'];
}
}
$attdefaultvalue = $attribute->getDefaultValue();
$attributeValue = $product->getlabel();
$attributeValueName = Mage::getModel('catalog/product')->load($_product->getId())->getAttributeText('label');
if(strlen($attributeValue) && ($attdefaultvalue !== $attributeValue)) {
$labeltype = $class;
$labelname = $attributeValueName;
}
else {
$labeltype = "";
}
}
$hoverimage = Mage::getModel('catalog/product')->load($_product->getId())->getMediaGalleryImages()->getItemByColumnValue('label','hover');
if($hoverimage){
$hoverimage = $hoverimage->getUrl();
}
?>
<li class="item<?php if( ++$_iterator == sizeof($_productCollection) ): ?> last<?php endif; ?>">
<div class="inner">
<?php // Product Image ?>
<div class="product-image">
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" style="width: <?php echo $productgridimagewidth?>px; height: <?php echo $productgridimageheight; ?>px; overflow: hidden; float: left; ">
<?php if($hoverimage){ ?>
<img class="additional_img" src="<?php echo $hoverimage; ?>" width="<?php echo $productlistimagewidth; ?>" height="<?php echo $productlistimageheight; ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
<img id="product-collection-image-<?php echo $_product->getId(); ?>" class="regular_img" src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($productlistimagewidth,$productlistimageheight); ?>" width="<?php echo $productlistimagewidth; ?>" height="<?php echo $productlistimageheight; ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
<?php } else { ?>
<img id="product-collection-image-<?php echo $_product->getId(); ?>" class="regular_img1" src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($productlistimagewidth,$productlistimageheight); ?>" width="<?php echo $productlistimagewidth; ?>" height="<?php echo $productlistimageheight; ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
<?php }?>
</a>
<?php if ($labeltype && $showlabel): ?>
<span class="<?php echo $labeltype; ?>-label ico-label"><?php echo $labelname; ?></span>
<?php endif; ?>
</div>
<?php // Product description ?>
<div class="product-shop">
<?php $_productNameStripped = $this->stripTags($_product->getName(), null, true); ?>
<h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped; ?>"><?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?></a></h2>
<h4><?php echo $_helper->productAttribute($_product, $_product->getSub_name(), 'sub_name') ?></h4>
<?php
if ($this->getChild('name.after')) {
$_nameAfterChildren = $this->getChild('name.after')->getSortedChildren();
foreach ($_nameAfterChildren as $_nameAfterChildName) {
$_nameAfterChild = $this->getChild('name.after')->getChild($_nameAfterChildName);
$_nameAfterChild->setProduct($_product);
echo $_nameAfterChild->toHtml();
}
}
?>
<?php echo $this->getReviewsSummaryHtml($_product, true, true)?>
<?php echo $this->getPriceHtml($_product, true) ?>
<p>
<?php if($baseprice = Mage::helper('baseprice')->getBasePriceLabel($_product, true)): ?>
<div class="baseprice">(<?php echo $baseprice ?>)</div>
<?php endif; ?>
</p>
<div class="desc std">
<?php $sdesc = $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?>
<?php
if ($productlistdeslenght) :
echo substr(strip_tags($sdesc), 0, $productlistdeslenght).'...'.' <a href="'.$_product->getProductUrl().'" title="'.$_productNameStripped.'">More detail</a>';
else :
echo substr(strip_tags($sdesc), 0, 300).'...';
endif;
?>
</div>
<div class="actions">
<ul class="add-to-links">
<li class="addtocart">
<?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; ?>
</li>
<?php if ($this->helper('wishlist')->isAllow()) : ?>
<li class="wishlist">
<button class="button btn-wishlist" onclick="setLocation('<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>')">
<i class="icon-heart"></i>
</button>
</li>
<?php endif; ?>
<?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
<li class="compare">
<button class="button btn-compare" onclick="setLocation('<?php echo $_compareUrl ?>')">
<i class="icon-refresh"></i>
</button>
<a style="display:none" href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Compare') ?></a>
</li>
<?php endif; ?>
</ul>
</div>
</div>
</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(); ?>
<?php
if($baseconfig["productgridnumbercolumn"]) :
$_columnCount = $baseconfig["productgridnumbercolumn"];
endif;
?>
<ul class="products-grid products-grid-special">
<?php $i=0; foreach ($_productCollection as $_product):
$product = Mage::getModel('catalog/product')->load($_product->getId());
$attribute = $product->getResource()->getAttribute('label');
if(is_object($attribute)){
$_options= $attribute->getSource()->getAllOptions(true, true);
foreach($_options as $option){
if ($option['value'] == $product->getData("label")){
$class = $option['label'];
}
}
$attdefaultvalue = $attribute->getDefaultValue();
$attributeValue = $product->getlabel();
$attributeValueName = Mage::getModel('catalog/product')->load($_product->getId())->getAttributeText('label');
if(strlen($attributeValue) && ($attdefaultvalue !== $attributeValue)) {
$labeltype = $class;
$labelname = $attributeValueName;
}
else {
$labeltype = "";
}
}
$_rowCount = ceil($_collectionSize/$_columnCount);
if ($i%$_columnCount==0) : $j++; endif;
if ($i++%$_columnCount==0): $width = 100; endif;
if ($_columnCount):
$width = 100/$_columnCount;
$width = "style=\"width:{$width}%;\"";
endif;
$return = false;
$hoverimage = Mage::getModel('catalog/product')->load($_product->getId())->getMediaGalleryImages()->getItemByColumnValue('label','hover');
if($hoverimage){
$hoverimage = $hoverimage->getUrl();
}
?>
<li class="item <?php if ($j==$_rowCount) : echo "item-row-last"; endif; ?> <?php if(($i-1)%$config['perrow']==0): ?> first<?php elseif($i%$config['perrow']==0): ?> last<?php endif; ?>" <?php echo $width;?>>
<div class="inner">
<div class="product-image">
<a title="<?php echo $this->htmlEscape($_product->getName()) ?>" href="<?php echo $_product->getProductUrl() ?>" style="width: <?php echo $productgridimagewidth?>px; height: <?php echo $productgridimageheight; ?>px; overflow: hidden; ">
<?php if($hoverimage){ ?>
<img class="additional_img" src="<?php echo $hoverimage; ?>" width="<?php echo $productgridimagewidth; ?>" height="<?php echo $productgridimageheight; ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
<img id="product-collection-image-<?php echo $_product->getId(); ?>" class="regular_img" src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($productgridimagewidth,$productgridimageheight); ?>" width="<?php echo $productgridimagewidth; ?>" height="<?php echo $productgridimageheight; ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
<?php } else { ?>
<img id="product-collection-image-<?php echo $_product->getId(); ?>" class="regular_img1" src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($productgridimagewidth,$productgridimageheight); ?>" width="<?php echo $productgridimagewidth; ?>" height="<?php echo $productgridimageheight; ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
<?php }?>
</a>
<?php if ($labeltype && $showlabel): ?>
<span class="<?php echo $labeltype; ?>-label ico-label"><?php echo $labelname; ?></span>
<?php endif; ?>
<div class="actions">
<ul class="add-to-links">
<li class="button-cart">
<?php if($_product->isSaleable()){ ?>
<button class="form-button" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')">
<i class="icon-shopping-cart"></i> <?php echo $this->__('Add to cart');?>
</button>
<?php } else { ?>
<div class="out-of-stock"><i class="icon-off"></i> <?php echo $this->__('Out of stock');?></div>
<?php } ?>
</li>
<?php if ($this->helper('wishlist')->isAllow()) : ?>
<li class="wishlist"><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist"><i class="icon-heart"></i></a></li>
<?php endif; ?>
</ul>
</div>
</div>
<div class="product-information">
<h5>
<a title="<?php echo $this->htmlEscape($_product->getName()) ?>" href="<?php echo $_product->getProductUrl() ?>"><?php echo $_product->getName() ?></a>
</h5>
<?php
if ($this->getChild('name.after')) {
$_nameAfterChildren = $this->getChild('name.after')->getSortedChildren();
foreach ($_nameAfterChildren as $_nameAfterChildName) {
$_nameAfterChild = $this->getChild('name.after')->getChild($_nameAfterChildName);
$_nameAfterChild->setProduct($_product);
echo $_nameAfterChild->toHtml();
}
}
?>
<?php echo $this->getReviewsSummaryHtml($_product, true, true)?>
<?php echo $this->getPriceHtml($_product,true, '_jmproduct_' . rand()) ?>
<?php if($numberchar) : ?>
<p class="pdescription"><?php echo substr(nl2br(strlen($_product->getDescription()) > 10 ? $_product->getDescription() : $_product->getShortDescription()), 0, $numberchar).'...';?></p>
<?php endif; ?>
<p>
<?php if($baseprice = Mage::helper('baseprice')->getBasePriceLabel($_product, true)): ?>
<div class="baseprice">(<?php echo $baseprice ?>)</div>
<?php endif; ?>
</div>
</div>
</li>
<?php endforeach ?>
</ul>
<script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
<?php endif; ?>
</div>
<?php endif; ?>
<div class="toolbar-bottom">
<?php echo $this->getToolbarHtml() ?>
</div>
</div>
<?php
// Provides a block where additional page components may be attached, primarily good for in-page JavaScript
if ($this->getChild('after')) {
$_afterChildren = $this->getChild('after')->getSortedChildren();
foreach ($_afterChildren as $_afterChildName) {
$_afterChild = $this->getChild('after')->getChild($_afterChildName);
//set product collection on after blocks
$_afterChild->setProductCollection($_productCollection);
echo $_afterChild->toHtml();
}
}
?>