Wednesday, November 21, 2012

Magento invoice pdf : display custom options in one line



open default.php
at path:

app/code/local/Mage/Sales/Model/Order/Pdf/Items/Invoice

//REPLACE THE LINES  one that starts with if ($options) {
        //foreach ($options as $option) { with the followin lines.

       
       $options = $this->getItemOptions();
    if ($options) {
        foreach ($options as $option) {
            if ($option['value']) {
                $_printValue = isset($option['print_value']) ? $option['print_value'] : strip_tags($option['value']);
                $values = explode(', ', $_printValue);
                foreach ($values as $value) {
                    $optlabel= Mage::helper('core/string')->str_split(strip_tags($option['label']), 70, true, true);
                    $optval = Mage::helper('core/string')->str_split($value, 50, true, true);
                    $lines[][] = array(
                        'text' => htmlspecialchars_decode ($optlabel[0]." : ".$optval[0]),
                        'feed' =>35
                    );
                }
            }
        }
    }

2 comments:

  1. I have been surfing online more than 3 hours lately, yet I by no means found any attention-grabbing article like yours. It is lovely value enough for me. Personally, if all webmasters and bloggers made good content as you probably did, the web can be much more useful than ever before.
    Magento Developers

    ReplyDelete
  2. Works like a charme for displaying custom options. Do you know a way to display the single prices for article and each custom option into the invoice?
    Your help would be much appreciated....

    ReplyDelete