如何使用预prestashop webservice api在产品中添加tags?我需要一个这样的功能:
function addTagToProduct((int)$ProductId, (string)$tagname){}attachment document也是这样:我应该传递给webservice哪些内容来添加这些内容呢?
发布于 2016-03-14 11:55:39
我使用这个函数向我的产品添加标签:
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;
}希望能帮上忙。
https://stackoverflow.com/questions/35975677
复制相似问题