Magento: How to set and get registry?
Registry means registering or creating a new variable which is to be used later on in the project/code. The registry variable acts as a global variable which can be used anywhere.
Here are the functions to register, unregister and fetch a registry variable.
register(): register a variable
unregister(): unregister a variable
registry(‘VARIABLE_NAME’): fetch registry variable value
We can store anything in the registry variable. It can be integer, string, array, etc.
The below example shows how to create, fetch and destroy registry variable.
The Store ID of the shop is stored in registry with variable name store_id. Mage::app()->getStore()->getId() gives the current store id.
Fetch registry variable value
Destroy / Unregister the variable
Hope this helps. Thanks.