Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • How to Set & Get Magento Registry?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.26k
    Comment on it

    Hello Readers,
    This tutorial will guide you about "How to Set & Retrieve Variable in magento registry ". Registry means creating a new global variable which is to be used later in any magento template file (.phtml). Magento registry function is a static function & can be called directly without creating an object.


    There are 3 functions to register, unregister and fetch a registry variable.


    register() – This function registers our variables. We can store anything in the registry variable. It can be integer, string, array, etc.

    registry() – This is used to get the value of registered variable.

    unregister() – This function destroys our registered variable.


    Set Variable to registry

    Mage::register('name-of-key', $data);

    Retrieve Variable from magento registry.

    $getData = Mage::registry('name-of-key');


    Destroy / Unregister the variable


    This will destroy the variable when we no longer need it.


    Default Key In Magento
    There are Some By Default Key in magento through which we can get the current Details of magento data like Current Product, & Current category details.


    If you want to get the current category. then use the below code.

    $_current_category = Mage::registry('current_category');


    If you want to get current product details. then use the below code.

    $current_product = Mage::registry('current_product');

 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: