Prestashop 1.5.4 Web サービスを使用して、説明、名前などの属性を持つすべての製品を取得します。私の問題は、Web サービスを呼び出すたびに、製品 ID のみが返されることです。どうすれば属性も取得できますか?
編集:
コード:
class ShopApi
{
public $client;
public function __construct()
{
$this->getClient();
}
public function getClient()
{
try {
// creating web service access
$this->client = new PrestaShopWebservice('http://wikibazaar.ir/', 'A38L095W0RHRXE8PM9CM01CZW7KIU4PX', false);
} catch (PrestaShopWebserviceException $ex) {
// Shows a message related to the error
echo 'error: <br />' . $ex->getMessage();
}
}
}
class ProductApi extends ShopApi
{
public function findAll()
{
$products = array();
/// The key-value array
$opt['resource'] = 'products';
$opt['display'] = '[description]';
$opt['limit'] = 1;
$xml = $this->client->get($opt);
$resources = $xml->products->children();
foreach ($resources as $resource)
$products[] = $resource->attributes();
return $products;
}
}
編集:
webservice からの応答が問題ないことがわかりました。しかし、関数でxmlを解析する際に問題がありsimplexml_load_string()
ます。何か案が?それは $product var_dump です:
SimpleXMLElement#1 ( [products] => SimpleXMLElement#2 ( [product] => SimpleXMLElement#3 ( [description] => SimpleXMLElement#4 ( [language] => SimpleXMLElement#5 ( [@attributes] => array ( 'id' => '1' ) ) ) ) ) )