MageFever Blog

  1. Magento 2 Restrict Product From From Getting Add To Cart Programmatically

    We have to stop products from getting add to cart in certain situations like sell products based on customer group. This post will help you to implement that functionality in the easiest way.

    Read more »
  2. Disable payment method programmatically in Magento 2

    We have several situation where we need to disable payment method on basis of configuration or conditions. For example Cash On Delivery based on Zipcode where we need to disable payment method based on zipcode availibility. This post will guide you with simple steps so you may know how can we disable paymet method programmtically in magento.

    Read more »
  3. Magento 2 Data Patch and schema patches

    Hello Magento Lovers,

     

    Let's discuss Data Patch in this post. Data Patch is the replacement of the UpgradeData and InstallData. 

     

    A data patch is a class that contains data modification instructions. It is defined in a <Vendor>/<Module_Name>/Setup/Patch/Data/<Patch_Name>.php file and implements \Magento\Framework\Setup\Patch\DataPatchInterface.

    A schema patch contains custom schema modification instructions. These modifications can be complex. It is defined in a <Vendor>/<Module_Name>/Setup/Patch/Schema/<Patch_Name>.php file and implements \Magento\Framework\Setup\Patch\SchemaPatchInterface.

    Unlike the declarative schema approach, patches will only be applied once. A list of applied patches is stored in

    Read more »
  4. Magento 2 Create Table Using Declarative Schema db_schema.xml

    Magento 2 updates features and standards in order to simplify the process and improve security. Magento 2 has introduced the declarative schema. The new declarative schema approach allows developers to declare the final desired state of the database and has the system adjust to it automatically, without performing redundant operations.

    Read more »
  5. Magento 2 Convert number to currency format

    In Magento as an e-commerce platform, We need to deal with currency in our code. We often get numbers which we need to show as currency or process as currency.  This post will help you to convert all your number into a currency format.

    Read more »
  6. Magento 2 add toggle (yes-no) product attribute programmatically

    Hello Magento Lovers,

    I have described how to add toggle (yes/no) attribute to the product using the setup install script.

    We always need some features based on enable/disable or yes/no. Magento 2 has introduced a very attractive toggle button.

    It's very simple to add using a Script. We can use either Install Data / Upgrade Data file in the setup directory based on our requirement, whether we are creating a module from scratch or we are modifying the existing module.

    I have used InstallData.php in this post. 

     app/code/Vendor/Modulename/Setup/InstallData.php

        <?php
    
    namespace Vendor\Module\Setup;
    
    use Magento\Eav\Setup\EavSetup;
    use Magento\Eav\Setup\EavSetupFactory;
    use Magento\Framework\Setup\InstallDataInterface;
    use Magento\Framework\Setup\ModuleContextInterface;
    use Magento\Framework\Setup\ModuleDataSetupInterface;
    
    /**
     * Install Data
    Read more »
  7. Magento 2: Add Image Uploader to admin configuration

    Hello Magento Lovers,

    It's very simple to add Image uploader in admin configuration using system.xml

    In System.xml

    app/code/Magefever/ImageUpload/etc/adminhtml/system.xml

        <?xml version="1.0"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
    	<system>
    		<tab id="magentofever" translate="label" sortOrder="10">
    			<label>MageFever</label>
    		</tab>
    		<section id="magefever_main" translate="label" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="1">
    			<class>separator-top</class>
    			<label>Add Image Uploader to admin configurtion</label>
    			<tab>MagentoFever</tab>
    Read more »
  8. Magento 2: Add Dynamic FIelds in Admin Configuration

    Very often we need to save complex data like serialized data. We need such data on dynamic fields like a dynamic dropdown. If we save dynamic dropdown in separate fields then the burden on the database will be increased. To resolve this complexity serialized data are much useful.  Such dynamic fields are useful in form and configuration. I will show you how to add dynamic fields in the configuration in  this post

    Read more »