Magento 2 Redirect disabled product to other URL
Magento 2 Redirect Disabled Product To Other URL, You can achieve this functionality using override Magento\Cms\Controller\Noroute\Index controller Create di.xml filePath: app/code/VenderName/ModuleName/etc/di.xml <?xml version=”1.0″?> <config xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation=”urn:magento:framework:ObjectManager/etc/config.xsd”> <preference for=”Magento\Cms\Controller\Noroute\Index” type=”VenderName\ModuleName\Rewrite\Controller\Noroute\Index” /> </config> Create Index.php filePath: app/code/VenderName/ModuleName/Rewrite/Controller/Noroute/Index.php <?php /** * * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace VenderName\ModuleName\Rewrite\Controller\Noroute; […]
Magento 2 allow Country on checkout
today we discuss about the, Magento 2 allow Country on checkout.This article helps to store owners to restrict countries to place order by the customer is restricted in some countries.Display only the countries you ship to on checkout in magento2. Method 1 Log in to the Magento admin panel and navigate to Stores > Configuration […]
Magento 2 customer data in CSV using script
Magento 2 customer data in CSV using root script, or get customer data in a CSV file from MySQL Create “myscript.php” file on Magento root or pub directory and add below code.Execute this file from terminal like “php myscript.php“ or hit the URL like “example.com/myscript.php“You can find the CSV file in pub/media/ folder. use Magento\Framework\App\Bootstrap; […]
Image preview before upload using jQuery
Image preview before upload using jQuery. Show the image before uploading it on the server using jQuery, This article explains how to preview an image before uploading. Allowed File Extensions while image upload using “allowedFileExtensions“ HTML code <input type=”file” class=”form-control” id=”file_attache” placeholder=”file attache” name=”file_attache”> jQuery code $(“#file_attache”).fileinput({ overwriteInitial: true, maxFileSize: 2500, showClose: false, showCaption: false, […]
Magento 2 save data in custom table
Today we discuss the Magento 2 save data in the custom table. How to insert data into a custom table using the model.And update data into database by sending id of the data.You can send data clicking on button and reload the page.If you do not want refresh or reload the page during the insert […]
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 […]