0

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 Answer 1

1

The error means that there is no $result['store_hours'] in your code. You need to update the key name to match your array.

5
  • How to update my code? Can you pls guide me.
    – zus
    Apr 22, 2021 at 3:20
  • FYI In xampp localhost everything working good, when I try on my live website I am getting this error.
    – zus
    Apr 22, 2021 at 3:21
  • In your template file you are calling $result['store_hours'] somewhere, but the code your posted doesn't have 'store_hours'. Try var_dump($result) in your template to see what the array looks like and find the data you need and update the call.
    – bernieu2
    Apr 22, 2021 at 3:24
  • I think their should be , after 'url_key' =>$this->getDataByKey('url_key')
    – Ankit
    Apr 22, 2021 at 6:08
  • check this please magento.stackexchange.com/a/368409/55221 Jul 18, 2023 at 5:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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