28 Apr

Magento random block generator / block randomiser

This could be pretty useful if you want to combine XML block control with a random content display (eg. banner ads). Very easily achieved, simply create 1 file in ./base/default/template/page/html/random_block.phtml <?php $children = $this->getSortedChildren(); if(is_array($children)) { shuffle($children); echo $this->getChildHtml($children[0]); } ?> Then in your relevant XML file - control the output by using: <block type="core/template" … Continue reading

25 Feb

Custom attributes for categories in Magento

Sometimes there is a requirement to have custom attributes for a category, but it isn't that straightforward to add, at least not through the GUI. The method, for a text input, is: 1 Create the new attribute via admin, or via SQL using the following: INSERT INTO `eav_attribute` (`entity_type_id`, `attribute_code`, `attribute_model`, `backend_model`, `backend_type`, `backend_table`, `frontend_model`, … Continue reading

19 Feb

Magento 1.4 Install Errors

We imagine there is going to be a few, but here are the ones we have come across so far: 1 Unsupported operand types ... Hostname.php Solution: Comment out line +471 in ./lib/Zend/Validate/Hostname.php #$regexChars += include($this->_validIdns[strtoupper($this->_tld)]); 2 Invalid mode for clean Solution: Remove ./app/code/core/Zend/Cache/ 3 Invalid argument supplied for foreach ... toolbar.phtml This is due … Continue reading

4 Feb

Quick script to mass enable categories in Magento

Just another easy one if you are looking to enable categories by ID - we usually incorporate this script into our product insertion API, so that it enables a category automatically for a product upon insertion. But it can also be used standalone. This script would be ideal alongside our export Magento category ID script … Continue reading

31 Jan

Mass update stock levels in Magento - FAST

This isn't ground-breaking code, but rather just using some core code in a rather stripped out manner. As we're not big fans of Magento data flow here, we perform most of our stock and catalogue updates using external scripts to Mage::app. We have been trickling elements of these out to the wider world so you … Continue reading