2016-09-06 20 views
2

私はwebサービスをPHPで作成していますが、私はprestashop webserviceライブラリ(https://github.com/PrestaShop/PrestaShop-webservice-lib)を使用しています。これは私のコードです:私は、ページを実行するとphp - prestashopクラス 'Product'が見つかりません

define('DEBUG', true); 
define('PS_SHOP_PATH', 'http://xxxxx.com/'); 
define('PS_WS_AUTH_KEY', 'xxxxx'); 
require_once ('PSWebServiceLibrary.php'); 

$webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG); 
$xml = $webService->get(array('url' => PS_SHOP_PATH .'/api/customers?schema=synopsis')); 

$customer = array(); 
$product = array(); 

/*if (strlen($_POST('c_email'))>0) 
    $customer['email'] = Tools::getValue('c_email'); 
else 
    $customer['email'] = '[email protected]'; 
*/ 
$customer['email'] ="[email protected]"; 
$customer['firstname'] = "navid"; 
$customer['lastname'] ="abutorab"; 
$customer['address1'] = "adres"; 
$customer['city'] = "citye"; 
$customer['phone'] = "09360544841"; 

$id['country'] = '165'; 
$id['lang'] = '1'; 
$id['currency'] = '1'; 
$id['carrier'] = '3'; 

$product['quantity'] ="1"; 
$id_product="10104"; 
$product['id'] = $id_product; 
echo Product::getPriceStatic($product['id']) . "-----"; 
$product['price'] = Product::getPriceStatic($product['id']); 
$product['name'] = Product::getProductName($product['id']); 

$product['total'] = $product['price'] * $product['quantity']; 

$xml->customer->firstname = $customer['firstname']; 
$xml->customer->lastname = $customer['lastname']; 
$xml->customer->email = $customer['email']; 
$xml->customer->newsletter = '1'; 
$xml->customer->optin = '1'; 
$xml->customer->active = '1'; 


$opt = array('resource' => 'customers'); 
$opt['postXml'] = $xml->asXML(); 
$xml = $webService->add($opt); 



// ID of created customer 
$id['customer'] = $xml->customer->id; 

、私はこのエラーを取得する:

Class 'Product' not found in /home/xxxxx/public_html/test/test.php on line 37 

ライン37は、この行です:

$product['price'] = Product::getPriceStatic($product['id']); 

私はそれを作るために含めるべきか正常に動作します ?

+1

モジュールを開発していますか? PrestaShopクラスを使用する場合は、PrestaShop環境で「作業」しなければなりません。 – sarcom

+0

@sarcom、いいえ私はモジュール用に開発していません、私は自分のアプリケーションのためのAPIに取り組んでいます。 Prestashop環境に慣れていないので、どのようにこれらのクラスを組み込むことができますか? –

+1

することはできません... xmlsとAPI呼び出しで作業する必要があります – sarcom

答えて

1

Webサービスコードの開始時に次の行を追加してください。

require_once(dirname(__FILE__).'/../../config/config.inc.php'); 

注:ファイルパスごとにパスを調整してください。あなたは 'config.inc.php'ファイルをインクルードする必要があります。

関連する問題