Magento 2
Magento 2 Tutorial / User Guide is a powerful toolkit that helps all store owner who is using Magento 2 platform to have a solid understanding. Latest News Learn more on Magento 2 Plugin & Class rewrite and Custom functionality with Me! I have shared here my Magento 2 customization and useful articles ad developer, it might help you.
-
Magento2 php8.1 extension install
Magento2 php8.1 extension install on magento 2.4.5.p1 open source version. Here using Ubuntu version 20.04 and magento version 2.4.5.p1 and Web server apache If you have already has another PHP version then do below process. At my system php7.4
-
Magento 2 create yes/no product attribute
magento 2 create yes/no product attribute and assigns to all attributes sets. Using Data patch installer. Your module must be a dependency on the Magento_Catalog module using module.xml. Example: Data match installer script:
-
Category page NOINDEX,NOFOLLOW when filters applied
Category page NOINDEX,NOFOLLOW when filters applied. Most websites are getting duplicated content issues at SEO when filters applied To avoid the issue we need to mark the category page’s meta robots value to `NOINDEX,NOFOLLOW` when the filter is applied on the category page. Defined an observer on event layout_generate_blocks_after The Observer class code will be Module is available at https://github.com/devamitbera/Magento2-extension/tree/master/Category-disallow/
-
Magento2 programmatically create coupon
In this article, i have explaining how to we can create coupon programmatically. At Magento 2, if you wish to create a coupon programatically . Follow below steps: First, you have to create a Cart Price rule/Shopping Cart rule. At, Second steps you will create coupon code. Advanced sales promotion rules like #free-gift, discount on #first-order, #nth-order, #total-sales-amount, #total-order-number #specific-customers #subscribers etc.http://bit.ly/M2-Sales-Promotion 1.Create Cart Price rules For a create rules, i have used repository interface classes: For set the data for rules repository class, we have use the interface This interface some setter methods using this setter method, using those method you can set discount percent/amount ,rules starting & ending…
-
Magento2 Checkout shipping address autofill
Magento2 Checkout shipping address autofill. If you want to Magento2 Checkout shipping address autofill during checkout then you have to use Magento 2 plugin. I have used plugin over on Class below classes for autofill checkout Shipping address: Magento\Checkout\Block\Checkout\AttributeMerger is main classis the main class where i able to auto fill firstname,lastname,street,city,postcode,country_id,region,region_id,telephone,companyabove fields value using after Create after Plugin (Devbera\AutofillCheckoutAddress\Plugin\Magento\Checkout::afterMerge ) on Magento\Checkout\Block\Checkout\AttributeMerger::merge for shipping address fields autofill up. Step1:Define Plugin classes: First Create di.xml at app/code/{VendorName}/{ModuleName}/etc/frontent where we are define the plugin classes. Code Step2: Declare plugin class Create First plugin class AttributeMergerPlugin.php at app/code/{VendorName}/{ModuleName}/Plugin/Magento/Checkout/ Code Second plugin class which will auto fill email id for NON _login customer Create seocnf…
-
Magento2 add a cms page link to menu
Magento2 add a cms page link to menu or add a link to the menu, Magento2 add a cms page link to the menu. If you are store owner/ developer then sometimes, you want to add a cms page link to menu of your Magento 2 store. Magento 2 does not provide any feature like add a Cms page to your existing menu. At default Magento, you can only add the categories to its menu. So, today I am writing this blog for how you add a cms page link to the menu. For this, you need some coding also. If you do not want to wish to do any…
-
Magento 2 import email address to Newsletter from csv
Magento 2 import email address to Newsletter from csv. I have a requirement to import email is from CSV and import the email ids to Newsletter Subscriber list from csv. Write a PHP script which will import Newsletter subscriber from CSV. In this script, first i have read the email ids from Csv , Then first check an email is exits as customer Using Magento\Customer\Api\AccountManagementInterface ‘s function isEmailAvailable($emailId,$websiteId) and depends on customer types Guest ( mean guest Not register) and register, i have added the email to subscriber list. For add an email to the subscriber list, we need to call factory class Magento\Newsletter\Model\SubscriberFactory and need to Customer.Guest customer use $_subscriberFactory->create()->subscribe($Email); and register customer ,use…
-
How to get magento2 base url
How to get magento2 base url. You want to get magento2 base url for your current store then you can follow this post. During your daily work, several time, you need to current store base url and at Magento 1.x version you can get base url using Mage::getBaseUrl();As Magento2, do not used factory patterns, so the code like Mage::getBaseUrl(); is not exist by which you can base URL.But at Magento2, you should use StoreManager object and using $this->_storeManager->getStore()->getBaseUrl() you can get base url. Magento2, use interface, injection of class, that you should Inject. Magento\Store\Model\StoreManagerInterface at Model, Resource model, Block, Helper classes for getting base url using below code: $objectManager = \Magento\Framework\App\ObjectManager::getInstance();…
-
Magento2 get admin url
Magento2 get admin URL Magento2 get admin url.If want to get admin URL to Magento 2 then you can try below Solution In order to get admin URL ,you need to inject the Magento_Backend ‘s helper class Magento\Backend\Helper\Data to __construct() function. /** * @var Magento\Backend\Helper\Data */ protected $HelperBackend; public function __construct( .... \Magento\Backend\Helper\Data $HelperBackend .... ) { ... $this->HelperBackend = $HelperBackend; ... } /** * * @param \Magento\Framework\Event\Observer $observer * @return void */ public function getAdminUrl() { echo $this->HelperBackend->getHomePageUrl(); } Here you will get Magento 2 get admin url from getAdminUrl() which basically return Magento_Backend module’s getHomePageUrl() function, This function also given admin home page url.