<?php
require_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;
}
}
?>
magento批量修改价格
最新推荐文章于 2018-08-13 10:45:03 发布