关于睿艾科技

企业级电子商务及供应链解决方案


magento -- 修改所有商品的价格为原来的1.2倍示例

新闻添加时间:2017-07-10 8:32:07

  1. $collection = Mage::getResourceModel(’catalog/product_collection’)->load();  
  2. foreach($collection as $items){  
  3.    $product = Mage::getModel(’catalog/product’)->load($items->getId());  
  4.    $product->setPrice(round($product->getPrice()*1.2));  
  5.     if($product->getSpecialPrice()){  
  6.        $product->setSpecialPrice(round($product->getSpecialPrice()*1.2));  
  7.     }  
  8.    $product->save();              
  9. }  换成
  1. $collection = Mage::getResourceModel(’catalog/product_collection’)->load();  
  2. foreach($collection as $items){  
  3.    $product = Mage::getModel(’catalog/product’)->load($items->getId());  
  4.    $product->setPrice(round($product->getPrice()*1.2));  
  5.     if($product->getSpecialPrice()){  
  6.        $product->setSpecialPrice(round($product->getSpecialPrice()*1.2));  
  7.     }  
  8.    $product->save();              
  9. }