I need to know how to add a data range (from and a to date) for tier prices in magento, which will make the prices only appear within the given date range.
I am new to magento, so any guidance will be great help.
thanks in advance.
Since this is not possible by default within, magento what you could try is :
Create 2 fields in Admin -> Catalog -> Attribute for tierprice_to_date
and tierprice_from_date
and add it to price
group in your Attribute Sets.
In /app/design/frontend/base/default/template/catalog/product/view.phtml
if(date between tierprice_from_date and tierprice_to_date){
echo $this->getTierPriceHtml();
}
Then create a custom module with observer that check the price when items are added to cart using event 'sales_quote_add_item'
:
Create: app/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>
Create: app/code/local/MageIgniter/TierPriceDateRange/Model/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;
}
Create: app/etc/modules/MageIgniter_TierPriceDateRange.xml
<?xml version="1.0"?>
<config>
<modules>
<MageIgniter_TierPriceDateRange>
<active>true</active>
<codePool>local</codePool>
</MageIgniter_TierPriceDateRange>
</modules>
</config>
Then clear cache, if any.
This is not possible within the standard Magento configuration. You would have to build (or have it build for you) a custom module to make this possible.
See also http://www.magentocommerce.com/boards/viewthread/230679/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With