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;
Shopify, Shopify Apps, Magento, WordPress, Codeigniter, Joomla, Big Commerce | PHP
Tuesday, 23 January 2018
How to set background color into transparent image Imagick PHP
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
Labels:
Cent,
Cent OS,
cli,
dom,
Extensions,
Git,
httpd,
install,
Intl,
JSON,
Magento 2,
Mcrypt,
mysql-server,
mysqlnd,
PHP,
PHP 7,
simplexml
Saturday, 30 December 2017
How to download and Extract Uncompress zip / gz file from URL in PHP
ini_set('display_errors', 1);
$dbname = 'db_'.date('Ymdhis').".gz";
$url = 'http://www.domainname.com/backups/bkp30122017.gz';
file_put_contents($dbname, fopen($url, 'r'));
Extract / Uncompress GZ / ZIP file
try{
//This input should be from somewhere else, hard-coded in this example
$file_name = $dbname;
// Raising this value may increase performance
$buffer_size = 4096; // read 4kb at a time
$out_file_name = str_replace('.gz', '.sql', $file_name);
// Open our files (in binary mode)
$file = gzopen($file_name, 'rb');
$out_file = fopen($out_file_name, 'wb');
// Keep repeating until the end of the input file
while (!gzeof($file)) {
// Read buffer-size bytes
// Both fwrite and gzread and binary-safe
fwrite($out_file, gzread($file, $buffer_size));
}
// Files are done, close files
fclose($out_file);
gzclose($file);
} catch (Exception $ex) {
echo $ex->getMessage();
}
Wednesday, 27 December 2017
How to upload image / file in magento
<input type="file" name="image">
Select path of media directory
$path = Mage::getBaseDir() . DS . 'media' . DS . 'customerimages' . DS;
$imagename = $this->uploadImageFile($_FILES, $path);
Create functions
function uploadImageFile($filedata, $path){
if(isset($filedata['image']) && $filedata['image']['error'] == 0){
try{
$uploader = new Varien_File_Uploader('image');
$uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'));
$uploader->setAllowRenameFiles(true);
if(!is_dir($path)){
mkdir($path, 0755, true);
}
$ext = pathinfo($filedata['image']['name'], PATHINFO_EXTENSION);
$uploader->save($path, date('Ymd') . "_" . date('his') . '.' . $ext);
$uploadFile = $uploader->getUploadedFileName();
if($uploadFile){
return $uploadFile;
} else {
return 'File not uploaded!';
}
} catch (Exception $e) {
return $e->getMessage();
}
} else {
return 'Please select image file!';
}
}
Tuesday, 26 December 2017
How to get product Tire / Final / Group price custom in Magento
How to get product Tire / Final / Group price custom order in Magento
$productid = 4108;
$qty = 3;
$customergroup = 1;
$_productB = Mage::getModel('catalog/product')->load($productid);
$_productB->setCustomerGroupId($customergroup);
echo $_productB->getPriceModel()->getFinalPrice($qty, $_productB);exit;
Subscribe to:
Posts (Atom)