I want to use some data from intercepters in a block.

To start with I have attempted to use DI to inject a simple custom model but by logging I see that a instance is been used by the interceptor and the block.

What should I be doing to share data between the interceptor (plugin) and block given that this will always be in the same request lifecycle (i.e. not persisting between requests)?

1 Answer 1


You should be able to use the core registry for this purpose. Inject Magento\Framework\Registry into block and plug-in classes. Use it like this: $this->coreRegistry->register('my_data', $data); and $data = $this->coreRegistry->registry('my_data');

  • When I use $data = $this->coreRegistry->registry('my_data'); from the block class I don't see the expected value. Could the type of interceptor (around) be causing an issue? Commented Oct 5, 2016 at 8:00
  • Sounds like the call to access the data is happening before the data is set. It would help if you posted your code. Commented Oct 5, 2016 at 8:20
  • From logging I see the call to ->register('foo', 'bar') happens before ->registry('foo'). Could it be the coreRegistry is scoped? Commented Oct 5, 2016 at 15:20
  • Works very well for me - I have used it for sharing data between two plugins. Just the approach is not my favourite one, as it works like a global variable.
    – hey
    Commented Apr 17, 2019 at 3:19

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.