Magento:将客户群添加到pdf包装单

时间:2011-05-11 15:58:14

标签: magento

我正在尝试将客户的群组添加到pdf包装单中。我假设这应该在Sales / Model / Order / Pdf / Abstract.php中完成,但我该放在哪里?

由于

2 个答案:

答案 0 :(得分:1)

好的,这就是我的所作所为。我把以下代码 - 我写的:

/* Add Customer Type to Invoice */
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
$readresult=$write->query("select customer_id from `sales_order` where increment_id = ".$order->getIncrementId()." limit 0,1;");
$row = $readresult->fetch();
$customerId = $row['customer_id'];
$myRoleId = 1;

if (!empty($customerId)) {
    $write = Mage::getSingleton('core/resource')->getConnection('core_write');
    $readresult=$write->query("select group_id from `customer_entity` where entity_id = ".$customerId." limit 0,1;");
    $row = $readresult->fetch();
    $myRoleId = $row['group_id'];
}

switch ($myRoleId){
case 2: $groupTitle = 'Wholesaler Invoice';
  break;
case 3: $groupTitle = 'Retailer Invoice';
  break;
case 4: $groupTitle = 'Dealer Invoice';
  break;
default: $groupTitle = 'Customer Invoice';
  break;
}

$page->drawText($groupTitle, 480, 780, 'UTF-8');    
/* End add Customer Type */     

在此代码块已经存在之后:

/* Add head */
$this->insertOrder($page, $order, Mage::getStoreConfigFlag(self::XML_PATH_SALES_PDF_INVOICE_PUT_ORDER_ID, $order->getStoreId()));

$page->setFillColor(new Zend_Pdf_Color_GrayScale(1));
$this->_setFontRegular($page);
$page->drawText(Mage::helper('sales')->__('Invoice # ') . $invoice->getIncrementId(), 35, 780, 'UTF-8');

在app \ code \ local \ Mage \ Sales \ Model \ Order \ Pdf \ Invoice.php文件中

答案 1 :(得分:0)

如果您有$order可用,例如在Abstract.php中,您可以使用以下代码获取客户组ID和名称。

$customerGroupId = $order->getCustomerGroupId();
$groupname = Mage::getModel('customer/group')->load($customerGroupId)->getCustomerGroupCode();