Announcement

Collapse
No announcement yet.

writing product custom field isn't working. what am i doing wrong?

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

    writing product custom field isn't working. what am i doing wrong?

    I have this inside a loop of products that reside in the array named record.
    I get output for &mvt:record:id; and &mvt:record:code so i know my loop is working.
    Also I get &mvt:record:customfield:product_flag; and it definitely outputs SALE
    I checked by looking in the database and the contents of the product_flag is SALE no spaces before or after or anything like that.


    What I am trying to do is unset sale to be null.
    I can't seem to get rid of SALE on these products. I have tried Write_Product_Id and also Write_Product_Code

    Code:
        <mvt:if expr="(l.settings:record:customfield:product_flag EQ 'SALE')"> <BR>-  SALE FLAG YES  --- code: &mvt:record:code; (&mvt:record:id;)flag: &mvt:record:customfield:product_flag;<BR>
            <mvt:comment>remove sale flag </mvt:comment>
            <mvt:item name="customfields" param="Write_Product_ID( l.settings:record:id, 'product_flag', '')" />
            <mvt:else>
                 .
        </mvt:if>
    The . is so I can easily see that the if else is working. It's only there for debugging purposes.
    Last edited by kayakbabe; 09-01-18, 06:17 PM.

    #2
    As written, this will change the value of the custom field in the DB, but it won't change the value of the variable, l.settings:record:customfield:product_flag. You'll need a second mvt:assign to do that. Also, I don't know exactly what you've stored in "record;" maybe the :id value is not the same as the product ID?
    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


      #3
      Off the top of my head, a positive value may need to be present to write to the field. A quick idea to try (if you haven't already): two actually, use a space in between the single quotes or use ascii code expression for the 'space' instead of the literal. If that doesn't work, does writing anything to that field work in this snippet?

      Scott
      Need to offer Shipping Insurance?
      Interactive Design Solutions https://www.myids.net
      MivaMerchant Business Partner | Certified MivaMerchant Web Developer
      Competitive Rates, Custom Modules and Integrations, Store Integration
      AutoBaskets|Advanced Waitlist Integration|Ask about Shipping Insurance Integration
      My T-shirt Collection is mostly MivaCon T-shirts!!

      Comment


        #4
        Um, ya, I think Kent has it right. I suggest doing a "read_ " after the IF block to check for the change in 'product_flag.'

        Scott
        Need to offer Shipping Insurance?
        Interactive Design Solutions https://www.myids.net
        MivaMerchant Business Partner | Certified MivaMerchant Web Developer
        Competitive Rates, Custom Modules and Integrations, Store Integration
        AutoBaskets|Advanced Waitlist Integration|Ask about Shipping Insurance Integration
        My T-shirt Collection is mostly MivaCon T-shirts!!

        Comment


          #5
          This maybe what Kent and Scott where getting at, but you might want:

          <mvt:assign name="g.thisIsNull" value="''"/>

          and then
          <mvt:item name="customfields" param="Write_Product_ID( l.settings:record:id, 'product_flag', g.thisIsNull)" />
          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


            #6
            what I really need is to just delete it all together. I saw some posts by brennan but i'm still not 100% sure if... when you write an empty value like g.thisIsNull to a product custom field does miva delete it from the product custom field table?

            I see by playing with the store admin that is how the admin for product custom fields works. I need to emulate that to set and remove a custom field value by what category products belong to.

            (the product flags in the levels readytheme). I have bestsellers (HOT), new, and sale flags. I am wanting to automate the flags, to speed up data entry on thousands of products.

            Comment


              #7
              I can attest to the fact that the code above works...have used it before.
              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


                #8
                Thanks Bruce! It did work.

                Comment

                Working...
                X