I think custom variables were originally designed to be used in emails but I use them within the main site for little bits of information whose value needs to change on a per store/language basis.
This is how you get a custom variable inside a phtml file:
Continue reading Magento: Get a custom variable value in a phtml file
You may well have certain pages that you do not want Google, et al, to index in the SERPS. Examples include log in pages, thank you pages, and perhaps content of little search value such as legal blurb. This can let you control a little more, albeit very slightly, the pages you want Google to show and those that you don’t.
You can use the Custom Layout Update control (in the Custom Design tab) to set the robots control on a per-page basis. Simply add the following code into the Custom Layout Update textarea in the Magento admin:
Continue reading Magento Custom Layout Update: Robots No-index
Some useful bits and bobs to do with ordering, size-limiting and getting data out of collections that I tend to often need to look up.
Limiting the Size of a Collection
Loading Friendly URLs/Rewrites
Filter Collection by Attribute and Conditionals List
Get First Item From Collection
Continue reading Magento 1.9: Useful Collection Snippets
Sometimes, when editing a page you need to know what the full module_controller_action route is so you can modify the correct blocks in the layout files. Here is a simple bit of code to display the full action name in the form of module_controller_action.
Continue reading Magento (v1.x) : Show full page action name (module_controller_action)
Here is how to get the the store config information for the phone number:
<?php echo Mage::getStoreConfig(‘general/store_information/phone’);?>
And for the address:
<?php echo Mage::getStoreConfig(‘general/store_information/address’);?>
In fact you can get all sorts of interesting “config” data out using this getStoreConfig method.
Continue reading Magento: Get store address, phone number or other config information
This is a quick and dirty list of the stages to install and set up memcache on centos 7 running php 5.4**
Continue reading Adding Memcache for Magento on Centos 7
Ok, so you have written an import script to add a whole load of products into a store but they just don’t show on the front end. There they are in the admin but not on the front end. Here is one possible cause. Continue reading Magento: Programmatically added products do not appear in store until you load and save them in admin.
Following a database export/import as part of a migration or copy to a new development environment some database problems can occur, even if the entire db is copied. Sometimes the problem can be the log files references, as is likely with the error:
Integrity constraint violation: 1062 Duplicate entry ‘123456’ for key ‘PRIMARY’
Where 123456 is some number.
Continue reading Magento Error: Integrity constraint violation: 1062 Duplicate entry ‘123456’ for key ‘PRIMARY’
So you want to add some additional functionality when the user posts stuff to your contact form. You will need to either add an observer or override the contact form controller. Here is how to do the latter.
Continue reading Magento: Override the Contacts Core Controller
So you are trying to do a fulltext search but your searches for “cat” or “dog” always return zero results, even though you have articles all about cats and dogs. By default the minimum search text length for full index searches is 4 characters, anything less than that returns nothing, zip, nada, jack-all. You need to change the minimum word length.
This can throw people using something like Magento whose product types or names are short, such as “bag”,”cup”, or “mug”. The problem isn’t actually in Magento but a server setting. You might be kind of stuck if you are using a shared hosting environment – you can contact your hosting service and ask nicely.
Continue reading Mysql: Change the full text index minimum word length