Set default product values when adding new product in Magento 1.7

前端 未结 2 1499
无人及你
无人及你 2020-12-19 10:47

I have created an Observer.php for the event catalog_product_new_action



        
相关标签:
2条回答
  • 2020-12-19 11:39

    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.

    0 讨论(0)
  • 2020-12-19 11:46
    ....
    
    //$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/

    0 讨论(0)
提交回复
热议问题