0

I have created a custom module. In controller i am setting variable as

$resultPage->getLayout()->getBlock('custom_block')->setPid($pId);

In production mode I am getting above error, although its working well in developer mode. Any suggestion?

  • Run php bin/magento setup:di:compile in developer mode and see if will show any error. – Ylgen Guxholli Oct 17 '18 at 14:27
  • In developer mode its working I am able to set variable and use any block function that exist at the block class ,however when I do switch to production mode getting above error. Also I am not able to access any function of the block – Muhammad Ayaz Oct 17 '18 at 15:08
  • You didnt get me i think , before merging any branch or code into production , run a di:compile first to see if you are good to go for production . Did you run that already ? – Ylgen Guxholli Oct 17 '18 at 15:11
  • Thanks YLgen Guxhilli! for your quick response, I got it fixed. While debugging I learned that if your reference block name is wrong in your layout file you will get this error ,you will not be able to access block functions and set variable as well. – Muhammad Ayaz Oct 17 '18 at 16:04
  • Glad you fixed it :) – Ylgen Guxholli Oct 17 '18 at 16:54

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.