Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update "inventory_level" of product by sku id in Bigcommerce?

I am trying to update the inventory level of a products but unfortunately not getting success.Here is my code. I want to update product's "inventory_level" but enable to do so..

<?php

require "bigcommerce.php";
use Bigcommerce\Api\Client as Bigcommerce;


Bigcommerce::configure(array(
    'store_url' => 'https://store-nos85a.mybigcommerce.com/',
    'username' => 'admin',
    'api_key' => '4b7c4bba19f290a728e00be6ae7133cda71f477b'
    ));

Bigcommerce::setCipher('RC4-SHA');
Bigcommerce::verifyPeer(false);
            $product = Bigcommerce::getProduct(76); 
            print_r($product->skus);
                       foreach($product->skus as $sku)
                        {
                           
                            if($sku->id==5)
                                {
                              $fields = array("inventory_level"=>112);
                              Bigcommerce::updateProduct(76,$fields);
                                }
                            echo "id :  ".$sku->id;
                            echo " Invntory Level: ".$sku->inventory_level."<br/>";
                            echo " SKU : ".$sku->sku."<br/>";
                           
                        }
                                                    
           
?>

Here Bigcommerce::updateProduct(76,$field); is not working.

like image 880
Jinank Thakker Avatar asked Oct 09 '13 13:10

Jinank Thakker


People also ask

Can I update SKU inventory and dimensions without exporting/importing?

Exporting SKUs is similar to exporting products. To get started, go to Products › Export Product SKUs and select the SKU Inventory Management template. Can I update SKU inventory and dimensions without exporting/importing all of my products? Yes. Product SKUs can be exported and imported using the SKU Inventory Management template.

What is inventory tracking in BigCommerce?

In BigCommerce, inventory tracking can refer to many things, including: maintaining an accurate count of how many of each of your products are available for purchase sending low stock alerts / notifications to yourself or your suppliers communicating stock levels and product availability to your shoppers

How do I See and update stock levels in my store?

If your store is using the Multi-Channel Product List, click on a product row to see and update stock levels. Stock for multiple simple products can be updated at the same time using the Bulk Edit action in the control panel.

How to update/modify the stock or inventory in WooCommerce?

The import-export plugin offers two methods for updating/modifying the stock or inventory in WooCommerce. Let’s walk through the inventory updating methods. Method 1: Editing the respective columns of the CSV/XML before import. In the CSV column header for product stock, update the stock value for products that are to be updated.


1 Answers

No need to download ALL products, why not retrieve JUST the product that has the sku you need?

GET: /api/v2/products?sku=sku-that-I'm-interested-in

parse the response for the id (that's the product ID for the product with that SKU)

Then do a PUT using that product ID.

like image 146
Memotronics Avatar answered Nov 14 '22 23:11

Memotronics