Skip to main content
Post Closed as "Not suitable for this site" by David Manners, Fabian Blechschmidt, Sander Mangel, 7ochem, Amit Bera
format code
Source Link
David Manners
  • 27.3k
  • 9
  • 76
  • 220

iI am trying to add custom attribute publisher name"publisher name" below product name in PDF invoice & publisher. Publisher is a custom attribute created by me
copy
app/code/core/Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php
to
app/code/local/Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php

with adding

I have copied

app/code/core/Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php

to

app/code/local/Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php

And have added some codescode in default.phpdefault.php but this is not working properly &. It is showing attribute id like 250,251 in the pdf but iI want it to show publisher name
i

I add following code in default.php

$Publisher = $this->getPublisherValue($item);

&

 
 $lines[1][] = array(
        'text'  => Mage::helper('core/string')->str_split($Publisher, 35),
        'feed'  => 35
    );

&

 

private function getPublisherValue($item)
    {
        $prod = Mage::getModel('catalog/product')->load($item->getProductId());
 
        if(($return_publisher = $prod->getPublisher()))
            return $return_publisher;
        else
            return 'N/A';
   }

   

i am trying to add custom attribute publisher name below product name in PDF invoice & publisher is custom attribute created by me
copy
app/code/core/Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php
to
app/code/local/Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php

with adding some codes in default.php but this not working properly & showing attribute id like 250,251 in pdf but i want publisher name
i add following code in default.php

$Publisher = $this->getPublisherValue($item);

&

 $lines[1][] = array(
        'text'  => Mage::helper('core/string')->str_split($Publisher, 35),
        'feed'  => 35
    );

&

private function getPublisherValue($item)
    {
        $prod = Mage::getModel('catalog/product')->load($item->getProductId());
 
        if(($return_publisher = $prod->getPublisher()))
            return $return_publisher;
        else
            return 'N/A';
   }

   

I am trying to add custom attribute "publisher name" below product name in PDF invoice. Publisher is a custom attribute created by me.

I have copied

app/code/core/Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php

to

app/code/local/Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php

And have added some code in default.php but this is not working properly. It is showing attribute id like 250,251 in the pdf but I want it to show publisher name

I add following code in default.php

$Publisher = $this->getPublisherValue($item);
 
 $lines[1][] = array(
        'text'  => Mage::helper('core/string')->str_split($Publisher, 35),
        'feed'  => 35
    );
 

private function getPublisherValue($item)
    {
        $prod = Mage::getModel('catalog/product')->load($item->getProductId());
 
        if(($return_publisher = $prod->getPublisher()))
            return $return_publisher;
        else
            return 'N/A';
   }
deleted 4337 characters in body
Source Link
Dinesh
  • 809
  • 4
  • 18
  • 32

getting problem in add add custom product attribute in PDF invoice magento1.9

i am trying to add custom attribute, product(book) publisher name below product name in PDF invoice & publisher is custom attribute created by me 
copy 
app/code/core/Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php 
to 
app/code/local/Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php 

with following codeadding some codes in default.php but this not working properly & showing attribute id like 250,251 in pdf but i want publisher name default
i add following code in default.php code

    class Mage_Sales_Model_Order_Pdf_Items_Invoice_Default extends Mage_Sales_Model_Order_Pdf_Items_Abstract
{
    /**
     * Draw item line
     */
    public function draw()
    {
        $order  = $this->getOrder();
        $item   = $this->getItem();
        $pdf    = $this->getPdf();
        $page   = $this->getPage();
        $lines  = array();
        $Publisher = $this->getPublisherValue($item);
    

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

&

 $lines[1][] = array(
            'text'  => Mage::helper('core/string')->str_split($Publisher, 35),
            'feed'  => 35
        );
        


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

        // draw QTY
        $lines[0][] = array(
            'text'  => $item->getQty() * 1,
            'feed'  => 435,
            'align' => 'right'
        );

        // draw item Prices
        $i = 0;
        $prices = $this->getItemPricesForDisplay();
        $feedPrice = 395;
        $feedSubtotal = $feedPrice + 170;
        foreach ($prices as $priceData){
            if (isset($priceData['label'])) {
                // draw Price label
                $lines[$i][] = array(
                    'text'  => $priceData['label'],
                    'feed'  => $feedPrice,
                    'align' => 'right'
                );
                // draw Subtotal label
                $lines[$i][] = array(
                    'text'  => $priceData['label'],
                    'feed'  => $feedSubtotal,
                    'align' => 'right'
                );
                $i++;
            }
            // draw Price
            $lines[$i][] = array(
                'text'  => $priceData['price'],
                'feed'  => $feedPrice,
                'font'  => 'bold',
                'align' => 'right'
            );
            // draw Subtotal
            $lines[$i][] = array(
                'text'  => $priceData['subtotal'],
                'feed'  => $feedSubtotal,
                'font'  => 'bold',
                'align' => 'right'
            );
            $i++;
        }

        // draw Tax
        $lines[0][] = array(
            'text'  => $order->formatPriceTxt($item->getTaxAmount()),
            'feed'  => 495,
            'font'  => 'bold',
            'align' => 'right'
        );

        // custom options
        $options = $this->getItemOptions();
        if ($options) {
            foreach ($options as $option) {
                // draw options label
                $lines[][] = array(
                    'text' => Mage::helper('core/string')->str_split(strip_tags($option['label']), 40, true, true),
                    'font' => 'italic',
                    'feed' => 35
                );

                if ($option['value']) {
                    if (isset($option['print_value'])) {
                        $_printValue = $option['print_value'];
                    } else {
                        $_printValue = strip_tags($option['value']);
                    }
                    $values = explode(', ', $_printValue);
                    foreach ($values as $value) {
                        $lines[][] = array(
                            'text' => Mage::helper('core/string')->str_split($value, 30, true, true),
                            'feed' => 40
                        );
                    }
                }
            }
        }

        $lineBlock = array(
            'lines'  => $lines,
            'height' => 20
        );

        $page = $pdf->drawLineBlocks($page, array($lineBlock), array('table_header' => true));
        $this->setPage($page);
    }

       

&

private function getPublisherValue($item)
    {
        $prod = Mage::getModel('catalog/product')->load($item->getProductId());
 
        if(!($return_publisher = $prod->getPublisher()))
            return 'N/A';$return_publisher;
        else
            return $return_publisher;'N/A';
   }
}
   

