views:

59

answers:

2

I am adding a simple Product in magento, in which I want to set the following, along with others:-

  1. Special Price
  2. Special Price From Date
  3. Special Price To date

The problem seems to be the #2 & #3 points. I have been successful in setting the #1 point, but I need help in solving the issues with the last 2 points.

I have tried using the following two methods for #2 point:-

  1. setData()
  2. setSpecialFromDate()

But neither of the above 2 methods had worked.
Same case goes for the #3 point.

Please if anybody can help, it is really appreciated.

+1  A: 

At last after a day's wastage, I finally made it. Use the code below to make it work:-

<?php
// Both the Start & End Dates must be in MySQL DB Format
$startDate = '2010-06-30';
$endDate = '2010-09-30';

// Creates the Product object, whose Special Dates are going to be changed
$product = new Mage_Catalog_Model_Product();
$product->load(YOUR_REQUIRED_PRODUCT_ID);

// Sets the Start Date
$product->setSpecialFromDate($startDate);
$product->setSpecialFromDateIsFormated(true);

// Sets the End Date
$product->setSpecialToDate($endDate);
$product->setSpecialToDateIsFormated(true);
?>

This code just worked like a charm. Hope this helps.

Knowledge Craving
A: 

Non-programmatically, you should be able to achieve this using the Prices tab under the Product Information. I assume, though, that you needed to do this as part of a script. Either way, thanks for sharing that, I need to know more objects :)

melee