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
Solved! Go to Solution.
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.
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.