using an array to update multable databases

da darrenhallinan 12 Jan, 2017
Hello

So Im stock on something here and would appreciate it if someone would be able to help me out

In a nut shell:
I am building a script to update stock across a number of websites.

The idea is that this script runs on completion of an order.

I have got to the point where I need to insert or update the DB tables but the array that I have pulled needs to be modified or duplicated in order to run a DB save multiple times (correct me if I'm wrong)

See attached screen shot of form in the admin area to get an idea of what I'm trying to achieve.

So the output I get is this, which is exactly the info i need (I don't need the virtuemart_order_item_id).

[order_items] => Array
        (
            [0] => Array
                (
                    [virtuemart_order_item_id] => 13
                    [order_item_sku] => TL-MR3220
                    [product_quantity] => 1
                )

            [1] => Array
                (
                    [virtuemart_order_item_id] => 14
                    [order_item_sku] => TL-WR841N
                    [product_quantity] => 1
                )

            [2] => Array
                (
                    [virtuemart_order_item_id] => 15
                    [order_item_sku] => TL-123455677
                    [product_quantity] => 1
                )

            [virtuemart_order_item_id] => 15
        )



So now from that i need to run a DB multi save to deduct the product_quantity where product_sku = order_item_sku

But as I can only use a model id once I need to recreate the array with a different model id.

How would I do that?
This topic is locked and no more replies can be posted.