从Magento中的值获取自定义属性标签



我需要从它的值中获得一个自定义属性标签。我有下面的代码-

$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现在所在的属性的标签。

如何?

如果我正确理解你的问题,这应该有效:

    //$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;

最新更新