“cataloginventory/stock_item_api” set no data on update
-
13-12-2019 - |
Question
I try to create over 4,000 products in a demostore. catalog/product_api
returns the id of the created product ... all fine. Then i call catalog/product_attribute_media_api
with the id of the created product to create a image by base64-content. Even this works too. At the last i try to call cataloginventory/stock_item_api
as update. It's run, i get as result true
, but there is no data visible in the database / adminpanel.
Here the script part:
$arrCurrentStockData = array(
'qty' => '100',
'is_in_stock ' => 1,
'manage_stock ' => 1,
'use_config_manage_stock' => 0,
'min_qty' => 1,
'use_config_min_qty ' => 1,
'min_sale_qty' => 1,
'use_config_min_sale_qty' => 1,
'max_sale_qty' => 10,
'use_config_max_sale_qty' => 1,
'is_qty_decimal' => 0,
'backorders' => 1,
'use_config_backorders' => 1,
'notify_stock_qty' => 10,
'use_config_notify_stock_qty' => 1
);
var_dump(Mage::getModel('cataloginventory/stock_item_api')->update($intProductID,$arrCurrentStockData));
I tried to to this with the regular class cataloginventory/stock_item
- no data. Tried to set data in the creat-call from the product as stock_data
- no data.
I have a clean local installation (1.8.1) without 3rd-party-extensions. What's wrong? Has Anybody a tip? Even now, many , many thanks!
Edit
If i open a product in adminpanel and save it, then write the system data to the cataloginventory_stock_item
-table - funny!
Solution
I solved the problem by run a api-request (soap) like this:
$soapMulticalls = array();
$arrProductsExists = $soap->call($soapSession, 'catalog_product.list');
foreach($arrProductsExists as $arrProduct) {
$soapMulticallDataItem = array(
'catalog_product.update',
array(
$arrProduct['product_id'],
array(
'stock_data' => array(
'qty' => '999',
'is_in_stock' => 1,
'manage_stock' => 1,
'backorders' => 0,
'use_config_backorders' => 0,
'use_config_manage_stock' => 1
)
)
)
);
array_push($soapMulticalls, $soapMulticallDataItem);
}
if (count($soapMulticalls) > 0) {
var_dump($soap->multiCall($soapSession, $soapMulticalls));
}
That's not the perfect way. But: it's work.