Wednesday 24 February 2016

database server does not support the InnoDB storage engine.


Line 59 of the file app/code/core/Mage/Install/Model/Installer/Db/Mysql4.php
Replace:
    public function supportEngine()
    {
        $variables  = $this->_getConnection()
            ->fetchPairs('SHOW VARIABLES');
        return (!isset($variables['have_innodb']) || $variables['have_innodb'] != 'YES') ? false : true;
    }
   
   
    with this:
   
    public function supportEngine()
    {
        $variables  = $this->_getConnection()
            ->fetchPairs('SHOW ENGINES');
        return (isset($variables['InnoDB']) && $variables['InnoDB'] != 'NO');
    }

Thursday 18 February 2016

how to get logged In customer’s details on magento

 // Check if any customer is logged in or not
if (Mage::getSingleton('customer/session')->isLoggedIn()) {

    // Load the customer's data
    $customer = Mage::getSingleton('customer/session')->getCustomer();

    $customer->getPrefix();
    $customer->getName(); // Full Name
    $customer->getFirstname(); // First Name
    $customer->getMiddlename(); // Middle Name
    $customer->getLastname(); // Last Name
    $customer->getSuffix();

    // All other customer data
    $customer->getWebsiteId(); // ID
    $customer->getEntityId(); // ID
    $customer->getEntityTypeId(); // ID
    $customer->getAttributeSetId(); // ID
    $customer->getEmail();
    $customer->getGroupId(); // ID
    $customer->getStoreId(); // ID
    $customer->getCreatedAt(); // yyyy-mm-ddThh:mm:ss+01:00
    $customer->getUpdatedAt(); // yyyy-mm-dd hh:mm:ss
    $customer->getIsActive(); // 1
    $customer->getDisableAutoGroupChange();
    $customer->getTaxvat();
    $customer->getPasswordHash();
    $customer->getCreatedIn(); // Admin
    $customer->getGender(); // ID
    $customer->getDefaultBilling(); // ID
    $customer->getDefaultShipping(); // ID
    $customer->getDob(); // yyyy-mm-dd hh:mm:ss
    $customer->getTaxClassId(); // ID
}

Monday 15 February 2016

how to ip track location country

$key='4aa3d8dd845debd79b15b3d55449dbeddbf00645e0acdd2b943a99f298b9c089';
    $ip=$_SERVER['REMOTE_ADDR'];
$url='http://api.ipinfodb.com/v3/ip-country/?key='.$key.'&ip='.$ip;
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $data = curl_exec($ch);
    curl_close($ch);
    $dataArr=explode(";",$data);
    if($dataArr[3]=="IN"){
        //echo "<pre>"; print_r($dataArr); echo "</pre>"; exit;
        header("Location: ./india");
        exit;
    }

Tuesday 9 February 2016

magento custom search by name ,description short_description

// Code to Search Product by $searchstring and get Product IDs
    $product_collection = Mage::getResourceModel('catalog/product_collection')
                 ->addAttributeToSelect('*')
                 ->addAttributeToFilter('name', array('like' => '%'.$searchstring.'%'))
                 ->load();

    foreach ($product_collection as $product) {
        $ids[] = $product->getId();
    }

Sunday 7 February 2016

How can I find all products without images in Magento?

//this builds a collection that's analagous to
//select * from products where image = 'no_selection'
$products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*')->addAttributeToFilter('visibility', 4)->addAttributeToFilter('status', 1)->addAttributeToFilter('image', 'no_selection');

foreach($products as $product)
{
    echo  $product->getSku() . " has no image \n<br />\n";
    //var_dump($product->getData()); //uncomment to see all product attributes
                                     //remove ->addAttributeToFilter('image', 'no_selection');
                                     //from above to see all images and get an idea of
                                     //the things you may query for
}

Thursday 4 February 2016

How to retrieve a customer by phone number in magento?

$customer = Mage::getResourceModel('customer/address_collection')
    ->addAttributeToSelect('telephone')
    ->addAttributeToFilter('telephone', $phoneNumber)
    ->getFirstItem()->getCustomer();
if ($customer !== false) {
    // Do stuff...
}