Thursday 11 October 2018

How to redirect www to non www AND http to https in AWS .htaccess


AWS WWW to non WWW redirection
RewriteEngine On
RewriteCond %{SERVER_NAME} =www.example.com
RewriteRule ^.*$ https://example.com%{REQUEST_URI}
AWS HTTP to HTTPS redirection
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^.*$ https://example.com%{REQUEST_URI}
AWS WWW to non WWW and HTTP to HTTPS
RewriteEngine On
RewriteCond %{SERVER_NAME} =www.example.com
RewriteRule ^.*$ https://example.com%{REQUEST_URI}
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^.*$ https://example.com%{REQUEST_URI}

Friday 5 October 2018

How to get list of all categories array tree view in Magento 1

Call Category function

$categories = $this->getTreeCategories(2, false);
print_r($categories);
Get All categories array tree view

function getTreeCategories($parentId, $isChild) {
     
        $allCats = Mage::getModel('catalog/category')->getCollection()
                ->addAttributeToSelect('*')
                ->addAttributeToFilter('is_active', '1')
                ->addAttributeToFilter('include_in_menu', '1')
                ->addAttributeToFilter('parent_id', array('eq' => $parentId));
        $subcat = ($isChild) ? "  -- " : "";
        foreach ($allCats as $category) {
            $options[] = array(
                'label' => Mage::helper('jaydip_attrfiltercount')->__($subcat.iconv(mb_detect_encoding($category->getName(), mb_detect_order(), true), "UTF-8", $category->getName())),
                'value' => $category->getId()
            );
            $subcats = $category->getChildren();
            if ($subcats != '') {
                $options[] = $this->getTreeCategories($category->getId(), true);
            }
        }
        $optiondata = array();
        foreach ($options as $option):
            if(isset($option[0])){
             
                foreach ($option as $value):
                    $optiondata[] = array(
                        'label' => $value['label'],
                        'value' => $value['value']
                    );
                endforeach;
             
            }else{
                $optiondata[] = array(
                    'label' => $option['label'],
                    'value' => $option['value']
                );
            }
        endforeach;
     
        return $optiondata;
    }

Tuesday 2 October 2018

Product image Still zoom if I remove mouse cursor from image in magento 2

You need to replace the code of lib/web/magnifier/magnifier.js in your theme as below.

Find

$(document).on('mousemove', onMousemove);
_init($box, gOptions);

Replace

$box.on('mousemove', onMousemove);
       
/*Code By Jaydip*/
$box.on('mouseleave', mouseleave);
    function mouseleave(e) {
         onThumbLeave();
         isOverThumb = false;
         $magnifierPreview.addClass(MagnifyCls.magnifyHidden);
    }
/*Code By Jaydip*/
       
 _init($box, customUserOptions);