Skip to main content

Posts

Magento 2 - Check If Customer Login Or Not

Magento 2 - Check If Customer Login Or Not
protected $customerSession;

public function __construct(
    \Magento\Customer\Model\SessionFactory $customerSession
) {
    $this->customerSession = $customerSession;
}
public function isLoggedIn()
{
    return $this->customerSession->create()->isLoggedIn();
}
use isLoggedIn() to check customer login or not
Recent posts

Magento 2 - Get Current Cart Items

Magento 2 - Get Current Cart Items:

use the session to get the quote 
public function __construct(
        ...
        Magento\Checkout\Model\Session $session
        ...
    ) {
        ...
        $this->_session = $session;
        ...
    }


public function yourFunctionName()
{
    $items = $this->_session->getQuote()->getAllVisibleItems();
}

NOTE : Magento\Checkout\Model\Cart is deprecated.

Magento 2 - Setup Magento 2 PWA

Setup PWA (Linux os)Step 1 : Install magento 2.3.1Step 2 : Install/upgrade nodeUse n module from npm in order to upgrade nodesudo npm install n -gFor the latest stable version:sudo n stableFor the latest version:sudo n latestStep 3: Install/update yarn :sudo npm install --global yarn sudo npm upgrade --global yarn

Magento 2 - Set different theme on mobile devices

By Setting up different themes on different mobile devices you can increase user experience and speed up the website on mobile. 
For configuring it, Please have a look on the video. https://youtu.be/v7R46oqkPBs