Announcement

Collapse
No announcement yet.

Input Module. How to assign to store.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Input Module. How to assign to store.

    I'm using the new (5.70) Import functionality and seem to be missing something really basic. How does one assign the module to your store?

    I know I could also make it a utility module and have the user assign it there, but it seems Merchant import modules to not require that extra step. What am I missing?

    Do I need to implement ImportModule_Persistent_Provision() to accomplish that?
    Ray Yates
    "If I have seen further, it is by standing on the shoulders of giants."
    --- Sir Isaac Newton

    #2
    Haven't used or created an import/export module in a while, but i recall that it auto assigns on install.
    Bruce Golub
    Phosphor Media - "Your Success is our Business"

    Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
    phosphormedia.com

    Comment


      #3
      For new import modules they have to be registered by the user from the Data Management/Import Settings screen. When the first import is created, your module will be installed in the store.

      Comment


        #4
        I see. It would be nice to create the import record automatically, so what's the API call to add this during installation?

        After examining the Add Import Dialog, I find where it's calling the AJAX function Import_Insert() to post the form data. This prompted me to look into the LSK but alas I did not find /features/imp

        The structure of the Imports table seems pretty straight forward, but before I go poking around in there, I though I would ask.
        Last edited by RayYates; 02-08-16, 07:52 PM.
        Ray Yates
        "If I have seen further, it is by standing on the shoulders of giants."
        --- Sir Isaac Newton

        Comment


          #5
          Burch

          I really did not want to have to have to force users to create a new import record manually. I could reverse engineer the Ajax function and call the Module_JSON function during installation, but it would be preferable to call the Internal function directly. I'm groping in the dark. Could you provide some light?
          Last edited by RayYates; 02-10-16, 05:32 PM. Reason: spelling
          Ray Yates
          "If I have seen further, it is by standing on the shoulders of giants."
          --- Sir Isaac Newton

          Comment


            #6
            I would prefer to use an API call for this but until its documented or included in the LSK, I came up with my own. I'm sure someone else has already figured this out but I could find no reference.

            For posterity:
            Code:
            <MvFUNCTION NAME="Install_Import" PARAMETERS="module var" STANDARDOUTPUTLEVEL="">
                <MvCOMMENT>
                    Called from Module_Install_Store()
                    If the module Import record does not exist, create it.
                </MvCOMMENT>
            
                <MvOPENVIEW NAME="Merchant" VIEW="imp"
                    QUERY = "{ 'SELECT * FROM ' $ Store_Table_Prefix $ 'Imports WHERE module_id = ?' }" FIELDS="l.module:id">
                <MvIF EXPR = "{ g.MvOPENVIEW_Error }">
                    <MvFUNCTIONRETURN VALUE = "{ [ g.Module_Library_Utilities ].Error( l.module:name $ ': Install_Import failed. ', g.MvOPENVIEW_Error ) }">
                </MvIF>
                <MvIF EXPR="{ NOT imp.d.eof }">
                    <MvCLOSEVIEW NAME="Merchant" VIEW="imp">
                    <MvFUNCTIONRETURN VALUE = 1>
                </MvIF>
                <MvCLOSEVIEW NAME="Merchant" VIEW="imp">
            
                <MvASSIGN NAME="l.fieldlist" VALUE="id,module_id,descrip,delim,header,automap,map,config">
                <MvASSIGN NAME="l.data:id" VALUE="{ [ g.Module_Library_DB ].StoreKey_Generate( l.keyname ) }">
                <MvASSIGN NAME="l.data:module_id" VALUE="{ l.module:id}">
                <MvASSIGN NAME="l.data:descrip" VALUE="Map Locations Add/Update from CSV">
                <MvASSIGN NAME="l.data:delim" VALUE="44">
                <MvASSIGN NAME="l.data:header" VALUE="1">
                <MvASSIGN NAME="l.data:automap" VALUE="1">
                <MvASSIGN NAME="l.data:map" VALUE="">
                <MvASSIGN NAME="l.data:config" VALUE=":categories=replace_data,:name=addupdate,:products=replace_data">
                <MvFUNCTIONRETURN VALUE="{ Store_Table_Insert('Imports', l.fieldlist, l.data) }">
            </MvFUNCTION>
            
            
            <MvFUNCTION NAME="UnInstall_Import" PARAMETERS="module var" STANDARDOUTPUTLEVEL="" ERROROUTPUTLEVEL="">
                <MvCOMMENT>
                    Called from Module_Uninstall_Store()
                    Delete all module import records.
                </MvCOMMENT>
                
                <MvQUERY NAME="Merchant"
                    QUERY = "{ 'DELETE FROM ' $ g.Store_Table_Prefix $ 'Imports WHERE module_id = ?' }"
                    FIELDS="l.module:id">
                <MvIF EXPR = "{ g.MvQUERY_Error }">
                    <MvFUNCTIONRETURN VALUE = "{ [ g.Module_Library_Utilities ].Error( l.module:name $ ': UnInstall_Import failed. ', g.MvQUERY_Error ) }">
                </MvIF>
                <MvFUNCTIONRETURN = 1>
            </MvFUNCTION>
            IMPORTANT NOTE: If you use l.module:feature "import" by itself and create the Import definition/setting in the admin, you will find there is no way to uninstall the module. You can not delete definitions/settings in the admin, requiring you to screw around with the Modules and Import databases manually (not good).

            So the module can be installed and uninstalled I used this in Module_Description().
            Code:
            <MvASSIGN NAME = "l.module:features"    VALUE = "util,data_store,import">
            Last edited by RayYates; 02-13-16, 05:46 AM.
            Ray Yates
            "If I have seen further, it is by standing on the shoulders of giants."
            --- Sir Isaac Newton

            Comment

            Working...
            X