To work out the customer id and customer details in a custom module we need to call a reference container in the layout page. Here an example showing a reference container of custom Quote Block Use Cacheable to fetch each customer logged in or not and get the customer Id to custom module.
Author: Bibin Johnson
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
Calling admin Panel product placeholder image to frontend.
Here we can take the object manager to get the backend placeholder url of the image. It can be done with block or $objectmanager within the phtml file. For getting the Repositories we need to add some code to pull it to our phtml file. For calling $imageHelper Lib for all repositories we can use… Continue reading Calling admin Panel product placeholder image to frontend.
Using CheckBoxes for products in PLP Page -magento
Here we are trying to use checkboxes for the products and select a product individually from the list All the opertions are taking place at Magento_Catalog/product/list.phtml Here is script for making a single selection of the product: we also need to link a jqurey api of cloudflare for this functionality. it is linked using require.js… Continue reading Using CheckBoxes for products in PLP Page -magento
How to Add EAV Attribute in Magento 2
Magento supports two types of attributes including EAV attributes and extension attributes that provide extra functionalities for your stores. In this post, you will get an overview about EAV attributes and detailed instruction in how to add EAV attribute in Magento 2. Construct function is must for EAV attribute add to controller Setting EAV attribute… Continue reading How to Add EAV Attribute in Magento 2
Getting Product image from product Id -magento 2
Here is an example how to get the product image from the backend to frontend website page. This is the code you can use in your phtml file to get the image from the _product collection. In the head section we have to add two lib- For additional sections you can also add some custom… Continue reading Getting Product image from product Id -magento 2
How to add observer to customer edited details.
Create a custom module n the code folder,here we are going to override the EDITPOST file from the magento-customer/controller/account . EditPost.php here added first name and last name to the event dispatch Here my vendor name is JJ and module name is Customerupdate di.xml for the module etc/frontend events.xml Observer folder contains EDITCUSTOMER.php
Adding custom fields to customer Registration form
Create a Vendor and Module folder in app/code. Here an example of vendor name : JJ and module name : Customer to add a custom input field for Phone Number This is added to get the custom field in the customer create and customer edit pages. registration.php : Setup / Installdata.php Etc/module.xml view/frontend/layout/default.xml view/frontend/templates/additional.phtml Here… Continue reading Adding custom fields to customer Registration form
How to Add Pagination in Magento 2 Custom Collection
Pagination is the process of separating print or digital content into discrete pages. It is an ordinal numbering of pages, which is usually located at the bottom of the site pages. Pagination also refers to the automated process of adding consecutive numbers to identify the sequential order of pages. Some types of website content benefit… Continue reading How to Add Pagination in Magento 2 Custom Collection
Get store e-mail in phtml file in Magneto 2
To get store email id to phtml file create a php tag to input the email field to the project. For creating a php tag must be imported and it must contain the following code to retrieve the store email address. the output for the code will be the store email address.