Create category custom layout in Magento 2
Today we discuss to create a category custom layout in Magento2 Create layout.xml fine in your theme app/design/frontend/ABC/XYZ/Magento_Theme/layouts.xml <page_layouts xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation=”urn:magento:framework:View/PageLayout/etc/layouts.xsd”> <layout id=”customlayout”> <label translate=”true”>Custom Layout Page</label> </layout> </page_layouts> Layout id = customlayout Create customlayout.xml file, Layout id name file name will same. app/design/frontend/ABC/XYZ/Magento_Theme/page_layout/customlayout.xml <?xml version=”1.0″?> <layout xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation=”urn:magento:framework:View/Layout/etc/page_layout.xsd”> <update handle=”empty”/> <referenceContainer name=”page.wrapper”> <container name=”header.container” […]
Integrate MailChimp API with PHP
Today, We will tell you how to integrate MailChimp API with PHP.Subscribers add to Mailchimp using their API using PHP cURL.Mailchimp is a popular email marketing tool(service) that manages subscribers.Using Mailchimp, you can send an email like announcements or offers. Requirement API key from the Mailchimp List id from the Mailchimp Customer data sent to […]
Product price in Magento 2
Get product price in Magento 2, Get Product Price Including Tax, get the special price of products in Magento 2. 1.Magento 2 get Product Price Including Tax <?php namespace Vendor\Module\Helper; use Magento\Framework\App\Helper\AbstractHelper; use Magento\Framework\App\Helper\Context; use Magento\Catalog\Model\Product; use Magento\Catalog\Helper\Data as TaxHelper; class Data extends AbstractHelper { protected $productModel; protected $taxHelper; public function __construct( Context $context, Product […]
Magento 2 Product update programmatically
Sometime we need to Magento 2 product update programmatically, like we want to update metatitle and meta description of the all products using the script. Create “Myscript.php” file on the root and paste the below code.Execute from the terminal “php Myscript.php“ <?php use Magento\Framework\App\Bootstrap; require ‘app/bootstrap.php’; $bootstrap = Bootstrap::create(BP, $_SERVER); $objectManager = $bootstrap->getObjectManager(); $state = […]
Image lazy loading using JS
Image lazy loading using JS, improve your website speed. Lazy loading images JavaScript Background-image lazy load Lazy load images jQuery Piece of html code // jquery librabray <script src=”https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js”></script> <img class=”lazy” data-src=”http://example.com/image.png” /> <img class=”lazy” data-src=”http://example.com/image.png” /> <img class=”lazy” data-src=”http://example.com/image.png” /> <img class=”lazy” data-src=”http://example.com/image.png” /> jQuery code setTimeout(function() { lazyLoadImages( $(‘.lazy’) ); }, 100); var […]
Add class or attribute in jQueryAdd class or attribute in jQuery
Hello, Reader today we discuss the add class or attribute in jQuery.Sometimes developers need to add a custom class or attribute on the element after the page load or clicked somewhere to perform functionality according to the need. 1. Add random class or attribute on the drop-down options var counterOption = 0; jQuery(“select”).each( function (){ […]
Magento2 admin login programmatically
Sometimes we need Magento2 admin login programmatically.If you forgot the password of the admin and you have a username then you create an Admin.php file and paste the below code. After creating the file put it into the website running directory like pub.Now hit the file like http://example.com/Admin.php Code of the Admin.php file <?php use […]
Add/Remove Class in Javascript
Add/Remove Class in Javascript, we will use “classList” function. When a user clicks on the element, then a class will be added to that element.Apply your logic using the newly added class, like show hide another div to attract the user. HTML code <!DOCTYPE html> <html> <head> <title></title> </head> <body> <div id=”close-container”> <button id=”my_button”> My […]
Magento2 setup with breeze
Magento2 setup with breeze, Why Breeze : Breeze module offers Magento alternative js frontend. It makes your store 3 times faster. It brings your website closer to a high Google Page Speed score. The goal of the Breeze module is to boost the default Luma theme performance via replacing all scripts with simplified versions. It […]
Detect device in jQuery
Sometime we need to detect device in jQuery to identify the screen, To add some extra or different logic according to the requirement. 5 ways to detect the mobile Devices in jQuery Solution 1:- Using navigator userAgent. if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) { // mobile device code } Solution 2:- Using window matchMedia method $(function() { […]
Magento 2 rest api
Today we discuss the Magento 2 rest API. API is also called web services. API stands for the Application programming interface Proccess of the prodcut add to cart usign rest API Create customer token Create an empty cart/quote using the token Add to product to the cart Fetch cart details Fetch cart totals Apply coupon […]
Add Product With Custom Options To Cart Graphql in Magento 2
Add product to cart GraphQL Magento 2 Add product to cart GraphQL Magento 2 or Add Simple Product With Custom Options To Cart in Magento2 Method Post AUTHORIZATION Bearer Token BODY graphql mutation { addSimpleProductsToCart( input: { cart_id: “ctxNWM4yYu4udYCUm8TSeXZOdv7VXv72” cart_items: [ { data: { quantity: 1 sku: “test” } customizable_options: { id: 16, value_string: “28” […]