0

I manage to obtain the creditmemos in pdf format via this code (for a webservice)



$result = array();
//.....
//....

Mage::app()->setCurrentStore($store_id); // my store id

$CreditMemo = Mage::getResourceModel('sales/order_creditmemo_collection')
        ->addAttributeToSelect('*')
        ->addAttributeToFilter('entity_id', array('in' => $creditmemo_id))
        ->load();
if ($CreditMemo->getSize() > 0) {
  $pdf = Mage::getModel('sales/order_pdf_Creditmemo')->getPdf($CreditMemo);
  if ($pdf) {
    $file = $pdf->render(); // get the pdf content
    $result['file'] = base64_encode($file); // convert it to 64
  }
}

return $result; //return result in soap

But it doesnt apply the same template as in the frontend.

I use a similar code to generate PDF invoices and do not encounter this problem....

Do you know how to define the template for creditmemos ?

Thanks;

1 Answer 1

0

Finally the site had an SNMM module (Auit). By using it I was able to get the file with the right template

 $creditMemos = Mage::getResourceModel('sales/order_creditmemo_collection');
 $creditMemos->addFieldToFilter('entity_id', $creditmemo_id);
 $creditMemos->load();

 foreach ($creditMemos as $C) {
    $pdf = Mage::getModel('auit_pdf/creditmemo')->getPdf(array($C));

    //.... etc...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.