複数の倉庫の場所を許可するモジュールがあり、これは catalognventory_stock_item テーブルの stock_id フィールドを使用します。
2 つの製品と 4 つの倉庫があるシナリオの場合。各倉庫には、製品 1 が 8 単位、製品 2 が 4 単位ありました。cataloginventory_stock_item テーブルは次のようになります。
item_id | product_id | stock_id | qty
1 | 1 | 1 | 8
2 | 1 | 2 | 8
3 | 1 | 3 | 8
4 | 1 | 4 | 8
5 | 2 | 1 | 4
6 | 2 | 2 | 4
7 | 2 | 3 | 4
8 | 2 | 4 | 4
item_id
= id
product_id = 製品 ID
stock_id = 倉庫 ID
現在、私は現在、このようなスクリプトを使用してプログラムで製品をインポートしています(カットダウンバージョン)
$product = new Mage_Catalog_Model_Product();
$product->setSku('importproduct1');
$product->setName('Import Product 1');
$product->setTypeId('simple');
...
$product->setStockData(array(
'is_in_stock' => 1,
'qty' => 5
));
$product->save();
setStockData メソッドを使用して、必要な配置で数量を適用する方法を見つけるのに苦労しています。
私が試してみました
$product->setStockData(array(
'is_in_stock' => 1,
'qty' => 5
'stock_id' =>1
));
各stock_idに複数の配列を使用する必要があると思いますが、アプローチ方法がわかりません。