24/7 Support - 800.608.6482

Miva Merchant Community Forums

Page 2 of 2 FirstFirst 1 2

Thread: Direct Call to custom module missing global variables

  1. #11
    Join Date
    Nov 2011
    Posts
    56

    Default Re: Direct Call to custom module missing global variables

    Quote Originally Posted by RayYates View Post
    Rick

    I found it in the PDF but it's not showing up on any of the sites we manage.

    Miva Merchant 5.5
    Production Release 8Update 5
    Miva Merchant Engine v5.13
    Database API: mysql

    Go to Utilities from the store admin. You should see an item labelled Token List under the Modules tab. Check the box next to it and click update. After that, navigating to a page in admin will show the VAR LIST button at the top right of the page (next to the extras and help buttons).

    Remember, this is only available on PR8 Update 5+ stores.

  2. #12
    Join Date
    Dec 2006
    Location
    Florida
    Posts
    1,205

    Default Re: Direct Call to custom module missing global variables

    Very Very Nice!!! Much better than any of the third party tools (including mine). Great Job.
    Ray Yates
    "If I have seen further, it is by standing on the shoulders of giants."
    --- Sir Isaac Newton
    PCINet: http://www.pcinet.com/
    Toolbelt: http://www.pcinet.com/miva-modules/ry_toolbelt.html
    Toolbelt Documentation: http://www.pcinet.com/docs/toolbelt_docs.html
    Miva Script: http://www.MivaScript.com/

  3. #13
    Join Date
    Mar 2009
    Posts
    537

    Default Re: Direct Call to custom module missing global variables

    Quote Originally Posted by dorgan View Post
    When I call my custom module directly it seems like g.Store_Table_Prefix and some other global level variables are not being set. How do i get these values populated?
    When called directly your module should do something like the following:

    Code:
    <MvDO FILE = "../../lib/config.mvc">
    
    <MvIF EXPR = "{ NOT [ '../../lib/db.mvc' ].OpenDataFiles( g.Merchant_Version, g.Domain ) }">
        <MvEXIT>
    </MvIF>
    
    <MvEVAL EXPR = "{ [ '../../lib/util.mvc' ].SetRuntimePaths() }">
    
    <MvIF EXPR = "{ NOT [ g.Module_Library_DB ].Store_Open( g.Store_Code, g.Store ) }">
        <MvEXIT>
    </MvIF>
    The initial MvDO of lib/config.mv will set all of the global variables that indicate the version and the various feature and lib paths relative to the mm5 directory. We have to use a relative path to get to config.mvc because we haven't yet determined the root directory for modules so that we can use the g.Module_XXX variables.

    The OpenDataFiles call will connect to the database and populate g.Domain. Note that we have to use a relative path here as well.

    The SetRuntimePaths function will look at the settings in g.Domain and set the g.Module_XXX path variables.

    The Store_Open call will open the store specified by the input parameter Store_Code and set the g.Store variable. This function will also set g.Store_Table_Prefix. Note that since we've called SetRuntimePaths() we can use g.Module_Library_DB in the call.

    It is critically important that, at the bare minimum, any custom entry points into Miva Merchant MvDO lib/config.mvc. This MvDO explicitly sets any global variables that we use in database queries or subsequent MvDO operations. Passing any of those variables in as parameters will introduce one or more major security holes into your module.

Posting Rules

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •