我可以通过编程方式添加具有特定ID的产品吗?

时间:2012-04-17 03:07:07

标签: magento

如何使用指定的product_id / entity_id添加新产品?

$newprod = new Mage_Catalog_Model_Product();
$newprod->setProductId( 100 ); // how do i make this work
$newprod->setSku(... );

1 个答案:

答案 0 :(得分:0)

你可以尝试这样的事情:

$product = Mage::getModel('catalog/product')->load($desiredId);

if(!$product){ //here also might be something like $product->getSku()
$product->set.......//set required fields here
$product->setEntityId($desiredId); //we won't mess up things, because product with desired id et not exists
$product->save()
}