3

A company that I'm working for has 20+ stores in the UK and are starting to frequently open more and more. There's a lot of traces of words throughout the CMS in category descriptions, pages and even product descriptions that mention "21 stores" or "25+ stores throughout the UK".

Is there a way I can create a global tag that can be used in my CMS? Something like {{storecount}}? I was going to create a block or widget - but I've noticed Magento doesn't call these in to category descriptions - it just outputs the string {{block...}}.

Cheers,

Liam

4

You can use a custom variable, as described by Inchoo:

customvarDirective

You can define your own custom variable here:

System > Custom Variables

And then output it on any cms page or block. Unfortunately not in product/category descriptions, etc.

{{customvar code=”my_custom_var”}}

Inside of php code

Mage::getModel(‘core/variable’)->loadByCode(‘my_custom_var’)->getValue();
  • Perfect! With this in mind, I'd like to dynamically increase the store count when we open more stores - so I'll take a look at the controller of my stores plugin, find this custom variable on the database and change it on the submission of a new store entry :) – Liam McArthur Sep 21 '15 at 10:38
2

There's always a (better) way to get things done in Magento. Here we go !

  1. Create a System Config Field (preferably) under System - Configuration - General - Store Information -> << Stores Count >>

  2. Observe the respective _afterSave event fired after you create an every store, under System - Manage Stores and increment your count (saved value) of your new << Stores count>> system config field.

  3. Use this saved config field else where on your Magento store like this

{{config path='general/store_information/stores_count'}}

Mage::getStoreConfig('general/store_information/stores_count')

In this way you can automate to manage this, saves you a good amount of time in managing this manually !

A sidenote: also observe the delete stores respective action event to decrement your store count, in the event of deleting any stores.

Ok thanks for your question, am about to start my first contribution to the community by creating a little extension shortly, to manage this:-)

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.