Posts

Showing posts from December, 2020

How to override js in magento 2

 How to override js in magento 2 To override js we need requirejs-config.js requirejs-config.js need to create at [Vendor]/[Module]/view/frontend/requirejs-config.js var config = {     map: {         '*': {             'Magento_Checkout/js/model/shipping-rates-validator':'Vendor_Module/js/model/shipping-rates-validator'         }     } }; Create file at app/code/Vendor/Module/view/frontend/web/js/model/shipping-rates-validator.js Write your inside file and boom!!!  If developer mode is on and symlinks are generating clear cache bin/magento cache:clean If production mode is on , need to deploy static content files using command bin/magento s:s:d  If like efforts, Please share, comment and subscribe for future posts and inspire more.

Adding custom attribute to Customer

Adding custom attribute to Customer Create InstallData.php file at app/code/{Vendor}/{Module Name}/Setup/InstallData.php <?php namespace Hello\CustomerAttribute\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; use Magento\Eav\Model\Config; use Magento\Customer\Model\Customer; class InstallData implements InstallDataInterface { private $eavSetupFactory; public function __construct(EavSetupFactory $eavSetupFactory, Config $eavConfig) { $this->eavSetupFactory = $eavSetupFactory; $this->eavConfig       = $eavConfig; } public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]); $eavSetup->addAttribute( \Magento\Customer\Model\Customer::ENTITY, 'mobil

Magento 2 Add Product Attribute Programmatically

 Magento 2 Add Product Attribute Programmatically Create file InstallData.php at app/code/Vendor/Module/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; class InstallData implements InstallDataInterface { private $eavSetupFactory; public function __construct(EavSetupFactory $eavSetupFactory) { $this->eavSetupFactory = $eavSetupFactory; } public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]); $eavSetup->addAttribute( \Magento\Catalog\Model\Product::ENTITY, 'brand_attribute', [ 'type' => 'text', 'backend' => '', 'frontend' =&g