Magento 2 create category attribute using upgradeData
Today we discuss about the Magento 2 create category attribute using upgradeData using the script. We are creating a select box category attribute using the below steps. Increase the module version from 1.0.0 to 1.0.1 in module.xml filePath: app/code/Custom/CategoryAttribute/etc/module.xml <?xml version=”1.0″ ?> <config xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation=”urn:magento:framework:Module/etc/module.xsd”> <module name=”Custom_CategoryAttribute” setup_version=”1.0.1″> <sequence> <module name=”Magento_Catalog”/> </sequence> </module> </config> Create […]
Print HTML Content using JavaScript
Today we discuss about the Print HTML Content using JavaScript.To print the content page or page with dynamic html.The document.write() method is used to write data to the tag of your HTML document. JavaScript code example var mywindow = window.open(”, ‘Printing example’, ‘height=400,width=600’); mywindow.document.write(‘<html><head><title>Print demo</title>’); /*optional stylesheet*/ //mywindow.document.write(‘<link rel=”stylesheet” href=”main.css” type=”text/css” />’); mywindow.document.write(‘</head><body>’); mywindow.document.write(‘<div>I am […]
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() { […]