How to Get Logged in Customer Data in Magento 2

You can use \Magento\Customer\Model\Session to get the current customer id. First import this class to get the customer session, after this you will be able to get the customer session data. Here is an example how to get the customer id from customer session – Magento 2 Get Current Customer Id Example: <?php namespace Tutorialsplane\HelloWorld\Controller\Index; class Index… Continue reading How to Get Logged in Customer Data in Magento 2

Published
Categorized as Magento

Add google analytics code in magento2

To add google analytics code in Magento2Log in to Magento Backend On the Admin sidebar, go to Stores > Settings > Configuration. In the left panel, expand Sales and choose Google API. Expand  the Google Analytics section and do the following: Set Enable to Yes. Enter your Google Analytics Account Number. If you want to conduct A/B testing and other performance tests on your content, set Content Experiments to Yes. When complete, click Save Config.

Published
Categorized as Magento

Update minicart section after adding a product

whenever we add a product from custom plp page or custom page, auto update to cart is not enabled from magento. Adding the following code to the script will enable auto update of the cart section in any page. This can be also used with ajax call also to update the minicart section after adding… Continue reading Update minicart section after adding a product

How to Create a Custom Module and To Add A Column To Existing Database Table In Magento 2

Step1: Follow these steps to create a module: Create the module folder. Create the etc/module.xml file. Create the registration.php file. Run the bin/magento setup:upgrade script to install the new module. Check if the module is working. Method To Add A Column To Existing Database Table In Magento 2: Step 1: Create a file called ‘InstallSchema.php’ in the setup folder of the module,… Continue reading How to Create a Custom Module and To Add A Column To Existing Database Table In Magento 2

Published
Categorized as Magento