One feature that attracts merchants to Magento Enterprise is the CMS content known as Banners. Using this feature allows for adding content and promos to the store’s homepage or category pages on a schedule. The merchant can schedule the promotion to show up on and be removed from the website during certain dates or even hours. However, the scheduled banners are hard to get them to work correctly.
On this post, we will focus on what prevents banners from not showing up at the expected, scheduled time when assigned promotion rules. Generally, the problem occurs when a promotion rule is created and needs to be APPLIED in order to become active. Most admins set up the rules, save them, and assume Magento will show the correct banner/promotion at midnight on Saturday, but nothing shows up.
The solution: At Shero, we have we have created our own module that ensures banners will show on the website as scheduled and you can enjoy your weekend. The main idea of the module is simple: twice a day at 12 fetch all store rules, apply them as configured, and clear cache.
* applying all rules does not mean they will become all active, it just forces rules to be applied (active or inactive) as they are configured in Magento.
Our module will be based on cron jobs and builds up a simple config panel in the admin. We have named our module Shero/Cronrules. Now let’s explain in steps how to properly set it up.
- Create module directory under app/code/local/Shero/Cronrules
- Inside the folder created, create these folder: ect, Helper, Model.
- Create the module declaration file at app/etc/modules/Shero_Cronrules.xml with the following content:
4. Under etc folder we created, create the following file:
5.Under Model/ folder create the following file:
6. Under Helper/ folder create the following file:
After following upper steps, the folder structure should look like this:
The two most important things so far are:
- The cron will run twice a day at 12 AM and 12 PM
- The module needs to be activated from the Magento admin panel. You’ll have to check for possible issues and enable logs.
The tab in admin can be found at System > Configuration > Shero > Shero Banners:
If you choose yes to the Enable Logs option, each time the cron for applying rules will run, it will write in a file: var/log/CatalogRuleCron.log and the content in the success case will be:
2017-04-20T16:05:03+00:00 DEBUG (7): Catalog Rules applied successfully and Cache-s cleared!
That’s all you have to do. Now set up your banners with promotion rules and expect them to show up at the correct time. This is a real example of how the banners look in one of the stores we’ve worked on.
To wrap it up, this module solves the following problems:
- Applies catalog promotion rules twice/day when the administrator forgets to do it.
- Promotion-related banners show up on the scheduled time.
- Cache clears when changes are applied to banners or catalog rules that prevent them from showing up properly.
These were all the steps you have to follow in order to integrate our module in your website. Hope it helps you in solving banners not showing up at the scheduled time in your Magento Enterprise website.
If you have any difficulty in setting up the module feel free to contact us.