1). get_currentuserinfo(); 此函数将当前登录用户信息赋给全局变量$current_user以及一些单独的用户信息全局变量例如$display_name, $user_email等。 如下: <?php global $current_user, $display_name…
April 29, 2015
Magento 批量修改属性 Magento Bulk update attributes
As we’re updating product attributes, a traditional approach is as follows:
<?php //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->setSku($newSku); $product->setName('New product name'); $product->setShortDescription(addslashes("short description here.")); $product->setDescription(addslashes("long description")); //Perform Save $product->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.