2013-01-23 24 views

Trả lời

6

Do đây là không thể theo mặc định bên trong, magento những gì bạn có thể thử là:

Tạo 2 trường trong Admin -> Catalogue -> Thuộc tính cho tierprice_to_datetierprice_from_date và thêm nó vào price nhóm trong Bộ thuộc tính của bạn.

Trong /app/design/frontend/base/default/template/catalog/product/view.phtml

if(date between tierprice_from_date and tierprice_to_date){ 
    echo $this->getTierPriceHtml(); 
} 

Sau đó tạo một module tùy chỉnh với người quan sát rằng kiểm tra giá khi các mặt hàng được thêm vào giỏ hàng sử dụng sự kiện 'sales_quote_add_item':

Tạo: ứng dụng/code/local/MageIgniter/TierPriceDateRange/etc/config.xml

<?xml version="1.0"?> 
<config> 
    <modules> 
     <MageIgniter_TierPriceDateRange> 
      <version>1.0.1</version> 
     </MageIgniter_TierPriceDateRange> 
    </modules> 

    <global> 
     <models> 
      <tierpricedaterange> 
       <class>MageIgniter_TierPriceDateRange_Model</class> 
      </tierpricedaterange> 
     </models> 
     <events> 
      <sales_quote_add_item> 
       <observers> 
        <tierpricedaterange_observer> 
         <type>singleton</type> 
         <class>tierpricedaterange/observer</class> 
         <method>updatePrice</method> 
        </tierpricedaterange_observer> 
       </observers> 
      </sales_quote_add_item> 
     </events> 
    </global> 
</config> 

Tạo: ứng dụng/code/local/MageIgniter/TierPriceDa teRange/mẫu/Observer.php

class MageIgniter_TierPriceDateRange_Model_Observer 
{ 
    public function updatePrice($observer) { 
    if(date NOT between tierprice_from_date and tierprice_to_date){ 
     $cartItem = $observer->getEvent()->getQuoteItem(); 
     // check if a tier price was apply and change it back to the original price (none tier price) 
     $product = Mage::getModule('catalog/product')->load($product->getId()); 

     if($cartItem->getPrice() == $product->getTierPrice($cartItem->getQty())){ 
      $new_price = $product->getPrice(); 
      $product->setOriginalCustomPrice($new_price); 
      $product->save(); 
     } 
    } 
    return $this; 
} 

Tạo: app/etc/modules/MageIgniter_TierPriceDateRange.xml

<?xml version="1.0"?> 
    <config> 
      <modules> 
        <MageIgniter_TierPriceDateRange> 
          <active>true</active> 
          <codePool>local</codePool> 
        </MageIgniter_TierPriceDateRange> 
      </modules> 
    </config> 

Sau đó, rõ ràng bộ nhớ cache, nếu có.

+0

Tôi khuyên bạn nên sử dụng hàm 'isStoreDateInInterval'. Cách sử dụng: 'Mage :: app() -> getLocale() -> isStoreDateInInterval (null, tierprice_from_date, tierprice_to_date' – Ian

+0

bạn có thể cho tôi biết làm thế nào tôi có thể gán các thuộc tính mới cho từng nhóm khách hàng trong phần giá tầng. dữ liệu cho từng nhóm khách hàng –

+0

@RohitGoel Xem http://stackoverflow.com/questions/18241595/how-do-you-add-custom-attributes-to-customer-groups-in-magento –

2

Điều này là không thể trong cấu hình Magento chuẩn. Bạn sẽ phải xây dựng (hoặc có nó xây dựng cho bạn) một mô-đun tùy chỉnh để làm cho điều này có thể.

cũng Xem http://www.magentocommerce.com/boards/viewthread/230679/

+0

có, tôi muốn được trợ giúp tạo mô-đun. thanks anyways :) –

+0

bạn có thể vui lòng cho tôi biết làm thế nào tôi có thể gán các thuộc tính mới cho từng nhóm khách hàng trong phần giá tầng. Tôi cần phải thêm dữ liệu khác nhau cho từng nhóm khách hàng. –

Các vấn đề liên quan