1

我在以下方面进行了一些发票模板修改:

/Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php

允许在发票上包含制造商等自定义属性。

此代码有效,但它会吐出制造商 ID,我需要标签。

 $product = Mage::getModel('catalog/product')->loadByAttribute('sku', $this->getSku($item), array('manufacturer'));

           if ($product) {
             $lines[0][] = array(
               'text'  => Mage::helper('core/string')->str_split($manufacturer, 15),
               'feed'  => 220
              );
    }

例如 - 当我需要“耐克”时,我得到 4138

我已经尝试过这个可以在前端工作但我得到一个错误:致命错误:调用非对象上的成员函数getResource()

$_product->getResource()->getAttribute('pos_short_colour')->getFrontend()->getValue($_product)

那么如何在发票模板中调用标签而不是 ID。

PS 我也尝试过使用 getData / getLabel / getText

4

1 回答 1

1

您可以使用该getAttributeText()函数获取属性的标签。例如:

$text = $product->getAttributeText('manufacturer');

另外,我相信您在第二段代码中看到的错误是因为您使用$_product的是未定义/空值。试试$product吧。

于 2012-12-16T14:52:19.960 回答