Wednesday 26 September 2018

SELECT list is not in GROUP BY clause and contains nonaggregated column … incompatible with sql_mode=only_full_group_by

Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'returntr_prod.tbl_customer_pod_uploads.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by


will be simply solved by changing the sql mode in MySQL by this command,

SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
OR

set @@global.show_compatibility_56=ON;

OR from CMD
mysql -u root -p mg_cstore < db.sql
This is too works me.. I used this becz in my project there are many Queries like this so just change this sql mode only_full_group_by


For permenant solution in ubuntu 16 and 18

Step1) find and modify the config file my.cnf. Usually it’s in /etc/my.cnf or /etc/mysql/my.cnf.
Step 2) Add following code end of the file
[mysqld]sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION

Saturday 22 September 2018

How to Skip | Hide shipping address in checkout Magento 1.9

Step 1 :

Create config.xml file : app/code/local/Jaydip/Kansagra/etc/config.xml

<config>
   <global>
        <blocks>
            <jaydip_kansagra>
                <class>Jaydip_Kansagra_Block</class>
            </jaydip_kansagra>
            <!-- For Hide Shipping address-->
            <checkout>
                <rewrite>
                    <onepage>Jaydip_kansagra_Block_Kansagra_Checkout_Onepage</onepage>
                </rewrite>
            </checkout>
            <!-- For Hide Shipping address-->
       </blocks>
       ...........
       ...........
       ...........
       <!-- For Hide Shipping address-->
        <rewrite>
            <hideshippingadd> <!--This can be any unique id -->
                <from><![CDATA[#^/checkout/onepage/#]]></from>  <!-- the URL which u want to override-->
                <to>/kansagra/onepage/</to>  <!-- destination url -->
            </hideshippingadd>
        </rewrite>
        <!-- For Hide Shipping address-->
       ...........
       ...........
       ...........
   </global>
</config>


Step 2 : 

Create OnepageController.php file : app/code/local/Jaydip/Kansagra/controllers/OnepageController.php

<?php
require_once Mage::getModuleDir('controllers', "Mage_Checkout") . DS . "OnepageController.php";
class Jaydip_Kansagra_OnepageController extends Mage_Checkout_OnepageController {
    public function saveBillingAction() {
        if ($this->_expireAjax()) {
            return;
        }
        if ($this->getRequest()->isPost()) {
            $data = $this->getRequest()->getPost('billing', array());
            $customerAddressId = $this->getRequest()->getPost('billing_address_id', false);
            if (isset($data['email'])) {
                $data['email'] = trim($data['email']);
            }
            $result = $this->getOnepage()->saveBilling($data, $customerAddressId);
            if (!isset($result['error'])) {
                if ($this->getOnepage()->getQuote()->isVirtual()) {
                    $result['goto_section'] = 'payment';
                    $result['update_section'] = array(
                        'name' => 'payment-method',
                        'html' => $this->_getPaymentMethodsHtml()
                    );
                } elseif (isset($data['use_for_shipping']) && $data['use_for_shipping'] == 1) {
                    $result['goto_section'] = 'shipping_method';
                    $result['update_section'] = array(
                        'name' => 'shipping-method',
                        'html' => $this->_getShippingMethodsHtml()
                    );
                 
                } else {
                    $result['goto_section'] = 'shipping';
                }
            }
            $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
        }
    }
}

Step 3 :

Create Onepage.php file : app/code/local/Jaydip/Kansagra/Block/Kansagra/Checkout/Onepage.php

<?php
class Jaydip_Kansagra_Block_Kansagra_Checkout_Onepage extends Mage_Checkout_Block_Onepage {
    protected function _getStepCodes() {
        return array('login', 'billing', 'shipping_method', 'payment', 'review');
    }
}

Step 4 : 

And now you need to copy billing.phtml from app/design/frontend/base/default/checkout/onepage

folder into app/design/frontend/rwd/default/template/newgenray/checkout folder.

Find following code

<li class="control">
<input type="radio" name="billing[use_for_shipping]" id="billing:use_for_shipping_yes" value="1"<?php if ($this->isUseBillingAddressForShipping()) {?> checked="checked"<?php }?> title="<?php echo Mage::helper('core')->quoteEscape($this->__('Ship to this address')) ?>" onclick="$('shipping:same_as_billing').checked = true;" class="radio" /><label for="billing:use_for_shipping_yes"><?php echo  $this->__('Ship to this address') ?></label>
</li>
<li class="control">
<input type="radio" name="billing[use_for_shipping]" id="billing:use_for_shipping_no" value="0"<?php if (!$this->isUseBillingAddressForShipping()) {?> checked="checked"<?php }?> title="<?php echo Mage::helper('core')->quoteEscape($this->__('Ship to different address')) ?>" onclick="$('shipping:same_as_billing').checked = false;" class="radio" /><label for="billing:use_for_shipping_no"><?php echo $this->__('Ship to different address') ?></label>
</li>

and replace this by

<li class="control">
   <input type="hidden" name="billing[use_for_shipping]" id="billing:use_for_shipping_yes" value="1"  />
</li>

Wednesday 19 September 2018

How to change url without reloading page in jQuery | Javascript | PHP

<?php
$actual_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$lastchar = substr($actual_link, -1);
if($lastchar == '/'){
$redirecturl = rtrim($actual_link,"/");
?>
<script>
    window.history.pushState('page2', 'Title', '<?php echo $redirecturl; ?>');
</script>
<?php } ?>