Categories
Programming

WordPress – Changing The Site URL Using WP-CLI Command Line Tool

The WP-CLI command line tool is a handy application to run various WordPress tasks. Download the WP-CLI command line tool into the WordPress root folder using CURL or WGET. [bash] curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar [/bash] Check if the tool is working. [bash] php wp-cli.phar –info [/bash] Not run the search and replace command to look through all […]

Categories
Et Cetera

Google AdWords Campaign / Spelling Fail – Millets Outdoor Store

I Googled “North Face Shoes“. Millets Outdoor Store flashed an advertisement, offering an additional 15% off by using a coupon code! I clicked (costing Millet a click) the link and visited their North Face landing page. I added a North Face shoe to the basket and applied the voucher code “REDHOT“. I was greeted with […]

Categories
Programming

Magento – Adding a Custom Category Attribute (EAV)

[php] $setup = new Mage_Eav_Model_Entity_Setup(‘core_setup’); $setup->startSetup(); $setup->addAttribute(Mage_Catalog_Model_Category::ENTITY, ‘show_sale_icon’, array( ‘backend’ => ”, ‘default’ => 0, ‘global’ => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, ‘group’ => ‘General’, ‘input’ => ‘select’, ‘label’ => ‘Show Category Sale Icon’, ‘position’ => 100, ‘required’ => false, ‘source’ => ‘eav/entity_attribute_source_boolean’, ‘type’ => ‘int’, ‘user_defined’ => true, ‘visible’ => true, ‘visible_on_front’ => true, ) ); $setup->endSetup(); [/php] […]

Categories
Programming

Magento Fix – Email Validation for New gTLDs

Have you come across the following errors in Magento? Invalid email address “[email protected]” “[email protected]” is not a valid hostname. ‘domain.events’ appears to be a DNS hostname but cannot match TLD against known list ‘domain.events’ appears to be a local network name but local network names are not allowed It is probably because the Zend email […]

Categories
Programming

Yoast Google Analytics Reassign ‘__gaTracker’ Tracker to ‘ga’ Variable

Google Analytics by Yoast is a must have plugin for all WordPress installs. It makes adding GA trackers a breeze and it can also ping certain events to Google Analytics. The only unexplained bit of code is the issue. At some point, the ‘ga’ variable changed to ‘__gaTracker’. This raised some concerns among the techy […]

Categories
Programming

Magento – Reset File and Folder Permissions

You might have come across the following error while in Magento Connect Manager – Warning: Your Magento folder does not have sufficient write permissions. Magento needs certain file and folder permissions to be able to automatically performs upgrades and module installs. Open your SSH and browse to your root folder. Then, run the following commands. […]

Categories
Programming

Magento – Get CMS Static Block Model Data (Title, Status, Content)

You can store template and HTML data in Magento’s static blocks. If you want to pull it into your PHTML templates, just call load up the model and use the data fields. [php] <?php $staticBlock = Mage::getModel(‘cms/block’)->load(‘static-block-identifier’); echo $staticBlock->getTitle(); echo $staticBlock->getIdentifier(); echo $staticBlock->getIsActive(); echo $staticBlock->getContent(); ?> [/php]

Categories
Programming

Magento – Check if CMS Static Block is Enabled / Active

Static blocks in Magento are really useful. They offer an easy way to insert content into various parts of the template. You are only limited by your imagination. You can check if the static blocks are enabled, before printing them to screen. [php] <?php if(Mage::getModel(‘cms/block’)->load(‘static-block-identifier’)->getIsActive()) : echo Mage::app()->getLayout()->createBlock(‘cms/block’)->setBlockId(‘static-block-identifier’)->toHtml(); endif; ?> [/php]

Categories
Programming

Magento – Get Logged In Customer’s Group ID

[php] <?php /* Check if customer is logged in */ $isLoggedIn = Mage::getSingleton(‘customer/session’)->isLoggedIn(); /* If customer is logged in */ if($isLoggedIn) : /* Get the logged in customer’s group ID */ $customerGroupId = Mage::getSingleton(‘customer/session’)->getCustomerGroupId(); /* Check if the logged in customer’s group ID matches with the ID you are after */ /* Customer group IDs […]

Categories
Programming

How to Clone a Git Repository into the Current Directory

Somehow, most examples of Git’s clone command show a subfolder for the repository to be cloned into. I, for example, prefer navigating to the desired directory and like to clone into the current directory. The Git command has to be changed to appear as follows: [bash] git clone [email protected]:your-username/repository-name.git . git clone https://github.com/your-username/repository-name . [/bash] […]