微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ContextErrorException注意:未定义的偏移量:1 prestashop 1.7

如何解决ContextErrorException注意:未定义的偏移量:1 prestashop 1.7

我有一个在prestashop 1.5上可以完美运行的交付模块,当迁移到prestashop 1.7时,我遇到以下问题,我是prestashop的新手,但我认为问题来自此行“ $ horaire = explode('|' ,$ select_day [1]);“。

 public function hookdisplayCarrierExtraContent($params)
    {
          
        $jours = array();
        $stores= Store::getStores(Context::getContext()->language->id);
        $stores_datas=array(); 
         
        for($i = 0; $i<count($stores); $i++) 
        {
            $stores[$i]['name']    = str_replace(["'",'"'],"&#39;",$stores[$i]['name']);
            $stores[$i]['address1']= str_replace("'",$stores[$i]['address1']);
            $stores[$i]['address2']= str_replace("'",$stores[$i]['address2']);
            $stores[$i]['hours']    = str_replace(["'","[","]","",$stores[$i]['hours']);

            $stores[$i]['hours'] = explode(',',$stores[$i]['hours'] );         

            $stores[$i]['note']    = str_replace("'",$stores[$i]['note']);
            $stores_datas[$stores[$i]['id_store']] = $stores[$i];
            $stores_datas[$stores[$i]['id_store']]['has_store_picture'] = file_exists(_PS_STORE_IMG_DIR_.(int)($stores[$i]['id_store']).'.jpg');
            
            $stores_datas[$stores[$i]['id_store']]['hours'] = $stores[$i]['hours'];  
            $stores_datas[$stores[$i]['id_store']]['working_days_hours']=$this->_getStoreWorkingHours($stores[$i]);
            /*dump($this->_getStoreWorkingHours($stores[$i]));die;*/
            if (is_array($this->_getStoreWorkingHours($stores[$i])) || is_object($this->_getStoreWorkingHours($stores[$i])))
            {
            foreach ($this->_getStoreWorkingHours($stores[$i]) as $jour) 
            {
                $jours[$jour['id']] = $jour['day'];
            }
            }
        }
        //extract selecte day from the selected address.
        // the date and hours are stored in "other" field of Address as a string.
        $cart=$params['cart'];
        ksort($jours);
        // Get the selected adress form cart.
   
        $selected_adress=new Address($cart->id_address_delivery);
        //extract day.
        $select_day= explode(')',$selected_adress->other);
        $horaire=  explode('|',$select_day[1]); ------preblem is here 
        $jour=$horaire[0];
        $this->context->smarty->assign(array(
            'stores' => json_encode($stores_datas),'carrier' => (int)Configuration::get('AVAILABLE_STORE_DELIVERY_CARRIER'),'map' => Configuration::get('AVAILABLE_STORE_DELIVERY_disPLAY_MAP'),'address_id' =>$selected_adress->alias,'jour_id'=> $this->getDateWeek($horaire[0]),'jours' => $jours,'json'=> serialize($stores_datas) 

        ));
     
        if(Configuration::get('AVAILABLE_STORE_DELIVERY_disPLAY_MAP') == true) 
        {
            $this->context->smarty->assign('heightMap',Configuration::get('AVAILABLE_STORE_DELIVERY_HEIGHT_MAP'));
            $this->context->smarty->assign('widthMap',Configuration::get('AVAILABLE_STORE_DELIVERY_WIDTH_MAP'));
            $this->context->smarty->assign('defaultLat',(float)Configuration::get('PS_STORES_CENTER_LAT'));
            $this->context->smarty->assign('defaultLong',(float)Configuration::get('PS_STORES_CENTER_LONG'));
            $this->context->smarty->assign('logo_store',Configuration::get('PS_STORES_ICON'));
            $this->context->smarty->assign('hasstoreIcon',file_exists(_PS_IMG_DIR_.Configuration::get('PS_STORES_ICON')));
        }


        return $this->display(__FILE__,'availablestoredelivery.tpl');
    }

解决方法

您的脚本试图通过首先用)符号然后通过管道符号|来展开地址数据库对象的“其他”字符串字段来获取数据。无需进行任何一致性检查,因此请查看您的客户地址“其他”字段内容,也许它们在版本升级期间未正确迁移。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?