我需要从它的值中获取自定义属性标签。我有以下代码 -
$labels = $product->getAdwordsLabels();
$labels_array = explode(',', $labels);
foreach($labels_array as $value) {
$goog_labels .= "<g:adwords_labels>$value</g:adwords_labels>";
}
return $goog_labels;
$ value的值是属性的整数表示。我需要所有属性的标签,现在是$ value。
如何?
答案 0 :(得分:0)
如果我理解你的问题,这应该有效:
//$labels = $product->getAdwordsLabels();
$labels = $product->getResource()->getAttribute("adwords_labels")->getStoreLabel();
$labels_array = explode(',', $labels);
foreach($labels_array as $value) {
$goog_labels .= "<g:adwords_labels>$value</g:adwords_labels>";
}
return $goog_labels;