Posts

Magento 2 How to Identify Payment method is offline or online after place order

Offline Payment methods are Cash on delivery, Check/Money order, Bank transfer.

Online Payment methods are Amazon,Braintree,Paypal, Authorize.net and many more online payments available.

You can check payment method is offline or online using programmatically by

$order->getPayment()->getMethodInstance()->isOffline()
result will offline payment method with 0 or 1.

please check with below code for Observer. event name is sales_order_place_after

public function execute(\Magento\Framework\Event\Observer $observer) { $order = $observer->getOrder(); $isOffline = $order->getPayment()->getMethodInstance()->isOffline(); if ($isOffline) { echo __('offline'); } else { echo __('online'); } }

How to delete cookies in Magento 2?

In magento you can delete cookies via Magento\Framework\Stdlib\CookieManagerInterface interface class.

You can delete cookie using cookiesdelete() function from CookieManagerInterface Interface.

If you have set the cookie using cookie’s $metadata property, You need to inject Magento\Framework\Stdlib\Cookie\CookieMetadataFactory factory in your class to delete the cookie.

<?php namespace Itsmage\DeleteCookie\Model; class Cookie { /** * @var \Magento\Framework\Stdlib\CookieManagerInterface CookieManagerInterface */ private $cookieManager; /** * @var \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory CookieMetadataFactory */ private $cookieMetadataFactory; public function __construct( \Magento\Framework\Stdlib\CookieManagerInterface $cookieManager, \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory ) { $this->cookieManager = $cookieManager; $this->cookieMetadataFactory =…

Magento 2 Events Observer lists

Check with below lists of all the events dispatched that you can observe in your Magento2 web store.

Magento 2 Events Observer lists:

'adminhtml_cache_flush_all' 'adminhtml_cache_flush_system' 'backend_auth_user_login_success', ['user' => $this->getCredentialStorage()] 'backend_auth_user_login_failed', ['user_name' => $username, 'exception' => $e] 'backend_auth_user_login_failed', ['user_name' => $username, 'exception' => $e] 'adminhtml_store_edit_form_prepare_form', ['block' => $this] 'adminhtml_block_html_before', ['block' => $this] 'backend_block_widget_grid_prepare_grid_before', ['grid' => $this, 'collection' => $this->getCollection()] 'theme_save_after' 'store_group_save', ['group' => $groupModel] 'store_delete', ['store' => $model] 'adminhtml_cache_flush_system'…

Redirect request with POST data using .htaccess

RewriteEngine on
RewriteCond %{SERVER_PORT} !443
RewriteCond %{REQUEST_URI} string_to_match_in_url
RewriteCond %{REQUEST_METHOD} POST
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [L,R=307]

The first RewriteCond checks if the request is NOT coming as HTTPS, otherwise it will go in endless loop. If yes, the second RewriteCond checks if the URL contains a string we are looking for. Then if that URL is being submitted as POST method. If everything matches, then we redirect the request using HTTPS secure protocol retaining the POST method and the associated data.

Magento2 basic interview questions and answers.

The Differences Between Magento 1 and Magento 2 Magento1 : API Added Retroactively Flexible Architecture No Front-end Library Legacy PHP No Support for HTML5/CSS3 Weak Content Staging Full Page Cache (EE) JS – Prototype Legacy Checkout Magento2 : API is Core to the technology New Architecture for Speed Ships with LESS PHP5.6+ / 7.0 Native Support HTML5/CSS3 Advanced Content Staging FPC (EE)/Varnish JS – Jquery Streamlined Checkout Process Which command is used to enable or disable a magento2 module ? php bin/magento module:enable NameSpace_ModuleName php bin/magento module:disable NameSpace_ModuleName Which files are necessary to install – upgrade database tables and to records in it? Normally, there are four files for this listed below 1.InstallSchema 2.UpgradeSchema 3.InstallData 4.UpgradeData What are the recommended steps to be followed before Magento2 programming? Before development starts, disable whole cache. Set Development mode as SetEnv MAGE_MODE developer in .htacces or run t…

HIDE A FOLDER IN ANY OPERATING SYSTEM

PASSWORD PROTECT FOLDER WITHOUT USING ANY SOFTWARE IN WINDOWS

How to create the batch file to lock a folder
1.Copy and paste the following codes in a notepad file.

cls
@ECHO OFF
title Folder Confidential
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
if NOT EXIST Confidential goto MDLOCKER
:CONFIRM
echo Are you sure you want to lock the folder(Y/N)
set/p "cho=>"
if %cho%==Y goto LOCK
if %cho%==y goto LOCK
if %cho%==n goto END
if %cho%==N goto END
echo Invalid choice.
goto CONFIRM
:LOCK
ren Confidential "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
echo Folder locked
goto End
:UNLOCK
echo Enter the Password to unlock folder
set/p "pass=>"
if NOT %pass%== REPLACE THIS PORTION WITH YOUR PASSWORD goto FAIL
attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" Conf…