“Undefined property: Interceptor::$invoiceService” while overriding controller in magento2Magento 2 error while adding new order statusMagento 2 Service Contract API Example For Creating A Shipment and Adding ItemsMagento 2: How to override newsletter Subscriber modelMagento 2 - Can't access to products with direct urlMagento 2: Shipment Email gives Missing required argument $debugHintsPathDI not working in ControllerError when i clicked on ship button inside a orderMagento 2.2.5: Overriding Admin Controller sales/orderhow to capture cybersource echeck programtically

Exposing a company lying about themselves in a tightly knit industry: Is my career at risk on the long run?

Could any one tell what PN is this Chip? Thanks~

When did hardware antialiasing start being available?

What is the difference between something being completely legal and being completely decriminalized?

Friend wants my recommendation but I don't want to

What kind of footwear is suitable for walking in micro gravity environment?

How can an organ that provides biological immortality be unable to regenerate?

Symbolism of 18 Journeyers

Are hand made posters acceptable in Academia?

Pre-Employment Background Check With Consent For Future Checks

What (if any) is the reason to buy in small local stores?

Would this string work as string?

What is the reasoning behind standardization (dividing by standard deviation)?

How do you justify more code being written by following clean code practices?

Why I don't get the wanted width of tcbox?

Why is "la Gestapo" feminine?

Why does Surtur say that Thor is Asgard's doom?

How do researchers send unsolicited emails asking for feedback on their works?

Is there any common country to visit for uk and schengen visa?

Does fire aspect on a sword, destroy mob drops?

Why is there so much iron?

What is 管理しきれず?

What will the Frenchman say?

Would mining huge amounts of resources on the Moon change its orbit?



“Undefined property: Interceptor::$invoiceService” while overriding controller in magento2


Magento 2 error while adding new order statusMagento 2 Service Contract API Example For Creating A Shipment and Adding ItemsMagento 2: How to override newsletter Subscriber modelMagento 2 - Can't access to products with direct urlMagento 2: Shipment Email gives Missing required argument $debugHintsPathDI not working in ControllerError when i clicked on ship button inside a orderMagento 2.2.5: Overriding Admin Controller sales/orderhow to capture cybersource echeck programtically













0















I am trying to override "AdminhtmlOrderInvoiceSave" controller, So I made changes in di.xml as below -



<preference for="MagentoSalesControllerAdminhtmlOrderInvoiceSave" type="CustomcodeProductserialnoControllerSalesAdminhtmlOrderInvoiceSave" />


And create as save.php controller at location -
CustomcodeProductserialnoControllerSalesAdminhtmlOrderInvoiceSave.php



and overide its execute function like below -



namespace CustomcodeProductserialnoControllerSalesAdminhtmlOrderInvoice;

class Save extends MagentoSalesControllerAdminhtmlOrderInvoiceSave


public function execute()

/** @var MagentoBackendModelViewResultRedirect $resultRedirect */
====
....................
........................
default code............
......................

