Set default product values when adding new product in Magento 1.7

有些话、适合烂在心里 提交于 2019-11-29 11:00:24
....

//$product->save();

$stockItem = Mage::getModel('cataloginventory/stock_item');
$stockItem->assignProduct($product);
$stockItem->setData('is_in_stock', 1);
$stockItem->setData('stock_id', 1);
$stockItem->setData('store_id', 1);
$stockItem->setData('manage_stock', 0);
$stockItem->setData('use_config_manage_stock', 0);
$stockItem->setData('min_sale_qty', 0);
$stockItem->setData('use_config_min_sale_qty', 0);
$stockItem->setData('max_sale_qty', 1000);
$stockItem->setData('use_config_max_sale_qty', 0);

//$stockItem->save();

Read more at http://blog.magentoconnect.us/creating-magento-products-on-the-fly/

It looks like you'll need to work with the actual stock item object which is set as a property on the product object.

See Mage_CatalogInventory_Model_Observer::copyInventoryData()[link] for a reference of the stock item properties.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!