Magento special price still showing after expiration

Posted: December 16, 2011 in Web

Did you set a special price to expire on a certain date in Magento, but it didn’t automatically remove itself? Here’s the fix.

The problem

After much research, I can only assume this special price issue not working properly is a bug in Magento. The only accepted solution was to visit the admin page System > Configuration and Reindex the Data for Product Prices. Fine, but I can’t tell my client to log into his admin every morning and clear his indices.

Create cron jobs

Instead, I created some cron jobs to clear the indices and cache storage every night at midnight.

Reindex all Magento indices

Create one cron using the following command:

php /home/path/to/magento/shell/indexer.php reindexall

Clear all cache

To clear all Magento cache, we will need to create a script file that deletes everything in /var/cache/.

  1. Create a file called clearcache.sh in the directory one level above public_html (so it’s not publicly accessible)
  2. Put the following lines into that file:
     #!/bin/bash rm -rf /home/path/to/magento/public_html/var/cache/*
  3. Edit the path to your Magento installation and /var/cache/ directory as necessary.
  4. Create the cron job using the following command:
bash -s < /home/path/to/clearcache.sh

Tell your friends


I graduated from LSU with a B.F.A. in Graphic Design and a minor in Art History. My passions are web design and front-end development with over 10 years of experience.


Leave a comment

Did this article help you? Do you have a different opinion? Feel free to leave a comment or ask questions.