getting problem in add add custom product attribute in PDF invoice magento1.9

i am trying to add custom attribute, product(book) publisher name below product name in PDF invoice & publisher is custom attribute created by me copy app/code/core/Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php to app/code/local/Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php with following code in default.php but this not working properly & showing attribute id like 250,251 in pdf default.php code

    class Mage_Sales_Model_Order_Pdf_Items_Invoice_Default extends Mage_Sales_Model_Order_Pdf_Items_Abstract
{
    /**
     * Draw item line
     */
    public function draw()
    {
        $order  = $this->getOrder();
        $item   = $this->getItem();
        $pdf    = $this->getPdf();
        $page   = $this->getPage();
        $lines  = array();
        $Publisher = $this->getPublisherValue($item);
    

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


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

        // draw QTY
        $lines[0][] = array(
            'text'  => $item->getQty() * 1,
            'feed'  => 435,
            'align' => 'right'
        );

        // draw item Prices
        $i = 0;
        $prices = $this->getItemPricesForDisplay();
        $feedPrice = 395;
        $feedSubtotal = $feedPrice + 170;
        foreach ($prices as $priceData){
            if (isset($priceData['label'])) {
                // draw Price label
                $lines[$i][] = array(
                    'text'  => $priceData['label'],
                    'feed'  => $feedPrice,
                    'align' => 'right'
                );
                // draw Subtotal label
                $lines[$i][] = array(
                    'text'  => $priceData['label'],
                    'feed'  => $feedSubtotal,
                    'align' => 'right'
                );
                $i++;
            }
            // draw Price
            $lines[$i][] = array(
                'text'  => $priceData['price'],
                'feed'  => $feedPrice,
                'font'  => 'bold',
                'align' => 'right'
            );
            // draw Subtotal
            $lines[$i][] = array(
                'text'  => $priceData['subtotal'],
                'feed'  => $feedSubtotal,
                'font'  => 'bold',
                'align' => 'right'
            );
            $i++;
        }

        // draw Tax
        $lines[0][] = array(
            'text'  => $order->formatPriceTxt($item->getTaxAmount()),
            'feed'  => 495,
            'font'  => 'bold',
            'align' => 'right'
        );

        // custom options
        $options = $this->getItemOptions();
        if ($options) {
            foreach ($options as $option) {
                // draw options label
                $lines[][] = array(
                    'text' => Mage::helper('core/string')->str_split(strip_tags($option['label']), 40, true, true),
                    'font' => 'italic',
                    'feed' => 35
                );

                if ($option['value']) {
                    if (isset($option['print_value'])) {
                        $_printValue = $option['print_value'];
                    } else {
                        $_printValue = strip_tags($option['value']);
                    }
                    $values = explode(', ', $_printValue);
                    foreach ($values as $value) {
                        $lines[][] = array(
                            'text' => Mage::helper('core/string')->str_split($value, 30, true, true),
                            'feed' => 40
                        );
                    }
                }
            }
        }

        $lineBlock = array(
            'lines'  => $lines,
            'height' => 20
        );

        $page = $pdf->drawLineBlocks($page, array($lineBlock), array('table_header' => true));
        $this->setPage($page);
    }

