As per our business solutions or client requirements, we need to create custom product attributes. There are 2 ways to create custom product attributes: 1. From Admin Admin > Stores > Attributes: Product > Add New Attribute 2. Programmatically We can create custom product attributes using the InstallData setup script as well as using Data […]
How to create custom product attribute using Data Patch in Magento 2
Usually, we can check whether a customer is logged in via the Customer Session (Magento\Customer\Model\Session) class. Sometimes when a full-page cache is enabled, the generic class will not work as per our expectation. So in that case we can use HttpContext (Magento\Framework\App\Http\Context) class to check whether a customer is logged in or not. HttpContext class […]
Custom Attributes are the attributes that we can add with customized sources of available data types. In short, we can add Custom Attributes not available in built-in Magento. The Customer and Catalog entities use EAV entities and CustomAttributesDataInterface defines getCustomAttributes() and setCustomAttributes() methods. In this blog, we are getting an idea of how we can […]
Declarative Schema in Magento 2
4 years ago
Declarative schema is a new concept introduced in Magento 2.3. It makes the smooth process of database schema operations with fewer coding and execution steps. Before Magento 2.3, the following script files are used in the Setup directory of the module to perform DB management: InstallSchema.php: runs script when module is installed to the setup […]
Magento 2 + CMS block create via Data Patch
4 years ago
It’s easy to create a Cms Block via admin, but when code is moved to another server or in some cases of data loss, might be a chance to lose that block, and is not recoverable. Creating a CMS Block via data patch is easy to use, it will create automatically blocks when the source […]
Easy way to check whether customer logged in or not via customer Js component in phtml file. <div data-bind="scope: 'customer'"> <!-- ko if: customer().fullname --> Logged In customer <!-- /ko --> <!-- ko ifnot: customer().fullname --> Notlogged In customer <!-- /ko --> </div> <script type="text/x-magento-init"> { "*": { "Magento_Ui/js/core/app": { "components": { "customer": { "component": […]

