Useful Tricks

This section contains some useful programming tricks.
How to Add related products in Magento by code / script

To create the related product programmatically in Magento <?phpset_time_limit(0);ini_set(‘memory_limit’,’1024M’);require_once ‘../../app/Mage.php’;Mage::app(); $sku=’12345’;  //some Sku$product = Mage::getModel(‘catalog/product’)->loadByAttribute(‘sku’,$sku); if($product){$sRelatedProducts = “123456,123”;$aRelatedProducts = explode(‘,’,…

Create a Country Drop Down in the Frontend of Magento

<?php$_countries= Mage::getResourceModel(‘directory/country_collection’)                                    ->loadData()                                    ->toOptionArray(false) ?><?php if (count($_countries) > 0): ?>    <select name=”country” id=”country”>        <option value=””>– Please Select –</option>        <?php foreach($_countries as…

Category Navigation Listings in Magento

<div id=”leftnav”><?php $helper = $this->helper(‘catalog/category’) ?><?php $categories = $this->getStoreCategories() ?><?php if (count($categories) > 0): ?><ul id=”leftnav-tree” class=”level0″><?php foreach($categories as $category):…

1 10 11 12 42