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() { […]
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” […]
Top 5 image optimizer tools
Today we share the top 5 image optimizer tools which are used for the reduced size of the images without installing any software.Purpose of the image optimization is to improve the speed of web pages.Image optimization also improves your SEO ranking.Using image optimizer tools get a higher Lighthouse score and increase your visibility.You can reduce […]
Magento 2 product image in new order email
Today we discuss about display product image in new order email.Sometimes you want to add an image of the product in the mail send after a place order. You will need add some code into this file :- File : vendor/magento/module-sales/view/frontend/templates/email/items/order/default.phtml Override 1:- Override above core file into theme app/design/frontend/[VENDOR]/[TEMPLATE]/Magento_Sales/templates/email/items/order/default.phtml Override 2:- Override above core […]
Syntax error unexpected eof in Graphql
Hello, reader today I will tell about syntax error unexpected EOF in graphql Magento 2. Sometimes you get this error message from postman when running a GraphQL query. Error : “Syntax Error: Unexpected <EOF> “ Solution 1 Method to be POST Solution 2 Header field Content-Type to be application/json Solution 3 Check your passing query […]
Magento 2 rtrim() expects parameter 1 to be string
Error : rtrim() expects parameter 1 to be string, bool given#0 ./vendor/magento/framework/Encryption/Adapter/Mcrypt.php(171): rtrim() Solution 1:- I just installed it on my server using apt install php7.4-mcrypt Restert apache server :- service apache2 restart Check php installed extention php -m Solution 2:- Run below command rm -rf var/cache/ generation/ chmod 777 -R var/ pub/ generated/ Related […]
Magento 2 success and error message
Today, we describe success and error messages in Magento 2. messageManagerDisplay success and error messages with the help of the messageManager object . protected messageManager; public function __construct( ——— \Magento\Framework\Message\ManagerInterface $messageManager, ——— ){ $this->messageManager = $messageManager; } public function myFucntion(){ $message =$this->messageManager->addError(__(“Error message”)); $message =$this->messageManager->addWarning(__(“Warning message”)); $message =$this->messageManager->addNotice(__(“Notice message”)); $message =$this->messageManager->addSuccess(__(“Success message”)); return $message; } […]
magento2 get category image
Today we will learn about magento2 get category image in phtml file. I have Used This code to get Category images in my code Please look at these. I am using this module Myvendor/Mymodule. Solution 1 File: app/code/Myvendor/Mymodule/Block/Home/Category.php namespace Myvendor\Mymodule\Block\Home; use Magento\Framework\View\Element\Template\Context; use Magento\Catalog\ViewModel\Category\Image; class Category extends \Magento\Framework\View\Element\Template { public $image; public function __construct( Context […]
Magento 2.4 newsletter using ajax
Magento 2.4 newsletter using ajax, Customers subscribe to the newsletter in your store for any reason, they will get message near to newsletter. Steps to AJAX Newsletter in Magento 2: 1 Create di.xml at MyVendor/MyModule/etc folder <?xml version=”1.0″?> <config xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation=”urn:magento:framework:ObjectManager/etc/config.xsd”> <type name=”Magento\Newsletter\Controller\Subscriber\NewAction”> <plugin name=”custom_Subscriber_NewAction” type=”MyVendor\MyModule\Plugin\Controller\Subscriber\NewAction” sortOrder=”10″ disabled=”false” /> </type> </config> 2. Create NewAction.php at […]
Get block attribute value in phtml
Add block in your CMS page or CMS block {{block type=”Myvendor\Mymodule\Block\Index” template=”Myvendor_Mymodule::index.phtml” deskdisplay=”4″ tabletdisplay=”2″ mobiledisplay=”1″}} In Your phtml file get the attribute value. echo $deskDisplay = $block->getData(“deskdisplay”); Related Post : Create enquiry form in Magento 2 Like us on Facebook and Linkedin for more updates.
Magento2.4 run from root
We will discuss how to execute the Magento2.4 run from root.Magent2.4.x by default does not load from the root of Magento. 404 Not Found after fresh Magento 2.4 installation It seems now Magento will only load from pub folder. So the best solution for this is to create a virtual host and point it to […]
Magento 2 send custom email programmatically
Hello reader, In this article, we are going to send a custom email template, after creating a form, on submission of that form we will send form information by sending a custom email. This email will use custom email template. Email is a way to communicate with customers and suppliers or vice-versa The below files […]