Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/web-services/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Web services Prestashop webservice添加产品&x27;s标签和附件文件_Web Services_Prestashop 1.6 - Fatal编程技术网

Web services Prestashop webservice添加产品&x27;s标签和附件文件

Web services Prestashop webservice添加产品&x27;s标签和附件文件,web-services,prestashop-1.6,Web Services,Prestashop 1.6,如何使用prestashop webservice api在产品中添加标记? 我需要一个这样的函数: function addTagToProduct((int)$ProductId, (string)$tagname){} 附件文档也一样:我应该传递给webservice什么来添加这些标签?我使用此功能向我的产品添加标签: public function getTagId($Tag){ //if tag exists $xml = $this->get(array('u

如何使用prestashop webservice api在产品中添加
标记
? 我需要一个这样的函数:

function addTagToProduct((int)$ProductId, (string)$tagname){}

附件文档也一样:我应该传递给webservice什么来添加这些标签?

我使用此功能向我的产品添加标签:

public function getTagId($Tag){
    //if tag exists
    $xml = $this->get(array('url' => $this->url . '/api/tags?filter[name]='.$Tag.'&limit=1'));
    $resources = $xml -> children() -> children();
    if(!empty($resources)){
        $attributes = $resources->tag->attributes();
        return $attributes['id'];
    }

    //if not exists, add it
    $xml = $this->get(array('url' => $this->url . '/api/tags?schema=synopsis'));
    $resources = $xml -> children() -> children();

    unset($resources->id);
    $resources->name        = $Tag;
    $resources->id_lang     = $this->getIdLang();

    $opt = array(
        'resource' => 'tags',
        'postXml'  => $xml->asXML()
    );

    $xml = $this->add($opt);
    return $xml->tag->id;
}
希望能有所帮助