Magento: how to get the price of a product with catalog rules applied

前端 未结 4 1064
清歌不尽
清歌不尽 2020-12-28 17:51

I\'m developing a script (external to Magento, not a module) which aims to output a text list of all available products, their prices and some other attributes. However, cat

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-28 18:19

    This helped me in this issue: http://www.magentocommerce.com/boards/viewthread/176883/ . Jernej's solution seems plausible, but it does not handle rules that Overwrite other rules by using 'stop processing' and therefore can apply more than one rule.

    $original_price = $_product->getPrice();
    $store_id = 1; // Use the default store
    $discounted_price = Mage::getResourceModel('catalogrule/rule')->getRulePrice( 
                            Mage::app()->getLocale()->storeTimeStamp($store_id), 
                            Mage::app()->getStore($store_id)->getWebsiteId(), 
                            Mage::getSingleton('customer/session')->getCustomerGroupId(), 
                            $_product->getId());
    
    // if the product isn't discounted then default back to the original price
    if ($discounted_price===false) {
        $discounted_price=$original_price;
    }
    

提交回复
热议问题