Sarathlal N

Random banner in Magento 1 using static blocks

The banners are an inevitable part of any E-Commerce store. They help to increase our sales by promoting new products, special offers & discounts etc.

Today I’m going to make a simple random banner in our Magento powered online store with static blocks and template files.

Here we use a PHP function, mt_rand() to achieve our goal. The mt_rand() return a random integer value between one and N because our parameters for mt_rand() function is one & N.

We use this returned integer value as a part of our static block identifier & echo that static block on that page.

To view our random banner, flesh the Magento cache and reload the store.

Recent Posts

  1. Automating Release Generation with GitHub Actions
  2. WP CLI Commands to Bulk Delete Entries in WordPress Database
  3. Split a Single CSV File into Multiple Files Using the Split Command - Bash
  4. Migrating code repo from BitBucket to GitHub
  5. Streamlining Development - Our Journey with Git, Bitbucket, and Jira

Your Questions / Comments

If you found this article interesting, found errors, or just want to discuss about it, please get in touch.