       private function getPublisherValue($item)
    {
        $prod = Mage::getModel('catalog/product')->load($item->getProductId());
 
        if(!($return_publisher = $prod->getPublisher()))
            return 'N/A';
        else
            return $return_publisher;
   }
}

getting problem in add custom product attribute in PDF invoice magento1.9

i am trying to add custom attribute publisher name below product name in PDF invoice & publisher is custom attribute created by me 
copy 
app/code/core/Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php 
to 
app/code/local/Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php 

with adding some codes in default.php but this not working properly & showing attribute id like 250,251 in pdf but i want publisher name
i add following code in default.php

$Publisher = $this->getPublisherValue($item);

&

 $lines[1][] = array(
        'text'  => Mage::helper('core/string')->str_split($Publisher, 35),
        'feed'  => 35
    );

&

private function getPublisherValue($item)
    {
        $prod = Mage::getModel('catalog/product')->load($item->getProductId());
 
        if(($return_publisher = $prod->getPublisher()))
            return $return_publisher;
        else
            return 'N/A';
   }

   
Source Link
Dinesh
  • 809
  • 4
  • 18
  • 32

getting problem in add add custom product attribute in PDF invoice magento1.9

i am trying to add custom attribute, product(book) publisher name below product name in PDF invoice & publisher is custom attribute created by me copy app/code/core/Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php to app/code/local/Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php with following code in default.php but this not working properly & showing attribute id like 250,251 in pdf default.php code

    class Mage_Sales_Model_Order_Pdf_Items_Invoice_Default extends Mage_Sales_Model_Order_Pdf_Items_Abstract
{
    /**
     * Draw item line
     */
    public function draw()
    {
        $order  = $this->getOrder();
        $item   = $this->getItem();
        $pdf    = $this->getPdf();
        $page   = $this->getPage();
        $lines  = array();
        $Publisher = $this->getPublisherValue($item);
    

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


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

        // draw QTY
        $lines[0][] = array(
            'text'  => $item->getQty() * 1,
            'feed'  => 435,
            'align' => 'right'
        );

        // draw item Prices
        $i = 0;
        $prices = $this->getItemPricesForDisplay();
        $feedPrice = 395;
        $feedSubtotal = $feedPrice + 170;
        foreach ($prices as $priceData){
            if (isset($priceData['label'])) {
                // draw Price label
                $lines[$i][] = array(
                    'text'  => $priceData['label'],
                    'feed'  => $feedPrice,
                    'align' => 'right'
                );
                // draw Subtotal label
                $lines[$i][] = array(
                    'text'  => $priceData['label'],
                    'feed'  => $feedSubtotal,
                    'align' => 'right'
                );
                $i++;
            }
            // draw Price
            $lines[$i][] = array(
                'text'  => $priceData['price'],
                'feed'  => $feedPrice,
                'font'  => 'bold',
                'align' => 'right'
            );
            // draw Subtotal
            $lines[$i][] = array(
                'text'  => $priceData['subtotal'],
                'feed'  => $feedSubtotal,
                'font'  => 'bold',
                'align' => 'right'
            );
            $i++;
        }

        // draw Tax
        $lines[0][] = array(
            'text'  => $order->formatPriceTxt($item->getTaxAmount()),
            'feed'  => 495,
            'font'  => 'bold',
            'align' => 'right'
        );

        // custom options
        $options = $this->getItemOptions();
        if ($options) {
            foreach ($options as $option) {
                // draw options label
                $lines[][] = array(
                    'text' => Mage::helper('core/string')->str_split(strip_tags($option['label']), 40, true, true),
                    'font' => 'italic',
                    'feed' => 35
                );

                if ($option['value']) {
                    if (isset($option['print_value'])) {
                        $_printValue = $option['print_value'];
                    } else {
                        $_printValue = strip_tags($option['value']);
                    }
                    $values = explode(', ', $_printValue);
                    foreach ($values as $value) {
                        $lines[][] = array(
                            'text' => Mage::helper('core/string')->str_split($value, 30, true, true),
                            'feed' => 40
                        );
                    }
                }
            }
        }

        $lineBlock = array(
            'lines'  => $lines,
            'height' => 20
        );

        $page = $pdf->drawLineBlocks($page, array($lineBlock), array('table_header' => true));
        $this->setPage($page);
    }

       private function getPublisherValue($item)
    {
        $prod = Mage::getModel('catalog/product')->load($item->getProductId());
 
        if(!($return_publisher = $prod->getPublisher()))
            return 'N/A';
        else
            return $return_publisher;
   }
}