As we know, there are so many situation where we require to check whether customer is currently logged in or not. In this blog post you will learn about how to check customer is logged in or not in Magento 2. In order to check this situation you can use below code snippet.
/** @var \Magento\Framework\App\ObjectManager $om */
$om = \Magento\Framework\App\ObjectManager::getInstance();
/** @var \Magento\Framework\App\Http\Context $context */
$context = $om->get('Magento\Framework\App\Http\Context');
/** @var bool $isLoggedIn */
$isLoggedIn = $context->getValue(\Magento\Customer\Model\Context::CONTEXT_AUTH);
Once you got the result in $isLoggedIn variable, you can check condition as per below.
// If customer is logged in
// Some code snippet here
PHP is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML. Developers are always looking for ways to improve their skills, and taking advantage of PHP’s versatility is a great way to create more robust and efficient code. There are many things that you can do to make your next project more readable and maintainable. Below are tips to
In Magento 1.x, store owner can directly do reindex from Index management. But in Magento 2.x there is no direct options available for Reindex from backend. As Magento 2.x provides reindex using command line. So lets discuss about how to do reindex using command line. If you need to do whole index management in the Magento 2.x store, then you have to run the following command. First go to magento
Magento by default provides us a very good template for displaying different different pages. It also provides variety of layout files to display different pages with different different layouts. But for our convenience we need to do some modifications in the default layout of magento. One of the most common issue for product display is how to show 4 products instead of 3 in a row in magento. Because, magento
Every time you log in to the Magento Admin Panel, you will see an admin magento notification popop message.From the developer point of view, it’s best way to stay informed about new updates. But end client never like these pop up on every login about which they don’t know anything. In this post I will show you how to disable Admin Notification Popup. This popup functionality is provided by one