try catch (LocalizedException $e)
$this->messageManager->addError($e->getMessage());
catch (Exception $e)
echo "<pre>";
print_r($e->getMessage()); die;
$this->messageManager->addError(__('We can't save the invoice right now.'));
$this->_objectManager->get('PsrLogLoggerInterface')->critical($e);

return $resultRedirect->setPath('sales/*/new', ['order_id' => $orderId]);




On this line its giving me error -



$invoice = $this->invoiceService->prepareInvoice($order, $invoiceItems);


Error - : Notice: Undefined property: CustomcodeProductserialnoControllerSalesAdminhtmlOrderInvoiceSaveInterceptor::$invoiceService in /var/www/html/git_projects/testbeat/app/code/Customcode/Productserialno/Controller/Sales/Adminhtml/Order/Invoice/Save.php on line 51



Please let me know what I am doing wrong .



Thanks










share|improve this question














bumped to the homepage by Community 20 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • remvoe var folder and check

    – Rakesh Jesadiya
    Sep 1 '17 at 8:30











  • Hi Rakesh, I removed all directories of var, pub/static then again run upgrade, content deploy n flush cache but still giving same issue....

    – Atul
    Sep 1 '17 at 10:41
















0















I am trying to override "AdminhtmlOrderInvoiceSave" controller, So I made changes in di.xml as below -



<preference for="MagentoSalesControllerAdminhtmlOrderInvoiceSave" type="CustomcodeProductserialnoControllerSalesAdminhtmlOrderInvoiceSave" />


And create as save.php controller at location -
CustomcodeProductserialnoControllerSalesAdminhtmlOrderInvoiceSave.php



and overide its execute function like below -



namespace CustomcodeProductserialnoControllerSalesAdminhtmlOrderInvoice;

class Save extends MagentoSalesControllerAdminhtmlOrderInvoiceSave


public function execute()

/** @var MagentoBackendModelViewResultRedirect $resultRedirect */
====
....................
........................
default code............
......................

try catch (LocalizedException $e)
$this->messageManager->addError($e->getMessage());
catch (Exception $e)
echo "<pre>";
print_r($e->getMessage()); die;
$this->messageManager->addError(__('We can't save the invoice right now.'));
$this->_objectManager->get('PsrLogLoggerInterface')->critical($e);

return $resultRedirect->setPath('sales/*/new', ['order_id' => $orderId]);




On this line its giving me error -



$invoice = $this->invoiceService->prepareInvoice($order, $invoiceItems);


Error - : Notice: Undefined property: CustomcodeProductserialnoControllerSalesAdminhtmlOrderInvoiceSaveInterceptor::$invoiceService in /var/www/html/git_projects/testbeat/app/code/Customcode/Productserialno/Controller/Sales/Adminhtml/Order/Invoice/Save.php on line 51



Please let me know what I am doing wrong .



Thanks










share|improve this question














bumped to the homepage by Community 20 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • remvoe var folder and check

    – Rakesh Jesadiya
    Sep 1 '17 at 8:30











  • Hi Rakesh, I removed all directories of var, pub/static then again run upgrade, content deploy n flush cache but still giving same issue....

    – Atul
    Sep 1 '17 at 10:41














0












0








0








I am trying to override "AdminhtmlOrderInvoiceSave" controller, So I made changes in di.xml as below -



<preference for="MagentoSalesControllerAdminhtmlOrderInvoiceSave" type="CustomcodeProductserialnoControllerSalesAdminhtmlOrderInvoiceSave" />


And create as save.php controller at location -
CustomcodeProductserialnoControllerSalesAdminhtmlOrderInvoiceSave.php



and overide its execute function like below -



namespace CustomcodeProductserialnoControllerSalesAdminhtmlOrderInvoice;

class Save extends MagentoSalesControllerAdminhtmlOrderInvoiceSave


public function execute()

/** @var MagentoBackendModelViewResultRedirect $resultRedirect */
====
....................
........................
default code............
......................

try catch (LocalizedException $e)
$this->messageManager->addError($e->getMessage());
catch (Exception $e)
echo "<pre>";
print_r($e->getMessage()); die;
$this->messageManager->addError(__('We can't save the invoice right now.'));
$this->_objectManager->get('PsrLogLoggerInterface')->critical($e);

return $resultRedirect->setPath('sales/*/new', ['order_id' => $orderId]);




On this line its giving me error -



$invoice = $this->invoiceService->prepareInvoice($order, $invoiceItems);


Error - : Notice: Undefined property: CustomcodeProductserialnoControllerSalesAdminhtmlOrderInvoiceSaveInterceptor::$invoiceService in /var/www/html/git_projects/testbeat/app/code/Customcode/Productserialno/Controller/Sales/Adminhtml/Order/Invoice/Save.php on line 51



Please let me know what I am doing wrong .



Thanks










share|improve this question














I am trying to override "AdminhtmlOrderInvoiceSave" controller, So I made changes in di.xml as below -



<preference for="MagentoSalesControllerAdminhtmlOrderInvoiceSave" type="CustomcodeProductserialnoControllerSalesAdminhtmlOrderInvoiceSave" />


And create as save.php controller at location -
CustomcodeProductserialnoControllerSalesAdminhtmlOrderInvoiceSave.php



and overide its execute function like below -



namespace CustomcodeProductserialnoControllerSalesAdminhtmlOrderInvoice;

class Save extends MagentoSalesControllerAdminhtmlOrderInvoiceSave


public function execute()

/** @var MagentoBackendModelViewResultRedirect $resultRedirect */
====
....................
........................
default code............
......................

try catch (LocalizedException $e)
$this->messageManager->addError($e->getMessage());
catch (Exception $e)
echo "<pre>";
print_r($e->getMessage()); die;
$this->messageManager->addError(__('We can't save the invoice right now.'));
$this->_objectManager->get('PsrLogLoggerInterface')->critical($e);

return $resultRedirect->setPath('sales/*/new', ['order_id' => $orderId]);




On this line its giving me error -



$invoice = $this->invoiceService->prepareInvoice($order, $invoiceItems);


Error - : Notice: Undefined property: CustomcodeProductserialnoControllerSalesAdminhtmlOrderInvoiceSaveInterceptor::$invoiceService in /var/www/html/git_projects/testbeat/app/code/Customcode/Productserialno/Controller/Sales/Adminhtml/Order/Invoice/Save.php on line 51



Please let me know what I am doing wrong .



Thanks







magento2






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Sep 1 '17 at 8:06









AtulAtul

470822




470822





bumped to the homepage by Community 20 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 20 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.














  • remvoe var folder and check

    – Rakesh Jesadiya
    Sep 1 '17 at 8:30











  • Hi Rakesh, I removed all directories of var, pub/static then again run upgrade, content deploy n flush cache but still giving same issue....

    – Atul
    Sep 1 '17 at 10:41


















  • remvoe var folder and check

    – Rakesh Jesadiya
    Sep 1 '17 at 8:30











  • Hi Rakesh, I removed all directories of var, pub/static then again run upgrade, content deploy n flush cache but still giving same issue....

    – Atul
    Sep 1 '17 at 10:41

















remvoe var folder and check

– Rakesh Jesadiya
Sep 1 '17 at 8:30





remvoe var folder and check

– Rakesh Jesadiya
Sep 1 '17 at 8:30













Hi Rakesh, I removed all directories of var, pub/static then again run upgrade, content deploy n flush cache but still giving same issue....

– Atul
Sep 1 '17 at 10:41






Hi Rakesh, I removed all directories of var, pub/static then again run upgrade, content deploy n flush cache but still giving same issue....

– Atul
Sep 1 '17 at 10:41











1 Answer
1






active

oldest

votes


















0














The scope of this variable is private. Hence you can't use this in your overriding (inherited) class. please inject MagentoSalesModelServiceInvoiceService class for this variable in your constructor as it is injected into the main class.



Don't forget to run upgrade and di:compile commands after DI.



Edit: try this in your class



<?php

namespace CustomcodeProductserialnoControllerSalesAdminhtmlOrderInvoice;


use MagentoBackendAppAction;
use MagentoFrameworkRegistry;
use MagentoSalesModelOrderEmailSenderInvoiceSender;
use MagentoSalesModelOrderEmailSenderShipmentSender;
use MagentoSalesModelOrderShipmentFactory;
use MagentoSalesModelServiceInvoiceService;

class Save extends MagentoSalesControllerAdminhtmlOrderInvoiceSave

/**
* @var InvoiceService
*/
private $invoiceService;

public function __construct
(
ActionContext $context,
Registry $registry,
InvoiceSender $invoiceSender,
ShipmentSender $shipmentSender,
ShipmentFactory $shipmentFactory,
InvoiceService $invoiceService
)

$this->invoiceService = $invoiceService;
parent::__construct($context, $registry, $invoiceSender, $shipmentSender, $shipmentFactory, $invoiceService);


/**
* Save invoice
* We can save only new invoice. Existing invoices are not editable
*
* @return MagentoFrameworkControllerResultInterface
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function execute()

..........................
.......All code with customization------




=================My Code is this ===================



namespace CustomcodeProductserialnoControllerSalesAdminhtmlOrderInvoice;

class Save extends MagentoSalesControllerAdminhtmlOrderInvoiceSave

/**
* @var InvoiceService
*/
private $invoiceService;

public function __construct(
MagentoBackendAppAction $context,
Registry $registry,
InvoiceSender $invoiceSender,
ShipmentSender $shipmentSender,
ShipmentFactory $shipmentFactory,
InvoiceService $invoiceService
)
parent::__construct($context, $registry, $invoiceSender, $shipmentSender, $shipmentFactory, $invoiceService);


public function execute()
..........................
.......All code with customization------





Plz check because my code still giving same error.
Recoverable Error: Argument 1 passed to CustomcodeProductserialnoControllerSalesAdminhtmlOrderInvoiceSave::__construct() must be an instance of MagentoBackendAppAction,



Plz let me know what I m doing wrong.






share|improve this answer

























  • I tried like this inside class - private $invoiceService; public function __construct( MagentoSalesModelServiceInvoiceService $invoiceService ) $this->invoiceService = $invoiceService; but its giving 500 error ....

    – Atul
    Sep 2 '17 at 10:16











  • did you run upgrade and compile commands afterwards??

    – Yogesh Agarwal
    Sep 2 '17 at 10:36











  • yes I have run Upgrade command but not compile because i m already in developer mode, >>>> now defined it as - public function __construct( MagentoFrameworkAppActionContext $context, MagentoSalesModelServiceInvoiceService $invoiceService, array $data = [] ) $this->invoiceService = $invoiceService; parent::__construct($context, $data); Now its giving - Argument 2 passed to MagentoSalesControllerAdminhtmlOrderInvoiceSave::__construct() must be an instance of MagentoFrameworkRegistry, error...

    – Atul
    Sep 2 '17 at 10:46












  • -> can you plz add respective live of code via update your answer.

    – Atul
    Sep 2 '17 at 11:39











  • @Atul I have made an edit. please give it a shot.

    – Yogesh Agarwal
    Sep 2 '17 at 12:13










Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f191550%2fundefined-property-interceptorinvoiceservice-while-overriding-controller-i%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














The scope of this variable is private. Hence you can't use this in your overriding (inherited) class. please inject MagentoSalesModelServiceInvoiceService class for this variable in your constructor as it is injected into the main class.



Don't forget to run upgrade and di:compile commands after DI.



Edit: try this in your class



<?php

namespace CustomcodeProductserialnoControllerSalesAdminhtmlOrderInvoice;


use MagentoBackendAppAction;
use MagentoFrameworkRegistry;
use MagentoSalesModelOrderEmailSenderInvoiceSender;
use MagentoSalesModelOrderEmailSenderShipmentSender;
use MagentoSalesModelOrderShipmentFactory;
use MagentoSalesModelServiceInvoiceService;

class Save extends MagentoSalesControllerAdminhtmlOrderInvoiceSave

/**
* @var InvoiceService
*/
private $invoiceService;

public function __construct
(
ActionContext $context,
Registry $registry,
InvoiceSender $invoiceSender,
ShipmentSender $shipmentSender,
ShipmentFactory $shipmentFactory,
InvoiceService $invoiceService
)

$this->invoiceService = $invoiceService;
parent::__construct($context, $registry, $invoiceSender, $shipmentSender, $shipmentFactory, $invoiceService);


/**
* Save invoice
* We can save only new invoice. Existing invoices are not editable
*
* @return MagentoFrameworkControllerResultInterface
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function execute()

..........................
.......All code with customization------




=================My Code is this ===================



namespace CustomcodeProductserialnoControllerSalesAdminhtmlOrderInvoice;

class Save extends MagentoSalesControllerAdminhtmlOrderInvoiceSave

/**
* @var InvoiceService
*/
private $invoiceService;

public function __construct(
MagentoBackendAppAction $context,
Registry $registry,
InvoiceSender $invoiceSender,
ShipmentSender $shipmentSender,
ShipmentFactory $shipmentFactory,
InvoiceService $invoiceService
)
parent::__construct($context, $registry, $invoiceSender, $shipmentSender, $shipmentFactory, $invoiceService);


public function execute()
..........................
.......All code with customization------





Plz check because my code still giving same error.
Recoverable Error: Argument 1 passed to CustomcodeProductserialnoControllerSalesAdminhtmlOrderInvoiceSave::__construct() must be an instance of MagentoBackendAppAction,



Plz let me know what I m doing wrong.






share|improve this answer

























  • I tried like this inside class - private $invoiceService; public function __construct( MagentoSalesModelServiceInvoiceService $invoiceService ) $this->invoiceService = $invoiceService; but its giving 500 error ....

    – Atul
    Sep 2 '17 at 10:16











  • did you run upgrade and compile commands afterwards??

    – Yogesh Agarwal
    Sep 2 '17 at 10:36











  • yes I have run Upgrade command but not compile because i m already in developer mode, >>>> now defined it as - public function __construct( MagentoFrameworkAppActionContext $context, MagentoSalesModelServiceInvoiceService $invoiceService, array $data = [] ) $this->invoiceService = $invoiceService; parent::__construct($context, $data); Now its giving - Argument 2 passed to MagentoSalesControllerAdminhtmlOrderInvoiceSave::__construct() must be an instance of MagentoFrameworkRegistry, error...

    – Atul
    Sep 2 '17 at 10:46












  • -> can you plz add respective live of code via update your answer.

    – Atul
    Sep 2 '17 at 11:39











  • @Atul I have made an edit. please give it a shot.

    – Yogesh Agarwal
    Sep 2 '17 at 12:13















0














The scope of this variable is private. Hence you can't use this in your overriding (inherited) class. please inject MagentoSalesModelServiceInvoiceService class for this variable in your constructor as it is injected into the main class.



Don't forget to run upgrade and di:compile commands after DI.



Edit: try this in your class



<?php

namespace CustomcodeProductserialnoControllerSalesAdminhtmlOrderInvoice;


use MagentoBackendAppAction;
use MagentoFrameworkRegistry;
use MagentoSalesModelOrderEmailSenderInvoiceSender;
use MagentoSalesModelOrderEmailSenderShipmentSender;
use MagentoSalesModelOrderShipmentFactory;
use MagentoSalesModelServiceInvoiceService;

class Save extends MagentoSalesControllerAdminhtmlOrderInvoiceSave

/**
* @var InvoiceService
*/
private $invoiceService;

public function __construct
(
ActionContext $context,
Registry $registry,
InvoiceSender $invoiceSender,
ShipmentSender $shipmentSender,
ShipmentFactory $shipmentFactory,
InvoiceService $invoiceService
)

$this->invoiceService = $invoiceService;
parent::__construct($context, $registry, $invoiceSender, $shipmentSender, $shipmentFactory, $invoiceService);


/**
* Save invoice
* We can save only new invoice. Existing invoices are not editable
*
* @return MagentoFrameworkControllerResultInterface
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function execute()

..........................
.......All code with customization------




=================My Code is this ===================



namespace CustomcodeProductserialnoControllerSalesAdminhtmlOrderInvoice;

class Save extends MagentoSalesControllerAdminhtmlOrderInvoiceSave

/**
* @var InvoiceService
*/
private $invoiceService;

public function __construct(
MagentoBackendAppAction $context,
Registry $registry,
InvoiceSender $invoiceSender,
ShipmentSender $shipmentSender,
ShipmentFactory $shipmentFactory,
InvoiceService $invoiceService
)
parent::__construct($context, $registry, $invoiceSender, $shipmentSender, $shipmentFactory, $invoiceService);


public function execute()
..........................
.......All code with customization------





Plz check because my code still giving same error.
Recoverable Error: Argument 1 passed to CustomcodeProductserialnoControllerSalesAdminhtmlOrderInvoiceSave::__construct() must be an instance of MagentoBackendAppAction,



Plz let me know what I m doing wrong.






share|improve this answer

























  • I tried like this inside class - private $invoiceService; public function __construct( MagentoSalesModelServiceInvoiceService $invoiceService ) $this->invoiceService = $invoiceService; but its giving 500 error ....

    – Atul
    Sep 2 '17 at 10:16











  • did you run upgrade and compile commands afterwards??

    – Yogesh Agarwal
    Sep 2 '17 at 10:36











  • yes I have run Upgrade command but not compile because i m already in developer mode, >>>> now defined it as - public function __construct( MagentoFrameworkAppActionContext $context, MagentoSalesModelServiceInvoiceService $invoiceService, array $data = [] ) $this->invoiceService = $invoiceService; parent::__construct($context, $data); Now its giving - Argument 2 passed to MagentoSalesControllerAdminhtmlOrderInvoiceSave::__construct() must be an instance of MagentoFrameworkRegistry, error...

    – Atul
    Sep 2 '17 at 10:46












  • -> can you plz add respective live of code via update your answer.

    – Atul
    Sep 2 '17 at 11:39











  • @Atul I have made an edit. please give it a shot.

    – Yogesh Agarwal
    Sep 2 '17 at 12:13













0












0








0







The scope of this variable is private. Hence you can't use this in your overriding (inherited) class. please inject MagentoSalesModelServiceInvoiceService class for this variable in your constructor as it is injected into the main class.



Don't forget to run upgrade and di:compile commands after DI.



Edit: try this in your class



<?php

namespace CustomcodeProductserialnoControllerSalesAdminhtmlOrderInvoice;


use MagentoBackendAppAction;
use MagentoFrameworkRegistry;
use MagentoSalesModelOrderEmailSenderInvoiceSender;
use MagentoSalesModelOrderEmailSenderShipmentSender;
use MagentoSalesModelOrderShipmentFactory;
use MagentoSalesModelServiceInvoiceService;

class Save extends MagentoSalesControllerAdminhtmlOrderInvoiceSave

/**
* @var InvoiceService
*/
private $invoiceService;

public function __construct
(
ActionContext $context,
Registry $registry,
InvoiceSender $invoiceSender,
ShipmentSender $shipmentSender,
ShipmentFactory $shipmentFactory,
InvoiceService $invoiceService
)

$this->invoiceService = $invoiceService;
parent::__construct($context, $registry, $invoiceSender, $shipmentSender, $shipmentFactory, $invoiceService);


/**
* Save invoice
* We can save only new invoice. Existing invoices are not editable
*
* @return MagentoFrameworkControllerResultInterface
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function execute()

..........................
.......All code with customization------




=================My Code is this ===================



namespace CustomcodeProductserialnoControllerSalesAdminhtmlOrderInvoice;

class Save extends MagentoSalesControllerAdminhtmlOrderInvoiceSave

/**
* @var InvoiceService
*/
private $invoiceService;

public function __construct(
MagentoBackendAppAction $context,
Registry $registry,
InvoiceSender $invoiceSender,
ShipmentSender $shipmentSender,
ShipmentFactory $shipmentFactory,
InvoiceService $invoiceService
)
parent::__construct($context, $registry, $invoiceSender, $shipmentSender, $shipmentFactory, $invoiceService);


public function execute()
..........................
.......All code with customization------





Plz check because my code still giving same error.
Recoverable Error: Argument 1 passed to CustomcodeProductserialnoControllerSalesAdminhtmlOrderInvoiceSave::__construct() must be an instance of MagentoBackendAppAction,



Plz let me know what I m doing wrong.






share|improve this answer















The scope of this variable is private. Hence you can't use this in your overriding (inherited) class. please inject MagentoSalesModelServiceInvoiceService class for this variable in your constructor as it is injected into the main class.



Don't forget to run upgrade and di:compile commands after DI.



Edit: try this in your class



<?php

namespace CustomcodeProductserialnoControllerSalesAdminhtmlOrderInvoice;


use MagentoBackendAppAction;
use MagentoFrameworkRegistry;
use MagentoSalesModelOrderEmailSenderInvoiceSender;
use MagentoSalesModelOrderEmailSenderShipmentSender;
use MagentoSalesModelOrderShipmentFactory;
use MagentoSalesModelServiceInvoiceService;

class Save extends MagentoSalesControllerAdminhtmlOrderInvoiceSave

/**
* @var InvoiceService
*/
private $invoiceService;

public function __construct
(
ActionContext $context,
Registry $registry,
InvoiceSender $invoiceSender,
ShipmentSender $shipmentSender,
ShipmentFactory $shipmentFactory,
InvoiceService $invoiceService
)

$this->invoiceService = $invoiceService;
parent::__construct($context, $registry, $invoiceSender, $shipmentSender, $shipmentFactory, $invoiceService);


/**
* Save invoice
* We can save only new invoice. Existing invoices are not editable
*
* @return MagentoFrameworkControllerResultInterface
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function execute()

..........................
.......All code with customization------




=================My Code is this ===================



namespace CustomcodeProductserialnoControllerSalesAdminhtmlOrderInvoice;

class Save extends MagentoSalesControllerAdminhtmlOrderInvoiceSave

/**
* @var InvoiceService
*/
private $invoiceService;

public function __construct(
MagentoBackendAppAction $context,
Registry $registry,
InvoiceSender $invoiceSender,
ShipmentSender $shipmentSender,
ShipmentFactory $shipmentFactory,
InvoiceService $invoiceService
)
parent::__construct($context, $registry, $invoiceSender, $shipmentSender, $shipmentFactory, $invoiceService);


public function execute()
..........................
.......All code with customization------





Plz check because my code still giving same error.
Recoverable Error: Argument 1 passed to CustomcodeProductserialnoControllerSalesAdminhtmlOrderInvoiceSave::__construct() must be an instance of MagentoBackendAppAction,



Plz let me know what I m doing wrong.







share|improve this answer














share|improve this answer



share|improve this answer








edited Sep 6 '17 at 5:46

























answered Sep 2 '17 at 5:48









Yogesh AgarwalYogesh Agarwal

712316




712316












  • I tried like this inside class - private $invoiceService; public function __construct( MagentoSalesModelServiceInvoiceService $invoiceService ) $this->invoiceService = $invoiceService; but its giving 500 error ....

    – Atul
    Sep 2 '17 at 10:16











  • did you run upgrade and compile commands afterwards??

    – Yogesh Agarwal
    Sep 2 '17 at 10:36











  • yes I have run Upgrade command but not compile because i m already in developer mode, >>>> now defined it as - public function __construct( MagentoFrameworkAppActionContext $context, MagentoSalesModelServiceInvoiceService $invoiceService, array $data = [] ) $this->invoiceService = $invoiceService; parent::__construct($context, $data); Now its giving - Argument 2 passed to MagentoSalesControllerAdminhtmlOrderInvoiceSave::__construct() must be an instance of MagentoFrameworkRegistry, error...

    – Atul
    Sep 2 '17 at 10:46












  • -> can you plz add respective live of code via update your answer.

    – Atul
    Sep 2 '17 at 11:39











  • @Atul I have made an edit. please give it a shot.

    – Yogesh Agarwal
    Sep 2 '17 at 12:13

















  • I tried like this inside class - private $invoiceService; public function __construct( MagentoSalesModelServiceInvoiceService $invoiceService ) $this->invoiceService = $invoiceService; but its giving 500 error ....

    – Atul
    Sep 2 '17 at 10:16











  • did you run upgrade and compile commands afterwards??

    – Yogesh Agarwal
    Sep 2 '17 at 10:36











  • yes I have run Upgrade command but not compile because i m already in developer mode, >>>> now defined it as - public function __construct( MagentoFrameworkAppActionContext $context, MagentoSalesModelServiceInvoiceService $invoiceService, array $data = [] ) $this->invoiceService = $invoiceService; parent::__construct($context, $data); Now its giving - Argument 2 passed to MagentoSalesControllerAdminhtmlOrderInvoiceSave::__construct() must be an instance of MagentoFrameworkRegistry, error...

    – Atul
    Sep 2 '17 at 10:46












  • -> can you plz add respective live of code via update your answer.

    – Atul
    Sep 2 '17 at 11:39











  • @Atul I have made an edit. please give it a shot.

    – Yogesh Agarwal
    Sep 2 '17 at 12:13
















I tried like this inside class - private $invoiceService; public function __construct( MagentoSalesModelServiceInvoiceService $invoiceService ) $this->invoiceService = $invoiceService; but its giving 500 error ....

– Atul
Sep 2 '17 at 10:16





I tried like this inside class - private $invoiceService; public function __construct( MagentoSalesModelServiceInvoiceService $invoiceService ) $this->invoiceService = $invoiceService; but its giving 500 error ....

– Atul
Sep 2 '17 at 10:16













did you run upgrade and compile commands afterwards??

– Yogesh Agarwal
Sep 2 '17 at 10:36





did you run upgrade and compile commands afterwards??

– Yogesh Agarwal
Sep 2 '17 at 10:36













yes I have run Upgrade command but not compile because i m already in developer mode, >>>> now defined it as - public function __construct( MagentoFrameworkAppActionContext $context, MagentoSalesModelServiceInvoiceService $invoiceService, array $data = [] ) $this->invoiceService = $invoiceService; parent::__construct($context, $data); Now its giving - Argument 2 passed to MagentoSalesControllerAdminhtmlOrderInvoiceSave::__construct() must be an instance of MagentoFrameworkRegistry, error...

– Atul
Sep 2 '17 at 10:46






yes I have run Upgrade command but not compile because i m already in developer mode, >>>> now defined it as - public function __construct( MagentoFrameworkAppActionContext $context, MagentoSalesModelServiceInvoiceService $invoiceService, array $data = [] ) $this->invoiceService = $invoiceService; parent::__construct($context, $data); Now its giving - Argument 2 passed to MagentoSalesControllerAdminhtmlOrderInvoiceSave::__construct() must be an instance of MagentoFrameworkRegistry, error...

– Atul
Sep 2 '17 at 10:46














-> can you plz add respective live of code via update your answer.

– Atul
Sep 2 '17 at 11:39





-> can you plz add respective live of code via update your answer.

– Atul
Sep 2 '17 at 11:39













@Atul I have made an edit. please give it a shot.

– Yogesh Agarwal
Sep 2 '17 at 12:13





@Atul I have made an edit. please give it a shot.

– Yogesh Agarwal
Sep 2 '17 at 12:13

















draft saved

draft discarded
















































Thanks for contributing an answer to Magento Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f191550%2fundefined-property-interceptorinvoiceservice-while-overriding-controller-i%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Nidaros erkebispedøme

Birsay

Where did Arya get these scars? Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar Manara Favourite questions and answers from the 1st quarter of 2019Why did Arya refuse to end it?Has the pronunciation of Arya Stark's name changed?Has Arya forgiven people?Why did Arya Stark lose her vision?Why can Arya still use the faces?Has the Narrow Sea become narrower?Does Arya Stark know how to make poisons outside of the House of Black and White?Why did Nymeria leave Arya?Why did Arya not kill the Lannister soldiers she encountered in the Riverlands?What is the current canonical age of Sansa, Bran and Arya Stark?