Tuesday, August 1, 2017

Run stored procedure when inout parameter

mysql> SET @increment = 10;
mysql> CALL p(@increment);
more info click here

Thursday, August 18, 2016

Warning!symlink(): Cannot create symlink, error code(1314) magento 2

I faced this problem and try to figure out. I agree with Chris O'Toole. I will add extra step. My steps are,

  1. Open app/etc/di.xml and search Symlink. Check it is in following section. 
Replace Symlink with Copy word. Save.
  1. Delete all folders in pub/static. Don't delete .htaccess and other files.
  2. Run xampp as administrator. Run command line as administrator. 
 Run grunt exec:<theme name>.
You will see it is running fine. 

Then you can run grunt less:<theme name>

Finally you can run grunt watch

When you do any changes in less files(_theme.less or _extend.less) it will automatically create style-l and style-m css files in pub/static folder.

I'm running magento 2.1 in windows 10. 

Thanks & Regards,
Chamath Gunasekara

Sunday, July 31, 2016

Magento 2 : Less variable issue

If you get variable issue when running 

grunt exec:themename 
when deploying theme using
php bin/magento setup:static-content:deploy

First delete var/* 
Then run following commands

php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy

If doesn't solve your problem check your parent theme name in your theme.xml. If it is not luma then change back to luma and run following commands again.

php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy

Thanks & Regards,
Chamath Gunasekara

Thursday, June 2, 2016

How to do date addition in PHP

$sub_user_time_logged_in = "05:02:04";
$user_time_logged_in = "04:07:15";
$total_user_time_logged_in = strtotime($sub_user_time_logged_in) + strtotime($user_time_logged_in);
$total_user_time_logged_in = date("H:i:s", $total_user_time_logged_in);


Thursday, April 9, 2015

How to point magento multi websites to domains

Backend configurations
Add secure and unsecure domain urls for websites
Add default domain url default config

Index.php changes
You need edit index.php file as follows

switch($_SERVER['HTTP_HOST']) {
    case 'domain.co.uk':
    case 'www. domain.co.uk':
        $mageRunCode = 'base';
        $mageRunType = 'website';
    case ' domain.eu':
    case 'www. domain.eu':
        $mageRunCode = 'euwebsite';
        $mageRunType = 'website';
Comment following lines if you have
/* Run store or run website */
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';

 Point main domain by adding your hosting server dns in domain registrar
                It will take some time to resolve DNS settings. Use intodns.com to check dns of a domain.

 Then you need to point other domain. There are two ways.

 Using cPanel
 Go to parked domain in bottom of the cpanel
Add your domain. It will automatically point to your public_domain

Sometimes you may get error as follows
Sorry, the domain is already pointed to an IP address that does not appear to use DNS servers associated with this server. Please transfer the domain to this servers nameservers or have your administrator add one of its nameservers to /etc/ips.remotedns and make the proper A entries on that remote nameserver.
This is an issue in DNS setting or WHM setting
                Check DNS first whether it is resolve or not
                If it is ok go to WHM > Tweak Settings > Domains > Allow Remote Domains
Switch the option to On and click on Save. Now you can add parked domain.
Make sure to off after setup parked domain
Using WHM
You can also park a domain in the WebHost Manager using Home » DNS Functions » Park a Domain

Have fun... :-)

Tuesday, April 7, 2015

How to add Magento Product Reviews form anywhere on product page

Step1: Go to catalog.xml in your "layout" directory and find following section

<reference name="content">
<block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">

Step2: Add the following after above line:

<block type="review/product_view_list" name="product.top.reviews" as="product.top.reviews" template="review/product/view/list.phtml">
    <block type="review/form" name="product.review.form" as="review_form" />

Step3: Now call following code where you want to display review form:

<?php echo $this->getChildHtml('product.top.reviews') ?>