0

I am getting below log errors in custom module

a.Notice: Undefined offset: 2 in line if($commodity_name[2] != "") {

b.Notice: Undefined offset: 3 & Notice: Uninitialized string offset: 2 in line if($commodity_name[3] != "") {

c.Notice: Undefined offset: 1 & Notice: Uninitialized string offset: 3 in if($commodity_name[1] != "") {

<?php
    if($CommodityDetail1 == "") {
        if($commodity_name[1] != "") {
            $CommodityDetail1 = $commodity_name[1];
            $Commoditypid1 = $commodity_id_change[1];
        }
    }
?>

<label>Cmdty Detail 1</label><input class="removenamebypid_<?php echo $Commoditypid1 ?>" style="width:100px" type="text" id="service_cmdtydetail1" name="service_cmdtydetail1" value="product1" maxlength="3000" />
<input type="hidden" value="product" id="addnamebypid_<?php echo $Commoditypid1 ?>" />

<?php
    if($CommodityDetail2 == "") {
        if($commodity_name[2] != "") {
            $CommodityDetail2 = $commodity_name[2];
            $Commoditypid2 = $commodity_id_change[2];
        }
    }
?>
<label>Cmdty Detail 2</label><input class="removenamebypid_<?php echo $Commoditypid2 ?>" style="width:100px" type="text" id="service_cmdtydetail2" name="service_cmdtydetail2" value="product2" maxlength="3000"/>
<input type="hidden" value="<?php echo $CommodityDetail2; ?>" id="addnamebypid_<?php echo $Commoditypid2 ?>" />

<?php
    if($CommodityDetail3 == "") {
        if($commodity_name[3] != "") {
            $CommodityDetail3 = $commodity_name[3];
            $Commoditypid3 = $commodity_id_change[3];
        }
    }
?>
1
0

Below code solved issue :

if( !isset($commodity_name[2]) ) $commodity_name[2] = '' ;
if( !isset($commodity_name[1]) ) $commodity_name[1] = '' ;
if( !isset($commodity_name[3]) ) $commodity_name[3] = '' ;
1
  • if anyone have better solution, please post here...... – Baby in Magento Aug 23 '17 at 12:46

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.