1

我正在编辑我的发票文件

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

如果它们的内容很长,我会遇到一个问题,即列会出现在其他列中并与其他列重叠。例如,在下一列上运行的产品描述。我试图弄清楚如何限制宽度/自动换行/为内容创建一个新行。

代码是:

// draw Product name
$lines[0] = array(array(
    'text' => Mage::helper('core/string')->str_split($item->getName(), 60, true, true),
    'feed' => 35,
));

// draw SKU
//  $lines[0][] = array(
//    'text'  => Mage::helper('core/string')->str_split($this->getSku($item), 25),
//  'feed'  => 255
//  );

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

if ($product) {
    $lines[0][] = array(
        'text'  => Mage::helper('core/string')->str_split($product->getAttributeText('manufacturer'), 15),
        'feed'  => 220
    );
}
// draw Colour (Added by James)
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $this->getSku($item), array('pos_short_colour'));

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

我知道'feed'是设置数组从左侧开始的距离(如果所有项目在css术语中都是'绝对',则几乎=到margin-left)。

但我不确定如何限制它们的宽度和自动换行,这样如果我的制造商很长,它就不会碰到颜色。发票上没有足够的空间来简单地为每个属性提供更多空间。

4

2 回答 2

1

答案就在那里:

   $lines[0] = array(array(
        'text' => Mage::helper('core/string')->str_split($item->getName(), 60, true, true),
        'feed' => 35,
    ));

这里的60是每行显示多少个字符->getName(), 60, true,

于 2012-12-18T01:48:04.110 回答
0

我遇到过同样的问题。当我添加一个新列时,产品描述列消失了。我通过减少 $productDescr 的 str_split 函数中的数字(长度)来解决这个问题。

于 2014-12-10T14:43:05.873 回答