magento批量修改价格

来源:互联网 发布:手机域名注册管理局 编辑:程序博客网 时间:2024/06/10 20:15
<?phprequire_once 'app/Mage.php';//echo phpinfo();exit;set_time_limit(0);Mage::app('default');$read = Mage::getSingleton('core/resource')->getConnection('core_read');$row = $read->fetchAll("select p.`entity_id` from `catalog_product_entity` as p, `catalog_product_entity_decimal` as d where p.`entity_id` = d.`entity_id` and d.`attribute_id` =79 and d.`value` not in (0,868,444)");//$products = Mage::getModel('catalog/category')->load(75)->getProductCollection();foreach($row as $val){$product = Mage::getModel('catalog/product')->load($val['entity_id']);$cost = $product->getCost();$price = $product->getPrice();$special_price = $product->getSpecialPrice();if(!empty($cost)){$cost = $cost/6.1;//echo $product->getId() . '----';if(!empty($special_price)){//$special_price = $special_price + 1.5;//$product->setData('special_price', $special_price);if($cost >= $special_price){$price = $cost + 15/6.1;$special_price = $cost + 10/6.1;$product->setData('price', $price);$product->setData('special_price', $special_price);echo $product->getId() . '----' . $special_price . 's----' . $cost."<br>";}}else{if($cost >= $price){$price = $cost + 10/6.1;$product->setData('price', $price);echo $product->getId() . '----' . $price . 'p----' . $cost."<br>";}}//$price = $price + 1.5;//$product->setData('price', $price);$product->save();//exit;}}?>

0 0
原创粉丝点击