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:

  1. goto mage_catalogrule_model_resource_rule
  2. goto method _getruleproductsstmt
  3. 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")));

  4. 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

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -