Announcement

Collapse
No announcement yet.

Rest API for Product Variant Specific Pricing

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

    Rest API for Product Variant Specific Pricing

    Hello

    Our PHP has to be updated on the miva server in which I will loose my database connection to check to see if a product variant is set up for Specific Pricing. I have an automated price update that updates all products on my miva site but some of our products are set up using a product variant using the Specific Pricing Option.

    I do not see using the Rest call ProductVariantList_Load_Product to see if this option is enabled.

    I check it with this select statement

    #This qry checks to see if there is a specific pricing product variant
    $ProdVarQry = "Select * From s01_ProductVariantPricing Where s01_ProductVariantPricing.product_id = '$ParentProdId' and method = 1"

    I need to check it to make sure that it is set up this way because I send the Function = 'Provision_Store' with an xml payload to update the specific pricing

    PRodVarPricing.JPG​​​






    if($ParentProdCode -eq 'Unit' -Or $ParentProdCode -eq 'Quantity' -Or $ParentProdCode -eq 'UM' ){
    $AttBuild += "<Attribute_Option attribute_code='$ParentProdCode' option_code='$Unit' />"
    }
    Else{
    $AttBuild += "<Attribute_Option attribute_code='$ParentProdCode' option_code='$code' />"
    }


    #Ending for ForEach on $dataSetPPID
    }



    $body = @{
    Store_Code = $storeCode
    Function = 'Provision_Store'
    xml = "<ProductVariant_Update product_code=$ProdVar>
    <Options>
    $AttBuild
    </Options>
    <ProductVariantPricing>
    <Method>specific</Method>
    <Price>$ProductsPrice</Price>
    <Weight>$UnitWeight</Weight>
    </ProductVariantPricing>
    </ProductVariant_Update>"
    }

    if ( $includeTimestamp ){
    $body["Miva_Request_Timestamp"] = [DateTimeOffset]::Now.ToUnixTimeSeconds()
    }


    I need a solution for this check since I am loosing my DB connection.

    #2
    In order to get that data you would need to run the ProductVariantPricing_Load function but it has not been whitelisted for the API yet. I will have this added as a feature request and link this post to the request so that it can be updated.

    A workaround until the function can be whitelisted could be storing the data in a product custom field on the variant. This way it will be available using the productlist_load_query function.
    Nicholas Adkins
    Technical Training Specialist / Miva, Inc.
    [email protected]
    https://www.miva.com/mivalearn

    Comment


      #3
      Hi Nicholas,
      how long will it take to get the feature added?

      Also can you elaborate on what data you are referring to in to storing in the custom field? I need to check with the variant is set as what the screenshot shows in the above post. Set as a specific price on the variant radio button 2. When that option is selected its value is set to a 1 on the column attribute method in the table s01_ProductVariantPricing.

      Comment


        #4
        Hello, I don't have a timeline yet but will inquire further. What is the timing on your Database access change?

        As for the workaround, you can create a custom product field called variantPricing then on using a feed in Miva template code can be used to check the pricing option and update the custom field. The feed can be set up to run at an interval of your choosing to make sure that the custom field is updated.

        I will write up a snippet that you can add to a feed template to get this started.

        Once the custom field is populated you can do the productlist_load_query and add the ondemand column for custom fields and check to see what pricing method the variant is using.
        Nicholas Adkins
        Technical Training Specialist / Miva, Inc.
        [email protected]
        https://www.miva.com/mivalearn

        Comment

        Working...
        X