更新时间:2023-11-30 09:39:22
这不起作用,因为您需要当前存储为 admin存储来进行这种操作.
This doesn't work because you need the current store being the admin store for this kind of operation.
要创建特定的商店视图,请使用给定属性的默认值:
To make a specific store view use the default value for a given attribute:
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$product = Mage::getModel('catalog/product')
->load($product_id) // in your case: 1
->setStoreId($store_id) // in your case: 3
->setData($attr, false) // in your case: 'name'
->save();