2

I have managed to create a module, and overwrite the \Magento\Sales\Model\Order\Pdf\Invoice class, using the steps proposed by this answer: https://magento.stackexchange.com/a/241932/80959

My question is how do I edit the _drawItem() method?

In the original implementation all the data is sent to some product renderer object:

/**
 * Draw Item process
 *
 * @param  \Magento\Framework\DataObject $item
 * @param  \Zend_Pdf_Page $page
 * @param  \Magento\Sales\Model\Order $order
 * @return \Zend_Pdf_Page
 */
protected function _drawItem(\Magento\Framework\DataObject $item, \Zend_Pdf_Page $page, \Magento\Sales\Model\Order $order)
{
    $type = $item->getOrderItem()->getProductType();
    $renderer = $this->_getRenderer($type);
    $renderer->setOrder($order);
    $renderer->setItem($item);
    $renderer->setPdf($this);
    $renderer->setPage($page);
    $renderer->setRenderedModel($this);

    $renderer->draw();

    return $renderer->getPage();
}

I don't understand it's purpose, nor I am able to find it's source code.

Should I discard that code altogether and start drawing each value? Or is there a purpose for that renderer, case in which I might lose some functionality?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.