Saturday 28 October 2017

Get Address of customer from database Query in Magento PHP Mysql

SELECT
`entity_id` as `entity_id`,
`firstname`.`value` as `First_Name`,
`surname`.`value` as `Surname`,
`telephone`.`value` as `Telephone`,
`country`.`value` as `country`,
`region`.`value` as `region`,
`statecounty`.`value` as `statecounty`,
`city`.`value` as `city`,
`company`.`value` as `company`,
`street`.`value` as `street1`,
`customer_entity`.`created_at`,
`customer_entity`.`updated_at`
FROM
`customer_address_entity_varchar` as `country`
INNER JOIN
`customer_address_entity_varchar` as  `firstname` USING (`entity_id`)
INNER JOIN
`customer_address_entity_varchar` as  `surname` USING (`entity_id`)
INNER JOIN
`customer_address_entity_varchar` as  `telephone` USING (`entity_id`)
INNER JOIN
`customer_address_entity_varchar` as  `region` USING (`entity_id`)
INNER JOIN
`customer_address_entity_varchar` as  `statecounty` USING (`entity_id`)
INNER JOIN
`customer_address_entity_varchar` as  `city` USING (`entity_id`)
INNER JOIN
`customer_address_entity_varchar` as  `company` USING (`entity_id`)
INNER JOIN
`customer_address_entity_text` as  `street` USING (`entity_id`)
INNER JOIN
`customer_entity` USING (`entity_id`)
WHERE
`firstname`.`attribute_id` = 20  &&
`surname`.`attribute_id` = 22  &&
`country`.`attribute_id` = 27 &&
`region`.`attribute_id` = 28 &&
`statecounty`.`attribute_id` = 144 &&
`city`.`attribute_id` = 26 &&
`company`.`attribute_id` = 24 &&
`street`.`attribute_id` = 25 &&
`telephone`.`attribute_id` = 31

Tuesday 26 September 2017

Transfer Attribute value from one attribute to another attribute in magento

You can transfer Attribute value from one attribute to another attribute in magento


public function changeattrAction()
    {
        //echo 'tes';exit;
        $products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*');
     
        $j = 0;
        //echo count($products->getData());exit;
        foreach ($products as $k=>$product):
            if($j >= 5000 && $j < 5500){
                //echo $j;
             
                if($product->getH1() != ''){
                    echo $j.'. '.$product->getId().' '.$product->getH1().'<br>';
                    $product->setH1copy($product->getH1());
                    $product->save();
                }
            }
            $j = $j+1;
         
        endforeach;
    }

Thursday 14 September 2017

Create Zip file of all php files from your server using PHP file

Create Zip file of all php files from your server using PHP file. If you have not cpanel of the server so you can use this php file and compress files as zip file.

Just you need put this file into root directory of the server (ex.public_html/createzip.php)

And run this file from browser eg. http://domain.com/createzip.php

Create one file name : createzip.php and put following code into the file. and run file from browser.

<?php
// Get real path for our folder
$realpath = getcwd();
$rootPath = realpath($realpath);
// Initialize archive object
$zip = new ZipArchive();
$filename = 'bk_'.date('YmdHis').'.zip';
$zip->open($filename, ZipArchive::CREATE | ZipArchive::OVERWRITE);
// Create recursive directory iterator
/** @var SplFileInfo[] $files */
$files = new RecursiveIteratorIterator(
    new RecursiveDirectoryIterator($rootPath),
    RecursiveIteratorIterator::LEAVES_ONLY
);
foreach ($files as $name => $file)
{
    // Skip directories (they would be added automatically)
    if (!$file->isDir())
    {
        // Get real and relative path for current file
        $filePath = $file->getRealPath();
        $relativePath = substr($filePath, strlen($rootPath) + 1);
        // Add current file to archive
        $zip->addFile($filePath, $relativePath);
    }
}
// Zip archive will be created only after closing object
$zip->close();

Saturday 9 September 2017

W: GPG error: https://repo.skype.com stable InRelease

Did you got error something like this, whenever you get update ubuntu "sudo apt-get update" in terminal?

W: GPG error: https://repo.skype.com stable InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 1F3045A5DF7587C3

ANS.

According to https://repo.skype.com/, run:

curl https://repo.skype.com/data/SKYPE-GPG-KEY | sudo apt-key add -

in a terminal

Friday 25 August 2017

Zip File Extract using PHP file

If you have not cpanel of the server so you can use this php file and extract uploaded zip file.

<?php
ini_set('display_errors', 1);
$zip = new ZipArchive;
if ($zip->open('test.zip') === TRUE) {
    $zip->extractTo('./rr/');
    $zip->close();
    echo "It's extract";
} else {
    echo 'failed';
}
?>

Saturday 12 August 2017

SoftException in Application.cpp:668: is writable by group

500 Error: File is writable by group

On occasion you may get a 500 page error (a blue/green error) when trying to run a PHP file in your account. When checking the error log which you can do via the cPanel account log in you may see the following line:

[Sat Aug 12 00:57:37 2017] [error] [client 103.240.34.54] SoftException in Application.cpp:668: Directory "/home/username/public_html/index.php" is writeable by group

This is due to the server running SuPHP and the files having higher permissions than allowed, 
 
How to solve this issue
 
Fix this problem you need to make sure your files are chmod 644 for all PHP based files and 755 for directories in order for them to work with SuPHP. You can easily do this by connecting via FTP with Filezilla Not from Cpanel and right clicking on the problem folders and files and selecting file permissions. Also set  0755 permission on public_html directory.