2016-06-29 3 views
1

Я использую версию prestashop 1.4.3. И я хочу получить данные пользователя в wordpress. Я пробовал под кодом без везения. Давая мне это Фатальная ошибка:Как получить доступ к функциям prestashop в wordpress

Class 'FrontController' not found in /opt/lampp/htdocs/domin.com/prestashop/init.php on line 28.

Вот мой сценарий:

$psabspath = ''; 
$psabspath = $_SERVER['DOCUMENT_ROOT'] . '/domin.com/prestashop/'; 

if ($psabspath != '' && file_exists($psabspath . 'config/config.inc.php') 
               && (file_exists($psabspath . 'classes/FrontController.php') || 
                file_exists($psabspath . 'classes/controller/FrontController.php'))) { 
    require_once($psabspath . 'init.php'); 
    require_once($psabspath . 'config/config.inc.php'); 

    class PrestaShopIntegration_FrontController extends FrontController { 
     public function __destruct() 
     { 
      if (Context::getContext()->cookie) 
       Context::getContext()->cookie->write(); 
     } 

     public function init() { 
      $this->page_name = 'wordpress'; 
      parent::init(); 

      if (isset($this->context)) { 
       if (version_compare(_PS_VERSION_, '1.5.4', '>=')) 
        $this->setMedia(); 
       if ($this->checkAccess()) { 
        $this->postProcess(); 
        $this->initHeader(); 
        if ($this->viewAccess()) 
         $this->initContent(); 
        else 
         $this->errors[] = Tools::displayError('Access denied.'); 
        $this->initFooter(); 
       } 
      } 
     } 

    } 
} 

ответ

0

Вы должны сначала включить config.php файл, а затем вы сможете включить init.php.

$psabspath = ''; 
$psabspath = $_SERVER['DOCUMENT_ROOT'] . '/myskinrecipes.com/shop/'; 

if ($psabspath != '' && file_exists($psabspath . 'config/config.inc.php') 
               && (file_exists($psabspath . 'classes/FrontController.php') || 
                file_exists($psabspath . 'classes/controller/FrontController.php'))) { 
    require_once($psabspath . 'config/config.inc.php'); 
    require_once($psabspath . 'init.php'); 

    class PrestaShopIntegration_FrontController extends FrontController { 
     public function __destruct() 
     { 
      if (Context::getContext()->cookie) 
       Context::getContext()->cookie->write(); 
     } 

     public function init() { 
      $this->page_name = 'wordpress'; 
      parent::init(); 

      if (isset($this->context)) { 
       if (version_compare(_PS_VERSION_, '1.5.4', '>=')) 
        $this->setMedia(); 
       if ($this->checkAccess()) { 
        $this->postProcess(); 
        $this->initHeader(); 
        if ($this->viewAccess()) 
         $this->initContent(); 
        else 
         $this->errors[] = Tools::displayError('Access denied.'); 
        $this->initFooter(); 
       } 
      } 
     } 

    } 
} 

config.php будет загружать файлы конфигурации PrestaShop и загрузить всю Framework.

init.php только для загрузки контроллера.

+0

Неустранимая ошибка: Class 'Configuration' не найден в /opt/lampp/htdocs/domin.com/prestashop/config/config.inc.php в строке 105. –

+0

И строка 105 имеет этот код Configuration :: loadConfiguration() ; –

+0

Хорошо, я буду загружать вашу конкретную версию Prestashop, протестировать ее и вернуться к вам как можно скорее. –

Смежные вопросы