Thứ Năm, 14 tháng 8, 2014

Thay đổi tiền tệ viêt nam trong magento

root/lib/Zend/Locale/Data/vi.xml 
Tìm:
 1.Trong <symbols>
                                     <symbols>
                                    <decimal>.</decimal> 
                                    <group>.</group>
                                    <list>;</list>
………….</symbols>
<!—từ dấu , sửa thành dấu .à định vị tiền 1,000 đ thành 1.000 đ
2.Bạn tìm function roundPrice() trong

app/code/core/Mage/Core/Model/Store.php 

public function roundPrice($price)
    {
        return round($price, 2);
    }
 Sửa lại thành=>
public function roundPrice($price,$roundTo=3)
    {
        return round($price, $roundTo);
    }
3.Tim /lib/zend/Currency.php 

protected $_options = array(
        'position'  => self::STANDARD,
        'script'    => null,
        'format'    => null,
        'display'   => self::NO_SYMBOL,
        'precision' => 2,
        'name'      => null,
        'currency'  => null,
        'symbol'    => null
    );
Thay bằng:
protected $_options = array(
        'position'  => self::STANDARD,
        'script'    => null,
        'format'    => null,
        'display'   => self::NO_SYMBOL,
        'precision' => 3,
        'name'      => null,
        'currency'  => null,
        'symbol'    => null
    );

4.Mở file Currency.php trong app\code\core\Mage\Directory\Mode
Tìm:

public function format($price, $options=array(), $includeContainer = true, $addBrackets = false)
    {
        return $this->formatPrecision($price, 2, $options, $includeContainer, $addBrackets);
    }
ð  Sửa lại thành số 3
public function format($price, $options = array(), $includeContainer = true, $addBrackets = false)
    {
        return $this->formatPrecision($price, 3, $options, $includeContainer, $addBrackets);
    }
5.Sửa định vị tiền hiển thị danh sách sản phẩm trong admin. Tìm

/js\varien\js.js: dòng 254:
    var r = (j ? i.substr(0, j) + groupSymbol : "") + i.substr(j).replace(re, "$1" + groupSymbol) + (precision ? decimalSymbol + Math.abs(price - i).toFixed(precision).replace(/-/, 0).slice(2) : "")
Thêm +'0' vào cuối dòng:
    var r = (j ? i.substr(0, j) + groupSymbol : "") + i.substr(j).replace(re, "$1" + groupSymbol) + (precision ? decimalSymbol + Math.abs(price - i).toFixed(precision).replace(/-/, 0).slice(2) : "")+'0'

vào trang admin xóa cache và xem kết quả

Hiên thị tổng số tiền trong giỏ hàng

Để hiển thị tổng số tiền hiện tại trong giỏ hàng echo đoạn code dưới
<?php echo $price=number_format(Mage::getSingleton('checkout/session')->getQuote()->getSubtotal(),3);?>
khi hiển thị số tiền hàng đơn vị có dấu , (phẩy) ví dụ: 1,123.000 đ =>1.1.23.000 đ mới đúng
thay đổi thành
<?php echo $price = number_format(Mage::getSingleton('checkout/session')->getQuote()->getSubtotal(), 3, ".", ".");

=>”.”,”.” là dấu chấm của hàng đơn vị

. Định dạng hiển thị thời gian đặt hàng theo dd/mm/yyyy HH:mm

. Định dạng hiển thị thời gian  đặt hàng theo dd/mm/yyyy HH:mm
Để hiển thị thời gian đặt hàng theo mẫu ví dụ: 17/10/2014 13:05
Dùng funtion formatDate();
Trong file history.phtml là danh sách đơn đặt hàng tim chổ ngày đã đặt
<?php echo $this->formatDate($_order->getCreatedAtStoreDate()) ?>
Ta thay thành:
<?php echo $this->formatDate($_order->getCreatedAtStoreDate(),'short',true) ?>

Thứ Ba, 8 tháng 7, 2014

Xóa block trong 1 trang (How to remove block into a page of magento)

Xóa block trong 1 trang
 (How to remove block into a page of magento/Adding A CSS Class To The Body tag)

ví dụ Trong trang cutomer muốn không hiển thị my cart / giỏ hàng thì làm như sau:
 Mở file customer.xml layout
bỏ đoạn code dưới vào

 <remove name="cart_sidebar"/>

 nếu muốn dùng chung cho tất cả các trang thuộc customer thì bỏ vào trong thẻ
<default>
  <remove name="cart_sidebar"/>
</default>

.....

Thêm tên class vào body trong magento (How to add class into body in magento)

Thêm tên class vào <body> trong magento (How to add class into body in magento)

Muốn thêm tên class vào body của 1 trang nào đó ví dụ trang customer.
mở file layout : customer.xml 
chèn vào đoạn code :


 <reference name="root">
            <action method="addBodyClass"><classname>customers-profile</classname></action>
  </reference>


trong đó  customers-profile: là tên class mới thêm vào <body>