Announcement

Collapse
No announcement yet.

Updating Custom Fields Generated by Module

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

    Updating Custom Fields Generated by Module

    We're setting up the Advanced Shipping Manager and looking to automate updating some of the custom fields it has. In most cases, the Write_Product_Code function:
    Code:
    <mvt:item name="customfields" param="Write_Product_Code( 'product_code', 'custom_field_code', 'value' )" />
    would work, but the custom fields this module creates has a different structure.

    For example, their field "ASM Origin Zip" is
    Code:
    l.settings:product:customfield_values:advshipmgr:originzip
    as opposed to the usual
    Code:
    l.settings:product:customfield_values:customfields:originzip
    Is there a way to format the Write_Product_Code function to update these values, or another function that can do so?

    Thanks!

    #2
    can you post your code that gets the value and tries to write it? I'm trying to read between the lines...
    Colin Puttick
    Miva Web Developer @ Glendale Designs

    Comment


      #3
      The value being written would be hand-written based on an conditional, so it would look something like this:
      Code:
      <mvt:if expr="[condition]">
      <mvt:item name="customfields" param="Write_Product_Code(l.settings:product:code, 'originzip', '12345')" />
      </mvt:if>
      In this case, the error message is "Product custom field 'originzip' could not be found", due to the different structure of these variables.

      ------

      If it helps, this is an example of something similar that works to update some normal Miva custom fields that we're trying to replicate:
      Code:
      <mvt:foreach iterator="product" array="all_products:products">
      
          <mvt:if expr="l.settings:product:price LT l.settings:product:base_price">
              <mvt:item name="customfields" param="Write_Product_Code( l.settings:product:code, 'ss_sale-price', l.settings:product:price )" />
          <mvt:else>
              <mvt:item name="customfields" param="Write_Product_Code( l.settings:product:code, 'ss_sale-price', '' )" />
          </mvt:if>
      
          <mvt:if expr="l.settings:product:imagetypes:main">
              <mvt:item name="customfields" param="Write_Product_Code( l.settings:product:code, 'ss_image', l.settings:product:imagetypes:main )" />
          <mvt:else>
              <mvt:item name="customfields" param="Write_Product_Code( l.settings:product:code, 'ss_image', l.settings:product:image )" />
          </mvt:if>
      
      </mvt:foreach>
      Thanks!
      Last edited by darian; 12-17-20, 11:38 AM.

      Comment


        #4
        Originally posted by darian View Post
        The value being written would be hand-written based on an conditional, so it would look something like this:
        Code:
        <mvt:if expr="[condition]">
        <mvt:item name="customfields" param="Write_Product_Code(l.settings:product:code, 'originzip', '12345')" />
        </mvt:if>
        In this case, the error message is "Product custom field 'originzip' could not be found", due to the different structure of these variables.




        [/CODE]

        Thanks!
        Does the 'originzip' field exist when you look at a product? Cause if it doesn't, the Write_Product_Code() function isn't going to work.
        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


          #5
          It is; it's also listed as a custom field that's available for display under Product Display Layout, but the variable & entity is different than other custom fields when looking under the token list (specifically, "advshipmgr" instead of "customfields").
          Code:
          variable: l.settings:product:customfield_values:advshipmgr:originzip
          entity: &mvt:product:customfield_values:advshipmgr:originzip;
          I don't think the Write_Product_Code() function will work as I'm sure that function is explicitly looking for something with the l.settings:product:customfield_values:customfields : structure. But, I didn't want to make that assumption in case it can be written differently for this case or if there's just another function I can use.

          Comment


            #6
            The Write_Product_code() function only cares about a few things:


            l.settings:product:code = identifies, buy code, the product who's custom field needs to be updated

            'originzip' = the literal value of the destinations custom field's code

            '12345' = the variable that contains the contents of what gets placed into the custom field.

            the fact that there is an result of "l.settings:product:customfield_values:advshipmgr: o riginzip" is a function of how the module's creator generated the variable name. (I.e., in a non-standard way. They could have called it anything like: l.settings:what_would_your_mother_say:originzip). Their use of inserting :customfields: into their structure not withstanding. At least AFAIK.)
            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


              #7
              I guess what throws me off with it is that it exists under the Custom Field lists that can be assigned under PROD (and Export Products to Flat File also lists it as a Custom Field). So, I was hoping it could be updated with Write_Product_Code() like everything else on that list. But they are noticeably missing from the Custom Fields under Utility Settings > Custom Fields. /lament

              I might just be stuck with having to Export / Import to update these fields by hand in a spreadsheet instead of something on schedule with conditionals. I was hoping to avoid that, but it might just be how it needs to be done.

              Thanks.

              Comment


                #8
                Custom fields are created and managed by modules. The most common fields are the ones created by Miva's own Custom Fields module, which is designed to make them available to users as a general-purpose tool. The commands such as Write_Product_Code are part of that module, and they work only with the module's own fields.

                The Advanced Shipping Manager (ASM) module creates its own custom fields. The Miva Custom Fields module doesn't know about these, so there's no way for commands like Write_Product_Code to access them. The ASM module may contain some functions that you can call with mvt:do, to achieve the same result; you'll have to contact King Webmaster to find out about that. Otherwise, it can probably be done with some custom template coding, but it would be somewhat complex. It's not something I can just type in here and pass along without taking some time to test it. If you have the budget for an hour or two of custom work, I should be able to hook you up.
                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

                Working...
                X