如何在wordpress中访问prestashop函数

时间:2016-06-29 08:04:51

标签: module prestashop

我正在使用prestashop 1.4.3版本。我想在wordpress中获取用户数据。我试过下面的代码没有运气。给我这个致命的错误:

  

未找到类'FrontController'   第28行的/opt/lampp/htdocs/domin.com/prestashop/init.php。

这是我的剧本:

$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();
                }
            }
        }

    }
}

1 个答案:

答案 0 :(得分: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仅用于加载控制器。