cancel
Showing results for 
Search instead for 
Did you mean: 

report.CRITICAL: Notice: Undefined index

SOLVED

report.CRITICAL: Notice: Undefined index

app\code\Zero\Storelocator\Rewrite\Amasty\Storelocator\Location.php

 

public function getFrontendData(): array
    {  

        $storeHours = $this->getDataByKey('attributes'); 

        $result = [
            'id' => (int)$this->getDataByKey('id'),
            'lat' => $this->getDataByKey('lat'),
            'lng' => $this->getDataByKey('lng'),
            'zip' => $this->getDataByKey('zip'),
            'address'=>$this->getDataByKey('address'),
            'state'=>$this->_storelocHelper->getRegionDataByName($this->getDataByKey('state')),
            'popup_html' => $this->getDataByKey('popup_html'),
            'phone'=>$this->getDataByKey('phone'),
            'distance'=>round($this->getDataByKey('distance'),1),
            'name' =>$this->getDataByKey('name'),
            'city' =>$this->getDataByKey('city'),
            'url_key' =>$this->getDataByKey('url_key')
             'store_hours_weekdays' => $storeHours['store_hours'] ['option_title']['0'],
             'store_hours_weekend_days' => $storeHours['store_hours'] ['option_title']['1']
        ];

        if ($this->getDataByKey('marker_url')) {
            $result['marker_url'] = $this->getDataByKey('marker_url');
        }

        return $result;
    }

How to solve the report.CRITICAL: Notice: Undefined index: store_hours in /app/app/code/Zero/Storelocator/Rewrite/Amasty/Storelocator/Location.php

1 ACCEPTED SOLUTION

Accepted Solutions

Re: report.CRITICAL: Notice: Undefined index

Hi @Aveeva 

 

The issue is that the key store_hours  is not present in the $storeHours array.

Put a check using 

if(array_key_exists('store_hours',$storeHours )) {
    $var1 => $storeHours['store_hours'] ['option_title']['0'],
    $var2 => $storeHours['store_hours'] ['option_title']['1']
}

then after pass the values to result array.

---
Problem Solved Click Accept as Solution!:Magento Community India Forum

View solution in original post

1 REPLY 1

Re: report.CRITICAL: Notice: Undefined index

Hi @Aveeva 

 

The issue is that the key store_hours  is not present in the $storeHours array.

Put a check using 

if(array_key_exists('store_hours',$storeHours )) {
    $var1 => $storeHours['store_hours'] ['option_title']['0'],
    $var2 => $storeHours['store_hours'] ['option_title']['1']
}

then after pass the values to result array.

---
Problem Solved Click Accept as Solution!:Magento Community India Forum