Announcement

Collapse
No announcement yet.

use array to get only some of the product custom fields?

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

    use array to get only some of the product custom fields?

    Since the following grabs ALL the custom product fields for a particular product
    Code:
    <mvt:item name="customfields" param="Read_Product_ID(l.settings:product:id, '', l.settings:test )" />
    Can I do something like this:

    Code:
    <mvt:item name="customfields" param="Read_Product_ID(l.settings:product:id, ('MAP','DISCONTD','UPC','UOM','COLOR'), l.settings:test )" />
    Code:
    <mvt:item name="customfields" param="Read_Product_ID(l.settings:product:id, 'MAP,DISCONTD,UPC,UOM,COLOR', l.settings:test )" />
    to get only a few of the fields?

    My examples don't work, what is the correct sytax?

    *** Better yet, is there a way to use custom field groups to grab all the customfields that belong to a group and display them?***
    Last edited by kayakbabe; 02-04-17, 12:16 AM.

    #2
    I found the better way after digging through the api and finding something that had no documentation but looked like it might work.

    <mvt:do file="g.Module_Root $ '/modules/util/customfld.mvc'" name="l.success" value="ProductFieldAndValueList_Load_Group(product id,group id, var)" />

    I found I also needed to use group load code... so I ended up with this:

    Code:
    <mvt:do file="g.Module_Root $ '/modules/util/customfld.mvc'" name="l.success" value="Group_Load_Code('errata',l.settings:ke_group)" />
    <mvt:do file="g.Module_Root $ '/modules/util/customfld.mvc'" name="l.success" value="ProductFieldAndValueList_Load_Group(l.settings:product:id,l.settings:ke_group:id, l.settings:test)" />
    It sure would be nice and logical if I could use the code instead of the id that way this will port across dev to live sites more easily.
    A lot of the other api things allow usage of the code or the id.

    ??? is this being depreciated since it doesn't have any documentation in the api search on thew website, and it isn't listed in the pdf? Is this safe to use? Will it disappear in a future update???
    Last edited by kayakbabe; 02-04-17, 01:49 AM.

    Comment


      #3
      If:

      <mvt:item name="customfields" param="Read_Product_ID(l.settings:product:id, '', l.settings:test )" />

      Gets all the custom fields, why not just use that? Unless your talking about hundreds of custom fields, or you have a huge amount of traffic, I don't think it will add too much to the load on the system.
      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


        #4
        It isn't about that, though that is super important. it is about easily updatable and readable code for the next guy who comes along and has to do development on the store.
        <mvt:item name="customfields" param="Read_Product_ID(l.settings:product:id, ('MAP','DISCONTD','UPC','UOM','COLOR'), l.settings:test )" /> then I could add a field super easy.
        <mvt:item name="customfields" param="Read_Product_ID(l.settings:product:id, ('MAP','DISCONTD','UPC','UOM','COLOR','FLAVOR'), l.settings:test )" /> versus doing a loop and testing for each one.. which is more code.. more work to update. just plain silly if you ask me since many of the other function do it. I am sure Miva has an object they call that will get the id's from the codes. I would even bet money in vegas that is just one line added to the function.

        and like you mentioned... for a high traffic store, it would matter a lot doing it then old inefficient long way you suggest and for a store with lots of fields it would matter a lot too.

        and for me.. it is all the above issues.

        Comment


          #5
          I do think though.. that the way I Figured it out is very similar to what I really wish would happen.
          Because now, I only have to add the custom field to a custom field group that I defined on the utilities page.

          So now, a coder doesn't even have to modify it, I can tell our product manager to go add it in the utilities. If the marketing department wants something like flavor added to the display of the products, he just goes to the group and includes the custom product field in that group.

          note: my html output loop on the product display checks first and will skip output put if a custom field has no value.

          Comment


            #6
            Hmm, I tried this:

            Code:
             
             <mvt:do file="g.Module_Root $ '/modules/util/customfld.mvc'" name="l.success" value="Group_Load_Code('errata',l.settings:ke_group)" /> <mvt:do file="g.Module_Root $ '/modules/util/customfld.mvc'" name="l.success" value="ProductFieldAndValueList_Load_Group(l.settings:product:id,l.settings:ke_group:id, l.settings:test)" />
            But I get an array of ALL customfields...
            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
              You can pass in a comma seperated list of fields you want to grab like this:

              Code:
               <mvt:item name="customfields" param="Read_Category_Code( 'teams', 'dodgers, angels', g.Custom_Fields )" />
              It will then return them like this:
              &mvte:global:Custom_Fields:dodgers;
              &mvte:global:Custom_Fields:angels;
              Brennan Heyde
              VP Product
              Miva, Inc.
              [email protected]
              https://www.miva.com

              Comment


                #8
                yea, i know...was looking to do them by "group" idea so the customer can add them to the group and not have to change the code...it would just appear in my "group-array".
                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


                  #9
                  Bruce,

                  Your code seems to be ok (code below works on my site).

                  I'm sure that you've probably already verified, but my checklist would be:
                  Is the group name 'errata' match the custom field group name? Uppercase/lowercase issues? Was the value returned/assigned to l.settings:ke_group:id ? Are only required fields assigned to the custom field group? Is the created group visible as a separate tab on the product configuration page?
                  Code:
                            <mvt:do file="g.Module_Root $ '/modules/util/customfld.mvc'" name="l.success" value="Group_Load_Code('product_specs',l.settings:cf_group)" />
                          <mvt:do file="g.Module_Root $ '/modules/util/customfld.mvc'" name="l.success" value="ProductFieldAndValueList_Load_Group(l.settings:product:id,l.settings:cf_group:id, l.settings:custom_field_data)" />
                  
                          <mvt:foreach iterator="cfs" array="custom_field_data">
                                  &mvt:cfs:code; = &mvt:cfs:value;
                          </mvt:foreach>

                  Comment

                  Working...
                  X