Skip to content

Instantly share code, notes, and snippets.

@dakira
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dakira/135f0ca7c86e38a5cf18 to your computer and use it in GitHub Desktop.
Save dakira/135f0ca7c86e38a5cf18 to your computer and use it in GitHub Desktop.
Magento: Activate products in the future
<?php
/*
Follow these steps to create this functionality:
1. Create a custom date attribute, lets call it ‘activation_date’
2. Create a cron job that should implement the following:
2.1 Retrieve all product ids that were not activated (E.G. status disabled) and their activation date
is lower than current date
2.2 Activate all these products by the product attribute mass-action model:
*/
Mage::getSingleton('catalog/product_action')
->updateAttributes(
$retrievedProductIdsArray,
array('status' => Mage_Catalog_Model_Product_Status::STATUS_ENABLED),
Mage_Core_Model_App::ADMIN_STORE_ID
);
/*
3. Schedule the cron job in your module configuration file (config.xml) 4. Enjoy It!
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment