0

Today When I run my store it says following error message..

Notice: Undefined offset: 4 in /var/www/vhosts/myhost.com/Myproject/app/design/frontend/tapestore/default/template/catalog/product/featured_list.phtml on line 171

The following code is found in that place...

166 <?php if ($desct) { ?>
167     <div class="product-grid-description">
168        <ul>
169        <?php
170             $i = 0;
171             while ($desctexpl[$i] && $i < 4) {
172                   echo "<li>" . Mage::helper('core/string')->truncate($desctexpl[$i], '40') . "</li>";
173                   $i++;
174             }
175         ?>
176         </ul>
177     </div>
178 <?php } ?>

Could any one suggest what might be the problem ? and how to solve it ?

1
  • Please share all code of featured_list.phtml
    – Arunendra
    Mar 22, 2016 at 6:42

1 Answer 1

1

Use below code:

166 <?php if ($desct) { ?>
167     <div class="product-grid-description">
168        <ul>
169        <?php
170             $i = 0;                   
171               while (array_key_exists($i,$desctexpl) && $i < 4) {
172                   echo "<li>" . Mage::helper('core/string')->truncate($desctexpl[$i], '40') . "</li>";
173                   $i++;
174               }                   
175         ?>
176         </ul>
177     </div>
178 <?php } ?>
2
  • it worked fine @PrashantValanda. Can I ask why did this happen ? Because it was working before . Mar 22, 2016 at 7:05
  • May be there is no value for $desctexpl[$i] where $i = 4. So it will trigger notice. Mar 22, 2016 at 7:14

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.