Monday, August 22, 2016

Wordpress - localhost url not found

you will need to edit the http.conf file in the Apache -> Conf folder
1. Open in a plain text editor
2. Find the line that looks like this
#LoadModule rewrite_module modules/mod_rewrite.so
3. Remove hash
LoadModule rewrite_module modules/mod_rewrite.so
4. save
5. regenerate .htaccess

Enjoy :)

Wednesday, August 17, 2016

Magento: Load record of my model by custom Field

Magento: Load record of my model by custom Field


$model = Mage::getModel('foo_bar/baz');
$model->load($id, 'field_name');

Thursday, August 4, 2016

Magento- Country and States in Magento

Magento has inbuilt model for Country and State as seen in Checkout page.
In checkout page if you select Country like ‘France’ , a drop down will be seen in place of textbox for States.
I am writing here the code to directly get country name from ID and also to get States info from country.

<?php
    $countryName = Mage::getModel('directory/country')->load('FR')->getName(); //get country name
 
     
    echo 'Country Name ->'.$countryName.'<br/>';
 
 
    $states = Mage::getModel('directory/country')->load('FR')->getRegions();
 
     
 
    //state names
 
    foreach ($states as $state)
 
    {      
 
        echo 'ID->'.$state->getId().'<br/>';
        echo 'Name->'.$state->getName().'<br/>';
 
    }
?>

Wednesday, August 3, 2016

PHP- How to change the array key to start from 1 instead of 0 ?

how to change the array key to start from 1 instead of 0 ?

$newarr = array_combine(range(1, count($oldarr)), array_values($oldarr));