I have override Magento\Sales\Block\Adminhtml\Order\Invoice\Create\Items.php file, Its overided, When I am executing process, system calling respective _beforeToHtml() function from my file.

But at the end of function here is a line of code - return parent::_prepareLayout(); That creating issue I think because on the page it's showing nothing. And also not giving any error.

Here is code -


namespace Customcode\Productserialno\Block\Sales\Adminhtml\Order\Invoice\Create;

class Items extends \Magento\Sales\Block\Adminhtml\Order\Invoice\Create\Items
    protected function _beforeToHtml()
        $onclick = "submitAndReloadArea($('invoice_item_container'),'" . $this->getUpdateUrl() . "')";
            ['class' => 'update-button', 'label' => __('Update Qty\'s'), 'onclick' => $onclick]
        $this->_disableSubmitButton = true;
        $submitButtonClass = ' disabled';
        foreach ($this->getInvoice()->getAllItems() as $item) {
             * @see bug #14839
            if ($item->getQty()/* || $this->getSource()->getData('base_grand_total')*/) {
                $this->_disableSubmitButton = false;
                $submitButtonClass = '';
        if ($this->getOrder()->getForcedShipmentWithInvoice()) {
            $_submitLabel = __('Submit Invoice and Shipment');
        } else {
            $_submitLabel = __('Submit Invoice');
                'label' => $_submitLabel,
                'class' => 'save submit-button primary' . $submitButtonClass,
                'onclick' => '',
                'disabled' => $this->_disableSubmitButton
        return parent::_prepareLayout();
        } catch(Exception $e){ echo $e->getMessage();die;}

Here I override only "onclick" value of 'submit_button'.

Plz, let me know what I am doing wrong.


2 Answers 2


instead of return parent::_prepareLayout(); use return $this;. Because you can't call the same parent function again


To return the parent::_prepareLayout(); you have to call

return \Magento\Sales\Block\Adminhtml\Items\AbstractItems::_prepareLayout();

as you parent class now is the one you extend and the _prepareLayout() function doesn't exist.

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.