Clean special price when special price equal to price

class Mage_Shell_CleanSpcialPrice extends Mage_Shell_Abstract
{


    /**
     * Run script
     *
     */
    public function run()
    {
    	
    	$collection = Mage::getModel('catalog/product')->getCollection()
    	//->addAttributeToFilter('type_id', 'configurable')
    	->addAttributeToSelect(array('name', 'price', 'special_price'), 'left')
    	->addAttributeToFilter('status',1);
    	foreach ($collection as $_product) {
    		var_dump('sp_price:' . $_product->getData('special_price'));
    		var_dump('org_price:' . $_product->getData('price'));
    		if ($_product->getData('special_price') ==  $_product->getData('price')) {
    			$_product->setSpecialPrice('')
					        ->setSpecialToDate('')
					        ->setSpecialFromDate('')
					        ->save();
    			var_dump('clean ' . $_product->getSku() . ' special price');
    		} else {
    			var_dump('no need to clean.'.$_product->getSku().' special price');
    		}
    		
    	}
    	
    	//do priec index
    	var_dump('do price index');
    	$process = Mage::getModel('index/process')->load(2);
    	$process->reindexAll();
    	$process = Mage::getModel('index/process')->load(4);
    	$process->reindexAll();
    	var_dump('finished!');
    }
}

$shell = new Mage_Shell_CleanSpcialPrice();
$shell->run();

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值