Magento 批量修改属性 Magento Bulk update attributes

As we’re updating product attributes, a traditional approach is as follows:

//Load the Product
$product = Mage::getModel('catalog/product')->load($product_id)); //By ID
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $oldSku);//By SKU
//Update product attributes via Setters
$product->setName('New product name');
$product->setShortDescription(addslashes("short description here."));
$product->setDescription(addslashes("long description"));
//Perform Save

$product = Mage::getModel('catalog/product')->load(1);
$product->setName('Some Random Name');
$product->getResource()->saveAttribute($product, 'name');

please review the following as another reference: Magento getSingleton() vs getModel() issue

— Update —

Double check the array syntax for the attributes being passed.

array("sku" => $data['sku'], 'price' => $data['price']), 





Add a Comment

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.