Announcement

Collapse
No announcement yet.

How to alter module priority

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

    How to alter module priority

    I'm working on module which generates the coupon code in its 'fulfill' feature. Everything works beautifully but my plan was to send the coupon code to the customer in the order confirmation email which is generated by another module's 'fulfill' feature.

    In the sources for miva I didn't find the implementation for StoreModuleList_Load_Feature function, so I poked around the database structure in hopes of finding anything that would control the priority for modules so they're called in a particular order (i.e. first the coupon is created then email is sent). No luck there.

    My ideas at this point are (in order of increasing awkwardness):
    - implement coupon generation as log feature hooked to 'AUTH' Action
    - uninstall email module and re-install it again so it is picked after my module in unsorted result
    - implement coupon generation in component call referenced in email template

    Do I have any less hack-y options at this time?

    #2
    Re: How to alter module priority

    Well, first workaround is out of the window. According to sources log feature is called after fulfill.

    Comment


      #3
      Re: How to alter module priority

      Found unused module_id lower than email module and after thorough review to make sure it's not used anywhere else pulled heart-stopping trick:

      UPDATE `Modules` SET `id` = 240 WHERE `id` = 258;
      UPDATE `ModuleXFeature` SET `module_id` = 240 WHERE `module_id` = 258;
      UPDATE `s01_Items` SET `module_id` = 240 WHERE `module_id` = 258;
      UPDATE `s01_StoreModules` SET `module_id` = 240 WHERE `module_id` = 258;

      Other tables referencing module_ids (charges, shipping etc) were not involved in my case.
      Now modules are called in the order I need.

      Don't try this at home! Not proud of what I had to do. Miva should really add `call_order` in `s01_StoreModules` and sort by that column in StoreModuleList_Load_Feature

      Comment


        #4
        Re: How to alter module priority

        It does seem odd that the LSK doesn't contain any of the Module or StoreModule functions. Weren't they in there at one time?

        Tigra, could you put your coupon-generation code in a system action, instead of a log action? The possible downside of that is that the code will get run as soon as customer tries to check out, even though they might get stopped by a problem such as a declined credit card. Sometimes you can use a combination of system and log action to cover all the possibilities.

        HTH --
        Kent Multer
        Magic Metal Productions
        http://TheMagicM.com
        * Web developer/designer
        * E-commerce and Miva
        * Author, The Official Miva Web Scripting Book -- available on-line:
        http://www.amazon.com/exec/obidos/IS...icmetalproducA

        Comment


          #5
          Re: How to alter module priority

          The best way to do this is with a token in the email template. My coupon module does this in thousands of stores. You can wrap the generation token with a conditional to only do it when one of the actions is AUTH if the store has a re-send email feature. Now if you are doing this for your store only you could modify the order of the module IDs, but you would not want to do that to other stores which might get your module.
          Bill Weiland - Emporium Plus http://www.emporiumplus.com/store.mvc
          Online Documentation http://www.emporiumplus.com/tk3/v3/doc.htm
          Question http://www.emporiumplus.com/mivamodu...vc?Screen=SPTS
          Facebook http://www.facebook.com/EmporiumPlus
          Twitter http://twitter.com/emporiumplus

          Comment


            #6
            Re: How to alter module priority

            Thanks for your reply.
            My code is intended for one store deployment, thus module ID based solution.
            I would probably resort to using component token otherwise as you suggested.
            What would like to see is this issue put to rest at the system level.
            There's even existing (although not the most elegant) interface for reordering records - for example in product attributes.

            Comment


              #7
              Re: How to alter module priority

              That's an option. Thanks for the idea. If similar situation arises I'll just make as separate action for it and add it to the list after AUTH. This way if there are other modules hooked to AUTH I don't have to deal with random call order again. According to source the Actions are processed in the order they're listed.

              Originally posted by Kent Multer View Post

              Tigra, could you put your coupon-generation code in a system action, instead of a log action? ...

              Comment

              Working...
              X