从prestashop Web服务获取产品及其属性

ham*_*dkh 1 web-services prestashop-1.5

我将使用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;
    }
}
Run Code Online (Sandbox Code Playgroud)

编辑:
我发现从Web服务的响应是可以的。但是使用simplexml_load_string()功能解析xml时出现问题。任何的想法?这是$ product var_dump:

SimpleXMLElement#1 ( [products] => SimpleXMLElement#2 ( [product] => SimpleXMLElement#3 ( [description] => SimpleXMLElement#4 ( [language] => SimpleXMLElement#5 ( [@attributes] => array ( 'id' => '1' ) ) ) ) ) )
Run Code Online (Sandbox Code Playgroud)

lel*_*man 5

我认为这样$opt['display'] = 'full';就可以了。您也可以只选择一些特定的属性,例如

$opt['display'] = '[id,name]';
Run Code Online (Sandbox Code Playgroud)

查看官方文档,您可能会发现它很有趣