i've been using Mage::registry('current_category');
but i only found about that from a template done by someone else, so i am wondering if there is an easy way to get a list of all the registry keys/values currently being used in magento
while i'm not fussed if a link is provided with a list of magento ones i would like to get a list of any registry keys/values used in 3rd party modules
Best Answer
Sort of.
If you obey the intents of the Magento system designers, you can't see what's in the registry. That's because Magento's core engineers have declared the array that stores the registry values on the
Mage
class asprivate
Also, there's no method in
Mage
for fetching the raw registry or all its keys. This means under normal operating conditions, the only methods allowed to access$_registry
are in the classMage
. Since you can't rewrite anything inMage
, you're out of luck.If you're willing to use reflection (and have PHP 5.3+ installed), you can use the following to grab the array
This instantiates a
ReflectionClass
class, passing inMage
to tell PHP it's the definedMage
class we wish to reflect into.Then we grab a ReflectionProperty object with
getProperty
, passing in_registry
which tells PHP we want to reflect into the_registry
property on theMage
class.Then we use the
setAccessible
method to change the property fromprivate
to public, and then grab its value withgetValue
.