I was referring this How to get current product in phtml without registry?

$myBlock = \Magento\Framework\App\ObjectManager::getInstance()->get('Magento\Catalog\Model\Session')->getData('last_viewed_product_id');

Its work on my local devops, but not work in production. Anyone know why? I am trying to get the bundle product id by session, is there any other way can do it?


  • did you run php bin/magento s:s:d after you change the production mode? – Kris Wen Nov 28 '19 at 1:50
  • Actually I just push my code to production server, my local devops doesn't need to run above, the code still effective – Paul Fan Nov 28 '19 at 4:04
  • On production server it's compulsory to run s:s:d command for changes – Naresh Rupareliya Nov 28 '19 at 4:09
  • Is it no harm no risk to run this? php bin/magento – Paul Fan Nov 28 '19 at 13:32
  • There should be no risk, unless there is something wrong with the code. – Kris Wen Dec 5 '19 at 6:47

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.