magento - Catalog Price Rules applied to special_price -
first question on stackoverflow...i excited :)
currently magento using special price if lower applied catalog price rule. if catalog price rule makes product cheaper special price, catalog price rule defines shop price.
i looking elegant way make catalog price rules applied special price (additionally). maybe there store config it? maybe there neat observer way?
thank much!
please note answer works old magento versions < 1.9. newer magento versions please check @josef's answer.
i sad say, solved first real stackoverflow question own:
- goto
mage_catalogrule_model_resource_rule
- goto method
_getruleproductsstmt
add initial select of method before first original
->from
:$select->from(null, array('default_price' => new zend_db_expr("case when pp_default_special.value pp_default_special.value else pp_default_normal.value end")));
add after first join() has happened
$specialpriceattr = mage::getsingleton('eav/config') ->getattribute(mage_catalog_model_product::entity, 'special_price'); $specialpricetable = $specialpriceattr->getbackend()->gettable(); $specialpriceattributeid= $specialpriceattr->getid(); $joincondition2 = '%1$s.entity_id=rp.product_id , (%1$s.attribute_id=' . $specialpriceattributeid . ') , %1$s.store_id=%2$s'; $select->join( array('pp_default_special'=>$specialpricetable), sprintf($joincondition2, 'pp_default_special', mage_core_model_app::admin_store_id), null );
how works:
when catalog price rule applied (via backend or cron) db table catalogrule_product_price
populated. above sql magic joins special_price
(if exists) resultset column default_value
, if no special_price found regular price gets joined.
the result has been checked , working.
have fun! , dont hack core!
Comments
Post a Comment