Need to block some CMS pages from the non-logged-in customersUsing an observer and Events Getting the page ID or page identifier
Category: Magento
Call Phtml file on CMS Page – Magento2
We can create a layout file on the frontend using the block or pages from magetno admin panel here the trick used to create that. all phtml using block code login to magento admin. Open any cms page and write block code in content section. Here we called an external phtml file to a page… Continue reading Call Phtml file on CMS Page – Magento2
How to Add Product To Cart With Custom Price in Magento 2
Steps to Add Product To Cart With Custom Price in Magento 2 Step 1: First, create a file “events.xml” at the below-given path. appcodeVendorExtensionetcfrontendevents.xml Now add the below code Step 2: Now, we need one more file named “Customprice.php” that overrides our price. Go to the below path appcodeVendorExtensionObserverCustomprice.php And finally, add the code as mentioned below, <?php namespace VendorExtensionObserver; use… Continue reading How to Add Product To Cart With Custom Price in Magento 2
How to configure Magento with PWA
Disable a shipping method based on a condition
Here we’re considering the ordertotal of the cart. di.xml file
How To Change Welcome Message In Magento 2
Steps to Change Welcome Message In Magento 2: Login to the Admin panel Navigate to Content > Design > Configuration Edit the store view for which you want to change the default welcome message in the Magento 2 store Expand the Header section Input your custom welcome message in the Welcome Text field Save the configuration
DB schema method in Magento2
DB schema method is used to create tables or columns inside a table. create dbschema.xml inside app/code/vendor/module/etc/ It will create a table named declarative_table. Thank you.
How do call the quote subtotal inside a custom shipping method?
To call the quote total inside a custom shipping method On the collect function public function collect( \Magento\Quote\Model\Quote\Address\Total $total ) { parent::collect($quote, $shippingAssignment, $total); $orderTotal = $total->getSubtotal(); } Thank you.
Block IP or bots in the Cloudways server
Block the IP on Htaccess file <Limit GET POST>order allow,denydeny from 46.228.47.114deny from 46.225.88.5allow from all</Limit> Block bots using the Htacess file with name RewriteCond %{HTTP_USER_AGENT} Mj12bot [NC]RewriteCond %{HTTP_USER_AGENT} Dotbot [NC] Thank you.
How to create new credentials for Magento admin.
create a new admin user. bin/magento admin:user:create –admin-user=admin –admin-password=newpass123 –admin-email=admin@example.com –admin-firstname=John –admin-lastname=Doe Clear Cache: bin/magento cache:clean bin/magento admin:user:create –admin-user=admin12 –admin-password=admin@12 –admin-email=admin@example.com –admin-firstname=Jerin –admin-lastname=m