antoniocosentino
2/1/2018 - 11:19 AM

Shopware 5 Styla Plugin - No curl hack

shopware5/engine/Shopware/Plugins/Local/Frontend/StylaSEO/Controllers/Frontend/Magazin.php if CURL request to SEO API is creating issues replace postDispatch() with this

    public function postDispatch(){

        $type = $this->_feed_params['type'];
        $js_include = StylaUtils::getJsEmbedCode($this->_username, $this->_snippet_url);

        $ret = null;

        $path = StylaUtils::getCurrentPath($this->_base_dir);
        //disabling call to SEO API
        //$ret = StylaUtils::getRemoteContent($this->_username, $path, $this->_url_query_params, $this->_source_url);

        $custom_page = $this->View()->getAssign('sCustomPage');
        if($ret){
            $custom_page['head_content'] = $ret['head_content'];
            $custom_page['page_title'] = $ret['page_title'];
            $custom_page['meta_description'] = $ret['meta_description'];
            $custom_page['query_params'] = $ret['query_params'];
            $stylaDiv = '<div id="stylaMagazine" data-magazinename="'.$this->_username.'" data-rootpath="'.$this->_base_dir.'"></div>';
            $this->View()->assign('sContent', $ret['noscript_content']."\r\n".$js_include."\r\n".$stylaDiv);
            $status_code = $ret['status_code'];
        }
        //since we disabled SEO API call, providing just the basic content
        else {
            $stylaDiv = '<div id="stylaMagazine" data-magazinename="'.$this->_username.'" data-rootpath="'.$this->_base_dir.'"></div>';
            $this->View()->assign('sContent', $js_include."\r\n".$stylaDiv);
            $status_code = 200;
        }

        $this->View()->assign('sCustomPage', $custom_page);
        $this->View()->assign('feed_type', $type);
        $this->Response()->setHttpResponseCode($status_code);
    }