Announcement

Collapse
No announcement yet.

Using not_image

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

    Using not_image

    I'd like to use the new not_image feature in a module I'm working on, but I seem to be having trouble at a very, very basic level getting it to function. At first, my module ONLY used the not_image feature, but then it seemed that there was no way to assign it to my store, so I added util and installed it through the Utilities menu. Just to test it, I tried to eval some text when the insert or delete functions were triggered, but nothing happened. I figured that might be because this type of module feature won't allow outputting to the screen, so I tried have it send me an email. That didn't work either.

    I assumed I could trigger the "delete" function from the Image Management utility by deleting the resized images for one of my product images. I then visited that product page so Image Machine would re-create them, assuming that would trigger the "insert" function.

    What am I missing? Am I fundamentally misunderstanding something about how the not_image feature works?

    Thanks for your help.

    Josh

    #2
    Re: Using not_image

    Hi Josh,

    Have you been able to get it to work yet? The not_image feature requires Miva Merchant 9.3, are you on that version? What you are doing sounds correct, so can you give me a little more information on your store? Engine version, Miva Merchant version, database type, etc...?

    Thank you
    David Carver
    Miva, Inc. | Software Developer

    Comment


      #3
      Re: Using not_image

      Hi David,
      I haven't revisited it since I posted this, but I was working in my Miva developer store. Here's the info:

      Miva Merchant 9.0003
      MivaScript Engine v5.22
      Database API: mysql

      Also, can you clarify whether I would need to use the utility or system feature in order to install the module to my store, or should it work even with just the not_image feature and nothing else?

      Thanks,
      Josh

      Comment


        #4
        Re: Using not_image

        Josh,

        You will need a different feature that allows the module to be "installed" at the store level.

        Here is a quick module I wrote and it works as expected:

        Code:
        <MvFUNCTION NAME = "Module_Description" PARAMETERS = "module var" STANDARDOUTPUTLEVEL = "">
            <MvASSIGN NAME = "l.module:code"            VALUE = "test">
            <MvASSIGN NAME = "l.module:name"           VALUE = "Test">
            <MvASSIGN NAME = "l.module:provider"       VALUE = "Miva Merchant">
            <MvASSIGN NAME = "l.module:version"         VALUE = "1.0000">
            <MvASSIGN NAME = "l.module:api_ver"         VALUE = "5.72">
            <MvASSIGN NAME = "l.module:description"    VALUE = "">
            <MvASSIGN NAME = "l.module:features"        VALUE = "util, not_image">
        </MvFUNCTION>
        
        
        <MvCOMMENT>
        |
        | Store Utilities Feature (util)
        |
        </MvCOMMENT>
        
        
        <MvFUNCTION NAME = "StoreUtilityModule_Action" PARAMETERS = "module var" STANDARDOUTPUTLEVEL = "">
            <MvFUNCTIONRETURN VALUE = 1>
        </MvFUNCTION>
        
        
        <MvFUNCTION NAME = "StoreUtilityModule_LeftNavigation" PARAMETERS = "module var, indent" STANDARDOUTPUTLEVEL = "">
            <MvFUNCTIONRETURN VALUE = 1>
        </MvFUNCTION>
        
        
        <MvFUNCTION NAME = "StoreUtilityModule_Screen" PARAMETERS = "module var" STANDARDOUTPUTLEVEL = "">
            <MvFUNCTIONRETURN VALUE = 1>
        </MvFUNCTION>
        
        
        <MvFUNCTION NAME = "StoreUtilityModule_Validate" PARAMETERS = "module var" STANDARDOUTPUTLEVEL = "">
            <MvFUNCTIONRETURN VALUE = 1>
        </MvFUNCTION>
        
        
        <MvCOMMENT>
        |
        | Image Change Notification Feature (not_image)
        |
        </MvCOMMENT>
        
        
        <MvFUNCTION NAME = "Module_Notify_Image_Insert" PARAMETERS = "module var, image var" STANDARDOUTPUTLEVEL = "">
            <MvASSIGN NAME = "l.string" VALUE = "{ miva_array_serialize( l.image ) }">
        
        
            <MvEXPORT FILE = "not_image_insert.log" FIELDS = "l.string" DELIMITER = ",">
        </MvFUNCTION>
        
        
        <MvFUNCTION NAME = "Module_Notify_Image_Delete" PARAMETERS = "module var, image var" STANDARDOUTPUTLEVEL = "">
            <MvASSIGN NAME = "l.string" VALUE = "{ miva_array_serialize( l.image ) }">
        
        
            <MvEXPORT FILE = "not_image_delete.log" FIELDS = "l.string" DELIMITER = ",">
        </MvFUNCTION>
        My store is setup on the same specs as yours as well. Maybe the test module can guide you in the right direction or maybe you'll notice the issue. Let me know if it still doesn't work for you and we'll trouble shoot it some more.

        Thanks
        David Carver
        Miva, Inc. | Software Developer

        Comment


          #5
          Re: Using not_image

          David,
          Thanks for the complete example to help me troubleshoot. I ended up just copying it entirely to test, and still don't seem to be getting any output. The documentation for MvEXPORT said it would create the file in the data folder, so I assume that's the mivadata folder, correct? I've looked all over and haven't found the log files. I went ahead and installed this on another store as well and still didn't see anything. Maybe I'm looking in the wrong place? What else could be going on?


          Thanks,
          Josh

          Comment


            #6
            Re: Using not_image

            Josh,

            Yes, MvEXPORT will output to the data directory. How are you testing these triggers? I went to a product image tab, added the picture and that triggered the image insert functionality. Then I selected the image and click delete, which triggered the image delete functionality. Let me know if either of those will trigger the API.

            Thanks
            David Carver
            Miva, Inc. | Software Developer

            Comment


              #7
              Re: Using not_image

              I tried a couple of things. Initially I was just going to the Image Management utility and using the "Delete Resized" option to delete a group of images, then visiting a product page that would regenerate those images. I then tried adding and removing images from a product listing, and also uploading and deleting images through the upload tool.

              Josh

              Comment


                #8
                Re: Using not_image

                Josh,

                Are you doing this in the template code or via a module?
                Thanks,

                Rick Wilson
                CEO
                Miva, Inc.
                [email protected]
                https://www.miva.com

                Comment


                  #9
                  Re: Using not_image

                  Everything I mentioned in my last post was just in the admin. No template code or module stuff to try triggering the not_image feature. The only module is the one that is exactly the code David supplied above, so I'm hoping to trigger the not_image feature and find a log file.

                  Your continued help is appreciated.

                  Josh

                  Comment


                    #10
                    Re: Using not_image

                    Josh,

                    Those the not_image API functions are not triggered on image generation or deleting resized images. They are only triggered on master image insert / delete. If you add my module and install it under the Utilities section of your store, then go a product upload an image it should trigger the insert API function. Let me know if those exact steps still do not work.

                    Thank you
                    David Carver
                    Miva, Inc. | Software Developer

                    Comment


                      #11
                      Re: Using not_image

                      I'm still not seeing anything when following those steps. However, as much as I would like to figure this out, it actually doesn't matter any more. I didn't realize that not_image was only triggered by master images. I wanted to create a module that would automatically copy images to Rackspace Files for CDN delivery and thought that not_image was the perfect solution to trigger this, but I guess it's not. It would need to include generated images.

                      My alternative as I see it right now is to have my module check to verify whether an object exists periodically... I'll have to think about that some more.

                      If you'd like to dig into my dev store to continue troubleshooting the issue you're welcome to: dev.superiorcelebrations.com


                      Thanks,
                      Josh

                      Comment


                        #12
                        Re: Using not_image

                        Josh,

                        I logged into your store and tested it out. It appears to work as expected. I uploaded an image, then deleted it for a test product and looked in the dev mivadata folder. There I saw the 2 files created from the not_image feature in the test module.

                        Are you sure you were looking at the correct mivadata folder?

                        Thanks
                        David Carver
                        Miva, Inc. | Software Developer

                        Comment


                          #13
                          Re: Using not_image

                          Hmm... I'm not sure what to tell you. I see your files, and was able to reproduce it. Those log files contain references to one of the images I uploaded earlier, so I must have just missed it somehow. I really thought I checked that folder.

                          So, my first issue was that I misunderstood when the not_image feature was triggered. I think this was the core problem 90% of the time.

                          My second issue was that I somehow overlooked the file once I tested it properly. Still not sure how I did that.

                          Thanks for helping clarify how this should work, and being patient with my missteps there at the end.

                          As a follow-up question... Is there any way to hook into the system creating or deleting generated images?


                          Thanks again,
                          Josh

                          Comment


                            #14
                            Re: Using not_image

                            Hi Josh,

                            Glad we worked together to figure out that first issue.

                            As for your follow up question...

                            It really depends on how much coding you know in MivaScript. You could theoretically create your own so called "feature" if this module is just for your needs. The GeneratedImages database functions are in the MMLSK, meaning the source code is available to you. You could modify the insert / delete functions to specifically call your module at that point in time in order to copy the images up to the CDN. One issue with this is when you upgrade your changes will be overwritten so you would have to be conscious of that.

                            If you're not comfortable enough with that, you could write a utility module that creates its own tab and when viewed compares the sent images to CDN with the images in the sNN_GeneratedImages table, then sends the differences.

                            Just a few random ideas, hope that helps.

                            Thanks
                            David Carver
                            Miva, Inc. | Software Developer

                            Comment


                              #15
                              Re: Using not_image

                              Interesting thoughts. I've generally been hesitant to directly modify core code. Like you said, it becomes an issue when upgrading. Partly this is because I don't know how often the LSK is updated. Last I checked it still showed version 9.0000. I'd hate to update the core files, then not have an updated copy to work from to be able to make future upgrades when necessary.

                              That said, I may just give myself an option to manually trigger a check. That's probably the safest route since I'll know when image changes are made anyways.

                              Thanks for the ideas!

                              Josh

                              Comment

                              Working...
                              X