Eu estou escrevendo um webservice usando php e estou usando a biblioteca de serviços web prestashop (https://github.com/PrestaShop/PrestaShop-webservice-lib). este é o meu código:
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"] = "admin@yoursite.com";
*/
$customer["email"] ="navid.abutorab@gmail.com";
$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;
Quando eu corro a página, recebo este erro:
Class "Product" not found in /home/xxxxx/public_html/test/test.php on line 37
a linha 37 é esta linha:
$product["price"] = Product::getPriceStatic($product["id"]);
o que devo incluir para que funcione bem?
Respostas:
1 para resposta № 1Tente adicionar a seguinte linha no início do seu código de serviço da web.
require_once(dirname(__FILE__)."/../../config/config.inc.php");
Nota: Por favor, ajuste o caminho de acordo com o caminho do arquivo. Você só precisa incluir o arquivo "config.inc.php".