1

How can I automatically set the news_from_date and the news_to_date for a new product?

news_from_date should be the date now and news_to_date should be date now +1 week.

  • Do you want to do this in the Admin? Via the Dataflow importer? Via PHP? – Tyler V. Oct 1 '15 at 23:11
1

This answer explains how to use dynamic default values: Different default value of an attribute in different attribute sets

You can apply the same here, i.e. create an observer for catalog_product_save_before, with code like this:

$product = $observer->getProduct();
if ($product->isObjectNew()) {
    $product->setNewsFromDate(now());
    $product->setNewsToDate(strtotime('+1 week'));
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.