购物内容API无法在OpenCart中使用

时间:2016-04-16 16:50:04

标签: opencart2.x opencart-module google-content-api

我正在尝试将OpenCart中的购物内容API集成到我的PHP应用程序中并收到此错误:

  

Fatal error: Uncaught exception 'GSC_ParseError' with message 'Not Found' in /home/public_html/admin/controller/module/GShoppingContent.php:2805 Stack trace: #0 /home/public_html/admin/controller/module/GShoppingContent.php(980): _GSC_AtomParser::parse('Not Found') #1 /home/public_html/admin/controller/module/contentapi.php(76): GSC_Client->insertProduct(Object(GSC_Product)) #2 [internal function]: ControllerModuleContentApi->index(Array) #3 /home//public_html/vqmod/vqcache/vq2-system_modification_system_engine_action.php(71): call_user_func(Array, Array) #4 /home//public_html/vqmod/vqcache/vq2-system_engine_front.php(89): Action->execute(Object(Registry)) #5 /home//public_html/vqmod/vqcache/vq2-system_engine_front.php(63): Front->execute(Object(Action)) #6 /home//public_html/admin/index.php(175): Front->dispatch(Object(Action), Object(Action)) #7 {main} thrown in /home//public_html/admin/controller/module/GShoppingContent.php on line 280 5

这是我的代码:

require_once('GShoppingContent.php');

class ControllerModuleContentApi extends Controller {
    private $error = array();

    public function index() {
        $this->load->language('module/contentapi');
        $this->db->query("

        CREATE TABLE IF NOT EXISTS `contentapi` (
     `contentapiid` int(11) NOT NULL AUTO_INCREMENT,
  `contentapimerchantid` varchar(256) NOT NULL,
  `contentapiemail` varchar(256) NOT NULL,
  `contentapipassword` varchar(256) NOT NULL,
  PRIMARY KEY (`contentapiid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

");

 $contentAPI11=$this->db->query("select * from contentapi");
 $data['contentapidata'] = $contentAPI11->rows;

if (isset($this->request->post['merchantid']) && isset($this->request->post['GoogleMerchantEmail']) && isset($this->request->post['GoogleMerchantPassword'] )) {


            $merchantid=$this->request->post['merchantid'];
            $GoogleMerchantEmail=$this->request->post['GoogleMerchantEmail'];
            $GoogleMerchantPassword=$this->request->post['GoogleMerchantPassword'];

            $primaryid=$this->request->post['primaryid'];



            $this->db->query("UPDATE  contentapi SET  contentapimerchantid='$merchantid',contentapiemail='$GoogleMerchantEmail',contentapipassword='$GoogleMerchantPassword' where contentapiid='$primaryid'"); 


        }

         $retrieveapidetails=$this->db->query("select * from contentapi");
         if($retrieveapidetails->num_rows>0)
         {
         $retrieveapidetails1=$retrieveapidetails->rows;
         foreach($retrieveapidetails1 as $retrieveapidetails2)
         {
             $contentapimerchantid=$retrieveapidetails2["contentapimerchantid"];
             $contentapiemail=$retrieveapidetails2["contentapiemail"];
             $contentapipassword=$retrieveapidetails2["contentapipassword"];


         }

         $retrieveproducts=$this->db->query("select oc_product.model,oc_product.sku,oc_product.price,oc_product.image,oc_product_description.name,oc_product_description.description from oc_product,oc_product_description where oc_product.product_id=oc_product_description.product_id");
         $retrieveproducts1=$retrieveproducts->rows;
         $client = new GSC_Client($contentapimerchantid);
        $client->login($contentapiemail, $contentapipassword);
         foreach($retrieveproducts1 as $retrieveproducts2)
         {
             $productid=$retrieveproducts2["product_id"];
             $productname=$retrieveproducts2["name"];
             $productmodel=$retrieveproducts2["model"];
             $productprice=$retrieveproducts2["price"];
             $productimage=$retrieveproducts2["image"];
             $productsku=$retrieveproducts2["sku"];
             $productdescription=$retrieveproducts2["description"];
             $product = new GSC_Product();
$product->setTitle($productname);
$product->setDescription($productdescription);
$link = 'https://testingsite.com/index.php?route=product/product&product_id=' . $productid;
$product->setProductLink($link);
$product->setSKU($productsku);
$product->setImageLink('https://testingsite.com/'.$productimage);
$product->setBrand($productimage);
$product->setPrice($productprice, 'usd');
$entry = $client->insertProduct($product);

         }
         }

0 个答案:

没有答案