0

I am getting a division by zero warning in my log file from this snippet of text in my Magento theme:

<li class="item<?php if(($i-0)%$_columnCount==0): ?>  last1<?php elseif($i%$_columnCount==0): ?> last1<?php endif; ?>">

Can someone tell me what is wrong? Thank you!


Here is the whole page of code:

<?php
$_item = $this->getItem();
$isVisibleProduct = $_item->getProduct()->isVisibleInSiteVisibility();
$canApplyMsrp = Mage::helper('catalog')->canApplyMsrp($_item->getProduct(), Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type::TYPE_BEFORE_ORDER_CONFIRM
);
?>
<?php if ($_columnCount) { ?>
<li class="item<?php if(($i-0)%$_columnCount==0): ?> last1<?php 
elseif($i%$_columnCount==0): ?> last1<?php endif; ?>">
<?php } ?>
<div class="item-inner">
<?php if ($this->hasProductUrl()): ?>
    <a href="<?php echo $this->getProductUrl()?>" title="<?php echo $this->htmlEscape($this->getProductName()) ?>" class="product-image"><img src="<?php echo $this->getProductThumbnail()->resize(70, 85)->setWatermarkSize('30x10'); ?>" width="70" height="85" alt="<?php echo $this->htmlEscape($this->getProductName()) ?>" /></a>
<?php else: ?>
    <span class="product-image"><img src="<?php echo $this->getProductThumbnail()->resize(70, 85)->setWatermarkSize('30x10'); ?>" width="70" height="85" alt="<?php echo $this->htmlEscape($this->getProductName()) ?>" /></span>
<?php endif; ?>
<div class="product-details">

 <div class="access">
    <a href="<?php echo $this->getDeleteUrl() ?>" title="<?php echo $this->__('Remove This Item') ?>" onclick="return confirm('<?php echo $this->__('Are you sure you would like to remove this item from the shopping cart?') ?>');" class="btn-remove1"><?php echo $this->__('Remove') ?></a>
    <?php if ($isVisibleProduct): ?>
    <a href="<?php echo $this->getConfigureUrl() ?>" title="<?php echo $this->__('Edit item') ?>" class="btn-edit"><i class="icon-pencil"></i><span class="hidden"><?php echo $this->__('Edit item')?></span></a>
    <?php endif ?>
 </div> <!--access-->

<strong><?php echo $this->getQty() ?></strong> x

<?php if ($canApplyMsrp): ?>

    <span class="map-cart-sidebar-item"><?php echo $this->__('See price before order confirmation.'); ?></span>

<?php else: ?>

<?php if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
    <?php if ($this->helper('tax')->displayCartBothPrices()): ?>
        <?php echo $this->__('Excl. Tax'); ?>:
    <?php endif; ?>
    <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?>
        <?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?>
    <?php else: ?>
        <?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()) ?>
    <?php endif; ?>
    <?php if (Mage::helper('weee')->getApplied($_item)): ?>
        <br />
        <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales')): ?>
            <small>
            <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
                <span class="nobr"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount'],true,true); ?></span><br />
            <?php endforeach; ?>
            </small>
        <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales')): ?>
            <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
                <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></small></span><br />
            <?php endforeach; ?>
        <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales')): ?>
            <small>
            <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
                <span class="nobr"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></span><br />
            <?php endforeach; ?>
            </small>
        <?php endif; ?>
        <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales')): ?>
            <span class="nobr"><?php echo Mage::helper('weee')->__('Total'); ?>:<br /> <?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?></span>
        <?php endif; ?>
    <?php endif; ?>
<?php endif; ?>



<?php if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
    <?php $_incl = $this->helper('checkout')->getPriceInclTax($_item); ?>
    <?php if ($this->helper('tax')->displayCartBothPrices()): ?>
        <br /><?php echo $this->__('Incl. Tax'); ?>:
    <?php endif; ?>
    <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales')): ?>
        <?php echo $this->helper('checkout')->formatPrice($_incl+$_item->getWeeeTaxAppliedAmount()); ?>
    <?php else: ?>
        <?php echo $this->helper('checkout')->formatPrice($_incl-$_item->getWeeeTaxDisposition()) ?>
    <?php endif; ?>
    <?php if (Mage::helper('weee')->getApplied($_item)): ?>
        <br />
        <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales')): ?>
            <small>
            <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
                <span class="nobr"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount'],true,true); ?></span><br />
            <?php endforeach; ?>
            </small>
        <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales')): ?>
            <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
                <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></small></span><br />
            <?php endforeach; ?>
        <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales')): ?>
            <small>
            <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
                <span class="nobr"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></span><br />
            <?php endforeach; ?>
            </small>
        <?php endif; ?>
        <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales')): ?>
            <span class="nobr"><?php echo Mage::helper('weee')->__('Total incl. tax'); ?>:<br /> <?php echo $this->helper('checkout')->formatPrice($_incl+$_item->getWeeeTaxAppliedAmount()); ?></span>
        <?php endif; ?>
    <?php endif; ?>
<?php endif; ?>

<?php endif; //Can apply MSRP ?>

    <?php if ($_options = $this->getOptionList()):?>
    <div class="truncated">
      <div class="truncated_full_value">
        <dl class="item-options">
            <?php foreach ($_options as $_option) : ?>
            <dt><?php echo $this->htmlEscape($_option['label']) ?></dt>
            <dd>
                <?php if (is_array($_option['value'])): ?>
                <?php echo nl2br(implode("\n", $_option['value'])) ?>
                <?php else: ?>
                <?php echo $_option['value'] ?>
                <?php endif; ?>
            </dd>
            <?php endforeach; ?>
        </dl>
      </div>

    </div>
    <?php endif; ?>

 <p class="product-name"><?php if ($this->hasProductUrl()): ?><a href="<?php echo $this->getProductUrl() ?>"><?php endif; ?><?php $prod_name= $this->htmlEscape($this->getProductName()); if(strlen($prod_name) > 35) { echo substr($prod_name,0,35)."..."; } else { echo $prod_name; } ?><?php if ($this->hasProductUrl()): ?></a><?php endif; ?></p>

</div> <!--product-details-bottoms-->

0

Try this.

    <?php if ($_columnCount) { ?>
    <li class="item<?php if(($i-0)%$_columnCount==0): ?>  last1<?php elseif($i%$_columnCount==0): ?> last1<?php endif; ?>">
    <?php } else { ?>
    <li class="item">
<?php } ?>
  • So it works, but for some reason I can't scroll the page with my mouse roller. My mouse scroll works when I disable it. – LNGLA Apr 19 '17 at 6:18
  • Try the updated answer – Mike Apr 19 '17 at 6:37
0

Your variable $_columnCount is zero at some point and modulo (the % operator) on 0 is illegal behaviour as you're essentially asking for the remainder of a zero divison.

  • Thanks for the response. Would I have to adjust any of the numbers to make this work and what would I change them too? – LNGLA Apr 19 '17 at 4:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.