Thursday 25 January 2018

How to keep multiple values selected dropdown in magento addField (multiselect)



$filterData = $this->helper('adminhtml')->prepareFilterString($this->getRequest()->getParam('filter', false));
$fieldset->addField('warehouse', 'multiselect', array(
            'label' => Mage::helper('namespace_reports')->__('Warehouse'),
            'title' => Mage::helper('namespace_reports')->__('Select multiple warehouse'),
            'name' => 'warehouse',
            'values' => $this->_getWarehouseArr(),
            'value' => isset($filterData['warehouse'][0]) ? explode(',', $filterData['warehouse'][0]) : array(),
            'style' => 'height:43px'
        ));

Tuesday 23 January 2018

How to set background color into transparent image Imagick PHP

ini_set('display_errors',1);
header('Content-type: image/png');
$strInputFile = 'front.png'; // transparent image
$im = new Imagick($strInputFile);
$im->setImageBackgroundColor('green');
$im = $im->flattenImages();
echo $im;exit;

Saturday 13 January 2018

How to install custom or subdomain SSL certificate in AWS.

How to install custom or subdomain SSL certificate in AWS.

1. sudo dpkg –s openssl

2. sudo a2enmod ssl

3. sudo service apache2 restart

4. openssl req -nodes -newkey rsa:2048 -keyout myserver.key -out server.csr
1. Country Name (2 letter code) [AU]: GB
2. State or Province Name (full name) [Some-State]: Surrey
3. Locality Name (eg, city) []: London
4. Organization Name (eg, company) [Internet Widgits Pty Ltd]: Company Name Pvt Ltd
5. Organizational Unit Name (eg, section) []: IT Department
6. Common Name (eg, YOUR name) []: yourdomain.com
7. Email Address []:webmaster@yourdomain.com
8. A challenge password []:
9. An optional company name []:

5. GET Certificate files and upload to "/var/www/html/cert/" :
1. private.key - Which you have generate using step 4
2. c00d2e98b15a0818.crt - Which you get certificate 3rd party
3. gd_bundle-g2-g1.crt - Which you get chain 3rd party

6. sudo nano /etc/apache2/sites-available/default-ssl.conf
**************
**************
DocumentRoot /var/www/html
<Directory /var/www/html/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
*******
*******
*******
SSLCertificateFile "/var/www/html/cert/c00d2e98b15a0818.crt"
SSLCertificateKeyFile "/var/www/html/cert/private.key"
SSLCertificateChainFile "/var/www/html/cert/gd_bundle-g2-g1.crt"
*******
*******
*******

7. sudo a2ensite default-ssl.conf
8. sudo service apache2 restart
9. Check your ssl : https://www.sslshopper.com/ssl-checker.html

Tuesday 9 January 2018

Clear configurable Swatches, Images, Flush Magento ALL Cache and cache files

ini_set('display_errors', 1);
require_once('../app/Mage.php');
Mage::app()->setCurrentStore(Mage::getModel('core/store')->load(Mage_Core_Model_App::ADMIN_STORE_ID));
/* Clear Cache */
try {
    $allTypes = Mage::app()->useCache();
    foreach($allTypes as $type => $cache) {
        Mage::app()->getCacheInstance()->cleanType($type);
    }
   
    /**
     * Flush cache storage
     */
    Mage::dispatchEvent('adminhtml_cache_flush_all');
    Mage::app()->getCacheInstance()->flush();
   
    /**
     * Flush all magento cache
     */
    Mage::app()->cleanCache();
    Mage::dispatchEvent('adminhtml_cache_flush_system');
   
   
} catch (Exception $e) {
    Mage::logException($e->getMessage());
}
try {
    /* cleanImages */
    Mage::getModel('catalog/product_image')->clearCache();
    Mage::dispatchEvent('clean_catalog_images_cache_after');
   
    /* cleanSwatches */
    Mage::helper('configurableswatches/productimg')->clearSwatchesCache();
    Mage::dispatchEvent('clean_configurable_swatches_cache_after');
   
    clearCstoreCacheDir('../var/cache');
   
    echo 'Success';
   
} catch (Mage_Core_Exception $e) {
    echo $e->getMessage();
} catch (Exception $e) {
    echo Mage::helper('adminhtml')->__('An error occurred while clearing the configurable swatches image cache.');
}
function clearCstoreCacheDir($dirPath) {
    if (!is_dir($dirPath)) {
        throw new InvalidArgumentException("$dirPath must be a directory");
    }
    if (substr($dirPath, strlen($dirPath) - 1, 1) != '/') {
        $dirPath .= '/';
    }
    $files = glob($dirPath . '*', GLOB_MARK);
    foreach ($files as $file) {
        if (is_dir($file)) {
            self::deleteDir($file);
        } else {
            unlink($file);
        }
    }
    rmdir($dirPath);
}

Tuesday 2 January 2018

How to install extensions in php 7 cent os


Install extensions in php 7 cent os follow these steps

1. curl 'https://setup.ius.io/' -o setup-ius.sh
2. sudo bash setup-ius.sh
3. sudo yum install -y mod_php70w php70w-cli php70w-mysqlnd php70w-json php70w-gd php70w-dom php70w-simplexml php70w-mcrypt php70w-intl httpd mysql-server git