Announcement

Collapse
No announcement yet.

MM Database - SKU to Code?

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

    MM Database - SKU to Code?

    I am writing an external script (not a module) and I am looking to relate a product in an order (with options) to the sku for that variant.

    so - order contains small red tshirt which is SKU axd123

    I can get the order, items and options.
    But how do I get the sku?

    The sku is assigned to that product, and we are using variant price set by inventory product (for dynamic pricing).

    I am directly accessing the MM database.
    I assume there is something relations between the item/option in the order, and the product on the site?

    Bill
    William Gilligan - Orange Marmalade, Inc.
    www.OrangeMarmaladeinc.com

    #2
    Re: MM Database - SKU to Code?

    There's a utility function, Validate_Attributes_DetermineVariant, that handles this nicely.
    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
      Re: MM Database - SKU to Code?

      Originally posted by Kent Multer View Post
      There's a utility function, Validate_Attributes_DetermineVariant, that handles this nicely.
      I may be missing something - but I see two issues:
      1 - I am _not_ creating a module. I am accessing the database directly (stand alone mivascript).
      2 - I don't see where this access the SQU for an item in an order.
      http://www.mivamerchant.com/assets/a...ff87a27ce8d179

      My research shows the SKU's seem to _only_ be available in the basket - and _not_ in the final order.
      This seems odd to me...

      Bill
      William Gilligan - Orange Marmalade, Inc.
      www.OrangeMarmaladeinc.com

      Comment


        #4
        Re: MM Database - SKU to Code? SOLVED!

        OK - in order to get the SKU into an order, contact miva support and get the variantbasketitem module.
        This module (I have tested it) replaces (when set via the logging tab) the product code for _every item in an order _ with the SKU assigned at the variant level.

        That means that the red small t is now completely different from a green small t.
        Previously, both would have the same product code, but different options.
        Now they have different product codes (SKU) and different options.

        Perfect.
        William Gilligan - Orange Marmalade, Inc.
        www.OrangeMarmaladeinc.com

        Comment


          #5
          Re: MM Database - SKU to Code?

          Product SKUs are stored in a column of the Products table. To find the SKU for a particular size & color shirt, you need to look at the BasketOptions and extract the info for the product attributes and options. With that, you can use Validate_Attributes_DetermineVariant() to find the variant that's associated with that size & color; then you can get the SKU from the Products table. Even if you're not writing a module, the code for that function will probably tell you what you need.
          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


            #6
            Re: MM Database - SKU to Code?

            Originally posted by Kent Multer View Post
            Product SKUs are stored in a column of the Products table. To find the SKU for a particular size & color shirt, you need to look at the BasketOptions and extract the info for the product attributes and options. With that, you can use Validate_Attributes_DetermineVariant() to find the variant that's associated with that size & color; then you can get the SKU from the Products table. Even if you're not writing a module, the code for that function will probably tell you what you need.
            Originally posted by Kent Multer View Post
            Product SKUs are stored in a column of the Products table.
            Hi Kent,
            I had a whole response written to explain the issues when I realized I think we are mis-communicating.

            I am not looking at baskets in any way. Only a final completed and finished order, as it exists in the database.
            The final order does NOT contain a SKU, unless you implement the module Miva offers (or write your own).

            There is no _safe and reliable_ way (as far as I can tell) to convert an order item / order options into a product code with a unique SKU after the fact.

            The key is - as you indicate - to get the sku from the basket and into a table, which is what Miva's module does.
            But without that piece, it simply does not exist.

            B
            William Gilligan - Orange Marmalade, Inc.
            www.OrangeMarmaladeinc.com

            Comment


              #7
              Re: MM Database - SKU to Code?

              OrderOptions, BasketOptions, "you say potato ..." :^) . OrderOptions contain pretty-much the same data as the BasketOptions they were made from. I think both contain the data you need to work backwards and find the attributes.
              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