The method calcProductPriceRule in Mage_CatalogRule_Model_Rule can be used to apply product rules on a specific (custom) price. Unfortunately, this method does not apply the rules according to their priority. In my opinion that is because the method getRulesFromProduct() within the corresponding Resource-Model-Class does not add a "order by" condition.

Does anyone know if this is by purpose or just a bug?

PS: We do need to manipulate the price based on complex configuration options - that is why we want to call the calcProductPriceRule-Method.


Guess I solved it by modify

public function getRulesFromProduct($date, $websiteId, $customerGroupId, $productId)
    $adapter = $this->_getReadAdapter();
    if (is_string($date)) {
        $date = strtotime($date);
    $select = $adapter->select()
        ->where('website_id = ?', $websiteId)
        ->where('customer_group_id = ?', $customerGroupId)
        ->where('product_id = ?', $productId)
        ->where('from_time = 0 or from_time < ?', $date)
        ->where('to_time = 0 or to_time > ?', $date)

    return $adapter->fetchAll($select);

adding ->order('sort_order');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.