Fixed: error not show the label sale on category list product, detail product, the sm extension when apply promotions

Issue:

Error not show the label sale on category list product, detail product, the sm extension when apply promotions in admin

Solution:

1. In category list products

Please go to in app/design/frontend/default/sm_theme/template/catalog/product/list.phtml and find:

            $now = date("Y-m-d");
            $newsFrom= substr($_product->getData('news_from_date'),0,10);
            $newsTo=  substr($_product->getData('news_to_date'),0,10);
            $specialprice = Mage::getModel('catalog/product')->load($_product->getId())->getSpecialPrice();
            $price = Mage::getModel('catalog/product')->load($_product->getId())->getPrice();
            $saleoff= round(($price - $specialprice)/$price*100) ;

=> change to:

            $now = date("Y-m-d");
            $newsFrom= substr($_product->getData('news_from_date'),0,10);
            $newsTo=  substr($_product->getData('news_to_date'),0,10);
            $specialprice = Mage::getModel('catalog/product')->load($_product->getId())->getSpecialPrice();
            //echo $specialprice . '-hau<br/>';
            $price = Mage::getModel('catalog/product')->load($_product->getId())->getPrice();
            if ($specialprice == '' ) {
                $store_id = Mage::app()->getStore()->getStoreId();
                $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());
                $specialprice = $discounted_price;

            }

            $saleoff= round(($price - $specialprice)/$price*100) ;

2. In detail product

Please go to \app\design\frontend\default\sm_theme\template\catalog\product\view\media.phtml and find:

    $now = date("Y-m-d");
    $newsFrom= substr($_product->getData('news_from_date'),0,10);
    $newsTo=  substr($_product->getData('news_to_date'),0,10);
    $specialprice = Mage::getModel('catalog/product')->load($_product->getId())->getSpecialPrice();

=> change to:

    $now = date("Y-m-d");
    $newsFrom= substr($_product->getData('news_from_date'),0,10);
    $newsTo=  substr($_product->getData('news_to_date'),0,10);
    $specialprice = Mage::getModel('catalog/product')->load($_product->getId())->getSpecialPrice();
    //echo $specialprice . '-hau<br/>';
    $price = Mage::getModel('catalog/product')->load($_product->getId())->getPrice();
    if ($specialprice == '' ) {
        $store_id = Mage::app()->getStore()->getStoreId();
        $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());
        $specialprice = $discounted_price;

    }

    $saleoff= round(($price - $specialprice)/$price*100) ;

3. In these extensions: sm tablisting, sm slider, sm slideshow….

Please refer use the code in :

\app\design\frontend\default\sm_theme\template\sm\slider\slider.phtml

\app\design\frontend\default\sm_theme\template\sm\tablisting\default_items.phtml

=> the code:

$now = date("Y-m-d");
$newsFrom= substr($_product->getData('news_from_date'),0,10);
$newsTo=  substr($_product->getData('news_to_date'),0,10);
$specialprice = Mage::getModel('catalog/product')->load($_product->getId())->getSpecialPrice();
//echo $specialprice . '-hau<br/>';
$price = Mage::getModel('catalog/product')->load($_product->getId())->getPrice();
if ($specialprice == '' ) {
$store_id = Mage::app()->getStore()->getStoreId();
$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());
$specialprice = $discounted_price;
}

$saleoff= round(($price - $specialprice)/$price*100) ;

Thanks!